@snap/camera-kit 0.18.1 → 0.20.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 (178) hide show
  1. package/README.md +1 -1
  2. package/dist/CameraKit.d.ts +2 -2
  3. package/dist/bootstrapCameraKit.d.ts.map +1 -1
  4. package/dist/bootstrapCameraKit.js +3 -1
  5. package/dist/bootstrapCameraKit.js.map +1 -1
  6. package/dist/clients/grpcHandler.d.ts +9 -3
  7. package/dist/clients/grpcHandler.d.ts.map +1 -1
  8. package/dist/clients/grpcHandler.js +20 -3
  9. package/dist/clients/grpcHandler.js.map +1 -1
  10. package/dist/dependency-injection/RootServices.d.ts +2 -0
  11. package/dist/dependency-injection/RootServices.d.ts.map +1 -1
  12. package/dist/dependency-injection/RootServices.js.map +1 -1
  13. package/dist/environment.js +1 -1
  14. package/dist/environment.js.map +1 -1
  15. package/dist/index.d.ts +1 -0
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +1 -0
  18. package/dist/index.js.map +1 -1
  19. package/dist/lens-client-interface/filePicker.d.ts +31 -0
  20. package/dist/lens-client-interface/filePicker.d.ts.map +1 -0
  21. package/dist/lens-client-interface/filePicker.js +3 -0
  22. package/dist/lens-client-interface/filePicker.js.map +1 -0
  23. package/dist/lens-client-interface/imagePicker.d.ts +2 -1
  24. package/dist/lens-client-interface/imagePicker.d.ts.map +1 -1
  25. package/dist/lens-client-interface/imagePicker.js +6 -3
  26. package/dist/lens-client-interface/imagePicker.js.map +1 -1
  27. package/dist/lens-client-interface/lensClientInterface.d.ts +3 -2
  28. package/dist/lens-client-interface/lensClientInterface.d.ts.map +1 -1
  29. package/dist/lens-client-interface/lensClientInterface.js +3 -2
  30. package/dist/lens-client-interface/lensClientInterface.js.map +1 -1
  31. package/dist/lens-core-module/loader/lensCoreFactory.d.ts +9 -2
  32. package/dist/lens-core-module/loader/lensCoreFactory.d.ts.map +1 -1
  33. package/dist/lens-core-module/loader/lensCoreFactory.js +18 -6
  34. package/dist/lens-core-module/loader/lensCoreFactory.js.map +1 -1
  35. package/dist/lensCoreWasmVersions.js +3 -3
  36. package/dist/lensCoreWasmVersions.js.map +1 -1
  37. package/dist/metrics/reporters/reportHttpMetrics.d.ts +5 -1
  38. package/dist/metrics/reporters/reportHttpMetrics.d.ts.map +1 -1
  39. package/dist/metrics/reporters/reportHttpMetrics.js +21 -15
  40. package/dist/metrics/reporters/reportHttpMetrics.js.map +1 -1
  41. package/dist/metrics/reporters/reporters.d.ts +1 -1
  42. package/dist/remote-configuration/cofHandler.d.ts.map +1 -1
  43. package/dist/remote-configuration/cofHandler.js +1 -1
  44. package/dist/remote-configuration/cofHandler.js.map +1 -1
  45. package/docs/html/assets/navigation.js +1 -1
  46. package/docs/html/assets/search.js +1 -1
  47. package/docs/html/classes/CameraKit.html +2 -2
  48. package/docs/html/classes/CameraKitSession.html +2 -2
  49. package/docs/html/classes/CameraKitSource.html +2 -2
  50. package/docs/html/classes/LensPerformanceMeasurement.html +2 -2
  51. package/docs/html/classes/LensPerformanceMetrics.html +2 -2
  52. package/docs/html/classes/LensRepository.html +2 -2
  53. package/docs/html/classes/Transform2D.html +2 -2
  54. package/docs/html/classes/TypedCustomEvent.html +2 -2
  55. package/docs/html/classes/TypedEventTarget.html +2 -2
  56. package/docs/html/enums/Lens_CameraFacing.html +2 -2
  57. package/docs/html/functions/ConcatInjectable.html +2 -2
  58. package/docs/html/functions/Injectable.html +2 -2
  59. package/docs/html/functions/bootstrapCameraKit.html +2 -2
  60. package/docs/html/functions/createExtension.html +2 -2
  61. package/docs/html/functions/createImageSource.html +2 -2
  62. package/docs/html/functions/createMediaStreamSource.html +2 -2
  63. package/docs/html/functions/createVideoSource.html +2 -2
  64. package/docs/html/functions/estimateLensPerformance.html +2 -2
  65. package/docs/html/functions/filePickerFactory.html +5 -0
  66. package/docs/html/functions/lensSourcesFactory.html +2 -2
  67. package/docs/html/functions/remoteApiServicesFactory.html +2 -2
  68. package/docs/html/hierarchy.html +1 -1
  69. package/docs/html/index.html +3 -3
  70. package/docs/html/interfaces/BitmojiUserInfo.html +2 -2
  71. package/docs/html/interfaces/CameraKitBootstrapConfiguration.html +2 -2
  72. package/docs/html/interfaces/CameraKitDeviceOptions.html +2 -2
  73. package/docs/html/interfaces/CameraKitSourceInfo.html +2 -2
  74. package/docs/html/interfaces/CameraKitSourceSubscriber.html +2 -2
  75. package/docs/html/interfaces/ComputedFrameMetrics.html +2 -2
  76. package/docs/html/interfaces/CreateSessionOptions.html +2 -2
  77. package/docs/html/interfaces/EstimatedLensPerformance.html +2 -2
  78. package/docs/html/interfaces/FriendUserInfo.html +2 -2
  79. package/docs/html/interfaces/FunctionSourceOptions.html +2 -2
  80. package/docs/html/interfaces/Lens.html +2 -2
  81. package/docs/html/interfaces/LensCreator.html +2 -2
  82. package/docs/html/interfaces/LensLaunchData.html +2 -2
  83. package/docs/html/interfaces/LensSource.html +2 -2
  84. package/docs/html/interfaces/LensUserData.html +2 -2
  85. package/docs/html/interfaces/LoadAssetRequest.html +2 -2
  86. package/docs/html/interfaces/MediaStreamSourceOptions.html +2 -2
  87. package/docs/html/interfaces/Preview.html +2 -2
  88. package/docs/html/interfaces/RemoteApiRequest.html +2 -2
  89. package/docs/html/interfaces/RemoteApiResponse.html +2 -2
  90. package/docs/html/interfaces/RemoteApiService.html +2 -2
  91. package/docs/html/interfaces/Snapcode.html +2 -2
  92. package/docs/html/interfaces/UriCancelRequest.html +2 -2
  93. package/docs/html/interfaces/UriRequest.html +2 -2
  94. package/docs/html/interfaces/UriResponse.html +2 -2
  95. package/docs/html/interfaces/VideoSourceOptions.html +2 -2
  96. package/docs/html/modules.html +6 -2
  97. package/docs/html/types/ArgumentValidationError.html +2 -2
  98. package/docs/html/types/AssetLoader.html +2 -2
  99. package/docs/html/types/AssetResponse.html +1 -1
  100. package/docs/html/types/AssetTiming.html +2 -2
  101. package/docs/html/types/BenchmarkError.html +1 -1
  102. package/docs/html/types/BootstrapError.html +2 -2
  103. package/docs/html/types/CacheKeyNotFoundError.html +1 -1
  104. package/docs/html/types/CameraKitSessionEventListener.html +2 -2
  105. package/docs/html/types/CameraKitSessionEvents.html +2 -2
  106. package/docs/html/types/CameraKitSourceError.html +1 -1
  107. package/docs/html/types/ConfigurationError.html +2 -2
  108. package/docs/html/types/FetchHandler.html +1 -1
  109. package/docs/html/types/FilePicker.html +6 -0
  110. package/docs/html/types/FilePickerOptions.html +2 -0
  111. package/docs/html/types/FilePickerResult.html +2 -0
  112. package/docs/html/types/Keyboard.html +2 -2
  113. package/docs/html/types/KeyboardEvents.html +2 -2
  114. package/docs/html/types/LegalError.html +1 -1
  115. package/docs/html/types/LensAbortError.html +2 -2
  116. package/docs/html/types/LensAssetError.html +2 -2
  117. package/docs/html/types/LensContentValidationError.html +1 -1
  118. package/docs/html/types/LensError.html +1 -1
  119. package/docs/html/types/LensExecutionError.html +2 -2
  120. package/docs/html/types/LensImagePickerError.html +2 -2
  121. package/docs/html/types/LensLaunchParams.html +2 -2
  122. package/docs/html/types/LensMetricsEvents.html +2 -2
  123. package/docs/html/types/LensPerformanceCluster.html +1 -1
  124. package/docs/html/types/LensView.html +2 -2
  125. package/docs/html/types/LensWait.html +2 -2
  126. package/docs/html/types/Matrix.html +2 -2
  127. package/docs/html/types/PersistentStoreError.html +2 -2
  128. package/docs/html/types/PlatformNotSupportedError.html +2 -2
  129. package/docs/html/types/PublicContainer.html +2 -2
  130. package/docs/html/types/PublicServices.html +2 -2
  131. package/docs/html/types/RemoteApiCancelRequestHandler.html +2 -2
  132. package/docs/html/types/RemoteApiRequestHandler.html +2 -2
  133. package/docs/html/types/RemoteApiServices.html +1 -1
  134. package/docs/html/types/RemoteApiStatus.html +2 -2
  135. package/docs/html/types/RenderTarget.html +2 -2
  136. package/docs/html/types/Uri.html +1 -1
  137. package/docs/html/types/WebGLError.html +1 -1
  138. package/docs/html/types/Zodiac.html +1 -1
  139. package/docs/html/variables/extensionRequestContext.html +2 -2
  140. package/docs/md/README.md +1 -1
  141. package/docs/md/classes/CameraKit.md +1 -1
  142. package/docs/md/classes/CameraKitSession.md +1 -1
  143. package/docs/md/classes/CameraKitSource.md +1 -1
  144. package/docs/md/classes/LensPerformanceMeasurement.md +1 -1
  145. package/docs/md/classes/LensPerformanceMetrics.md +1 -1
  146. package/docs/md/classes/LensRepository.md +1 -1
  147. package/docs/md/classes/Transform2D.md +1 -1
  148. package/docs/md/classes/TypedCustomEvent.md +1 -1
  149. package/docs/md/classes/TypedEventTarget.md +1 -1
  150. package/docs/md/enums/Lens_CameraFacing.md +1 -1
  151. package/docs/md/interfaces/BitmojiUserInfo.md +1 -1
  152. package/docs/md/interfaces/CameraKitBootstrapConfiguration.md +1 -1
  153. package/docs/md/interfaces/CameraKitDeviceOptions.md +1 -1
  154. package/docs/md/interfaces/CameraKitSourceInfo.md +1 -1
  155. package/docs/md/interfaces/CameraKitSourceSubscriber.md +1 -1
  156. package/docs/md/interfaces/ComputedFrameMetrics.md +1 -1
  157. package/docs/md/interfaces/CreateSessionOptions.md +1 -1
  158. package/docs/md/interfaces/EstimatedLensPerformance.md +1 -1
  159. package/docs/md/interfaces/FriendUserInfo.md +1 -1
  160. package/docs/md/interfaces/FunctionSourceOptions.md +1 -1
  161. package/docs/md/interfaces/Lens.md +1 -1
  162. package/docs/md/interfaces/LensCreator.md +1 -1
  163. package/docs/md/interfaces/LensLaunchData.md +1 -1
  164. package/docs/md/interfaces/LensSource.md +1 -1
  165. package/docs/md/interfaces/LensUserData.md +1 -1
  166. package/docs/md/interfaces/LoadAssetRequest.md +1 -1
  167. package/docs/md/interfaces/MediaStreamSourceOptions.md +1 -1
  168. package/docs/md/interfaces/Preview.md +1 -1
  169. package/docs/md/interfaces/RemoteApiRequest.md +1 -1
  170. package/docs/md/interfaces/RemoteApiResponse.md +1 -1
  171. package/docs/md/interfaces/RemoteApiService.md +1 -1
  172. package/docs/md/interfaces/Snapcode.md +1 -1
  173. package/docs/md/interfaces/UriCancelRequest.md +1 -1
  174. package/docs/md/interfaces/UriRequest.md +1 -1
  175. package/docs/md/interfaces/UriResponse.md +1 -1
  176. package/docs/md/interfaces/VideoSourceOptions.md +1 -1
  177. package/docs/md/modules.md +65 -3
  178. package/package.json +6 -6
package/README.md CHANGED
@@ -181,7 +181,7 @@ session.pause('capture');
181
181
 
182
182
  ## Error Handling
183
183
 
