@snap/camera-kit 0.13.2 → 0.14.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 (234) hide show
  1. package/docs/html/assets/search.js +1 -1
  2. package/docs/html/classes/CameraKit.html +4 -3
  3. package/docs/html/classes/CameraKitSession.html +4 -3
  4. package/docs/html/classes/CameraKitSource.html +4 -3
  5. package/docs/html/classes/LensPerformanceMeasurement.html +4 -3
  6. package/docs/html/classes/LensPerformanceMetrics.html +4 -3
  7. package/docs/html/classes/LensRepository.html +6 -5
  8. package/docs/html/classes/LensSources.html +4 -3
  9. package/docs/html/classes/Transform2D.html +4 -3
  10. package/docs/html/classes/TypedCustomEvent.html +4 -3
  11. package/docs/html/classes/TypedEventTarget.html +4 -3
  12. package/docs/html/functions/Injectable.html +4 -3
  13. package/docs/html/functions/bootstrapCameraKit.html +4 -3
  14. package/docs/html/functions/createExtension.html +4 -3
  15. package/docs/html/functions/createImageSource.html +4 -3
  16. package/docs/html/functions/createMediaStreamSource.html +4 -3
  17. package/docs/html/functions/createUserMediaSource.html +4 -3
  18. package/docs/html/functions/createVideoSource.html +4 -3
  19. package/docs/html/functions/estimateLensPerformance.html +4 -3
  20. package/docs/html/functions/getRequiredBootstrapURLs.html +4 -3
  21. package/docs/html/functions/lensSourcesFactory.html +4 -3
  22. package/docs/html/functions/remoteApiServicesFactory.html +4 -3
  23. package/docs/html/index.html +5 -4
  24. package/docs/html/interfaces/CameraKitBootstrapConfiguration.html +16 -5
  25. package/docs/html/interfaces/CameraKitSourceSubscriber.html +5 -4
  26. package/docs/html/interfaces/ComputedFrameMetrics.html +4 -3
  27. package/docs/html/interfaces/CreateSessionOptions.html +4 -3
  28. package/docs/html/interfaces/EstimatedLensPerformance.html +4 -3
  29. package/docs/html/interfaces/Lens.html +13 -3
  30. package/docs/html/interfaces/LensSource.html +4 -3
  31. package/docs/html/interfaces/MediaStreamSourceOptions.html +4 -3
  32. package/docs/html/interfaces/Preview.html +4 -3
  33. package/docs/html/interfaces/RemoteApiRequest.html +4 -3
  34. package/docs/html/interfaces/RemoteApiResponse.html +4 -3
  35. package/docs/html/interfaces/RemoteApiService.html +4 -3
  36. package/docs/html/interfaces/Snapcode.html +4 -3
  37. package/docs/html/interfaces/UriCancelRequest.html +4 -3
  38. package/docs/html/interfaces/UriRequest.html +4 -3
  39. package/docs/html/interfaces/UriResponse.html +4 -3
  40. package/docs/html/interfaces/VideoSourceOptions.html +4 -3
  41. package/docs/html/modules.html +6 -4
  42. package/docs/html/types/AssetLoader.html +4 -3
  43. package/docs/html/types/AssetTiming.html +4 -3
  44. package/docs/html/types/BenchmarkError.html +4 -3
  45. package/docs/html/types/BootstrapError.html +4 -3
  46. package/docs/html/types/CacheKeyNotFoundError.html +4 -3
  47. package/docs/html/types/CameraKitDeviceInfo.html +4 -3
  48. package/docs/html/types/CameraKitDeviceOptions.html +4 -3
  49. package/docs/html/types/CameraKitSessionEventListener.html +4 -3
  50. package/docs/html/types/CameraKitSessionEvents.html +6 -5
  51. package/docs/html/types/CameraKitSourceError.html +4 -3
  52. package/docs/html/types/CameraKitSourceInfo.html +4 -3
  53. package/docs/html/types/CameraKitSourceOptions.html +4 -3
  54. package/docs/html/types/ConfigurationError.html +4 -3
  55. package/docs/html/types/Keyboard.html +4 -3
  56. package/docs/html/types/KeyboardEvents.html +4 -3
  57. package/docs/html/types/LegalError.html +4 -3
  58. package/docs/html/types/LensAbortError.html +119 -0
  59. package/docs/html/types/LensAssetError.html +4 -3
  60. package/docs/html/types/LensContentValidationError.html +4 -3
  61. package/docs/html/types/LensError.html +4 -3
  62. package/docs/html/types/LensExecutionError.html +4 -3
  63. package/docs/html/types/LensImagePickerError.html +4 -3
  64. package/docs/html/types/LensLaunchParams.html +4 -3
  65. package/docs/html/types/LensMetricsEvents.html +4 -3
  66. package/docs/html/types/LensPerformanceCluster.html +4 -3
  67. package/docs/html/types/LensView.html +4 -3
  68. package/docs/html/types/LensWait.html +4 -3
  69. package/docs/html/types/PersistentStoreError.html +4 -3
  70. package/docs/html/types/PlatformNotSupportedError.html +4 -3
  71. package/docs/html/types/PublicContainer.html +4 -3
  72. package/docs/html/types/RemoteApiRequestHandler.html +4 -3
  73. package/docs/html/types/RemoteApiServices.html +4 -3
  74. package/docs/html/types/RemoteApiStatus.html +4 -3
  75. package/docs/html/types/RenderTarget.html +4 -3
  76. package/docs/html/types/Uri.html +4 -3
  77. package/docs/html/types/WebGLError.html +4 -3
  78. package/docs/html/variables/extensionRequestContext.html +4 -3
  79. package/docs/md/classes/CameraKit.md +1 -1
  80. package/docs/md/classes/CameraKitSession.md +1 -1
  81. package/docs/md/classes/CameraKitSource.md +1 -1
  82. package/docs/md/classes/LensPerformanceMeasurement.md +1 -1
  83. package/docs/md/classes/LensPerformanceMetrics.md +1 -1
  84. package/docs/md/classes/LensRepository.md +3 -3
  85. package/docs/md/classes/LensSources.md +1 -1
  86. package/docs/md/classes/Transform2D.md +1 -1
  87. package/docs/md/classes/TypedCustomEvent.md +1 -1
  88. package/docs/md/classes/TypedEventTarget.md +1 -1
  89. package/docs/md/interfaces/CameraKitBootstrapConfiguration.md +13 -2
  90. package/docs/md/interfaces/CameraKitSourceSubscriber.md +3 -3
  91. package/docs/md/interfaces/ComputedFrameMetrics.md +1 -1
  92. package/docs/md/interfaces/CreateSessionOptions.md +1 -1
  93. package/docs/md/interfaces/EstimatedLensPerformance.md +1 -1
  94. package/docs/md/interfaces/Lens.md +11 -1
  95. package/docs/md/interfaces/LensSource.md +1 -1
  96. package/docs/md/interfaces/MediaStreamSourceOptions.md +1 -1
  97. package/docs/md/interfaces/Preview.md +1 -1
  98. package/docs/md/interfaces/RemoteApiRequest.md +1 -1
  99. package/docs/md/interfaces/RemoteApiResponse.md +1 -1
  100. package/docs/md/interfaces/RemoteApiService.md +1 -1
  101. package/docs/md/interfaces/Snapcode.md +1 -1
  102. package/docs/md/interfaces/UriCancelRequest.md +1 -1
  103. package/docs/md/interfaces/UriRequest.md +1 -1
  104. package/docs/md/interfaces/UriResponse.md +1 -1
  105. package/docs/md/interfaces/VideoSourceOptions.md +1 -1
  106. package/docs/md/modules.md +24 -4
  107. package/lib/CameraKit.d.ts +139 -7
  108. package/lib/CameraKit.js +19 -19
  109. package/lib/CameraKit.js.map +1 -1
  110. package/lib/__tests__/data.d.ts +9 -4
  111. package/lib/__tests__/data.js +19 -9
  112. package/lib/__tests__/data.js.map +1 -1
  113. package/lib/bootstrapCameraKit.js +2 -2
  114. package/lib/bootstrapCameraKit.js.map +1 -1
  115. package/lib/common/localization.js +7 -31
  116. package/lib/common/localization.js.map +1 -1
  117. package/lib/configuration.d.ts +7 -0
  118. package/lib/configuration.js +1 -0
  119. package/lib/configuration.js.map +1 -1
  120. package/lib/configurationOverrides.d.ts +2 -2
  121. package/lib/configurationOverrides.js +11 -6
  122. package/lib/configurationOverrides.js.map +1 -1
  123. package/lib/dependency-injection/RootServices.d.ts +2 -2
  124. package/lib/dependency-injection/RootServices.js.map +1 -1
  125. package/lib/environment.json +1 -1
  126. package/lib/extensions/extensionRequestContext.js +4 -4
  127. package/lib/extensions/extensionRequestContext.js.map +1 -1
  128. package/lib/extensions/uriHandlersRegister.d.ts +2 -2
  129. package/lib/extensions/uriHandlersRegister.js.map +1 -1
  130. package/lib/generated-proto/blizzard/cameraKitEvents.d.ts +272 -0
  131. package/lib/generated-proto/blizzard/cameraKitEvents.js +38 -24
  132. package/lib/generated-proto/blizzard/cameraKitEvents.js.map +1 -1
  133. package/lib/handlers/cameraKitServiceFetchHandlerFactory.js +2 -2
  134. package/lib/handlers/cameraKitServiceFetchHandlerFactory.js.map +1 -1
  135. package/lib/index.d.ts +2 -1
  136. package/lib/index.js +2 -1
  137. package/lib/index.js.map +1 -1
  138. package/lib/lens/Lens.d.ts +9 -1
  139. package/lib/lens/Lens.js +2 -1
  140. package/lib/lens/Lens.js.map +1 -1
  141. package/lib/lens/LensPersistenceStore.d.ts +2 -2
  142. package/lib/lens/LensPersistenceStore.js.map +1 -1
  143. package/lib/lens/LensRepository.d.ts +2 -2
  144. package/lib/lens/LensRepository.js +5 -4
  145. package/lib/lens/LensRepository.js.map +1 -1
  146. package/lib/lens/assets/LensAssetRepository.d.ts +4 -4
  147. package/lib/lens/assets/LensAssetRepository.js +1 -3
  148. package/lib/lens/assets/LensAssetRepository.js.map +1 -1
  149. package/lib/lens/assets/LensAssetsProvider.d.ts +9 -3
  150. package/lib/lens/assets/LensAssetsProvider.js +12 -5
  151. package/lib/lens/assets/LensAssetsProvider.js.map +1 -1
  152. package/lib/lens-client-interface/imagePicker.d.ts +2 -2
  153. package/lib/lens-client-interface/imagePicker.js.map +1 -1
  154. package/lib/lens-client-interface/lensClientInterface.d.ts +2 -2
  155. package/lib/lens-client-interface/lensClientInterface.js.map +1 -1
  156. package/lib/lens-core-module/generated-types.d.ts +4 -2
  157. package/lib/lens-core-module/generated-types.js.map +1 -1
  158. package/lib/lens-core-module/index.d.ts +1 -0
  159. package/lib/lens-core-module/index.js +1 -0
  160. package/lib/lens-core-module/index.js.map +1 -1
  161. package/lib/lens-core-module/lensCore.d.ts +41 -0
  162. package/lib/lens-core-module/lensCore.js +54 -0
  163. package/lib/lens-core-module/lensCore.js.map +1 -0
  164. package/lib/lens-core-module/lensCoreError.d.ts +15 -0
  165. package/lib/lens-core-module/lensCoreError.js +43 -0
  166. package/lib/lens-core-module/lensCoreError.js.map +1 -0
  167. package/lib/lens-core-module/loader/lensCoreFactory.d.ts +1 -2
  168. package/lib/lens-core-module/loader/lensCoreFactory.js +24 -26
  169. package/lib/lens-core-module/loader/lensCoreFactory.js.map +1 -1
  170. package/lib/lensCoreWasmVersions.json +3 -3
  171. package/lib/logger/registerLogEntriesSubscriber.js +2 -2
  172. package/lib/logger/registerLogEntriesSubscriber.js.map +1 -1
  173. package/lib/media-sources/CameraKitSource.d.ts +3 -3
  174. package/lib/media-sources/CameraKitSource.js +22 -31
  175. package/lib/media-sources/CameraKitSource.js.map +1 -1
  176. package/lib/media-sources/FunctionSource.js +33 -36
  177. package/lib/media-sources/FunctionSource.js.map +1 -1
  178. package/lib/media-sources/MediaStreamSource.js +11 -15
  179. package/lib/media-sources/MediaStreamSource.js.map +1 -1
  180. package/lib/metrics/businessEventsReporter.js +114 -108
  181. package/lib/metrics/businessEventsReporter.js.map +1 -1
  182. package/lib/metrics/reporters/reportGlobalException.js +25 -7
  183. package/lib/metrics/reporters/reportGlobalException.js.map +1 -1
  184. package/lib/metrics/reporters/reportHttpMetrics.js +2 -2
  185. package/lib/metrics/reporters/reportHttpMetrics.js.map +1 -1
  186. package/lib/metrics/reporters/reportLensView.js +5 -3
  187. package/lib/metrics/reporters/reportLensView.js.map +1 -1
  188. package/lib/metrics/reporters/reportLensWait.js +8 -2
  189. package/lib/metrics/reporters/reportLensWait.js.map +1 -1
  190. package/lib/metrics/reporters/reportPlatformCapabilities.d.ts +12 -0
  191. package/lib/metrics/reporters/reportPlatformCapabilities.js +18 -0
  192. package/lib/metrics/reporters/reportPlatformCapabilities.js.map +1 -0
  193. package/lib/metrics/reporters/reporters.d.ts +2 -1
  194. package/lib/metrics/reporters/reporters.js +3 -1
  195. package/lib/metrics/reporters/reporters.js.map +1 -1
  196. package/lib/namedErrors.d.ts +17 -0
  197. package/lib/namedErrors.js +2 -0
  198. package/lib/namedErrors.js.map +1 -1
  199. package/lib/platform/assertPlatformSupported.d.ts +4 -0
  200. package/lib/platform/assertPlatformSupported.js +15 -0
  201. package/lib/platform/assertPlatformSupported.js.map +1 -0
  202. package/lib/platform/cameraKitUserAgent.d.ts +2 -0
  203. package/lib/platform/cameraKitUserAgent.js +20 -0
  204. package/lib/platform/cameraKitUserAgent.js.map +1 -0
  205. package/lib/platform/platformCapabilities.d.ts +50 -0
  206. package/lib/platform/platformCapabilities.js +121 -0
  207. package/lib/platform/platformCapabilities.js.map +1 -0
  208. package/lib/{common/cameraKitUserAgent.d.ts → platform/platformInfo.d.ts} +13 -10
  209. package/lib/{common/cameraKitUserAgent.js → platform/platformInfo.js} +94 -100
  210. package/lib/platform/platformInfo.js.map +1 -0
  211. package/lib/remote-configuration/cofHandler.js +2 -2
  212. package/lib/remote-configuration/cofHandler.js.map +1 -1
  213. package/lib/remote-configuration/preloadConfiguration.d.ts +2 -2
  214. package/lib/remote-configuration/preloadConfiguration.js.map +1 -1
  215. package/lib/session/CameraKitSession.d.ts +3 -3
  216. package/lib/session/CameraKitSession.js +23 -30
  217. package/lib/session/CameraKitSession.js.map +1 -1
  218. package/lib/session/CameraKitSessionEvents.d.ts +7 -3
  219. package/lib/session/CameraKitSessionEvents.js +17 -0
  220. package/lib/session/CameraKitSessionEvents.js.map +1 -1
  221. package/lib/session/LensPerformanceMetrics.d.ts +2 -2
  222. package/lib/session/LensPerformanceMetrics.js +4 -3
  223. package/lib/session/LensPerformanceMetrics.js.map +1 -1
  224. package/lib/session/lensState.d.ts +2 -2
  225. package/lib/session/lensState.js +36 -37
  226. package/lib/session/lensState.js.map +1 -1
  227. package/package.json +2 -2
  228. package/lib/assertPlatformSupported.d.ts +0 -6
  229. package/lib/assertPlatformSupported.js +0 -21
  230. package/lib/assertPlatformSupported.js.map +0 -1
  231. package/lib/common/cameraKitUserAgent.js.map +0 -1
  232. package/lib/common/locale.d.ts +0 -2
  233. package/lib/common/locale.js +0 -11
  234. package/lib/common/locale.js.map +0 -1
