@snap/camera-kit 0.7.0 → 0.9.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 (245) hide show
  1. package/docs/html/assets/main.js +57 -53
  2. package/docs/html/assets/search.js +1 -1
  3. package/docs/html/assets/style.css +504 -362
  4. package/docs/html/classes/CameraKit.html +113 -47
  5. package/docs/html/classes/CameraKitSession.html +202 -142
  6. package/docs/html/classes/CameraKitSource.html +124 -60
  7. package/docs/html/classes/LensPerformanceMeasurement.html +112 -46
  8. package/docs/html/classes/LensPerformanceMetrics.html +97 -32
  9. package/docs/html/classes/LensRepository.html +130 -66
  10. package/docs/html/classes/LensSources.html +98 -32
  11. package/docs/html/classes/Transform2D.html +111 -43
  12. package/docs/html/classes/TypedCustomEvent.html +109 -47
  13. package/docs/html/classes/TypedEventTarget.html +125 -65
  14. package/docs/html/functions/Injectable.html +113 -120
  15. package/docs/html/functions/bootstrapCameraKit.html +100 -104
  16. package/docs/html/functions/createExtension.html +90 -94
  17. package/docs/html/functions/createImageSource.html +90 -93
  18. package/docs/html/functions/createMediaStreamSource.html +90 -93
  19. package/docs/html/functions/createUserMediaSource.html +92 -96
  20. package/docs/html/functions/createVideoSource.html +90 -93
  21. package/docs/html/functions/estimateLensPerformance.html +88 -92
  22. package/docs/html/functions/getRequiredBootstrapURLs.html +90 -94
  23. package/docs/html/functions/lensSourcesFactory.html +88 -91
  24. package/docs/html/functions/uriHandlersFactory.html +88 -91
  25. package/docs/html/index.html +134 -170
  26. package/docs/html/interfaces/CameraKitBootstrapConfiguration.html +115 -49
  27. package/docs/html/interfaces/CameraKitSourceSubscriber.html +111 -45
  28. package/docs/html/interfaces/ComputedFrameMetrics.html +98 -32
  29. package/docs/html/interfaces/CreateSessionOptions.html +95 -29
  30. package/docs/html/interfaces/EstimatedLensPerformance.html +98 -32
  31. package/docs/html/interfaces/Lens.html +115 -49
  32. package/docs/html/interfaces/LensSource.html +107 -41
  33. package/docs/html/interfaces/MediaStreamSourceOptions.html +94 -28
  34. package/docs/html/interfaces/UriCancelRequest.html +94 -28
  35. package/docs/html/interfaces/UriHandler.html +108 -42
  36. package/docs/html/interfaces/UriRequest.html +106 -40
  37. package/docs/html/interfaces/UriResponse.html +106 -40
  38. package/docs/html/interfaces/VideoSourceOptions.html +90 -24
  39. package/docs/html/modules.html +161 -164
  40. package/docs/html/types/AssetLoader.html +91 -94
  41. package/docs/html/types/AssetTiming.html +85 -88
  42. package/docs/html/types/BenchmarkError.html +85 -88
  43. package/docs/html/types/BootstrapError.html +86 -89
  44. package/docs/html/types/CacheKeyNotFoundError.html +85 -88
  45. package/docs/html/types/CameraKitDeviceInfo.html +87 -90
  46. package/docs/html/types/CameraKitSessionEventListener.html +86 -89
  47. package/docs/html/types/CameraKitSessionEvents.html +88 -91
  48. package/docs/html/types/CameraKitSourceError.html +85 -88
  49. package/docs/html/types/CameraKitSourceInfo.html +85 -88
  50. package/docs/html/types/CameraKitSourceOptions.html +88 -92
  51. package/docs/html/types/ConfigurationError.html +86 -89
  52. package/docs/html/types/Keyboard.html +108 -111
  53. package/docs/html/types/KeyboardEvents.html +86 -89
  54. package/docs/html/types/LegalError.html +85 -88
  55. package/docs/html/types/LensAssetError.html +85 -88
  56. package/docs/html/types/LensContentValidationError.html +85 -88
  57. package/docs/html/types/LensError.html +85 -88
  58. package/docs/html/types/LensExecutionError.html +86 -89
  59. package/docs/html/types/LensImagePickerError.html +85 -88
  60. package/docs/html/types/LensLaunchParams.html +85 -88
  61. package/docs/html/types/LensMetricsEvents.html +86 -89
  62. package/docs/html/types/LensPerformanceCluster.html +85 -88
  63. package/docs/html/types/LensView.html +85 -88
  64. package/docs/html/types/LensWait.html +85 -88
  65. package/docs/html/types/PersistentStoreError.html +85 -88
  66. package/docs/html/types/PlatformNotSupportedError.html +86 -89
  67. package/docs/html/types/PublicContainer.html +85 -88
  68. package/docs/html/types/RenderTarget.html +85 -88
  69. package/docs/html/types/Uri.html +85 -88
  70. package/docs/html/types/UriHandlers.html +86 -89
  71. package/docs/html/types/WebGLError.html +85 -88
  72. package/docs/html/variables/extensionRequestContext.html +85 -88
  73. package/docs/md/README.md +1 -1
  74. package/docs/md/classes/CameraKit.md +1 -1
  75. package/docs/md/classes/CameraKitSession.md +1 -1
  76. package/docs/md/classes/CameraKitSource.md +1 -1
  77. package/docs/md/classes/LensPerformanceMeasurement.md +1 -1
  78. package/docs/md/classes/LensPerformanceMetrics.md +1 -1
  79. package/docs/md/classes/LensRepository.md +3 -3
  80. package/docs/md/classes/LensSources.md +1 -1
  81. package/docs/md/classes/Transform2D.md +3 -1
  82. package/docs/md/classes/TypedCustomEvent.md +1 -1
  83. package/docs/md/classes/TypedEventTarget.md +3 -3
  84. package/docs/md/interfaces/CameraKitBootstrapConfiguration.md +1 -1
  85. package/docs/md/interfaces/CameraKitSourceSubscriber.md +1 -1
  86. package/docs/md/interfaces/ComputedFrameMetrics.md +1 -1
  87. package/docs/md/interfaces/CreateSessionOptions.md +1 -1
  88. package/docs/md/interfaces/EstimatedLensPerformance.md +1 -1
  89. package/docs/md/interfaces/Lens.md +1 -1
  90. package/docs/md/interfaces/LensSource.md +1 -1
  91. package/docs/md/interfaces/MediaStreamSourceOptions.md +1 -1
  92. package/docs/md/interfaces/UriCancelRequest.md +1 -1
  93. package/docs/md/interfaces/UriHandler.md +1 -1
  94. package/docs/md/interfaces/UriRequest.md +1 -1
  95. package/docs/md/interfaces/UriResponse.md +1 -1
  96. package/docs/md/interfaces/VideoSourceOptions.md +1 -1
  97. package/docs/md/modules.md +3 -3
  98. package/lib/CameraKit.d.ts +7 -7
  99. package/lib/__tests__/data.d.ts +1 -1
  100. package/lib/__tests__/deferred.d.ts +1 -1
  101. package/lib/__tests__/jest.matchers.d.ts +1 -1
  102. package/lib/benchmark/estimateLensPerformanceCluster.d.ts +2 -2
  103. package/lib/bootstrapCameraKit.d.ts +1 -1
  104. package/lib/common/cameraKitUserAgent.d.ts +1 -1
  105. package/lib/common/cameraKitUserAgent.js +5 -3
  106. package/lib/common/cameraKitUserAgent.js.map +1 -1
  107. package/lib/common/localization.d.ts +8 -4
  108. package/lib/common/localization.js.map +1 -1
  109. package/lib/common/memoize.d.ts +2 -2
  110. package/lib/common/pageVisibility.js +1 -1
  111. package/lib/common/pageVisibility.js.map +1 -1
  112. package/lib/common/typeguards.d.ts +2 -2
  113. package/lib/common/types.d.ts +2 -2
  114. package/lib/common/validate.js +20 -12
  115. package/lib/common/validate.js.map +1 -1
  116. package/lib/configuration.d.ts +1 -1
  117. package/lib/configuration.js.map +1 -1
  118. package/lib/configurationOverrides.d.ts +1 -1
  119. package/lib/dependency-injection/Container.d.ts +5 -6
  120. package/lib/dependency-injection/Container.js +1 -1
  121. package/lib/dependency-injection/Container.js.map +1 -1
  122. package/lib/dependency-injection/PartialContainer.d.ts +10 -6
  123. package/lib/dependency-injection/PartialContainer.js.map +1 -1
  124. package/lib/dependency-injection/RootServices.d.ts +2 -2
  125. package/lib/dependency-injection/types.d.ts +9 -9
  126. package/lib/dependency-injection/types.js.map +1 -1
  127. package/lib/environment.json +1 -1
  128. package/lib/events/TypedCustomEvent.d.ts +1 -1
  129. package/lib/events/TypedEventTarget.d.ts +2 -2
  130. package/lib/events/scan.d.ts +1 -1
  131. package/lib/events/scan.js +3 -3
  132. package/lib/events/scan.js.map +1 -1
  133. package/lib/extensions/UriHandlers.d.ts +1 -1
  134. package/lib/generated-proto/blizzard/cameraKitEvents.d.ts +4 -4
  135. package/lib/generated-proto/pb_schema/camera_kit/v3/business_events.d.ts +4 -4
  136. package/lib/generated-proto/pb_schema/camera_kit/v3/business_events.js +3 -3
  137. package/lib/generated-proto/pb_schema/camera_kit/v3/business_events.js.map +1 -1
  138. package/lib/generated-proto/pb_schema/camera_kit/v3/export.d.ts +4 -4
  139. package/lib/generated-proto/pb_schema/camera_kit/v3/export.js +9 -9
  140. package/lib/generated-proto/pb_schema/camera_kit/v3/export.js.map +1 -1
  141. package/lib/generated-proto/pb_schema/camera_kit/v3/legal_prompt.d.ts +4 -4
  142. package/lib/generated-proto/pb_schema/camera_kit/v3/legal_prompt.js +2 -2
  143. package/lib/generated-proto/pb_schema/camera_kit/v3/legal_prompt.js.map +1 -1
  144. package/lib/generated-proto/pb_schema/camera_kit/v3/lens.d.ts +4 -4
  145. package/lib/generated-proto/pb_schema/camera_kit/v3/lens.js +17 -17
  146. package/lib/generated-proto/pb_schema/camera_kit/v3/lens.js.map +1 -1
  147. package/lib/generated-proto/pb_schema/camera_kit/v3/operational_metrics.d.ts +4 -4
  148. package/lib/generated-proto/pb_schema/camera_kit/v3/operational_metrics.js +4 -4
  149. package/lib/generated-proto/pb_schema/camera_kit/v3/operational_metrics.js.map +1 -1
  150. package/lib/generated-proto/pb_schema/camera_kit/v3/ranking.d.ts +4 -4
  151. package/lib/generated-proto/pb_schema/camera_kit/v3/ranking.js +3 -3
  152. package/lib/generated-proto/pb_schema/camera_kit/v3/ranking.js.map +1 -1
  153. package/lib/generated-proto/pb_schema/camera_kit/v3/service.d.ts +4 -4
  154. package/lib/generated-proto/pb_schema/camera_kit/v3/service.js +25 -25
  155. package/lib/generated-proto/pb_schema/camera_kit/v3/service.js.map +1 -1
  156. package/lib/generated-proto/pb_schema/cdp/cof/benchmark.d.ts +4 -4
  157. package/lib/generated-proto/pb_schema/cdp/cof/circumstance_service.d.ts +4533 -333
  158. package/lib/generated-proto/pb_schema/cdp/cof/config_request.d.ts +4 -4
  159. package/lib/generated-proto/pb_schema/cdp/cof/config_response.d.ts +572 -32
  160. package/lib/generated-proto/pb_schema/cdp/cof/config_result.d.ts +4 -4
  161. package/lib/generated-proto/pb_schema/cdp/cof/debug_info.d.ts +4 -4
  162. package/lib/generated-proto/pb_schema/common/ruid.d.ts +4 -4
  163. package/lib/generated-proto/pb_schema/common/value.d.ts +4 -4
  164. package/lib/generated-proto/pb_schema/google/api/http.d.ts +4 -4
  165. package/lib/generated-proto/pb_schema/google/protobuf/any.d.ts +4 -4
  166. package/lib/generated-proto/pb_schema/google/protobuf/descriptor.d.ts +4 -4
  167. package/lib/generated-proto/pb_schema/google/protobuf/timestamp.d.ts +4 -4
  168. package/lib/generated-proto/pb_schema/google/protobuf/wrappers.d.ts +4 -4
  169. package/lib/generated-proto/pb_schema/lenses/geocircle.d.ts +4 -4
  170. package/lib/generated-proto/pb_schema/lenses/geopoint.d.ts +4 -4
  171. package/lib/generated-proto/pb_schema/lenses/launch_params.d.ts +4 -4
  172. package/lib/generated-proto/pb_schema/lenses/launchdata.d.ts +4 -4
  173. package/lib/generated-proto/pb_schema/lenses/lures.d.ts +4 -4
  174. package/lib/generated-proto/pb_schema/lenses/persistent_store.d.ts +4 -4
  175. package/lib/generated-proto/pb_schema/lenses/snappable.d.ts +4 -4
  176. package/lib/generated-proto/pb_schema/lenses/user_data.d.ts +4 -4
  177. package/lib/handlers/HandlerChainBuilder.d.ts +3 -3
  178. package/lib/handlers/arrayBufferParsingHandler.d.ts +2 -2
  179. package/lib/handlers/arrayBufferParsingHandler.js.map +1 -1
  180. package/lib/handlers/cameraKitServiceFetchHandlerFactory.d.ts +1 -1
  181. package/lib/handlers/defaultFetchHandler.d.ts +1 -1
  182. package/lib/handlers/headersModifyingFetchHandler.js +5 -1
  183. package/lib/handlers/headersModifyingFetchHandler.js.map +1 -1
  184. package/lib/handlers/noCorsRetryingFetchHandler.js +4 -3
  185. package/lib/handlers/noCorsRetryingFetchHandler.js.map +1 -1
  186. package/lib/handlers/requestStateEmittingHandler.d.ts +2 -2
  187. package/lib/handlers/requestStateEmittingHandler.js.map +1 -1
  188. package/lib/handlers/responseCachingHandler.d.ts +1 -1
  189. package/lib/handlers/responseCachingHandler.js.map +1 -1
  190. package/lib/handlers/retryingHandler.d.ts +7 -0
  191. package/lib/handlers/retryingHandler.js +14 -5
  192. package/lib/handlers/retryingHandler.js.map +1 -1
  193. package/lib/legal/legalPrompt.d.ts +1 -1
  194. package/lib/legal/legalPrompt.js.map +1 -1
  195. package/lib/legal/legalState.d.ts +1 -1
  196. package/lib/legal/legalState.js.map +1 -1
  197. package/lib/lens/Lens.d.ts +1 -1
  198. package/lib/lens/LensLaunchParams.d.ts +2 -2
  199. package/lib/lens/LensRepository.d.ts +7 -8
  200. package/lib/lens/LensRepository.js.map +1 -1
  201. package/lib/lens/assets/LensAssetRepository.d.ts +2 -2
  202. package/lib/lens/assets/LensAssetsProvider.d.ts +1 -1
  203. package/lib/lens/assets/deviceDependentAssetLoader.d.ts +1 -1
  204. package/lib/lens/assets/remoteMediaAssetLoaderFactory.d.ts +1 -1
  205. package/lib/lens/assets/staticAssetLoader.d.ts +1 -1
  206. package/lib/lens-core-module/generated-types.d.ts +29 -29
  207. package/lib/lens-core-module/generated-types.js.map +1 -1
  208. package/lib/lens-core-module/loader/lensCoreFactory.d.ts +1 -1
  209. package/lib/lensCoreWasmVersions.json +3 -3
  210. package/lib/logger/logger.d.ts +2 -2
  211. package/lib/media-sources/CameraKitSource.d.ts +3 -3
  212. package/lib/media-sources/CameraKitSource.js.map +1 -1
  213. package/lib/media-sources/FunctionSource.d.ts +1 -1
  214. package/lib/metrics/businessEventsReporter.d.ts +4 -4
  215. package/lib/metrics/businessEventsReporter.js.map +1 -1
  216. package/lib/metrics/metricsEventTarget.d.ts +5 -5
  217. package/lib/metrics/metricsHandler.d.ts +1 -1
  218. package/lib/metrics/operationalMetricsReporter.d.ts +2 -2
  219. package/lib/metrics/reporters/reportBenchmarks.d.ts +1 -1
  220. package/lib/metrics/reporters/reportLegalState.d.ts +1 -1
  221. package/lib/metrics/reporters/reportLensAndAssetDownload.d.ts +4 -4
  222. package/lib/metrics/reporters/reportLensValidationFailed.d.ts +1 -1
  223. package/lib/metrics/reporters/reportLensView.d.ts +1 -1
  224. package/lib/metrics/reporters/reportLensView.js +1 -1
  225. package/lib/metrics/reporters/reportLensView.js.map +1 -1
  226. package/lib/metrics/reporters/reportLensWait.d.ts +1 -1
  227. package/lib/metrics/reporters/reportUserSession.d.ts +1 -1
  228. package/lib/namedErrors.d.ts +17 -17
  229. package/lib/persistence/Persistence.d.ts +1 -1
  230. package/lib/remote-configuration/cofHandler.d.ts +1 -1
  231. package/lib/remote-configuration/cofHandler.js +18 -5
  232. package/lib/remote-configuration/cofHandler.js.map +1 -1
  233. package/lib/session/CameraKitSession.d.ts +1 -1
  234. package/lib/session/CameraKitSession.js.map +1 -1
  235. package/lib/session/CameraKitSessionEvents.d.ts +3 -3
  236. package/lib/session/LensKeyboard.d.ts +2 -2
  237. package/lib/session/LensPerformanceMetrics.js.map +1 -1
  238. package/lib/session/lensState.d.ts +2 -2
  239. package/lib/session/lensState.js.map +1 -1
  240. package/lib/session/sessionState.d.ts +1 -1
  241. package/lib/transforms/Transform2D.js +2 -1
  242. package/lib/transforms/Transform2D.js.map +1 -1
  243. package/package.json +14 -14
  244. package/docs/html/assets/widgets.png +0 -0
  245. package/docs/html/assets/widgets@2x.png +0 -0
