@snap/camera-kit 1.1.0 → 1.2.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 (256) hide show
  1. package/README.md +1 -1
  2. package/dist/CameraKit.d.ts +13 -6
  3. package/dist/CameraKit.d.ts.map +1 -1
  4. package/dist/CameraKit.js +18 -2
  5. package/dist/CameraKit.js.map +1 -1
  6. package/dist/RootServices.d.ts +2 -0
  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 +2 -0
  11. package/dist/bootstrapCameraKit.js.map +1 -1
  12. package/dist/environment.js +1 -1
  13. package/dist/environment.js.map +1 -1
  14. package/dist/extensions/extensionRequestContext.d.ts +6 -0
  15. package/dist/extensions/extensionRequestContext.d.ts.map +1 -1
  16. package/dist/extensions/extensionRequestContext.js +3 -2
  17. package/dist/extensions/extensionRequestContext.js.map +1 -1
  18. package/dist/geo/geoDataProvider.d.ts +32 -0
  19. package/dist/geo/geoDataProvider.d.ts.map +1 -0
  20. package/dist/geo/geoDataProvider.js +25 -0
  21. package/dist/geo/geoDataProvider.js.map +1 -0
  22. package/dist/geo/registerGeoDataProvider.d.ts +11 -0
  23. package/dist/geo/registerGeoDataProvider.d.ts.map +1 -0
  24. package/dist/geo/registerGeoDataProvider.js +22 -0
  25. package/dist/geo/registerGeoDataProvider.js.map +1 -0
  26. package/dist/index.d.ts +3 -2
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +2 -1
  29. package/dist/index.js.map +1 -1
  30. package/dist/lens-core-module/generated-types.d.ts +28 -0
  31. package/dist/lens-core-module/generated-types.d.ts.map +1 -1
  32. package/dist/lens-core-module/generated-types.js.map +1 -1
  33. package/dist/lens-core-module/lensCore.d.ts.map +1 -1
  34. package/dist/lens-core-module/lensCore.js +1 -0
  35. package/dist/lens-core-module/lensCore.js.map +1 -1
  36. package/dist/lensCoreWasmVersions.js +3 -3
  37. package/dist/lensCoreWasmVersions.js.map +1 -1
  38. package/dist/platform/platformInfo.d.ts.map +1 -1
  39. package/dist/platform/platformInfo.js +1 -1
  40. package/dist/platform/platformInfo.js.map +1 -1
  41. package/dist/remote-configuration/cofHandler.js.map +1 -1
  42. package/dist/remote-configuration/remoteConfiguration.d.ts +4 -0
  43. package/dist/remote-configuration/remoteConfiguration.d.ts.map +1 -1
  44. package/dist/remote-configuration/remoteConfiguration.js +10 -0
  45. package/dist/remote-configuration/remoteConfiguration.js.map +1 -1
  46. package/dist/session/CameraKitSession.d.ts +9 -9
  47. package/dist/session/CameraKitSession.d.ts.map +1 -1
  48. package/dist/session/CameraKitSession.js +4 -2
  49. package/dist/session/CameraKitSession.js.map +1 -1
  50. package/dist/session/LensKeyboard.d.ts +74 -30
  51. package/dist/session/LensKeyboard.d.ts.map +1 -1
  52. package/dist/session/LensKeyboard.js +60 -38
  53. package/dist/session/LensKeyboard.js.map +1 -1
  54. package/dist/uri-handlers/internal-handlers/httpUriHandler.d.ts +7 -0
  55. package/dist/uri-handlers/internal-handlers/httpUriHandler.d.ts.map +1 -1
  56. package/dist/uri-handlers/internal-handlers/httpUriHandler.js +7 -2
  57. package/dist/uri-handlers/internal-handlers/httpUriHandler.js.map +1 -1
  58. package/docs/html/assets/hierarchy.js +1 -1
  59. package/docs/html/assets/navigation.js +1 -1
  60. package/docs/html/assets/search.js +1 -1
  61. package/docs/html/classes/CameraKit.html +2 -2
  62. package/docs/html/classes/CameraKitSession.html +6 -3
  63. package/docs/html/classes/CameraKitSource.html +2 -2
  64. package/docs/html/classes/LensPerformanceMeasurement.html +2 -2
  65. package/docs/html/classes/LensPerformanceMetrics.html +2 -2
  66. package/docs/html/classes/LensRepository.html +2 -2
  67. package/docs/html/classes/Transform2D.html +2 -2
  68. package/docs/html/classes/TypedCustomEvent.html +3 -3
  69. package/docs/html/classes/TypedEventTarget.html +2 -2
  70. package/docs/html/enums/Lens_CameraFacing.html +2 -2
  71. package/docs/html/functions/bootstrapCameraKit.html +2 -2
  72. package/docs/html/functions/createExtension.html +2 -2
  73. package/docs/html/functions/createImageSource.html +2 -2
  74. package/docs/html/functions/createMediaStreamSource.html +2 -2
  75. package/docs/html/functions/createVideoSource.html +2 -2
  76. package/docs/html/functions/estimateLensPerformance.html +2 -2
  77. package/docs/html/functions/filePickerFactory.html +2 -2
  78. package/docs/html/functions/getExtensionRequestContext.html +3 -0
  79. package/docs/html/functions/lensSourcesFactory.html +2 -2
  80. package/docs/html/functions/remoteApiServicesFactory.html +1 -1
  81. package/docs/html/hierarchy.html +1 -1
  82. package/docs/html/index.html +3 -3
  83. package/docs/html/interfaces/BitmojiUserInfo.html +2 -2
  84. package/docs/html/interfaces/CameraKitBootstrapConfiguration.html +2 -2
  85. package/docs/html/interfaces/CameraKitDeviceOptions.html +3 -3
  86. package/docs/html/interfaces/CameraKitSourceInfo.html +2 -2
  87. package/docs/html/interfaces/CameraKitSourceSubscriber.html +2 -2
  88. package/docs/html/interfaces/ComputedFrameMetrics.html +2 -2
  89. package/docs/html/interfaces/CreateSessionOptions.html +2 -2
  90. package/docs/html/interfaces/EstimatedLensPerformance.html +2 -2
  91. package/docs/html/interfaces/Font.html +2 -2
  92. package/docs/html/interfaces/FriendUserInfo.html +2 -2
  93. package/docs/html/interfaces/FunctionSourceOptions.html +2 -2
  94. package/docs/html/interfaces/Keyboard.html +29 -0
  95. package/docs/html/interfaces/KeyboardActiveEvent.html +12 -0
  96. package/docs/html/interfaces/Lens.html +2 -2
  97. package/docs/html/interfaces/LensCreator.html +2 -2
  98. package/docs/html/interfaces/LensHttpRequest.html +2 -2
  99. package/docs/html/interfaces/LensLaunchData.html +2 -2
  100. package/docs/html/interfaces/LensSource.html +2 -2
  101. package/docs/html/interfaces/LensUserData.html +2 -2
  102. package/docs/html/interfaces/LoadAssetRequest.html +2 -2
  103. package/docs/html/interfaces/MediaStreamSourceOptions.html +3 -3
  104. package/docs/html/interfaces/Preview.html +2 -2
  105. package/docs/html/interfaces/RemoteApiRequest.html +2 -2
  106. package/docs/html/interfaces/RemoteApiResponse.html +2 -2
  107. package/docs/html/interfaces/RemoteApiService.html +2 -2
  108. package/docs/html/interfaces/Snapcode.html +2 -2
  109. package/docs/html/interfaces/UriCancelRequest.html +2 -2
  110. package/docs/html/interfaces/UriRequest.html +2 -2
  111. package/docs/html/interfaces/UriResponse.html +2 -2
  112. package/docs/html/interfaces/VideoSourceOptions.html +3 -3
  113. package/docs/html/modules.html +1 -1
  114. package/docs/html/types/ArgumentValidationError.html +2 -2
  115. package/docs/html/types/AssetLoader.html +2 -2
  116. package/docs/html/types/AssetResponse.html +1 -1
  117. package/docs/html/types/AssetTiming.html +2 -2
  118. package/docs/html/types/BenchmarkError.html +1 -1
  119. package/docs/html/types/BootstrapError.html +2 -2
  120. package/docs/html/types/CacheKeyNotFoundError.html +1 -1
  121. package/docs/html/types/CameraKitSessionEventListener.html +2 -2
  122. package/docs/html/types/CameraKitSessionEvents.html +2 -2
  123. package/docs/html/types/CameraKitSourceError.html +1 -1
  124. package/docs/html/types/ConfigurationError.html +2 -2
  125. package/docs/html/types/FetchHandler.html +1 -1
  126. package/docs/html/types/FilePicker.html +2 -2
  127. package/docs/html/types/FilePickerOptions.html +2 -2
  128. package/docs/html/types/FilePickerResult.html +2 -2
  129. package/docs/html/types/KeyboardEventListener.html +2 -0
  130. package/docs/html/types/KeyboardEvents.html +2 -2
  131. package/docs/html/types/LegalError.html +1 -1
  132. package/docs/html/types/LensAbortError.html +2 -2
  133. package/docs/html/types/LensAssetError.html +2 -2
  134. package/docs/html/types/LensContentValidationError.html +1 -1
  135. package/docs/html/types/LensError.html +1 -1
  136. package/docs/html/types/LensExecutionError.html +2 -2
  137. package/docs/html/types/LensHttpHandler.html +2 -2
  138. package/docs/html/types/LensImagePickerError.html +2 -2
  139. package/docs/html/types/LensLaunchParams.html +2 -2
  140. package/docs/html/types/LensMetricsEvents.html +2 -2
  141. package/docs/html/types/LensPerformanceCluster.html +1 -1
  142. package/docs/html/types/LensView.html +2 -2
  143. package/docs/html/types/LensWait.html +2 -2
  144. package/docs/html/types/Matrix.html +2 -2
  145. package/docs/html/types/PersistentStoreError.html +2 -2
  146. package/docs/html/types/PlatformNotSupportedError.html +2 -2
  147. package/docs/html/types/PublicContainer.html +2 -2
  148. package/docs/html/types/PublicServices.html +2 -2
  149. package/docs/html/types/RemoteApiCancelRequestHandler.html +2 -2
  150. package/docs/html/types/RemoteApiRequestHandler.html +2 -2
  151. package/docs/html/types/RemoteApiServices.html +1 -1
  152. package/docs/html/types/RemoteApiStatus.html +2 -2
  153. package/docs/html/types/RenderTarget.html +2 -2
  154. package/docs/html/types/Uri.html +1 -1
  155. package/docs/html/types/WebGLError.html +1 -1
  156. package/docs/html/types/Zodiac.html +1 -1
  157. package/docs/html/variables/extensionRequestContext.html +3 -2
  158. package/docs/md/README.md +2 -2
  159. package/docs/md/classes/CameraKit.md +1 -1
  160. package/docs/md/classes/CameraKitSession.md +6 -3
  161. package/docs/md/classes/CameraKitSource.md +1 -1
  162. package/docs/md/classes/LensPerformanceMeasurement.md +1 -1
  163. package/docs/md/classes/LensPerformanceMetrics.md +1 -1
  164. package/docs/md/classes/LensRepository.md +1 -1
  165. package/docs/md/classes/Transform2D.md +1 -1
  166. package/docs/md/classes/TypedCustomEvent.md +1 -1
  167. package/docs/md/classes/TypedEventTarget.md +1 -1
  168. package/docs/md/enumerations/Lens_CameraFacing.md +1 -1
  169. package/docs/md/functions/bootstrapCameraKit.md +1 -1
  170. package/docs/md/functions/createExtension.md +1 -1
  171. package/docs/md/functions/createImageSource.md +1 -1
  172. package/docs/md/functions/createMediaStreamSource.md +1 -1
  173. package/docs/md/functions/createVideoSource.md +1 -1
  174. package/docs/md/functions/estimateLensPerformance.md +1 -1
  175. package/docs/md/functions/filePickerFactory.md +1 -1
  176. package/docs/md/functions/getExtensionRequestContext.md +21 -0
  177. package/docs/md/functions/lensSourcesFactory.md +1 -1
  178. package/docs/md/functions/remoteApiServicesFactory.md +1 -1
  179. package/docs/md/globals.md +6 -3
  180. package/docs/md/interfaces/BitmojiUserInfo.md +1 -1
  181. package/docs/md/interfaces/CameraKitBootstrapConfiguration.md +1 -1
  182. package/docs/md/interfaces/CameraKitDeviceOptions.md +1 -1
  183. package/docs/md/interfaces/CameraKitSourceInfo.md +1 -1
  184. package/docs/md/interfaces/CameraKitSourceSubscriber.md +1 -1
  185. package/docs/md/interfaces/ComputedFrameMetrics.md +1 -1
  186. package/docs/md/interfaces/CreateSessionOptions.md +1 -1
  187. package/docs/md/interfaces/EstimatedLensPerformance.md +1 -1
  188. package/docs/md/interfaces/Font.md +1 -1
  189. package/docs/md/interfaces/FriendUserInfo.md +1 -1
  190. package/docs/md/interfaces/FunctionSourceOptions.md +1 -1
  191. package/docs/md/interfaces/Keyboard.md +137 -0
  192. package/docs/md/interfaces/KeyboardActiveEvent.md +46 -0
  193. package/docs/md/interfaces/Lens.md +1 -1
  194. package/docs/md/interfaces/LensCreator.md +1 -1
  195. package/docs/md/interfaces/LensHttpRequest.md +1 -1
  196. package/docs/md/interfaces/LensLaunchData.md +1 -1
  197. package/docs/md/interfaces/LensSource.md +1 -1
  198. package/docs/md/interfaces/LensUserData.md +1 -1
  199. package/docs/md/interfaces/LoadAssetRequest.md +1 -1
  200. package/docs/md/interfaces/MediaStreamSourceOptions.md +1 -1
  201. package/docs/md/interfaces/Preview.md +1 -1
  202. package/docs/md/interfaces/RemoteApiRequest.md +1 -1
  203. package/docs/md/interfaces/RemoteApiResponse.md +1 -1
  204. package/docs/md/interfaces/RemoteApiService.md +1 -1
  205. package/docs/md/interfaces/Snapcode.md +1 -1
  206. package/docs/md/interfaces/UriCancelRequest.md +1 -1
  207. package/docs/md/interfaces/UriRequest.md +1 -1
  208. package/docs/md/interfaces/UriResponse.md +1 -1
  209. package/docs/md/interfaces/VideoSourceOptions.md +1 -1
  210. package/docs/md/type-aliases/ArgumentValidationError.md +1 -1
  211. package/docs/md/type-aliases/AssetLoader.md +1 -1
  212. package/docs/md/type-aliases/AssetResponse.md +1 -1
  213. package/docs/md/type-aliases/AssetTiming.md +1 -1
  214. package/docs/md/type-aliases/BenchmarkError.md +1 -1
  215. package/docs/md/type-aliases/BootstrapError.md +1 -1
  216. package/docs/md/type-aliases/CacheKeyNotFoundError.md +1 -1
  217. package/docs/md/type-aliases/CameraKitSessionEventListener.md +1 -1
  218. package/docs/md/type-aliases/CameraKitSessionEvents.md +1 -1
  219. package/docs/md/type-aliases/CameraKitSourceError.md +1 -1
  220. package/docs/md/type-aliases/ConfigurationError.md +1 -1
  221. package/docs/md/type-aliases/FetchHandler.md +1 -1
  222. package/docs/md/type-aliases/FilePicker.md +1 -1
  223. package/docs/md/type-aliases/FilePickerOptions.md +1 -1
  224. package/docs/md/type-aliases/FilePickerResult.md +1 -1
  225. package/docs/md/type-aliases/KeyboardEventListener.md +11 -0
  226. package/docs/md/type-aliases/KeyboardEvents.md +3 -3
  227. package/docs/md/type-aliases/LegalError.md +1 -1
  228. package/docs/md/type-aliases/LensAbortError.md +1 -1
  229. package/docs/md/type-aliases/LensAssetError.md +1 -1
  230. package/docs/md/type-aliases/LensContentValidationError.md +1 -1
  231. package/docs/md/type-aliases/LensError.md +1 -1
  232. package/docs/md/type-aliases/LensExecutionError.md +1 -1
  233. package/docs/md/type-aliases/LensHttpHandler.md +1 -1
  234. package/docs/md/type-aliases/LensImagePickerError.md +1 -1
  235. package/docs/md/type-aliases/LensLaunchParams.md +1 -1
  236. package/docs/md/type-aliases/LensMetricsEvents.md +1 -1
  237. package/docs/md/type-aliases/LensPerformanceCluster.md +1 -1
  238. package/docs/md/type-aliases/LensView.md +1 -1
  239. package/docs/md/type-aliases/LensWait.md +1 -1
  240. package/docs/md/type-aliases/Matrix.md +1 -1
  241. package/docs/md/type-aliases/PersistentStoreError.md +1 -1
  242. package/docs/md/type-aliases/PlatformNotSupportedError.md +1 -1
  243. package/docs/md/type-aliases/PublicContainer.md +1 -1
  244. package/docs/md/type-aliases/PublicServices.md +2 -2
  245. package/docs/md/type-aliases/RemoteApiCancelRequestHandler.md +1 -1
  246. package/docs/md/type-aliases/RemoteApiRequestHandler.md +1 -1
  247. package/docs/md/type-aliases/RemoteApiServices.md +1 -1
  248. package/docs/md/type-aliases/RemoteApiStatus.md +1 -1
  249. package/docs/md/type-aliases/RenderTarget.md +1 -1
  250. package/docs/md/type-aliases/Uri.md +1 -1
  251. package/docs/md/type-aliases/WebGLError.md +1 -1
  252. package/docs/md/type-aliases/Zodiac.md +1 -1
  253. package/docs/md/variables/extensionRequestContext.md +6 -2
  254. package/package.json +2 -2
  255. package/docs/html/types/Keyboard.html +0 -19
  256. package/docs/md/type-aliases/Keyboard.md +0 -114
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.1.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.2.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
 