@@ -6,6 +6,7 @@ interface CameraKitRuntimeConfiguration {
6
6
  logLevel: LogLevelName;
7
7
  shouldUseWorker: boolean;
8
8
  apiHostname: CameraKitApiHostname;
9
+ userAgentFlavor: "release" | "debug";
9
10
  }
10
11
  export type CameraKitApiHostname = "camera-kit-api.snapar.com" | "api-kit.snapchat.com";
11
12
  /**
@@ -75,6 +76,12 @@ export interface CameraKitBootstrapConfiguration {
75
76
  * based on this root endpoint.
76
77
  */
77
78
  wasmEndpointOverride?: string;
79
+ /**
80
+ * Applications may optionally provide a unique identifier called analyticsId. This ID would enable Camera Kit to
81
+ * improve data reporting and accuracy and to better support potential needs related to an application's lens and
82
+ * user analytics.
83
+ */
84
+ analyticsId?: string;
78
85
  }
79
86
  /**
80
87
  * This type represents the result of merging user-supplied config with default config -- as such, it has no nullable
@@ -14,6 +14,7 @@ const defaultConfiguration = {
14
14
  logLevel: "info",
15
15
  shouldUseWorker: true,
16
16
  apiHostname: "camera-kit-api.snapar.com",
17
+ userAgentFlavor: "release",
17
18
  };
18
19
  /** @internal */