@@ -1,41 +1,41 @@
1
1
  /// <reference types="dom-webcodecs" />
2
- export declare type DefaultEventHandler = (...data: any[]) => void;
3
- export declare type DefaultErrorHandler = (err: LensCoreError) => void;
4
- export declare type LensCoreEnumValue = {
2
+ export type DefaultEventHandler = (...data: any[]) => void;
3
+ export type DefaultErrorHandler = (err: LensCoreError) => void;
4
+ export type LensCoreEnumValue = {
5
5
  value: number;
6
6
  };
7
- export declare type GetOutputCanvasesOutput = Record<number, HTMLCanvasElement>;
8
- export declare type SetRenderSizeInput = SetRenderSizeMatchInputResolutionInput | SetRenderSizeExplicitInput;
9
- export declare type SetRemoteAssetsProviderInput = (assetDescriptor: AssetDescriptor) => void;
10
- export declare type ContentType = "text/plain" | "text/html" | "application/json" | "application/octet-stream" | "application/x-protobuf" | "application/grpc";
11
- export declare type SavePersistentStoreCallback = (id: string, data: ArrayBuffer) => void;
12
- export declare type ShowHintCallback = (effectId: string, hintId: string) => void;
13
- export declare type HideHintCallback = (effectId: string) => void;
14
- export declare type ReceiveInstanceCallback = (instance: WebAssembly.Instance, module: WebAssembly.Module) => void;
15
- export declare type AssetType = LensCoreEnumValue;
16
- export declare type CanvasType = LensCoreEnumValue;
17
- export declare type RenderLoopMode = LensCoreEnumValue;
18
- export declare type LensApiVisibility = LensCoreEnumValue;
19
- export declare type DeviceClass = LensCoreEnumValue;
20
- export declare type UserDataAccess = LensCoreEnumValue;
21
- export declare type InterfaceControl = LensCoreEnumValue;
22
- export declare type InterfaceAction = LensCoreEnumValue;
23
- export declare type ExternalMediaOrientation = LensCoreEnumValue;
24
- export declare type ErrorType = LensCoreEnumValue;
25
- export declare type Uri = `${string}://${string}`;
26
- export declare type Dimensions = {
7
+ export type GetOutputCanvasesOutput = Record<number, HTMLCanvasElement>;
8
+ export type SetRenderSizeInput = SetRenderSizeMatchInputResolutionInput | SetRenderSizeExplicitInput;
9
+ export type SetRemoteAssetsProviderInput = (assetDescriptor: AssetDescriptor) => void;
10
+ export type ContentType = "text/plain" | "text/html" | "application/json" | "application/octet-stream" | "application/x-protobuf" | "application/grpc";
11
+ export type SavePersistentStoreCallback = (id: string, data: ArrayBuffer) => void;
12
+ export type ShowHintCallback = (effectId: string, hintId: string) => void;
13
+ export type HideHintCallback = (effectId: string) => void;
14
+ export type ReceiveInstanceCallback = (instance: WebAssembly.Instance, module: WebAssembly.Module) => void;
15
+ export type AssetType = LensCoreEnumValue;
16
+ export type CanvasType = LensCoreEnumValue;
17
+ export type RenderLoopMode = LensCoreEnumValue;
18
+ export type LensApiVisibility = LensCoreEnumValue;
19
+ export type DeviceClass = LensCoreEnumValue;
20
+ export type UserDataAccess = LensCoreEnumValue;
21
+ export type InterfaceControl = LensCoreEnumValue;
22
+ export type InterfaceAction = LensCoreEnumValue;
23
+ export type ExternalMediaOrientation = LensCoreEnumValue;
24
+ export type ErrorType = LensCoreEnumValue;
25
+ export type Uri = `${string}://${string}`;
26
+ export type Dimensions = {
27
27
  width: number;
28
28
  height: number;
29
29
  };
30
- export declare type Size2D = {
30
+ export type Size2D = {
31
31
  width: number;
32
32
  height: number;
33
33
  };
34
- export declare type Vec2D = {
34
+ export type Vec2D = {
35
35
  x: number;
36
36
  y: number;
37
37
  };
38
- export declare type Rect = {
38
+ export type Rect = {
39
39
  origin: Vec2D;
40
40
  size: Size2D;
41
41
  };
@@ -238,7 +238,7 @@ export interface ScreenDimmingRequestInput {
238
238
  effectId: string;
239
239
  enabled: boolean;
240
240
  }
241
- export declare type ScreenDimmingRequestHandler = (config: ScreenDimmingRequestInput) => void;
241
+ export type ScreenDimmingRequestHandler = (config: ScreenDimmingRequestInput) => void;
242
242
  export interface ClientInterfaceData {
243
243
  HeaderId?: string;
244
244
  DescriptionId?: string;
@@ -253,7 +253,7 @@ export interface ClientInterfaceRequestInput {
253
253
  interfaceAction: InterfaceAction;
254
254
  data: ClientInterfaceData;
255
255
  }
256
- export declare type ClientInterfaceRequestHandler = (config: ClientInterfaceRequestInput) => void;
256
+ export type ClientInterfaceRequestHandler = (config: ClientInterfaceRequestInput) => void;
257
257
  export interface LensCoreConfig {
258
258
  configId: string;
259
259
  value: {
@@ -273,7 +273,7 @@ export interface LensCoreConfig {
273
273
  };
274
274
  };
275
275
  }
276
- export declare type SetPreloadedConfigurationInput = Array<LensCoreConfig>;
276
+ export type SetPreloadedConfigurationInput = Array<LensCoreConfig>;
277
277
  export interface SetAllSoundsMutedInput {
278
278
  muted: boolean;
279
279
  fade: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../src/lens-core-module/generated-types.ts"],"names":[],"mappings":"","sourcesContent":["export type DefaultEventHandler = (...data: any[]) => void;\n\nexport type DefaultErrorHandler = (err: LensCoreError) => void;\n\nexport type LensCoreEnumValue = { value: number };\n\nexport type GetOutputCanvasesOutput = Record<number, HTMLCanvasElement>;\n\nexport type SetRenderSizeInput = SetRenderSizeMatchInputResolutionInput | SetRenderSizeExplicitInput;\n\nexport type SetRemoteAssetsProviderInput = (assetDescriptor: AssetDescriptor) => void;\n\nexport type ContentType =\n | \"text/plain\"\n | \"text/html\"\n | \"application/json\"\n | \"application/octet-stream\"\n | \"application/x-protobuf\"\n | \"application/grpc\";\n\nexport type SavePersistentStoreCallback = (id: string, data: ArrayBuffer) => void;\n\nexport type ShowHintCallback = (effectId: string, hintId: string) => void;\n\nexport type HideHintCallback = (effectId: string) => void;\n\nexport type ReceiveInstanceCallback = (instance: WebAssembly.Instance, module: WebAssembly.Module) => void;\n\nexport type AssetType = LensCoreEnumValue;\n\nexport type CanvasType = LensCoreEnumValue;\n\nexport type RenderLoopMode = LensCoreEnumValue;\n\nexport type LensApiVisibility = LensCoreEnumValue;\n\nexport type DeviceClass = LensCoreEnumValue;\n\nexport type UserDataAccess = LensCoreEnumValue;\n\nexport type InterfaceControl = LensCoreEnumValue;\n\nexport type InterfaceAction = LensCoreEnumValue;\n\nexport type ExternalMediaOrientation = LensCoreEnumValue;\n\nexport type ErrorType = LensCoreEnumValue;\n\nexport type Uri = `${string}://${string}`;\n\nexport type Dimensions = { width: number; height: number };\n\nexport type Size2D = { width: number; height: number };\n\nexport type Vec2D = { x: number; y: number };\n\nexport type Rect = { origin: Vec2D; size: Size2D };\n\nexport interface ClearAllLensesInput {\n onSuccess?: DefaultEventHandler;\n onFailure?: DefaultErrorHandler;\n}\n\nexport interface OnFrameProcessedParam {\n processingTimeMs: number;\n}\n\nexport interface InitializeInput {\n canvas?: HTMLCanvasElement | string;\n outputResolution?: Dimensions;\n showFpsPanel?: boolean;\n shouldUseWorker?: boolean;\n onFrameProcessed?: (arg: OnFrameProcessedParam) => void;\n onFailure?: DefaultErrorHandler;\n onSuccess?: DefaultEventHandler;\n exceptionHandler?: (error: LensCoreError) => void;\n}\n\nexport interface PlayCanvasInput {\n type: CanvasType;\n onReady?: () => void;\n onSuccess?: DefaultEventHandler;\n onFailure?: DefaultErrorHandler;\n}\n\nexport interface PauseCanvasInput {\n type: CanvasType;\n onSuccess?: DefaultEventHandler;\n onFailure?: DefaultErrorHandler;\n}\n\nexport interface SetFpsLimitInput {\n fps: number;\n onSuccess?: DefaultEventHandler;\n onFailure?: DefaultErrorHandler;\n}\n\nexport interface SetInputTransformInput {\n matrix: Float32Array | ArrayBuffer;\n onSuccess?: DefaultEventHandler;\n onFailure?: DefaultErrorHandler;\n}\n\nexport interface SetOnFrameProcessedInput {\n onFrameProcessed: (arg: OnFrameProcessedParam) => void;\n onSuccess?: DefaultEventHandler;\n onFailure?: DefaultErrorHandler;\n}\n\nexport interface SetRenderSizeMatchInputResolutionInput {\n mode: \"matchInputResolution\";\n onSuccess?: DefaultEventHandler;\n onFailure?: DefaultErrorHandler;\n}\n\nexport interface SetRenderSizeExplicitInput {\n mode: \"explicit\";\n target: Dimensions;\n onSuccess?: DefaultEventHandler;\n onFailure?: DefaultErrorHandler;\n}\n\nexport interface SetRenderLoopInput {\n mode: RenderLoopMode;\n onSuccess?: DefaultEventHandler;\n onFailure?: DefaultErrorHandler;\n}\n\nexport interface TeardownInput {\n onSuccess?: DefaultEventHandler;\n onFailure?: DefaultEventHandler;\n}\n\nexport interface ReplayTrackingDataInput {\n buffer: Uint8Array | ArrayBuffer;\n}\n\nexport interface UseMediaElementInput {\n media?: HTMLCanvasElement | HTMLImageElement | HTMLVideoElement | MediaStream;\n requestWebcam?: boolean;\n startOnFrontCamera?: boolean;\n mirrorMedia?: boolean;\n pauseExistingMedia?: boolean;\n autoplayNewMedia?: boolean;\n autoplayPreviewCanvas?: boolean;\n useManualFrameProcessing?: boolean;\n replayTrackingData?: ReplayTrackingDataInput;\n onFailure?: DefaultErrorHandler;\n onSuccess?: DefaultEventHandler;\n}\n\nexport interface UriListener {\n handleRequest: (request: UriRequest) => void;\n cancelRequest?: (request: UriCancelRequest) => void;\n}\n\nexport interface UriRequest {\n uri: Uri;\n identifier: string;\n method: \"GET\" | \"POST\";\n contentType: ContentType;\n data: ArrayBuffer;\n}\n\nexport interface UriResponse {\n code: number;\n description: string;\n contentType: ContentType;\n data: ArrayBuffer;\n metadata?: Record<string, string>;\n}\n\nexport interface UriCancelRequest {\n uri: Uri;\n requestId: string;\n}\n\nexport interface LensDescriptor {\n lensId: string;\n lensChecksum: string;\n lensPath?: string;\n lensDataBuffer?: Uint8Array | ArrayBuffer;\n onTurnOn?: DefaultEventHandler;\n onTurnOff?: DefaultEventHandler;\n onFirstFrameProcessed?: DefaultEventHandler;\n onResourcesLoaded?: DefaultEventHandler;\n launchData?: Uint8Array | ArrayBuffer;\n apiVisibility?: LensApiVisibility;\n publicApiUserDataAccess?: UserDataAccess;\n}\n\nexport interface AddLensInput extends LensDescriptor {\n onSuccess?: DefaultEventHandler;\n onFailure?: DefaultErrorHandler;\n}\n\nexport interface ReplaceLensesInput {\n lenses: LensDescriptor | Array<LensDescriptor>;\n onSuccess?: DefaultEventHandler;\n onFailure?: DefaultErrorHandler;\n}\n\nexport interface RemoveLensInput {\n lensId: string;\n onSuccess?: DefaultEventHandler;\n onFailure?: DefaultErrorHandler;\n}\n\nexport interface AssetDescriptor {\n assetId: string;\n assetType: AssetType;\n avatarId?: string;\n effectId?: string;\n}\n\nexport interface ProvideRemoteAssetsResponseInput {\n assetId: string;\n assetType: AssetType;\n assetBuffer?: ArrayBuffer;\n assetChecksum?: string;\n onFailure?: DefaultErrorHandler;\n}\n\nexport interface ProcessFrameInput {\n inputFrame: ImageBitmap | HTMLCanvasElement | HTMLImageElement | VideoFrame;\n timestampMillis: number;\n onSuccess?: DefaultEventHandler;\n onFailure?: DefaultErrorHandler;\n}\n\nexport interface LensCoreError extends Error {\n otherExceptions?: Array<Error>;\n cause: { type: ErrorType; metadata?: any };\n}\n\nexport interface ImageToYuvBufferInput {\n image: Uint8Array | ArrayBuffer | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap;\n width: number;\n height: number;\n outputBuffer?: Uint8Array | ArrayBuffer;\n onSuccess: (buffer: ArrayBuffer) => void;\n onFailure?: DefaultErrorHandler;\n}\n\nexport interface YuvBufferToBitmapInput {\n buffer: Uint8Array | ArrayBuffer;\n width: number;\n height: number;\n targetWidth?: number;\n targetHeight?: number;\n preserveCanvasState?: boolean;\n allowBufferTransfer?: boolean;\n onSuccess: (bitmap: ImageBitmap) => void;\n onFailure?: DefaultErrorHandler;\n}\n\nexport interface SetInterfaceControlVisibilityInput {\n effectId: string;\n interfaceControl: InterfaceControl;\n visibility: boolean;\n}\n\nexport interface HandleClientInterfaceActionInput {\n effectId: string;\n interfaceControl: InterfaceControl;\n interfaceAction: InterfaceAction;\n}\n\nexport interface ProvideExternalImageInput {\n data: Uint8Array | ArrayBuffer;\n orientation: ExternalMediaOrientation;\n faceRects?: Array<Rect>;\n}\n\nexport interface ProvideExternalVideoInput {\n data: Uint8Array | ArrayBuffer;\n orientation: ExternalMediaOrientation;\n relStartPosition?: number;\n relEndPosition?: number;\n volume?: number;\n}\n\nexport interface ScreenDimmingRequestInput {\n effectId: string;\n enabled: boolean;\n}\n\nexport type ScreenDimmingRequestHandler = (config: ScreenDimmingRequestInput) => void;\n\nexport interface ClientInterfaceData {\n HeaderId?: string;\n DescriptionId?: string;\n FaceFilteringEnabled?: \"0\" | \"1\";\n FaceFilteringMultipleFaces?: \"0\" | \"1\";\n ImageEnabled?: \"0\" | \"1\";\n VideoEnabled?: \"0\" | \"1\";\n}\n\nexport interface ClientInterfaceRequestInput {\n effectId: string;\n interfaceControl: InterfaceControl;\n interfaceAction: InterfaceAction;\n data: ClientInterfaceData;\n}\n\nexport type ClientInterfaceRequestHandler = (config: ClientInterfaceRequestInput) => void;\n\nexport interface LensCoreConfig {\n configId: string;\n value:\n | { stringValue: string }\n | { boolValue: boolean }\n | { intValue: number }\n | { longValue: number }\n | { floatValue: number }\n | {\n anyValue: {\n typeUrl: string;\n value: Uint8Array | ArrayBuffer;\n };\n };\n}\n\nexport type SetPreloadedConfigurationInput = Array<LensCoreConfig>;\n\nexport interface SetAllSoundsMutedInput {\n muted: boolean;\n fade: boolean;\n}\n\nexport interface SetDeviceClassInput {\n deviceClass: DeviceClass;\n onSuccess?: DefaultEventHandler;\n onFailure?: DefaultErrorHandler;\n}\n\nexport interface SetAudioParametersInput {\n parameters: {\n numChannels?: number;\n sampleRate?: number;\n };\n onSuccess?: DefaultEventHandler;\n onFailure?: DefaultErrorHandler;\n}\n\nexport interface SystemFont {\n name: string;\n data: Uint8Array | ArrayBuffer;\n}\n\nexport interface SetSystemFontsInput {\n fonts: SystemFont[];\n}\nexport interface ProcessAudioSampleBufferInput {\n input: Float32Array[] | ArrayBuffer[];\n output?: Float32Array[] | ArrayBuffer[];\n onSuccess?: DefaultEventHandler;\n onFailure?: DefaultErrorHandler;\n}\n\nexport interface InitialEmscriptenModule {\n mainScriptUrlOrBlob: string;\n compiledModule?: WebAssembly.Module;\n pthreadWorkerScriptUrl?: string;\n instantiateWasm?: (importObject: WebAssembly.Imports, receiveInstance: ReceiveInstanceCallback) => void;\n print?: (text: string) => void;\n printErr?: (text: string) => void;\n}\n\nexport interface LensCoreModule extends InitialEmscriptenModule {\n AssetType: {\n RemoteMediaByUrl: AssetType;\n DeviceDependent: AssetType;\n Static: AssetType;\n URL: AssetType;\n BitmojiDynamicAsset: AssetType;\n };\n\n CanvasType: {\n None: CanvasType;\n Preview: CanvasType;\n Capture: CanvasType;\n All: CanvasType;\n };\n\n LensApiVisibility: {\n Dev: LensApiVisibility;\n Private: LensApiVisibility;\n Public: LensApiVisibility;\n };\n\n DeviceClass: {\n Undefined: DeviceClass;\n BarelyWorking: DeviceClass;\n LowEnd: DeviceClass;\n MidEnd: DeviceClass;\n HighEnd: DeviceClass;\n };\n\n RenderLoopMode: {\n SetTimeout: RenderLoopMode;\n RequestAnimationFrame: RenderLoopMode;\n };\n\n UserDataAccess: {\n Restricted: UserDataAccess;\n Unrestricted: UserDataAccess;\n };\n\n InterfaceControl: {\n ToggleCameraButton: InterfaceControl;\n ImagePicker: InterfaceControl;\n Hint: InterfaceControl;\n Modal: InterfaceControl;\n LinkBitmojiCallToAction: InterfaceControl;\n SnapButton: InterfaceControl;\n PlayButton: InterfaceControl;\n All: InterfaceControl;\n ExitFullScreenButton: InterfaceControl;\n MemoriesButton: InterfaceControl;\n LensAttachmentButton: InterfaceControl;\n ReverseCamera: InterfaceControl;\n };\n\n InterfaceAction: {\n EnableHighlight: InterfaceAction;\n DisableHighlight: InterfaceAction;\n Trigger: InterfaceAction;\n Show: InterfaceAction;\n Hide: InterfaceAction;\n };\n\n ExternalMediaOrientation: {\n CW0: ExternalMediaOrientation;\n CW90: ExternalMediaOrientation;\n CW180: ExternalMediaOrientation;\n CW270: ExternalMediaOrientation;\n };\n\n ErrorType: {\n LensDeserialization: ErrorType;\n Validation: ErrorType;\n Uncategorized: ErrorType;\n LensExecution: ErrorType;\n Abort: ErrorType;\n };\n\n initialize: (config: InitializeInput) => void;\n processFrame: (config: ProcessFrameInput) => void;\n addLens: (config: AddLensInput) => void;\n replaceLenses: (config: ReplaceLensesInput) => void;\n removeLens: (config: RemoveLensInput) => void;\n clearAllLenses: (config: ClearAllLensesInput) => void;\n teardown: (config: TeardownInput) => void;\n useMediaElement: (config: UseMediaElementInput) => void;\n setFPSLimit: (config: SetFpsLimitInput) => void;\n setRenderLoopMode: (config: SetRenderLoopInput) => void;\n getCoreVersion: () => number;\n playCanvas: (input: PlayCanvasInput) => void;\n pauseCanvas: (input: PauseCanvasInput) => void;\n getOutputCanvases: () => GetOutputCanvasesOutput;\n setRenderSize: (input: SetRenderSizeInput) => void;\n startProfiling: () => void;\n endProfiling: () => void;\n setInputTransform: (config: SetInputTransformInput) => void;\n registerUriListener: (scheme: string, route: string, listener: UriListener) => void;\n provideUriResponse: (requestId: string, response: UriResponse) => void;\n setRemoteAssetsProvider: (provider: SetRemoteAssetsProviderInput) => void;\n provideRemoteAssetsResponse: (assetResponse: ProvideRemoteAssetsResponseInput) => void;\n registerShowHintCallback: (callback: ShowHintCallback) => void;\n registerHideHintCallback: (callback: HideHintCallback) => void;\n registerSavePersistentStoreCallback: (callback: SavePersistentStoreCallback) => void;\n imageToYuvBuffer: (config: ImageToYuvBufferInput) => void;\n yuvBufferToBitmap: (config: YuvBufferToBitmapInput) => void;\n setOnFrameProcessedCallback: (config: SetOnFrameProcessedInput) => void;\n setInterfaceControlVisibility: (config: SetInterfaceControlVisibilityInput) => void;\n handleClientInterfaceAction: (config: HandleClientInterfaceActionInput) => void;\n provideExternalImage: (config: ProvideExternalImageInput) => void;\n provideExternalVideo: (config: ProvideExternalVideoInput) => void;\n setScreenDimmingRequestHandler: (callback: ScreenDimmingRequestHandler) => void;\n setClientInterfaceRequestHandler: (callback: ClientInterfaceRequestHandler) => void;\n setPreloadedConfiguration: (config: SetPreloadedConfigurationInput) => void;\n setAllSoundsMuted: (config: SetAllSoundsMutedInput) => void;\n setDeviceClass: (config: SetDeviceClassInput) => void;\n setSystemFonts: (config: SetSystemFontsInput) => void;\n setAudioParameters: (config: SetAudioParametersInput) => void;\n processAudioSampleBuffer: (config: ProcessAudioSampleBufferInput) => void;\n}\n\ndeclare global {\n // This function is provided by the Emscripten glue file and responsible for initialization, will be fullfiled\n // when everything is loaded and it is safe to call compiled functions\n // eslint-disable-next-line max-len\n // https://emscripten.org/docs/getting_started/FAQ.html#how-can-i-tell-when-the-page-is-fully-loaded-and-it-is-safe-to-call-compiled-functions\n // Function is defined by the LensCore web assembly\n // eslint-disable-next-line max-len\n // https://github.sc-corp.net/Snapchat/LensCore/blob/6715da8c877d593e4fe133f4145eb3022204525d/Platforms/WebAssembly/LookserySDK/CMakeLists.txt#L65\n function createLensesModule(module: InitialEmscriptenModule): Promise<InitialEmscriptenModule & LensCoreModule>;\n}\n"]}
1
+ {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../src/lens-core-module/generated-types.ts"],"names":[],"mappings":"","sourcesContent":["export type DefaultEventHandler = (...data: any[]) => void;\n\nexport type DefaultErrorHandler = (err: LensCoreError) => void;\n\nexport type LensCoreEnumValue = { value: number };\n\nexport type GetOutputCanvasesOutput = Record<number, HTMLCanvasElement>;\n\nexport type SetRenderSizeInput = SetRenderSizeMatchInputResolutionInput | SetRenderSizeExplicitInput;\n\nexport type SetRemoteAssetsProviderInput = (assetDescriptor: AssetDescriptor) => void;\n\nexport type ContentType =\n | \"text/plain\"\n | \"text/html\"\n | \"application/json\"\n | \"application/octet-stream\"\n | \"application/x-protobuf\"\n | \"application/grpc\";\n\nexport type SavePersistentStoreCallback = (id: string, data: ArrayBuffer) => void;\n\nexport type ShowHintCallback = (effectId: string, hintId: string) => void;\n\nexport type HideHintCallback = (effectId: string) => void;\n\nexport type ReceiveInstanceCallback = (instance: WebAssembly.Instance, module: WebAssembly.Module) => void;\n\nexport type AssetType = LensCoreEnumValue;\n\nexport type CanvasType = LensCoreEnumValue;\n\nexport type RenderLoopMode = LensCoreEnumValue;\n\nexport type LensApiVisibility = LensCoreEnumValue;\n\nexport type DeviceClass = LensCoreEnumValue;\n\nexport type UserDataAccess = LensCoreEnumValue;\n\nexport type InterfaceControl = LensCoreEnumValue;\n\nexport type InterfaceAction = LensCoreEnumValue;\n\nexport type ExternalMediaOrientation = LensCoreEnumValue;\n\nexport type ErrorType = LensCoreEnumValue;\n\nexport type Uri = `${string}://${string}`;\n\nexport type Dimensions = { width: number; height: number };\n\nexport type Size2D = { width: number; height: number };\n\nexport type Vec2D = { x: number; y: number };\n\nexport type Rect = { origin: Vec2D; size: Size2D };\n\nexport interface ClearAllLensesInput {\n onSuccess?: DefaultEventHandler;\n onFailure?: DefaultErrorHandler;\n}\n\nexport interface OnFrameProcessedParam {\n processingTimeMs: number;\n}\n\nexport interface InitializeInput {\n canvas?: HTMLCanvasElement | string;\n outputResolution?: Dimensions;\n showFpsPanel?: boolean;\n shouldUseWorker?: boolean;\n onFrameProcessed?: (arg: OnFrameProcessedParam) => void;\n onFailure?: DefaultErrorHandler;\n onSuccess?: DefaultEventHandler;\n exceptionHandler?: (error: LensCoreError) => void;\n}\n\nexport interface PlayCanvasInput {\n type: CanvasType;\n onReady?: () => void;\n onSuccess?: DefaultEventHandler;\n onFailure?: DefaultErrorHandler;\n}\n\nexport interface PauseCanvasInput {\n type: CanvasType;\n onSuccess?: DefaultEventHandler;\n onFailure?: DefaultErrorHandler;\n}\n\nexport interface SetFpsLimitInput {\n fps: number;\n onSuccess?: DefaultEventHandler;\n onFailure?: DefaultErrorHandler;\n}\n\nexport interface SetInputTransformInput {\n matrix: Float32Array | ArrayBuffer;\n onSuccess?: DefaultEventHandler;\n onFailure?: DefaultErrorHandler;\n}\n\nexport interface SetOnFrameProcessedInput {\n onFrameProcessed: (arg: OnFrameProcessedParam) => void;\n onSuccess?: DefaultEventHandler;\n onFailure?: DefaultErrorHandler;\n}\n\nexport interface SetRenderSizeMatchInputResolutionInput {\n mode: \"matchInputResolution\";\n onSuccess?: DefaultEventHandler;\n onFailure?: DefaultErrorHandler;\n}\n\nexport interface SetRenderSizeExplicitInput {\n mode: \"explicit\";\n target: Dimensions;\n onSuccess?: DefaultEventHandler;\n onFailure?: DefaultErrorHandler;\n}\n\nexport interface SetRenderLoopInput {\n mode: RenderLoopMode;\n onSuccess?: DefaultEventHandler;\n onFailure?: DefaultErrorHandler;\n}\n\nexport interface TeardownInput {\n onSuccess?: DefaultEventHandler;\n onFailure?: DefaultEventHandler;\n}\n\nexport interface ReplayTrackingDataInput {\n buffer: Uint8Array | ArrayBuffer;\n}\n\nexport interface UseMediaElementInput {\n media?: HTMLCanvasElement | HTMLImageElement | HTMLVideoElement | MediaStream;\n requestWebcam?: boolean;\n startOnFrontCamera?: boolean;\n mirrorMedia?: boolean;\n pauseExistingMedia?: boolean;\n autoplayNewMedia?: boolean;\n autoplayPreviewCanvas?: boolean;\n useManualFrameProcessing?: boolean;\n replayTrackingData?: ReplayTrackingDataInput;\n onFailure?: DefaultErrorHandler;\n onSuccess?: DefaultEventHandler;\n}\n\nexport interface UriListener {\n handleRequest: (request: UriRequest) => void;\n cancelRequest?: (request: UriCancelRequest) => void;\n}\n\nexport interface UriRequest {\n uri: Uri;\n identifier: string;\n method: \"GET\" | \"POST\";\n contentType: ContentType;\n data: ArrayBuffer;\n}\n\nexport interface UriResponse {\n code: number;\n description: string;\n contentType: ContentType;\n data: ArrayBuffer;\n metadata?: Record<string, string>;\n}\n\nexport interface UriCancelRequest {\n uri: Uri;\n requestId: string;\n}\n\nexport interface LensDescriptor {\n lensId: string;\n lensChecksum: string;\n lensPath?: string;\n lensDataBuffer?: Uint8Array | ArrayBuffer;\n onTurnOn?: DefaultEventHandler;\n onTurnOff?: DefaultEventHandler;\n onFirstFrameProcessed?: DefaultEventHandler;\n onResourcesLoaded?: DefaultEventHandler;\n launchData?: Uint8Array | ArrayBuffer;\n apiVisibility?: LensApiVisibility;\n publicApiUserDataAccess?: UserDataAccess;\n}\n\nexport interface AddLensInput extends LensDescriptor {\n onSuccess?: DefaultEventHandler;\n onFailure?: DefaultErrorHandler;\n}\n\nexport interface ReplaceLensesInput {\n lenses: LensDescriptor | Array<LensDescriptor>;\n onSuccess?: DefaultEventHandler;\n onFailure?: DefaultErrorHandler;\n}\n\nexport interface RemoveLensInput {\n lensId: string;\n onSuccess?: DefaultEventHandler;\n onFailure?: DefaultErrorHandler;\n}\n\nexport interface AssetDescriptor {\n assetId: string;\n assetType: AssetType;\n avatarId?: string;\n effectId?: string;\n}\n\nexport interface ProvideRemoteAssetsResponseInput {\n assetId: string;\n assetType: AssetType;\n assetBuffer?: ArrayBuffer;\n assetChecksum?: string;\n onFailure?: DefaultErrorHandler;\n}\n\nexport interface ProcessFrameInput {\n inputFrame: ImageBitmap | HTMLCanvasElement | HTMLImageElement | VideoFrame;\n timestampMillis: number;\n onSuccess?: DefaultEventHandler;\n onFailure?: DefaultErrorHandler;\n}\n\nexport interface LensCoreError extends Error {\n otherExceptions?: Array<Error>;\n cause: { type: ErrorType; metadata?: any };\n}\n\nexport interface ImageToYuvBufferInput {\n image: Uint8Array | ArrayBuffer | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap;\n width: number;\n height: number;\n outputBuffer?: Uint8Array | ArrayBuffer;\n onSuccess: (buffer: ArrayBuffer) => void;\n onFailure?: DefaultErrorHandler;\n}\n\nexport interface YuvBufferToBitmapInput {\n buffer: Uint8Array | ArrayBuffer;\n width: number;\n height: number;\n targetWidth?: number;\n targetHeight?: number;\n preserveCanvasState?: boolean;\n allowBufferTransfer?: boolean;\n onSuccess: (bitmap: ImageBitmap) => void;\n onFailure?: DefaultErrorHandler;\n}\n\nexport interface SetInterfaceControlVisibilityInput {\n effectId: string;\n interfaceControl: InterfaceControl;\n visibility: boolean;\n}\n\nexport interface HandleClientInterfaceActionInput {\n effectId: string;\n interfaceControl: InterfaceControl;\n interfaceAction: InterfaceAction;\n}\n\nexport interface ProvideExternalImageInput {\n data: Uint8Array | ArrayBuffer;\n orientation: ExternalMediaOrientation;\n faceRects?: Array<Rect>;\n}\n\nexport interface ProvideExternalVideoInput {\n data: Uint8Array | ArrayBuffer;\n orientation: ExternalMediaOrientation;\n relStartPosition?: number;\n relEndPosition?: number;\n volume?: number;\n}\n\nexport interface ScreenDimmingRequestInput {\n effectId: string;\n enabled: boolean;\n}\n\nexport type ScreenDimmingRequestHandler = (config: ScreenDimmingRequestInput) => void;\n\nexport interface ClientInterfaceData {\n HeaderId?: string;\n DescriptionId?: string;\n FaceFilteringEnabled?: \"0\" | \"1\";\n FaceFilteringMultipleFaces?: \"0\" | \"1\";\n ImageEnabled?: \"0\" | \"1\";\n VideoEnabled?: \"0\" | \"1\";\n}\n\nexport interface ClientInterfaceRequestInput {\n effectId: string;\n interfaceControl: InterfaceControl;\n interfaceAction: InterfaceAction;\n data: ClientInterfaceData;\n}\n\nexport type ClientInterfaceRequestHandler = (config: ClientInterfaceRequestInput) => void;\n\nexport interface LensCoreConfig {\n configId: string;\n value:\n | { stringValue: string }\n | { boolValue: boolean }\n | { intValue: number }\n | { longValue: number }\n | { floatValue: number }\n | {\n anyValue: {\n typeUrl: string;\n value: Uint8Array | ArrayBuffer;\n };\n };\n}\n\nexport type SetPreloadedConfigurationInput = Array<LensCoreConfig>;\n\nexport interface SetAllSoundsMutedInput {\n muted: boolean;\n fade: boolean;\n}\n\nexport interface SetDeviceClassInput {\n deviceClass: DeviceClass;\n onSuccess?: DefaultEventHandler;\n onFailure?: DefaultErrorHandler;\n}\n\nexport interface SetAudioParametersInput {\n parameters: {\n numChannels?: number;\n sampleRate?: number;\n };\n onSuccess?: DefaultEventHandler;\n onFailure?: DefaultErrorHandler;\n}\n\nexport interface SystemFont {\n name: string;\n data: Uint8Array | ArrayBuffer;\n}\n\nexport interface SetSystemFontsInput {\n fonts: SystemFont[]\n}\nexport interface ProcessAudioSampleBufferInput {\n input: Float32Array[] | ArrayBuffer[];\n output?: Float32Array[] | ArrayBuffer[];\n onSuccess?: DefaultEventHandler;\n onFailure?: DefaultErrorHandler;\n}\n\nexport interface InitialEmscriptenModule {\n mainScriptUrlOrBlob: string;\n compiledModule?: WebAssembly.Module;\n pthreadWorkerScriptUrl?: string;\n instantiateWasm?: (importObject: WebAssembly.Imports, receiveInstance: ReceiveInstanceCallback) => void;\n print?: (text: string) => void;\n printErr?: (text: string) => void;\n}\n\nexport interface LensCoreModule extends InitialEmscriptenModule {\n AssetType: {\n RemoteMediaByUrl: AssetType;\n DeviceDependent: AssetType;\n Static: AssetType;\n URL: AssetType;\n BitmojiDynamicAsset: AssetType;\n };\n\n CanvasType: {\n None: CanvasType;\n Preview: CanvasType;\n Capture: CanvasType;\n All: CanvasType;\n };\n\n LensApiVisibility: {\n Dev: LensApiVisibility;\n Private: LensApiVisibility;\n Public: LensApiVisibility;\n };\n\n DeviceClass: {\n Undefined: DeviceClass;\n BarelyWorking: DeviceClass;\n LowEnd: DeviceClass;\n MidEnd: DeviceClass;\n HighEnd: DeviceClass;\n };\n\n RenderLoopMode: {\n SetTimeout: RenderLoopMode;\n RequestAnimationFrame: RenderLoopMode;\n };\n\n UserDataAccess: {\n Restricted: UserDataAccess;\n Unrestricted: UserDataAccess;\n };\n\n InterfaceControl: {\n ToggleCameraButton: InterfaceControl;\n ImagePicker: InterfaceControl;\n Hint: InterfaceControl;\n Modal: InterfaceControl;\n LinkBitmojiCallToAction: InterfaceControl;\n SnapButton: InterfaceControl;\n PlayButton: InterfaceControl;\n All: InterfaceControl;\n ExitFullScreenButton: InterfaceControl;\n MemoriesButton: InterfaceControl;\n LensAttachmentButton: InterfaceControl;\n ReverseCamera: InterfaceControl;\n };\n\n InterfaceAction: {\n EnableHighlight: InterfaceAction;\n DisableHighlight: InterfaceAction;\n Trigger: InterfaceAction;\n Show: InterfaceAction;\n Hide: InterfaceAction;\n };\n\n ExternalMediaOrientation: {\n CW0: ExternalMediaOrientation;\n CW90: ExternalMediaOrientation;\n CW180: ExternalMediaOrientation;\n CW270: ExternalMediaOrientation;\n };\n\n ErrorType: {\n LensDeserialization: ErrorType;\n Validation: ErrorType;\n Uncategorized: ErrorType;\n LensExecution: ErrorType;\n Abort: ErrorType;\n };\n\n initialize: (config: InitializeInput) => void;\n processFrame: (config: ProcessFrameInput) => void;\n addLens: (config: AddLensInput) => void;\n replaceLenses: (config: ReplaceLensesInput) => void;\n removeLens: (config: RemoveLensInput) => void;\n clearAllLenses: (config: ClearAllLensesInput) => void;\n teardown: (config: TeardownInput) => void;\n useMediaElement: (config: UseMediaElementInput) => void;\n setFPSLimit: (config: SetFpsLimitInput) => void;\n setRenderLoopMode: (config: SetRenderLoopInput) => void;\n getCoreVersion: () => number;\n playCanvas: (input: PlayCanvasInput) => void;\n pauseCanvas: (input: PauseCanvasInput) => void;\n getOutputCanvases: () => GetOutputCanvasesOutput;\n setRenderSize: (input: SetRenderSizeInput) => void;\n startProfiling: () => void;\n endProfiling: () => void;\n setInputTransform: (config: SetInputTransformInput) => void;\n registerUriListener: (scheme: string, route: string, listener: UriListener) => void;\n provideUriResponse: (requestId: string, response: UriResponse) => void;\n setRemoteAssetsProvider: (provider: SetRemoteAssetsProviderInput) => void;\n provideRemoteAssetsResponse: (assetResponse: ProvideRemoteAssetsResponseInput) => void;\n registerShowHintCallback: (callback: ShowHintCallback) => void;\n registerHideHintCallback: (callback: HideHintCallback) => void;\n registerSavePersistentStoreCallback: (callback: SavePersistentStoreCallback) => void;\n imageToYuvBuffer: (config: ImageToYuvBufferInput) => void;\n yuvBufferToBitmap: (config: YuvBufferToBitmapInput) => void;\n setOnFrameProcessedCallback: (config: SetOnFrameProcessedInput) => void;\n setInterfaceControlVisibility: (config: SetInterfaceControlVisibilityInput) => void;\n handleClientInterfaceAction: (config: HandleClientInterfaceActionInput) => void;\n provideExternalImage: (config: ProvideExternalImageInput) => void;\n provideExternalVideo: (config: ProvideExternalVideoInput) => void;\n setScreenDimmingRequestHandler: (callback: ScreenDimmingRequestHandler) => void;\n setClientInterfaceRequestHandler: (callback: ClientInterfaceRequestHandler) => void;\n setPreloadedConfiguration: (config: SetPreloadedConfigurationInput) => void;\n setAllSoundsMuted: (config: SetAllSoundsMutedInput) => void;\n setDeviceClass: (config: SetDeviceClassInput) => void;\n setSystemFonts: (config: SetSystemFontsInput) => void;\n setAudioParameters: (config: SetAudioParametersInput) => void;\n processAudioSampleBuffer: (config: ProcessAudioSampleBufferInput) => void;\n}\n\ndeclare global {\n // This function is provided by the Emscripten glue file and responsible for initialization, will be fullfiled\n // when everything is loaded and it is safe to call compiled functions\n // eslint-disable-next-line max-len\n // https://emscripten.org/docs/getting_started/FAQ.html#how-can-i-tell-when-the-page-is-fully-loaded-and-it-is-safe-to-call-compiled-functions\n // Function is defined by the LensCore web assembly\n // eslint-disable-next-line max-len\n // https://github.sc-corp.net/Snapchat/LensCore/blob/6715da8c877d593e4fe133f4145eb3022204525d/Platforms/WebAssembly/LookserySDK/CMakeLists.txt#L65\n function createLensesModule(module: InitialEmscriptenModule): Promise<InitialEmscriptenModule & LensCoreModule>;\n}\n"]}
@@ -24,7 +24,7 @@ export declare function getRequiredBootstrapURLs(endpointOverride?: string): Pro
24
24
  * @internal
25
25
  */
26
26
  export declare const lensCoreFactory: {
27
- (args_0: FetchHandler<Response>, args_1: CameraKitConfiguration): Promise<InitialEmscriptenModule & LensCoreModule>;
27
+ (args_0: FetchHandler, args_1: CameraKitConfiguration): Promise<InitialEmscriptenModule & LensCoreModule>;
28
28
  token: "lensCore";
29
29
  dependencies: readonly ["defaultFetchHandler", "configuration"];
30
30
  };
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "204",
3
- "buildNumber": "79",
4
- "baseUrl": "https://cf-st.sc-cdn.net/d/iEUhGJVwtLtAdTgiqHdLk?go=IgsKCTIBBEgBUFxgAQ%3D%3D&uc=92"
2
+ "version": "209",
3
+ "buildNumber": "8",
4
+ "baseUrl": "https://cf-st.sc-cdn.net/d/MkroAjRWoH1TVgTCn9VZV?go=IgsKCTIBBEgBUFxgAQ%3D%3D&uc=92"
5
5
  }
@@ -22,8 +22,8 @@ export interface LogEntry {
22
22
  level: keyof Logger;
23
23
  messages: any[];
24
24
  }
25
- export declare type LogLevelName = keyof typeof logLevelMap;
26
- export declare type Logger = Record<LogLevelName, (message?: any, ...optionalParams: any[]) => void>;
25
+ export type LogLevelName = keyof typeof logLevelMap;
26
+ export type Logger = Record<LogLevelName, (message?: any, ...optionalParams: any[]) => void>;
27
27
  /**
28
28
  * Gets logger for a given module.
29
29
  *
@@ -11,13 +11,13 @@ export interface CameraKitSourceSubscriber {
11
11
  readonly onDetach?: (reportError: (error: Error) => void) => void | Promise<void>;
12
12
  }
13
13
  /** @category Rendering */
14
- export declare type CameraKitDeviceInfo = {
14
+ export type CameraKitDeviceInfo = {
15
15
  cameraType: "front" | "back";
16
16
  fpsLimit: number;
17
17
  };
18
- export declare type CameraKitSourceInfo = Pick<UseMediaElementInput, "media" | "replayTrackingData" | "useManualFrameProcessing">;
18
+ export type CameraKitSourceInfo = Pick<UseMediaElementInput, "media" | "replayTrackingData" | "useManualFrameProcessing">;
19
19
  /** @category Rendering */
20
- export declare type CameraKitSourceOptions<T = {}> = Partial<T> & Partial<CameraKitDeviceInfo>;
20
+ export type CameraKitSourceOptions<T = {}> = Partial<T> & Partial<CameraKitDeviceInfo>;
21
21
  /**
22
22
  * This general-purpose class represents a source of media for a {@link CameraKitSession}.
23
23
  *
@@ -1 +1 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E,SAAS,EAAE,EAAE;YACxC,IAAI,CAAC,IAAI,CAAC,QAAQ;gBAAE,OAAO,SAAS,CAAC,sBAAsB,CAAC,sBAAsB,CAAC,CAAC,CAAC;YACrF,MAAM,MAAM,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;YACjC,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,CAAC;QACpF,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;;;OAIG;IAEH,YAAY,CAAC,SAAsB;QAC/B,OAAO,IAAI,OAAO,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE;YACxC,IAAI,CAAC,IAAI,CAAC,QAAQ;gBAAE,OAAO,SAAS,CAAC,sBAAsB,CAAC,qBAAqB,CAAC,CAAC,CAAC;YACpF,MAAM,MAAM,GAAG,IAAI,YAAY,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;YAClD,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,CAAC;QACtE,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAtBG;IAAC,QAAQ;;;;oDAOR;AAOD;IAAC,QAAQ;;qCACe,WAAW;;mDAMlC","sourcesContent":["/* eslint-disable @typescript-eslint/member-ordering */\n\nimport { validate } from \"../common/validate\";\nimport { LensCoreModule, UseMediaElementInput } from \"../lens-core-module/generated-types\";\nimport { Transform2D } from \"../transforms\";\n\nconst defaultDeviceInfo: CameraKitDeviceInfo = {\n cameraType: \"front\",\n fpsLimit: Number.POSITIVE_INFINITY,\n};\n\nconst createNotAttachedError = (message: string) =>\n new Error(`${message}. This CameraKitSource is not attached to a CameraKitSession.`);\n\n/**\n * When creating a {@link CameraKitSource}, passing a CameraKitSourceSubscriber allows logic to implemented which will\n * run whenever that source is attached/detached from a CameraKitSession.\n *\n * @category Rendering\n */\nexport interface CameraKitSourceSubscriber {\n readonly onAttach?: (\n source: CameraKitSource,\n lensCore: LensCoreModule,\n reportError: (error: Error) => void\n ) => void | Promise<void>;\n readonly onDetach?: (reportError: (error: Error) => void) => void | Promise<void>;\n}\n\n/** @category Rendering */\nexport type CameraKitDeviceInfo = {\n cameraType: \"front\" | \"back\";\n fpsLimit: number;\n};\n\nexport type CameraKitSourceInfo = Pick<\n UseMediaElementInput,\n \"media\" | \"replayTrackingData\" | \"useManualFrameProcessing\"\n>;\n\n/** @category Rendering */\nexport type CameraKitSourceOptions<T = {}> = Partial<T> & Partial<CameraKitDeviceInfo>;\n\n/**\n * This general-purpose class represents a source of media for a {@link CameraKitSession}.\n *\n * When an instance is passed to {@link CameraKitSession.setSource | CameraKitSession.setSource}, it will be \"attached\"\n * to the session. Later it may be \"detached\" from the session.\n *\n * Passing a {@link CameraKitSourceSubscriber} to the constructor allows callers to specify behavior\n * that will occur when the source is attached and detached. This can be used to e.g. update the render size.\n *\n * @category Rendering\n */\nexport class CameraKitSource {\n private lensCore?: LensCoreModule;\n private readonly deviceInfo: CameraKitDeviceInfo;\n\n constructor(\n private readonly sourceInfo: CameraKitSourceInfo,\n private readonly subscriber: CameraKitSourceSubscriber = {},\n deviceInfo: Partial<CameraKitDeviceInfo> = {}\n ) {\n this.deviceInfo = { ...defaultDeviceInfo, ...deviceInfo };\n }\n\n /**\n * Called by {@link CameraKitSession} when this source is set as that session's source.\n *\n * @param lensCore\n * @param reportError Calling this function will report an error back to the session.\n * @returns Rejects if any calls to LensCore or CameraKitSource.subscriber.onAttach fail.\n * @internal\n */\n async attach(lensCore: LensCoreModule, reportError: (error: Error) => void): Promise<void> {\n if (this.lensCore) {\n throw new Error(\n \"Cannot attach. This CameraKitCustomSource has already been attached to \" +\n \"a CameraKitSession. To re-attach, create a copy of this CameraKitCustomSource.\"\n );\n }\n\n this.lensCore = lensCore;\n\n await new Promise((onSuccess, onFailure) => {\n lensCore.useMediaElement({\n autoplayNewMedia: false,\n autoplayPreviewCanvas: false,\n media: this.sourceInfo.media,\n pauseExistingMedia: false,\n replayTrackingData: this.sourceInfo.replayTrackingData,\n requestWebcam: false,\n startOnFrontCamera: this.deviceInfo.cameraType === \"front\",\n useManualFrameProcessing: this.sourceInfo.useManualFrameProcessing,\n onSuccess,\n onFailure,\n });\n });\n\n await new Promise<void>((onSuccess, onFailure) => {\n // LensCore uses 0 to remove the limit.\n const fps = this.deviceInfo.fpsLimit < Number.POSITIVE_INFINITY ? this.deviceInfo.fpsLimit : 0;\n lensCore.setFPSLimit({ fps, onSuccess, onFailure });\n });\n\n if (this.subscriber.onAttach) await this.subscriber.onAttach(this, lensCore, reportError);\n }\n\n /**\n * Make a copy of the source, sharing the same {@link CameraKitSourceSubscriber}.\n *\n * @param deviceInfo Optionally provide new device info for the copy (e.g. to change the camera type).\n * @returns The new {@link CameraKitSource}\n */\n copy(deviceInfo: Partial<CameraKitDeviceInfo> = {}): CameraKitSource {\n return new CameraKitSource(this.sourceInfo, this.subscriber, { ...this.deviceInfo, ...deviceInfo });\n }\n\n /**\n * Called by {@link CameraKitSession} when it must remove this source.\n *\n * @param reportError Calling this function will report an error back to the session.\n * @returns\n * @internal\n */\n detach(reportError: (error: Error) => void): void | Promise<void> {\n if (!this.lensCore) return Promise.reject(createNotAttachedError(\"Cannot detach\"));\n if (this.subscriber.onDetach) return this.subscriber.onDetach(reportError);\n }\n\n /**\n * Set the resolution used to render this source.\n *\n * It’s important to distinguish render size from display size. The size at which the output canvases are displayed\n * on a web page is determined by the CSS of the page. It is distinct from the size at which LensCore renders\n * Lenses. Performance is dominated by render size, while any display scaling can most often be thought of as free.\n *\n * If greater performance is required, a smaller render size may boost frame-rate. It does come at a cost, including\n * loss of accuracy in various tracking and computer-vision algorithms (since they'll be operating on fewer pixels).\n *\n * The size of the Live and Capture {@link RenderTarget} is always the same.\n *\n * @todo Currently it's only valid to call `setRenderSize` after `CameraKitSession.play` has been called. This\n * constraint should be removed, so callers don't have to understand the underlying LensCore state machine.\n *\n * @param width pixels\n * @param height pixels\n * @returns Promise resolves when the render size has been successfully updated.\n */\n @validate\n setRenderSize(width: number, height: number): Promise<void> {\n return new Promise((onSuccess, onFailure) => {\n if (!this.lensCore) return onFailure(createNotAttachedError(\"Cannot setRenderSize\"));\n const target = { width, height };\n this.lensCore.setRenderSize({ mode: \"explicit\", target, onSuccess, onFailure });\n });\n }\n\n /**\n * Apply a 2D transformation to the source (e.g. translation, rotation, scale).\n *\n * @param transform Specifies the 3x3 matrix describing the transformation.\n */\n @validate\n setTransform(transform: Transform2D): Promise<void> {\n return new Promise((onSuccess, onFailure) => {\n if (!this.lensCore) return onFailure(createNotAttachedError(\"Cannot setTransform\"));\n const matrix = new Float32Array(transform.matrix);\n this.lensCore.setInputTransform({ matrix, onSuccess, onFailure });\n });\n }\n}\n"]}
1
+ {"version":3,"file":"CameraKitSource.js","sourceRoot":"","sources":["../../src/media-sources/CameraKitSource.ts"],"names":[],"mappings":"AAAA,uDAAuD;;AAEvD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,iBAAiB,GAAwB;IAC3C,UAAU,EAAE,OAAO;IACnB,QAAQ,EAAE,MAAM,CAAC,iBAAiB;CACrC,CAAC;AAEF,MAAM,sBAAsB,GAAG,CAAC,OAAe,EAAE,EAAE,CAC/C,IAAI,KAAK,CAAC,GAAG,OAAO,+DAA+D,CAAC,CAAC;AA+BzF;;;;;;;;;;GAUG;AACH,MAAM,OAAO,eAAe;IAIxB,YACqB,UAA+B,EAC/B,aAAwC,EAAE,EAC3D,aAA2C,EAAE;QAF5B,eAAU,GAAV,UAAU,CAAqB;QAC/B,eAAU,GAAV,UAAU,CAAgC;QAG3D,IAAI,CAAC,UAAU,mCAAQ,iBAAiB,GAAK,UAAU,CAAE,CAAC;IAC9D,CAAC;IAED;;;;;;;OAOG;IACG,MAAM,CAAC,QAAwB,E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C,CAAC;QACtE,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AArBG;IADC,QAAQ;;;;oDAOR;AAQD;IADC,QAAQ;;qCACe,WAAW;;mDAMlC","sourcesContent":["/* eslint-disable @typescript-eslint/member-ordering */\n\nimport { validate } from \"../common/validate\";\nimport { LensCoreModule, UseMediaElementInput } from \"../lens-core-module/generated-types\";\nimport { Transform2D } from \"../transforms\";\n\nconst defaultDeviceInfo: CameraKitDeviceInfo = {\n cameraType: \"front\",\n fpsLimit: Number.POSITIVE_INFINITY,\n};\n\nconst createNotAttachedError = (message: string) =>\n new Error(`${message}. This CameraKitSource is not attached to a CameraKitSession.`);\n\n/**\n * When creating a {@link CameraKitSource}, passing a CameraKitSourceSubscriber allows logic to implemented which will\n * run whenever that source is attached/detached from a CameraKitSession.\n *\n * @category Rendering\n */\nexport interface CameraKitSourceSubscriber {\n readonly onAttach?: (\n source: CameraKitSource,\n lensCore: LensCoreModule,\n reportError: (error: Error) => void\n ) => void | Promise<void>;\n readonly onDetach?: (reportError: (error: Error) => void) => void | Promise<void>;\n}\n\n/** @category Rendering */\nexport type CameraKitDeviceInfo = {\n cameraType: \"front\" | \"back\";\n fpsLimit: number;\n};\n\nexport type CameraKitSourceInfo = Pick<\n UseMediaElementInput,\n \"media\" | \"replayTrackingData\" | \"useManualFrameProcessing\"\n>;\n\n/** @category Rendering */\nexport type CameraKitSourceOptions<T = {}> = Partial<T> & Partial<CameraKitDeviceInfo>;\n\n/**\n * This general-purpose class represents a source of media for a {@link CameraKitSession}.\n *\n * When an instance is passed to {@link CameraKitSession.setSource | CameraKitSession.setSource}, it will be \"attached\"\n * to the session. Later it may be \"detached\" from the session.\n *\n * Passing a {@link CameraKitSourceSubscriber} to the constructor allows callers to specify behavior\n * that will occur when the source is attached and detached. This can be used to e.g. update the render size.\n *\n * @category Rendering\n */\nexport class CameraKitSource {\n private lensCore?: LensCoreModule;\n private readonly deviceInfo: CameraKitDeviceInfo;\n\n constructor(\n private readonly sourceInfo: CameraKitSourceInfo,\n private readonly subscriber: CameraKitSourceSubscriber = {},\n deviceInfo: Partial<CameraKitDeviceInfo> = {}\n ) {\n this.deviceInfo = { ...defaultDeviceInfo, ...deviceInfo };\n }\n\n /**\n * Called by {@link CameraKitSession} when this source is set as that session's source.\n *\n * @param lensCore\n * @param reportError Calling this function will report an error back to the session.\n * @returns Rejects if any calls to LensCore or CameraKitSource.subscriber.onAttach fail.\n * @internal\n */\n async attach(lensCore: LensCoreModule, reportError: (error: Error) => void): Promise<void> {\n if (this.lensCore) {\n throw new Error(\n \"Cannot attach. This CameraKitCustomSource has already been attached to \" +\n \"a CameraKitSession. To re-attach, create a copy of this CameraKitCustomSource.\"\n );\n }\n\n this.lensCore = lensCore;\n\n await new Promise((onSuccess, onFailure) => {\n lensCore.useMediaElement({\n autoplayNewMedia: false,\n autoplayPreviewCanvas: false,\n media: this.sourceInfo.media,\n pauseExistingMedia: false,\n replayTrackingData: this.sourceInfo.replayTrackingData,\n requestWebcam: false,\n startOnFrontCamera: this.deviceInfo.cameraType === \"front\",\n useManualFrameProcessing: this.sourceInfo.useManualFrameProcessing,\n onSuccess,\n onFailure,\n });\n });\n\n await new Promise<void>((onSuccess, onFailure) => {\n // LensCore uses 0 to remove the limit.\n const fps = this.deviceInfo.fpsLimit < Number.POSITIVE_INFINITY ? this.deviceInfo.fpsLimit : 0;\n lensCore.setFPSLimit({ fps, onSuccess, onFailure });\n });\n\n if (this.subscriber.onAttach) await this.subscriber.onAttach(this, lensCore, reportError);\n }\n\n /**\n * Make a copy of the source, sharing the same {@link CameraKitSourceSubscriber}.\n *\n * @param deviceInfo Optionally provide new device info for the copy (e.g. to change the camera type).\n * @returns The new {@link CameraKitSource}\n */\n copy(deviceInfo: Partial<CameraKitDeviceInfo> = {}): CameraKitSource {\n return new CameraKitSource(this.sourceInfo, this.subscriber, { ...this.deviceInfo, ...deviceInfo });\n }\n\n /**\n * Called by {@link CameraKitSession} when it must remove this source.\n *\n * @param reportError Calling this function will report an error back to the session.\n * @returns\n * @internal\n */\n detach(reportError: (error: Error) => void): void | Promise<void> {\n if (!this.lensCore) return Promise.reject(createNotAttachedError(\"Cannot detach\"));\n if (this.subscriber.onDetach) return this.subscriber.onDetach(reportError);\n }\n\n /**\n * Set the resolution used to render this source.\n *\n * It’s important to distinguish render size from display size. The size at which the output canvases are displayed\n * on a web page is determined by the CSS of the page. It is distinct from the size at which LensCore renders\n * Lenses. Performance is dominated by render size, while any display scaling can most often be thought of as free.\n *\n * If greater performance is required, a smaller render size may boost frame-rate. It does come at a cost, including\n * loss of accuracy in various tracking and computer-vision algorithms (since they'll be operating on fewer pixels).\n *\n * The size of the Live and Capture {@link RenderTarget} is always the same.\n *\n * @todo Currently it's only valid to call `setRenderSize` after `CameraKitSession.play` has been called. This\n * constraint should be removed, so callers don't have to understand the underlying LensCore state machine.\n *\n * @param width pixels\n * @param height pixels\n * @returns Promise resolves when the render size has been successfully updated.\n */\n @validate\n setRenderSize(width: number, height: number): Promise<void> {\n return new Promise((onSuccess, onFailure) => {\n if (!this.lensCore) return onFailure(createNotAttachedError(\"Cannot setRenderSize\"));\n const target = { width, height };\n this.lensCore.setRenderSize({ mode: \"explicit\", target, onSuccess, onFailure });\n });\n }\n\n /**\n * Apply a 2D transformation to the source (e.g. translation, rotation, scale).\n *\n * @param transform Specifies the 3x3 matrix describing the transformation.\n */\n @validate\n setTransform(transform: Transform2D): Promise<void> {\n return new Promise((onSuccess, onFailure) => {\n if (!this.lensCore) return onFailure(createNotAttachedError(\"Cannot setTransform\"));\n const matrix = new Float32Array(transform.matrix);\n this.lensCore.setInputTransform({ matrix, onSuccess, onFailure });\n });\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import { CameraKitSource, CameraKitSourceOptions } from "./CameraKitSource";
2
2
  /** @internal */
3
- export declare type FrameFormat = "rgb" | "yuv" | "nv12";
3
+ export type FrameFormat = "rgb" | "yuv" | "nv12";
4
4
  /** @internal */
5
5
  export interface FrameInput {
6
6
  format?: FrameFormat;
@@ -11,7 +11,7 @@ import { MetricsEventTarget } from "./metricsEventTarget";
11
11
  * For a full list of business events (using their internal names), see:
12
12
  * https://docs.google.com/document/d/1-kSzFWCWw9Qo3D08FR1_cqeHTsUtk9p3p3uOptzWDTY/
13
13
  */
14
- declare type CameraKitBusinessEventMap = {
14
+ type CameraKitBusinessEventMap = {
15
15
  assetDownload: MakeBusinessEvent<blizzard.CameraKitAssetDownload>;
16
16
  assetValidationFailed: MakeBusinessEvent<blizzard.CameraKitAssetValidationFailed>;
17
17
  benchmarkComplete: MakeBusinessEvent<blizzard.CameraKitWebBenchmarkComplete>;
@@ -23,14 +23,14 @@ declare type CameraKitBusinessEventMap = {
23
23
  lensContentValidationFailed: MakeBusinessEvent<blizzard.CameraKitLensContentValidationFailed>;
24
24
  session: MakeBusinessEvent<blizzard.CameraKitSession>;
25
25
  };
26
- export declare type MakeBusinessEvent<E> = Omit<{
26
+ export type MakeBusinessEvent<E> = Omit<{
27
27
  [K in keyof E]: Exclude<E[K], undefined> extends Record<keyof any, any> ? MakeBusinessEvent<Exclude<E[K], undefined>> : E[K];
28
28
  }, "cameraKitEventBase">;
29
- export declare type MakeTaggedBusinessEvent<K extends keyof CameraKitBusinessEventMap> = {
29
+ export type MakeTaggedBusinessEvent<K extends keyof CameraKitBusinessEventMap> = {
30
30
  name: K;
31
31
  } & CameraKitBusinessEventMap[K];
32
32
  export declare const businessEventsReporterFactory: {
33
- (args_0: MetricsEventTarget, args_1: FetchHandler<Response>): void;
33
+ (args_0: MetricsEventTarget, args_1: FetchHandler): void;
34
34
  token: "businessEventsReporter";
35
35
  dependencies: readonly ["metricsEventTarget", "metricsHandler"];
36
36
  };
@@ -1 +1 @@
1
- {"version":3,"file":"businessEventsReporter.js","sourceRoot":"","sources":["../../src/metrics/businessEventsReporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,OAAO,EAAE,kBAAkB,IAAI,SAAS,EAA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C,2CAA2C;YAC3C;gBACI,oCAAoC,EAAE,QAAQ,CAAC,oCAAoC,CAAC,WAAW,CAC3F,KAAK,CACR;aACJ;SACJ;QACD,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC;YAChB,oBAAoB;YACpB,EAAE,gBAAgB,EAAE,QAAQ,CAAC,gBAAgB,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE;SACrE;KACJ,CAAC,CAAC;AACP,CAAC,CACJ,CAAC","sourcesContent":["import { v4 } from \"uuid\";\nimport { cameraKitUserAgent as userAgent } from \"../common/cameraKitUserAgent\";\nimport { entries } from \"../common/entries\";\nimport { Injectable } from \"../dependency-injection/Injectable\";\nimport { EventOfType } from \"../events/TypedCustomEvent\";\nimport { EventsFromTarget } from \"../events/TypedEventTarget\";\nimport { FetchHandler } from \"../handlers/defaultFetchHandler\";\nimport { createBatchingHandler } from \"../handlers/batchingHandler\";\nimport { HandlerChainBuilder } from \"../handlers/HandlerChainBuilder\";\nimport { createMappingHandler } from \"../handlers/mappingHandler\";\nimport * as blizzard from \"../generated-proto/blizzard/cameraKitEvents\";\nimport { getLogger } from \"../logger/logger\";\nimport { metricsHandlerFactory } from \"./metricsHandler\";\nimport { MetricsEventTarget, metricsEventTargetFactory } from \"./metricsEventTarget\";\n\nconst logger = getLogger(\"BusinessEventsReporter\");\n\ntype Nullables<T> = { [K in keyof T]-?: undefined extends T[K] ? K : never }[keyof T];\ntype UndefinedToOptional<T> = Partial<Pick<T, Nullables<T>>> & Omit<T, Nullables<T>>;\n\ntype CameraKitBusinessEvents = EventsFromTarget<MetricsEventTarget>[\"detail\"];\n\ntype MakeBlizzardEvent<E> = Omit<E, \"name\"> & { cameraKitEventBase: blizzard.CameraKitEventBase };\n\ntype CreateEventData<EventType extends EventsFromTarget<MetricsEventTarget>[\"type\"]> = (\n event: MakeBlizzardEvent<EventOfType<EventType, EventsFromTarget<MetricsEventTarget>>[\"detail\"]>\n) => [string, UndefinedToOptional<blizzard.ServerEventData>];\n\ntype EventHandlers = {\n [EventType in EventsFromTarget<MetricsEventTarget>[\"type\"]]: CreateEventData<EventType>;\n};\n\n/**\n * Translate between an external metric name, which is exposed to SDK users, and an internal Blizzard event name,\n * property name, and constructor.\n *\n * It is very important that we do this, since the naming of these internal business events are unintuitive and will\n * not make sense to SDK users.\n *\n * For a full list of business events (using their internal names), see:\n * https://docs.google.com/document/d/1-kSzFWCWw9Qo3D08FR1_cqeHTsUtk9p3p3uOptzWDTY/\n */\ntype CameraKitBusinessEventMap = {\n assetDownload: MakeBusinessEvent<blizzard.CameraKitAssetDownload>;\n assetValidationFailed: MakeBusinessEvent<blizzard.CameraKitAssetValidationFailed>;\n benchmarkComplete: MakeBusinessEvent<blizzard.CameraKitWebBenchmarkComplete>;\n exception: MakeBusinessEvent<blizzard.CameraKitException>;\n legalPrompt: MakeBusinessEvent<blizzard.CameraKitLegalPrompt>;\n lensDownload: MakeBusinessEvent<blizzard.CameraKitLensDownload>;\n lensView: MakeBusinessEvent<blizzard.CameraKitWebLensSwipe>;\n lensWait: MakeBusinessEvent<blizzard.CameraKitLensSpin>;\n lensContentValidationFailed: MakeBusinessEvent<blizzard.CameraKitLensContentValidationFailed>;\n session: MakeBusinessEvent<blizzard.CameraKitSession>;\n};\n\n/**\n * This interface is defined in the CameraKit pb_schema proto definition – but the generated TypeScript does not handle\n * the `Any` type properly. It does not conform to the Proto3 canonical JSON mapping scheme, as defined here:\n * https://developers.google.com/protocol-buffers/docs/proto3#json\n *\n * To solve this (since we only need one message from the CameraKit schema), we'll just manually define the correct\n * interface here.\n */\ninterface SetBusinessEventsRequest {\n batchEvents: {\n \"@type\": \"com.snapchat.analytics.blizzard.ServerEventBatch\";\n serverEvents: blizzard.ServerEvent[];\n };\n}\n\n// CameraKit's prod metrics endpoint.\n// See: https://github.sc-corp.net/Snapchat/pb_schema/blob/2a966db/proto/camera_kit/v3/service.proto#L133\nconst BUSINESS_EVENTS_ENDPOINT = \"https://api-kit.snapchat.com/com.snap.camerakit.v3.Metrics/metrics/business_events\";\n\n// These values are (currently) arbitrarily selected.\n// TODO: Once we have gathered a sufficient quantity of metrics data, we should tune these numbers to ensure we're\n// operating with the right cost vs. staying under the `keepalive` request body limit of 64 kibibytes.\nconst BUSINESS_EVENT_BATCH_MAX_SIZE = 100;\nconst BUSINESS_EVENT_BATCH_MAX_AGE_MS = 5000;\n\nfunction listenAndReport(\n metricsEventTarget: MetricsEventTarget,\n metricsHandler: FetchHandler,\n eventHandlers: EventHandlers\n): void {\n const sessionId = v4();\n logger.log(`Session ID: ${sessionId}`);\n\n const handler = new HandlerChainBuilder(metricsHandler)\n .map(\n createMappingHandler((events: blizzard.ServerEvent[]) => {\n const body: SetBusinessEventsRequest = {\n batchEvents: {\n \"@type\": \"com.snapchat.analytics.blizzard.ServerEventBatch\",\n serverEvents: events,\n },\n };\n return new Request(BUSINESS_EVENTS_ENDPOINT, {\n method: \"POST\",\n body: JSON.stringify(body),\n credentials: \"include\",\n\n // Setting this to true makes fetch behave like `Navigator.sendBeacon` – that is, the request\n // will still be made even if the page terminates.\n // https://developer.mozilla.org/en-US/docs/Web/API/fetch\n keepalive: true,\n });\n })\n )\n .map(\n createBatchingHandler({\n batchReduce: (\n previousBundle: blizzard.ServerEvent[] | undefined,\n businessEvent: blizzard.ServerEvent\n ) => {\n const bundle = previousBundle ?? [];\n bundle.push(businessEvent);\n return bundle;\n },\n isBatchComplete: (bundle) => bundle.length >= BUSINESS_EVENT_BATCH_MAX_SIZE,\n maxBatchAge: BUSINESS_EVENT_BATCH_MAX_AGE_MS,\n })\n ).handler;\n\n const makeBlizzardEvent = <E extends CameraKitBusinessEvents>(event: E): MakeBlizzardEvent<E> => {\n return {\n ...event,\n cameraKitEventBase: blizzard.CameraKitEventBase.fromPartial({\n kitEventBase: blizzard.KitEventBase.fromPartial({\n locale: userAgent.locale,\n kitVariant: blizzard.KitType.CAMERA_KIT_WEB,\n kitVariantVersion: userAgent.sdkShortVersion,\n kitClientTimestampMillis: Date.now(),\n }),\n deviceCluster: 0,\n cameraKitVersion: userAgent.sdkLongVersion,\n lensCoreVersion: userAgent.lensCoreVersion,\n deviceModel: userAgent.deviceModel,\n cameraKitVariant: blizzard.CameraKitVariant.CAMERA_KIT_VARIANT_PARTNER,\n cameraKitFlavor: blizzard.CameraKitFlavor.CAMERA_KIT_FLAVOR_DEBUG,\n // We overload appId, using the origin instead because it's nice and human-readable (our backed adds\n // the true appId as oauth_client_id before forwarding events to Blizzard).\n appId: userAgent.origin,\n deviceConnectivity: blizzard.CameraKitConnectivityType.CAMERA_KIT_CONNECTIVITY_TYPE_WIFI,\n sessionId: sessionId,\n }),\n };\n };\n\n const sendServerEvent = (\n eventName: string,\n eventData: UndefinedToOptional<blizzard.ServerEventData>\n ): Promise<void> => {\n return handler(\n blizzard.ServerEvent.fromPartial({\n eventName,\n osType: userAgent.osType,\n osVersion: userAgent.osVersion,\n maxSequenceIdOnInstance: 0,\n sequenceId: 0,\n eventData,\n })\n );\n };\n\n entries(eventHandlers).forEach(([eventType, createEventData]) => {\n metricsEventTarget.addEventListener(eventType, ({ detail }) => {\n // Safety: When iterating over object keys in a mapped type, we lose the association between the key type\n // and the value type – at each iteration, the key type is a union of all possible keys and the value type\n // is a union of all possible values. When the value is a function with an argument, and that argument\n // depends on the key type (which is a union), the contravariance of the argument type means that the union\n // becomes an intersection. In our case here, this means the compiler expects each argument to contain all\n // properties from all event types. The cast is safe because the mapped `EventHandlers` type ensures that\n // `createEventData` takes an argument of the type corresponding its key's `eventType`'s event detail.\n const [eventName, eventData] = createEventData(makeBlizzardEvent(detail) as any);\n sendServerEvent(eventName, eventData);\n });\n });\n}\n\nexport type MakeBusinessEvent<E> = Omit<\n {\n [K in keyof E]: Exclude<E[K], undefined> extends Record<keyof any, any>\n ? MakeBusinessEvent<Exclude<E[K], undefined>>\n : E[K];\n },\n \"cameraKitEventBase\"\n>;\n\nexport type MakeTaggedBusinessEvent<K extends keyof CameraKitBusinessEventMap> = {\n name: K;\n} & CameraKitBusinessEventMap[K];\n\nexport const businessEventsReporterFactory = Injectable(\n \"businessEventsReporter\",\n [metricsEventTargetFactory.token, metricsHandlerFactory.token] as const,\n (metricsEventTarget: MetricsEventTarget, metricsHandler: FetchHandler) => {\n /**\n * This defines a mapping from a business event's external name (the name we document in public API docs), to\n * its internal representation as a Blizzard ServerEvent.\n *\n * It is important that we do this, since the naming of these internal business events are unintuitive and will\n * not make sense to SDK users.\n *\n * To specify the internal event, we must give the ServerEvent's eventName, the specific property name which\n * contains the event data (this is a \"oneof\" property on ServerEvent), and use the correct event type's\n * `fromPartial` method (this is generated from the ServerEvent protobuf).\n *\n * These events are documented here:\n * https://docs.google.com/document/d/1-kSzFWCWw9Qo3D08FR1_cqeHTsUtk9p3p3uOptzWDTY/\n *\n * They are defined in code here:\n * https://github.sc-corp.net/Snapchat/snapchat/tree/master/blizzard/schema/blizzard-schema/\n * codeGen/src/main/java/com/snapchat/analytics/schema/events/cameraKit\n */\n listenAndReport(metricsEventTarget, metricsHandler, {\n assetDownload: (event) => [\n \"CAMERA_KIT_ASSET_DOWNLOAD\",\n { cameraKitAssetDownload: blizzard.CameraKitAssetDownload.fromPartial(event) },\n ],\n assetValidationFailed: (event) => [\n \"CAMERA_KIT_ASSET_VALIDATION_FAILED\",\n { cameraKitAssetValidationFailed: blizzard.CameraKitAssetValidationFailed.fromPartial(event) },\n ],\n benchmarkComplete: (event) => [\n \"CAMERA_KIT_WEB_BENCHMARK_COMPLETE\",\n { cameraKitWebBenchmarkComplete: blizzard.CameraKitWebBenchmarkComplete.fromPartial(event) },\n ],\n exception: (event) => [\n \"CAMERA_KIT_EXCEPTION\",\n { cameraKitException: blizzard.CameraKitException.fromPartial(event) },\n ],\n legalPrompt: (event) => [\n \"CAMERA_KIT_LEGAL_PROMPT\",\n { cameraKitLegalPrompt: blizzard.CameraKitLegalPrompt.fromPartial(event) },\n ],\n lensDownload: (event) => [\n \"CAMERA_KIT_LENS_DOWNLOAD\",\n { cameraKitLensDownload: blizzard.CameraKitLensDownload.fromPartial(event) },\n ],\n lensView: (event) => [\n \"CAMERA_KIT_WEB_LENS_SWIPE\",\n { cameraKitWebLensSwipe: blizzard.CameraKitWebLensSwipe.fromPartial(event) },\n ],\n lensWait: (event) => [\n \"CAMERA_KIT_LENS_SPIN\",\n { cameraKitLensSpin: blizzard.CameraKitLensSpin.fromPartial(event) },\n ],\n lensContentValidationFailed: (event) => [\n \"CAMERA_KIT_LENS_CONTENT_VALIDATION_FAILED\",\n {\n cameraKitLensContentValidationFailed: blizzard.CameraKitLensContentValidationFailed.fromPartial(\n event\n ),\n },\n ],\n session: (event) => [\n \"CAMERA_KIT_SESSION\",\n { cameraKitSession: blizzard.CameraKitSession.fromPartial(event) },\n ],\n });\n }\n);\n"]}
1
+ {"version":3,"file":"businessEventsReporter.js","sourceRoot":"","sources":["../../src/metrics/businessEventsReporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,OAAO,EAAE,kBAAkB,IAAI,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC/E,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAIhE,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,QAAQ,MAAM,6CAA6C,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAsB,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAErF,MAAM,MAAM,GAAG,SAAS,CAAC,wBAAwB,CAAC,CAAC;AAuDnD,qCAAqC;AACrC,yGAAyG;AACzG,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C,KAAK,EAAE,EAAE,CAAC;YACpB,yBAAyB;YACzB,EAAE,oBAAoB,EAAE,QAAQ,CAAC,oBAAoB,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE;SAC7E;QACD,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC;YACrB,0BAA0B;YAC1B,EAAE,qBAAqB,EAAE,QAAQ,CAAC,qBAAqB,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE;SAC/E;QACD,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC;YACjB,2BAA2B;YAC3B,EAAE,qBAAqB,EAAE,QAAQ,CAAC,qBAAqB,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE;SAC/E;QACD,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC;YACjB,sBAAsB;YACtB,EAAE,iBAAiB,EAAE,QAAQ,CAAC,iBAAiB,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE;SACvE;QACD,2BAA2B,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC;YACpC,2CAA2C;YAC3C;gBACI,oCAAoC,EAChC,QAAQ,CAAC,oCAAoC,CAAC,WAAW,CAAC,KAAK,CAAC;aACvE;SACJ;QACD,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC;YAChB,oBAAoB;YACpB,EAAE,gBAAgB,EAAE,QAAQ,CAAC,gBAAgB,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE;SACrE;KACJ,CAAC,CAAC;AACP,CAAC,CACJ,CAAC","sourcesContent":["import { v4 } from \"uuid\";\nimport { cameraKitUserAgent as userAgent } from \"../common/cameraKitUserAgent\";\nimport { entries } from \"../common/entries\";\nimport { Injectable } from \"../dependency-injection/Injectable\";\nimport { EventOfType } from \"../events/TypedCustomEvent\";\nimport { EventsFromTarget } from \"../events/TypedEventTarget\";\nimport { FetchHandler } from \"../handlers/defaultFetchHandler\";\nimport { createBatchingHandler } from \"../handlers/batchingHandler\";\nimport { HandlerChainBuilder } from \"../handlers/HandlerChainBuilder\";\nimport { createMappingHandler } from \"../handlers/mappingHandler\";\nimport * as blizzard from \"../generated-proto/blizzard/cameraKitEvents\";\nimport { getLogger } from \"../logger/logger\";\nimport { metricsHandlerFactory } from \"./metricsHandler\";\nimport { MetricsEventTarget, metricsEventTargetFactory } from \"./metricsEventTarget\";\n\nconst logger = getLogger(\"BusinessEventsReporter\");\n\ntype Nullables<T> = { [K in keyof T]-?: undefined extends T[K] ? K : never }[keyof T];\ntype UndefinedToOptional<T> = Partial<Pick<T, Nullables<T>>> & Omit<T, Nullables<T>>;\n\ntype CameraKitBusinessEvents = EventsFromTarget<MetricsEventTarget>[\"detail\"];\n\ntype MakeBlizzardEvent<E> = Omit<E, \"name\"> & { cameraKitEventBase: blizzard.CameraKitEventBase };\n\ntype CreateEventData<EventType extends EventsFromTarget<MetricsEventTarget>[\"type\"]> = (\n event: MakeBlizzardEvent<EventOfType<EventType, EventsFromTarget<MetricsEventTarget>>[\"detail\"]>\n) => [string, UndefinedToOptional<blizzard.ServerEventData>];\n\ntype EventHandlers = {\n [EventType in EventsFromTarget<MetricsEventTarget>[\"type\"]]: CreateEventData<EventType>;\n};\n\n/**\n * Translate between an external metric name, which is exposed to SDK users, and an internal Blizzard event name,\n * property name, and constructor.\n *\n * It is very important that we do this, since the naming of these internal business events are unintuitive and will\n * not make sense to SDK users.\n *\n * For a full list of business events (using their internal names), see:\n * https://docs.google.com/document/d/1-kSzFWCWw9Qo3D08FR1_cqeHTsUtk9p3p3uOptzWDTY/\n */\ntype CameraKitBusinessEventMap = {\n assetDownload: MakeBusinessEvent<blizzard.CameraKitAssetDownload>;\n assetValidationFailed: MakeBusinessEvent<blizzard.CameraKitAssetValidationFailed>;\n benchmarkComplete: MakeBusinessEvent<blizzard.CameraKitWebBenchmarkComplete>;\n exception: MakeBusinessEvent<blizzard.CameraKitException>;\n legalPrompt: MakeBusinessEvent<blizzard.CameraKitLegalPrompt>;\n lensDownload: MakeBusinessEvent<blizzard.CameraKitLensDownload>;\n lensView: MakeBusinessEvent<blizzard.CameraKitWebLensSwipe>;\n lensWait: MakeBusinessEvent<blizzard.CameraKitLensSpin>;\n lensContentValidationFailed: MakeBusinessEvent<blizzard.CameraKitLensContentValidationFailed>;\n session: MakeBusinessEvent<blizzard.CameraKitSession>;\n};\n\n/**\n * This interface is defined in the CameraKit pb_schema proto definition – but the generated TypeScript does not handle\n * the `Any` type properly. It does not conform to the Proto3 canonical JSON mapping scheme, as defined here:\n * https://developers.google.com/protocol-buffers/docs/proto3#json\n *\n * To solve this (since we only need one message from the CameraKit schema), we'll just manually define the correct\n * interface here.\n */\ninterface SetBusinessEventsRequest {\n batchEvents: {\n \"@type\": \"com.snapchat.analytics.blizzard.ServerEventBatch\";\n serverEvents: blizzard.ServerEvent[];\n };\n}\n\n// CameraKit's prod metrics endpoint.\n// See: https://github.sc-corp.net/Snapchat/pb_schema/blob/2a966db/proto/camera_kit/v3/service.proto#L133\nconst BUSINESS_EVENTS_ENDPOINT = \"https://api-kit.snapchat.com/com.snap.camerakit.v3.Metrics/metrics/business_events\";\n\n// These values are (currently) arbitrarily selected.\n// TODO: Once we have gathered a sufficient quantity of metrics data, we should tune these numbers to ensure we're\n// operating with the right cost vs. staying under the `keepalive` request body limit of 64 kibibytes.\nconst BUSINESS_EVENT_BATCH_MAX_SIZE = 100;\nconst BUSINESS_EVENT_BATCH_MAX_AGE_MS = 5000;\n\nfunction listenAndReport(\n metricsEventTarget: MetricsEventTarget,\n metricsHandler: FetchHandler,\n eventHandlers: EventHandlers\n): void {\n const sessionId = v4();\n logger.log(`Session ID: ${sessionId}`);\n\n const handler = new HandlerChainBuilder(metricsHandler)\n .map(\n createMappingHandler((events: blizzard.ServerEvent[]) => {\n const body: SetBusinessEventsRequest = {\n batchEvents: {\n \"@type\": \"com.snapchat.analytics.blizzard.ServerEventBatch\",\n serverEvents: events,\n },\n };\n return new Request(BUSINESS_EVENTS_ENDPOINT, {\n method: \"POST\",\n body: JSON.stringify(body),\n credentials: \"include\",\n\n // Setting this to true makes fetch behave like `Navigator.sendBeacon` – that is, the request\n // will still be made even if the page terminates.\n // https://developer.mozilla.org/en-US/docs/Web/API/fetch\n keepalive: true,\n });\n })\n )\n .map(\n createBatchingHandler({\n batchReduce: (\n previousBundle: blizzard.ServerEvent[] | undefined,\n businessEvent: blizzard.ServerEvent\n ) => {\n const bundle = previousBundle ?? [];\n bundle.push(businessEvent);\n return bundle;\n },\n isBatchComplete: (bundle) => bundle.length >= BUSINESS_EVENT_BATCH_MAX_SIZE,\n maxBatchAge: BUSINESS_EVENT_BATCH_MAX_AGE_MS,\n })\n ).handler;\n\n const makeBlizzardEvent = <E extends CameraKitBusinessEvents>(event: E): MakeBlizzardEvent<E> => {\n return {\n ...event,\n cameraKitEventBase: blizzard.CameraKitEventBase.fromPartial({\n kitEventBase: blizzard.KitEventBase.fromPartial({\n locale: userAgent.locale,\n kitVariant: blizzard.KitType.CAMERA_KIT_WEB,\n kitVariantVersion: userAgent.sdkShortVersion,\n kitClientTimestampMillis: Date.now(),\n }),\n deviceCluster: 0,\n cameraKitVersion: userAgent.sdkLongVersion,\n lensCoreVersion: userAgent.lensCoreVersion,\n deviceModel: userAgent.deviceModel,\n cameraKitVariant: blizzard.CameraKitVariant.CAMERA_KIT_VARIANT_PARTNER,\n cameraKitFlavor: blizzard.CameraKitFlavor.CAMERA_KIT_FLAVOR_DEBUG,\n // We overload appId, using the origin instead because it's nice and human-readable (our backed adds\n // the true appId as oauth_client_id before forwarding events to Blizzard).\n appId: userAgent.origin,\n deviceConnectivity: blizzard.CameraKitConnectivityType.CAMERA_KIT_CONNECTIVITY_TYPE_WIFI,\n sessionId: sessionId,\n }),\n };\n };\n\n const sendServerEvent = (\n eventName: string,\n eventData: UndefinedToOptional<blizzard.ServerEventData>\n ): Promise<void> => {\n return handler(\n blizzard.ServerEvent.fromPartial({\n eventName,\n osType: userAgent.osType,\n osVersion: userAgent.osVersion,\n maxSequenceIdOnInstance: 0,\n sequenceId: 0,\n eventData,\n })\n );\n };\n\n entries(eventHandlers).forEach(([eventType, createEventData]) => {\n metricsEventTarget.addEventListener(eventType, ({ detail }) => {\n // Safety: When iterating over object keys in a mapped type, we lose the association between the key type\n // and the value type – at each iteration, the key type is a union of all possible keys and the value type\n // is a union of all possible values. When the value is a function with an argument, and that argument\n // depends on the key type (which is a union), the contravariance of the argument type means that the union\n // becomes an intersection. In our case here, this means the compiler expects each argument to contain all\n // properties from all event types. The cast is safe because the mapped `EventHandlers` type ensures that\n // `createEventData` takes an argument of the type corresponding its key's `eventType`'s event detail.\n const [eventName, eventData] = createEventData(makeBlizzardEvent(detail) as any);\n sendServerEvent(eventName, eventData);\n });\n });\n}\n\nexport type MakeBusinessEvent<E> = Omit<\n {\n [K in keyof E]: Exclude<E[K], undefined> extends Record<keyof any, any>\n ? MakeBusinessEvent<Exclude<E[K], undefined>>\n : E[K];\n },\n \"cameraKitEventBase\"\n>;\n\nexport type MakeTaggedBusinessEvent<K extends keyof CameraKitBusinessEventMap> = {\n name: K;\n} & CameraKitBusinessEventMap[K];\n\nexport const businessEventsReporterFactory = Injectable(\n \"businessEventsReporter\",\n [metricsEventTargetFactory.token, metricsHandlerFactory.token] as const,\n (metricsEventTarget: MetricsEventTarget, metricsHandler: FetchHandler) => {\n /**\n * This defines a mapping from a business event's external name (the name we document in public API docs), to\n * its internal representation as a Blizzard ServerEvent.\n *\n * It is important that we do this, since the naming of these internal business events are unintuitive and will\n * not make sense to SDK users.\n *\n * To specify the internal event, we must give the ServerEvent's eventName, the specific property name which\n * contains the event data (this is a \"oneof\" property on ServerEvent), and use the correct event type's\n * `fromPartial` method (this is generated from the ServerEvent protobuf).\n *\n * These events are documented here:\n * https://docs.google.com/document/d/1-kSzFWCWw9Qo3D08FR1_cqeHTsUtk9p3p3uOptzWDTY/\n *\n * They are defined in code here:\n * https://github.sc-corp.net/Snapchat/snapchat/tree/master/blizzard/schema/blizzard-schema/\n * codeGen/src/main/java/com/snapchat/analytics/schema/events/cameraKit\n */\n listenAndReport(metricsEventTarget, metricsHandler, {\n assetDownload: (event) => [\n \"CAMERA_KIT_ASSET_DOWNLOAD\",\n { cameraKitAssetDownload: blizzard.CameraKitAssetDownload.fromPartial(event) },\n ],\n assetValidationFailed: (event) => [\n \"CAMERA_KIT_ASSET_VALIDATION_FAILED\",\n { cameraKitAssetValidationFailed: blizzard.CameraKitAssetValidationFailed.fromPartial(event) },\n ],\n benchmarkComplete: (event) => [\n \"CAMERA_KIT_WEB_BENCHMARK_COMPLETE\",\n { cameraKitWebBenchmarkComplete: blizzard.CameraKitWebBenchmarkComplete.fromPartial(event) },\n ],\n exception: (event) => [\n \"CAMERA_KIT_EXCEPTION\",\n { cameraKitException: blizzard.CameraKitException.fromPartial(event) },\n ],\n legalPrompt: (event) => [\n \"CAMERA_KIT_LEGAL_PROMPT\",\n { cameraKitLegalPrompt: blizzard.CameraKitLegalPrompt.fromPartial(event) },\n ],\n lensDownload: (event) => [\n \"CAMERA_KIT_LENS_DOWNLOAD\",\n { cameraKitLensDownload: blizzard.CameraKitLensDownload.fromPartial(event) },\n ],\n lensView: (event) => [\n \"CAMERA_KIT_WEB_LENS_SWIPE\",\n { cameraKitWebLensSwipe: blizzard.CameraKitWebLensSwipe.fromPartial(event) },\n ],\n lensWait: (event) => [\n \"CAMERA_KIT_LENS_SPIN\",\n { cameraKitLensSpin: blizzard.CameraKitLensSpin.fromPartial(event) },\n ],\n lensContentValidationFailed: (event) => [\n \"CAMERA_KIT_LENS_CONTENT_VALIDATION_FAILED\",\n {\n cameraKitLensContentValidationFailed:\n blizzard.CameraKitLensContentValidationFailed.fromPartial(event),\n },\n ],\n session: (event) => [\n \"CAMERA_KIT_SESSION\",\n { cameraKitSession: blizzard.CameraKitSession.fromPartial(event) },\n ],\n });\n }\n);\n"]}
@@ -12,21 +12,21 @@ import { MakeTaggedBusinessEvent } from "./businessEventsReporter";
12
12
  /**
13
13
  * The Exception metric reports every time we handle an exception.
14
14
  */
15
- export declare type Exception = MakeTaggedBusinessEvent<"exception">;
16
- export declare type CameraKitBootstrapMetricEvents = TypedCustomEvent<BenchmarkComplete["name"], BenchmarkComplete>;
17
- export declare type CameraKitSessionMetricEvents = TypedCustomEvent<LegalPrompt["name"], LegalPrompt> | TypedCustomEvent<LensView["name"], LensView> | TypedCustomEvent<LensWait["name"], LensWait> | TypedCustomEvent<LensDownload["name"], LensDownload> | TypedCustomEvent<AssetDownload["name"], AssetDownload> | TypedCustomEvent<AssetValidationFailed["name"], AssetValidationFailed> | TypedCustomEvent<LensContentValidationFailed["name"], LensContentValidationFailed> | TypedCustomEvent<Session["name"], Session>;
15
+ export type Exception = MakeTaggedBusinessEvent<"exception">;
16
+ export type CameraKitBootstrapMetricEvents = TypedCustomEvent<BenchmarkComplete["name"], BenchmarkComplete>;
17
+ export type CameraKitSessionMetricEvents = TypedCustomEvent<LegalPrompt["name"], LegalPrompt> | TypedCustomEvent<LensView["name"], LensView> | TypedCustomEvent<LensWait["name"], LensWait> | TypedCustomEvent<LensDownload["name"], LensDownload> | TypedCustomEvent<AssetDownload["name"], AssetDownload> | TypedCustomEvent<AssetValidationFailed["name"], AssetValidationFailed> | TypedCustomEvent<LensContentValidationFailed["name"], LensContentValidationFailed> | TypedCustomEvent<Session["name"], Session>;
18
18
  /**
19
19
  * A union of all event types emitted by the {@link CameraKit.events} event emitter.
20
20
  *
21
21
  * @internal
22
22
  */
23
- export declare type CameraKitMetricEvents = CameraKitSessionMetricEvents | CameraKitBootstrapMetricEvents | TypedCustomEvent<Exception["name"], Exception>;
23
+ export type CameraKitMetricEvents = CameraKitSessionMetricEvents | CameraKitBootstrapMetricEvents | TypedCustomEvent<Exception["name"], Exception>;
24
24
  /**
25
25
  * This event target may be used to listen for any of the metrics events reported by CameraKit.
26
26
  *
27
27
  * @internal
28
28
  */
29
- export declare type MetricsEventTarget = TypedEventTarget<CameraKitMetricEvents>;
29
+ export type MetricsEventTarget = TypedEventTarget<CameraKitMetricEvents>;
30
30
  /**
31
31
  * Any metrics that we wish to emit to applications should be dispatched on this event target.
32
32
  *
@@ -3,7 +3,7 @@ import { FetchHandler } from "../handlers/defaultFetchHandler";
3
3
  * @internal
4
4
  */
5
5
  export declare const metricsHandlerFactory: {
6
- (args_0: FetchHandler<Response>): import("../handlers/HandlerChainBuilder").Handler<RequestInfo, Response, RequestInit | undefined>;
6
+ (args_0: FetchHandler): import("../handlers/HandlerChainBuilder").Handler<RequestInfo, Response, RequestInit | undefined>;
7
7
  token: "metricsHandler";
8
8
  dependencies: readonly ["cameraKitServiceFetchHandler"];
9
9
  };
@@ -1,6 +1,6 @@
1
1
  import { FetchHandler } from "../handlers/defaultFetchHandler";
2
2
  import { OperationalMetric } from "../generated-proto/pb_schema/camera_kit/v3/operational_metrics";
3
- declare type MetricsHandler = (metric: OperationalMetric) => Promise<void>;
3
+ type MetricsHandler = (metric: OperationalMetric) => Promise<void>;
4
4
  /**
5
5
  * Use this class to report operational metrics – these are metrics that describe aspects of the SDK's performance,
6
6
  * which may be used to assess and investigate operational issues.
@@ -45,7 +45,7 @@ export declare class OperationalMetricsReporter {
45
45
  * @internal
46
46
  */
47
47
  export declare const operationalMetricReporterFactory: {
48
- (args_0: FetchHandler<Response>): OperationalMetricsReporter;
48
+ (args_0: FetchHandler): OperationalMetricsReporter;
49
49
  token: "operationalMetricsReporter";
50
50
  dependencies: readonly ["metricsHandler"];
51
51
  };
@@ -2,7 +2,7 @@ import { CameraKitConfiguration } from "../../configuration";
2
2
  import { MakeTaggedBusinessEvent } from "../businessEventsReporter";
3
3
  import { MetricsEventTarget } from "../metricsEventTarget";
4
4
  import { OperationalMetricsReporter } from "../operationalMetricsReporter";
5
- export declare type BenchmarkComplete = MakeTaggedBusinessEvent<"benchmarkComplete">;
5
+ export type BenchmarkComplete = MakeTaggedBusinessEvent<"benchmarkComplete">;
6
6
  export declare const reportBenchmarks: {
7
7
  (args_0: MetricsEventTarget, args_1: OperationalMetricsReporter, args_2: CameraKitConfiguration): Promise<void>;
8
8
  token: "reportBenchmarks";
@@ -4,7 +4,7 @@ import { OperationalMetricsReporter } from "../operationalMetricsReporter";
4
4
  /**
5
5
  * The LegalPrompt metric reports each time a BIPA legal prompt is shown.
6
6
  */
7
- export declare type LegalPrompt = MakeTaggedBusinessEvent<"legalPrompt">;
7
+ export type LegalPrompt = MakeTaggedBusinessEvent<"legalPrompt">;
8
8
  /**
9
9
  * @internal
10
10
  */
@@ -11,8 +11,8 @@ export declare const isLensOrAssetRequest: (value: Dimensions) => value is Asset
11
11
  * It corresponds to the internal CameraKitLensDownload event, described here:
12
12
  * https://docs.google.com/document/d/1-kSzFWCWw9Qo3D08FR1_cqeHTsUtk9p3p3uOptzWDTY/edit#heading=h.stqom49qs91t
13
13
  */
14
- export declare type LensDownload = MakeTaggedBusinessEvent<"lensDownload">;
15
- export declare type LensDownloadDimensions = {
14
+ export type LensDownload = MakeTaggedBusinessEvent<"lensDownload">;
15
+ export type LensDownloadDimensions = {
16
16
  requestType: "lens_content";
17
17
  lensId: string;
18
18
  };
@@ -24,8 +24,8 @@ export declare type LensDownloadDimensions = {
24
24
  * It corresponds to the internal CameraKitAssetDownload event, described here:
25
25
  * https://docs.google.com/document/d/1-kSzFWCWw9Qo3D08FR1_cqeHTsUtk9p3p3uOptzWDTY/edit#heading=h.vlormd1724fp
26
26
  */
27
- export declare type AssetDownload = MakeTaggedBusinessEvent<"assetDownload">;
28
- export declare type AssetDownloadDimensions = {
27
+ export type AssetDownload = MakeTaggedBusinessEvent<"assetDownload">;
28
+ export type AssetDownloadDimensions = {
29
29
  requestType: "asset";
30
30
  assetType: string;
31
31
  assetId: string;
@@ -3,7 +3,7 @@ import { MetricsEventTarget } from "../metricsEventTarget";
3
3
  /**
4
4
  * The LensContentValidationFailed metric reports every time we handle an lens checksum validation failure.
5
5
  */
6
- export declare type LensContentValidationFailed = MakeTaggedBusinessEvent<"lensContentValidationFailed">;
6
+ export type LensContentValidationFailed = MakeTaggedBusinessEvent<"lensContentValidationFailed">;
7
7
  /**
8
8
  * @internal
9
9
  */
@@ -19,7 +19,7 @@ import { CameraKitConfiguration } from "../../configuration";
19
19
  * @category Lenses
20
20
  * @category Metrics
21
21
  */
22
- export declare type LensView = MakeTaggedBusinessEvent<"lensView">;
22
+ export type LensView = MakeTaggedBusinessEvent<"lensView">;
23
23
  /**
24
24
  * @internal
25
25
  */
@@ -64,7 +64,7 @@ export const reportLensView = Injectable("reportLensView", [
64
64
  var _a;
65
65
  if (viewTimeSec < viewTimeThresholdSec)
66
66
  return;
67
- const { cluster: performanceCluster, webglRendererInfo, } = (_a = (yield configuration.lensPerformance)) !== null && _a !== void 0 ? _a : {
67
+ const { cluster: performanceCluster, webglRendererInfo } = (_a = (yield configuration.lensPerformance)) !== null && _a !== void 0 ? _a : {
68
68
  cluster: 0,
69
69
  webglRendererInfo: "unknown",
70
70
  };