@snap/camera-kit 0.16.2 → 0.17.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 (144) hide show
  1. package/LICENSE.md +139 -3873
  2. package/README.md +1 -1
  3. package/docs/html/classes/CameraKit.html +2 -2
  4. package/docs/html/classes/CameraKitSession.html +2 -2
  5. package/docs/html/classes/CameraKitSource.html +2 -2
  6. package/docs/html/classes/LensPerformanceMeasurement.html +2 -2
  7. package/docs/html/classes/LensPerformanceMetrics.html +2 -2
  8. package/docs/html/classes/LensRepository.html +2 -2
  9. package/docs/html/classes/Transform2D.html +2 -2
  10. package/docs/html/classes/TypedCustomEvent.html +2 -2
  11. package/docs/html/classes/TypedEventTarget.html +2 -2
  12. package/docs/html/enums/Lens_CameraFacing.html +2 -2
  13. package/docs/html/enums/UserData_Zodiac.html +2 -2
  14. package/docs/html/functions/ConcatInjectable.html +2 -2
  15. package/docs/html/functions/Injectable.html +2 -2
  16. package/docs/html/functions/bootstrapCameraKit.html +2 -2
  17. package/docs/html/functions/createExtension.html +2 -2
  18. package/docs/html/functions/createImageSource.html +2 -2
  19. package/docs/html/functions/createMediaStreamSource.html +2 -2
  20. package/docs/html/functions/createVideoSource.html +2 -2
  21. package/docs/html/functions/estimateLensPerformance.html +2 -2
  22. package/docs/html/functions/lensSourcesFactory.html +2 -2
  23. package/docs/html/functions/remoteApiServicesFactory.html +2 -2
  24. package/docs/html/hierarchy.html +1 -1
  25. package/docs/html/index.html +3 -3
  26. package/docs/html/interfaces/CameraKitBootstrapConfiguration.html +2 -2
  27. package/docs/html/interfaces/CameraKitDeviceOptions.html +2 -2
  28. package/docs/html/interfaces/CameraKitSourceInfo.html +2 -2
  29. package/docs/html/interfaces/CameraKitSourceSubscriber.html +2 -2
  30. package/docs/html/interfaces/ComputedFrameMetrics.html +2 -2
  31. package/docs/html/interfaces/CreateSessionOptions.html +2 -2
  32. package/docs/html/interfaces/EstimatedLensPerformance.html +2 -2
  33. package/docs/html/interfaces/FunctionSourceOptions.html +2 -2
  34. package/docs/html/interfaces/Lens.html +2 -2
  35. package/docs/html/interfaces/LensCreator.html +2 -2
  36. package/docs/html/interfaces/LensLaunchData.html +2 -2
  37. package/docs/html/interfaces/LensSource.html +2 -2
  38. package/docs/html/interfaces/LoadAssetRequest.html +2 -2
  39. package/docs/html/interfaces/MediaStreamSourceOptions.html +2 -2
  40. package/docs/html/interfaces/Preview.html +2 -2
  41. package/docs/html/interfaces/RemoteApiRequest.html +2 -2
  42. package/docs/html/interfaces/RemoteApiResponse.html +2 -2
  43. package/docs/html/interfaces/RemoteApiService.html +2 -2
  44. package/docs/html/interfaces/Snapcode.html +2 -2
  45. package/docs/html/interfaces/UriCancelRequest.html +2 -2
  46. package/docs/html/interfaces/UriRequest.html +2 -2
  47. package/docs/html/interfaces/UriResponse.html +2 -2
  48. package/docs/html/interfaces/VideoSourceOptions.html +2 -2
  49. package/docs/html/modules.html +2 -2
  50. package/docs/html/types/AssetLoader.html +2 -2
  51. package/docs/html/types/AssetResponse.html +1 -1
  52. package/docs/html/types/AssetTiming.html +2 -2
  53. package/docs/html/types/BenchmarkError.html +1 -1
  54. package/docs/html/types/BootstrapError.html +2 -2
  55. package/docs/html/types/CacheKeyNotFoundError.html +1 -1
  56. package/docs/html/types/CameraKitSessionEventListener.html +2 -2
  57. package/docs/html/types/CameraKitSessionEvents.html +2 -2
  58. package/docs/html/types/CameraKitSourceError.html +1 -1
  59. package/docs/html/types/ConfigurationError.html +2 -2
  60. package/docs/html/types/FetchHandler.html +1 -1
  61. package/docs/html/types/Keyboard.html +2 -2
  62. package/docs/html/types/KeyboardEvents.html +2 -2
  63. package/docs/html/types/LegalError.html +1 -1
  64. package/docs/html/types/LensAbortError.html +2 -2
  65. package/docs/html/types/LensAssetError.html +2 -2
  66. package/docs/html/types/LensContentValidationError.html +1 -1
  67. package/docs/html/types/LensError.html +1 -1
  68. package/docs/html/types/LensExecutionError.html +2 -2
  69. package/docs/html/types/LensImagePickerError.html +2 -2
  70. package/docs/html/types/LensLaunchParams.html +2 -2
  71. package/docs/html/types/LensMetricsEvents.html +2 -2
  72. package/docs/html/types/LensPerformanceCluster.html +1 -1
  73. package/docs/html/types/LensView.html +2 -2
  74. package/docs/html/types/LensWait.html +2 -2
  75. package/docs/html/types/Matrix.html +2 -2
  76. package/docs/html/types/PersistentStoreError.html +2 -2
  77. package/docs/html/types/PlatformNotSupportedError.html +2 -2
  78. package/docs/html/types/PublicContainer.html +2 -2
  79. package/docs/html/types/PublicServices.html +2 -2
  80. package/docs/html/types/RemoteApiCancelRequestHandler.html +2 -2
  81. package/docs/html/types/RemoteApiRequestHandler.html +2 -2
  82. package/docs/html/types/RemoteApiServices.html +1 -1
  83. package/docs/html/types/RemoteApiStatus.html +2 -2
  84. package/docs/html/types/RenderTarget.html +2 -2
  85. package/docs/html/types/Uri.html +1 -1
  86. package/docs/html/types/WebGLError.html +1 -1
  87. package/docs/html/variables/extensionRequestContext.html +2 -2
  88. package/docs/md/README.md +1 -1
  89. package/docs/md/classes/CameraKit.md +1 -1
  90. package/docs/md/classes/CameraKitSession.md +1 -1
  91. package/docs/md/classes/CameraKitSource.md +1 -1
  92. package/docs/md/classes/LensPerformanceMeasurement.md +1 -1
  93. package/docs/md/classes/LensPerformanceMetrics.md +1 -1
  94. package/docs/md/classes/LensRepository.md +1 -1
  95. package/docs/md/classes/Transform2D.md +1 -1
  96. package/docs/md/classes/TypedCustomEvent.md +1 -1
  97. package/docs/md/classes/TypedEventTarget.md +1 -1
  98. package/docs/md/enums/Lens_CameraFacing.md +1 -1
  99. package/docs/md/enums/UserData_Zodiac.md +1 -1
  100. package/docs/md/interfaces/CameraKitBootstrapConfiguration.md +1 -1
  101. package/docs/md/interfaces/CameraKitDeviceOptions.md +1 -1
  102. package/docs/md/interfaces/CameraKitSourceInfo.md +1 -1
  103. package/docs/md/interfaces/CameraKitSourceSubscriber.md +1 -1
  104. package/docs/md/interfaces/ComputedFrameMetrics.md +1 -1
  105. package/docs/md/interfaces/CreateSessionOptions.md +1 -1
  106. package/docs/md/interfaces/EstimatedLensPerformance.md +1 -1
  107. package/docs/md/interfaces/FunctionSourceOptions.md +1 -1
  108. package/docs/md/interfaces/Lens.md +1 -1
  109. package/docs/md/interfaces/LensCreator.md +1 -1
  110. package/docs/md/interfaces/LensLaunchData.md +1 -1
  111. package/docs/md/interfaces/LensSource.md +1 -1
  112. package/docs/md/interfaces/LoadAssetRequest.md +1 -1
  113. package/docs/md/interfaces/MediaStreamSourceOptions.md +1 -1
  114. package/docs/md/interfaces/Preview.md +1 -1
  115. package/docs/md/interfaces/RemoteApiRequest.md +1 -1
  116. package/docs/md/interfaces/RemoteApiResponse.md +1 -1
  117. package/docs/md/interfaces/RemoteApiService.md +1 -1
  118. package/docs/md/interfaces/Snapcode.md +1 -1
  119. package/docs/md/interfaces/UriCancelRequest.md +1 -1
  120. package/docs/md/interfaces/UriRequest.md +1 -1
  121. package/docs/md/interfaces/UriResponse.md +1 -1
  122. package/docs/md/interfaces/VideoSourceOptions.md +1 -1
  123. package/docs/md/modules.md +2 -2
  124. package/lib/bootstrapCameraKit.js +3 -1
  125. package/lib/bootstrapCameraKit.js.map +1 -1
  126. package/lib/environment.js +1 -1
  127. package/lib/environment.js.map +1 -1
  128. package/lib/lens/LensSource.js +2 -2
  129. package/lib/lens/LensSource.js.map +1 -1
  130. package/lib/lens/cameraKitLensSource.d.ts +3 -2
  131. package/lib/lens/cameraKitLensSource.js +87 -42
  132. package/lib/lens/cameraKitLensSource.js.map +1 -1
  133. package/lib/lens/fetchWatermarkLens.d.ts +11 -0
  134. package/lib/lens/fetchWatermarkLens.js +27 -0
  135. package/lib/lens/fetchWatermarkLens.js.map +1 -0
  136. package/lib/lensCoreWasmVersions.js +3 -3
  137. package/lib/lensCoreWasmVersions.js.map +1 -1
  138. package/lib/remote-configuration/preloadConfiguration.js +8 -3
  139. package/lib/remote-configuration/preloadConfiguration.js.map +1 -1
  140. package/lib/session/LensKeyboard.d.ts +1 -6
  141. package/lib/session/lensState.d.ts +3 -2
  142. package/lib/session/lensState.js +71 -48
  143. package/lib/session/lensState.js.map +1 -1
  144. package/package.json +2 -2