@@ -10,6 +10,7 @@ import type { TypedCustomEvent } from "./events/TypedCustomEvent";
10
10
  import type { LensView } from "./metrics/reporters/reportLensView";
11
11
  import type { LensWait } from "./metrics/reporters/reportLensWait";
12
12
  import type { PageVisibility } from "./common/pageVisibility";
13
+ import type { RemoteConfiguration } from "./remote-configuration/remoteConfiguration";
13
14
  /**
14
15
  * Lens metrics events.
15
16
  *
@@ -68,6 +69,7 @@ export declare class CameraKit {
68
69
  private readonly lensCore;
69
70
  private readonly pageVisibility;
70
71
  private readonly container;
72
+ private readonly remoteConfig;
71
73
  /** @deprecated Use {@link lensRepository} */
72
74
  readonly lenses: {
73
75
  repository: LensRepository;
@@ -82,7 +84,7 @@ export declare class CameraKit {
82
84
  /**
83
85
  * Used to query for lenses and lens groups.
84
86
  */
85
- lensRepository: LensRepository, lensCore: LensCore, pageVisibility: PageVisibility, container: Container<RootServices>, allMetrics: MetricsEventTarget);
87
+ lensRepository: LensRepository, lensCore: LensCore, pageVisibility: PageVisibility, container: Container<RootServices>, remoteConfig: RemoteConfiguration, allMetrics: MetricsEventTarget);
86
88
  /**
87
89
  * Create a CameraKitSession.
88
90
  *
@@ -202,6 +204,8 @@ export declare const cameraKitFactory: {
202
204
  setSystemFonts: (config: import("./lens-core-module/generated-types").SetSystemFontsInput) => void;
203
205
  registerBeginWebXrHandler: (handler: ((config: import("./lens-core-module/generated-types").BeginWebXrInput) => void) | null) => void;
204
206
  registerEndWebXrHandler: (handler: (() => void) | null) => void;
207
+ setGeoDataProvider: (provider: import("./lens-core-module/generated-types").SetGeoDataProviderInput) => void;
208
+ provideGeoData: (config: import("./lens-core-module/generated-types").ProvideGeoDataInput) => void;
205
209
  } & {
206
210
  processFrame: (input: Omit<import("./lens-core-module/generated-types").ProcessFrameInput, "onFailure" | "onSuccess">) => Promise<any>;
207
211
  addLens: (input: Omit<import("./lens-core-module/generated-types").AddLensInput, "onFailure" | "onSuccess">) => Promise<any>;
@@ -221,6 +225,7 @@ export declare const cameraKitFactory: {
221
225
  setDeviceClass: (input: Omit<import("./lens-core-module/generated-types").SetDeviceClassInput, "onFailure" | "onSuccess">) => Promise<any>;
222
226
  setAudioParameters: (input: Omit<import("./lens-core-module/generated-types").SetAudioParametersInput, "onFailure" | "onSuccess">) => Promise<any>;
223
227
  processAudioSampleBuffer: (input: Omit<import("./lens-core-module/generated-types").ProcessAudioSampleBufferInput, "onFailure" | "onSuccess">) => Promise<any>;
228
+ setGpuIndex: (input: Omit<import("./lens-core-module/generated-types").SetGpuIndexInput, "onFailure" | "onSuccess">) => Promise<any>;
224
229
  } & {
225
230
  initialize(input: {
226
231
  canvas?: string | HTMLCanvasElement | undefined;
@@ -239,7 +244,7 @@ export declare const cameraKitFactory: {
239
244
  onFailure?: ((err: LensCoreError) => void) | undefined;
240
245
  }): void;
241
246
  playCanvas(input: Omit<import("./lens-core-module/generated-types").PlayCanvasInput, "onFailure" | "onSuccess" | "onReady">): Promise<void>;
242
- } & import("./lens-core-module/lensCore").LensCoreErrorField, args_3: PageVisibility, args_4: Container<{
247
+ } & import("./lens-core-module/lensCore").LensCoreErrorField, args_3: PageVisibility, args_4: RemoteConfiguration, args_5: Container<{
243
248
  LensRepository: LensRepository;
244
249
  } & {
245
250
  metricsEventTarget: MetricsEventTarget;
@@ -247,6 +252,8 @@ export declare const cameraKitFactory: {
247
252
  lensCore: LensCore;
248
253
  } & {
249
254
  pageVisibility: PageVisibility;
255
+ } & {
256
+ remoteConfiguration: RemoteConfiguration;
250
257
  } & {
251
258
  lensCore: LensCore;
252
259
  } & import("./RootServices").PublicServices & import("@snap/ts-inject").ServicesFromInjectables<[{
@@ -288,7 +295,7 @@ export declare const cameraKitFactory: {
288
295
  (args_0: import("./configuration").CameraKitConfiguration, args_1: 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 & {
289
296
  signal?: AbortSignal | null | undefined;
290
297
  isSideEffect?: boolean | undefined;
291
- }>, args_2: import("./clients/grpcHandler").GrpcHandler): import("./remote-configuration/remoteConfiguration").RemoteConfiguration;
298
+ }>, args_2: import("./clients/grpcHandler").GrpcHandler): RemoteConfiguration;
292
299
  token: "remoteConfiguration";
293
300
  dependencies: readonly ["configuration", "cofHandler", "grpcHandlerFactory"];
294
301
  }, {
@@ -308,7 +315,7 @@ export declare const cameraKitFactory: {
308
315
  token: "lensAssetRepository";
309
316
  dependencies: readonly ["lensCore", "deviceDependentAssetLoader", "remoteMediaAssetLoader", "staticAssetLoader", "metricsEventTarget", "requestStateEventTarget"];
310
317
  }, {
311
- (args_0: import(".").FetchHandler, args_1: import("./remote-configuration/remoteConfiguration").RemoteConfiguration): import(".").AssetLoader;
318
+ (args_0: import(".").FetchHandler, args_1: RemoteConfiguration): import(".").AssetLoader;
312
319
  token: "deviceDependentAssetLoader";
313
320
  dependencies: readonly ["defaultFetchHandler", "remoteConfiguration"];
314
321
  }, {
@@ -316,7 +323,7 @@ export declare const cameraKitFactory: {
316
323
  token: "staticAssetLoader";
317
324
  dependencies: readonly ["defaultFetchHandler"];
318
325
  }, {
319
- (args_0: import("./remote-configuration/remoteConfiguration").RemoteConfiguration, args_1: import("./legal/legalPrompt").LegalPromptFactory): import("@snap/state-management").StateMachine<import("@snap/state-management").Action<"requestLegalPrompt", undefined> | import("@snap/state-management").Action<"accept", string> | import("@snap/state-management").Action<"reject", string>, import("@snap/state-management").State<"unknown", undefined> | import("@snap/state-management").State<"accepted", undefined> | import("@snap/state-management").State<"rejected", undefined>>;
326
+ (args_0: RemoteConfiguration, args_1: import("./legal/legalPrompt").LegalPromptFactory): import("@snap/state-management").StateMachine<import("@snap/state-management").Action<"requestLegalPrompt", undefined> | import("@snap/state-management").Action<"accept", string> | import("@snap/state-management").Action<"reject", string>, import("@snap/state-management").State<"unknown", undefined> | import("@snap/state-management").State<"accepted", undefined> | import("@snap/state-management").State<"rejected", undefined>>;
320
327
  token: "legalState";
321
328
  dependencies: readonly ["remoteConfiguration", "legalPrompt"];
322
329
  }, {
@@ -333,6 +340,6 @@ export declare const cameraKitFactory: {
333
340
  dependencies: readonly ["logEntries", "metricsEventTarget", "metricsClient"];
334
341
  }]>>): CameraKit;
335
342
  token: "CameraKit";
336
- dependencies: readonly ["LensRepository", "metricsEventTarget", "lensCore", "pageVisibility", "$container"];
343
+ dependencies: readonly ["LensRepository", "metricsEventTarget", "lensCore", "pageVisibility", "remoteConfiguration", "$container"];
337
344
  };
338
345
  //# sourceMapping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MAAM,EAAE;QAAE,UAAU,EAAE,cAAc,CAAA;KAAE,CAAC;IAEhD;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC,iBAAiB,CAAC,CAA0B;IAE/E,OAAO,CAAC,QAAQ,CAA0B;IAE1C,gBAAgB;;IAEZ;;OAEG;IACM,cAAc,EAAE,cAAc,EAEtB,QAAQ,EAAE,QAAQ,EAClB,cAAc,EAAE,cAAc,EAC9B,SAAS,EAAE,SAAS,CAAC,YAAY,CAAC,EAClC,YAAY,EAAE,mBAAmB,EAClD,UAAU,EAAE,kBAAkB;IAUlC;;;;;;;;;;;;;;;;OAgBG;IAEG,aAAa,CAAC,EAChB,gBAAgB,EAChB,oBAAoB,GACvB,GAAE,oBAAyB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAmGxD;;OAEG;IAEG,OAAO;CAMhB;AAED,gBAAgB;AAChB,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkB5B,CAAC"}
package/dist/CameraKit.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { __awaiter, __esDecorate, __runInitializers } from "tslib";
2
2
  import { CONTAINER, Injectable } from "@snap/ts-inject";
3
+ import { firstValueFrom } from "rxjs";
3
4
  import { lensRepositoryFactory } from "./lens/LensRepository";
4
5
  import { cameraKitSessionFactory } from "./session/CameraKitSession";
5
6
  import { registerLensAssetsProvider } from "./lens/assets/LensAssetsProvider";
@@ -18,6 +19,8 @@ import { errorLoggingDecorator } from "./logger/errorLoggingDecorator";
18
19
  import { TypedEventTarget } from "./events/TypedEventTarget";
19
20
  import { pageVisibilityFactory } from "./common/pageVisibility";
20
21
  import { setPreloadedConfiguration } from "./remote-configuration/preloadConfiguration";
22
+ import { remoteConfigurationFactory } from "./remote-configuration/remoteConfiguration";
23
+ import { registerGeoDataProvider } from "./geo/registerGeoDataProvider";
21
24
  const logger = getLogger("CameraKit");
22
25
  const publicMetricsEventNames = ["lensView", "lensWait"];
23
26
  export let CameraKit = (() => {
@@ -26,11 +29,12 @@ export let CameraKit = (() => {
26
29
  let _createSession_decorators;
27
30
  let _destroy_decorators;
28
31
  return _a = class CameraKit {
29
- constructor(lensRepository, lensCore, pageVisibility, container, allMetrics) {
32
+ constructor(lensRepository, lensCore, pageVisibility, container, remoteConfig, allMetrics) {
30
33
  this.lensRepository = (__runInitializers(this, _instanceExtraInitializers), lensRepository);
31
34
  this.lensCore = lensCore;
32
35
  this.pageVisibility = pageVisibility;
33
36
  this.container = container;
37
+ this.remoteConfig = remoteConfig;
34
38
  this.metrics = new TypedEventTarget();
35
39
  this.sessions = [];
36
40
  this.lenses = { repository: this.lensRepository };
@@ -56,6 +60,16 @@ export let CameraKit = (() => {
56
60
  shouldUseWorker: !renderWhileTabHidden && config.shouldUseWorker,
57
61
  exceptionHandler,
58
62
  });
63
+ if (this.lensCore.setGpuIndex) {
64
+ try {
65
+ yield this.lensCore.setGpuIndex({
66
+ gpuIndex: yield firstValueFrom(this.remoteConfig.getGpuIndexConfig()),
67
+ });
68
+ }
69
+ catch (cause) {
70
+ logger.error(new Error("Cannot set GPU index.", { cause }));
71
+ }
72
+ }
59
73
  if (config.fonts.length > 0) {
60
74
  this.lensCore.setSystemFonts({
61
75
  fonts: config.fonts,
@@ -74,6 +88,7 @@ export let CameraKit = (() => {
74
88
  .provides(cameraKitSessionFactory)
75
89
  .run(registerLensAssetsProvider)
76
90
  .run(registerLensClientInterfaceHandler)
91
+ .run(registerGeoDataProvider)
77
92
  .run(setPreloadedConfiguration)
78
93
  .run(reportSessionScopedMetrics)
79
94
  .run(registerUriHandlers);
@@ -104,6 +119,7 @@ export const cameraKitFactory = Injectable("CameraKit", [
104
119
  metricsEventTargetFactory.token,
105
120
  lensCoreFactory.token,
106
121
  pageVisibilityFactory.token,
122
+ remoteConfigurationFactory.token,
107
123
  CONTAINER,
108
- ], (lensRepository, metrics, lensCore, pageVisibility, container) => new CameraKit(lensRepository, lensCore, pageVisibility, container, metrics));
124
+ ], (lensRepository, metrics, lensCore, pageVisibility, remoteConfiguration, container) => new CameraKit(lensRepository, lensCore, pageVisibility, container, remoteConfiguration, metrics));
109
125
  //# sourceMappingURL=CameraKit.js.map
@@ -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,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAEzE,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,kCAAkC,EAAE,MAAM,6CAA6C,CAAC;AACjG,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAA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BAE9B,MAAM,OAAO,GAAG,gBAAgB,CAAC,GAAG,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAC;oBACpE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;oBAC5B,OAAO,OAAO,CAAC;gBACnB,CAAC;aAAA;YAMK,OAAO;;oBACT,WAAW,EAAE,CAAC;oBACd,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;oBAC9B,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;oBACrE,IAAI,CAAC,QAAQ,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"]}
1
+ {"version":3,"file":"CameraKit.js","sourceRoot":"","sources":["../src/CameraKit.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAEtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAI9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,EAAE,eAAe,EAA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oBAC5B,OAAO,OAAO,CAAC;gBACnB,CAAC;aAAA;YAMK,OAAO;;oBACT,WAAW,EAAE,CAAC;oBACd,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;oBAC9B,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;oBACrE,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;gBACvB,CAAC;aAAA;;;yCAhHA,qBAAqB,CAAC,MAAM,CAAC;mCA0G7B,qBAAqB,CAAC,MAAM,CAAC;YAzG9B,wLAAM,aAAa,wCAoGlB;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,0BAA0B,CAAC,KAAK;IAChC,SAAS;CACH,EACV,CACI,cAA8B,EAC9B,OAA2B,EAC3B,QAAkB,EAClB,cAA8B,EAC9B,mBAAwC,EACxC,SAAkC,EACpC,EAAE,CAAC,IAAI,SAAS,CAAC,cAAc,EAAE,QAAQ,EAAE,cAAc,EAAE,SAAS,EAAE,mBAAmB,EAAE,OAAO,CAAC,CACxG,CAAC","sourcesContent":["import type { Container } from \"@snap/ts-inject\";\nimport { CONTAINER, Injectable } from \"@snap/ts-inject\";\nimport { firstValueFrom } from \"rxjs\";\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\";\nimport type { RemoteConfiguration } from \"./remote-configuration/remoteConfiguration\";\nimport { remoteConfigurationFactory } from \"./remote-configuration/remoteConfiguration\";\nimport { registerGeoDataProvider } from \"./geo/registerGeoDataProvider\";\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 private readonly remoteConfig: RemoteConfiguration,\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 (this.lensCore.setGpuIndex) {\n // NOTE: setGpuIndex was added in LensCore@292. This check ensures compatibility with older versions.\n\n // Camera Kit allows a performance cluster to be provided during bootstrap.\n // This cluster is passed to the LENS_FEATURE_GPU_INDEX config as LENS_CLUSTER_ORIG_4,\n // which maps the cluster to a GPU index.\n try {\n await this.lensCore.setGpuIndex({\n gpuIndex: await firstValueFrom(this.remoteConfig.getGpuIndexConfig()),\n });\n } catch (cause) {\n // LensCore initialization can proceed without the GPU index,\n // as it is mainly needed for ML lenses.\n logger.error(new Error(\"Cannot set GPU index.\", { cause }));\n }\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(registerGeoDataProvider)\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 remoteConfigurationFactory.token,\n CONTAINER,\n ] as const,\n (\n lensRepository: LensRepository,\n metrics: MetricsEventTarget,\n lensCore: LensCore,\n pageVisibility: PageVisibility,\n remoteConfiguration: RemoteConfiguration,\n container: Container<RootServices>\n ) => new CameraKit(lensRepository, lensCore, pageVisibility, container, remoteConfiguration, metrics)\n);\n"]}
@@ -28,6 +28,7 @@ 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
30
  import type { remoteApiSpecsClientFactory } from "./clients/remoteApiSpecsClient";
31
+ import type { geoDataProviderFactory } from "./geo/geoDataProvider";
31
32
  /**
32
33
  * All services available to be customized by client app.
33
34
  */