19
20
  export const configurationToken = "configuration";
@@ -1 +1 @@
1
- {"version":3,"file":"configuration.js","sourceRoot":"","sources":["../src/configuration.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAU/D;;;GAGG;AACH,MAAM,oBAAoB,GAAmF;IACzG,mHAAmH;IACnH,6GAA6G;IAC7G,qFAAqF;IACrF,eAAe,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,iBAAiB,EAAE,SAAS,EAAE;IAC7E,MAAM,EAAE,MAAM;IACd,QAAQ,EAAE,MAAM;IAChB,eAAe,EAAE,IAAI;IACrB,WAAW,EAAE,2BAA2B;CAC3C,CAAC;AA2FF,gBAAgB;AAChB,MAAM,CAAC,MAAM,kBAAkB,GAAG,eAAe,CAAC;AAElD,gBAAgB;AAChB,MAAM,CAAC,MAAM,mCAAmC,GAAG,CAAC,aAA8C,EAAE,EAAE;IAClG,6DAA6D;IAC7D,MAAM,SAAS,GAAG,yBAAyB,EAAE,CAAC;IAC9C,IAAI,SAAS,EAAE;QACX,OAAO,CAAC,IAAI,CAAC,iCAAiC,EAAE,SAAS,CAAC,CAAC;KAC9D;IACD,OAAO,UAAU,CAAC,kBAAkB,EAAE,GAA2B,EAAE;QAC/D,uGAAuG;QACvG,kFAAkF;QAClF,MAAM,UAAU,mCACT,aAAa,KAChB,eAAe,EACX,aAAa,CAAC,eAAe,YAAY,OAAO;gBAC5C,CAAC,CAAC,kFAAkF;oBAClF,aAAa,CAAC,eAAe,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,oBAAoB,CAAC,eAAgB,CAAC;gBAClF,CAAC,CAAC,aAAa,CAAC,eAAe,GAC1C,CAAC;QACF,qDACO,oBAAoB,GACpB,qBAAqB,CAAC,UAAU,CAAC,GACjC,qBAAqB,CAAC,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,EAAE,CAAC,EAC3C;IACN,CAAC,CAAC,CAAC;AACP,CAAC,CAAC","sourcesContent":["import { EstimatedLensPerformance } from \"./benchmark/estimateLensPerformanceCluster\";\nimport { copyDefinedProperties } from \"./common/copyDefinedProperties\";\nimport { getConfigurationOverrides } from \"./configurationOverrides\";\nimport { Injectable } from \"./dependency-injection/Injectable\";\nimport { LogLevelName } from \"./logger/logger\";\n\n/**\n * From T, pick the set of properties whose values are optional. Create a new type containing only those properties.\n */\ntype PickOptionals<T> = {\n [K in keyof T as T[K] extends Exclude<T[K], undefined> ? never : K]: T[K];\n};\n\n/**\n * Defaults are provided for runtime configuration and any optional bootstrap configuration properties which require\n * defaults.\n */\nconst defaultConfiguration: CameraKitRuntimeConfiguration & PickOptionals<CameraKitBootstrapConfiguration> = {\n // If the applications doesn't provide performance data (e.g. via estimateLensPerformance), we'll use 0 to indicate\n // no performance estimation occurred. This is indicative of typical performance-targeting logic, which often\n // defaults to the lowest-tier experience in the absense of performance cluster data.\n lensPerformance: { cluster: 0, benchmarks: [], webglRendererInfo: \"unknown\" },\n logger: \"noop\",\n logLevel: \"info\",\n shouldUseWorker: true,\n apiHostname: \"camera-kit-api.snapar.com\",\n};\n\ninterface CameraKitRuntimeConfiguration {\n lensPerformance: EstimatedLensPerformance | Promise<EstimatedLensPerformance>;\n logger: \"noop\" | \"console\";\n logLevel: LogLevelName;\n shouldUseWorker: boolean;\n apiHostname: CameraKitApiHostname;\n}\n\nexport type CameraKitApiHostname = \"camera-kit-api.snapar.com\" | \"api-kit.snapchat.com\";\n\n/**\n * Configuration which must be provided when calling {@link bootstrapCameraKit}. These values are used to create various\n * CameraKit components.\n *\n * @category Bootstrapping and Configuration\n */\nexport interface CameraKitBootstrapConfiguration {\n /**\n * Long-lived token granting your application access to CameraKit APIs. This is found in the SnapKit Dev Portal,\n * where it's called the API Token.\n */\n apiToken: string;\n\n /**\n * Determine where to print CameraKit log messages. By default no logs will be printed.\n *\n * CameraKit emits log messages to help diagnose and root cause issues that may occur during the development of a\n * host application. The printing of these can be controlled via the following\n * options:\n * - `noop`: log messages are ignored.\n * - `console`: log messages are printed to console.\n */\n logger?: \"noop\" | \"console\";\n\n /**\n * Log only if a logged entry level is greater than or equal to this level. Here is the order of levels:\n * error > warn > log = info > debug. Default value is \"info\".\n */\n logLevel?: LogLevelName;\n\n /**\n * Some lenses may decide to modify their behavior based on the performance of the current environment. If you are\n * using such lenses, providing an estimation of lens performance may lead to better user experience (especially on\n * low-performance devices).\n *\n * Running the {@link estimateLensPerformance} function will run benchmarks and estimate an appropriate lens\n * performance cluster (i.e. a performance rating) based on the current environment.\n *\n * Lower cluster = worse expected performance capability.\n *\n * @example\n * ```ts\n * import { bootstrapCameraKit, estimateLensPerformance } from '@snap/camera-kit`\n *\n * const cameraKit = await bootstrapCameraKit({\n * apiToken: '...',\n * lensPerformance: estimateLensPerformance(),\n * })\n * ```\n */\n lensPerformance?: EstimatedLensPerformance | Promise<EstimatedLensPerformance>;\n\n /**\n * In recommended production deployments, the WebAssembly assets required by CameraKit will be downloaded from an\n * optimized CDN. But sometimes (e.g. during development or within a CI pipeline), it may be necessary to download\n * these assets from somewhere else.\n *\n * This configuration option allows the application to specify URLs to be used for both the WebAssembly and JS glue\n * file that are used to run and interact with CameraKit's rendering engine.\n */\n lensCoreOverrideUrls?: { wasm: string; js: string };\n\n /**\n * In recommended production deployments, the WebAssembly assets required by CameraKit will be downloaded from an\n * optimized CDN. But sometimes during development or within a CI pipeline, it may be necessary to download these\n * assets from somewhere else. With a provided `wasmEndpointOverride`, asset URLs will be automatically generated\n * based on this root endpoint.\n */\n wasmEndpointOverride?: string;\n}\n\n/**\n * This type represents the result of merging user-supplied config with default config -- as such, it has no nullable\n * fields, making it a more convenient type for other components to use.\n *\n * @internal\n */\nexport type CameraKitConfiguration = CameraKitRuntimeConfiguration & CameraKitBootstrapConfiguration;\n\n/** @internal */\nexport const configurationToken = \"configuration\";\n\n/** @internal */\nexport const createCameraKitConfigurationFactory = (configuration: CameraKitBootstrapConfiguration) => {\n // always leave debug mode warning about overrides in console\n const overrides = getConfigurationOverrides();\n if (overrides) {\n console.warn(\"Configuration overrides applied\", overrides);\n }\n return Injectable(configurationToken, (): CameraKitConfiguration => {\n // We'll ensure that we handle errors on any Promises passed as config values, otherwise we either must\n // handle them separately wherever they're used, or rejections would go unhandled.\n const safeConfig: CameraKitBootstrapConfiguration = {\n ...configuration,\n lensPerformance:\n configuration.lensPerformance instanceof Promise\n ? // Safety: defaultConfiguration.lensPerformance is defined (it's hardcoded above).\n configuration.lensPerformance.catch(() => defaultConfiguration.lensPerformance!)\n : configuration.lensPerformance,\n };\n return {\n ...defaultConfiguration,\n ...copyDefinedProperties(safeConfig),\n ...copyDefinedProperties(overrides ?? {}),\n };\n });\n};\n"]}
1
+ {"version":3,"file":"configuration.js","sourceRoot":"","sources":["../src/configuration.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAU/D;;;GAGG;AACH,MAAM,oBAAoB,GAAmF;IACzG,mHAAmH;IACnH,6GAA6G;IAC7G,qFAAqF;IACrF,eAAe,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,iBAAiB,EAAE,SAAS,EAAE;IAC7E,MAAM,EAAE,MAAM;IACd,QAAQ,EAAE,MAAM;IAChB,eAAe,EAAE,IAAI;IACrB,WAAW,EAAE,2BAA2B;IACxC,eAAe,EAAE,SAAS;CAC7B,CAAC;AAmGF,gBAAgB;AAChB,MAAM,CAAC,MAAM,kBAAkB,GAAG,eAAe,CAAC;AAElD,gBAAgB;AAChB,MAAM,CAAC,MAAM,mCAAmC,GAAG,CAAC,aAA8C,EAAE,EAAE;IAClG,6DAA6D;IAC7D,MAAM,SAAS,GAAG,yBAAyB,EAAE,CAAC;IAC9C,IAAI,SAAS,EAAE;QACX,OAAO,CAAC,IAAI,CAAC,iCAAiC,EAAE,SAAS,CAAC,CAAC;KAC9D;IACD,OAAO,UAAU,CAAC,kBAAkB,EAAE,GAA2B,EAAE;QAC/D,uGAAuG;QACvG,kFAAkF;QAClF,MAAM,UAAU,mCACT,aAAa,KAChB,eAAe,EACX,aAAa,CAAC,eAAe,YAAY,OAAO;gBAC5C,CAAC,CAAC,kFAAkF;oBAClF,aAAa,CAAC,eAAe,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,oBAAoB,CAAC,eAAgB,CAAC;gBAClF,CAAC,CAAC,aAAa,CAAC,eAAe,GAC1C,CAAC;QACF,qDACO,oBAAoB,GACpB,qBAAqB,CAAC,UAAU,CAAC,GACjC,qBAAqB,CAAC,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,EAAE,CAAC,EAC3C;IACN,CAAC,CAAC,CAAC;AACP,CAAC,CAAC","sourcesContent":["import { EstimatedLensPerformance } from \"./benchmark/estimateLensPerformanceCluster\";\nimport { copyDefinedProperties } from \"./common/copyDefinedProperties\";\nimport { getConfigurationOverrides } from \"./configurationOverrides\";\nimport { Injectable } from \"./dependency-injection/Injectable\";\nimport { LogLevelName } from \"./logger/logger\";\n\n/**\n * From T, pick the set of properties whose values are optional. Create a new type containing only those properties.\n */\ntype PickOptionals<T> = {\n [K in keyof T as T[K] extends Exclude<T[K], undefined> ? never : K]: T[K];\n};\n\n/**\n * Defaults are provided for runtime configuration and any optional bootstrap configuration properties which require\n * defaults.\n */\nconst defaultConfiguration: CameraKitRuntimeConfiguration & PickOptionals<CameraKitBootstrapConfiguration> = {\n // If the applications doesn't provide performance data (e.g. via estimateLensPerformance), we'll use 0 to indicate\n // no performance estimation occurred. This is indicative of typical performance-targeting logic, which often\n // defaults to the lowest-tier experience in the absense of performance cluster data.\n lensPerformance: { cluster: 0, benchmarks: [], webglRendererInfo: \"unknown\" },\n logger: \"noop\",\n logLevel: \"info\",\n shouldUseWorker: true,\n apiHostname: \"camera-kit-api.snapar.com\",\n userAgentFlavor: \"release\",\n};\n\ninterface CameraKitRuntimeConfiguration {\n lensPerformance: EstimatedLensPerformance | Promise<EstimatedLensPerformance>;\n logger: \"noop\" | \"console\";\n logLevel: LogLevelName;\n shouldUseWorker: boolean;\n apiHostname: CameraKitApiHostname;\n userAgentFlavor: \"release\" | \"debug\";\n}\n\nexport type CameraKitApiHostname = \"camera-kit-api.snapar.com\" | \"api-kit.snapchat.com\";\n\n/**\n * Configuration which must be provided when calling {@link bootstrapCameraKit}. These values are used to create various\n * CameraKit components.\n *\n * @category Bootstrapping and Configuration\n */\nexport interface CameraKitBootstrapConfiguration {\n /**\n * Long-lived token granting your application access to CameraKit APIs. This is found in the SnapKit Dev Portal,\n * where it's called the API Token.\n */\n apiToken: string;\n\n /**\n * Determine where to print CameraKit log messages. By default no logs will be printed.\n *\n * CameraKit emits log messages to help diagnose and root cause issues that may occur during the development of a\n * host application. The printing of these can be controlled via the following\n * options:\n * - `noop`: log messages are ignored.\n * - `console`: log messages are printed to console.\n */\n logger?: \"noop\" | \"console\";\n\n /**\n * Log only if a logged entry level is greater than or equal to this level. Here is the order of levels:\n * error > warn > log = info > debug. Default value is \"info\".\n */\n logLevel?: LogLevelName;\n\n /**\n * Some lenses may decide to modify their behavior based on the performance of the current environment. If you are\n * using such lenses, providing an estimation of lens performance may lead to better user experience (especially on\n * low-performance devices).\n *\n * Running the {@link estimateLensPerformance} function will run benchmarks and estimate an appropriate lens\n * performance cluster (i.e. a performance rating) based on the current environment.\n *\n * Lower cluster = worse expected performance capability.\n *\n * @example\n * ```ts\n * import { bootstrapCameraKit, estimateLensPerformance } from '@snap/camera-kit`\n *\n * const cameraKit = await bootstrapCameraKit({\n * apiToken: '...',\n * lensPerformance: estimateLensPerformance(),\n * })\n * ```\n */\n lensPerformance?: EstimatedLensPerformance | Promise<EstimatedLensPerformance>;\n\n /**\n * In recommended production deployments, the WebAssembly assets required by CameraKit will be downloaded from an\n * optimized CDN. But sometimes (e.g. during development or within a CI pipeline), it may be necessary to download\n * these assets from somewhere else.\n *\n * This configuration option allows the application to specify URLs to be used for both the WebAssembly and JS glue\n * file that are used to run and interact with CameraKit's rendering engine.\n */\n lensCoreOverrideUrls?: { wasm: string; js: string };\n\n /**\n * In recommended production deployments, the WebAssembly assets required by CameraKit will be downloaded from an\n * optimized CDN. But sometimes during development or within a CI pipeline, it may be necessary to download these\n * assets from somewhere else. With a provided `wasmEndpointOverride`, asset URLs will be automatically generated\n * based on this root endpoint.\n */\n wasmEndpointOverride?: string;\n\n /**\n * Applications may optionally provide a unique identifier called analyticsId. This ID would enable Camera Kit to\n * improve data reporting and accuracy and to better support potential needs related to an application's lens and\n * user analytics.\n */\n analyticsId?: string;\n}\n\n/**\n * This type represents the result of merging user-supplied config with default config -- as such, it has no nullable\n * fields, making it a more convenient type for other components to use.\n *\n * @internal\n */\nexport type CameraKitConfiguration = CameraKitRuntimeConfiguration & CameraKitBootstrapConfiguration;\n\n/** @internal */\nexport const configurationToken = \"configuration\";\n\n/** @internal */\nexport const createCameraKitConfigurationFactory = (configuration: CameraKitBootstrapConfiguration) => {\n // always leave debug mode warning about overrides in console\n const overrides = getConfigurationOverrides();\n if (overrides) {\n console.warn(\"Configuration overrides applied\", overrides);\n }\n return Injectable(configurationToken, (): CameraKitConfiguration => {\n // We'll ensure that we handle errors on any Promises passed as config values, otherwise we either must\n // handle them separately wherever they're used, or rejections would go unhandled.\n const safeConfig: CameraKitBootstrapConfiguration = {\n ...configuration,\n lensPerformance:\n configuration.lensPerformance instanceof Promise\n ? // Safety: defaultConfiguration.lensPerformance is defined (it's hardcoded above).\n configuration.lensPerformance.catch(() => defaultConfiguration.lensPerformance!)\n : configuration.lensPerformance,\n };\n return {\n ...defaultConfiguration,\n ...copyDefinedProperties(safeConfig),\n ...copyDefinedProperties(overrides ?? {}),\n };\n });\n};\n"]}
@@ -1,8 +1,8 @@
1
- import { CameraKitBootstrapConfiguration } from "./configuration";
1
+ import { CameraKitConfiguration } from "./configuration";
2
2
  /**
3
3
  * Configuration overrides that are stored in session storage.
4
4
  */
5
- type StoredOverrides = Pick<CameraKitBootstrapConfiguration, "wasmEndpointOverride" | "logger" | "logLevel">;
5
+ type StoredOverrides = Pick<CameraKitConfiguration, "wasmEndpointOverride" | "logger" | "logLevel" | "userAgentFlavor">;
6
6
  /**
7
7
  * Checks whether there are configuration overrides stored, and if yes, returns them.
8
8
  *
@@ -2,7 +2,12 @@
2
2
  * Prefix of override key on window object.
3
3
  */
4
4
  const windowFieldPrefix = "__snap_camkit_override__";
5
- const configPropertiesToOverride = ["wasmEndpointOverride", "logger", "logLevel"];
5
+ const configPropertiesToOverride = [
6
+ "wasmEndpointOverride",
7
+ "logger",
8
+ "logLevel",
9
+ "userAgentFlavor",
10
+ ];
6
11
  configPropertiesToOverride.forEach((fieldToOverride) => {
7
12
  defineWindowField(fieldToOverride);
8
13
  });
@@ -15,14 +20,12 @@ function defineWindowField(propertyToOverride) {
15
20
  return (_a = getConfigurationOverrides()) === null || _a === void 0 ? void 0 : _a[propertyToOverride];
16
21
  },
17
22
  set(value) {
18
- var _a;
19
- const storedOverrdies = (_a = getConfigurationOverrides()) !== null && _a !== void 0 ? _a : {};
20
- storedOverrdies[propertyToOverride] = value;
21
- if (Object.values(storedOverrdies).every((value) => typeof value === "undefined")) {
23
+ const storedOverrides = Object.assign(Object.assign({}, getConfigurationOverrides()), { [propertyToOverride]: value });
24
+ if (Object.values(storedOverrides).every((value) => typeof value === "undefined")) {
22
25
  sessionStorage.removeItem(windowFieldPrefix);
23
26
  }
24
27
  else {
25
- sessionStorage.setItem(windowFieldPrefix, JSON.stringify(storedOverrdies));
28
+ sessionStorage.setItem(windowFieldPrefix, JSON.stringify(storedOverrides));
26
29
  }
27
30
  },
28
31
  enumerable: false,
@@ -35,6 +38,8 @@ function defineWindowField(propertyToOverride) {
35
38
  * @internal
36
39
  */
37
40
  export function getConfigurationOverrides() {
41
+ if (!sessionStorage)
42
+ return undefined;
38
43
  const overridesString = sessionStorage.getItem(windowFieldPrefix);
39
44
  return overridesString && JSON.parse(overridesString);
40
45
  }
@@ -1 +1 @@
1
- {"version":3,"file":"configurationOverrides.js","sourceRoot":"","sources":["../src/configurationOverrides.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,iBAAiB,GAAG,0BAA0B,CAAC;AAOrD,MAAM,0BAA0B,GAAiC,CAAC,sBAAsB,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;AAEhH,0BAA0B,CAAC,OAAO,CAAC,CAAC,eAAe,EAAE,EAAE;IACnD,iBAAiB,CAAC,eAAe,CAAC,CAAC;AACvC,CAAC,CAAC,CAAC;AAEH,SAAS,iBAAiB,CAAC,kBAAyC;IAChE,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAO;IAE1C,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,iBAAiB,GAAG,kBAAkB,EAAE,EAAE;QACvE,GAAG;;YACC,OAAO,MAAA,yBAAyB,EAAE,0CAAG,kBAAkB,CAAC,CAAC;QAC7D,CAAC;QACD,GAAG,CAAC,KAAU;;YACV,MAAM,eAAe,GAAG,MAAA,yBAAyB,EAAE,mCAAI,EAAE,CAAC;YAC1D,eAAe,CAAC,kBAAkB,CAAC,GAAG,KAAK,CAAC;YAC5C,IAAI,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,KAAK,KAAK,WAAW,CAAC,EAAE;gBAC/E,cAAc,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC;aAChD;iBAAM;gBACH,cAAc,CAAC,OAAO,CAAC,iBAAiB,EAAE,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC,CAAC;aAC9E;QACL,CAAC;QACD,UAAU,EAAE,KAAK;QACjB,YAAY,EAAE,IAAI;KACrB,CAAC,CAAC;AACP,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,yBAAyB;IACrC,MAAM,eAAe,GAAG,cAAc,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAClE,OAAO,eAAe,IAAI,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;AAC1D,CAAC","sourcesContent":["import { CameraKitBootstrapConfiguration } from \"./configuration\";\n\n/**\n * Prefix of override key on window object.\n */\nconst windowFieldPrefix = \"__snap_camkit_override__\";\n\n/**\n * Configuration overrides that are stored in session storage.\n */\ntype StoredOverrides = Pick<CameraKitBootstrapConfiguration, \"wasmEndpointOverride\" | \"logger\" | \"logLevel\">;\n\nconst configPropertiesToOverride: Array<keyof StoredOverrides> = [\"wasmEndpointOverride\", \"logger\", \"logLevel\"];\n\nconfigPropertiesToOverride.forEach((fieldToOverride) => {\n defineWindowField(fieldToOverride);\n});\n\nfunction defineWindowField(propertyToOverride: keyof StoredOverrides) {\n if (typeof window === \"undefined\") return;\n\n Object.defineProperty(window, `${windowFieldPrefix}${propertyToOverride}`, {\n get() {\n return getConfigurationOverrides()?.[propertyToOverride];\n },\n set(value: any) {\n const storedOverrdies = getConfigurationOverrides() ?? {};\n storedOverrdies[propertyToOverride] = value;\n if (Object.values(storedOverrdies).every((value) => typeof value === \"undefined\")) {\n sessionStorage.removeItem(windowFieldPrefix);\n } else {\n sessionStorage.setItem(windowFieldPrefix, JSON.stringify(storedOverrdies));\n }\n },\n enumerable: false,\n configurable: true,\n });\n}\n\n/**\n * Checks whether there are configuration overrides stored, and if yes, returns them.\n *\n * @internal\n */\nexport function getConfigurationOverrides(): StoredOverrides | undefined {\n const overridesString = sessionStorage.getItem(windowFieldPrefix);\n return overridesString && JSON.parse(overridesString);\n}\n"]}
1
+ {"version":3,"file":"configurationOverrides.js","sourceRoot":"","sources":["../src/configurationOverrides.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,iBAAiB,GAAG,0BAA0B,CAAC;AAOrD,MAAM,0BAA0B,GAAiC;IAC7D,sBAAsB;IACtB,QAAQ;IACR,UAAU;IACV,iBAAiB;CACpB,CAAC;AAEF,0BAA0B,CAAC,OAAO,CAAC,CAAC,eAAe,EAAE,EAAE;IACnD,iBAAiB,CAAC,eAAe,CAAC,CAAC;AACvC,CAAC,CAAC,CAAC;AAEH,SAAS,iBAAiB,CAAC,kBAAyC;IAChE,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAO;IAE1C,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,iBAAiB,GAAG,kBAAkB,EAAE,EAAE;QACvE,GAAG;;YACC,OAAO,MAAA,yBAAyB,EAAE,0CAAG,kBAAkB,CAAC,CAAC;QAC7D,CAAC;QACD,GAAG,CAAC,KAAU;YACV,MAAM,eAAe,mCAAQ,yBAAyB,EAAE,KAAE,CAAC,kBAAkB,CAAC,EAAE,KAAK,GAAE,CAAC;YACxF,IAAI,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,KAAK,KAAK,WAAW,CAAC,EAAE;gBAC/E,cAAc,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC;aAChD;iBAAM;gBACH,cAAc,CAAC,OAAO,CAAC,iBAAiB,EAAE,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC,CAAC;aAC9E;QACL,CAAC;QACD,UAAU,EAAE,KAAK;QACjB,YAAY,EAAE,IAAI;KACrB,CAAC,CAAC;AACP,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,yBAAyB;IACrC,IAAI,CAAC,cAAc;QAAE,OAAO,SAAS,CAAC;IACtC,MAAM,eAAe,GAAG,cAAc,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAClE,OAAO,eAAe,IAAI,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;AAC1D,CAAC","sourcesContent":["import { CameraKitConfiguration } from \"./configuration\";\n\n/**\n * Prefix of override key on window object.\n */\nconst windowFieldPrefix = \"__snap_camkit_override__\";\n\n/**\n * Configuration overrides that are stored in session storage.\n */\ntype StoredOverrides = Pick<CameraKitConfiguration, \"wasmEndpointOverride\" | \"logger\" | \"logLevel\" | \"userAgentFlavor\">;\n\nconst configPropertiesToOverride: Array<keyof StoredOverrides> = [\n \"wasmEndpointOverride\",\n \"logger\",\n \"logLevel\",\n \"userAgentFlavor\",\n];\n\nconfigPropertiesToOverride.forEach((fieldToOverride) => {\n defineWindowField(fieldToOverride);\n});\n\nfunction defineWindowField(propertyToOverride: keyof StoredOverrides) {\n if (typeof window === \"undefined\") return;\n\n Object.defineProperty(window, `${windowFieldPrefix}${propertyToOverride}`, {\n get() {\n return getConfigurationOverrides()?.[propertyToOverride];\n },\n set(value: any) {\n const storedOverrides = { ...getConfigurationOverrides(), [propertyToOverride]: value };\n if (Object.values(storedOverrides).every((value) => typeof value === \"undefined\")) {\n sessionStorage.removeItem(windowFieldPrefix);\n } else {\n sessionStorage.setItem(windowFieldPrefix, JSON.stringify(storedOverrides));\n }\n },\n enumerable: false,\n configurable: true,\n });\n}\n\n/**\n * Checks whether there are configuration overrides stored, and if yes, returns them.\n *\n * @internal\n */\nexport function getConfigurationOverrides(): StoredOverrides | undefined {\n if (!sessionStorage) return undefined;\n const overridesString = sessionStorage.getItem(windowFieldPrefix);\n return overridesString && JSON.parse(overridesString);\n}\n"]}
@@ -6,7 +6,7 @@ import { staticAssetLoaderFactory } from "../lens/assets/staticAssetLoader";
6
6
  import { defaultFetchHandlerFactory } from "../handlers/defaultFetchHandler";
7
7
  import { cameraKitServiceFetchHandlerFactory } from "../handlers/cameraKitServiceFetchHandlerFactory";
8
8
  import { createCameraKitConfigurationFactory } from "../configuration";
9
- import { LensCoreModule } from "../lens-core-module/generated-types";
9
+ import { LensCore } from "../lens-core-module/lensCore";
10
10
  import { metricsEventTargetFactory } from "../metrics/metricsEventTarget";
11
11
  import { metricsHandlerFactory } from "../metrics/metricsHandler";
12
12
  import { operationalMetricReporterFactory } from "../metrics/operational/operationalMetricsReporter";
@@ -49,7 +49,7 @@ export type PublicServices = ServicesFromInjectables<[
49
49
  * `bootstrapCameraKit` API to applications.
50
50
  */
51
51
  export type RootServices = {
52
- [lensCoreFactory.token]: LensCoreModule;
52
+ [lensCoreFactory.token]: LensCore;
53
53
  } & PublicServices & ServicesFromInjectables<[
54
54
  typeof metricsEventTargetFactory,
55
55
  typeof requestStateEventTargetFactory,
@@ -1 +1 @@
1
- {"version":3,"file":"RootServices.js","sourceRoot":"","sources":["../../src/dependency-injection/RootServices.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,4CAA4C,CAAC","sourcesContent":["import { lensRepositoryFactory } from \"../lens/LensRepository\";\nimport { lensCoreFactory } from \"../lens-core-module/loader/lensCoreFactory\";\nimport { remoteMediaAssetLoaderFactory } from \"../lens/assets/remoteMediaAssetLoaderFactory\";\nimport { deviceDependentAssetLoaderFactory } from \"../lens/assets/deviceDependentAssetLoader\";\nimport { staticAssetLoaderFactory } from \"../lens/assets/staticAssetLoader\";\nimport { defaultFetchHandlerFactory } from \"../handlers/defaultFetchHandler\";\nimport { cameraKitServiceFetchHandlerFactory } from \"../handlers/cameraKitServiceFetchHandlerFactory\";\nimport { createCameraKitConfigurationFactory } from \"../configuration\";\nimport { LensCoreModule } from \"../lens-core-module/generated-types\";\nimport { metricsEventTargetFactory } from \"../metrics/metricsEventTarget\";\nimport { metricsHandlerFactory } from \"../metrics/metricsHandler\";\nimport { operationalMetricReporterFactory } from \"../metrics/operational/operationalMetricsReporter\";\nimport { lensSourcesFactory } from \"../extensions/LensSources\";\nimport { uriHandlersFactory } from \"../extensions/UriHandlers\";\nimport { lensPersistenceStoreFactory } from \"../lens/LensPersistenceStore\";\nimport { cofHandlerFactory } from \"../remote-configuration/cofHandler\";\nimport { remoteConfigurationFactory } from \"../remote-configuration/remoteConfiguration\";\nimport { lensAssetRepositoryFactory } from \"../lens/assets/LensAssetRepository\";\nimport { legalStateFactory } from \"../legal/legalState\";\nimport { legalPromptFactory } from \"../legal/legalPrompt\";\nimport { logEntriesFactory } from \"../logger/logEntries\";\nimport { reportGlobalException } from \"../metrics/reporters/reportGlobalException\";\nimport { requestStateEventTargetFactory } from \"../handlers/requestStateEmittingHandler\";\nimport { pageVisibilityFactory } from \"../common/pageVisibility\";\nimport { remoteApiServicesFactory } from \"../extensions/RemoteApiServices\";\nimport { ServicesFromInjectables } from \"./types\";\n\n/**\n * All services available to be customized by client app.\n */\nexport type PublicServices = ServicesFromInjectables<\n [\n ReturnType<typeof createCameraKitConfigurationFactory>,\n typeof pageVisibilityFactory,\n typeof defaultFetchHandlerFactory,\n typeof remoteMediaAssetLoaderFactory,\n typeof lensSourcesFactory,\n typeof remoteApiServicesFactory,\n typeof uriHandlersFactory\n ]\n>;\n\n/**\n * Define all the Services contained in CameraKit's root dependency injection container.\n *\n * Note: we do end up defining this list of Services twice (once here to create the type, once when we actually\n * create the Container inside the `bootstrapCameraKit` function). We could avoid doing this and just infer the\n * RootContainer type from the constructed container – but since we can only do that *inside* `bootstrapCameraKit`, it\n * makes it more awkward to provide a type for the `provide` user-supplied function (or use the type elsewhere, like in\n * CameraKitSession).\n *\n * There may be a way to eliminate this extra boilerplate, but for now it's required in order to present a cleaner\n * `bootstrapCameraKit` API to applications.\n */\nexport type RootServices = {\n // bootstrapCameraKit replaces the lensCoreFactory token's value with the resolved LensCoreModule (rather than the\n // Promise of the LensCoreModule), so we need to do the same re-mapping here.\n [lensCoreFactory.token]: LensCoreModule;\n} & PublicServices &\n ServicesFromInjectables<\n [\n typeof metricsEventTargetFactory,\n typeof requestStateEventTargetFactory,\n typeof cameraKitServiceFetchHandlerFactory,\n typeof cofHandlerFactory,\n typeof remoteConfigurationFactory,\n typeof lensRepositoryFactory,\n typeof lensPersistenceStoreFactory,\n typeof metricsHandlerFactory,\n typeof operationalMetricReporterFactory,\n typeof lensAssetRepositoryFactory,\n typeof deviceDependentAssetLoaderFactory,\n typeof staticAssetLoaderFactory,\n typeof legalStateFactory,\n typeof legalPromptFactory,\n typeof logEntriesFactory,\n typeof reportGlobalException\n ]\n >;\n"]}
1
+ {"version":3,"file":"RootServices.js","sourceRoot":"","sources":["../../src/dependency-injection/RootServices.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,4CAA4C,CAAC","sourcesContent":["import { lensRepositoryFactory } from \"../lens/LensRepository\";\nimport { lensCoreFactory } from \"../lens-core-module/loader/lensCoreFactory\";\nimport { remoteMediaAssetLoaderFactory } from \"../lens/assets/remoteMediaAssetLoaderFactory\";\nimport { deviceDependentAssetLoaderFactory } from \"../lens/assets/deviceDependentAssetLoader\";\nimport { staticAssetLoaderFactory } from \"../lens/assets/staticAssetLoader\";\nimport { defaultFetchHandlerFactory } from \"../handlers/defaultFetchHandler\";\nimport { cameraKitServiceFetchHandlerFactory } from \"../handlers/cameraKitServiceFetchHandlerFactory\";\nimport { createCameraKitConfigurationFactory } from \"../configuration\";\nimport { LensCore } from \"../lens-core-module/lensCore\";\nimport { metricsEventTargetFactory } from \"../metrics/metricsEventTarget\";\nimport { metricsHandlerFactory } from \"../metrics/metricsHandler\";\nimport { operationalMetricReporterFactory } from \"../metrics/operational/operationalMetricsReporter\";\nimport { lensSourcesFactory } from \"../extensions/LensSources\";\nimport { uriHandlersFactory } from \"../extensions/UriHandlers\";\nimport { lensPersistenceStoreFactory } from \"../lens/LensPersistenceStore\";\nimport { cofHandlerFactory } from \"../remote-configuration/cofHandler\";\nimport { remoteConfigurationFactory } from \"../remote-configuration/remoteConfiguration\";\nimport { lensAssetRepositoryFactory } from \"../lens/assets/LensAssetRepository\";\nimport { legalStateFactory } from \"../legal/legalState\";\nimport { legalPromptFactory } from \"../legal/legalPrompt\";\nimport { logEntriesFactory } from \"../logger/logEntries\";\nimport { reportGlobalException } from \"../metrics/reporters/reportGlobalException\";\nimport { requestStateEventTargetFactory } from \"../handlers/requestStateEmittingHandler\";\nimport { pageVisibilityFactory } from \"../common/pageVisibility\";\nimport { remoteApiServicesFactory } from \"../extensions/RemoteApiServices\";\nimport { ServicesFromInjectables } from \"./types\";\n\n/**\n * All services available to be customized by client app.\n */\nexport type PublicServices = ServicesFromInjectables<\n [\n ReturnType<typeof createCameraKitConfigurationFactory>,\n typeof pageVisibilityFactory,\n typeof defaultFetchHandlerFactory,\n typeof remoteMediaAssetLoaderFactory,\n typeof lensSourcesFactory,\n typeof remoteApiServicesFactory,\n typeof uriHandlersFactory\n ]\n>;\n\n/**\n * Define all the Services contained in CameraKit's root dependency injection container.\n *\n * Note: we do end up defining this list of Services twice (once here to create the type, once when we actually\n * create the Container inside the `bootstrapCameraKit` function). We could avoid doing this and just infer the\n * RootContainer type from the constructed container – but since we can only do that *inside* `bootstrapCameraKit`, it\n * makes it more awkward to provide a type for the `provide` user-supplied function (or use the type elsewhere, like in\n * CameraKitSession).\n *\n * There may be a way to eliminate this extra boilerplate, but for now it's required in order to present a cleaner\n * `bootstrapCameraKit` API to applications.\n */\nexport type RootServices = {\n // bootstrapCameraKit replaces the lensCoreFactory token's value with the resolved LensCore (rather than the\n // Promise of the LensCore), so we need to do the same re-mapping here.\n [lensCoreFactory.token]: LensCore;\n} & PublicServices &\n ServicesFromInjectables<\n [\n typeof metricsEventTargetFactory,\n typeof requestStateEventTargetFactory,\n typeof cameraKitServiceFetchHandlerFactory,\n typeof cofHandlerFactory,\n typeof remoteConfigurationFactory,\n typeof lensRepositoryFactory,\n typeof lensPersistenceStoreFactory,\n typeof metricsHandlerFactory,\n typeof operationalMetricReporterFactory,\n typeof lensAssetRepositoryFactory,\n typeof deviceDependentAssetLoaderFactory,\n typeof staticAssetLoaderFactory,\n typeof legalStateFactory,\n typeof legalPromptFactory,\n typeof logEntriesFactory,\n typeof reportGlobalException\n ]\n >;\n"]}
@@ -1 +1 @@
1
- { "PACKAGE_VERSION": "0.13.2-alpha.1" }
1
+ { "PACKAGE_VERSION": "0.14.0-alpha.1" }
@@ -1,10 +1,10 @@
1
- import { cameraKitUserAgent } from "../common/cameraKitUserAgent";
2
- import { fullLocale } from "../common/locale";
1
+ import { getCameraKitUserAgent } from "../platform/cameraKitUserAgent";
3
2
  import { ExtensionRequestContext } from "../generated-proto/pb_schema/camera_kit/v3/export";
3
+ import { getPlatformInfo } from "../platform/platformInfo";
4
4
  function getExtensionRequestContext() {
5
5
  return ExtensionRequestContext.encode({
6
- userAgent: cameraKitUserAgent.userAgent,
7
- locale: fullLocale,
6
+ userAgent: getCameraKitUserAgent(),
7
+ locale: getPlatformInfo().fullLocale,
8
8
  }).finish();
9
9
  }
10
10
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"extensionRequestContext.js","sourceRoot":"","sources":["../../src/extensions/extensionRequestContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,uBAAuB,EAAE,MAAM,mDAAmD,CAAC;AAE5F,SAAS,0BAA0B;IAC/B,OAAO,uBAAuB,CAAC,MAAM,CAAC;QAClC,SAAS,EAAE,kBAAkB,CAAC,SAAS;QACvC,MAAM,EAAE,UAAU;KACrB,CAAC,CAAC,MAAM,EAAE,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,0BAA0B,EAAE,CAAC","sourcesContent":["import { cameraKitUserAgent } from \"../common/cameraKitUserAgent\";\nimport { fullLocale } from \"../common/locale\";\nimport { ExtensionRequestContext } from \"../generated-proto/pb_schema/camera_kit/v3/export\";\n\nfunction getExtensionRequestContext(): ArrayBuffer {\n return ExtensionRequestContext.encode({\n userAgent: cameraKitUserAgent.userAgent,\n locale: fullLocale,\n }).finish();\n}\n\n/**\n * Extension request context.\n */\nexport const extensionRequestContext = getExtensionRequestContext();\n"]}
1
+ {"version":3,"file":"extensionRequestContext.js","sourceRoot":"","sources":["../../src/extensions/extensionRequestContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,mDAAmD,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,SAAS,0BAA0B;IAC/B,OAAO,uBAAuB,CAAC,MAAM,CAAC;QAClC,SAAS,EAAE,qBAAqB,EAAE;QAClC,MAAM,EAAE,eAAe,EAAE,CAAC,UAAU;KACvC,CAAC,CAAC,MAAM,EAAE,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,0BAA0B,EAAE,CAAC","sourcesContent":["import { getCameraKitUserAgent } from \"../platform/cameraKitUserAgent\";\nimport { ExtensionRequestContext } from \"../generated-proto/pb_schema/camera_kit/v3/export\";\nimport { getPlatformInfo } from \"../platform/platformInfo\";\n\nfunction getExtensionRequestContext(): ArrayBuffer {\n return ExtensionRequestContext.encode({\n userAgent: getCameraKitUserAgent(),\n locale: getPlatformInfo().fullLocale,\n }).finish();\n}\n\n/**\n * Extension request context.\n */\nexport const extensionRequestContext = getExtensionRequestContext();\n"]}
@@ -1,6 +1,6 @@
1
1
  import { LensKeyboard } from "../session/LensKeyboard";
2
2
  import { LensRepository } from "../lens";
3
- import { LensCoreModule } from "../lens-core-module";
3
+ import { LensCore } from "../lens-core-module";
4
4
  import { OperationalMetricsReporter } from "../metrics/operational/operationalMetricsReporter";
5
5
  import { RemoteApiServices } from "./RemoteApiServices";
6
6
  import { UriHandlers } from "./UriHandlers";
@@ -9,7 +9,7 @@ import { UriHandlers } from "./UriHandlers";
9
9
  * @internal
10
10
  */
11
11
  export declare const registerUriHandlers: {
12
- (args_0: LensCoreModule, args_1: import("@snap/state-management").StateMachine<import("@snap/state-management").Action<"applyLens", {
12
+ (args_0: LensCore, args_1: import("@snap/state-management").StateMachine<import("@snap/state-management").Action<"applyLens", {
13
13
  lens: import("../lens").Lens;
14
14
  launchParams?: import("..").LensLaunchParams | undefined;
15
15
  }> | import("@snap/state-management").Action<"downloadComplete", import("../lens").Lens> | import("@snap/state-management").Action<"turnedOn", import("../lens").Lens> | import("@snap/state-management").Action<"resourcesLoaded", import("../lens").Lens> | import("@snap/state-management").Action<"firstFrameProcessed", import("../lens").Lens> | import("@snap/state-management").Action<"applyLensComplete", import("../lens").Lens> | import("@snap/state-management").Action<"applyLensFailed", {
@@ -1 +1 @@
1
- {"version":3,"file":"uriHandlersRegister.js","sourceRoot":"","sources":["../../src/extensions/uriHandlersRegister.ts"],"names":[],"mappings":"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","sourcesContent":["import { isState } from \"@snap/state-management\";\n\nimport { Injectable } from \"../dependency-injection/Injectable\";\nimport { LensKeyboard, lensKeyboardFactory } from \"../session/LensKeyboard\";\nimport { LensState, lensStateFactory } from \"../session/lensState\";\nimport { LensRepository, lensRepositoryFactory } from \"../lens\";\nimport { SessionState, sessionStateFactory } from \"../session/sessionState\";\nimport { LensCoreModule, UriResponse, lensCoreFactory } from \"../lens-core-module\";\nimport { getLogger } from \"../logger/logger\";\nimport {\n OperationalMetricsReporter,\n operationalMetricReporterFactory,\n} from \"../metrics/operational/operationalMetricsReporter\";\nimport { RemoteApiServices, getRemoteApiUriHandler, remoteApiServicesFactory } from \"./RemoteApiServices\";\nimport { UriHandlers, extractSchemeAndRoute, isUriHandlers, isUriResponse, uriHandlersFactory } from \"./UriHandlers\";\n\nconst logger = getLogger(\"uriHandlersRegister\");\n\n/**\n * Registers URI handlers within LensCore.\n * @internal\n */\nexport const registerUriHandlers = Injectable(\n \"registerUriHandlers\",\n [\n lensCoreFactory.token,\n lensStateFactory.token,\n uriHandlersFactory.token,\n lensKeyboardFactory.token,\n remoteApiServicesFactory.token,\n lensRepositoryFactory.token,\n sessionStateFactory.token,\n operationalMetricReporterFactory.token,\n ] as const,\n (\n lensCore: LensCoreModule,\n lensState: LensState,\n userHandlers: UriHandlers,\n lensKeyboard: LensKeyboard,\n remoteApiServices: RemoteApiServices,\n lensRepository: LensRepository,\n sessionState: SessionState,\n operationalMetricsReporter: OperationalMetricsReporter\n ): void => {\n if (!isUriHandlers(userHandlers)) {\n throw new Error(\"Expected an array of UriHandler objects\");\n }\n\n // Users may define UriHandlers using the uriHandlersFactory.token, but we need to add some internally-defined\n // handlers (lens keyboard and Remote API) before registering handlers with LensCore.\n const allHandlers = userHandlers.concat(\n lensKeyboard.uriHandler,\n getRemoteApiUriHandler(\n remoteApiServices,\n sessionState,\n lensState,\n lensRepository,\n operationalMetricsReporter\n )\n );\n\n for (const { uri, handleRequest, cancelRequest } of allHandlers) {\n const uris = Array.isArray(uri) ? uri : [uri];\n for (const { scheme, route } of uris.map(extractSchemeAndRoute)) {\n lensCore.registerUriListener(scheme, route, {\n handleRequest: (request) => {\n const reply = (response: UriResponse) => {\n if (!isUriResponse(response)) {\n throw new Error(\"Expected UriResponse object\");\n }\n lensCore.provideUriResponse(request.identifier, response);\n };\n\n // Since lenses are the only things that make URI requests, we expect to always be in the\n // \"lensApplied\" state – we'll sanity check, though, and log a warning if we're not.\n const state = lensState.getState();\n if (isState(state, \"noLensApplied\")) {\n logger.warn(\n `Got a URI request for ${request.uri}, but there is no active lens. The ` +\n `request will not be processed.`\n );\n return;\n }\n\n // NOTE: we do not handle any error thrown on an extension side when handleRequest() is called.\n // That responsibility is delegated to the extension by design and that is exactly what Android\n // and iOS SDKs do.\n handleRequest(request, reply, state.data);\n },\n cancelRequest: (request) => {\n if (cancelRequest) {\n const state = lensState.getState();\n if (isState(state, \"noLensApplied\")) {\n logger.warn(\n `Got a URI cancel request for ${request.uri}, but there is no active ` +\n `lens. The cancel request will not be processed.`\n );\n return;\n }\n cancelRequest(request, state.data);\n }\n },\n });\n }\n }\n }\n);\n"]}
1
+ {"version":3,"file":"uriHandlersRegister.js","sourceRoot":"","sources":["../../src/extensions/uriHandlersRegister.ts"],"names":[],"mappings":"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","sourcesContent":["import { isState } from \"@snap/state-management\";\n\nimport { Injectable } from \"../dependency-injection/Injectable\";\nimport { LensKeyboard, lensKeyboardFactory } from \"../session/LensKeyboard\";\nimport { LensState, lensStateFactory } from \"../session/lensState\";\nimport { LensRepository, lensRepositoryFactory } from \"../lens\";\nimport { SessionState, sessionStateFactory } from \"../session/sessionState\";\nimport { LensCore, UriResponse, lensCoreFactory } from \"../lens-core-module\";\nimport { getLogger } from \"../logger/logger\";\nimport {\n OperationalMetricsReporter,\n operationalMetricReporterFactory,\n} from \"../metrics/operational/operationalMetricsReporter\";\nimport { RemoteApiServices, getRemoteApiUriHandler, remoteApiServicesFactory } from \"./RemoteApiServices\";\nimport { UriHandlers, extractSchemeAndRoute, isUriHandlers, isUriResponse, uriHandlersFactory } from \"./UriHandlers\";\n\nconst logger = getLogger(\"uriHandlersRegister\");\n\n/**\n * Registers URI handlers within LensCore.\n * @internal\n */\nexport const registerUriHandlers = Injectable(\n \"registerUriHandlers\",\n [\n lensCoreFactory.token,\n lensStateFactory.token,\n uriHandlersFactory.token,\n lensKeyboardFactory.token,\n remoteApiServicesFactory.token,\n lensRepositoryFactory.token,\n sessionStateFactory.token,\n operationalMetricReporterFactory.token,\n ] as const,\n (\n lensCore: LensCore,\n lensState: LensState,\n userHandlers: UriHandlers,\n lensKeyboard: LensKeyboard,\n remoteApiServices: RemoteApiServices,\n lensRepository: LensRepository,\n sessionState: SessionState,\n operationalMetricsReporter: OperationalMetricsReporter\n ): void => {\n if (!isUriHandlers(userHandlers)) {\n throw new Error(\"Expected an array of UriHandler objects\");\n }\n\n // Users may define UriHandlers using the uriHandlersFactory.token, but we need to add some internally-defined\n // handlers (lens keyboard and Remote API) before registering handlers with LensCore.\n const allHandlers = userHandlers.concat(\n lensKeyboard.uriHandler,\n getRemoteApiUriHandler(\n remoteApiServices,\n sessionState,\n lensState,\n lensRepository,\n operationalMetricsReporter\n )\n );\n\n for (const { uri, handleRequest, cancelRequest } of allHandlers) {\n const uris = Array.isArray(uri) ? uri : [uri];\n for (const { scheme, route } of uris.map(extractSchemeAndRoute)) {\n lensCore.registerUriListener(scheme, route, {\n handleRequest: (request) => {\n const reply = (response: UriResponse) => {\n if (!isUriResponse(response)) {\n throw new Error(\"Expected UriResponse object\");\n }\n lensCore.provideUriResponse(request.identifier, response);\n };\n\n // Since lenses are the only things that make URI requests, we expect to always be in the\n // \"lensApplied\" state – we'll sanity check, though, and log a warning if we're not.\n const state = lensState.getState();\n if (isState(state, \"noLensApplied\")) {\n logger.warn(\n `Got a URI request for ${request.uri}, but there is no active lens. The ` +\n `request will not be processed.`\n );\n return;\n }\n\n // NOTE: we do not handle any error thrown on an extension side when handleRequest() is called.\n // That responsibility is delegated to the extension by design and that is exactly what Android\n // and iOS SDKs do.\n handleRequest(request, reply, state.data);\n },\n cancelRequest: (request) => {\n if (cancelRequest) {\n const state = lensState.getState();\n if (isState(state, \"noLensApplied\")) {\n logger.warn(\n `Got a URI cancel request for ${request.uri}, but there is no active ` +\n `lens. The cancel request will not be processed.`\n );\n return;\n }\n cancelRequest(request, state.data);\n }\n },\n });\n }\n }\n }\n);\n"]}