184
- Camera Kit Web SDK methods may throw errors, or return rejected Promises -- these are documented in the [API docs](https://kit.snapchat.com/reference/CameraKit/web/0.18.1/index.html). It is good practice to handle such cases, to provide a good experience to your users.
184
+ Camera Kit Web SDK methods may throw errors, or return rejected Promises -- these are documented in the [API docs](https://kit.snapchat.com/reference/CameraKit/web/0.20.0/index.html). It is good practice to handle such cases, to provide a good experience to your users.
185
185
 
186
186
  Errors may also occur during Lens rendering. For example, Lenses contain their own scripting, which could throw an error. A rendering error could also occur if a Lens attempts to use a feature that is not supported by Camera Kit Web SDK.
187
187
 
@@ -266,9 +266,9 @@ export declare const cameraKitFactory: {
266
266
  token: "cameraKitServiceFetchHandler";
267
267
  dependencies: readonly ["configuration", "defaultFetchHandler"];
268
268
  }, {
269
- (args_0: import("./configuration").CameraKitConfiguration, args_1: import(".").FetchHandler): import("./clients/grpcHandler").GrpcHandler;
269
+ (args_0: import("./configuration").CameraKitConfiguration, args_1: import(".").FetchHandler, args_2: import("./handlers/requestStateEmittingHandler").RequestStateEventTarget): import("./clients/grpcHandler").GrpcHandler;
270
270
  token: "grpcHandlerFactory";
271
- dependencies: readonly ["configuration", "cameraKitServiceFetchHandler"];
271
+ dependencies: readonly ["configuration", "cameraKitServiceFetchHandler", "requestStateEventTarget"];
272
272
  }, {
273
273
  (args_0: import("./clients/grpcHandler").GrpcHandler): import("./clients/lensesClient").LensesClient;
274
274
  token: "lensesClient";
@@ -1 +1 @@
1
- {"version":3,"file":"bootstrapCameraKit.d.ts","sourceRoot":"","sources":["../src/bootstrapCameraKit.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,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AAK,eAAe,GAClD,OAAO,CAAC,SAAS,CAAC,CA2FpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,eAAe,IAAI,gBAAgB,CAElD"}
@@ -41,6 +41,7 @@ import { cameraKitLensSourceFactory } from "./lens/cameraKitLensSource";
41
41
  import { externalMetricsSubjectFactory, metricsClientFactory } from "./clients/metricsClient";
42
42
  import { Timer } from "./metrics/operational/Timer";
43
43
  import { fetchWatermarkLens } from "./lens/fetchWatermarkLens";
44
+ import { filePickerFactory } from "./lens-client-interface/filePicker";
44
45
  const logger = getLogger("bootstrapCameraKit");
45
46
  const nonWrappableErrors = [
46
47
  "ConfigurationError",
@@ -60,6 +61,7 @@ export function bootstrapCameraKit(configuration, provide) {
60
61
  assert(isSafeString(configuration.apiToken), configurationError("Invalid or unsafe apiToken provided."));
61
62
  const configurationFactory = createCameraKitConfigurationFactory(configuration);
62
63
  const defaultPublicContainer = Container.provides(configurationFactory)
64
+ .provides(filePickerFactory)
63
65
  .provides(defaultFetchHandlerFactory)
64
66
  .provides(remoteMediaAssetLoaderFactory)
65
67
  .provides(lensSourcesFactory)
@@ -70,11 +72,11 @@ export function bootstrapCameraKit(configuration, provide) {
70
72
  const telemetryContainer = Container.provides(publicContainer)
71
73
  .provides(pageVisibilityFactory)
72
74
  .provides(cameraKitServiceFetchHandlerFactory)
75
+ .provides(requestStateEventTargetFactory)
73
76
  .provides(grpcHandlerFactory)
74
77
  .provides(metricsClientFactory)
75
78
  .provides(logEntriesFactory)
76
79
  .run(registerLogEntriesSubscriber)
77
- .provides(requestStateEventTargetFactory)
78
80
  .provides(metricsEventTargetFactory)
79
81
  .provides(reportGlobalException)
80
82
  .provides(cofHandlerFactory)
@@ -1 +1 @@
1
- {"version":3,"file":"bootstrapCameraKit.js","sourceRoot":"","sources":["../src/bootstrapCameraKit.ts"],"names":[],"mappings":";AAAA,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,Y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AE;gBACxB,KAAK,GAAG,cAAc,CAAC,iDAAiD,EAAE,KAAK,CAAC,CAAC;aACpF;YACD,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACpB,MAAM,KAAK,CAAC;SACf;IACL,CAAC;CAAA;AA0CD,MAAM,UAAU,eAAe;IAC3B,OAAO,IAAI,gBAAgB,CAAC,EAAE,CAAC,CAAC;AACpC,CAAC","sourcesContent":["import environment from \"./environment\";\nimport lensCoreWasm from \"./lensCoreWasmVersions\";\nimport { lensRepositoryFactory } from \"./lens/LensRepository\";\nimport { Container } from \"./dependency-injection/Container\";\nimport type { CameraKit } from \"./CameraKit\";\nimport { cameraKitFactory } from \"./CameraKit\";\nimport { lensCoreFactory } from \"./lens-core-module/loader/lensCoreFactory\";\nimport { Injectable } from \"./dependency-injection/Injectable\";\nimport { remoteMediaAssetLoaderFactory } from \"./lens/assets/remoteMediaAssetLoaderFactory\";\nimport { deviceDependentAssetLoaderFactory } from \"./lens/assets/deviceDependentAssetLoader\";\nimport { staticAssetLoaderFactory } from \"./lens/assets/staticAssetLoader\";\nimport { defaultFetchHandlerFactory } from \"./handlers/defaultFetchHandler\";\nimport { cameraKitServiceFetchHandlerFactory } from \"./handlers/cameraKitServiceFetchHandlerFactory\";\nimport type { CameraKitBootstrapConfiguration } from \"./configuration\";\nimport { createCameraKitConfigurationFactory } from \"./configuration\";\nimport type { PublicServices } from \"./dependency-injection/RootServices\";\nimport { PartialContainer } from \"./dependency-injection/PartialContainer\";\nimport { uriHandlersFactory } from \"./extensions/UriHandlers\";\nimport { assert } from \"./common/assertions\";\nimport { isSafeString } from \"./common/typeguards\";\nimport { metricsEventTargetFactory } from \"./metrics/metricsEventTarget\";\nimport { reportGloballyScopedMetrics } from \"./metrics/reporters/reporters\";\nimport { getLogger } from \"./logger/logger\";\nimport { logEntriesFactory } from \"./logger/logEntries\";\nimport { assertPlatformSupported } from \"./platform/assertPlatformSupported\";\nimport { lensPersistenceStoreFactory } from \"./lens/LensPersistenceStore\";\nimport { remoteConfigurationFactory } from \"./remote-configuration/remoteConfiguration\";\nimport { lensAssetRepositoryFactory } from \"./lens/assets/LensAssetRepository\";\nimport { legalStateFactory } from \"./legal/legalState\";\nimport { legalPromptFactory } from \"./legal/legalPrompt\";\nimport type { ConfigurationError, PlatformNotSupportedError } from \"./namedErrors\";\nimport { bootstrapError, configurationError } from \"./namedErrors\";\nimport { businessEventsReporterFactory } from \"./metrics/businessEventsReporter\";\nimport { reportGlobalException } from \"./metrics/reporters/reportGlobalException\";\nimport { registerLogEntriesSubscriber } from \"./logger/registerLogEntriesSubscriber\";\nimport { requestStateEventTargetFactory } from \"./handlers/requestStateEmittingHandler\";\nimport { pageVisibilityFactory } from \"./common/pageVisibility\";\nimport { cofHandlerFactory } from \"./remote-configuration/cofHandler\";\nimport { remoteApiServicesFactory } from \"./extensions/RemoteApiServices\";\nimport { lensesClientFactory } from \"./clients/lensesClient\";\nimport { grpcHandlerFactory } from \"./clients/grpcHandler\";\nimport { lensSourcesFactory } from \"./lens/LensSource\";\nimport { cameraKitLensSourceFactory } from \"./lens/cameraKitLensSource\";\nimport { externalMetricsSubjectFactory, metricsClientFactory } from \"./clients/metricsClient\";\nimport { Timer } from \"./metrics/operational/Timer\";\nimport { fetchWatermarkLens } from \"./lens/fetchWatermarkLens\";\n\nconst logger = getLogger(\"bootstrapCameraKit\");\n\n// The following errors are not wrapped with BootstrapError and bubble up as is.\nconst nonWrappableErrors: [ConfigurationError[\"name\"], PlatformNotSupportedError[\"name\"]] = [\n \"ConfigurationError\",\n \"PlatformNotSupportedError\",\n];\n\n/**\n * Returns true if given error has to be wrapped with BootstrapError.\n */\nfunction shouldWrapError(error: unknown): boolean {\n if (error instanceof Error) {\n return !nonWrappableErrors.some((name) => error.name === name);\n }\n return true;\n}\n\n/**\n * For more advanced use-cases, this DI Container holds services for which a custom implementation may be provided by\n * the application.\n *\n * @category Bootstrapping and Configuration\n */\nexport type PublicContainer = Container<PublicServices>;\n\n/**\n * Bootstrap CameraKit. This will download the WebAssembly code which powers CameraKit's rendering engine, and return\n * an instance of {@link CameraKit}.\n *\n * CameraKit must be provided with some configuration (the application's API token), and there are some additional\n * configurations which are optional.\n *\n * Descriptions of the available configurations can be found in the documentation for\n * {@link CameraKitBootstrapConfiguration}\n *\n * ---\n *\n * There is also a second, more advanced way to modify CameraKit to provide greater flexibility to support less common\n * use cases.\n *\n * This requires some knowledge of CameraKit's dependency injection system, and allows applications to provide their\n * own custom implementations of certain CameraKit components. This functionality will only be needed by applications\n * with very specific, more advanced requirements.\n *\n * @example\n * ```ts\n * // The most common way to bootstrap:\n * const cameraKit = await bootstrapCameraKit({ apiToken: myApiToken })\n *\n * // For special advanced use-cases, it is possible to provide custom implementations for certain CameraKit components.\n * const cameraKit = await bootstrapCameraKit(config, (container) => {\n * return container.provides(myCustomRemoteMediaAssetLoaderFactory)\n * })\n * ```\n *\n * @param configuration Configure CameraKit with e.g. credentials, global resource endpoints, etc.\n * @param provide Optional function that can make modifications to CameraKit's root DI container.\n * @returns A {@link CameraKit} instance, which is the entry point to CameraKit's API.\n *\n * @throws\n * - {@link ConfigurationError} when provided configuration object is invalid\n * - {@link PlatformNotSupportedError} when current platform is not supported by CameraKit\n * - {@link BootstrapError} when a failure occurs while initializing CameraKit and downloading the render engine\n * WebAssembly binary.\n *\n * @category Bootstrapping and Configuration\n */\nexport async function bootstrapCameraKit(\n configuration: CameraKitBootstrapConfiguration,\n provide?: (c: PublicContainer) => PublicContainer\n): Promise<CameraKit> {\n console.info(\n `Camera Kit SDK: ${environment.PACKAGE_VERSION} (${lensCoreWasm.version}/${lensCoreWasm.buildNumber})`\n );\n\n try {\n const bootstrapLatency = new Timer(\"bootstrap_time\");\n\n assert(isSafeString(configuration.apiToken), configurationError(\"Invalid or unsafe apiToken provided.\"));\n\n const configurationFactory = createCameraKitConfigurationFactory(configuration);\n\n // Public container holds services which applications can overwrite with their own implementations.\n const defaultPublicContainer = Container.provides(configurationFactory)\n .provides(defaultFetchHandlerFactory)\n .provides(remoteMediaAssetLoaderFactory)\n .provides(lensSourcesFactory)\n .provides(remoteApiServicesFactory)\n .provides(uriHandlersFactory)\n .provides(externalMetricsSubjectFactory);\n\n const publicContainer = provide ? provide(defaultPublicContainer) : defaultPublicContainer;\n\n // Now that the client's provide() function has completed and the configuration override is ready,\n // we create another container to initialize the logger. This ensures that logging is available\n // as we continue bootstrapping. We don't initialize the logger as part of the defaultPublicContainer\n // because we don't want applications to provide their own logger implementations,\n // and we're not interested in errors thrown by their provide() function.\n // Below is the minimum required container to report errors to Blizzard.\n const telemetryContainer = Container.provides(publicContainer)\n .provides(pageVisibilityFactory)\n .provides(cameraKitServiceFetchHandlerFactory)\n .provides(grpcHandlerFactory)\n .provides(metricsClientFactory)\n .provides(logEntriesFactory)\n .run(registerLogEntriesSubscriber)\n .provides(requestStateEventTargetFactory)\n .provides(metricsEventTargetFactory)\n .provides(reportGlobalException)\n .provides(cofHandlerFactory)\n .provides(remoteConfigurationFactory)\n .provides(legalPromptFactory)\n .provides(legalStateFactory)\n // We'll run a PartialContainer containing reporters for globally-scoped metrics. Running this container\n // allows each metric reporter to initialize itself (e.g. by adding event listeners to detect when certain\n // actions occur). This PartialContainer also includes the service which listens to locally-reported metrics\n // and sends them to our backend.\n .run(reportGloballyScopedMetrics)\n .run(businessEventsReporterFactory);\n\n // Run the exception logger so that it can subscribe to log events -- we can't use `Container.run()` because\n // reportGlobalException is also used as a dependency by other Services (and run does not provide Services,\n // it just runs them once).\n telemetryContainer.get(reportGlobalException.token);\n\n // At this point, logger is configured to report to console and Blizzard.\n\n await assertPlatformSupported();\n\n // LensCore is a foundational component which must be created asynchronously.\n // But it's annoying for every consumer of LensCore to have to wait on Promise<LensCore>\n // (which means they become async themselves). So we'll create a DI container which provides Promise<LensCore>,\n // wait for that promise once here, then create a new DI container that just contains LensCore.\n const lensCore = await telemetryContainer.provides(lensCoreFactory).get(lensCoreFactory.token);\n\n const container = telemetryContainer\n .provides(Injectable(lensCoreFactory.token, () => lensCore))\n .provides(lensesClientFactory)\n .provides(cameraKitLensSourceFactory)\n .provides(lensPersistenceStoreFactory)\n .provides(deviceDependentAssetLoaderFactory)\n .provides(staticAssetLoaderFactory)\n .provides(lensAssetRepositoryFactory)\n .provides(lensRepositoryFactory)\n .provides(cameraKitFactory)\n .run(fetchWatermarkLens);\n\n const cameraKit = container.get(cameraKitFactory.token);\n\n bootstrapLatency.measure();\n container.get(metricsClientFactory.token).setOperationalMetrics(bootstrapLatency);\n\n return cameraKit;\n } catch (error) {\n if (shouldWrapError(error)) {\n error = bootstrapError(\"Error occurred during Camera Kit bootstrapping.\", error);\n }\n logger.error(error);\n throw error;\n }\n}\n\n/**\n * Extensions offer a way to provide custom implementations of certain parts of the CameraKit SDK.\n *\n * This enables more advanced use-cases, in which the default behavior of the SDK is substantially altered. For example,\n * replacing the default implementation that loads remote lens assets with a custom implementation that returns\n * different assets based on some business logic within the application.\n *\n * An extension is implemented as a {@link PartialContainer} – a collection of factory functions, each with its own\n * dependencies, which each provide some \"Service\". A Service can be of any type, and the CameraKit SDK defines its\n * own Services, some of which can be overridden by providing a custom implementation of the type via an extension.\n *\n * Here's an example of how extensions might be used:\n * ```ts\n * import { bootstrapCameraKit, createExtension, remoteMediaAssetLoaderFactory } from '@snap/camera-kit'\n *\n * const myCustomRemoteAssetLoader = Injectable(\n * remoteMediaAssetLoaderFactory.token,\n * [remoteMediaAssetLoaderFactory.token] as const,\n * (defaultLoader: AssetLoader): AssetLoader => {\n * return async (asset, lens) => {\n * if (lens?.id === MY_SPECIAL_LENS) {\n * return (await fetch('my/asset.glb')).arrayBuffer()\n * }\n * return defaultLoader(asset, lens)\n * }\n * },\n * )\n *\n * const myExtension = createExtension().provides(myCustomRemoteAssetLoader);\n * const cameraKit = bootstrapCameraKit(config, container => container.provides(myExtension));\n * ```\n *\n * This also enables greater modularity – the person/team creating the extension can do so in their own package, which\n * could be shared by many applications that all require the same functionality.\n *\n * @returns A {@link PartialContainer} which can be used to create a collection of Services, and can later be provided\n * to CameraKit's DI container during {@link bootstrapCameraKit}.\n *\n * @category Bootstrapping and Configuration\n */\nexport function createExtension(): PartialContainer {\n return new PartialContainer({});\n}\n"]}
1
+ {"version":3,"file":"bootstrapCameraKit.js","sourceRoot":"","sources":["../src/bootstrapCameraKit.ts"],"names":[],"mappings":";AAAA,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,YAAY,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAE7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAC/D,OAAO,EAAE,6BAA6B,EAAE,MAAM,6CAA6C,CAAC;AAC5F,OAAO,EAAE,iCAAiC,EAAE,MAAM,0CAA0C,CAAC;AAC7F,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAE,mCAAmC,EAAE,MAAM,gDAAgD,CAAC;AAErG,OAAO,EAAE,mCAAmC,EAAE,MAAM,iBAAiB,CAAC;AAEtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAA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B,GAAG,CAAC,kBAAkB,CAAC,CAAC;YAE7B,MAAM,SAAS,GAAG,SAAS,CAAC,GAAG,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;YAExD,gBAAgB,CAAC,OAAO,EAAE,CAAC;YAC3B,SAAS,CAAC,GAAG,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,qBAAqB,CAAC,gBAAgB,CAAC,CAAC;YAElF,OAAO,SAAS,CAAC;SACpB;QAAC,OAAO,KAAK,EAAE;YACZ,IAAI,eAAe,CAAC,KAAK,CAAC,EAAE;gBACxB,KAAK,GAAG,cAAc,CAAC,iDAAiD,EAAE,KAAK,CAAC,CAAC;aACpF;YACD,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACpB,MAAM,KAAK,CAAC;SACf;IACL,CAAC;CAAA;AA0CD,MAAM,UAAU,eAAe;IAC3B,OAAO,IAAI,gBAAgB,CAAC,EAAE,CAAC,CAAC;AACpC,CAAC","sourcesContent":["import environment from \"./environment\";\nimport lensCoreWasm from \"./lensCoreWasmVersions\";\nimport { lensRepositoryFactory } from \"./lens/LensRepository\";\nimport { Container } from \"./dependency-injection/Container\";\nimport type { CameraKit } from \"./CameraKit\";\nimport { cameraKitFactory } from \"./CameraKit\";\nimport { lensCoreFactory } from \"./lens-core-module/loader/lensCoreFactory\";\nimport { Injectable } from \"./dependency-injection/Injectable\";\nimport { remoteMediaAssetLoaderFactory } from \"./lens/assets/remoteMediaAssetLoaderFactory\";\nimport { deviceDependentAssetLoaderFactory } from \"./lens/assets/deviceDependentAssetLoader\";\nimport { staticAssetLoaderFactory } from \"./lens/assets/staticAssetLoader\";\nimport { defaultFetchHandlerFactory } from \"./handlers/defaultFetchHandler\";\nimport { cameraKitServiceFetchHandlerFactory } from \"./handlers/cameraKitServiceFetchHandlerFactory\";\nimport type { CameraKitBootstrapConfiguration } from \"./configuration\";\nimport { createCameraKitConfigurationFactory } from \"./configuration\";\nimport type { PublicServices } from \"./dependency-injection/RootServices\";\nimport { PartialContainer } from \"./dependency-injection/PartialContainer\";\nimport { uriHandlersFactory } from \"./extensions/UriHandlers\";\nimport { assert } from \"./common/assertions\";\nimport { isSafeString } from \"./common/typeguards\";\nimport { metricsEventTargetFactory } from \"./metrics/metricsEventTarget\";\nimport { reportGloballyScopedMetrics } from \"./metrics/reporters/reporters\";\nimport { getLogger } from \"./logger/logger\";\nimport { logEntriesFactory } from \"./logger/logEntries\";\nimport { assertPlatformSupported } from \"./platform/assertPlatformSupported\";\nimport { lensPersistenceStoreFactory } from \"./lens/LensPersistenceStore\";\nimport { remoteConfigurationFactory } from \"./remote-configuration/remoteConfiguration\";\nimport { lensAssetRepositoryFactory } from \"./lens/assets/LensAssetRepository\";\nimport { legalStateFactory } from \"./legal/legalState\";\nimport { legalPromptFactory } from \"./legal/legalPrompt\";\nimport type { ConfigurationError, PlatformNotSupportedError } from \"./namedErrors\";\nimport { bootstrapError, configurationError } from \"./namedErrors\";\nimport { businessEventsReporterFactory } from \"./metrics/businessEventsReporter\";\nimport { reportGlobalException } from \"./metrics/reporters/reportGlobalException\";\nimport { registerLogEntriesSubscriber } from \"./logger/registerLogEntriesSubscriber\";\nimport { requestStateEventTargetFactory } from \"./handlers/requestStateEmittingHandler\";\nimport { pageVisibilityFactory } from \"./common/pageVisibility\";\nimport { cofHandlerFactory } from \"./remote-configuration/cofHandler\";\nimport { remoteApiServicesFactory } from \"./extensions/RemoteApiServices\";\nimport { lensesClientFactory } from \"./clients/lensesClient\";\nimport { grpcHandlerFactory } from \"./clients/grpcHandler\";\nimport { lensSourcesFactory } from \"./lens/LensSource\";\nimport { cameraKitLensSourceFactory } from \"./lens/cameraKitLensSource\";\nimport { externalMetricsSubjectFactory, metricsClientFactory } from \"./clients/metricsClient\";\nimport { Timer } from \"./metrics/operational/Timer\";\nimport { fetchWatermarkLens } from \"./lens/fetchWatermarkLens\";\nimport { filePickerFactory } from \"./lens-client-interface/filePicker\";\n\nconst logger = getLogger(\"bootstrapCameraKit\");\n\n// The following errors are not wrapped with BootstrapError and bubble up as is.\nconst nonWrappableErrors: [ConfigurationError[\"name\"], PlatformNotSupportedError[\"name\"]] = [\n \"ConfigurationError\",\n \"PlatformNotSupportedError\",\n];\n\n/**\n * Returns true if given error has to be wrapped with BootstrapError.\n */\nfunction shouldWrapError(error: unknown): boolean {\n if (error instanceof Error) {\n return !nonWrappableErrors.some((name) => error.name === name);\n }\n return true;\n}\n\n/**\n * For more advanced use-cases, this DI Container holds services for which a custom implementation may be provided by\n * the application.\n *\n * @category Bootstrapping and Configuration\n */\nexport type PublicContainer = Container<PublicServices>;\n\n/**\n * Bootstrap CameraKit. This will download the WebAssembly code which powers CameraKit's rendering engine, and return\n * an instance of {@link CameraKit}.\n *\n * CameraKit must be provided with some configuration (the application's API token), and there are some additional\n * configurations which are optional.\n *\n * Descriptions of the available configurations can be found in the documentation for\n * {@link CameraKitBootstrapConfiguration}\n *\n * ---\n *\n * There is also a second, more advanced way to modify CameraKit to provide greater flexibility to support less common\n * use cases.\n *\n * This requires some knowledge of CameraKit's dependency injection system, and allows applications to provide their\n * own custom implementations of certain CameraKit components. This functionality will only be needed by applications\n * with very specific, more advanced requirements.\n *\n * @example\n * ```ts\n * // The most common way to bootstrap:\n * const cameraKit = await bootstrapCameraKit({ apiToken: myApiToken })\n *\n * // For special advanced use-cases, it is possible to provide custom implementations for certain CameraKit components.\n * const cameraKit = await bootstrapCameraKit(config, (container) => {\n * return container.provides(myCustomRemoteMediaAssetLoaderFactory)\n * })\n * ```\n *\n * @param configuration Configure CameraKit with e.g. credentials, global resource endpoints, etc.\n * @param provide Optional function that can make modifications to CameraKit's root DI container.\n * @returns A {@link CameraKit} instance, which is the entry point to CameraKit's API.\n *\n * @throws\n * - {@link ConfigurationError} when provided configuration object is invalid\n * - {@link PlatformNotSupportedError} when current platform is not supported by CameraKit\n * - {@link BootstrapError} when a failure occurs while initializing CameraKit and downloading the render engine\n * WebAssembly binary.\n *\n * @category Bootstrapping and Configuration\n */\nexport async function bootstrapCameraKit(\n configuration: CameraKitBootstrapConfiguration,\n provide?: (c: PublicContainer) => PublicContainer\n): Promise<CameraKit> {\n console.info(\n `Camera Kit SDK: ${environment.PACKAGE_VERSION} (${lensCoreWasm.version}/${lensCoreWasm.buildNumber})`\n );\n\n try {\n const bootstrapLatency = new Timer(\"bootstrap_time\");\n\n assert(isSafeString(configuration.apiToken), configurationError(\"Invalid or unsafe apiToken provided.\"));\n\n const configurationFactory = createCameraKitConfigurationFactory(configuration);\n\n // Public container holds services which applications can overwrite with their own implementations.\n const defaultPublicContainer = Container.provides(configurationFactory)\n .provides(filePickerFactory)\n .provides(defaultFetchHandlerFactory)\n .provides(remoteMediaAssetLoaderFactory)\n .provides(lensSourcesFactory)\n .provides(remoteApiServicesFactory)\n .provides(uriHandlersFactory)\n .provides(externalMetricsSubjectFactory);\n\n const publicContainer = provide ? provide(defaultPublicContainer) : defaultPublicContainer;\n\n // Now that the client's provide() function has completed and the configuration override is ready,\n // we create another container to initialize the logger. This ensures that logging is available\n // as we continue bootstrapping. We don't initialize the logger as part of the defaultPublicContainer\n // because we don't want applications to provide their own logger implementations,\n // and we're not interested in errors thrown by their provide() function.\n // Below is the minimum required container to report errors to Blizzard.\n const telemetryContainer = Container.provides(publicContainer)\n .provides(pageVisibilityFactory)\n .provides(cameraKitServiceFetchHandlerFactory)\n .provides(requestStateEventTargetFactory)\n .provides(grpcHandlerFactory)\n .provides(metricsClientFactory)\n .provides(logEntriesFactory)\n .run(registerLogEntriesSubscriber)\n .provides(metricsEventTargetFactory)\n .provides(reportGlobalException)\n .provides(cofHandlerFactory)\n .provides(remoteConfigurationFactory)\n .provides(legalPromptFactory)\n .provides(legalStateFactory)\n // We'll run a PartialContainer containing reporters for globally-scoped metrics. Running this container\n // allows each metric reporter to initialize itself (e.g. by adding event listeners to detect when certain\n // actions occur). This PartialContainer also includes the service which listens to locally-reported metrics\n // and sends them to our backend.\n .run(reportGloballyScopedMetrics)\n .run(businessEventsReporterFactory);\n\n // Run the exception logger so that it can subscribe to log events -- we can't use `Container.run()` because\n // reportGlobalException is also used as a dependency by other Services (and run does not provide Services,\n // it just runs them once).\n telemetryContainer.get(reportGlobalException.token);\n\n // At this point, logger is configured to report to console and Blizzard.\n\n await assertPlatformSupported();\n\n // LensCore is a foundational component which must be created asynchronously.\n // But it's annoying for every consumer of LensCore to have to wait on Promise<LensCore>\n // (which means they become async themselves). So we'll create a DI container which provides Promise<LensCore>,\n // wait for that promise once here, then create a new DI container that just contains LensCore.\n const lensCore = await telemetryContainer.provides(lensCoreFactory).get(lensCoreFactory.token);\n\n const container = telemetryContainer\n .provides(Injectable(lensCoreFactory.token, () => lensCore))\n .provides(lensesClientFactory)\n .provides(cameraKitLensSourceFactory)\n .provides(lensPersistenceStoreFactory)\n .provides(deviceDependentAssetLoaderFactory)\n .provides(staticAssetLoaderFactory)\n .provides(lensAssetRepositoryFactory)\n .provides(lensRepositoryFactory)\n .provides(cameraKitFactory)\n .run(fetchWatermarkLens);\n\n const cameraKit = container.get(cameraKitFactory.token);\n\n bootstrapLatency.measure();\n container.get(metricsClientFactory.token).setOperationalMetrics(bootstrapLatency);\n\n return cameraKit;\n } catch (error) {\n if (shouldWrapError(error)) {\n error = bootstrapError(\"Error occurred during Camera Kit bootstrapping.\", error);\n }\n logger.error(error);\n throw error;\n }\n}\n\n/**\n * Extensions offer a way to provide custom implementations of certain parts of the CameraKit SDK.\n *\n * This enables more advanced use-cases, in which the default behavior of the SDK is substantially altered. For example,\n * replacing the default implementation that loads remote lens assets with a custom implementation that returns\n * different assets based on some business logic within the application.\n *\n * An extension is implemented as a {@link PartialContainer} – a collection of factory functions, each with its own\n * dependencies, which each provide some \"Service\". A Service can be of any type, and the CameraKit SDK defines its\n * own Services, some of which can be overridden by providing a custom implementation of the type via an extension.\n *\n * Here's an example of how extensions might be used:\n * ```ts\n * import { bootstrapCameraKit, createExtension, remoteMediaAssetLoaderFactory } from '@snap/camera-kit'\n *\n * const myCustomRemoteAssetLoader = Injectable(\n * remoteMediaAssetLoaderFactory.token,\n * [remoteMediaAssetLoaderFactory.token] as const,\n * (defaultLoader: AssetLoader): AssetLoader => {\n * return async (asset, lens) => {\n * if (lens?.id === MY_SPECIAL_LENS) {\n * return (await fetch('my/asset.glb')).arrayBuffer()\n * }\n * return defaultLoader(asset, lens)\n * }\n * },\n * )\n *\n * const myExtension = createExtension().provides(myCustomRemoteAssetLoader);\n * const cameraKit = bootstrapCameraKit(config, container => container.provides(myExtension));\n * ```\n *\n * This also enables greater modularity – the person/team creating the extension can do so in their own package, which\n * could be shared by many applications that all require the same functionality.\n *\n * @returns A {@link PartialContainer} which can be used to create a collection of Services, and can later be provided\n * to CameraKit's DI container during {@link bootstrapCameraKit}.\n *\n * @category Bootstrapping and Configuration\n */\nexport function createExtension(): PartialContainer {\n return new PartialContainer({});\n}\n"]}
@@ -1,8 +1,9 @@
1
1
  import { grpc } from "@improbable-eng/grpc-web";
2
- import type { Handler, RequestMetadata } from "../handlers/HandlerChainBuilder";
2
+ import { type Handler, type RequestMetadata } from "../handlers/HandlerChainBuilder";
3
3
  import type { CameraKitConfiguration } from "../configuration";
4
4
  import type { Result } from "../common/result";
5
5
  import type { FetchHandler } from "../handlers/defaultFetchHandler";
6
+ import type { RequestStateEventTarget } from "../handlers/requestStateEmittingHandler";
6
7
  export interface GrpcRequest {
7
8
  serviceName: string;
8
9
  methodName: string;
@@ -13,6 +14,11 @@ export type GrpcHandler = Handler<GrpcRequest, GrpcResult, RequestMetadata>;
13
14
  export type GrpcResult = Result<grpc.UnaryOutput<grpc.ProtobufMessage> & {
14
15
  status: grpc.Code.OK;
15
16
  }, grpc.UnaryOutput<grpc.ProtobufMessage>>;
17
+ export declare const GRPC_CALL_REQUEST_TYPE = "grpc_call";
18
+ export interface GrpcRequestDimensions extends Record<string, string> {
19
+ requestType: typeof GRPC_CALL_REQUEST_TYPE;
20
+ methodName: string;
21
+ }
16
22
  /**
17
23
  * An Injectable handler that can make requests to the CameraKit backend service via grpc-web. This handler can be
18
24
  * passed to {@link createTsProtoClient} to produce a well-typed service client.
@@ -20,8 +26,8 @@ export type GrpcResult = Result<grpc.UnaryOutput<grpc.ProtobufMessage> & {
20
26
  * @internal
21
27
  */
22
28
  export declare const grpcHandlerFactory: {
23
- (args_0: CameraKitConfiguration, args_1: FetchHandler): GrpcHandler;
29
+ (args_0: CameraKitConfiguration, args_1: FetchHandler, args_2: RequestStateEventTarget): GrpcHandler;
24
30
  token: "grpcHandlerFactory";
25
- dependencies: readonly ["configuration", "cameraKitServiceFetchHandler"];
31
+ dependencies: readonly ["configuration", "cameraKitServiceFetchHandler", "requestStateEventTarget"];
26
32
  };
27
33
  //# sourceMappingURL=grpcHandler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"grpcHandler.d.ts","sourceRoot":"","sources":["../../src/clients/grpcHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAEhF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE/D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAGpE,MAAM,WAAW,WAAW;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAC7D,YAAY,EAAE,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;CACjE;AAED,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,EAAE,UAAU,EAAE,eAAe,CAAC,CAAC;AAE5E,MAAM,MAAM,UAAU,GAAG,MAAM,CAC3B,IAAI,CAAC,WAAW,CAAC,IAAI,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,cAAc,CAAC;AAElD,MAAM,WAAW,qBAAsB,SAAQ,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IACjE,WAAW,EAAE,OAAO,sBAAsB,CAAC;IAC3C,UAAU,EAAE,MAAM,CAAC;CACtB;AAYD;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB;;;;CAoG9B,CAAC"}
@@ -1,11 +1,20 @@
1
1
  import { __awaiter } from "tslib";
2
2
  import { grpc } from "@improbable-eng/grpc-web";
3
+ import { HandlerChainBuilder } from "../handlers/HandlerChainBuilder";
3
4
  import { Injectable } from "../dependency-injection/Injectable";
4
5
  import { configurationToken } from "../configuration";
5
6
  import { Err, Ok } from "../common/result";
6
7
  import { cameraKitServiceFetchHandlerFactory } from "../handlers/cameraKitServiceFetchHandlerFactory";
7
- export const grpcHandlerFactory = Injectable("grpcHandlerFactory", [configurationToken, cameraKitServiceFetchHandlerFactory.token], (configuration, handler) => {
8
+ import { createRequestStateEmittingHandler, requestStateEventTargetFactory, } from "../handlers/requestStateEmittingHandler";
9
+ import { MetricsDefinition } from "../generated-proto/pb_schema/camera_kit/v3/service";
10
+ export const GRPC_CALL_REQUEST_TYPE = "grpc_call";
11
+ function isMetricsGrpcMethod(method) {
12
+ return (method === MetricsDefinition.methods.setOperationalMetrics.name ||
13
+ method === MetricsDefinition.methods.setBusinessEvents.name);
14
+ }
15
+ export const grpcHandlerFactory = Injectable("grpcHandlerFactory", [configurationToken, cameraKitServiceFetchHandlerFactory.token, requestStateEventTargetFactory.token], (configuration, fetchHandler, requestStateEventTarget) => {
8
16
  const host = `https://${configuration.apiHostname}`;
17
+ const fetchHandlerWithMetrics = new HandlerChainBuilder(fetchHandler).map(createRequestStateEmittingHandler(requestStateEventTarget)).handler;
9
18
  const transport = (options) => {
10
19
  let metadata = undefined;
11
20
  const controller = globalThis.AbortController ? new AbortController() : undefined;
@@ -13,12 +22,20 @@ export const grpcHandlerFactory = Injectable("grpcHandlerFactory", [configuratio
13
22
  return {
14
23
  sendMessage(msgBytes) {
15
24
  var _a;
16
- handler(options.url, {
25
+ const requestInit = {
17
26
  headers: (_a = metadata === null || metadata === void 0 ? void 0 : metadata.toHeaders()) !== null && _a !== void 0 ? _a : {},
18
27
  method: "POST",
19
28
  body: msgBytes,
20
29
  signal: controller === null || controller === void 0 ? void 0 : controller.signal,
21
- })
30
+ };
31
+ const metricsDimensions = {
32
+ requestType: GRPC_CALL_REQUEST_TYPE,
33
+ methodName: options.methodDefinition.methodName,
34
+ };
35
+ const request = isMetricsGrpcMethod(options.methodDefinition.methodName)
36
+ ? fetchHandler(options.url, requestInit)
37
+ : fetchHandlerWithMetrics([options.url, metricsDimensions], requestInit);
38
+ request
22
39
  .then((response) => {
23
40
  options.onHeaders(new grpc.Metadata(response.headers), response.status);
24
41
  return response.arrayBuffer();
@@ -1 +1 @@
1
- {"version":3,"file":"grpcHandler.js","sourceRoot":"","sources":["../../src/clients/grpcHandler.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAEhE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EAAE,mCAAmC,EAAE,MAAM,iDAAiD,CAAC;AAsBtG,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CACxC,oBAAoB,EACpB,CAAC,kBAAkB,EAAE,mCAAmC,CAAC,KAAK,CAAU,EACxE,CAAC,aAAqC,EAAE,OAAqB,EAAe,EAAE;IAC1E,MAAM,IAAI,GAAG,WAAW,aAAa,CAAC,WAAW,EAAE,CAAC;IAOpD,MAAM,SAAS,GAA0B,CAAC,OAAO,EAAE,EAAE;QACjD,IAAI,QAAQ,GAA8B,SAAS,CAAC;QACpD,MAAM,UAAU,GAAG,UAAU,CAAC,eAAe,CAAC,CAAC,CA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AAC;YACxB,CAAC;SACJ,CAAC;IACN,CAAC,CAAC;IAEF,OAAO,CAAO,OAAO,EAAE,EAAE;QACrB,OAAA,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YACpB,IAAI,CAAC,KAAK,CACN;gBACI,UAAU,EAAE,OAAO,CAAC,UAAU;gBAC9B,OAAO,EAAE,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE;gBAC7C,aAAa,EAAE,KAAK;gBACpB,cAAc,EAAE,KAAK;gBACrB,WAAW,EAAE,OAAO,CAAC,WAAW;gBAChC,YAAY,EAAE,OAAO,CAAC,YAAY;aACrC,EACD;gBACI,OAAO,EAAE,IAAI,OAAO,CAAC,WAAW,EAAE;gBAClC,IAAI;gBACJ,KAAK,EAAE,CAAC,QAAQ,EAAE,EAAE;oBAChB,IAAI,eAAe,CAAC,QAAQ,CAAC,EAAE;wBAC3B,OAAO,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;qBACzB;yBAAM;wBACH,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC;qBAC1B;gBACL,CAAC;gBACD,SAAS;aACZ,CACJ,CAAC;QACN,CAAC,CAAC,CAAA;MAAA,CAAC;AACX,CAAC,CACJ,CAAC;AAEF,SAAS,eAAe,CACpB,KAA6C;IAE7C,OAAO,KAAK,CAAC,MAAM,KAAK,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;AACzC,CAAC","sourcesContent":["import { grpc } from \"@improbable-eng/grpc-web\";\nimport type { Handler, RequestMetadata } from \"../handlers/HandlerChainBuilder\";\nimport { Injectable } from \"../dependency-injection/Injectable\";\nimport type { CameraKitConfiguration } from \"../configuration\";\nimport { configurationToken } from \"../configuration\";\nimport type { Result } from \"../common/result\";\nimport { Err, Ok } from \"../common/result\";\nimport type { FetchHandler } from \"../handlers/defaultFetchHandler\";\nimport { cameraKitServiceFetchHandlerFactory } from \"../handlers/cameraKitServiceFetchHandlerFactory\";\n\nexport interface GrpcRequest {\n serviceName: string;\n methodName: string;\n requestType: grpc.ProtobufMessageClass<grpc.ProtobufMessage>;\n responseType: grpc.ProtobufMessageClass<grpc.ProtobufMessage>;\n}\n\nexport type GrpcHandler = Handler<GrpcRequest, GrpcResult, RequestMetadata>;\n\nexport type GrpcResult = Result<\n grpc.UnaryOutput<grpc.ProtobufMessage> & { status: grpc.Code.OK },\n grpc.UnaryOutput<grpc.ProtobufMessage>\n>;\n\n/**\n * An Injectable handler that can make requests to the CameraKit backend service via grpc-web. This handler can be\n * passed to {@link createTsProtoClient} to produce a well-typed service client.\n *\n * @internal\n */\nexport const grpcHandlerFactory = Injectable(\n \"grpcHandlerFactory\",\n [configurationToken, cameraKitServiceFetchHandlerFactory.token] as const,\n (configuration: CameraKitConfiguration, handler: FetchHandler): GrpcHandler => {\n const host = `https://${configuration.apiHostname}`;\n\n // We define our own Transport so that we can use our custom `fetch` implementation. This is important for two\n // reasons:\n // 1. Our custom fetch includes features like retries that we want to use for these requests.\n // 2. Applications may override this fetch implementation (via our DI system) to support more advanced\n // use-cases.\n const transport: grpc.TransportFactory = (options) => {\n let metadata: grpc.Metadata | undefined = undefined;\n const controller = globalThis.AbortController ? new AbortController() : undefined;\n let cancelled = false;\n return {\n sendMessage(msgBytes) {\n handler(options.url, {\n headers: metadata?.toHeaders() ?? {},\n method: \"POST\",\n body: msgBytes,\n signal: controller?.signal,\n })\n .then((response) => {\n options.onHeaders(new grpc.Metadata(response.headers), response.status);\n return response.arrayBuffer();\n })\n .then((body) => {\n if (cancelled) return;\n options.onChunk(new Uint8Array(body));\n options.onEnd();\n })\n .catch((error) => {\n if (cancelled) return;\n cancelled = true;\n options.onEnd(error);\n });\n },\n\n start(m) {\n metadata = m;\n },\n\n finishSend() {},\n\n cancel() {\n if (cancelled) return;\n cancelled = true;\n controller?.abort();\n },\n };\n };\n\n return async (request) =>\n new Promise((resolve) => {\n grpc.unary(\n {\n methodName: request.methodName,\n service: { serviceName: request.serviceName },\n requestStream: false,\n responseStream: false,\n requestType: request.requestType,\n responseType: request.responseType,\n },\n {\n request: new request.requestType(),\n host,\n onEnd: (response) => {\n if (isUnaryOutputOk(response)) {\n resolve(Ok(response));\n } else {\n resolve(Err(response));\n }\n },\n transport,\n }\n );\n });\n }\n);\n\nfunction isUnaryOutputOk(\n value: grpc.UnaryOutput<grpc.ProtobufMessage>\n): value is grpc.UnaryOutput<grpc.ProtobufMessage> & { status: grpc.Code.OK } {\n return value.status === grpc.Code.OK;\n}\n"]}
1
+ {"version":3,"file":"grpcHandler.js","sourceRoot":"","sources":["../../src/clients/grpcHandler.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAsC,MAAM,iCAAiC,CAAC;AAC1G,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAEhE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EAAE,mCAAmC,EAAE,MAAM,iDAAiD,CAAC;AAEtG,OAAO,EACH,iCAAiC,EACjC,8BAA8B,GACjC,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oDAAoD,CAAC;AAgBvF,MAAM,CAAC,MAAM,sBAAsB,GAAG,WAAW,CAAC;AAUlD,SAAS,mBAAmB,CAAC,MAAc;IACvC,OAAO,CACH,MAAM,KAAK,iBAAiB,CAAC,OAAO,CAAC,qBAAqB,CAAC,IAAI;QAC/D,MAAM,KAAK,iBAAiB,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAC9D,CAAC;AACN,CAAC;AAQD,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CACxC,oBAAoB,EACpB,CAAC,kBAAkB,EAAE,mCAAmC,CAAC,KAAK,EAAE,8BAA8B,CAAC,KAAK,CAAU,EA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K,EAAE,CAAC,QAAQ,EAAE,EAAE;oBAChB,IAAI,eAAe,CAAC,QAAQ,CAAC,EAAE;wBAC3B,OAAO,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;qBACzB;yBAAM;wBACH,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC;qBAC1B;gBACL,CAAC;gBACD,SAAS;aACZ,CACJ,CAAC;QACN,CAAC,CAAC,CAAA;MAAA,CAAC;AACX,CAAC,CACJ,CAAC;AAEF,SAAS,eAAe,CACpB,KAA6C;IAE7C,OAAO,KAAK,CAAC,MAAM,KAAK,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;AACzC,CAAC","sourcesContent":["import { grpc } from \"@improbable-eng/grpc-web\";\nimport { HandlerChainBuilder, type Handler, type RequestMetadata } from \"../handlers/HandlerChainBuilder\";\nimport { Injectable } from \"../dependency-injection/Injectable\";\nimport type { CameraKitConfiguration } from \"../configuration\";\nimport { configurationToken } from \"../configuration\";\nimport type { Result } from \"../common/result\";\nimport { Err, Ok } from \"../common/result\";\nimport type { FetchHandler } from \"../handlers/defaultFetchHandler\";\nimport { cameraKitServiceFetchHandlerFactory } from \"../handlers/cameraKitServiceFetchHandlerFactory\";\nimport type { RequestStateEventTarget } from \"../handlers/requestStateEmittingHandler\";\nimport {\n createRequestStateEmittingHandler,\n requestStateEventTargetFactory,\n} from \"../handlers/requestStateEmittingHandler\";\nimport { MetricsDefinition } from \"../generated-proto/pb_schema/camera_kit/v3/service\";\n\nexport interface GrpcRequest {\n serviceName: string;\n methodName: string;\n requestType: grpc.ProtobufMessageClass<grpc.ProtobufMessage>;\n responseType: grpc.ProtobufMessageClass<grpc.ProtobufMessage>;\n}\n\nexport type GrpcHandler = Handler<GrpcRequest, GrpcResult, RequestMetadata>;\n\nexport type GrpcResult = Result<\n grpc.UnaryOutput<grpc.ProtobufMessage> & { status: grpc.Code.OK },\n grpc.UnaryOutput<grpc.ProtobufMessage>\n>;\n\nexport const GRPC_CALL_REQUEST_TYPE = \"grpc_call\";\n\nexport interface GrpcRequestDimensions extends Record<string, string> {\n requestType: typeof GRPC_CALL_REQUEST_TYPE;\n methodName: string;\n}\n\n/**\n * Returns true if the given string is the name of a metric gRPC method.\n */\nfunction isMetricsGrpcMethod(method: string) {\n return (\n method === MetricsDefinition.methods.setOperationalMetrics.name ||\n method === MetricsDefinition.methods.setBusinessEvents.name\n );\n}\n\n/**\n * An Injectable handler that can make requests to the CameraKit backend service via grpc-web. This handler can be\n * passed to {@link createTsProtoClient} to produce a well-typed service client.\n *\n * @internal\n */\nexport const grpcHandlerFactory = Injectable(\n \"grpcHandlerFactory\",\n [configurationToken, cameraKitServiceFetchHandlerFactory.token, requestStateEventTargetFactory.token] as const,\n (\n configuration: CameraKitConfiguration,\n fetchHandler: FetchHandler,\n requestStateEventTarget: RequestStateEventTarget\n ): GrpcHandler => {\n const host = `https://${configuration.apiHostname}`;\n\n const fetchHandlerWithMetrics = new HandlerChainBuilder(fetchHandler).map(\n // TODO: ideally we don't need it here: https://jira.sc-corp.net/browse/CAMKIT-6350\n createRequestStateEmittingHandler<GrpcRequestDimensions>(requestStateEventTarget)\n ).handler;\n\n // We define our own Transport so that we can use our custom `fetch` implementation. This is important for two\n // reasons:\n // 1. Our custom fetch includes features like retries that we want to use for these requests.\n // 2. Applications may override this fetch implementation (via our DI system) to support more advanced\n // use-cases.\n const transport: grpc.TransportFactory = (options) => {\n let metadata: grpc.Metadata | undefined = undefined;\n const controller = globalThis.AbortController ? new AbortController() : undefined;\n let cancelled = false;\n return {\n sendMessage(msgBytes) {\n const requestInit = {\n headers: metadata?.toHeaders() ?? {},\n method: \"POST\",\n body: msgBytes,\n signal: controller?.signal,\n };\n const metricsDimensions: GrpcRequestDimensions = {\n requestType: GRPC_CALL_REQUEST_TYPE,\n methodName: options.methodDefinition.methodName,\n };\n // Note: Currently, we do not report network metrics for the metrics requests\n // themselves because that triggers an infinite loop of metrics reporting. Ideally,\n // we still want to report them, but attach them to the next metrics request without\n // triggering it.\n const request = isMetricsGrpcMethod(options.methodDefinition.methodName)\n ? fetchHandler(options.url, requestInit)\n : fetchHandlerWithMetrics([options.url, metricsDimensions], requestInit);\n request\n .then((response) => {\n options.onHeaders(new grpc.Metadata(response.headers), response.status);\n return response.arrayBuffer();\n })\n .then((body) => {\n if (cancelled) return;\n options.onChunk(new Uint8Array(body));\n options.onEnd();\n })\n .catch((error) => {\n if (cancelled) return;\n cancelled = true;\n options.onEnd(error);\n });\n },\n\n start(m) {\n metadata = m;\n },\n\n finishSend() {},\n\n cancel() {\n if (cancelled) return;\n cancelled = true;\n controller?.abort();\n },\n };\n };\n\n return async (request) =>\n new Promise((resolve) => {\n grpc.unary(\n {\n methodName: request.methodName,\n service: { serviceName: request.serviceName },\n requestStream: false,\n responseStream: false,\n requestType: request.requestType,\n responseType: request.responseType,\n },\n {\n request: new request.requestType(),\n host,\n onEnd: (response) => {\n if (isUnaryOutputOk(response)) {\n resolve(Ok(response));\n } else {\n resolve(Err(response));\n }\n },\n transport,\n }\n );\n });\n }\n);\n\nfunction isUnaryOutputOk(\n value: grpc.UnaryOutput<grpc.ProtobufMessage>\n): value is grpc.UnaryOutput<grpc.ProtobufMessage> & { status: grpc.Code.OK } {\n return value.status === grpc.Code.OK;\n}\n"]}
@@ -24,12 +24,14 @@ import type { lensesClientFactory } from "../clients/lensesClient";
24
24
  import type { pageVisibilityFactory } from "../common/pageVisibility";
25
25
  import type { remoteApiServicesFactory } from "../extensions/RemoteApiServices";
26
26
  import type { grpcHandlerFactory } from "../clients/grpcHandler";
27
+ import type { filePickerFactory } from "../lens-client-interface/filePicker";
27
28
  import type { ServicesFromInjectables } from "./types";
28
29
  /**
29
30
  * All services available to be customized by client app.
30
31
  */
31
32
  export type PublicServices = ServicesFromInjectables<[
32
33
  ReturnType<typeof createCameraKitConfigurationFactory>,
34
+ typeof filePickerFactory,
33
35
  typeof defaultFetchHandlerFactory,
34
36
  typeof remoteMediaAssetLoaderFactory,
35
37
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iCAAiC;IACxC,OAAO,wBAAwB;IAC/B,OAAO,iBAAiB;IACxB,OAAO,kBAAkB;IACzB,OAAO,iBAAiB;IACxB,OAAO,qBAAqB;CAC/B,CACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"RootServices.js","sourceRoot":"","sources":["../../src/dependency-injection/RootServices.ts"],"names":[],"mappings":"","sourcesContent":["import type { lensRepositoryFactory } from \"../lens/LensRepository\";\nimport type { lensCoreFactory } from \"../lens-core-module/loader/lensCoreFactory\";\nimport type { remoteMediaAssetLoaderFactory } from \"../lens/assets/remoteMediaAssetLoaderFactory\";\nimport type { deviceDependentAssetLoaderFactory } from \"../lens/assets/deviceDependentAssetLoader\";\nimport type { staticAssetLoaderFactory } from \"../lens/assets/staticAssetLoader\";\nimport type { defaultFetchHandlerFactory } from \"../handlers/defaultFetchHandler\";\nimport type { cameraKitServiceFetchHandlerFactory } from \"../handlers/cameraKitServiceFetchHandlerFactory\";\nimport type { createCameraKitConfigurationFactory } from \"../configuration\";\nimport type { externalMetricsSubjectFactory, metricsClientFactory } from \"../clients/metricsClient\";\nimport type { LensCore } from \"../lens-core-module/lensCore\";\nimport type { metricsEventTargetFactory } from \"../metrics/metricsEventTarget\";\nimport type { lensSourcesFactory } from \"../lens/LensSource\";\nimport type { uriHandlersFactory } from \"../extensions/UriHandlers\";\nimport type { lensPersistenceStoreFactory } from \"../lens/LensPersistenceStore\";\nimport type { cofHandlerFactory } from \"../remote-configuration/cofHandler\";\nimport type { remoteConfigurationFactory } from \"../remote-configuration/remoteConfiguration\";\nimport type { lensAssetRepositoryFactory } from \"../lens/assets/LensAssetRepository\";\nimport type { legalStateFactory } from \"../legal/legalState\";\nimport type { legalPromptFactory } from \"../legal/legalPrompt\";\nimport type { logEntriesFactory } from \"../logger/logEntries\";\nimport type { reportGlobalException } from \"../metrics/reporters/reportGlobalException\";\nimport type { requestStateEventTargetFactory } from \"../handlers/requestStateEmittingHandler\";\nimport type { lensesClientFactory } from \"../clients/lensesClient\";\nimport type { pageVisibilityFactory } from \"../common/pageVisibility\";\nimport type { remoteApiServicesFactory } from \"../extensions/RemoteApiServices\";\nimport type { grpcHandlerFactory } from \"../clients/grpcHandler\";\nimport type { 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 defaultFetchHandlerFactory,\n typeof remoteMediaAssetLoaderFactory,\n typeof lensSourcesFactory,\n typeof remoteApiServicesFactory,\n typeof uriHandlersFactory,\n typeof externalMetricsSubjectFactory\n ]\n>;\n\n/**\n * Define all the Services contained in CameraKit's root dependency injection container.\n *\n * Note: we do end up defining this list of Services twice (once here to create the type, once when we actually\n * create the Container inside the `bootstrapCameraKit` function). We could avoid doing this and just infer the\n * RootContainer type from the constructed container – but since we can only do that *inside* `bootstrapCameraKit`, it\n * makes it more awkward to provide a type for the `provide` user-supplied function (or use the type elsewhere, like in\n * CameraKitSession).\n *\n * There may be a way to eliminate this extra boilerplate, but for now it's required in order to present a cleaner\n * `bootstrapCameraKit` API to applications.\n */\nexport type RootServices = {\n // bootstrapCameraKit replaces the lensCoreFactory token's value with the resolved LensCore (rather than the\n // Promise of the LensCore), so we need to do the same re-mapping here.\n [lensCoreFactory.token]: LensCore;\n} & PublicServices &\n ServicesFromInjectables<\n [\n typeof pageVisibilityFactory,\n typeof metricsEventTargetFactory,\n typeof requestStateEventTargetFactory,\n typeof cameraKitServiceFetchHandlerFactory,\n typeof grpcHandlerFactory,\n typeof lensesClientFactory,\n typeof cofHandlerFactory,\n typeof remoteConfigurationFactory,\n typeof lensRepositoryFactory,\n typeof lensPersistenceStoreFactory,\n typeof metricsClientFactory,\n typeof lensAssetRepositoryFactory,\n typeof deviceDependentAssetLoaderFactory,\n typeof staticAssetLoaderFactory,\n typeof legalStateFactory,\n typeof legalPromptFactory,\n typeof logEntriesFactory,\n typeof reportGlobalException\n ]\n >;\n"]}
1
+ {"version":3,"file":"RootServices.js","sourceRoot":"","sources":["../../src/dependency-injection/RootServices.ts"],"names":[],"mappings":"","sourcesContent":["import type { lensRepositoryFactory } from \"../lens/LensRepository\";\nimport type { lensCoreFactory } from \"../lens-core-module/loader/lensCoreFactory\";\nimport type { remoteMediaAssetLoaderFactory } from \"../lens/assets/remoteMediaAssetLoaderFactory\";\nimport type { deviceDependentAssetLoaderFactory } from \"../lens/assets/deviceDependentAssetLoader\";\nimport type { staticAssetLoaderFactory } from \"../lens/assets/staticAssetLoader\";\nimport type { defaultFetchHandlerFactory } from \"../handlers/defaultFetchHandler\";\nimport type { cameraKitServiceFetchHandlerFactory } from \"../handlers/cameraKitServiceFetchHandlerFactory\";\nimport type { createCameraKitConfigurationFactory } from \"../configuration\";\nimport type { externalMetricsSubjectFactory, metricsClientFactory } from \"../clients/metricsClient\";\nimport type { LensCore } from \"../lens-core-module/lensCore\";\nimport type { metricsEventTargetFactory } from \"../metrics/metricsEventTarget\";\nimport type { lensSourcesFactory } from \"../lens/LensSource\";\nimport type { uriHandlersFactory } from \"../extensions/UriHandlers\";\nimport type { lensPersistenceStoreFactory } from \"../lens/LensPersistenceStore\";\nimport type { cofHandlerFactory } from \"../remote-configuration/cofHandler\";\nimport type { remoteConfigurationFactory } from \"../remote-configuration/remoteConfiguration\";\nimport type { lensAssetRepositoryFactory } from \"../lens/assets/LensAssetRepository\";\nimport type { legalStateFactory } from \"../legal/legalState\";\nimport type { legalPromptFactory } from \"../legal/legalPrompt\";\nimport type { logEntriesFactory } from \"../logger/logEntries\";\nimport type { reportGlobalException } from \"../metrics/reporters/reportGlobalException\";\nimport type { requestStateEventTargetFactory } from \"../handlers/requestStateEmittingHandler\";\nimport type { lensesClientFactory } from \"../clients/lensesClient\";\nimport type { pageVisibilityFactory } from \"../common/pageVisibility\";\nimport type { remoteApiServicesFactory } from \"../extensions/RemoteApiServices\";\nimport type { grpcHandlerFactory } from \"../clients/grpcHandler\";\nimport type { filePickerFactory } from \"../lens-client-interface/filePicker\";\nimport type { 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 filePickerFactory,\n typeof defaultFetchHandlerFactory,\n typeof remoteMediaAssetLoaderFactory,\n typeof lensSourcesFactory,\n typeof remoteApiServicesFactory,\n typeof uriHandlersFactory,\n typeof externalMetricsSubjectFactory\n ]\n>;\n\n/**\n * Define all the Services contained in CameraKit's root dependency injection container.\n *\n * Note: we do end up defining this list of Services twice (once here to create the type, once when we actually\n * create the Container inside the `bootstrapCameraKit` function). We could avoid doing this and just infer the\n * RootContainer type from the constructed container – but since we can only do that *inside* `bootstrapCameraKit`, it\n * makes it more awkward to provide a type for the `provide` user-supplied function (or use the type elsewhere, like in\n * CameraKitSession).\n *\n * There may be a way to eliminate this extra boilerplate, but for now it's required in order to present a cleaner\n * `bootstrapCameraKit` API to applications.\n */\nexport type RootServices = {\n // bootstrapCameraKit replaces the lensCoreFactory token's value with the resolved LensCore (rather than the\n // Promise of the LensCore), so we need to do the same re-mapping here.\n [lensCoreFactory.token]: LensCore;\n} & PublicServices &\n ServicesFromInjectables<\n [\n typeof pageVisibilityFactory,\n typeof metricsEventTargetFactory,\n typeof requestStateEventTargetFactory,\n typeof cameraKitServiceFetchHandlerFactory,\n typeof grpcHandlerFactory,\n typeof lensesClientFactory,\n typeof cofHandlerFactory,\n typeof remoteConfigurationFactory,\n typeof lensRepositoryFactory,\n typeof lensPersistenceStoreFactory,\n typeof metricsClientFactory,\n typeof lensAssetRepositoryFactory,\n typeof deviceDependentAssetLoaderFactory,\n typeof staticAssetLoaderFactory,\n typeof legalStateFactory,\n typeof legalPromptFactory,\n typeof logEntriesFactory,\n typeof reportGlobalException\n ]\n >;\n"]}
@@ -1,2 +1,2 @@
1
- export default { PACKAGE_VERSION: "0.18.1" };
1
+ export default { PACKAGE_VERSION: "0.20.0" };
2
2
  //# sourceMappingURL=environment.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"environment.js","sourceRoot":"","sources":["../src/environment.ts"],"names":[],"mappings":"AAAA,eAAe,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC","sourcesContent":["export default { PACKAGE_VERSION: \"0.18.1\" };\n"]}
1
+ {"version":3,"file":"environment.js","sourceRoot":"","sources":["../src/environment.ts"],"names":[],"mappings":"AAAA,eAAe,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC","sourcesContent":["export default { PACKAGE_VERSION: \"0.20.0\" };\n"]}
package/dist/index.d.ts CHANGED
@@ -40,4 +40,5 @@ export { TypedEventTarget } from "./events/TypedEventTarget";
40
40
  export { namedError } from "./namedErrors";
41
41
  export { Any } from "./generated-proto/pb_schema/google/protobuf/any";
42
42
  export { LensCore } from "./lens-core-module/lensCore";
43
+ export { FilePickerOptions, FilePickerResult, FilePicker, filePickerFactory } from "./lens-client-interface/filePicker";
43
44
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,sBAAsB,EAAE,+BAA+B,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC9G,OAAO,EACH,uBAAuB,EACvB,wBAAwB,EACxB,sBAAsB,GACzB,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5F,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EACH,GAAG,EACH,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,UAAU,EACV,WAAW,E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AO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,GAAG,EAAE,MAAM,iDAAiD,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC"}
package/dist/index.js CHANGED
@@ -32,4 +32,5 @@ export { TypedCustomEvent } from "./events/TypedCustomEvent";
32
32
  export { TypedEventTarget } from "./events/TypedEventTarget";
33
33
  export { namedError } from "./namedErrors";
34
34
  export { Any } from "./generated-proto/pb_schema/google/protobuf/any";
35
+ export { filePickerFactory } from "./lens-client-interface/filePicker";
35
36
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAA2D,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC9G,OAAO,EACH,uBAAuB,GAG1B,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAmB,MAAM,sBAAsB,CAAC;AAE5F,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAC/E,OAAO,EAAc,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAOH,kBAAkB,GACrB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAQH,wBAAwB,GAC3B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,SAAS,EAA2C,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,6BAA6B,EAAE,MAAM,yBAAyB,CAAC;AACxE,OAAO,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AACpD,OAA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E,MAAM,iDAAiD,CAAC","sourcesContent":["export { Keyboard, KeyboardEvents } from \"./session/LensKeyboard\";\nexport { CameraKitConfiguration, CameraKitBootstrapConfiguration, configurationToken } from \"./configuration\";\nexport {\n estimateLensPerformance,\n EstimatedLensPerformance,\n LensPerformanceCluster,\n} from \"./benchmark/estimateLensPerformanceCluster\";\nexport { createExtension, bootstrapCameraKit, PublicContainer } from \"./bootstrapCameraKit\";\nexport { PublicServices } from \"./dependency-injection/RootServices\";\nexport { extensionRequestContext } from \"./extensions/extensionRequestContext\";\nexport { LensSource, lensSourcesFactory } from \"./lens/LensSource\";\nexport {\n Uri,\n UriRequest,\n UriResponse,\n UriCancelRequest,\n UriHandler,\n UriHandlers,\n uriHandlersFactory,\n} from \"./extensions/UriHandlers\";\nexport {\n RemoteApiCancelRequestHandler,\n RemoteApiRequest,\n RemoteApiRequestHandler,\n RemoteApiResponse,\n RemoteApiService,\n RemoteApiServices,\n RemoteApiStatus,\n remoteApiServicesFactory,\n} from \"./extensions/RemoteApiServices\";\nexport { CameraKit, CreateSessionOptions, LensMetricsEvents } from \"./CameraKit\";\nexport { externalMetricsSubjectFactory } from \"./clients/metricsClient\";\nexport { Count } from \"./metrics/operational/Count\";\nexport { Histogram } from \"./metrics/operational/Histogram\";\nexport { Metric } from \"./metrics/operational/Metric\";\nexport { Timer } from \"./metrics/operational/Timer\";\nexport { LensView } from \"./metrics/reporters/reportLensView\";\nexport { LensWait } from \"./metrics/reporters/reportLensWait\";\nexport { Lens, toPublicLens, Snapcode, Preview, Lens_CameraFacing, LensCreator } from \"./lens/Lens\";\nexport { AssetTiming, LensRepository } from \"./lens/LensRepository\";\nexport {\n LensLaunchData,\n LensUserData,\n BitmojiUserInfo,\n FriendUserInfo,\n LensLaunchParams,\n Zodiac,\n} from \"./lens/LensLaunchData\";\nexport { AssetLoader, LoadAssetRequest, AssetResponse } from \"./lens/assets/LensAssetRepository\";\nexport { defaultFetchHandlerFactory, FetchHandler } from \"./handlers/defaultFetchHandler\";\nexport { remoteMediaAssetLoaderFactory } from \"./lens/assets/remoteMediaAssetLoaderFactory\";\nexport {\n CameraKitSource,\n CameraKitSourceInfo,\n CameraKitDeviceOptions,\n CameraKitSourceSubscriber,\n} from \"./media-sources/CameraKitSource\";\nexport { createMediaStreamSource, MediaStreamSourceOptions } from \"./media-sources/MediaStreamSource\";\nexport {\n createFunctionSource,\n FrameFormat,\n FrameInput,\n FrameOutput,\n FunctionSourceOptions,\n MediaSourceFunction,\n} from \"./media-sources/FunctionSource\";\nexport { createVideoSource, VideoSourceOptions } from \"./media-sources/VideoSource\";\nexport { createImageSource } from \"./media-sources/ImageSource\";\nexport { RenderTarget, CameraKitSession } from \"./session/CameraKitSession\";\nexport { CameraKitSessionEvents, CameraKitSessionEventListener } from \"./session/CameraKitSessionEvents\";\nexport { Container } from \"./dependency-injection/Container\";\nexport { Injectable, ConcatInjectable } from \"./dependency-injection/Injectable\";\nexport { PartialContainer } from \"./dependency-injection/PartialContainer\";\nexport { Transform2D, Matrix } from \"./transforms/Transform2D\";\nexport * from \"./namedErrors\";\nexport { LensPerformanceMeasurement, ComputedFrameMetrics } from \"./session/LensPerformanceMeasurement\";\nexport { LensPerformanceMetrics } from \"./session/LensPerformanceMetrics\";\nexport { TypedCustomEvent } from \"./events/TypedCustomEvent\";\nexport { TypedEventTarget } from \"./events/TypedEventTarget\";\nexport { namedError } from \"./namedErrors\";\nexport { Any } from \"./generated-proto/pb_schema/google/protobuf/any\";\nexport { LensCore } from \"./lens-core-module/lensCore\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAA2D,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC9G,OAAO,EACH,uBAAuB,GAG1B,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAmB,MAAM,sBAAsB,CAAC;AAE5F,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC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A0B,CAAC;AAC/D,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,0BAA0B,EAAwB,MAAM,sCAAsC,CAAC;AACxG,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,GAAG,EAAE,MAAM,iDAAiD,CAAC;AAGtE,OAAO,EAAmD,iBAAiB,EAAE,MAAM,oCAAoC,CAAC","sourcesContent":["export { Keyboard, KeyboardEvents } from \"./session/LensKeyboard\";\nexport { CameraKitConfiguration, CameraKitBootstrapConfiguration, configurationToken } from \"./configuration\";\nexport {\n estimateLensPerformance,\n EstimatedLensPerformance,\n LensPerformanceCluster,\n} from \"./benchmark/estimateLensPerformanceCluster\";\nexport { createExtension, bootstrapCameraKit, PublicContainer } from \"./bootstrapCameraKit\";\nexport { PublicServices } from \"./dependency-injection/RootServices\";\nexport { extensionRequestContext } from \"./extensions/extensionRequestContext\";\nexport { LensSource, lensSourcesFactory } from \"./lens/LensSource\";\nexport {\n Uri,\n UriRequest,\n UriResponse,\n UriCancelRequest,\n UriHandler,\n UriHandlers,\n uriHandlersFactory,\n} from \"./extensions/UriHandlers\";\nexport {\n RemoteApiCancelRequestHandler,\n RemoteApiRequest,\n RemoteApiRequestHandler,\n RemoteApiResponse,\n RemoteApiService,\n RemoteApiServices,\n RemoteApiStatus,\n remoteApiServicesFactory,\n} from \"./extensions/RemoteApiServices\";\nexport { CameraKit, CreateSessionOptions, LensMetricsEvents } from \"./CameraKit\";\nexport { externalMetricsSubjectFactory } from \"./clients/metricsClient\";\nexport { Count } from \"./metrics/operational/Count\";\nexport { Histogram } from \"./metrics/operational/Histogram\";\nexport { Metric } from \"./metrics/operational/Metric\";\nexport { Timer } from \"./metrics/operational/Timer\";\nexport { LensView } from \"./metrics/reporters/reportLensView\";\nexport { LensWait } from \"./metrics/reporters/reportLensWait\";\nexport { Lens, toPublicLens, Snapcode, Preview, Lens_CameraFacing, LensCreator } from \"./lens/Lens\";\nexport { AssetTiming, LensRepository } from \"./lens/LensRepository\";\nexport {\n LensLaunchData,\n LensUserData,\n BitmojiUserInfo,\n FriendUserInfo,\n LensLaunchParams,\n Zodiac,\n} from \"./lens/LensLaunchData\";\nexport { AssetLoader, LoadAssetRequest, AssetResponse } from \"./lens/assets/LensAssetRepository\";\nexport { defaultFetchHandlerFactory, FetchHandler } from \"./handlers/defaultFetchHandler\";\nexport { remoteMediaAssetLoaderFactory } from \"./lens/assets/remoteMediaAssetLoaderFactory\";\nexport {\n CameraKitSource,\n CameraKitSourceInfo,\n CameraKitDeviceOptions,\n CameraKitSourceSubscriber,\n} from \"./media-sources/CameraKitSource\";\nexport { createMediaStreamSource, MediaStreamSourceOptions } from \"./media-sources/MediaStreamSource\";\nexport {\n createFunctionSource,\n FrameFormat,\n FrameInput,\n FrameOutput,\n FunctionSourceOptions,\n MediaSourceFunction,\n} from \"./media-sources/FunctionSource\";\nexport { createVideoSource, VideoSourceOptions } from \"./media-sources/VideoSource\";\nexport { createImageSource } from \"./media-sources/ImageSource\";\nexport { RenderTarget, CameraKitSession } from \"./session/CameraKitSession\";\nexport { CameraKitSessionEvents, CameraKitSessionEventListener } from \"./session/CameraKitSessionEvents\";\nexport { Container } from \"./dependency-injection/Container\";\nexport { Injectable, ConcatInjectable } from \"./dependency-injection/Injectable\";\nexport { PartialContainer } from \"./dependency-injection/PartialContainer\";\nexport { Transform2D, Matrix } from \"./transforms/Transform2D\";\nexport * from \"./namedErrors\";\nexport { LensPerformanceMeasurement, ComputedFrameMetrics } from \"./session/LensPerformanceMeasurement\";\nexport { LensPerformanceMetrics } from \"./session/LensPerformanceMetrics\";\nexport { TypedCustomEvent } from \"./events/TypedCustomEvent\";\nexport { TypedEventTarget } from \"./events/TypedEventTarget\";\nexport { namedError } from \"./namedErrors\";\nexport { Any } from \"./generated-proto/pb_schema/google/protobuf/any\";\nexport { LensCore } from \"./lens-core-module/lensCore\";\n\nexport { FilePickerOptions, FilePickerResult, FilePicker, filePickerFactory } from \"./lens-client-interface/filePicker\";\n"]}
@@ -0,0 +1,31 @@
1
+ import type { FileWithHandle, fileOpen } from "browser-fs-access";
2
+ /**
3
+ * Default file picker dialog type.
4
+ */
5
+ export type OpenDefaultFilePicker = typeof fileOpen;
6
+ /**
7
+ * File picker options. For example, it indicates which MIME types of files are expected to be picked.
8
+ */
9
+ export type FilePickerOptions = Parameters<OpenDefaultFilePicker>[0];
10
+ /**
11
+ * File picker dialog result object, which is a Promise that resolves to a file or an array of files with handles.
12
+ */
13
+ export type FilePickerResult = Promise<FileWithHandle | FileWithHandle[]>;
14
+ /**
15
+ * A callback to show a file picker dialog.
16
+ * @param options - Options for the file picker dialog.
17
+ * @param openDefaultPicker - The default file picker function. The client app may choose to use
18
+ * the default file picker.
19
+ * @returns A promise that resolves to the result of the file picker dialog.
20
+ */
21
+ export type FilePicker = (options: FilePickerOptions, openDefaultPicker: OpenDefaultFilePicker) => FilePickerResult;
22
+ /**
23
+ * Default file picker factory function. The file picker is triggered when a lens issues a file request.
24
+ * Client applications can override this factory function to provide their custom file picker.
25
+ */
26
+ export declare const filePickerFactory: {
27
+ (): FilePicker;
28
+ token: "filePicker";
29
+ dependencies: [];
30
+ };
31
+ //# sourceMappingURL=filePicker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filePicker.d.ts","sourceRoot":"","sources":["../../src/lens-client-interface/filePicker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGlE;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,OAAO,QAAQ,CAAC;AAEpD;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC;AAErE;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC,cAAc,GAAG,cAAc,EAAE,CAAC,CAAC;AAE1E;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,qBAAqB,KAAK,gBAAgB,CAAC;AAEpH;;;GAGG;AACH,eAAO,MAAM,iBAAiB;;;;CAG7B,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Injectable } from "../dependency-injection/Injectable";
2
+ export const filePickerFactory = Injectable("filePicker", () => (options, openDefaultPicker) => openDefaultPicker(options));
3
+ //# sourceMappingURL=filePicker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filePicker.js","sourceRoot":"","sources":["../../src/lens-client-interface/filePicker.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AA8BhE,MAAM,CAAC,MAAM,iBAAiB,GAAG,UAAU,CACvC,YAAY,EACZ,GAAe,EAAE,CAAC,CAAC,OAAO,EAAE,iBAAiB,EAAE,EAAE,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAC/E,CAAC","sourcesContent":["import type { FileWithHandle, fileOpen } from \"browser-fs-access\";\nimport { Injectable } from \"../dependency-injection/Injectable\";\n\n/**\n * Default file picker dialog type.\n */\nexport type OpenDefaultFilePicker = typeof fileOpen;\n\n/**\n * File picker options. For example, it indicates which MIME types of files are expected to be picked.\n */\nexport type FilePickerOptions = Parameters<OpenDefaultFilePicker>[0];\n\n/**\n * File picker dialog result object, which is a Promise that resolves to a file or an array of files with handles.\n */\nexport type FilePickerResult = Promise<FileWithHandle | FileWithHandle[]>;\n\n/**\n * A callback to show a file picker dialog.\n * @param options - Options for the file picker dialog.\n * @param openDefaultPicker - The default file picker function. The client app may choose to use\n * the default file picker.\n * @returns A promise that resolves to the result of the file picker dialog.\n */\nexport type FilePicker = (options: FilePickerOptions, openDefaultPicker: OpenDefaultFilePicker) => FilePickerResult;\n\n/**\n * Default file picker factory function. The file picker is triggered when a lens issues a file request.\n * Client applications can override this factory function to provide their custom file picker.\n */\nexport const filePickerFactory = Injectable(\n \"filePicker\",\n (): FilePicker => (options, openDefaultPicker) => openDefaultPicker(options)\n);\n"]}
@@ -1,9 +1,10 @@
1
1
  import type { ClientInterfaceData } from "../lens-core-module/generated-types";
2
2
  import type { LensCore } from "../lens-core-module/lensCore";
3
+ import type { FilePicker } from "./filePicker";
3
4
  /**
4
5
  * Shows file open dialog to allow user to select image/video and provides the selection to LensCore.
5
6
  *
6
7
  * @internal
7
8
  */
8
- export declare function pickClientImage(clientInterfaceData: ClientInterfaceData, lensCore: LensCore): Promise<void>;
9
+ export declare function pickClientImage(clientInterfaceData: ClientInterfaceData, lensCore: LensCore, filePicker: FilePicker): Promise<void>;
9
10
  //# sourceMappingURL=imagePicker.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"imagePicker.d.ts","sourceRoot":"","sources":["../../src/lens-client-interface/imagePicker.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAoF7D;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,mBAAmB,EAAE,mBAAmB,EAAE,QAAQ,EAAE,QAAQ,iBAqCjG"}
1
+ {"version":3,"file":"imagePicker.d.ts","sourceRoot":"","sources":["../../src/lens-client-interface/imagePicker.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAE7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAmF/C;;;;GAIG;AACH,wBAAsB,eAAe,CACjC,mBAAmB,EAAE,mBAAmB,EACxC,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,UAAU,iBAyCzB"}
@@ -73,15 +73,18 @@ function getOrientation(data, lensCore) {
73
73
  return orientationMap[(_a = extractJpegOrientationTag(data)) !== null && _a !== void 0 ? _a : 1];
74
74
  }
75
75
  catch (error) {
76
- logger.info("Error occured while reading EXIF orientation tag.", error);
76
+ logger.info("Error occurred while reading EXIF orientation tag.", error);
77
77
  return lensCore.ExternalMediaOrientation.CW0;
78
78
  }
79
79
  }
80
- export function pickClientImage(clientInterfaceData, lensCore) {
80
+ export function pickClientImage(clientInterfaceData, lensCore, filePicker) {
81
81
  return __awaiter(this, void 0, void 0, function* () {
82
82
  const mimeTypes = getMimeType(clientInterfaceData);
83
83
  logger.debug(`Opening file dialog for MIME types: ${mimeTypes}`);
84
- const file = yield fileOpen({ mimeTypes });
84
+ const file = yield filePicker({ mimeTypes }, fileOpen);
85
+ if (Array.isArray(file)) {
86
+ throw new Error("Multiple files are not supported.");
87
+ }
85
88
  logger.debug(`Selected file MIME type: ${file.type}`);
86
89
  const data = yield readFileAsArrayBuffer(file);
87
90
  if (file.type.startsWith("image/")) {
@@ -1 +1 @@
1
- {"version":3,"file":"imagePicker.js","sourceRoot":"","sources":["../../src/lens-client-interface/imagePicker.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAG7C,OAAO,EAAE,yBAAyB,EAAe,MAAM,QAAQ,CAAC;AAEhE,MAAM,MAAM,GAAG,SAAS,CAAC,gCAAgC,CAAC,CAAC;AAI3D,MAAM,SAAS,GAAG;IACd,KAAK,EAAE;QACH,YAAY;QACZ,WAAW;QACX,WAAW;QACX,YAAY;QACZ,WAAW;QACX,eAAe;QACf,YAAY;QACZ,YAAY;KACf;IACD,KAAK,EAAE;QACH,YAAY;QACZ,aAAa;QACb,YAAY;QACZ,WAAW;QACX,YAAY;QACZ,WAAW;QACX,iBAAiB;QAC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AI,EAAE,CAAC,CAAC;QAEtD,MAAM,IAAI,GAAG,MAAM,qBAAqB,CAAC,IAAI,CAAC,CAAC;QAC/C,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;YAChC,QAAQ,CAAC,oBAAoB,CAAC;gBAC1B,IAAI;gBACJ,WAAW,EAAE,cAAc,CAAC,IAAI,EAAE,QAAQ,CAAC;gBAO3C,SAAS,EAAE;oBACP;wBACI,MAAM,EAAE;4BACJ,CAAC,EAAE,CAAC;4BACJ,CAAC,EAAE,CAAC;yBACP;wBACD,IAAI,EAAE;4BACF,KAAK,EAAE,CAAC;4BACR,MAAM,EAAE,CAAC;yBACZ;qBACJ;iBACJ;aACJ,CAAC,CAAC;SACN;aAAM;YACH,QAAQ,CAAC,oBAAoB,CAAC;gBAC1B,IAAI;gBACJ,WAAW,EAAE,QAAQ,CAAC,wBAAwB,CAAC,GAAG;aACrD,CAAC,CAAC;SACN;IACL,CAAC;CAAA","sourcesContent":["import type { FileWithHandle } from \"browser-fs-access\";\nimport { fileOpen } from \"browser-fs-access\";\nimport { getLogger } from \"../logger/logger\";\nimport type { ClientInterfaceData } from \"../lens-core-module/generated-types\";\nimport type { LensCore } from \"../lens-core-module/lensCore\";\nimport { extractJpegOrientationTag, Orientation } from \"./exif\";\n\nconst logger = getLogger(\"lensClientInterfaceImagePicker\");\n\n// Common MIME types supported by all browsers as per:\n// https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types\nconst mimeTypes = {\n image: [\n \"image/avif\",\n \"image/bmp\",\n \"image/gif\",\n \"image/jpeg\",\n \"image/png\",\n \"image/svg+xml\",\n \"image/tiff\",\n \"image/webp\",\n ],\n video: [\n \"video/3gpp\",\n \"video/3gpp2\",\n \"video/mp2t\",\n \"video/mp4\",\n \"video/mpeg\",\n \"video/ogg\",\n \"video/quicktime\",\n \"video/webm\",\n \"video/x-msvideo\",\n ],\n} as const;\n\nfunction* enumerateSupportedVideoTypes(types: typeof mimeTypes.video) {\n // test video element to perform MIME types support check\n const testVideoElement = typeof document !== \"undefined\" ? document.createElement(\"video\") : undefined;\n for (const type of types) {\n if (testVideoElement?.canPlayType(type) || false) {\n yield type;\n }\n }\n}\n\nfunction readFileAsArrayBuffer(file: FileWithHandle): Promise<ArrayBuffer> {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.addEventListener(\"load\", (event) => {\n // Safety: target.result is always an ArrayBuffer because we read file using readAsArrayBuffer()\n resolve(event.target!.result as ArrayBuffer);\n });\n reader.addEventListener(\"error\", (event) => {\n reject(event.target!.error);\n });\n reader.readAsArrayBuffer(file);\n });\n}\n\nfunction getMimeType({ ImageEnabled, VideoEnabled }: ClientInterfaceData) {\n const types = [];\n if (ImageEnabled === \"1\") types.push(...mimeTypes.image);\n if (VideoEnabled === \"1\") types.push(...enumerateSupportedVideoTypes(mimeTypes.video));\n if (types.length === 0) {\n throw new Error(\"Unknown media type requested.\");\n }\n return types;\n}\n\nfunction getOrientation(data: ArrayBuffer, lensCore: LensCore) {\n const orientationMap = {\n [Orientation.TopLeft]: lensCore.ExternalMediaOrientation.CW0,\n [Orientation.TopRight]: lensCore.ExternalMediaOrientation.CW0,\n [Orientation.BottomRight]: lensCore.ExternalMediaOrientation.CW180,\n [Orientation.BottomLeft]: lensCore.ExternalMediaOrientation.CW180,\n [Orientation.LeftTop]: lensCore.ExternalMediaOrientation.CW90,\n [Orientation.RightTop]: lensCore.ExternalMediaOrientation.CW90,\n [Orientation.RightBottom]: lensCore.ExternalMediaOrientation.CW270,\n [Orientation.LeftBottom]: lensCore.ExternalMediaOrientation.CW270,\n };\n try {\n return orientationMap[extractJpegOrientationTag(data) ?? Orientation.TopLeft];\n } catch (error) {\n logger.info(\"Error occured while reading EXIF orientation tag.\", error);\n return lensCore.ExternalMediaOrientation.CW0;\n }\n}\n\n/**\n * Shows file open dialog to allow user to select image/video and provides the selection to LensCore.\n *\n * @internal\n */\nexport async function pickClientImage(clientInterfaceData: ClientInterfaceData, lensCore: LensCore) {\n const mimeTypes = getMimeType(clientInterfaceData);\n logger.debug(`Opening file dialog for MIME types: ${mimeTypes}`);\n\n const file = await fileOpen({ mimeTypes });\n logger.debug(`Selected file MIME type: ${file.type}`);\n\n const data = await readFileAsArrayBuffer(file);\n if (file.type.startsWith(\"image/\")) {\n lensCore.provideExternalImage({\n data,\n orientation: getOrientation(data, lensCore),\n // As per Corvyn: both iOS and Android clients have the ability to pick out individual faces\n // from an image to apply the effect on, using each of their native face detectors (not using LensCore).\n // That's what the faceRects is for. For now, we can just apply the effect to the whole image (so face rect\n // [[0,0][1,1]]). In future, in order to be able to pick out individual faces in the media picker, we could:\n // - hook up some external web face tracking library\n // - make LensCore to expose face tracker to external clients\n faceRects: [\n {\n origin: {\n x: 0,\n y: 0,\n },\n size: {\n width: 1,\n height: 1,\n },\n },\n ],\n });\n } else {\n lensCore.provideExternalVideo({\n data,\n orientation: lensCore.ExternalMediaOrientation.CW0,\n });\n }\n}\n"]}
1
+ {"version":3,"file":"imagePicker.js","sourceRoot":"","sources":["../../src/lens-client-interface/imagePicker.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAG7C,OAAO,EAAE,yBAAyB,EAAe,MAAM,QAAQ,CAAC;AAGhE,MAAM,MAAM,GAAG,SAAS,CAAC,gCAAgC,CAAC,CAAC;AAI3D,MAAM,SAAS,GAAG;IACd,KAAK,EAAE;QACH,YAAY;QACZ,WAAW;QACX,WAAW;QACX,YAAY;QACZ,WAAW;QACX,eAAe;QACf,YAAY;QACZ,YAAY;KACf;IACD,KAAK,EAAE;QACH,YAAY;QACZ,aAAa;QACb,YAAY;QACZ,WAAW;QACX,YAAY;QACZ,WAAW;QACX,iBAAiB;QACjB,YAAY;QACZ,iBAAiB;KACpB;CACK,CAAC;AAEX,QAAQ,CAAC,CAAC,4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C,CAAC;SACxD;QACD,MAAM,CAAC,KAAK,CAAC,4BAA4B,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QAEtD,MAAM,IAAI,GAAG,MAAM,qBAAqB,CAAC,IAAI,CAAC,CAAC;QAC/C,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;YAChC,QAAQ,CAAC,oBAAoB,CAAC;gBAC1B,IAAI;gBACJ,WAAW,EAAE,cAAc,CAAC,IAAI,EAAE,QAAQ,CAAC;gBAO3C,SAAS,EAAE;oBACP;wBACI,MAAM,EAAE;4BACJ,CAAC,EAAE,CAAC;4BACJ,CAAC,EAAE,CAAC;yBACP;wBACD,IAAI,EAAE;4BACF,KAAK,EAAE,CAAC;4BACR,MAAM,EAAE,CAAC;yBACZ;qBACJ;iBACJ;aACJ,CAAC,CAAC;SACN;aAAM;YACH,QAAQ,CAAC,oBAAoB,CAAC;gBAC1B,IAAI;gBACJ,WAAW,EAAE,QAAQ,CAAC,wBAAwB,CAAC,GAAG;aACrD,CAAC,CAAC;SACN;IACL,CAAC;CAAA","sourcesContent":["import type { FileWithHandle } from \"browser-fs-access\";\nimport { fileOpen } from \"browser-fs-access\";\nimport { getLogger } from \"../logger/logger\";\nimport type { ClientInterfaceData } from \"../lens-core-module/generated-types\";\nimport type { LensCore } from \"../lens-core-module/lensCore\";\nimport { extractJpegOrientationTag, Orientation } from \"./exif\";\nimport type { FilePicker } from \"./filePicker\";\n\nconst logger = getLogger(\"lensClientInterfaceImagePicker\");\n\n// Common MIME types supported by all browsers as per:\n// https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types\nconst mimeTypes = {\n image: [\n \"image/avif\",\n \"image/bmp\",\n \"image/gif\",\n \"image/jpeg\",\n \"image/png\",\n \"image/svg+xml\",\n \"image/tiff\",\n \"image/webp\",\n ],\n video: [\n \"video/3gpp\",\n \"video/3gpp2\",\n \"video/mp2t\",\n \"video/mp4\",\n \"video/mpeg\",\n \"video/ogg\",\n \"video/quicktime\",\n \"video/webm\",\n \"video/x-msvideo\",\n ],\n} as const;\n\nfunction* enumerateSupportedVideoTypes(types: typeof mimeTypes.video) {\n // test video element to perform MIME types support check\n const testVideoElement = typeof document !== \"undefined\" ? document.createElement(\"video\") : undefined;\n for (const type of types) {\n if (testVideoElement?.canPlayType(type) || false) {\n yield type;\n }\n }\n}\n\nfunction readFileAsArrayBuffer(file: FileWithHandle): Promise<ArrayBuffer> {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.addEventListener(\"load\", (event) => {\n // Safety: target.result is always an ArrayBuffer because we read file using readAsArrayBuffer()\n resolve(event.target!.result as ArrayBuffer);\n });\n reader.addEventListener(\"error\", (event) => {\n reject(event.target!.error);\n });\n reader.readAsArrayBuffer(file);\n });\n}\n\nfunction getMimeType({ ImageEnabled, VideoEnabled }: ClientInterfaceData) {\n const types = [];\n if (ImageEnabled === \"1\") types.push(...mimeTypes.image);\n if (VideoEnabled === \"1\") types.push(...enumerateSupportedVideoTypes(mimeTypes.video));\n if (types.length === 0) {\n throw new Error(\"Unknown media type requested.\");\n }\n return types;\n}\n\nfunction getOrientation(data: ArrayBuffer, lensCore: LensCore) {\n const orientationMap = {\n [Orientation.TopLeft]: lensCore.ExternalMediaOrientation.CW0,\n [Orientation.TopRight]: lensCore.ExternalMediaOrientation.CW0,\n [Orientation.BottomRight]: lensCore.ExternalMediaOrientation.CW180,\n [Orientation.BottomLeft]: lensCore.ExternalMediaOrientation.CW180,\n [Orientation.LeftTop]: lensCore.ExternalMediaOrientation.CW90,\n [Orientation.RightTop]: lensCore.ExternalMediaOrientation.CW90,\n [Orientation.RightBottom]: lensCore.ExternalMediaOrientation.CW270,\n [Orientation.LeftBottom]: lensCore.ExternalMediaOrientation.CW270,\n };\n try {\n return orientationMap[extractJpegOrientationTag(data) ?? Orientation.TopLeft];\n } catch (error) {\n logger.info(\"Error occurred while reading EXIF orientation tag.\", error);\n return lensCore.ExternalMediaOrientation.CW0;\n }\n}\n\n/**\n * Shows file open dialog to allow user to select image/video and provides the selection to LensCore.\n *\n * @internal\n */\nexport async function pickClientImage(\n clientInterfaceData: ClientInterfaceData,\n lensCore: LensCore,\n filePicker: FilePicker\n) {\n const mimeTypes = getMimeType(clientInterfaceData);\n logger.debug(`Opening file dialog for MIME types: ${mimeTypes}`);\n\n const file = await filePicker({ mimeTypes }, fileOpen);\n if (Array.isArray(file)) {\n throw new Error(\"Multiple files are not supported.\");\n }\n logger.debug(`Selected file MIME type: ${file.type}`);\n\n const data = await readFileAsArrayBuffer(file);\n if (file.type.startsWith(\"image/\")) {\n lensCore.provideExternalImage({\n data,\n orientation: getOrientation(data, lensCore),\n // As per Corvyn: both iOS and Android clients have the ability to pick out individual faces\n // from an image to apply the effect on, using each of their native face detectors (not using LensCore).\n // That's what the faceRects is for. For now, we can just apply the effect to the whole image (so face rect\n // [[0,0][1,1]]). In future, in order to be able to pick out individual faces in the media picker, we could:\n // - hook up some external web face tracking library\n // - make LensCore to expose face tracker to external clients\n faceRects: [\n {\n origin: {\n x: 0,\n y: 0,\n },\n size: {\n width: 1,\n height: 1,\n },\n },\n ],\n });\n } else {\n lensCore.provideExternalVideo({\n data,\n orientation: lensCore.ExternalMediaOrientation.CW0,\n });\n }\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  import type { LensCore } from "../lens-core-module/lensCore";
2
+ import type { FilePicker } from "./filePicker";
2
3
  /**
3
4
  * Registers client interface handler in LensCore.
4
5
  *
@@ -7,8 +8,8 @@ import type { LensCore } from "../lens-core-module/lensCore";
7
8
  * @param sessionErrors EventTarget to dispatch errors in.
8
9
  */
9
10
  export declare const registerLensClientInterfaceHandler: {
10
- (args_0: LensCore): void;
11
+ (args_0: LensCore, args_1: FilePicker): void;
11
12
  token: "registerLensClientInterfaceHandler";
12
- dependencies: readonly ["lensCore"];
13
+ dependencies: readonly ["lensCore", "filePicker"];
13
14
  };
14
15
  //# sourceMappingURL=lensClientInterface.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"lensClientInterface.d.ts","sourceRoot":"","sources":["../../src/lens-client-interface/lensClientInterface.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAK7D;;;;;;GAMG;AACH,eAAO,MAAM,kCAAkC;;;;CA0B9C,CAAC"}
1
+ {"version":3,"file":"lensClientInterface.d.ts","sourceRoot":"","sources":["../../src/lens-client-interface/lensClientInterface.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAE7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAK/C;;;;;;GAMG;AACH,eAAO,MAAM,kCAAkC;;;;CA0B9C,CAAC"}