@@ -40,6 +41,7 @@ export type PublicServices = ServicesFromInjectables<[
40
41
  typeof lensSourcesFactory,
41
42
  typeof remoteApiServicesFactory,
42
43
  typeof uriHandlersFactory,
44
+ typeof geoDataProviderFactory,
43
45
  typeof externalMetricsSubjectFactory
44
46
  ]>;
45
47
  /**
@@ -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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"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
+ {"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\";\nimport type { geoDataProviderFactory } from \"./geo/geoDataProvider\";\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 geoDataProviderFactory,\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;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"}
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;AAwD7C;;;;;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,CA8FpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,eAAe,IAAI,gBAAgB,CAElD"}
@@ -42,6 +42,7 @@ import { fetchWatermarkLens } from "./lens/fetchWatermarkLens";
42
42
  import { filePickerFactory } from "./lens-client-interface/filePicker";
43
43
  import { userDataAccessResolverFactory } from "./lens/userDataAccessResolver";
44
44
  import { remoteApiSpecsClientFactory } from "./clients/remoteApiSpecsClient";
45
+ import { geoDataProviderFactory } from "./geo/geoDataProvider";
45
46
  const logger = getLogger("bootstrapCameraKit");
46
47
  const nonWrappableErrors = [
47
48
  "ConfigurationError",
@@ -68,6 +69,7 @@ export function bootstrapCameraKit(configuration, provide) {
68
69
  .provides(lensSourcesFactory)
69
70
  .provides(remoteApiServicesFactory)
70
71
  .provides(uriHandlersFactory)
72
+ .provides(geoDataProviderFactory)
71
73
  .provides(externalMetricsSubjectFactory);
72
74
  const publicContainer = provide ? provide(defaultPublicContainer) : defaultPublicContainer;
73
75
  const telemetryContainer = Container.provides(publicContainer)
@@ -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,EAAE,wBAAwB,EAAE,MAAM,i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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"]}
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,E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,CAAC,CAAC;iBAC3D,QAAQ,CAAC,mBAAmB,CAAC;iBAC7B,QAAQ,CAAC,2BAA2B,CAAC;iBACrC,QAAQ,CAAC,0BAA0B,CAAC;iBACpC,QAAQ,CAAC,2BAA2B,CAAC;iBACrC,QAAQ,CAAC,iCAAiC,CAAC;iBAC3C,QAAQ,CAAC,wBAAwB,CAAC;iBAClC,QAAQ,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\";\nimport { geoDataProviderFactory } from \"./geo/geoDataProvider\";\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(geoDataProviderFactory)\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"]}
@@ -1,2 +1,2 @@
1
- export default { PACKAGE_VERSION: "1.1.0" };
1
+ export default { PACKAGE_VERSION: "1.2.0" };
2
2
  //# sourceMappingURL=environment.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"environment.js","sourceRoot":"","sources":["../src/environment.ts"],"names":[],"mappings":"AAAA,eAAe,EAAE,eAAe,EAAE,OAAO,EAAE,CAAC","sourcesContent":["export default { PACKAGE_VERSION: \"1.1.0\" };\n"]}
1
+ {"version":3,"file":"environment.js","sourceRoot":"","sources":["../src/environment.ts"],"names":[],"mappings":"AAAA,eAAe,EAAE,eAAe,EAAE,OAAO,EAAE,CAAC","sourcesContent":["export default { PACKAGE_VERSION: \"1.2.0\" };\n"]}
@@ -1,5 +1,11 @@
1
+ /**
2
+ * Returns extension request context.
3
+ */
4
+ export declare const getExtensionRequestContext: import("../common/memoize").Memoized<() => ArrayBuffer>;
1
5
  /**
2
6
  * Extension request context.
7
+ *
8
+ * @deprecated Use {@link getExtensionRequestContext}
3
9
  */
