@snap/camera-kit 1.0.0 → 1.1.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 (264) hide show
  1. package/README.md +1 -1
  2. package/dist/CameraKit.d.ts +4 -0
  3. package/dist/CameraKit.d.ts.map +1 -1
  4. package/dist/CameraKit.js +8 -2
  5. package/dist/CameraKit.js.map +1 -1
  6. package/dist/RootServices.d.ts +4 -2
  7. package/dist/RootServices.d.ts.map +1 -1
  8. package/dist/RootServices.js.map +1 -1
  9. package/dist/bootstrapCameraKit.d.ts.map +1 -1
  10. package/dist/bootstrapCameraKit.js +4 -2
  11. package/dist/bootstrapCameraKit.js.map +1 -1
  12. package/dist/clients/remoteApiSpecsClient.d.ts +10 -0
  13. package/dist/clients/remoteApiSpecsClient.d.ts.map +1 -0
  14. package/dist/clients/remoteApiSpecsClient.js +6 -0
  15. package/dist/clients/remoteApiSpecsClient.js.map +1 -0
  16. package/dist/common/typeguards.d.ts +3 -0
  17. package/dist/common/typeguards.d.ts.map +1 -1
  18. package/dist/common/typeguards.js +12 -0
  19. package/dist/common/typeguards.js.map +1 -1
  20. package/dist/configuration.d.ts +115 -0
  21. package/dist/configuration.d.ts.map +1 -1
  22. package/dist/configuration.js +1 -0
  23. package/dist/configuration.js.map +1 -1
  24. package/dist/environment.js +1 -1
  25. package/dist/environment.js.map +1 -1
  26. package/dist/index.d.ts +3 -3
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +3 -3
  29. package/dist/index.js.map +1 -1
  30. package/dist/lensCoreWasmVersions.js +3 -3
  31. package/dist/lensCoreWasmVersions.js.map +1 -1
  32. package/dist/session/LensKeyboard.d.ts +1 -1
  33. package/dist/session/LensKeyboard.d.ts.map +1 -1
  34. package/dist/session/LensKeyboard.js.map +1 -1
  35. package/dist/uri-handlers/UriHandlers.d.ts.map +1 -0
  36. package/dist/uri-handlers/UriHandlers.js.map +1 -0
  37. package/dist/uri-handlers/internal-handlers/httpUriHandler.d.ts +35 -0
  38. package/dist/uri-handlers/internal-handlers/httpUriHandler.d.ts.map +1 -0
  39. package/dist/uri-handlers/internal-handlers/httpUriHandler.js +144 -0
  40. package/dist/uri-handlers/internal-handlers/httpUriHandler.js.map +1 -0
  41. package/dist/uri-handlers/internal-handlers/httpValidators.d.ts +9 -0
  42. package/dist/uri-handlers/internal-handlers/httpValidators.d.ts.map +1 -0
  43. package/dist/uri-handlers/internal-handlers/httpValidators.js +115 -0
  44. package/dist/uri-handlers/internal-handlers/httpValidators.js.map +1 -0
  45. package/dist/{extensions/RemoteApiServices.d.ts → uri-handlers/internal-handlers/remoteApiUriHandler.d.ts} +8 -8
  46. package/dist/uri-handlers/internal-handlers/remoteApiUriHandler.d.ts.map +1 -0
  47. package/dist/uri-handlers/internal-handlers/remoteApiUriHandler.js +121 -0
  48. package/dist/uri-handlers/internal-handlers/remoteApiUriHandler.js.map +1 -0
  49. package/dist/{extensions → uri-handlers}/uriHandlersRegister.d.ts +6 -4
  50. package/dist/uri-handlers/uriHandlersRegister.d.ts.map +1 -0
  51. package/dist/{extensions → uri-handlers}/uriHandlersRegister.js +13 -3
  52. package/dist/uri-handlers/uriHandlersRegister.js.map +1 -0
  53. package/dist/uri-handlers/uriRequestProcessor.d.ts +37 -0
  54. package/dist/uri-handlers/uriRequestProcessor.d.ts.map +1 -0
  55. package/dist/uri-handlers/uriRequestProcessor.js +69 -0
  56. package/dist/uri-handlers/uriRequestProcessor.js.map +1 -0
  57. package/docs/html/assets/hierarchy.js +1 -0
  58. package/docs/html/assets/highlight.css +9 -2
  59. package/docs/html/assets/icons.js +18 -0
  60. package/docs/html/assets/icons.svg +1 -0
  61. package/docs/html/assets/main.js +5 -4
  62. package/docs/html/assets/navigation.js +1 -1
  63. package/docs/html/assets/search.js +1 -1
  64. package/docs/html/assets/style.css +1422 -1226
  65. package/docs/html/classes/CameraKit.html +18 -16
  66. package/docs/html/classes/CameraKitSession.html +76 -51
  67. package/docs/html/classes/CameraKitSource.html +18 -18
  68. package/docs/html/classes/LensPerformanceMeasurement.html +11 -11
  69. package/docs/html/classes/LensPerformanceMetrics.html +8 -7
  70. package/docs/html/classes/LensRepository.html +25 -23
  71. package/docs/html/classes/Transform2D.html +9 -9
  72. package/docs/html/classes/TypedCustomEvent.html +5 -4
  73. package/docs/html/classes/TypedEventTarget.html +6 -6
  74. package/docs/html/enums/Lens_CameraFacing.html +5 -5
  75. package/docs/html/functions/bootstrapCameraKit.html +11 -10
  76. package/docs/html/functions/createExtension.html +7 -6
  77. package/docs/html/functions/createImageSource.html +5 -5
  78. package/docs/html/functions/createMediaStreamSource.html +5 -5
  79. package/docs/html/functions/createVideoSource.html +5 -5
  80. package/docs/html/functions/estimateLensPerformance.html +2 -2
  81. package/docs/html/functions/filePickerFactory.html +2 -2
  82. package/docs/html/functions/lensSourcesFactory.html +5 -4
  83. package/docs/html/functions/remoteApiServicesFactory.html +1 -1
  84. package/docs/html/hierarchy.html +1 -1
  85. package/docs/html/index.html +111 -88
  86. package/docs/html/interfaces/BitmojiUserInfo.html +3 -3
  87. package/docs/html/interfaces/CameraKitBootstrapConfiguration.html +40 -21
  88. package/docs/html/interfaces/CameraKitDeviceOptions.html +7 -7
  89. package/docs/html/interfaces/CameraKitSourceInfo.html +7 -7
  90. package/docs/html/interfaces/CameraKitSourceSubscriber.html +4 -4
  91. package/docs/html/interfaces/ComputedFrameMetrics.html +6 -6
  92. package/docs/html/interfaces/CreateSessionOptions.html +7 -7
  93. package/docs/html/interfaces/EstimatedLensPerformance.html +5 -5
  94. package/docs/html/interfaces/Font.html +6 -0
  95. package/docs/html/interfaces/FriendUserInfo.html +4 -4
  96. package/docs/html/interfaces/FunctionSourceOptions.html +4 -4
  97. package/docs/html/interfaces/Lens.html +21 -21
  98. package/docs/html/interfaces/LensCreator.html +3 -3
  99. package/docs/html/interfaces/LensHttpRequest.html +16 -0
  100. package/docs/html/interfaces/LensLaunchData.html +6 -6
  101. package/docs/html/interfaces/LensSource.html +5 -5
  102. package/docs/html/interfaces/LensUserData.html +10 -10
  103. package/docs/html/interfaces/LoadAssetRequest.html +10 -10
  104. package/docs/html/interfaces/MediaStreamSourceOptions.html +11 -11
  105. package/docs/html/interfaces/Preview.html +4 -4
  106. package/docs/html/interfaces/RemoteApiRequest.html +10 -10
  107. package/docs/html/interfaces/RemoteApiResponse.html +8 -8
  108. package/docs/html/interfaces/RemoteApiService.html +9 -9
  109. package/docs/html/interfaces/Snapcode.html +6 -6
  110. package/docs/html/interfaces/UriCancelRequest.html +3 -3
  111. package/docs/html/interfaces/UriRequest.html +7 -7
  112. package/docs/html/interfaces/UriResponse.html +6 -6
  113. package/docs/html/interfaces/VideoSourceOptions.html +9 -9
  114. package/docs/html/modules.html +1 -99
  115. package/docs/html/types/ArgumentValidationError.html +2 -2
  116. package/docs/html/types/AssetLoader.html +4 -4
  117. package/docs/html/types/AssetResponse.html +1 -1
  118. package/docs/html/types/AssetTiming.html +2 -2
  119. package/docs/html/types/BenchmarkError.html +1 -1
  120. package/docs/html/types/BootstrapError.html +2 -2
  121. package/docs/html/types/CacheKeyNotFoundError.html +1 -1
  122. package/docs/html/types/CameraKitSessionEventListener.html +2 -2
  123. package/docs/html/types/CameraKitSessionEvents.html +4 -3
  124. package/docs/html/types/CameraKitSourceError.html +1 -1
  125. package/docs/html/types/ConfigurationError.html +2 -2
  126. package/docs/html/types/FetchHandler.html +1 -1
  127. package/docs/html/types/FilePicker.html +5 -5
  128. package/docs/html/types/FilePickerOptions.html +2 -2
  129. package/docs/html/types/FilePickerResult.html +2 -2
  130. package/docs/html/types/Keyboard.html +9 -16
  131. package/docs/html/types/KeyboardEvents.html +2 -2
  132. package/docs/html/types/LegalError.html +1 -1
  133. package/docs/html/types/LensAbortError.html +6 -5
  134. package/docs/html/types/LensAssetError.html +2 -2
  135. package/docs/html/types/LensContentValidationError.html +1 -1
  136. package/docs/html/types/LensError.html +1 -1
  137. package/docs/html/types/LensExecutionError.html +6 -5
  138. package/docs/html/types/LensHttpHandler.html +9 -0
  139. package/docs/html/types/LensImagePickerError.html +2 -2
  140. package/docs/html/types/LensLaunchParams.html +2 -2
  141. package/docs/html/types/LensMetricsEvents.html +2 -2
  142. package/docs/html/types/LensPerformanceCluster.html +1 -1
  143. package/docs/html/types/LensView.html +3 -3
  144. package/docs/html/types/LensWait.html +2 -2
  145. package/docs/html/types/Matrix.html +2 -2
  146. package/docs/html/types/PersistentStoreError.html +2 -2
  147. package/docs/html/types/PlatformNotSupportedError.html +3 -3
  148. package/docs/html/types/PublicContainer.html +2 -2
  149. package/docs/html/types/PublicServices.html +2 -2
  150. package/docs/html/types/RemoteApiCancelRequestHandler.html +2 -2
  151. package/docs/html/types/RemoteApiRequestHandler.html +2 -2
  152. package/docs/html/types/RemoteApiServices.html +1 -1
  153. package/docs/html/types/RemoteApiStatus.html +2 -2
  154. package/docs/html/types/RenderTarget.html +3 -3
  155. package/docs/html/types/Uri.html +1 -1
  156. package/docs/html/types/WebGLError.html +1 -1
  157. package/docs/html/types/Zodiac.html +1 -1
  158. package/docs/html/variables/extensionRequestContext.html +2 -2
  159. package/docs/md/README.md +5 -3
  160. package/docs/md/classes/CameraKit.md +26 -37
  161. package/docs/md/classes/CameraKitSession.md +146 -107
  162. package/docs/md/classes/CameraKitSource.md +46 -37
  163. package/docs/md/classes/LensPerformanceMeasurement.md +18 -26
  164. package/docs/md/classes/LensPerformanceMetrics.md +8 -10
  165. package/docs/md/classes/LensRepository.md +66 -45
  166. package/docs/md/classes/Transform2D.md +19 -26
  167. package/docs/md/classes/TypedCustomEvent.md +24 -32
  168. package/docs/md/classes/TypedEventTarget.md +43 -54
  169. package/docs/md/enumerations/Lens_CameraFacing.md +31 -0
  170. package/docs/md/functions/bootstrapCameraKit.md +66 -0
  171. package/docs/md/functions/createExtension.md +50 -0
  172. package/docs/md/functions/createImageSource.md +30 -0
  173. package/docs/md/functions/createMediaStreamSource.md +30 -0
  174. package/docs/md/functions/createVideoSource.md +31 -0
  175. package/docs/md/functions/estimateLensPerformance.md +18 -0
  176. package/docs/md/functions/filePickerFactory.md +22 -0
  177. package/docs/md/functions/lensSourcesFactory.md +37 -0
  178. package/docs/md/functions/remoteApiServicesFactory.md +19 -0
  179. package/docs/md/globals.md +121 -0
  180. package/docs/md/interfaces/BitmojiUserInfo.md +9 -12
  181. package/docs/md/interfaces/CameraKitBootstrapConfiguration.md +99 -40
  182. package/docs/md/interfaces/CameraKitDeviceOptions.md +11 -17
  183. package/docs/md/interfaces/CameraKitSourceInfo.md +14 -20
  184. package/docs/md/interfaces/CameraKitSourceSubscriber.md +23 -28
  185. package/docs/md/interfaces/ComputedFrameMetrics.md +13 -19
  186. package/docs/md/interfaces/CreateSessionOptions.md +10 -13
  187. package/docs/md/interfaces/EstimatedLensPerformance.md +10 -14
  188. package/docs/md/interfaces/Font.md +25 -0
  189. package/docs/md/interfaces/FriendUserInfo.md +12 -16
  190. package/docs/md/interfaces/FunctionSourceOptions.md +6 -8
  191. package/docs/md/interfaces/Lens.md +26 -37
  192. package/docs/md/interfaces/LensCreator.md +6 -8
  193. package/docs/md/interfaces/LensHttpRequest.md +60 -0
  194. package/docs/md/interfaces/LensLaunchData.md +13 -17
  195. package/docs/md/interfaces/LensSource.md +26 -27
  196. package/docs/md/interfaces/LensUserData.md +30 -40
  197. package/docs/md/interfaces/LoadAssetRequest.md +13 -18
  198. package/docs/md/interfaces/MediaStreamSourceOptions.md +15 -22
  199. package/docs/md/interfaces/Preview.md +6 -8
  200. package/docs/md/interfaces/RemoteApiRequest.md +12 -17
  201. package/docs/md/interfaces/RemoteApiResponse.md +10 -14
  202. package/docs/md/interfaces/RemoteApiService.md +20 -19
  203. package/docs/md/interfaces/Snapcode.md +8 -11
  204. package/docs/md/interfaces/UriCancelRequest.md +7 -10
  205. package/docs/md/interfaces/UriRequest.md +15 -22
  206. package/docs/md/interfaces/UriResponse.md +14 -20
  207. package/docs/md/interfaces/VideoSourceOptions.md +13 -19
  208. package/docs/md/type-aliases/ArgumentValidationError.md +11 -0
  209. package/docs/md/type-aliases/AssetLoader.md +26 -0
  210. package/docs/md/type-aliases/AssetResponse.md +9 -0
  211. package/docs/md/type-aliases/AssetTiming.md +18 -0
  212. package/docs/md/type-aliases/BenchmarkError.md +9 -0
  213. package/docs/md/type-aliases/BootstrapError.md +12 -0
  214. package/docs/md/type-aliases/CacheKeyNotFoundError.md +9 -0
  215. package/docs/md/type-aliases/CameraKitSessionEventListener.md +11 -0
  216. package/docs/md/type-aliases/CameraKitSessionEvents.md +17 -0
  217. package/docs/md/type-aliases/CameraKitSourceError.md +9 -0
  218. package/docs/md/type-aliases/ConfigurationError.md +11 -0
  219. package/docs/md/type-aliases/FetchHandler.md +27 -0
  220. package/docs/md/type-aliases/FilePicker.md +32 -0
  221. package/docs/md/type-aliases/FilePickerOptions.md +11 -0
  222. package/docs/md/type-aliases/FilePickerResult.md +11 -0
  223. package/docs/md/type-aliases/Keyboard.md +114 -0
  224. package/docs/md/type-aliases/KeyboardEvents.md +11 -0
  225. package/docs/md/type-aliases/LegalError.md +9 -0
  226. package/docs/md/type-aliases/LensAbortError.md +22 -0
  227. package/docs/md/type-aliases/LensAssetError.md +11 -0
  228. package/docs/md/type-aliases/LensContentValidationError.md +9 -0
  229. package/docs/md/type-aliases/LensError.md +9 -0
  230. package/docs/md/type-aliases/LensExecutionError.md +23 -0
  231. package/docs/md/type-aliases/LensHttpHandler.md +41 -0
  232. package/docs/md/type-aliases/LensImagePickerError.md +12 -0
  233. package/docs/md/type-aliases/LensLaunchParams.md +11 -0
  234. package/docs/md/type-aliases/LensMetricsEvents.md +13 -0
  235. package/docs/md/type-aliases/LensPerformanceCluster.md +9 -0
  236. package/docs/md/type-aliases/LensView.md +21 -0
  237. package/docs/md/type-aliases/LensWait.md +13 -0
  238. package/docs/md/type-aliases/Matrix.md +12 -0
  239. package/docs/md/type-aliases/PersistentStoreError.md +11 -0
  240. package/docs/md/type-aliases/PlatformNotSupportedError.md +13 -0
  241. package/docs/md/type-aliases/PublicContainer.md +12 -0
  242. package/docs/md/type-aliases/PublicServices.md +11 -0
  243. package/docs/md/type-aliases/RemoteApiCancelRequestHandler.md +15 -0
  244. package/docs/md/type-aliases/RemoteApiRequestHandler.md +24 -0
  245. package/docs/md/type-aliases/RemoteApiServices.md +9 -0
  246. package/docs/md/type-aliases/RemoteApiStatus.md +11 -0
  247. package/docs/md/type-aliases/RenderTarget.md +14 -0
  248. package/docs/md/type-aliases/Uri.md +9 -0
  249. package/docs/md/type-aliases/WebGLError.md +9 -0
  250. package/docs/md/type-aliases/Zodiac.md +9 -0
  251. package/docs/md/variables/extensionRequestContext.md +11 -0
  252. package/package.json +6 -6
  253. package/dist/extensions/RemoteApiServices.d.ts.map +0 -1
  254. package/dist/extensions/RemoteApiServices.js +0 -159
  255. package/dist/extensions/RemoteApiServices.js.map +0 -1
  256. package/dist/extensions/UriHandlers.d.ts.map +0 -1
  257. package/dist/extensions/UriHandlers.js.map +0 -1
  258. package/dist/extensions/uriHandlersRegister.d.ts.map +0 -1
  259. package/dist/extensions/uriHandlersRegister.js.map +0 -1
  260. package/docs/md/.nojekyll +0 -1
  261. package/docs/md/enums/Lens_CameraFacing.md +0 -36
  262. package/docs/md/modules.md +0 -904
  263. /package/dist/{extensions → uri-handlers}/UriHandlers.d.ts +0 -0
  264. /package/dist/{extensions → uri-handlers}/UriHandlers.js +0 -0