@@ -1 +1 @@
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;AAC7D,OAAO,EAAa,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC1D,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;AACrG,OAAO,EAAmC,mCAAmC,EAAE,MAAM,iBAAiB,CAAC;AAEvG,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,iBAAi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CAAC,0BAA0B,CAAC;iBACpC,QAAQ,CAAC,2BAA2B,CAAC;iBACrC,QAAQ,CAAC,iCAAiC,CAAC;iBAC3C,QAAQ,CAAC,wBAAwB,CAAC;iBAClC,QAAQ,CAAC,0BAA0B,CAAC;iBACpC,QAAQ,CAAC,qBAAqB,CAAC;iBAC/B,QAAQ,CAAC,gBAAgB,CAAC,CAAC;YAEhC,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;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,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 { CameraKit, 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 { CameraKitBootstrapConfiguration, createCameraKitConfigurationFactory } from \"./configuration\";\nimport { 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 { bootstrapError, ConfigurationError, configurationError, PlatformNotSupportedError } 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\";\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\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;AAC7D,OAAO,EAAa,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC1D,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,gCAA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AAC;YACpB,MAAM,KAAK,CAAC;SACf;IACL,CAAC;CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,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 { CameraKit, 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 { CameraKitBootstrapConfiguration, createCameraKitConfigurationFactory } from \"./configuration\";\nimport { 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 { bootstrapError, ConfigurationError, configurationError, PlatformNotSupportedError } 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,2 +1,2 @@
1
- export default { PACKAGE_VERSION: "0.16.2" };
1
+ export default { PACKAGE_VERSION: "0.17.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.16.2\" };\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.17.0\" };\n"]}
@@ -30,8 +30,8 @@ export function loadLensesFromSources(sources, groupId, lensId) {
30
30
  return __awaiter(this, void 0, void 0, function* () {
31
31
  const source = sources.find((source) => source.isGroupOwner(groupId));
32
32
  if (!source) {
33
- throw new Error(`Cannot load lens ${lensId ? `${lensId} from ` : ""}group ${groupId}. No LensSource claimed ownership of` +
34
- `that lens group.`);
33
+ throw new Error(`Cannot load lens ${lensId ? `${lensId} from ` : ""}group ${groupId}. ` +
34
+ `No LensSource claimed ownership of that lens group.`);
35
35
  }
36
36
  const envelope = lensId === undefined ? yield source.loadLensGroup(groupId) : yield source.loadLens(lensId, groupId);
37
37
  return envelope instanceof ArrayBuffer || ArrayBuffer.isView(envelope)
@@ -1 +1 @@
1
- {"version":3,"file":"LensSource.js","sourceRoot":"","sources":["../../src/lens/LensSource.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,mDAAmD,CAAC;AAgB7E;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC,aAAa,EAAE,GAAiB,EAAE,CAAC,EAAE,CAAC,CAAC;AAEpF;;;;;GAKG;AACH,MAAM,UAAgB,qBAAqB,CAAC,OAAqB,EAAE,OAAe,EAAE,MAAe;;QAC/F,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;QACtE,IAAI,CAAC,MAAM,EAAE;YACT,MAAM,IAAI,KAAK,CACX,oBAAoB,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,QAAQ,CAAC,CAAC,CAAC,EAAE,SAAS,OAAO,sCAAsC;gBACrG,kBAAkB,CACzB,CAAC;SACL;QACD,MAAM,QAAQ,GACV,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAExG,OAAO,QAAQ,YAAY,WAAW,IAAI,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC;YAClE,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,YAAY,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM;YAC9F,CAAC,CAAC,EAAE,CAAC;IACb,CAAC;CAAA","sourcesContent":["import { Injectable } from \"../dependency-injection/Injectable\";\nimport { Envelope } from \"../generated-proto/pb_schema/camera_kit/v3/export\";\nimport { Lens } from \"../generated-proto/pb_schema/camera_kit/v3/lens\";\n\n/**\n * Provides Lens metadata for one or more Lens groups.\n *\n * When a Lens or Lens group is requested via the {@link LensRepository}, CameraKit will find the LensSource which\n * claims ownership of that group. The appropriate LensSource method will be called and must return an ArrayBuffer\n * containing the encoded Lens metadata -- this can be obtained from a CameraKit backend API.\n */\nexport interface LensSource {\n isGroupOwner(groupId: string): boolean;\n loadLens(lensId: string, groupId: string): Promise<ArrayBuffer>;\n loadLensGroup(groupId: string): Promise<ArrayBuffer>;\n}\n\n/**\n * By default, no custom {@link LensSource} is provided to CameraKit. But to enable certain advanced use-cases,\n * applications may provide their own {@link LensSource}.\n *\n * Perhaps the most convenient way to do this is with {@link ConcatInjectable}, as shown here:\n *\n * @example\n * ```ts\n * import { bootstrapCameraKit, lensSourcesFactory, LensSource } from '@snap/camera-kit'\n *\n * const cameraKit = bootstrapCameraKit(config, (container) => {\n * return container.provides(ConcatInjectable(\n * lensSourcesFactory.token,\n * (): LensSource => { return ... }\n * ))\n * })\n * ```\n */\nexport const lensSourcesFactory = Injectable(\"lensSources\", (): LensSource[] => []);\n\n/**\n * Given a list of LensSources (like the one provided by CameraKit's DI container under the `'lensSources'` token), and\n * a groupId/lensId, return a list of lenses loaded by the first LensSource claiming ownership of the given groupId.\n *\n * @internal\n */\nexport async function loadLensesFromSources(sources: LensSource[], groupId: string, lensId?: string): Promise<Lens[]> {\n const source = sources.find((source) => source.isGroupOwner(groupId));\n if (!source) {\n throw new Error(\n `Cannot load lens ${lensId ? `${lensId} from ` : \"\"}group ${groupId}. No LensSource claimed ownership of` +\n `that lens group.`\n );\n }\n const envelope =\n lensId === undefined ? await source.loadLensGroup(groupId) : await source.loadLens(lensId, groupId);\n\n return envelope instanceof ArrayBuffer || ArrayBuffer.isView(envelope)\n ? Envelope.decode(envelope instanceof Uint8Array ? envelope : new Uint8Array(envelope)).lenses\n : [];\n}\n"]}
1
+ {"version":3,"file":"LensSource.js","sourceRoot":"","sources":["../../src/lens/LensSource.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,mDAAmD,CAAC;AAgB7E;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC,aAAa,EAAE,GAAiB,EAAE,CAAC,EAAE,CAAC,CAAC;AAEpF;;;;;GAKG;AACH,MAAM,UAAgB,qBAAqB,CAAC,OAAqB,EAAE,OAAe,EAAE,MAAe;;QAC/F,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;QACtE,IAAI,CAAC,MAAM,EAAE;YACT,MAAM,IAAI,KAAK,CACX,oBAAoB,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,QAAQ,CAAC,CAAC,CAAC,EAAE,SAAS,OAAO,IAAI;gBACnE,qDAAqD,CAC5D,CAAC;SACL;QACD,MAAM,QAAQ,GACV,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAExG,OAAO,QAAQ,YAAY,WAAW,IAAI,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC;YAClE,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,YAAY,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM;YAC9F,CAAC,CAAC,EAAE,CAAC;IACb,CAAC;CAAA","sourcesContent":["import { Injectable } from \"../dependency-injection/Injectable\";\nimport { Envelope } from \"../generated-proto/pb_schema/camera_kit/v3/export\";\nimport { Lens } from \"../generated-proto/pb_schema/camera_kit/v3/lens\";\n\n/**\n * Provides Lens metadata for one or more Lens groups.\n *\n * When a Lens or Lens group is requested via the {@link LensRepository}, CameraKit will find the LensSource which\n * claims ownership of that group. The appropriate LensSource method will be called and must return an ArrayBuffer\n * containing the encoded Lens metadata -- this can be obtained from a CameraKit backend API.\n */\nexport interface LensSource {\n isGroupOwner(groupId: string): boolean;\n loadLens(lensId: string, groupId: string): Promise<ArrayBuffer>;\n loadLensGroup(groupId: string): Promise<ArrayBuffer>;\n}\n\n/**\n * By default, no custom {@link LensSource} is provided to CameraKit. But to enable certain advanced use-cases,\n * applications may provide their own {@link LensSource}.\n *\n * Perhaps the most convenient way to do this is with {@link ConcatInjectable}, as shown here:\n *\n * @example\n * ```ts\n * import { bootstrapCameraKit, lensSourcesFactory, LensSource } from '@snap/camera-kit'\n *\n * const cameraKit = bootstrapCameraKit(config, (container) => {\n * return container.provides(ConcatInjectable(\n * lensSourcesFactory.token,\n * (): LensSource => { return ... }\n * ))\n * })\n * ```\n */\nexport const lensSourcesFactory = Injectable(\"lensSources\", (): LensSource[] => []);\n\n/**\n * Given a list of LensSources (like the one provided by CameraKit's DI container under the `'lensSources'` token), and\n * a groupId/lensId, return a list of lenses loaded by the first LensSource claiming ownership of the given groupId.\n *\n * @internal\n */\nexport async function loadLensesFromSources(sources: LensSource[], groupId: string, lensId?: string): Promise<Lens[]> {\n const source = sources.find((source) => source.isGroupOwner(groupId));\n if (!source) {\n throw new Error(\n `Cannot load lens ${lensId ? `${lensId} from ` : \"\"}group ${groupId}. ` +\n `No LensSource claimed ownership of that lens group.`\n );\n }\n const envelope =\n lensId === undefined ? await source.loadLensGroup(groupId) : await source.loadLens(lensId, groupId);\n\n return envelope instanceof ArrayBuffer || ArrayBuffer.isView(envelope)\n ? Envelope.decode(envelope instanceof Uint8Array ? envelope : new Uint8Array(envelope)).lenses\n : [];\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  import { LensesClient } from "../clients/lensesClient";
2
+ import { RemoteConfiguration } from "../remote-configuration/remoteConfiguration";
2
3
  import { LensSource } from "./LensSource";
3
4
  /**
4
5
  * This LensSource loads lenses from the CameraKit backend service. It is meant to be used as the last LensSource in the
@@ -10,7 +11,7 @@ import { LensSource } from "./LensSource";
10
11
  * @internal
11
12
  */
12
13
  export declare const cameraKitLensSourceFactory: {
13
- (args_0: LensesClient): LensSource[];
14
+ (args_0: LensSource[], args_1: LensesClient, args_2: RemoteConfiguration): LensSource[];
14
15
  token: "lensSources";
15
- dependencies: readonly ["lensesClient"];
16
+ dependencies: readonly ["lensSources", "lensesClient", "remoteConfiguration"];
16
17
  };
@@ -1,9 +1,26 @@
1
1
  import { __awaiter } from "tslib";
2
+ import { catchError, firstValueFrom, map, of } from "rxjs";
2
3
  import { Writer } from "protobufjs";
3
4
  import { Lens } from "../generated-proto/pb_schema/camera_kit/v3/lens";
4
5
  import { lensesClientFactory } from "../clients/lensesClient";
5
- import { ConcatInjectable } from "../dependency-injection/Injectable";
6
+ import { Injectable } from "../dependency-injection/Injectable";
7
+ import { remoteConfigurationFactory } from "../remote-configuration/remoteConfiguration";
8
+ import { getLogger } from "../logger/logger";
6
9
  import { lensSourcesFactory } from "./LensSource";
10
+ import { watermarksLensGroup } from "./fetchWatermarkLens";
11
+ const logger = getLogger("CameraKitLensSource");
12
+ const hasAnyValue = (c) => {
13
+ var _a, _b;
14
+ return ((_b = (_a = c.value) === null || _a === void 0 ? void 0 : _a.anyValue) === null || _b === void 0 ? void 0 : _b.value) instanceof Uint8Array;
15
+ };
16
+ const defaultWatermarkLens = {
17
+ id: "60515300902",
18
+ name: "Watermark",
19
+ content: {
20
+ lnsSha256: "3EDEAEBCD51A547FF4D1F5708FBD6F4D628AD736BEE07AB3844B14E6C69EC510",
21
+ lnsUrlBolt: "https://bolt-gcdn.sc-cdn.net/3/L6uAe5Fhyg0ZFf3RLsCVZ?bo=EhgaABoAMgF9OgEEQgYIkbHPpgZIAlASYAE%3D&uc=18",
22
+ },
23
+ };
7
24
  /**
8
25
  * This LensSource loads lenses from the CameraKit backend service. It is meant to be used as the last LensSource in the
9
26
  * LensSource[] array used by LensRepository to load lenses.
@@ -13,47 +30,75 @@ import { lensSourcesFactory } from "./LensSource";
13
30
  *
14
31
  * @internal
15
32
  */
16
- export const cameraKitLensSourceFactory = ConcatInjectable(lensSourcesFactory.token, [lensesClientFactory.token], (lensesClient) => ({
17
- // This LensSource will claim ownership of all lens groups -- it should be used as the last element in a
18
- // list of LensSources, as a catch-all to load any lens groups not claimed by other LensSources.
19
- isGroupOwner() {
20
- return true;
21
- },
22
- loadLens(lensId, groupId) {
23
- var _a;
24
- return __awaiter(this, void 0, void 0, function* () {
25
- const result = yield lensesClient.getGroupLens({ lensId, groupId });
26
- if (!result.ok) {
27
- const error = result.unwrapErr();
28
- throw new Error(`Cannot load lens lens ${lensId} from group ${groupId}. An error occured in the ` +
29
- `gRPC client:\n\t[${error.status}] ${error.statusMessage}`);
30
- }
31
- const response = result.unwrap();
32
- if (!((_a = response.message) === null || _a === void 0 ? void 0 : _a.lens)) {
33
- throw new Error(`Cannot load lens ${lensId} from group ${groupId}. The response did not contain ` +
34
- `a lens.\n\t${JSON.stringify(result)} for requestId ${response.headers.get("x-request-id")}`);
35
- }
36
- return Lens.encode(response.message.lens, Writer.create().uint32(10).fork()).ldelim().finish();
37
- });
33
+ export const cameraKitLensSourceFactory = Injectable(lensSourcesFactory.token, [lensSourcesFactory.token, lensesClientFactory.token, remoteConfigurationFactory.token], (lensSources, lensesClient, remoteConfig) => [
34
+ ...lensSources,
35
+ {
36
+ isGroupOwner(groupId) {
37
+ return groupId === watermarksLensGroup;
38
+ },
39
+ loadLens() {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ const lensMessage = yield firstValueFrom(remoteConfig.get("CAMERA_KIT_WATERMARK_LENS").pipe(map((configResults) => {
42
+ var _a;
43
+ const lensMessage = (_a = configResults.find(hasAnyValue)) === null || _a === void 0 ? void 0 : _a.value.anyValue.value;
44
+ if (!lensMessage)
45
+ throw new Error("Failed to read watermark Lens from COF response.");
46
+ return lensMessage;
47
+ }), catchError((error) => {
48
+ logger.error(error);
49
+ return of(Lens.encode(Lens.fromPartial(defaultWatermarkLens)).finish());
50
+ })));
51
+ return Writer.create().uint32(10).bytes(lensMessage).finish();
52
+ });
53
+ },
54
+ loadLensGroup() {
55
+ return __awaiter(this, void 0, void 0, function* () {
56
+ throw new Error("Not implemented.");
57
+ });
58
+ },
38
59
  },
39
- loadLensGroup(groupId) {
40
- var _a;
41
- return __awaiter(this, void 0, void 0, function* () {
42
- const result = yield lensesClient.getGroup({ id: groupId });
43
- if (!result.ok) {
44
- const error = result.unwrapErr();
45
- throw new Error(`Cannot load lens group ${groupId}. An error occured in the gRPC client:\n` +
46
- `\t[${error.status}] ${error.statusMessage}`);
47
- }
48
- const response = result.unwrap();
49
- if (!((_a = response.message) === null || _a === void 0 ? void 0 : _a.lenses)) {
50
- throw new Error(`Cannot load lens group ${groupId}. The response contained no lenses ` +
51
- `\n\t${JSON.stringify(response)} for requestId ${response.headers.get("x-request-id")}`);
52
- }
53
- const writer = Writer.create();
54
- response.message.lenses.forEach((lens) => Lens.encode(lens, writer.uint32(10).fork()).ldelim());
55
- return writer.finish();
56
- });
60
+ {
61
+ // This LensSource will claim ownership of all lens groups -- it should be used as the last element in a
62
+ // list of LensSources, as a catch-all to load any lens groups not claimed by other LensSources.
63
+ isGroupOwner() {
64
+ return true;
65
+ },
66
+ loadLens(lensId, groupId) {
67
+ var _a;
68
+ return __awaiter(this, void 0, void 0, function* () {
69
+ const result = yield lensesClient.getGroupLens({ lensId, groupId });
70
+ if (!result.ok) {
71
+ const error = result.unwrapErr();
72
+ throw new Error(`Cannot load lens lens ${lensId} from group ${groupId}. An error occured in the ` +
73
+ `gRPC client:\n\t[${error.status}] ${error.statusMessage}`);
74
+ }
75
+ const response = result.unwrap();
76
+ if (!((_a = response.message) === null || _a === void 0 ? void 0 : _a.lens)) {
77
+ throw new Error(`Cannot load lens ${lensId} from group ${groupId}. The response did not contain ` +
78
+ `a lens.\n\t${JSON.stringify(result)} for requestId ${response.headers.get("x-request-id")}`);
79
+ }
80
+ return Lens.encode(response.message.lens, Writer.create().uint32(10).fork()).ldelim().finish();
81
+ });
82
+ },
83
+ loadLensGroup(groupId) {
84
+ var _a;
85
+ return __awaiter(this, void 0, void 0, function* () {
86
+ const result = yield lensesClient.getGroup({ id: groupId });
87
+ if (!result.ok) {
88
+ const error = result.unwrapErr();
89
+ throw new Error(`Cannot load lens group ${groupId}. An error occurred in the gRPC client:\n` +
90
+ `\t[${error.status}] ${error.statusMessage}`);
91
+ }
92
+ const response = result.unwrap();
93
+ if (!((_a = response.message) === null || _a === void 0 ? void 0 : _a.lenses)) {
94
+ throw new Error(`Cannot load lens group ${groupId}. The response contained no lenses ` +
95
+ `\n\t${JSON.stringify(response)} for requestId ${response.headers.get("x-request-id")}`);
96
+ }
97
+ const writer = Writer.create();
98
+ response.message.lenses.forEach((lens) => Lens.encode(lens, writer.uint32(10).fork()).ldelim());
99
+ return writer.finish();
100
+ });
101
+ },
57
102
  },
58
- }));
103
+ ]);
59
104
  //# sourceMappingURL=cameraKitLensSource.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cameraKitLensSource.js","sourceRoot":"","sources":["../../src/lens/cameraKitLensSource.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,iDAAiD,CAAC;AACvE,OAAO,EAAgB,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAc,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAE9D;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,gBAAgB,CACtD,kBAAkB,CAAC,KAAK,EACxB,CAAC,mBAAmB,CAAC,KAAK,CAAU,EACpC,CAAC,YAA0B,EAAc,EAAE,CAAC,CAAC;IACzC,wGAAwG;IACxG,gGAAgG;IAChG,YAAY;QACR,OAAO,IAAI,CAAC;IAChB,CAAC;IAEK,QAAQ,CAAC,MAAc,EAAE,OAAe;;;YAC1C,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;YACpE,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE;gBACZ,MAAM,KAAK,GAAG,MAAM,CAAC,SAAS,EAA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AAI,CAAC,SAAS,CAAC,QAAQ,CAAC,kBAAkB,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE,CAC9F,CAAC;aACL;YACD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;YAC/B,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;YAChG,OAAO,MAAM,CAAC,MAAM,EAAE,CAAC;;KAC1B;CACJ,CAAC,CACL,CAAC","sourcesContent":["import { Writer } from \"protobufjs\";\nimport { Lens } from \"../generated-proto/pb_schema/camera_kit/v3/lens\";\nimport { LensesClient, lensesClientFactory } from \"../clients/lensesClient\";\nimport { ConcatInjectable } from \"../dependency-injection/Injectable\";\nimport { LensSource, lensSourcesFactory } from \"./LensSource\";\n\n/**\n * This LensSource loads lenses from the CameraKit backend service. It is meant to be used as the last LensSource in the\n * LensSource[] array used by LensRepository to load lenses.\n *\n * We ensure this is the case by providing cameraKitLensSourceFactory *after* the DI container has been modified by the\n * application during bootstrap -- this way we're guaranteed to place this LensSource after all other LensSources.\n *\n * @internal\n */\nexport const cameraKitLensSourceFactory = ConcatInjectable(\n lensSourcesFactory.token,\n [lensesClientFactory.token] as const,\n (lensesClient: LensesClient): LensSource => ({\n // This LensSource will claim ownership of all lens groups -- it should be used as the last element in a\n // list of LensSources, as a catch-all to load any lens groups not claimed by other LensSources.\n isGroupOwner(): boolean {\n return true;\n },\n\n async loadLens(lensId: string, groupId: string): Promise<ArrayBuffer> {\n const result = await lensesClient.getGroupLens({ lensId, groupId });\n if (!result.ok) {\n const error = result.unwrapErr();\n throw new Error(\n `Cannot load lens lens ${lensId} from group ${groupId}. An error occured in the ` +\n `gRPC client:\\n\\t[${error.status}] ${error.statusMessage}`\n );\n }\n const response = result.unwrap();\n if (!response.message?.lens) {\n throw new Error(\n `Cannot load lens ${lensId} from group ${groupId}. The response did not contain ` +\n `a lens.\\n\\t${JSON.stringify(result)} for requestId ${response.headers.get(\"x-request-id\")}`\n );\n }\n return Lens.encode(response.message.lens, Writer.create().uint32(10).fork()).ldelim().finish();\n },\n\n async loadLensGroup(groupId: string): Promise<ArrayBuffer> {\n const result = await lensesClient.getGroup({ id: groupId });\n if (!result.ok) {\n const error = result.unwrapErr();\n throw new Error(\n `Cannot load lens group ${groupId}. An error occured in the gRPC client:\\n` +\n `\\t[${error.status}] ${error.statusMessage}`\n );\n }\n const response = result.unwrap();\n if (!response.message?.lenses) {\n throw new Error(\n `Cannot load lens group ${groupId}. The response contained no lenses ` +\n `\\n\\t${JSON.stringify(response)} for requestId ${response.headers.get(\"x-request-id\")}`\n );\n }\n const writer = Writer.create();\n response.message.lenses.forEach((lens) => Lens.encode(lens, writer.uint32(10).fork()).ldelim());\n return writer.finish();\n },\n })\n);\n"]}
1
+ {"version":3,"file":"cameraKitLensSource.js","sourceRoot":"","sources":["../../src/lens/cameraKitLensSource.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,iDAAiD,CAAC;AACvE,OAAO,EAAgB,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAuB,0BAA0B,EAAE,MAAM,6CAA6C,CAAC;AAE9G,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAc,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AA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schema/camera_kit/v3/lens\";\nimport { LensesClient, lensesClientFactory } from \"../clients/lensesClient\";\nimport { Injectable } from \"../dependency-injection/Injectable\";\nimport { RemoteConfiguration, remoteConfigurationFactory } from \"../remote-configuration/remoteConfiguration\";\nimport { ConfigResult } from \"../generated-proto/pb_schema/cdp/cof/config_result\";\nimport { getLogger } from \"../logger/logger\";\nimport { LensSource, lensSourcesFactory } from \"./LensSource\";\nimport { watermarksLensGroup } from \"./fetchWatermarkLens\";\n\nconst logger = getLogger(\"CameraKitLensSource\");\n\nconst hasAnyValue = (c: ConfigResult): c is ConfigResult & { value: { anyValue: { value: Uint8Array } } } => {\n return c.value?.anyValue?.value instanceof Uint8Array;\n};\n\nconst defaultWatermarkLens = {\n id: \"60515300902\",\n name: \"Watermark\",\n content: {\n lnsSha256: \"3EDEAEBCD51A547FF4D1F5708FBD6F4D628AD736BEE07AB3844B14E6C69EC510\",\n lnsUrlBolt:\n \"https://bolt-gcdn.sc-cdn.net/3/L6uAe5Fhyg0ZFf3RLsCVZ?bo=EhgaABoAMgF9OgEEQgYIkbHPpgZIAlASYAE%3D&uc=18\",\n },\n};\n/**\n * This LensSource loads lenses from the CameraKit backend service. It is meant to be used as the last LensSource in the\n * LensSource[] array used by LensRepository to load lenses.\n *\n * We ensure this is the case by providing cameraKitLensSourceFactory *after* the DI container has been modified by the\n * application during bootstrap -- this way we're guaranteed to place this LensSource after all other LensSources.\n *\n * @internal\n */\nexport const cameraKitLensSourceFactory = Injectable(\n lensSourcesFactory.token,\n [lensSourcesFactory.token, lensesClientFactory.token, remoteConfigurationFactory.token] as const,\n (lensSources: LensSource[], lensesClient: LensesClient, remoteConfig: RemoteConfiguration): LensSource[] => [\n ...lensSources,\n {\n isGroupOwner(groupId: string) {\n return groupId === watermarksLensGroup;\n },\n async loadLens() {\n const lensMessage = await firstValueFrom(\n remoteConfig.get(\"CAMERA_KIT_WATERMARK_LENS\").pipe(\n map((configResults) => {\n const lensMessage = configResults.find(hasAnyValue)?.value.anyValue.value;\n if (!lensMessage) throw new Error(\"Failed to read watermark Lens from COF response.\");\n return lensMessage;\n }),\n catchError((error) => {\n logger.error(error);\n return of(Lens.encode(Lens.fromPartial(defaultWatermarkLens)).finish());\n })\n )\n );\n\n return Writer.create().uint32(10).bytes(lensMessage).finish();\n },\n async loadLensGroup() {\n throw new Error(\"Not implemented.\");\n },\n },\n {\n // This LensSource will claim ownership of all lens groups -- it should be used as the last element in a\n // list of LensSources, as a catch-all to load any lens groups not claimed by other LensSources.\n isGroupOwner(): boolean {\n return true;\n },\n\n async loadLens(lensId: string, groupId: string): Promise<ArrayBuffer> {\n const result = await lensesClient.getGroupLens({ lensId, groupId });\n if (!result.ok) {\n const error = result.unwrapErr();\n throw new Error(\n `Cannot load lens lens ${lensId} from group ${groupId}. An error occured in the ` +\n `gRPC client:\\n\\t[${error.status}] ${error.statusMessage}`\n );\n }\n const response = result.unwrap();\n if (!response.message?.lens) {\n throw new Error(\n `Cannot load lens ${lensId} from group ${groupId}. The response did not contain ` +\n `a lens.\\n\\t${JSON.stringify(result)} for requestId ${response.headers.get(\"x-request-id\")}`\n );\n }\n return Lens.encode(response.message.lens, Writer.create().uint32(10).fork()).ldelim().finish();\n },\n\n async loadLensGroup(groupId: string): Promise<ArrayBuffer> {\n const result = await lensesClient.getGroup({ id: groupId });\n if (!result.ok) {\n const error = result.unwrapErr();\n throw new Error(\n `Cannot load lens group ${groupId}. An error occurred in the gRPC client:\\n` +\n `\\t[${error.status}] ${error.statusMessage}`\n );\n }\n const response = result.unwrap();\n if (!response.message?.lenses) {\n throw new Error(\n `Cannot load lens group ${groupId}. The response contained no lenses ` +\n `\\n\\t${JSON.stringify(response)} for requestId ${response.headers.get(\"x-request-id\")}`\n );\n }\n const writer = Writer.create();\n response.message.lenses.forEach((lens) => Lens.encode(lens, writer.uint32(10).fork()).ldelim());\n return writer.finish();\n },\n },\n ]\n);\n"]}
@@ -0,0 +1,11 @@
1
+ import { RemoteConfiguration } from "../remote-configuration/remoteConfiguration";
2
+ import { LensRepository } from "./LensRepository";
3
+ export declare const watermarksLensGroup = "watermarks";
4
+ /**
5
+ * @internal
6
+ */
7
+ export declare const fetchWatermarkLens: {
8
+ (args_0: RemoteConfiguration, args_1: LensRepository): void;
9
+ token: "fetchWatermarkLens";
10
+ dependencies: readonly ["remoteConfiguration", "LensRepository"];
11
+ };
@@ -0,0 +1,27 @@
1
+ import { __awaiter } from "tslib";
2
+ import { take } from "rxjs";
3
+ import { remoteConfigurationFactory } from "../remote-configuration/remoteConfiguration";
4
+ import { Injectable } from "../dependency-injection/Injectable";
5
+ import { getLogger } from "../logger/logger";
6
+ import { lensRepositoryFactory } from "./LensRepository";
7
+ const logger = getLogger("fetchWatermarkLens");
8
+ // Special group for all "watermark" lenses that are applied by the Camera Kit internally.
9
+ export const watermarksLensGroup = "watermarks";
10
+ /**
11
+ * @internal
12
+ */
13
+ export const fetchWatermarkLens = Injectable("fetchWatermarkLens", [remoteConfigurationFactory.token, lensRepositoryFactory.token], (remoteConfiguration, lensRepository) => {
14
+ remoteConfiguration
15
+ .getInitializationConfig()
16
+ .pipe(take(1))
17
+ .subscribe({
18
+ next: (config) => __awaiter(void 0, void 0, void 0, function* () {
19
+ if (config.watermarkEnabled) {
20
+ const lens = yield lensRepository.loadLens("", watermarksLensGroup);
21
+ yield lensRepository.cacheLensContent([lens]);
22
+ }
23
+ }),
24
+ error: logger.error,
25
+ });
26
+ });
27
+ //# sourceMappingURL=fetchWatermarkLens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetchWatermarkLens.js","sourceRoot":"","sources":["../../src/lens/fetchWatermarkLens.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAuB,0BAA0B,EAAE,MAAM,6CAA6C,CAAC;AAC9G,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAkB,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAEzE,MAAM,MAAM,GAAG,SAAS,CAAC,oBAAoB,CAAC,CAAC;AAE/C,0FAA0F;AAC1F,MAAM,CAAC,MAAM,mBAAmB,GAAG,YAAY,CAAC;AAEhD;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CACxC,oBAAoB,EACpB,CAAC,0BAA0B,CAAC,KAAK,EAAE,qBAAqB,CAAC,KAAK,CAAU,EACxE,CAAC,mBAAwC,EAAE,cAA8B,EAAE,EAAE;IACzE,mBAAmB;SACd,uBAAuB,EAAE;SACzB,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACb,SAAS,CAAC;QACP,IAAI,EAAE,CAAO,MAAM,EAAE,EAAE;YACnB,IAAI,MAAM,CAAC,gBAAgB,EAAE;gBACzB,MAAM,IAAI,GAAG,MAAM,cAAc,CAAC,QAAQ,CAAC,EAAE,EAAE,mBAAmB,CAAC,CAAC;gBACpE,MAAM,cAAc,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;aACjD;QACL,CAAC,CAAA;QACD,KAAK,EAAE,MAAM,CAAC,KAAK;KACtB,CAAC,CAAC;AACX,CAAC,CACJ,CAAC","sourcesContent":["import { take } from \"rxjs\";\nimport { RemoteConfiguration, remoteConfigurationFactory } from \"../remote-configuration/remoteConfiguration\";\nimport { Injectable } from \"../dependency-injection/Injectable\";\nimport { getLogger } from \"../logger/logger\";\nimport { LensRepository, lensRepositoryFactory } from \"./LensRepository\";\n\nconst logger = getLogger(\"fetchWatermarkLens\");\n\n// Special group for all \"watermark\" lenses that are applied by the Camera Kit internally.\nexport const watermarksLensGroup = \"watermarks\";\n\n/**\n * @internal\n */\nexport const fetchWatermarkLens = Injectable(\n \"fetchWatermarkLens\",\n [remoteConfigurationFactory.token, lensRepositoryFactory.token] as const,\n (remoteConfiguration: RemoteConfiguration, lensRepository: LensRepository) => {\n remoteConfiguration\n .getInitializationConfig()\n .pipe(take(1))\n .subscribe({\n next: async (config) => {\n if (config.watermarkEnabled) {\n const lens = await lensRepository.loadLens(\"\", watermarksLensGroup);\n await lensRepository.cacheLensContent([lens]);\n }\n },\n error: logger.error,\n });\n }\n);\n"]}
@@ -1,6 +1,6 @@
1
1
  export default {
2
- version: "251",
3
- buildNumber: "230",
4
- baseUrl: "https://cf-st.sc-cdn.net/d/9MftyEDBWQyGhMs6x4cUU?go=IgsKCTIBBEgBUFxgAQ%3D%3D&uc=92",
2
+ version: "256",
3
+ buildNumber: "264",
4
+ baseUrl: "https://cf-st.sc-cdn.net/d/tZfznbwVmxFm2fh24dXK1?go=IgsKCTIBBEgBUFxgAQ%3D%3D&uc=92",
5
5
  };
6
6
  //# sourceMappingURL=lensCoreWasmVersions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"lensCoreWasmVersions.js","sourceRoot":"","sources":["../src/lensCoreWasmVersions.ts"],"names":[],"mappings":"AAAA,eAAe;IACX,OAAO,EAAE,KAAK;IACd,WAAW,EAAE,KAAK;IAClB,OAAO,EAAE,oFAAoF;CAChG,CAAC","sourcesContent":["export default {\n version: \"251\",\n buildNumber: \"230\",\n baseUrl: \"https://cf-st.sc-cdn.net/d/9MftyEDBWQyGhMs6x4cUU?go=IgsKCTIBBEgBUFxgAQ%3D%3D&uc=92\",\n};\n"]}
1
+ {"version":3,"file":"lensCoreWasmVersions.js","sourceRoot":"","sources":["../src/lensCoreWasmVersions.ts"],"names":[],"mappings":"AAAA,eAAe;IACX,OAAO,EAAE,KAAK;IACd,WAAW,EAAE,KAAK;IAClB,OAAO,EAAE,oFAAoF;CAChG,CAAC","sourcesContent":["export default {\n version: \"256\",\n buildNumber: \"264\",\n baseUrl: \"https://cf-st.sc-cdn.net/d/tZfznbwVmxFm2fh24dXK1?go=IgsKCTIBBEgBUFxgAQ%3D%3D&uc=92\",\n};\n"]}
@@ -2,14 +2,19 @@ import { take } from "rxjs";
2
2
  import { Injectable } from "../dependency-injection/Injectable";
3
3
  import { Namespace } from "../generated-proto/pb_schema/cdp/cof/namespace";
4
4
  import { lensCoreFactory } from "../lens-core-module/loader/lensCoreFactory";
5
+ import { getLogger } from "../logger/logger";
5
6
  import { remoteConfigurationFactory } from "./remoteConfiguration";
7
+ const logger = getLogger("setPreloadedConfiguration");
6
8
  export const setPreloadedConfiguration = Injectable("setPreloadedConfiguration", [lensCoreFactory.token, remoteConfigurationFactory.token], (lensCore, remoteConfiguration) => {
7
9
  remoteConfiguration
8
10
  .getNamespace(Namespace.LENS_CORE_CONFIG)
9
11
  .pipe(take(1))
10
- .subscribe((configs) => {
11
- const inputs = configs.map(({ configId, value }) => ({ configId, value }));
12
- lensCore.setPreloadedConfiguration(inputs);
12
+ .subscribe({
13
+ next: (configs) => {
14
+ const inputs = configs.map(({ configId, value }) => ({ configId, value }));
15
+ lensCore.setPreloadedConfiguration(inputs);
16
+ },
17
+ error: logger.error,
13
18
  });
14
19
  });
15
20
  //# sourceMappingURL=preloadConfiguration.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"preloadConfiguration.js","sourceRoot":"","sources":["../../src/remote-configuration/preloadConfiguration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,gDAAgD,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,4CAA4C,CAAC;AAG7E,OAAO,EAAuB,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAExF,MAAM,CAAC,MAAM,yBAAyB,GAAG,UAAU,CAC/C,2BAA2B,EAC3B,CAAC,eAAe,CAAC,KAAK,EAAE,0BAA0B,CAAC,KAAK,CAAU,EAClE,CAAC,QAAkB,EAAE,mBAAwC,EAAE,EAAE;IAC7D,mBAAmB;SACd,YAAY,CAAC,SAAS,CAAC,gBAAgB,CAAC;SACxC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACb,SAAS,CAAC,CAAC,OAAO,EAAE,EAAE;QACnB,MAAM,MAAM,GAAmC,OAAO,CAAC,GAAG,CACtD,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAqB,CAAA,CACnE,CAAC;QAEF,QAAQ,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;AACX,CAAC,CACJ,CAAC","sourcesContent":["import { take } from \"rxjs\";\nimport { Injectable } from \"../dependency-injection/Injectable\";\nimport { Namespace } from \"../generated-proto/pb_schema/cdp/cof/namespace\";\nimport { lensCoreFactory } from \"../lens-core-module/loader/lensCoreFactory\";\nimport { LensCore } from \"../lens-core-module/lensCore\";\nimport { LensCoreConfig, SetPreloadedConfigurationInput } from \"../lens-core-module/generated-types\";\nimport { RemoteConfiguration, remoteConfigurationFactory } from \"./remoteConfiguration\";\n\nexport const setPreloadedConfiguration = Injectable(\n \"setPreloadedConfiguration\",\n [lensCoreFactory.token, remoteConfigurationFactory.token] as const,\n (lensCore: LensCore, remoteConfiguration: RemoteConfiguration) => {\n remoteConfiguration\n .getNamespace(Namespace.LENS_CORE_CONFIG)\n .pipe(take(1))\n .subscribe((configs) => {\n const inputs: SetPreloadedConfigurationInput = configs.map(\n ({ configId, value }) => ({ configId, value } as LensCoreConfig)\n );\n\n lensCore.setPreloadedConfiguration(inputs);\n });\n }\n);\n"]}
1
+ {"version":3,"file":"preloadConfiguration.js","sourceRoot":"","sources":["../../src/remote-configuration/preloadConfiguration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,gDAAgD,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,4CAA4C,CAAC;AAG7E,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAuB,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAExF,MAAM,MAAM,GAAG,SAAS,CAAC,2BAA2B,CAAC,CAAC;AAEtD,MAAM,CAAC,MAAM,yBAAyB,GAAG,UAAU,CAC/C,2BAA2B,EAC3B,CAAC,eAAe,CAAC,KAAK,EAAE,0BAA0B,CAAC,KAAK,CAAU,EAClE,CAAC,QAAkB,EAAE,mBAAwC,EAAE,EAAE;IAC7D,mBAAmB;SACd,YAAY,CAAC,SAAS,CAAC,gBAAgB,CAAC;SACxC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACb,SAAS,CAAC;QACP,IAAI,EAAE,CAAC,OAAO,EAAE,EAAE;YACd,MAAM,MAAM,GAAmC,OAAO,CAAC,GAAG,CACtD,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAqB,CAAA,CACnE,CAAC;YAEF,QAAQ,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAC;QAC/C,CAAC;QACD,KAAK,EAAE,MAAM,CAAC,KAAK;KACtB,CAAC,CAAC;AACX,CAAC,CACJ,CAAC","sourcesContent":["import { take } from \"rxjs\";\nimport { Injectable } from \"../dependency-injection/Injectable\";\nimport { Namespace } from \"../generated-proto/pb_schema/cdp/cof/namespace\";\nimport { lensCoreFactory } from \"../lens-core-module/loader/lensCoreFactory\";\nimport { LensCore } from \"../lens-core-module/lensCore\";\nimport { LensCoreConfig, SetPreloadedConfigurationInput } from \"../lens-core-module/generated-types\";\nimport { getLogger } from \"../logger/logger\";\nimport { RemoteConfiguration, remoteConfigurationFactory } from \"./remoteConfiguration\";\n\nconst logger = getLogger(\"setPreloadedConfiguration\");\n\nexport const setPreloadedConfiguration = Injectable(\n \"setPreloadedConfiguration\",\n [lensCoreFactory.token, remoteConfigurationFactory.token] as const,\n (lensCore: LensCore, remoteConfiguration: RemoteConfiguration) => {\n remoteConfiguration\n .getNamespace(Namespace.LENS_CORE_CONFIG)\n .pipe(take(1))\n .subscribe({\n next: (configs) => {\n const inputs: SetPreloadedConfigurationInput = configs.map(\n ({ configId, value }) => ({ configId, value } as LensCoreConfig)\n );\n\n lensCore.setPreloadedConfiguration(inputs);\n },\n error: logger.error,\n });\n }\n);\n"]}
@@ -81,12 +81,7 @@ export declare const lensKeyboardFactory: {
81
81
  lens: Lens;
82
82
  launchData?: import("..").LensLaunchData | undefined;
83
83
  }> | import("@snap/state-management").Action<"downloadComplete", Lens> | import("@snap/state-management").Action<"turnedOn", Lens> | import("@snap/state-management").Action<"resourcesLoaded", Lens> | import("@snap/state-management").Action<"firstFrameProcessed", Lens> | import("@snap/state-management").Action<"applyLensComplete", Lens> | import("@snap/state-management").Action<"applyLensFailed", {
84
- error: import("./lensState").LensErrors; /**
85
- * Send text to the active Lens. Also updates the provided HTMLTextAreaElement.
86
- *
87
- * @param text String to render. This can include escape sequences, such as the newline character ( \n ) for
88
- * multi-line input.
89
- */
84
+ error: import("./lensState").LensErrors;
90
85
  lens: Lens;
91
86
  }> | import("@snap/state-management").Action<"applyLensAborted", Lens> | import("@snap/state-management").Action<"removeLens", undefined> | import("@snap/state-management").Action<"turnedOff", Lens> | import("@snap/state-management").Action<"removeLensComplete", undefined> | import("@snap/state-management").Action<"removeLensFailed", Error>, import("@snap/state-management").State<"noLensApplied", undefined> | import("@snap/state-management").State<"applyingLens", Lens> | import("@snap/state-management").State<"lensApplied", Lens>>): LensKeyboard;
92
87
  token: "lensKeyboard";
@@ -7,6 +7,7 @@ import { LensAssetRepository } from "../lens/assets/LensAssetRepository";
7
7
  import { LegalError, LensContentValidationError, LensError } from "../namedErrors";
8
8
  import { MetricsClient } from "../clients/metricsClient";
9
9
  import { LensCore } from "../lens-core-module/lensCore";
10
+ import { RemoteConfiguration } from "../remote-configuration/remoteConfiguration";
10
11
  declare const createLensState: () => StateMachine<import("@snap/state-management").Action<"applyLens", {
11
12
  lens: Lens;
12
13
  launchData?: LensLaunchData | undefined;
@@ -17,7 +18,7 @@ declare const createLensState: () => StateMachine<import("@snap/state-management
17
18
  export type LensErrors = LegalError | LensContentValidationError | LensError;
18
19
  export type LensState = ReturnType<typeof createLensState>;
19
20
  export declare const lensStateFactory: {
20
- (args_0: LensCore, args_1: LensRepository, args_2: LensAssetRepository, args_3: IndexedDBPersistence<ArrayBuffer>, args_4: StateMachine<import("@snap/state-management").Action<"requestLegalPrompt", undefined> | import("@snap/state-management").Action<"accept", string> | import("@snap/state-management").Action<"reject", string>, import("@snap/state-management").State<"unknown", undefined> | import("@snap/state-management").State<"accepted", undefined> | import("@snap/state-management").State<"rejected", undefined>>, args_5: MetricsClient): StateMachine<import("@snap/state-management").Action<"applyLens", {
21
+ (args_0: LensCore, args_1: LensRepository, args_2: LensAssetRepository, args_3: IndexedDBPersistence<ArrayBuffer>, args_4: StateMachine<import("@snap/state-management").Action<"requestLegalPrompt", undefined> | import("@snap/state-management").Action<"accept", string> | import("@snap/state-management").Action<"reject", string>, import("@snap/state-management").State<"unknown", undefined> | import("@snap/state-management").State<"accepted", undefined> | import("@snap/state-management").State<"rejected", undefined>>, args_5: MetricsClient, args_6: RemoteConfiguration): StateMachine<import("@snap/state-management").Action<"applyLens", {
21
22
  lens: Lens;
22
23
  launchData?: LensLaunchData | undefined;
23
24
  }> | import("@snap/state-management").Action<"downloadComplete", Lens> | import("@snap/state-management").Action<"turnedOn", Lens> | import("@snap/state-management").Action<"resourcesLoaded", Lens> | import("@snap/state-management").Action<"firstFrameProcessed", Lens> | import("@snap/state-management").Action<"applyLensComplete", Lens> | import("@snap/state-management").Action<"applyLensFailed", {
@@ -25,6 +26,6 @@ export declare const lensStateFactory: {
25
26
  lens: Lens;
26
27
  }> | import("@snap/state-management").Action<"applyLensAborted", Lens> | import("@snap/state-management").Action<"removeLens", undefined> | import("@snap/state-management").Action<"turnedOff", Lens> | import("@snap/state-management").Action<"removeLensComplete", undefined> | import("@snap/state-management").Action<"removeLensFailed", Error>, import("@snap/state-management").State<"noLensApplied", undefined> | import("@snap/state-management").State<"applyingLens", Lens> | import("@snap/state-management").State<"lensApplied", Lens>>;
27
28
  token: "lensState";
28
- dependencies: readonly ["lensCore", "LensRepository", "lensAssetRepository", "lensPersistenceStore", "legalState", "metricsClient"];
29
+ dependencies: readonly ["lensCore", "LensRepository", "lensAssetRepository", "lensPersistenceStore", "legalState", "metricsClient", "remoteConfiguration"];
29
30
  };
30
31
  export {};