4
10
  export declare const extensionRequestContext: ArrayBuffer;
5
11
  //# sourceMappingURL=extensionRequestContext.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"extensionRequestContext.d.ts","sourceRoot":"","sources":["../../src/extensions/extensionRequestContext.ts"],"names":[],"mappings":"AAWA;;GAEG;AACH,eAAO,MAAM,uBAAuB,aAA+B,CAAC"}
1
+ {"version":3,"file":"extensionRequestContext.d.ts","sourceRoot":"","sources":["../../src/extensions/extensionRequestContext.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,eAAO,MAAM,0BAA0B,6CAAkD,WAAW,CAKlG,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,aAA+B,CAAC"}
@@ -1,11 +1,12 @@
1
1
  import { getCameraKitUserAgent } from "../platform/cameraKitUserAgent";
2
2
  import { ExtensionRequestContext } from "../generated-proto/pb_schema/camera_kit/v3/export";
3
3
  import { getPlatformInfo } from "../platform/platformInfo";
4
- function getExtensionRequestContext() {
4
+ import { memoize } from "../common/memoize";
5
+ export const getExtensionRequestContext = memoize(function getExtensionRequestContext() {
5
6
  return ExtensionRequestContext.encode({
6
7
  userAgent: getCameraKitUserAgent(),
7
8
  locale: getPlatformInfo().fullLocale,
8
9
  }).finish();
9
- }
10
+ });
10
11
  export const extensionRequestContext = getExtensionRequestContext();
11
12
  //# sourceMappingURL=extensionRequestContext.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"extensionRequestContext.js","sourceRoot":"","sources":["../../src/extensions/extensionRequestContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,mDAAmD,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,SAAS,0BAA0B;IAC/B,OAAO,uBAAuB,CAAC,MAAM,CAAC;QAClC,SAAS,EAAE,qBAAqB,EAAE;QAClC,MAAM,EAAE,eAAe,EAAE,CAAC,UAAU;KACvC,CAAC,CAAC,MAAM,EAAE,CAAC;AAChB,CAAC;AAKD,MAAM,CAAC,MAAM,uBAAuB,GAAG,0BAA0B,EAAE,CAAC","sourcesContent":["import { getCameraKitUserAgent } from \"../platform/cameraKitUserAgent\";\nimport { ExtensionRequestContext } from \"../generated-proto/pb_schema/camera_kit/v3/export\";\nimport { getPlatformInfo } from \"../platform/platformInfo\";\n\nfunction getExtensionRequestContext(): ArrayBuffer {\n return ExtensionRequestContext.encode({\n userAgent: getCameraKitUserAgent(),\n locale: getPlatformInfo().fullLocale,\n }).finish();\n}\n\n/**\n * Extension request context.\n */\nexport const extensionRequestContext = getExtensionRequestContext();\n"]}
1
+ {"version":3,"file":"extensionRequestContext.js","sourceRoot":"","sources":["../../src/extensions/extensionRequestContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,mDAAmD,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAK5C,MAAM,CAAC,MAAM,0BAA0B,GAAG,OAAO,CAAC,SAAS,0BAA0B;IACjF,OAAO,uBAAuB,CAAC,MAAM,CAAC;QAClC,SAAS,EAAE,qBAAqB,EAAE;QAClC,MAAM,EAAE,eAAe,EAAE,CAAC,UAAU;KACvC,CAAC,CAAC,MAAM,EAAE,CAAC;AAChB,CAAC,CAAC,CAAC;AAOH,MAAM,CAAC,MAAM,uBAAuB,GAAG,0BAA0B,EAAE,CAAC","sourcesContent":["import { getCameraKitUserAgent } from \"../platform/cameraKitUserAgent\";\nimport { ExtensionRequestContext } from \"../generated-proto/pb_schema/camera_kit/v3/export\";\nimport { getPlatformInfo } from \"../platform/platformInfo\";\nimport { memoize } from \"../common/memoize\";\n\n/**\n * Returns extension request context.\n */\nexport const getExtensionRequestContext = memoize(function getExtensionRequestContext(): ArrayBuffer {\n return ExtensionRequestContext.encode({\n userAgent: getCameraKitUserAgent(),\n locale: getPlatformInfo().fullLocale,\n }).finish();\n});\n\n/**\n * Extension request context.\n *\n * @deprecated Use {@link getExtensionRequestContext}\n */\nexport const extensionRequestContext = getExtensionRequestContext();\n"]}
@@ -0,0 +1,32 @@
1
+ import type { GeoData as GeoDataOrig, WeatherData as WeatherDataOrig, HourlyWeatherForecast as HourlyWeatherForecastOrig } from "../lens-core-module/generated-types";
2
+ /**
3
+ * @internal
4
+ */
5
+ type GeoData = GeoDataOrig;
6
+ /**
7
+ * @internal
8
+ */
9
+ type WeatherData = WeatherDataOrig;
10
+ /**
11
+ * @internal
12
+ */
13
+ type HourlyWeatherForecast = HourlyWeatherForecastOrig;
14
+ export { GeoData, WeatherData, HourlyWeatherForecast };
15
+ /**
16
+ * @internal
17
+ */
18
+ export type GeoDataProvider = () => GeoData | undefined;
19
+ /**
20
+ *
21
+ * @internal
22
+ */
23
+ export declare function isGeoData(value: unknown): value is GeoData;
24
+ /**
25
+ * @internal
26
+ */
27
+ export declare const geoDataProviderFactory: {
28
+ (): GeoDataProvider;
29
+ token: "geoDataProvider";
30
+ dependencies: [];
31
+ };
32
+ //# sourceMappingURL=geoDataProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geoDataProvider.d.ts","sourceRoot":"","sources":["../../src/geo/geoDataProvider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACR,OAAO,IAAI,WAAW,EACtB,WAAW,IAAI,eAAe,EAC9B,qBAAqB,IAAI,yBAAyB,EACrD,MAAM,qCAAqC,CAAC;AAG7C;;GAEG;AACH,KAAK,OAAO,GAAG,WAAW,CAAC;AAE3B;;GAEG;AACH,KAAK,WAAW,GAAG,eAAe,CAAC;AAEnC;;GAEG;AACH,KAAK,qBAAqB,GAAG,yBAAyB,CAAC;AAEvD,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,CAAC;AAEvD;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,GAAG,SAAS,CAAC;AAExD;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAE1D;AAwBD;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;CAEjC,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { Injectable } from "@snap/ts-inject";
2
+ import { isArrayOfType, isNumber, isRecord, isString, isUndefined } from "../common/typeguards";
3
+ export function isGeoData(value) {
4
+ return isRecord(value) && isWeatherData(value.weather);
5
+ }
6
+ function isWeatherData(value) {
7
+ return (isRecord(value) &&
8
+ isString(value.locationName) &&
9
+ isNumber(value.celsius) &&
10
+ isNumber(value.fahrenheit) &&
11
+ !isUndefined(value.hourlyForecasts) &&
12
+ isArrayOfType(isHourlyWeatherForecast, value.hourlyForecasts));
13
+ }
14
+ function isHourlyWeatherForecast(value) {
15
+ return (isRecord(value) &&
16
+ isNumber(value.celsius) &&
17
+ isNumber(value.fahrenheit) &&
18
+ isString(value.displayTime) &&
19
+ isString(value.weatherCondition) &&
20
+ isString(value.localizedWeatherCondition));
21
+ }
22
+ export const geoDataProviderFactory = Injectable("geoDataProvider", () => {
23
+ return () => undefined;
24
+ });
25
+ //# sourceMappingURL=geoDataProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geoDataProvider.js","sourceRoot":"","sources":["../../src/geo/geoDataProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAM7C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AA4BhG,MAAM,UAAU,SAAS,CAAC,KAAc;IACpC,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAC3D,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACjC,OAAO,CACH,QAAQ,CAAC,KAAK,CAAC;QACf,QAAQ,CAAC,KAAK,CAAC,YAAY,CAAC;QAC5B,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC;QACvB,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC;QAC1B,CAAC,WAAW,CAAC,KAAK,CAAC,eAAe,CAAC;QACnC,aAAa,CAAC,uBAAuB,EAAE,KAAK,CAAC,eAAe,CAAC,CAChE,CAAC;AACN,CAAC;AAED,SAAS,uBAAuB,CAAC,KAAc;IAC3C,OAAO,CACH,QAAQ,CAAC,KAAK,CAAC;QACf,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC;QACvB,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC;QAC1B,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC;QAC3B,QAAQ,CAAC,KAAK,CAAC,gBAAgB,CAAC;QAChC,QAAQ,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAC5C,CAAC;AACN,CAAC;AAKD,MAAM,CAAC,MAAM,sBAAsB,GAAG,UAAU,CAAC,iBAAiB,EAAE,GAAoB,EAAE;IACtF,OAAO,GAAG,EAAE,CAAC,SAAS,CAAC;AAC3B,CAAC,CAAC,CAAC","sourcesContent":["import { Injectable } from \"@snap/ts-inject\";\nimport type {\n GeoData as GeoDataOrig,\n WeatherData as WeatherDataOrig,\n HourlyWeatherForecast as HourlyWeatherForecastOrig,\n} from \"../lens-core-module/generated-types\";\nimport { isArrayOfType, isNumber, isRecord, isString, isUndefined } from \"../common/typeguards\";\n\n/**\n * @internal\n */\ntype GeoData = GeoDataOrig;\n\n/**\n * @internal\n */\ntype WeatherData = WeatherDataOrig;\n\n/**\n * @internal\n */\ntype HourlyWeatherForecast = HourlyWeatherForecastOrig;\n\nexport { GeoData, WeatherData, HourlyWeatherForecast };\n\n/**\n * @internal\n */\nexport type GeoDataProvider = () => GeoData | undefined;\n\n/**\n *\n * @internal\n */\nexport function isGeoData(value: unknown): value is GeoData {\n return isRecord(value) && isWeatherData(value.weather);\n}\n\nfunction isWeatherData(value: unknown): value is WeatherData {\n return (\n isRecord(value) &&\n isString(value.locationName) &&\n isNumber(value.celsius) &&\n isNumber(value.fahrenheit) &&\n !isUndefined(value.hourlyForecasts) &&\n isArrayOfType(isHourlyWeatherForecast, value.hourlyForecasts)\n );\n}\n\nfunction isHourlyWeatherForecast(value: unknown): value is HourlyWeatherForecast {\n return (\n isRecord(value) &&\n isNumber(value.celsius) &&\n isNumber(value.fahrenheit) &&\n isString(value.displayTime) &&\n isString(value.weatherCondition) &&\n isString(value.localizedWeatherCondition)\n );\n}\n\n/**\n * @internal\n */\nexport const geoDataProviderFactory = Injectable(\"geoDataProvider\", (): GeoDataProvider => {\n return () => undefined;\n});\n"]}
@@ -0,0 +1,11 @@
1
+ import type { LensCore } from "../lens-core-module/lensCore";
2
+ import type { GeoDataProvider } from "./geoDataProvider";
3
+ /**
4
+ * @internal
5
+ */
6
+ export declare const registerGeoDataProvider: {
7
+ (args_0: LensCore, args_1: GeoDataProvider): void;
8
+ token: "registerGeoDataProvider";
9
+ dependencies: readonly ["lensCore", "geoDataProvider"];
10
+ };
11
+ //# sourceMappingURL=registerGeoDataProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registerGeoDataProvider.d.ts","sourceRoot":"","sources":["../../src/geo/registerGeoDataProvider.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAE7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAMzD;;GAEG;AACH,eAAO,MAAM,uBAAuB;;;;CAsBnC,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { Injectable } from "@snap/ts-inject";
2
+ import { lensCoreFactory } from "../lens-core-module/loader/lensCoreFactory";
3
+ import { getLogger } from "../logger/logger";
4
+ import { isGeoData } from "./geoDataProvider";
5
+ import { geoDataProviderFactory } from "./geoDataProvider";
6
+ const logger = getLogger("registerGeoDataProvider");
7
+ export const registerGeoDataProvider = Injectable("registerGeoDataProvider", [lensCoreFactory.token, geoDataProviderFactory.token], (lensCore, getGeoData) => {
8
+ if (!lensCore.setGeoDataProvider) {
9
+ logger.warn("setGeoDataProvider is not defined.");
10
+ return;
11
+ }
12
+ lensCore.setGeoDataProvider(() => {
13
+ const geoData = getGeoData();
14
+ if (geoData) {
15
+ if (!isGeoData(geoData)) {
16
+ throw new Error("Expected GeoData object.");
17
+ }
18
+ lensCore.provideGeoData({ geoData });
19
+ }
20
+ });
21
+ });
22
+ //# sourceMappingURL=registerGeoDataProvider.js.map