package/README.md CHANGED
@@ -181,7 +181,7 @@ session.pause('capture');
181
181
 
182
182
  ## Error Handling
183
183
 
184
- Camera Kit Web SDK methods may throw errors, or return rejected Promises -- these are documented in the [API docs](https://kit.snapchat.com/reference/CameraKit/web/1.0.0/index.html). It is good practice to handle such cases, to provide a good experience to your users.
184
+ Camera Kit Web SDK methods may throw errors, or return rejected Promises -- these are documented in the [API docs](https://kit.snapchat.com/reference/CameraKit/web/1.1.0/index.html). It is good practice to handle such cases, to provide a good experience to your users.
185
185
 
186
186
  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.
187
187
 
@@ -273,6 +273,10 @@ export declare const cameraKitFactory: {
273
273
  (args_0: import("./clients/grpcHandler").GrpcHandler): import("./clients/lensesClient").LensesClient;
274
274
  token: "lensesClient";
275
275
  dependencies: readonly ["grpcHandlerFactory"];
276
+ }, {
277
+ (args_0: import("./clients/grpcHandler").GrpcHandler): import("./clients/remoteApiSpecsClient").RemoteApiSpecsClient;
278
+ token: "remoteApiSpecsClient";
279
+ dependencies: readonly ["grpcHandlerFactory"];
276
280
  }, {
277
281
  (args_0: import("./configuration").CameraKitConfiguration, args_1: import("./handlers/requestStateEmittingHandler").RequestStateEventTarget, args_2: import("./clients/metricsClient").MetricsClient): import("./handlers/HandlerChainBuilder").Handler<Partial<import("./generated-proto/pb_schema/cdp/cof/config_request").ConfigTargetingRequest>, import("./generated-proto/pb_schema/cdp/cof/config_response").ConfigTargetingResponse, import("./remote-configuration/cofHandler").Metadata & {
278
282
  signal?: AbortSignal | null | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"CameraKit.d.ts","sourceRoot":"","sources":["../src/CameraKit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAKnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAUvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgB5B,CAAC"}
package/dist/CameraKit.js CHANGED
@@ -5,7 +5,7 @@ import { cameraKitSessionFactory } from "./session/CameraKitSession";
5
5
  import { registerLensAssetsProvider } from "./lens/assets/LensAssetsProvider";
6
6
  import { lensCoreFactory } from "./lens-core-module/loader/lensCoreFactory";
7
7
  import { configurationToken } from "./configuration";
8
- import { registerUriHandlers } from "./extensions/uriHandlersRegister";
8
+ import { registerUriHandlers } from "./uri-handlers/uriHandlersRegister";
9
9
  import { metricsEventTargetFactory } from "./metrics/metricsEventTarget";
10
10
  import { reportSessionScopedMetrics } from "./metrics/reporters/reporters";
11
11
  import { lensStateFactory } from "./session/lensState";
@@ -50,11 +50,17 @@ export let CameraKit = (() => {
50
50
  "The lens cannot be rendered and will be removed from the CameraKitSession.", error));
51
51
  }
52
52
  };
53
+ const config = this.container.get(configurationToken);
53
54
  yield this.lensCore.initialize({
54
55
  canvas: liveRenderTarget,
55
- shouldUseWorker: !renderWhileTabHidden && this.container.get(configurationToken).shouldUseWorker,
56
+ shouldUseWorker: !renderWhileTabHidden && config.shouldUseWorker,
56
57
  exceptionHandler,
57
58
  });
59
+ if (config.fonts.length > 0) {
60
+ this.lensCore.setSystemFonts({
61
+ fonts: config.fonts,
62
+ });
63
+ }
58
64
  yield this.lensCore.setRenderLoopMode({
59
65
  mode: renderWhileTabHidden
60
66
  ? this.lensCore.RenderLoopMode.SetTimeout
@@ -1 +1 @@
1
- {"version":3,"file":"CameraKit.js","sourceRoot":"","sources":["../src/CameraKit.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAExD,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAI9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,EAAE,0BAA0B,E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B,EAClB,cAA8B,EAC9B,SAAkC,EACpC,EAAE,CAAC,IAAI,SAAS,CAAC,cAAc,EAAE,QAAQ,EAAE,cAAc,EAAE,SAAS,EAAE,OAAO,CAAC,CACnF,CAAC","sourcesContent":["import type { Container } from \"@snap/ts-inject\";\nimport { CONTAINER, Injectable } from \"@snap/ts-inject\";\nimport type { LensRepository } from \"./lens/LensRepository\";\nimport { lensRepositoryFactory } from \"./lens/LensRepository\";\nimport type { LensCoreError } from \"./lens-core-module/lensCoreError\";\nimport type { LensCore } from \"./lens-core-module/lensCore\";\nimport type { CameraKitSession } from \"./session/CameraKitSession\";\nimport { cameraKitSessionFactory } from \"./session/CameraKitSession\";\nimport { registerLensAssetsProvider } from \"./lens/assets/LensAssetsProvider\";\nimport { lensCoreFactory } from \"./lens-core-module/loader/lensCoreFactory\";\nimport { configurationToken } from \"./configuration\";\nimport type { RootServices } from \"./RootServices\";\nimport { registerUriHandlers } from \"./extensions/uriHandlersRegister\";\nimport type { MetricsEventTarget } from \"./metrics/metricsEventTarget\";\nimport { 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, lensAbortError } from \"./namedErrors\";\nimport { getLogger, resetLogger } from \"./logger/logger\";\nimport { errorLoggingDecorator } from \"./logger/errorLoggingDecorator\";\nimport { TypedEventTarget } from \"./events/TypedEventTarget\";\nimport type { TypedCustomEvent } from \"./events/TypedCustomEvent\";\nimport type { LensView } from \"./metrics/reporters/reportLensView\";\nimport type { LensWait } from \"./metrics/reporters/reportLensWait\";\nimport type { PageVisibility } from \"./common/pageVisibility\";\nimport { pageVisibilityFactory } from \"./common/pageVisibility\";\nimport { setPreloadedConfiguration } from \"./remote-configuration/preloadConfiguration\";\n\nconst logger = getLogger(\"CameraKit\");\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: LensCore,\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 @errorLoggingDecorator(logger)\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 if (error.name === \"LensCoreAbortError\") {\n logger.error(\n lensAbortError(\n \"Unrecoverable error occurred during lens execution. \" +\n \"The CameraKitSession will be destroyed.\",\n error\n )\n );\n } else {\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\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, spawning 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 this.lensCore.initialize({\n canvas: liveRenderTarget,\n shouldUseWorker: !renderWhileTabHidden && this.container.get(configurationToken).shouldUseWorker,\n exceptionHandler,\n });\n\n await this.lensCore.setRenderLoopMode({\n mode: renderWhileTabHidden\n ? this.lensCore.RenderLoopMode.SetTimeout\n : this.lensCore.RenderLoopMode.RequestAnimationFrame,\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 @errorLoggingDecorator(logger)\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: LensCore,\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":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,GAAG,EAAE,CAAC;gBACvB,CAAC;aAAA;;;yCA9FA,qBAAqB,CAAC,MAAM,CAAC;mCAwF7B,qBAAqB,CAAC,MAAM,CAAC;YAvF9B,wLAAM,aAAa,wCAkFlB;YAMD,sKAAM,OAAO,wCAKZ;;;;AAIL,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,QAAkB,EAClB,cAA8B,EAC9B,SAAkC,EACpC,EAAE,CAAC,IAAI,SAAS,CAAC,cAAc,EAAE,QAAQ,EAAE,cAAc,EAAE,SAAS,EAAE,OAAO,CAAC,CACnF,CAAC","sourcesContent":["import type { Container } from \"@snap/ts-inject\";\nimport { CONTAINER, Injectable } from \"@snap/ts-inject\";\nimport type { LensRepository } from \"./lens/LensRepository\";\nimport { lensRepositoryFactory } from \"./lens/LensRepository\";\nimport type { LensCoreError } from \"./lens-core-module/lensCoreError\";\nimport type { LensCore } from \"./lens-core-module/lensCore\";\nimport type { CameraKitSession } from \"./session/CameraKitSession\";\nimport { cameraKitSessionFactory } from \"./session/CameraKitSession\";\nimport { registerLensAssetsProvider } from \"./lens/assets/LensAssetsProvider\";\nimport { lensCoreFactory } from \"./lens-core-module/loader/lensCoreFactory\";\nimport { configurationToken } from \"./configuration\";\nimport type { RootServices } from \"./RootServices\";\nimport { registerUriHandlers } from \"./uri-handlers/uriHandlersRegister\";\nimport type { MetricsEventTarget } from \"./metrics/metricsEventTarget\";\nimport { 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, lensAbortError } from \"./namedErrors\";\nimport { getLogger, resetLogger } from \"./logger/logger\";\nimport { errorLoggingDecorator } from \"./logger/errorLoggingDecorator\";\nimport { TypedEventTarget } from \"./events/TypedEventTarget\";\nimport type { TypedCustomEvent } from \"./events/TypedCustomEvent\";\nimport type { LensView } from \"./metrics/reporters/reportLensView\";\nimport type { LensWait } from \"./metrics/reporters/reportLensWait\";\nimport type { PageVisibility } from \"./common/pageVisibility\";\nimport { pageVisibilityFactory } from \"./common/pageVisibility\";\nimport { setPreloadedConfiguration } from \"./remote-configuration/preloadConfiguration\";\n\nconst logger = getLogger(\"CameraKit\");\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: LensCore,\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 @errorLoggingDecorator(logger)\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 if (error.name === \"LensCoreAbortError\") {\n logger.error(\n lensAbortError(\n \"Unrecoverable error occurred during lens execution. \" +\n \"The CameraKitSession will be destroyed.\",\n error\n )\n );\n } else {\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\n const config = this.container.get(configurationToken);\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, spawning 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 this.lensCore.initialize({\n canvas: liveRenderTarget,\n shouldUseWorker: !renderWhileTabHidden && config.shouldUseWorker,\n exceptionHandler,\n });\n\n if (config.fonts.length > 0) {\n this.lensCore.setSystemFonts({\n fonts: config.fonts,\n });\n }\n\n await this.lensCore.setRenderLoopMode({\n mode: renderWhileTabHidden\n ? this.lensCore.RenderLoopMode.SetTimeout\n : this.lensCore.RenderLoopMode.RequestAnimationFrame,\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 @errorLoggingDecorator(logger)\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: LensCore,\n pageVisibility: PageVisibility,\n container: Container<RootServices>\n ) => new CameraKit(lensRepository, lensCore, pageVisibility, container, metrics)\n);\n"]}
@@ -11,7 +11,7 @@ import type { externalMetricsSubjectFactory, metricsClientFactory } from "./clie
11
11
  import type { LensCore } from "./lens-core-module/lensCore";
12
12
  import type { metricsEventTargetFactory } from "./metrics/metricsEventTarget";
13
13
  import type { lensSourcesFactory } from "./lens/LensSource";
14
- import type { uriHandlersFactory } from "./extensions/UriHandlers";
14
+ import type { uriHandlersFactory } from "./uri-handlers/UriHandlers";
15
15
  import type { lensPersistenceStoreFactory } from "./lens/LensPersistenceStore";
16
16
  import type { cofHandlerFactory } from "./remote-configuration/cofHandler";
17
17
  import type { remoteConfigurationFactory } from "./remote-configuration/remoteConfiguration";
@@ -23,10 +23,11 @@ import type { reportGlobalException } from "./metrics/reporters/reportGlobalExce
23
23
  import type { requestStateEventTargetFactory } from "./handlers/requestStateEmittingHandler";
24
24
  import type { lensesClientFactory } from "./clients/lensesClient";
25
25
  import type { pageVisibilityFactory } from "./common/pageVisibility";
26
- import type { remoteApiServicesFactory } from "./extensions/RemoteApiServices";
26
+ import type { remoteApiServicesFactory } from "./uri-handlers/internal-handlers/remoteApiUriHandler";
27
27
  import type { grpcHandlerFactory } from "./clients/grpcHandler";
28
28
  import type { filePickerFactory } from "./lens-client-interface/filePicker";
29
29
  import type { userDataAccessResolverFactory } from "./lens/userDataAccessResolver";
30
+ import type { remoteApiSpecsClientFactory } from "./clients/remoteApiSpecsClient";
30
31
  /**
31
32
  * All services available to be customized by client app.
32
33
  */
@@ -62,6 +63,7 @@ export type RootServices = {
62
63
  typeof cameraKitServiceFetchHandlerFactory,
63
64
  typeof grpcHandlerFactory,
64
65
  typeof lensesClientFactory,
66
+ typeof remoteApiSpecsClientFactory,
65
67
  typeof cofHandlerFactory,
66
68
  typeof remoteConfigurationFactory,
67
69
  typeof lensRepositoryFactory,
@@ -1 +1 @@
1
- {"version":3,"file":"RootServices.d.ts","sourceRoot":"","sources":["../src/RootServices.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,6CAA6C,CAAC;AACjG,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,0CAA0C,CAAC;AAClG,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AACjF,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,gDAAgD,CAAC;AAC1G,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,KAAK,EAAE,6BAA6B,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AACnG,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAC9E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,EAAE,2BAA2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AAO,0BAA0B;IACjC,OAAO,6BAA6B;IACpC,OAAO,kBAAkB;IACzB,OAAO,wBAAwB;IAC/B,OAAO,kBAAkB;IACzB,OAAO,6BAA6B;CACvC,CACJ,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,YAAY,GAAG;IAGvB,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC;CACrC,GAAG,cAAc,GACd,uBAAuB,CACnB;IACI,OAAO,qBAAqB;IAC5B,OAAO,yBAAyB;IAChC,OAAO,8BAA8B;IACrC,OAAO,mCAAmC;IAC1C,OAAO,kBAAkB;IACzB,OAAO,mBAAmB;IAC1B,OAAO,2BAA2B;IAClC,OAAO,iBAAiB;IACxB,OAAO,0BAA0B;IACjC,OAAO,qBAAqB;IAC5B,OAAO,2BAA2B;IAClC,OAAO,oBAAoB;IAC3B,OAAO,0BAA0B;IACjC,OAAO,iCAAiC;IACxC,OAAO,wBAAwB;IAC/B,OAAO,iBAAiB;IACxB,OAAO,kBAAkB;IACzB,OAAO,iBAAiB;IACxB,OAAO,qBAAqB;CAC/B,CACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"RootServices.js","sourceRoot":"","sources":["../src/RootServices.ts"],"names":[],"mappings":"","sourcesContent":["import type { ServicesFromInjectables } from \"@snap/ts-inject\";\nimport type { lensRepositoryFactory } from \"./lens/LensRepository\";\nimport type { lensCoreFactory } from \"./lens-core-module/loader/lensCoreFactory\";\nimport type { remoteMediaAssetLoaderFactory } from \"./lens/assets/remoteMediaAssetLoaderFactory\";\nimport type { deviceDependentAssetLoaderFactory } from \"./lens/assets/deviceDependentAssetLoader\";\nimport type { staticAssetLoaderFactory } from \"./lens/assets/staticAssetLoader\";\nimport type { defaultFetchHandlerFactory } from \"./handlers/defaultFetchHandler\";\nimport type { cameraKitServiceFetchHandlerFactory } from \"./handlers/cameraKitServiceFetchHandlerFactory\";\nimport type { createCameraKitConfigurationFactory } from \"./configuration\";\nimport type { externalMetricsSubjectFactory, metricsClientFactory } from \"./clients/metricsClient\";\nimport type { LensCore } from \"./lens-core-module/lensCore\";\nimport type { metricsEventTargetFactory } from \"./metrics/metricsEventTarget\";\nimport type { lensSourcesFactory } from \"./lens/LensSource\";\nimport type { uriHandlersFactory } from \"./extensions/UriHandlers\";\nimport type { lensPersistenceStoreFactory } from \"./lens/LensPersistenceStore\";\nimport type { cofHandlerFactory } from \"./remote-configuration/cofHandler\";\nimport type { remoteConfigurationFactory } from \"./remote-configuration/remoteConfiguration\";\nimport type { lensAssetRepositoryFactory } from \"./lens/assets/LensAssetRepository\";\nimport type { legalStateFactory } from \"./legal/legalState\";\nimport type { legalPromptFactory } from \"./legal/legalPrompt\";\nimport type { logEntriesFactory } from \"./logger/logEntries\";\nimport type { reportGlobalException } from \"./metrics/reporters/reportGlobalException\";\nimport type { requestStateEventTargetFactory } from \"./handlers/requestStateEmittingHandler\";\nimport type { lensesClientFactory } from \"./clients/lensesClient\";\nimport type { pageVisibilityFactory } from \"./common/pageVisibility\";\nimport type { remoteApiServicesFactory } from \"./extensions/RemoteApiServices\";\nimport type { grpcHandlerFactory } from \"./clients/grpcHandler\";\nimport type { filePickerFactory } from \"./lens-client-interface/filePicker\";\nimport type { userDataAccessResolverFactory } from \"./lens/userDataAccessResolver\";\n\n/**\n * All services available to be customized by client app.\n */\nexport type PublicServices = ServicesFromInjectables<\n [\n ReturnType<typeof createCameraKitConfigurationFactory>,\n typeof userDataAccessResolverFactory,\n typeof filePickerFactory,\n typeof defaultFetchHandlerFactory,\n typeof remoteMediaAssetLoaderFactory,\n typeof lensSourcesFactory,\n typeof remoteApiServicesFactory,\n typeof uriHandlersFactory,\n typeof externalMetricsSubjectFactory\n ]\n>;\n\n/**\n * Define all the Services contained in CameraKit's root dependency injection container.\n *\n * Note: we do end up defining this list of Services twice (once here to create the type, once when we actually\n * create the Container inside the `bootstrapCameraKit` function). We could avoid doing this and just infer the\n * RootContainer type from the constructed container – but since we can only do that *inside* `bootstrapCameraKit`, it\n * makes it more awkward to provide a type for the `provide` user-supplied function (or use the type elsewhere, like in\n * CameraKitSession).\n *\n * There may be a way to eliminate this extra boilerplate, but for now it's required in order to present a cleaner\n * `bootstrapCameraKit` API to applications.\n */\nexport type RootServices = {\n // bootstrapCameraKit replaces the lensCoreFactory token's value with the resolved LensCore (rather than the\n // Promise of the LensCore), so we need to do the same re-mapping here.\n [lensCoreFactory.token]: LensCore;\n} & PublicServices &\n ServicesFromInjectables<\n [\n typeof pageVisibilityFactory,\n typeof metricsEventTargetFactory,\n typeof requestStateEventTargetFactory,\n typeof cameraKitServiceFetchHandlerFactory,\n typeof grpcHandlerFactory,\n typeof lensesClientFactory,\n typeof cofHandlerFactory,\n typeof remoteConfigurationFactory,\n typeof lensRepositoryFactory,\n typeof lensPersistenceStoreFactory,\n typeof metricsClientFactory,\n typeof lensAssetRepositoryFactory,\n typeof deviceDependentAssetLoaderFactory,\n typeof staticAssetLoaderFactory,\n typeof legalStateFactory,\n typeof legalPromptFactory,\n typeof logEntriesFactory,\n typeof reportGlobalException\n ]\n >;\n"]}
1
+ {"version":3,"file":"RootServices.js","sourceRoot":"","sources":["../src/RootServices.ts"],"names":[],"mappings":"","sourcesContent":["import type { ServicesFromInjectables } from \"@snap/ts-inject\";\nimport type { lensRepositoryFactory } from \"./lens/LensRepository\";\nimport type { lensCoreFactory } from \"./lens-core-module/loader/lensCoreFactory\";\nimport type { remoteMediaAssetLoaderFactory } from \"./lens/assets/remoteMediaAssetLoaderFactory\";\nimport type { deviceDependentAssetLoaderFactory } from \"./lens/assets/deviceDependentAssetLoader\";\nimport type { staticAssetLoaderFactory } from \"./lens/assets/staticAssetLoader\";\nimport type { defaultFetchHandlerFactory } from \"./handlers/defaultFetchHandler\";\nimport type { cameraKitServiceFetchHandlerFactory } from \"./handlers/cameraKitServiceFetchHandlerFactory\";\nimport type { createCameraKitConfigurationFactory } from \"./configuration\";\nimport type { externalMetricsSubjectFactory, metricsClientFactory } from \"./clients/metricsClient\";\nimport type { LensCore } from \"./lens-core-module/lensCore\";\nimport type { metricsEventTargetFactory } from \"./metrics/metricsEventTarget\";\nimport type { lensSourcesFactory } from \"./lens/LensSource\";\nimport type { uriHandlersFactory } from \"./uri-handlers/UriHandlers\";\nimport type { lensPersistenceStoreFactory } from \"./lens/LensPersistenceStore\";\nimport type { cofHandlerFactory } from \"./remote-configuration/cofHandler\";\nimport type { remoteConfigurationFactory } from \"./remote-configuration/remoteConfiguration\";\nimport type { lensAssetRepositoryFactory } from \"./lens/assets/LensAssetRepository\";\nimport type { legalStateFactory } from \"./legal/legalState\";\nimport type { legalPromptFactory } from \"./legal/legalPrompt\";\nimport type { logEntriesFactory } from \"./logger/logEntries\";\nimport type { reportGlobalException } from \"./metrics/reporters/reportGlobalException\";\nimport type { requestStateEventTargetFactory } from \"./handlers/requestStateEmittingHandler\";\nimport type { lensesClientFactory } from \"./clients/lensesClient\";\nimport type { pageVisibilityFactory } from \"./common/pageVisibility\";\nimport type { remoteApiServicesFactory } from \"./uri-handlers/internal-handlers/remoteApiUriHandler\";\nimport type { grpcHandlerFactory } from \"./clients/grpcHandler\";\nimport type { filePickerFactory } from \"./lens-client-interface/filePicker\";\nimport type { userDataAccessResolverFactory } from \"./lens/userDataAccessResolver\";\nimport type { remoteApiSpecsClientFactory } from \"./clients/remoteApiSpecsClient\";\n\n/**\n * All services available to be customized by client app.\n */\nexport type PublicServices = ServicesFromInjectables<\n [\n ReturnType<typeof createCameraKitConfigurationFactory>,\n typeof userDataAccessResolverFactory,\n typeof filePickerFactory,\n typeof defaultFetchHandlerFactory,\n typeof remoteMediaAssetLoaderFactory,\n typeof lensSourcesFactory,\n typeof remoteApiServicesFactory,\n typeof uriHandlersFactory,\n typeof externalMetricsSubjectFactory\n ]\n>;\n\n/**\n * Define all the Services contained in CameraKit's root dependency injection container.\n *\n * Note: we do end up defining this list of Services twice (once here to create the type, once when we actually\n * create the Container inside the `bootstrapCameraKit` function). We could avoid doing this and just infer the\n * RootContainer type from the constructed container – but since we can only do that *inside* `bootstrapCameraKit`, it\n * makes it more awkward to provide a type for the `provide` user-supplied function (or use the type elsewhere, like in\n * CameraKitSession).\n *\n * There may be a way to eliminate this extra boilerplate, but for now it's required in order to present a cleaner\n * `bootstrapCameraKit` API to applications.\n */\nexport type RootServices = {\n // bootstrapCameraKit replaces the lensCoreFactory token's value with the resolved LensCore (rather than the\n // Promise of the LensCore), so we need to do the same re-mapping here.\n [lensCoreFactory.token]: LensCore;\n} & PublicServices &\n ServicesFromInjectables<\n [\n typeof pageVisibilityFactory,\n typeof metricsEventTargetFactory,\n typeof requestStateEventTargetFactory,\n typeof cameraKitServiceFetchHandlerFactory,\n typeof grpcHandlerFactory,\n typeof lensesClientFactory,\n typeof remoteApiSpecsClientFactory,\n typeof cofHandlerFactory,\n typeof remoteConfigurationFactory,\n typeof lensRepositoryFactory,\n typeof lensPersistenceStoreFactory,\n typeof metricsClientFactory,\n typeof lensAssetRepositoryFactory,\n typeof deviceDependentAssetLoaderFactory,\n typeof staticAssetLoaderFactory,\n typeof legalStateFactory,\n typeof legalPromptFactory,\n typeof logEntriesFactory,\n typeof reportGlobalException\n ]\n >;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"bootstrapCameraKit.d.ts","sourceRoot":"","sources":["../src/bootstrapCameraKit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAc,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAM1E,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,iBAAiB,CAAC;AAEvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAsD7C;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAsB,kBAAkB,CACpC,aAAa,EAAE,+BAA+B,EAC9C,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,eAAe,KAAK,eAAe,GAClD,OAAO,CAAC,SAAS,CAAC,CA4FpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,eAAe,IAAI,gBAAgB,CAElD"}
1
+ {"version":3,"file":"bootstrapCameraKit.d.ts","sourceRoot":"","sources":["../src/bootstrapCameraKit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAc,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAM1E,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,iBAAiB,CAAC;AAEvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAuD7C;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAsB,kBAAkB,CACpC,aAAa,EAAE,+BAA+B,EAC9C,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,eAAe,KAAK,eAAe,GAClD,OAAO,CAAC,SAAS,CAAC,CA6FpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,eAAe,IAAI,gBAAgB,CAElD"}
@@ -11,7 +11,7 @@ import { cameraKitFactory } from "./CameraKit";
11
11
  import { lensRepositoryFactory } from "./lens/LensRepository";
12
12
  import lensCoreWasm from "./lensCoreWasmVersions";
13
13
  import environment from "./environment";
14
- import { uriHandlersFactory } from "./extensions/UriHandlers";
14
+ import { uriHandlersFactory } from "./uri-handlers/UriHandlers";
15
15
  import { assert } from "./common/assertions";
16
16
  import { isSafeString } from "./common/typeguards";
17
17
  import { metricsEventTargetFactory } from "./metrics/metricsEventTarget";
@@ -31,7 +31,7 @@ import { registerLogEntriesSubscriber } from "./logger/registerLogEntriesSubscri
31
31
  import { requestStateEventTargetFactory } from "./handlers/requestStateEmittingHandler";
32
32
  import { pageVisibilityFactory } from "./common/pageVisibility";
33
33
  import { cofHandlerFactory } from "./remote-configuration/cofHandler";
34
- import { remoteApiServicesFactory } from "./extensions/RemoteApiServices";
34
+ import { remoteApiServicesFactory } from "./uri-handlers/internal-handlers/remoteApiUriHandler";
35
35
  import { lensesClientFactory } from "./clients/lensesClient";
36
36
  import { grpcHandlerFactory } from "./clients/grpcHandler";
37
37
  import { lensSourcesFactory } from "./lens/LensSource";
@@ -41,6 +41,7 @@ import { Timer } from "./metrics/operational/Timer";
41
41
  import { fetchWatermarkLens } from "./lens/fetchWatermarkLens";
42
42
  import { filePickerFactory } from "./lens-client-interface/filePicker";
43
43
  import { userDataAccessResolverFactory } from "./lens/userDataAccessResolver";
44
+ import { remoteApiSpecsClientFactory } from "./clients/remoteApiSpecsClient";
44
45
  const logger = getLogger("bootstrapCameraKit");
45
46
  const nonWrappableErrors = [
46
47
  "ConfigurationError",
@@ -91,6 +92,7 @@ export function bootstrapCameraKit(configuration, provide) {
91
92
  const container = telemetryContainer
92
93
  .provides(Injectable(lensCoreFactory.token, () => lensCore))
93
94
  .provides(lensesClientFactory)
95
+ .provides(remoteApiSpecsClientFactory)
94
96
  .provides(cameraKitLensSourceFactory)
95
97
  .provides(lensPersistenceStoreFactory)
96
98
  .provides(deviceDependentAssetLoaderFactory)
@@ -1 +1 @@
1
- {"version":3,"file":"bootstrapCameraKit.js","sourceRoot":"","sources":["../src/bootstrapCameraKit.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAAE,6BAA6B,EAAE,MAAM,6CAA6C,CAAC;AAC5F,OAAO,EAAE,iCAAiC,EAAE,MAAM,0CAA0C,CAAC;AAC7F,OAAO,E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AK,CAAC,CAAC;aACpF;YACD,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACpB,MAAM,KAAK,CAAC;SACf;IACL,CAAC;CAAA;AA0CD,MAAM,UAAU,eAAe;IAC3B,OAAO,IAAI,gBAAgB,CAAC,EAAE,CAAC,CAAC;AACpC,CAAC","sourcesContent":["import { Container, Injectable, PartialContainer } from \"@snap/ts-inject\";\nimport { remoteMediaAssetLoaderFactory } from \"./lens/assets/remoteMediaAssetLoaderFactory\";\nimport { deviceDependentAssetLoaderFactory } from \"./lens/assets/deviceDependentAssetLoader\";\nimport { staticAssetLoaderFactory } from \"./lens/assets/staticAssetLoader\";\nimport { defaultFetchHandlerFactory } from \"./handlers/defaultFetchHandler\";\nimport { cameraKitServiceFetchHandlerFactory } from \"./handlers/cameraKitServiceFetchHandlerFactory\";\nimport type { CameraKitBootstrapConfiguration } from \"./configuration\";\nimport { createCameraKitConfigurationFactory } from \"./configuration\";\nimport type { PublicServices } from \"./RootServices\";\nimport { lensCoreFactory } from \"./lens-core-module/loader/lensCoreFactory\";\nimport { cameraKitFactory } from \"./CameraKit\";\nimport type { CameraKit } from \"./CameraKit\";\nimport { lensRepositoryFactory } from \"./lens/LensRepository\";\nimport lensCoreWasm from \"./lensCoreWasmVersions\";\nimport environment from \"./environment\";\nimport { uriHandlersFactory } from \"./extensions/UriHandlers\";\nimport { assert } from \"./common/assertions\";\nimport { isSafeString } from \"./common/typeguards\";\nimport { metricsEventTargetFactory } from \"./metrics/metricsEventTarget\";\nimport { reportGloballyScopedMetrics } from \"./metrics/reporters/reporters\";\nimport { getLogger } from \"./logger/logger\";\nimport { logEntriesFactory } from \"./logger/logEntries\";\nimport { assertPlatformSupported } from \"./platform/assertPlatformSupported\";\nimport { lensPersistenceStoreFactory } from \"./lens/LensPersistenceStore\";\nimport { remoteConfigurationFactory } from \"./remote-configuration/remoteConfiguration\";\nimport { lensAssetRepositoryFactory } from \"./lens/assets/LensAssetRepository\";\nimport { legalStateFactory } from \"./legal/legalState\";\nimport { legalPromptFactory } from \"./legal/legalPrompt\";\nimport type { ConfigurationError, PlatformNotSupportedError } from \"./namedErrors\";\nimport { bootstrapError, configurationError } from \"./namedErrors\";\nimport { businessEventsReporterFactory } from \"./metrics/businessEventsReporter\";\nimport { reportGlobalException } from \"./metrics/reporters/reportGlobalException\";\nimport { registerLogEntriesSubscriber } from \"./logger/registerLogEntriesSubscriber\";\nimport { requestStateEventTargetFactory } from \"./handlers/requestStateEmittingHandler\";\nimport { pageVisibilityFactory } from \"./common/pageVisibility\";\nimport { cofHandlerFactory } from \"./remote-configuration/cofHandler\";\nimport { remoteApiServicesFactory } from \"./extensions/RemoteApiServices\";\nimport { lensesClientFactory } from \"./clients/lensesClient\";\nimport { grpcHandlerFactory } from \"./clients/grpcHandler\";\nimport { lensSourcesFactory } from \"./lens/LensSource\";\nimport { cameraKitLensSourceFactory } from \"./lens/cameraKitLensSource\";\nimport { externalMetricsSubjectFactory, metricsClientFactory } from \"./clients/metricsClient\";\nimport { Timer } from \"./metrics/operational/Timer\";\nimport { fetchWatermarkLens } from \"./lens/fetchWatermarkLens\";\nimport { filePickerFactory } from \"./lens-client-interface/filePicker\";\nimport { userDataAccessResolverFactory } from \"./lens/userDataAccessResolver\";\n\nconst logger = getLogger(\"bootstrapCameraKit\");\n\n// The following errors are not wrapped with BootstrapError and bubble up as is.\nconst nonWrappableErrors: [ConfigurationError[\"name\"], PlatformNotSupportedError[\"name\"]] = [\n \"ConfigurationError\",\n \"PlatformNotSupportedError\",\n];\n\n/**\n * Returns true if given error has to be wrapped with BootstrapError.\n */\nfunction shouldWrapError(error: unknown): boolean {\n if (error instanceof Error) {\n return !nonWrappableErrors.some((name) => error.name === name);\n }\n return true;\n}\n\n/**\n * For more advanced use-cases, this DI Container holds services for which a custom implementation may be provided by\n * the application.\n *\n * @category Bootstrapping and Configuration\n */\nexport type PublicContainer = Container<PublicServices>;\n\n/**\n * Bootstrap CameraKit. This will download the WebAssembly code which powers CameraKit's rendering engine, and return\n * an instance of {@link CameraKit}.\n *\n * CameraKit must be provided with some configuration (the application's API token), and there are some additional\n * configurations which are optional.\n *\n * Descriptions of the available configurations can be found in the documentation for\n * {@link CameraKitBootstrapConfiguration}\n *\n * ---\n *\n * There is also a second, more advanced way to modify CameraKit to provide greater flexibility to support less common\n * use cases.\n *\n * This requires some knowledge of CameraKit's dependency injection system, and allows applications to provide their\n * own custom implementations of certain CameraKit components. This functionality will only be needed by applications\n * with very specific, more advanced requirements.\n *\n * @example\n * ```ts\n * // The most common way to bootstrap:\n * const cameraKit = await bootstrapCameraKit({ apiToken: myApiToken })\n *\n * // For special advanced use-cases, it is possible to provide custom implementations for certain CameraKit components.\n * const cameraKit = await bootstrapCameraKit(config, (container) => {\n * return container.provides(myCustomRemoteMediaAssetLoaderFactory)\n * })\n * ```\n *\n * @param configuration Configure CameraKit with e.g. credentials, global resource endpoints, etc.\n * @param provide Optional function that can make modifications to CameraKit's root DI container.\n * @returns A {@link CameraKit} instance, which is the entry point to CameraKit's API.\n *\n * @throws\n * - {@link ConfigurationError} when provided configuration object is invalid\n * - {@link PlatformNotSupportedError} when current platform is not supported by CameraKit\n * - {@link BootstrapError} when a failure occurs while initializing CameraKit and downloading the render engine\n * WebAssembly binary.\n *\n * @category Bootstrapping and Configuration\n */\nexport async function bootstrapCameraKit(\n configuration: CameraKitBootstrapConfiguration,\n provide?: (c: PublicContainer) => PublicContainer\n): Promise<CameraKit> {\n console.info(\n `Camera Kit SDK: ${environment.PACKAGE_VERSION} (${lensCoreWasm.version}/${lensCoreWasm.buildNumber})`\n );\n\n try {\n const bootstrapLatency = new Timer(\"bootstrap_time\");\n\n assert(isSafeString(configuration.apiToken), configurationError(\"Invalid or unsafe apiToken provided.\"));\n\n const configurationFactory = createCameraKitConfigurationFactory(configuration);\n\n // Public container holds services which applications can overwrite with their own implementations.\n const defaultPublicContainer = Container.provides(configurationFactory)\n .provides(userDataAccessResolverFactory)\n .provides(filePickerFactory)\n .provides(defaultFetchHandlerFactory)\n .provides(remoteMediaAssetLoaderFactory)\n .provides(lensSourcesFactory)\n .provides(remoteApiServicesFactory)\n .provides(uriHandlersFactory)\n .provides(externalMetricsSubjectFactory);\n\n const publicContainer = provide ? provide(defaultPublicContainer) : defaultPublicContainer;\n\n // Now that the client's provide() function has completed and the configuration override is ready,\n // we create another container to initialize the logger. This ensures that logging is available\n // as we continue bootstrapping. We don't initialize the logger as part of the defaultPublicContainer\n // because we don't want applications to provide their own logger implementations,\n // and we're not interested in errors thrown by their provide() function.\n // Below is the minimum required container to report errors to Blizzard.\n const telemetryContainer = Container.provides(publicContainer)\n .provides(pageVisibilityFactory)\n .provides(cameraKitServiceFetchHandlerFactory)\n .provides(requestStateEventTargetFactory)\n .provides(grpcHandlerFactory)\n .provides(metricsClientFactory)\n .provides(logEntriesFactory)\n .run(registerLogEntriesSubscriber)\n .provides(metricsEventTargetFactory)\n .provides(reportGlobalException)\n .provides(cofHandlerFactory)\n .provides(remoteConfigurationFactory)\n .provides(legalPromptFactory)\n .provides(legalStateFactory)\n // We'll run a PartialContainer containing reporters for globally-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). This PartialContainer also includes the service which listens to locally-reported metrics\n // and sends them to our backend.\n .run(reportGloballyScopedMetrics)\n .run(businessEventsReporterFactory);\n\n // Run the exception logger so that it can subscribe to log events -- we can't use `Container.run()` because\n // reportGlobalException is also used as a dependency by other Services (and run does not provide Services,\n // it just runs them once).\n telemetryContainer.get(reportGlobalException.token);\n\n // At this point, logger is configured to report to console and Blizzard.\n\n await assertPlatformSupported();\n\n // LensCore is a foundational component which must be created asynchronously.\n // But it's annoying for every consumer of LensCore to have to wait on Promise<LensCore>\n // (which means they become async themselves). So we'll create a DI container which provides Promise<LensCore>,\n // wait for that promise once here, then create a new DI container that just contains LensCore.\n const lensCore = await telemetryContainer.provides(lensCoreFactory).get(lensCoreFactory.token);\n\n const container = telemetryContainer\n .provides(Injectable(lensCoreFactory.token, () => lensCore))\n .provides(lensesClientFactory)\n .provides(cameraKitLensSourceFactory)\n .provides(lensPersistenceStoreFactory)\n .provides(deviceDependentAssetLoaderFactory)\n .provides(staticAssetLoaderFactory)\n .provides(lensAssetRepositoryFactory)\n .provides(lensRepositoryFactory)\n .provides(cameraKitFactory)\n .run(fetchWatermarkLens);\n\n const cameraKit = container.get(cameraKitFactory.token);\n\n bootstrapLatency.measure();\n container.get(metricsClientFactory.token).setOperationalMetrics(bootstrapLatency);\n\n return cameraKit;\n } catch (error) {\n if (shouldWrapError(error)) {\n error = bootstrapError(\"Error occurred during Camera Kit bootstrapping.\", error);\n }\n logger.error(error);\n throw error;\n }\n}\n\n/**\n * Extensions offer a way to provide custom implementations of certain parts of the CameraKit SDK.\n *\n * This enables more advanced use-cases, in which the default behavior of the SDK is substantially altered. For example,\n * replacing the default implementation that loads remote lens assets with a custom implementation that returns\n * different assets based on some business logic within the application.\n *\n * An extension is implemented as a {@link PartialContainer} – a collection of factory functions, each with its own\n * dependencies, which each provide some \"Service\". A Service can be of any type, and the CameraKit SDK defines its\n * own Services, some of which can be overridden by providing a custom implementation of the type via an extension.\n *\n * Here's an example of how extensions might be used:\n * ```ts\n * import { bootstrapCameraKit, createExtension, remoteMediaAssetLoaderFactory } from '@snap/camera-kit'\n *\n * const myCustomRemoteAssetLoader = Injectable(\n * remoteMediaAssetLoaderFactory.token,\n * [remoteMediaAssetLoaderFactory.token] as const,\n * (defaultLoader: AssetLoader): AssetLoader => {\n * return async (asset, lens) => {\n * if (lens?.id === MY_SPECIAL_LENS) {\n * return (await fetch('my/asset.glb')).arrayBuffer()\n * }\n * return defaultLoader(asset, lens)\n * }\n * },\n * )\n *\n * const myExtension = createExtension().provides(myCustomRemoteAssetLoader);\n * const cameraKit = bootstrapCameraKit(config, container => container.provides(myExtension));\n * ```\n *\n * This also enables greater modularity – the person/team creating the extension can do so in their own package, which\n * could be shared by many applications that all require the same functionality.\n *\n * @returns A {@link PartialContainer} which can be used to create a collection of Services, and can later be provided\n * to CameraKit's DI container during {@link bootstrapCameraKit}.\n *\n * @category Bootstrapping and Configuration\n */\nexport function createExtension(): PartialContainer {\n return new PartialContainer({});\n}\n"]}
1
+ {"version":3,"file":"bootstrapCameraKit.js","sourceRoot":"","sources":["../src/bootstrapCameraKit.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAAE,6BAA6B,EAAE,MAAM,6CAA6C,CAAC;AAC5F,OAAO,EAAE,iCAAiC,EAAE,MAAM,0CAA0C,CAAC;AAC7F,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAE,mCAAmC,EAAE,MAAM,gDAAgD,CAAC;AAErG,OAAO,EAAE,mCAAmC,EAAE,MAAM,iBAAiB,CAAC;AAEtE,OAAO,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,YAAY,MAAM,wBAAwB,CAAC;AAClD,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,uB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,CAAC,0BAA0B,CAAC;iBACpC,QAAQ,CAAC,qBAAqB,CAAC;iBAC/B,QAAQ,CAAC,gBAAgB,CAAC;iBAC1B,GAAG,CAAC,kBAAkB,CAAC,CAAC;YAE7B,MAAM,SAAS,GAAG,SAAS,CAAC,GAAG,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;YAExD,gBAAgB,CAAC,OAAO,EAAE,CAAC;YAC3B,SAAS,CAAC,GAAG,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,qBAAqB,CAAC,gBAAgB,CAAC,CAAC;YAElF,OAAO,SAAS,CAAC;SACpB;QAAC,OAAO,KAAK,EAAE;YACZ,IAAI,eAAe,CAAC,KAAK,CAAC,EAAE;gBACxB,KAAK,GAAG,cAAc,CAAC,iDAAiD,EAAE,KAAK,CAAC,CAAC;aACpF;YACD,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACpB,MAAM,KAAK,CAAC;SACf;IACL,CAAC;CAAA;AA0CD,MAAM,UAAU,eAAe;IAC3B,OAAO,IAAI,gBAAgB,CAAC,EAAE,CAAC,CAAC;AACpC,CAAC","sourcesContent":["import { Container, Injectable, PartialContainer } from \"@snap/ts-inject\";\nimport { remoteMediaAssetLoaderFactory } from \"./lens/assets/remoteMediaAssetLoaderFactory\";\nimport { deviceDependentAssetLoaderFactory } from \"./lens/assets/deviceDependentAssetLoader\";\nimport { staticAssetLoaderFactory } from \"./lens/assets/staticAssetLoader\";\nimport { defaultFetchHandlerFactory } from \"./handlers/defaultFetchHandler\";\nimport { cameraKitServiceFetchHandlerFactory } from \"./handlers/cameraKitServiceFetchHandlerFactory\";\nimport type { CameraKitBootstrapConfiguration } from \"./configuration\";\nimport { createCameraKitConfigurationFactory } from \"./configuration\";\nimport type { PublicServices } from \"./RootServices\";\nimport { lensCoreFactory } from \"./lens-core-module/loader/lensCoreFactory\";\nimport { cameraKitFactory } from \"./CameraKit\";\nimport type { CameraKit } from \"./CameraKit\";\nimport { lensRepositoryFactory } from \"./lens/LensRepository\";\nimport lensCoreWasm from \"./lensCoreWasmVersions\";\nimport environment from \"./environment\";\nimport { uriHandlersFactory } from \"./uri-handlers/UriHandlers\";\nimport { assert } from \"./common/assertions\";\nimport { isSafeString } from \"./common/typeguards\";\nimport { metricsEventTargetFactory } from \"./metrics/metricsEventTarget\";\nimport { reportGloballyScopedMetrics } from \"./metrics/reporters/reporters\";\nimport { getLogger } from \"./logger/logger\";\nimport { logEntriesFactory } from \"./logger/logEntries\";\nimport { assertPlatformSupported } from \"./platform/assertPlatformSupported\";\nimport { lensPersistenceStoreFactory } from \"./lens/LensPersistenceStore\";\nimport { remoteConfigurationFactory } from \"./remote-configuration/remoteConfiguration\";\nimport { lensAssetRepositoryFactory } from \"./lens/assets/LensAssetRepository\";\nimport { legalStateFactory } from \"./legal/legalState\";\nimport { legalPromptFactory } from \"./legal/legalPrompt\";\nimport type { ConfigurationError, PlatformNotSupportedError } from \"./namedErrors\";\nimport { bootstrapError, configurationError } from \"./namedErrors\";\nimport { businessEventsReporterFactory } from \"./metrics/businessEventsReporter\";\nimport { reportGlobalException } from \"./metrics/reporters/reportGlobalException\";\nimport { registerLogEntriesSubscriber } from \"./logger/registerLogEntriesSubscriber\";\nimport { requestStateEventTargetFactory } from \"./handlers/requestStateEmittingHandler\";\nimport { pageVisibilityFactory } from \"./common/pageVisibility\";\nimport { cofHandlerFactory } from \"./remote-configuration/cofHandler\";\nimport { remoteApiServicesFactory } from \"./uri-handlers/internal-handlers/remoteApiUriHandler\";\nimport { lensesClientFactory } from \"./clients/lensesClient\";\nimport { grpcHandlerFactory } from \"./clients/grpcHandler\";\nimport { lensSourcesFactory } from \"./lens/LensSource\";\nimport { cameraKitLensSourceFactory } from \"./lens/cameraKitLensSource\";\nimport { externalMetricsSubjectFactory, metricsClientFactory } from \"./clients/metricsClient\";\nimport { Timer } from \"./metrics/operational/Timer\";\nimport { fetchWatermarkLens } from \"./lens/fetchWatermarkLens\";\nimport { filePickerFactory } from \"./lens-client-interface/filePicker\";\nimport { userDataAccessResolverFactory } from \"./lens/userDataAccessResolver\";\nimport { remoteApiSpecsClientFactory } from \"./clients/remoteApiSpecsClient\";\n\nconst logger = getLogger(\"bootstrapCameraKit\");\n\n// The following errors are not wrapped with BootstrapError and bubble up as is.\nconst nonWrappableErrors: [ConfigurationError[\"name\"], PlatformNotSupportedError[\"name\"]] = [\n \"ConfigurationError\",\n \"PlatformNotSupportedError\",\n];\n\n/**\n * Returns true if given error has to be wrapped with BootstrapError.\n */\nfunction shouldWrapError(error: unknown): boolean {\n if (error instanceof Error) {\n return !nonWrappableErrors.some((name) => error.name === name);\n }\n return true;\n}\n\n/**\n * For more advanced use-cases, this DI Container holds services for which a custom implementation may be provided by\n * the application.\n *\n * @category Bootstrapping and Configuration\n */\nexport type PublicContainer = Container<PublicServices>;\n\n/**\n * Bootstrap CameraKit. This will download the WebAssembly code which powers CameraKit's rendering engine, and return\n * an instance of {@link CameraKit}.\n *\n * CameraKit must be provided with some configuration (the application's API token), and there are some additional\n * configurations which are optional.\n *\n * Descriptions of the available configurations can be found in the documentation for\n * {@link CameraKitBootstrapConfiguration}\n *\n * ---\n *\n * There is also a second, more advanced way to modify CameraKit to provide greater flexibility to support less common\n * use cases.\n *\n * This requires some knowledge of CameraKit's dependency injection system, and allows applications to provide their\n * own custom implementations of certain CameraKit components. This functionality will only be needed by applications\n * with very specific, more advanced requirements.\n *\n * @example\n * ```ts\n * // The most common way to bootstrap:\n * const cameraKit = await bootstrapCameraKit({ apiToken: myApiToken })\n *\n * // For special advanced use-cases, it is possible to provide custom implementations for certain CameraKit components.\n * const cameraKit = await bootstrapCameraKit(config, (container) => {\n * return container.provides(myCustomRemoteMediaAssetLoaderFactory)\n * })\n * ```\n *\n * @param configuration Configure CameraKit with e.g. credentials, global resource endpoints, etc.\n * @param provide Optional function that can make modifications to CameraKit's root DI container.\n * @returns A {@link CameraKit} instance, which is the entry point to CameraKit's API.\n *\n * @throws\n * - {@link ConfigurationError} when provided configuration object is invalid\n * - {@link PlatformNotSupportedError} when current platform is not supported by CameraKit\n * - {@link BootstrapError} when a failure occurs while initializing CameraKit and downloading the render engine\n * WebAssembly binary.\n *\n * @category Bootstrapping and Configuration\n */\nexport async function bootstrapCameraKit(\n configuration: CameraKitBootstrapConfiguration,\n provide?: (c: PublicContainer) => PublicContainer\n): Promise<CameraKit> {\n console.info(\n `Camera Kit SDK: ${environment.PACKAGE_VERSION} (${lensCoreWasm.version}/${lensCoreWasm.buildNumber})`\n );\n\n try {\n const bootstrapLatency = new Timer(\"bootstrap_time\");\n\n assert(isSafeString(configuration.apiToken), configurationError(\"Invalid or unsafe apiToken provided.\"));\n\n const configurationFactory = createCameraKitConfigurationFactory(configuration);\n\n // Public container holds services which applications can overwrite with their own implementations.\n const defaultPublicContainer = Container.provides(configurationFactory)\n .provides(userDataAccessResolverFactory)\n .provides(filePickerFactory)\n .provides(defaultFetchHandlerFactory)\n .provides(remoteMediaAssetLoaderFactory)\n .provides(lensSourcesFactory)\n .provides(remoteApiServicesFactory)\n .provides(uriHandlersFactory)\n .provides(externalMetricsSubjectFactory);\n\n const publicContainer = provide ? provide(defaultPublicContainer) : defaultPublicContainer;\n\n // Now that the client's provide() function has completed and the configuration override is ready,\n // we create another container to initialize the logger. This ensures that logging is available\n // as we continue bootstrapping. We don't initialize the logger as part of the defaultPublicContainer\n // because we don't want applications to provide their own logger implementations,\n // and we're not interested in errors thrown by their provide() function.\n // Below is the minimum required container to report errors to Blizzard.\n const telemetryContainer = Container.provides(publicContainer)\n .provides(pageVisibilityFactory)\n .provides(cameraKitServiceFetchHandlerFactory)\n .provides(requestStateEventTargetFactory)\n .provides(grpcHandlerFactory)\n .provides(metricsClientFactory)\n .provides(logEntriesFactory)\n .run(registerLogEntriesSubscriber)\n .provides(metricsEventTargetFactory)\n .provides(reportGlobalException)\n .provides(cofHandlerFactory)\n .provides(remoteConfigurationFactory)\n .provides(legalPromptFactory)\n .provides(legalStateFactory)\n // We'll run a PartialContainer containing reporters for globally-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). This PartialContainer also includes the service which listens to locally-reported metrics\n // and sends them to our backend.\n .run(reportGloballyScopedMetrics)\n .run(businessEventsReporterFactory);\n\n // Run the exception logger so that it can subscribe to log events -- we can't use `Container.run()` because\n // reportGlobalException is also used as a dependency by other Services (and run does not provide Services,\n // it just runs them once).\n telemetryContainer.get(reportGlobalException.token);\n\n // At this point, logger is configured to report to console and Blizzard.\n\n await assertPlatformSupported();\n\n // LensCore is a foundational component which must be created asynchronously.\n // But it's annoying for every consumer of LensCore to have to wait on Promise<LensCore>\n // (which means they become async themselves). So we'll create a DI container which provides Promise<LensCore>,\n // wait for that promise once here, then create a new DI container that just contains LensCore.\n const lensCore = await telemetryContainer.provides(lensCoreFactory).get(lensCoreFactory.token);\n\n const container = telemetryContainer\n .provides(Injectable(lensCoreFactory.token, () => lensCore))\n .provides(lensesClientFactory)\n .provides(remoteApiSpecsClientFactory)\n .provides(cameraKitLensSourceFactory)\n .provides(lensPersistenceStoreFactory)\n .provides(deviceDependentAssetLoaderFactory)\n .provides(staticAssetLoaderFactory)\n .provides(lensAssetRepositoryFactory)\n .provides(lensRepositoryFactory)\n .provides(cameraKitFactory)\n .run(fetchWatermarkLens);\n\n const cameraKit = container.get(cameraKitFactory.token);\n\n bootstrapLatency.measure();\n container.get(metricsClientFactory.token).setOperationalMetrics(bootstrapLatency);\n\n return cameraKit;\n } catch (error) {\n if (shouldWrapError(error)) {\n error = bootstrapError(\"Error occurred during Camera Kit bootstrapping.\", error);\n }\n logger.error(error);\n throw error;\n }\n}\n\n/**\n * Extensions offer a way to provide custom implementations of certain parts of the CameraKit SDK.\n *\n * This enables more advanced use-cases, in which the default behavior of the SDK is substantially altered. For example,\n * replacing the default implementation that loads remote lens assets with a custom implementation that returns\n * different assets based on some business logic within the application.\n *\n * An extension is implemented as a {@link PartialContainer} – a collection of factory functions, each with its own\n * dependencies, which each provide some \"Service\". A Service can be of any type, and the CameraKit SDK defines its\n * own Services, some of which can be overridden by providing a custom implementation of the type via an extension.\n *\n * Here's an example of how extensions might be used:\n * ```ts\n * import { bootstrapCameraKit, createExtension, remoteMediaAssetLoaderFactory } from '@snap/camera-kit'\n *\n * const myCustomRemoteAssetLoader = Injectable(\n * remoteMediaAssetLoaderFactory.token,\n * [remoteMediaAssetLoaderFactory.token] as const,\n * (defaultLoader: AssetLoader): AssetLoader => {\n * return async (asset, lens) => {\n * if (lens?.id === MY_SPECIAL_LENS) {\n * return (await fetch('my/asset.glb')).arrayBuffer()\n * }\n * return defaultLoader(asset, lens)\n * }\n * },\n * )\n *\n * const myExtension = createExtension().provides(myCustomRemoteAssetLoader);\n * const cameraKit = bootstrapCameraKit(config, container => container.provides(myExtension));\n * ```\n *\n * This also enables greater modularity – the person/team creating the extension can do so in their own package, which\n * could be shared by many applications that all require the same functionality.\n *\n * @returns A {@link PartialContainer} which can be used to create a collection of Services, and can later be provided\n * to CameraKit's DI container during {@link bootstrapCameraKit}.\n *\n * @category Bootstrapping and Configuration\n */\nexport function createExtension(): PartialContainer {\n return new PartialContainer({});\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import { RemoteApiSpecsDefinition } from "../generated-proto/pb_schema/camera_kit/v3/remote_api_spec";
2
+ import type { TsProtoServiceClient } from "./createTsProtoClient";
3
+ import type { GrpcHandler } from "./grpcHandler";
4
+ export type RemoteApiSpecsClient = TsProtoServiceClient<typeof RemoteApiSpecsDefinition>;
5
+ export declare const remoteApiSpecsClientFactory: {
6
+ (args_0: GrpcHandler): RemoteApiSpecsClient;
7
+ token: "remoteApiSpecsClient";
8
+ dependencies: readonly ["grpcHandlerFactory"];
9
+ };
10
+ //# sourceMappingURL=remoteApiSpecsClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remoteApiSpecsClient.d.ts","sourceRoot":"","sources":["../../src/clients/remoteApiSpecsClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,4DAA4D,CAAC;AACtG,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAElE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGjD,MAAM,MAAM,oBAAoB,GAAG,oBAAoB,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAEzF,eAAO,MAAM,2BAA2B;;;;CAIvC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { Injectable } from "@snap/ts-inject";
2
+ import { RemoteApiSpecsDefinition } from "../generated-proto/pb_schema/camera_kit/v3/remote_api_spec";
3
+ import { createTsProtoClient } from "./createTsProtoClient";
4
+ import { grpcHandlerFactory } from "./grpcHandler";
5
+ export const remoteApiSpecsClientFactory = Injectable("remoteApiSpecsClient", [grpcHandlerFactory.token], (grpcHandler) => createTsProtoClient(RemoteApiSpecsDefinition, grpcHandler));
6
+ //# sourceMappingURL=remoteApiSpecsClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remoteApiSpecsClient.js","sourceRoot":"","sources":["../../src/clients/remoteApiSpecsClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,wBAAwB,EAAE,MAAM,4DAA4D,CAAC;AAEtG,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAInD,MAAM,CAAC,MAAM,2BAA2B,GAAG,UAAU,CACjD,sBAAsB,EACtB,CAAC,kBAAkB,CAAC,KAAK,CAAU,EACnC,CAAC,WAAwB,EAAwB,EAAE,CAAC,mBAAmB,CAAC,wBAAwB,EAAE,WAAW,CAAC,CACjH,CAAC","sourcesContent":["import { Injectable } from \"@snap/ts-inject\";\nimport { RemoteApiSpecsDefinition } from \"../generated-proto/pb_schema/camera_kit/v3/remote_api_spec\";\nimport type { TsProtoServiceClient } from \"./createTsProtoClient\";\nimport { createTsProtoClient } from \"./createTsProtoClient\";\nimport type { GrpcHandler } from \"./grpcHandler\";\nimport { grpcHandlerFactory } from \"./grpcHandler\";\n\nexport type RemoteApiSpecsClient = TsProtoServiceClient<typeof RemoteApiSpecsDefinition>;\n\nexport const remoteApiSpecsClientFactory = Injectable(\n \"remoteApiSpecsClient\",\n [grpcHandlerFactory.token] as const,\n (grpcHandler: GrpcHandler): RemoteApiSpecsClient => createTsProtoClient(RemoteApiSpecsDefinition, grpcHandler)\n);\n"]}
@@ -26,6 +26,8 @@ export declare function isTypedArray<T>(value: unknown): value is T;
26
26
  * Guards given object is not undefined.
27
27
  */
28
28
  export declare function isUndefined<T>(value: unknown): value is T;
29
+ export declare function isEmptyString(value: unknown): value is "";
30
+ export declare function isUndefinedOrEmptyString(value: unknown): value is "" | undefined;
29
31
  /**
30
32
  * Narrow an unknown type to a Record (i.e. a non-null JS object). This holds true for class instances, not just
31
33
  * plain objects.
@@ -64,5 +66,6 @@ export declare function predicateRecordValues<T>(predicate: (value: unknown) =>
64
66
  * @returns True if URL is valid.
65
67
  */
66
68
  export declare function isEmptyOrSafeUrl(urlString: string | undefined): boolean;
69
+ export declare function isPromise<T>(value: unknown): value is Promise<T>;
67
70
  export {};
68
71
  //# sourceMappingURL=typeguards.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"typeguards.d.ts","sourceRoot":"","sources":["../../src/common/typeguards.ts"],"names":[],"mappings":"AAAA,KAAK,aAAa,CAAC,CAAC,GAAG,OAAO,IAAI,MAAM,CAAC,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC,CAAC;AAEtE,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC;AAEtD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAExD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAA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,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAQvE;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAAC,CAAC,CAAC,CAKhE"}
@@ -31,6 +31,12 @@ export function isTypedArray(value) {
31
31
  export function isUndefined(value) {
32
32
  return typeof value === "undefined";
33
33
  }
34
+ export function isEmptyString(value) {
35
+ return value === "";
36
+ }
37
+ export function isUndefinedOrEmptyString(value) {
38
+ return isUndefined(value) || isEmptyString(value);
39
+ }
34
40
  export function isRecord(value) {
35
41
  return typeof value === "object" && value !== null && !Array.isArray(value);
36
42
  }
@@ -65,4 +71,10 @@ export function isEmptyOrSafeUrl(urlString) {
65
71
  return false;
66
72
  }
67
73
  }
74
+ export function isPromise(value) {
75
+ if (!value)
76
+ return false;
77
+ const maybePromise = value;
78
+ return typeof maybePromise.then === "function" && typeof maybePromise.catch === "function";
79
+ }
68
80
  //# sourceMappingURL=typeguards.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"typeguards.js","sourceRoot":"","sources":["../../src/common/typeguards.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,QAAQ,CAAC,KAAc;IACnC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACrC,CAAC;AAQD,MAAM,UAAU,YAAY,CAAC,KAAc;IACvC,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,kBAAkB,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,KAAc;IACnC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACrC,CAAC;AACD,MAAM,UAAU,aAAa,CAAC,KAAc;IACxC,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC7E,CAAC;AACD,MA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O,WAAW,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC;AAC/C,CAAC;AAOD,MAAM,UAAU,WAAW,CAAC,KAAc;IACtC,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;AACpD,CAAC;AAQD,MAAM,UAAU,qBAAqB,CAAI,SAAyC;IAC9E,OAAO,CAAC,KAAoB,EAA6B,EAAE;QACvD,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;YAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;gBAAE,OAAO,KAAK,CAAC;QACtE,OAAO,IAAI,CAAC;IAChB,CAAC,CAAC;AACN,CAAC;AAUD,MAAM,UAAU,gBAAgB,CAAC,SAA6B;IAC1D,IAAI,CAAC,SAAS;QAAE,OAAO,IAAI,CAAC;IAC5B,IAAI;QACA,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC;QAC/B,OAAO,GAAG,CAAC,QAAQ,KAAK,QAAQ,IAAI,GAAG,CAAC,QAAQ,KAAK,OAAO,CAAC;KAChE;IAAC,WAAM;QACJ,OAAO,KAAK,CAAC;KAChB;AACL,CAAC","sourcesContent":["type UnknownRecord<T = unknown> = Record<string | number | symbol, T>;\n\nexport type Guard<T> = (value: unknown) => value is T;\n\nexport function isString(value: unknown): value is string {\n return typeof value === \"string\";\n}\n\n/**\n * Ensures given value is a safe string.\n *\n * Safe strings allow to prevent CRLF attacks. We use encoding approach inspired by:\n * https://community.veracode.com/s/question/0D53n00007hJJV5CAO/is-cwe-id-117-intended-for-consolelog\n */\nexport function isSafeString(value: unknown): value is string {\n return isString(value) && encodeURIComponent(value) === value;\n}\n\nexport function isNumber(value: unknown): value is number {\n return typeof value === \"number\";\n}\nexport function isValidNumber(value: unknown): value is number {\n return isNumber(value) && !Number.isNaN(value) && Number.isFinite(value);\n}\nexport function isValidNumberOrUndefined(value: unknown): value is number | undefined {\n return isUndefined(value) || isValidNumber(value);\n}\n\nexport function isArrayOfType<T>(elementTypeGuard: Guard<T>, value: unknown): value is T[] {\n return Array.isArray(value) && value.every((id) => elementTypeGuard(id));\n}\n\nexport function isSafeStringArray(value: unknown): value is string[] {\n return isArrayOfType(isSafeString, value);\n}\n\nexport function isStringOrUndefined(value: unknown): value is string | undefined {\n return isUndefined(value) || isString(value);\n}\n\n/**\n * Guards given value is instance of ArrayBuffer.\n */\nexport function isArrayBuffer(value: unknown): value is ArrayBuffer {\n return value instanceof ArrayBuffer;\n}\n\n/**\n * Guards given value is a typed array.\n */\nexport function isTypedArray<T>(value: unknown): value is T {\n return value instanceof Object.getPrototypeOf(Uint8Array);\n}\n\n/**\n * Guards given object is not undefined.\n */\nexport function isUndefined<T>(value: unknown): value is T {\n return typeof value === \"undefined\";\n}\n\n/**\n * Narrow an unknown type to a Record (i.e. a non-null JS object). This holds true for class instances, not just\n * plain objects.\n */\nexport function isRecord(value: unknown): value is UnknownRecord {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * Check if the value is an arbitrary function\n */\nexport function isFunction(value: unknown): value is (...args: unknown[]) => unknown {\n return typeof value === \"function\";\n}\n\n/**\n * Type guard function to check if a value is an instance of Date.\n * @param value - The value to check.\n * @returns True if the value is a Date, false otherwise.\n */\nexport function isDate(value: unknown): value is Date {\n return value instanceof Date;\n}\n\nexport function isDateOrUndefined(value: unknown): value is Date | undefined {\n return isUndefined(value) || isDate(value);\n}\n\n/**\n * Type guard function to check if a value is an instance of Date and represents a valid date.\n * @param value - The value to check.\n * @returns True if the value is a valid Date, false otherwise.\n */\nexport function isValidDate(value: unknown): value is Date {\n return isDate(value) && !isNaN(value.getTime());\n}\n\n/**\n * Apply a given type predicate asserting values are of type T to each value in a Record.\n *\n * @param predicate Any unary type predicate\n * @returns A type predicate which takes an UnknownRecord and tests that all its values are of type T\n */\nexport function predicateRecordValues<T>(predicate: (value: unknown) => value is T) {\n return (value: UnknownRecord): value is UnknownRecord<T> => {\n for (const v of Object.values(value)) if (!predicate(v)) return false;\n return true;\n };\n}\n\n/**\n * Checks whether given value is undefined or a safe URL string.\n *\n * The function checks whether given string is a valid URL with https: protocol.\n *\n * @param urlString URL string to check.\n * @returns True if URL is valid.\n */\nexport function isEmptyOrSafeUrl(urlString: string | undefined): boolean {\n if (!urlString) return true;\n try {\n const url = new URL(urlString);\n return url.protocol === \"https:\" || url.protocol === \"http:\";\n } catch {\n return false;\n }\n}\n"]}
1
+ {"version":3,"file":"typeguards.js","sourceRoot":"","sources":["../../src/common/typeguards.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,QAAQ,CAAC,KAAc;IACnC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACrC,CAAC;AAQD,MAAM,UAAU,YAAY,CAAC,KAAc;IACvC,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,kBAAkB,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,KAAc;IACnC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACrC,CAAC;AACD,MAAM,UAAU,aAAa,CAAC,KAAc;IACxC,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC7E,CAAC;AACD,MAAM,UAAU,wBAAwB,CAAC,KAAc;IACnD,OAAO,WAAW,CAAC,KAAK,CAAC,IAAI,aAAa,CAAC,KAAK,CAAC,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,aAAa,CAAI,gBAA0B,EAAE,KAAc;IACvE,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC,CAAC;AAC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c;IACtC,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;AACpD,CAAC;AAQD,MAAM,UAAU,qBAAqB,CAAI,SAAyC;IAC9E,OAAO,CAAC,KAAoB,EAA6B,EAAE;QACvD,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;YAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;gBAAE,OAAO,KAAK,CAAC;QACtE,OAAO,IAAI,CAAC;IAChB,CAAC,CAAC;AACN,CAAC;AAUD,MAAM,UAAU,gBAAgB,CAAC,SAA6B;IAC1D,IAAI,CAAC,SAAS;QAAE,OAAO,IAAI,CAAC;IAC5B,IAAI;QACA,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC;QAC/B,OAAO,GAAG,CAAC,QAAQ,KAAK,QAAQ,IAAI,GAAG,CAAC,QAAQ,KAAK,OAAO,CAAC;KAChE;IAAC,WAAM;QACJ,OAAO,KAAK,CAAC;KAChB;AACL,CAAC;AAED,MAAM,UAAU,SAAS,CAAI,KAAc;IACvC,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IAEzB,MAAM,YAAY,GAAG,KAAmB,CAAC;IACzC,OAAO,OAAO,YAAY,CAAC,IAAI,KAAK,UAAU,IAAI,OAAO,YAAY,CAAC,KAAK,KAAK,UAAU,CAAC;AAC/F,CAAC","sourcesContent":["type UnknownRecord<T = unknown> = Record<string | number | symbol, T>;\n\nexport type Guard<T> = (value: unknown) => value is T;\n\nexport function isString(value: unknown): value is string {\n return typeof value === \"string\";\n}\n\n/**\n * Ensures given value is a safe string.\n *\n * Safe strings allow to prevent CRLF attacks. We use encoding approach inspired by:\n * https://community.veracode.com/s/question/0D53n00007hJJV5CAO/is-cwe-id-117-intended-for-consolelog\n */\nexport function isSafeString(value: unknown): value is string {\n return isString(value) && encodeURIComponent(value) === value;\n}\n\nexport function isNumber(value: unknown): value is number {\n return typeof value === \"number\";\n}\nexport function isValidNumber(value: unknown): value is number {\n return isNumber(value) && !Number.isNaN(value) && Number.isFinite(value);\n}\nexport function isValidNumberOrUndefined(value: unknown): value is number | undefined {\n return isUndefined(value) || isValidNumber(value);\n}\n\nexport function isArrayOfType<T>(elementTypeGuard: Guard<T>, value: unknown): value is T[] {\n return Array.isArray(value) && value.every((id) => elementTypeGuard(id));\n}\n\nexport function isSafeStringArray(value: unknown): value is string[] {\n return isArrayOfType(isSafeString, value);\n}\n\nexport function isStringOrUndefined(value: unknown): value is string | undefined {\n return isUndefined(value) || isString(value);\n}\n\n/**\n * Guards given value is instance of ArrayBuffer.\n */\nexport function isArrayBuffer(value: unknown): value is ArrayBuffer {\n return value instanceof ArrayBuffer;\n}\n\n/**\n * Guards given value is a typed array.\n */\nexport function isTypedArray<T>(value: unknown): value is T {\n return value instanceof Object.getPrototypeOf(Uint8Array);\n}\n\n/**\n * Guards given object is not undefined.\n */\nexport function isUndefined<T>(value: unknown): value is T {\n return typeof value === \"undefined\";\n}\n\nexport function isEmptyString(value: unknown): value is \"\" {\n return value === \"\";\n}\n\nexport function isUndefinedOrEmptyString(value: unknown): value is \"\" | undefined {\n return isUndefined(value) || isEmptyString(value);\n}\n\n/**\n * Narrow an unknown type to a Record (i.e. a non-null JS object). This holds true for class instances, not just\n * plain objects.\n */\nexport function isRecord(value: unknown): value is UnknownRecord {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * Check if the value is an arbitrary function\n */\nexport function isFunction(value: unknown): value is (...args: unknown[]) => unknown {\n return typeof value === \"function\";\n}\n\n/**\n * Type guard function to check if a value is an instance of Date.\n * @param value - The value to check.\n * @returns True if the value is a Date, false otherwise.\n */\nexport function isDate(value: unknown): value is Date {\n return value instanceof Date;\n}\n\nexport function isDateOrUndefined(value: unknown): value is Date | undefined {\n return isUndefined(value) || isDate(value);\n}\n\n/**\n * Type guard function to check if a value is an instance of Date and represents a valid date.\n * @param value - The value to check.\n * @returns True if the value is a valid Date, false otherwise.\n */\nexport function isValidDate(value: unknown): value is Date {\n return isDate(value) && !isNaN(value.getTime());\n}\n\n/**\n * Apply a given type predicate asserting values are of type T to each value in a Record.\n *\n * @param predicate Any unary type predicate\n * @returns A type predicate which takes an UnknownRecord and tests that all its values are of type T\n */\nexport function predicateRecordValues<T>(predicate: (value: unknown) => value is T) {\n return (value: UnknownRecord): value is UnknownRecord<T> => {\n for (const v of Object.values(value)) if (!predicate(v)) return false;\n return true;\n };\n}\n\n/**\n * Checks whether given value is undefined or a safe URL string.\n *\n * The function checks whether given string is a valid URL with https: protocol.\n *\n * @param urlString URL string to check.\n * @returns True if URL is valid.\n */\nexport function isEmptyOrSafeUrl(urlString: string | undefined): boolean {\n if (!urlString) return true;\n try {\n const url = new URL(urlString);\n return url.protocol === \"https:\" || url.protocol === \"http:\";\n } catch {\n return false;\n }\n}\n\nexport function isPromise<T>(value: unknown): value is Promise<T> {\n if (!value) return false;\n\n const maybePromise = value as Promise<T>;\n return typeof maybePromise.then === \"function\" && typeof maybePromise.catch === \"function\";\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  import type { EstimatedLensPerformance } from "./benchmark/estimateLensPerformanceCluster";
2
+ import type { Lens } from "./lens/Lens";
2
3
  import type { LogLevelName } from "./logger/logger";
3
4
  interface CameraKitRuntimeConfiguration {
4
5
  lensPerformance: EstimatedLensPerformance | Promise<EstimatedLensPerformance>;
@@ -7,8 +8,68 @@ interface CameraKitRuntimeConfiguration {
7
8
  shouldUseWorker: boolean;
8
9
  apiHostname: CameraKitApiHostname;
9
10
  userAgentFlavor: "release" | "debug";
11
+ fonts: Font[];
12
+ lensHttpHandler?: LensHttpHandler;
10
13
  }
11
14
  export type CameraKitApiHostname = "camera-kit-api.snapar.com" | "api-kit.snapchat.com";
15
+ /**
16
+ * Represents a font to be used by Camera Kit for text rendering.
17
+ */
18
+ export interface Font {
19
+ /**
20
+ * A unique name for the font.
21
+ */
22
+ name: string;
23
+ /**
24
+ * A buffer containing the font data (e.g., the contents of a `.ttf` file).
25
+ */
26
+ data: ArrayBuffer;
27
+ }
28
+ /**
29
+ * Represents context for an HTTP request made by a Lens.
30
+ *
31
+ * This interface provides detailed information about the request, such as its identifier,
32
+ * method, data payload, headers, and associated Lens object.
33
+ */
34
+ export interface LensHttpRequest {
35
+ /**
36
+ * The URL of the HTTP request.
37
+ */
38
+ url: string;
39
+ /**
40
+ * A unique identifier for the HTTP request.
41
+ */
42
+ identifier: string;
43
+ /**
44
+ * The HTTP method of the request (e.g., GET, POST, PUT, DELETE).
45
+ */
46
+ method: string;
47
+ /**
48
+ * The raw data payload for the HTTP request, represented as an `ArrayBuffer`.
49
+ */
50
+ data: ArrayBuffer;
51
+ /**
52
+ * The headers included in the HTTP request.
53
+ */
54
+ headers: Record<string, string>;
55
+ /**
56
+ * The {@link Lens} that initiated this request.
57
+ */
58
+ lens: Lens;
59
+ }
60
+ /**
61
+ * A handler function for customizing HTTP requests made by a Lens.
62
+ *
63
+ * This function is called whenever a Lens makes an HTTP request.
64
+ * It allows you to modify the request or response, integrate custom HTTP libraries,
65
+ * add authentication, or log request details.
66
+ *
67
+ * @param url - The URL for the HTTP request.
68
+ * @param init - The initial configuration for the HTTP request, following the Fetch API's `RequestInit`.
69
+ * @param lensRequest - Additional context about the Lens-specific request.
70
+ * @returns A Promise resolving to the HTTP response (`Response`).
71
+ */
72
+ export type LensHttpHandler = (url: string, init: RequestInit, lensRequest: LensHttpRequest) => Promise<Response>;
12
73
  /**
13
74
  * Configuration which must be provided when calling {@link bootstrapCameraKit}. These values are used to create various
14
75
  * CameraKit components.
@@ -82,6 +143,60 @@ export interface CameraKitBootstrapConfiguration {
82
143
  * user analytics.
83
144
  */
84
145
  analyticsId?: string;
146
+ /**
147
+ * An array of fonts to be used by Camera Kit for text rendering.
148
+ *
149
+ * Lenses usually have their own font assets, but emojis are often not embedded.
150
+ * As a result, you may need to provide additional fonts (e.g., an emoji font) to ensure all glyphs render
151
+ * correctly.
152
+ *
153
+ * @example
154
+ * fonts: [
155
+ * {
156
+ * name: 'EmojiFont',
157
+ * data: emojiFontArrayBuffer, // Your emoji font data goes here
158
+ * },
159
+ * ]
160
+ */
161
+ fonts?: Font[];
162
+ /**
163
+ * An optional custom HTTP handler for requests made by a Lens.
164
+ *
165
+ * This handler allows you to intercept and customize the behavior of HTTP requests,
166
+ * such as adding authentication headers, logging request details, or replacing the default
167
+ * HTTP library used by the Lens system.
168
+ *
169
+ * If not specified, the Lens system will use a default HTTP implementation.
170
+ *
171
+ * @example
172
+ * Here is an example of how to configure a custom `LensHttpHandler` to add an authentication token:
173
+ *
174
+ * ```typescript
175
+ * const customLensHttpHandler: LensHttpHandler = async (url, init, lensRequest) => {
176
+ * // Add an authentication token to the headers
177
+ * const sessionToken = await getAuthToken();
178
+ * const updatedInit = {
179
+ * ...init,
180
+ * headers: {
181
+ * ...init.headers,
182
+ * 'Authorization': `Bearer ${sessionToken}`,
183
+ * },
184
+ * };
185
+ *
186
+ * // Log the request details for debugging
187
+ * console.log(`Requesting ${lensRequest.url} from lens: ${lensRequest.lens.name}`);
188
+ *
189
+ * // Use fetch to perform the HTTP request
190
+ * return fetch(url, updatedInit);
191
+ * };
192
+ *
193
+ * const cameraKit = bootstrapCameraKit({
194
+ * apiToken,
195
+ * lensHttpHandler: customLensHttpHandler,
196
+ * });
197
+ * ```
198
+ */
199
+ lensHttpHandler?: LensHttpHandler;
85
200
  }
86
201
  /**
87
202
  * This type represents the result of merging user-supplied config with default config -- as such, it has no nullable
@@ -1 +1 @@
1
- {"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../src/configuration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,4CAA4C,CAAC;AAG3F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAyBpD,UAAU,6BAA6B;IACnC,eAAe,EAAE,wBAAwB,GAAG,OAAO,CAAC,wBA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