@snap/camera-kit 0.10.0 → 0.11.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 (242) hide show
  1. package/docs/html/assets/search.js +1 -1
  2. package/docs/html/classes/CameraKit.html +116 -100
  3. package/docs/html/classes/CameraKitSession.html +175 -153
  4. package/docs/html/classes/CameraKitSource.html +109 -101
  5. package/docs/html/classes/LensPerformanceMeasurement.html +98 -94
  6. package/docs/html/classes/LensPerformanceMetrics.html +83 -81
  7. package/docs/html/classes/LensRepository.html +120 -109
  8. package/docs/html/classes/LensSources.html +86 -82
  9. package/docs/html/classes/Transform2D.html +98 -94
  10. package/docs/html/classes/TypedCustomEvent.html +83 -82
  11. package/docs/html/classes/TypedEventTarget.html +92 -91
  12. package/docs/html/functions/Injectable.html +87 -80
  13. package/docs/html/functions/bootstrapCameraKit.html +89 -86
  14. package/docs/html/functions/createExtension.html +76 -75
  15. package/docs/html/functions/createImageSource.html +80 -77
  16. package/docs/html/functions/createMediaStreamSource.html +80 -77
  17. package/docs/html/functions/createUserMediaSource.html +84 -81
  18. package/docs/html/functions/createVideoSource.html +80 -77
  19. package/docs/html/functions/estimateLensPerformance.html +76 -75
  20. package/docs/html/functions/getRequiredBootstrapURLs.html +78 -76
  21. package/docs/html/functions/lensSourcesFactory.html +74 -74
  22. package/docs/html/functions/uriHandlersFactory.html +76 -75
  23. package/docs/html/index.html +75 -75
  24. package/docs/html/interfaces/CameraKitBootstrapConfiguration.html +107 -100
  25. package/docs/html/interfaces/CameraKitSourceSubscriber.html +82 -81
  26. package/docs/html/interfaces/ComputedFrameMetrics.html +94 -84
  27. package/docs/html/interfaces/CreateSessionOptions.html +86 -83
  28. package/docs/html/interfaces/EstimatedLensPerformance.html +85 -84
  29. package/docs/html/interfaces/Lens.html +114 -106
  30. package/docs/html/interfaces/LensSource.html +102 -94
  31. package/docs/html/interfaces/MediaStreamSourceOptions.html +80 -80
  32. package/docs/html/interfaces/Preview.html +81 -79
  33. package/docs/html/interfaces/Snapcode.html +86 -83
  34. package/docs/html/interfaces/UriCancelRequest.html +80 -80
  35. package/docs/html/interfaces/UriHandler.html +102 -93
  36. package/docs/html/interfaces/UriRequest.html +89 -89
  37. package/docs/html/interfaces/UriResponse.html +89 -89
  38. package/docs/html/interfaces/VideoSourceOptions.html +77 -77
  39. package/docs/html/modules.html +153 -153
  40. package/docs/html/types/AssetLoader.html +75 -74
  41. package/docs/html/types/AssetTiming.html +75 -74
  42. package/docs/html/types/BenchmarkError.html +73 -73
  43. package/docs/html/types/BootstrapError.html +75 -74
  44. package/docs/html/types/CacheKeyNotFoundError.html +73 -73
  45. package/docs/html/types/CameraKitDeviceInfo.html +75 -74
  46. package/docs/html/types/CameraKitSessionEventListener.html +75 -74
  47. package/docs/html/types/CameraKitSessionEvents.html +82 -74
  48. package/docs/html/types/CameraKitSourceError.html +73 -73
  49. package/docs/html/types/CameraKitSourceInfo.html +73 -73
  50. package/docs/html/types/CameraKitSourceOptions.html +75 -74
  51. package/docs/html/types/ConfigurationError.html +75 -74
  52. package/docs/html/types/Keyboard.html +85 -80
  53. package/docs/html/types/KeyboardEvents.html +84 -74
  54. package/docs/html/types/LegalError.html +73 -73
  55. package/docs/html/types/LensAssetError.html +75 -74
  56. package/docs/html/types/LensContentValidationError.html +73 -73
  57. package/docs/html/types/LensError.html +73 -73
  58. package/docs/html/types/LensExecutionError.html +75 -74
  59. package/docs/html/types/LensImagePickerError.html +75 -74
  60. package/docs/html/types/LensLaunchParams.html +75 -74
  61. package/docs/html/types/LensMetricsEvents.html +75 -74
  62. package/docs/html/types/LensPerformanceCluster.html +75 -74
  63. package/docs/html/types/LensView.html +75 -74
  64. package/docs/html/types/LensWait.html +75 -74
  65. package/docs/html/types/PersistentStoreError.html +75 -74
  66. package/docs/html/types/PlatformNotSupportedError.html +75 -74
  67. package/docs/html/types/PublicContainer.html +75 -74
  68. package/docs/html/types/RenderTarget.html +75 -74
  69. package/docs/html/types/Uri.html +73 -73
  70. package/docs/html/types/UriHandlers.html +75 -74
  71. package/docs/html/types/WebGLError.html +73 -73
  72. package/docs/html/variables/extensionRequestContext.html +75 -74
  73. package/docs/md/classes/CameraKit.md +14 -1
  74. package/docs/md/classes/CameraKitSession.md +1 -1
  75. package/docs/md/classes/CameraKitSource.md +1 -1
  76. package/docs/md/classes/LensPerformanceMeasurement.md +1 -1
  77. package/docs/md/classes/LensPerformanceMetrics.md +1 -1
  78. package/docs/md/classes/LensRepository.md +1 -1
  79. package/docs/md/classes/LensSources.md +1 -1
  80. package/docs/md/classes/Transform2D.md +1 -1
  81. package/docs/md/classes/TypedCustomEvent.md +1 -1
  82. package/docs/md/classes/TypedEventTarget.md +1 -1
  83. package/docs/md/interfaces/CameraKitBootstrapConfiguration.md +1 -1
  84. package/docs/md/interfaces/CameraKitSourceSubscriber.md +1 -1
  85. package/docs/md/interfaces/ComputedFrameMetrics.md +15 -1
  86. package/docs/md/interfaces/CreateSessionOptions.md +1 -1
  87. package/docs/md/interfaces/EstimatedLensPerformance.md +1 -1
  88. package/docs/md/interfaces/Lens.md +1 -1
  89. package/docs/md/interfaces/LensSource.md +1 -1
  90. package/docs/md/interfaces/MediaStreamSourceOptions.md +1 -1
  91. package/docs/md/interfaces/Preview.md +1 -1
  92. package/docs/md/interfaces/Snapcode.md +1 -1
  93. package/docs/md/interfaces/UriCancelRequest.md +1 -1
  94. package/docs/md/interfaces/UriHandler.md +1 -1
  95. package/docs/md/interfaces/UriRequest.md +1 -1
  96. package/docs/md/interfaces/UriResponse.md +1 -1
  97. package/docs/md/interfaces/VideoSourceOptions.md +1 -1
  98. package/docs/md/modules.md +2 -2
  99. package/lib/CameraKit.d.ts +21 -12
  100. package/lib/CameraKit.js +32 -4
  101. package/lib/CameraKit.js.map +1 -1
  102. package/lib/bootstrapCameraKit.js +5 -3
  103. package/lib/bootstrapCameraKit.js.map +1 -1
  104. package/lib/common/__mocks__/loadScript.d.ts +1 -1
  105. package/lib/common/__mocks__/loadScript.js +1 -1
  106. package/lib/common/__mocks__/loadScript.js.map +1 -1
  107. package/lib/common/dialog.d.ts +16 -0
  108. package/lib/common/dialog.js +146 -0
  109. package/lib/common/dialog.js.map +1 -0
  110. package/lib/common/hash.d.ts +5 -0
  111. package/lib/common/hash.js +17 -0
  112. package/lib/common/hash.js.map +1 -0
  113. package/lib/common/loadScript.d.ts +6 -1
  114. package/lib/common/loadScript.js +9 -2
  115. package/lib/common/loadScript.js.map +1 -1
  116. package/lib/common/localization.d.ts +17 -10
  117. package/lib/common/localization.js +653 -18
  118. package/lib/common/localization.js.map +1 -1
  119. package/lib/common/pageVisibility.d.ts +34 -20
  120. package/lib/common/pageVisibility.js +57 -48
  121. package/lib/common/pageVisibility.js.map +1 -1
  122. package/lib/dependency-injection/Container.d.ts +2 -2
  123. package/lib/dependency-injection/Container.js +10 -10
  124. package/lib/dependency-injection/Container.js.map +1 -1
  125. package/lib/dependency-injection/RootServices.d.ts +3 -1
  126. package/lib/dependency-injection/RootServices.js.map +1 -1
  127. package/lib/environment.json +1 -1
  128. package/lib/extensions/LensSources.d.ts +5 -5
  129. package/lib/extensions/LensSources.js +9 -9
  130. package/lib/extensions/LensSources.js.map +1 -1
  131. package/lib/extensions/UriHandlers.d.ts +1 -1
  132. package/lib/generated-proto/pb_schema/camera_kit/v3/legal_prompt.d.ts +5 -0
  133. package/lib/generated-proto/pb_schema/camera_kit/v3/legal_prompt.js +61 -0
  134. package/lib/generated-proto/pb_schema/camera_kit/v3/legal_prompt.js.map +1 -1
  135. package/lib/generated-proto/pb_schema/camera_kit/v3/service.d.ts +49 -0
  136. package/lib/generated-proto/pb_schema/camera_kit/v3/service.js +17 -1
  137. package/lib/generated-proto/pb_schema/camera_kit/v3/service.js.map +1 -1
  138. package/lib/generated-proto/pb_schema/cdp/cof/circumstance_service.d.ts +578 -0
  139. package/lib/generated-proto/pb_schema/cdp/cof/config_response.d.ts +84 -0
  140. package/lib/generated-proto/pb_schema/cdp/cof/config_result.d.ts +222 -1
  141. package/lib/generated-proto/pb_schema/cdp/cof/config_result.js +98 -2
  142. package/lib/generated-proto/pb_schema/cdp/cof/config_result.js.map +1 -1
  143. package/lib/handlers/HandlerChainBuilder.js +7 -2
  144. package/lib/handlers/HandlerChainBuilder.js.map +1 -1
  145. package/lib/handlers/batchingHandler.d.ts +8 -2
  146. package/lib/handlers/batchingHandler.js +5 -8
  147. package/lib/handlers/batchingHandler.js.map +1 -1
  148. package/lib/handlers/mappingHandler.d.ts +5 -1
  149. package/lib/handlers/mappingHandler.js +6 -4
  150. package/lib/handlers/mappingHandler.js.map +1 -1
  151. package/lib/handlers/rateLimitingHandler.d.ts +5 -1
  152. package/lib/handlers/rateLimitingHandler.js +6 -4
  153. package/lib/handlers/rateLimitingHandler.js.map +1 -1
  154. package/lib/handlers/responseCachingHandler.d.ts +1 -1
  155. package/lib/handlers/responseCachingHandler.js.map +1 -1
  156. package/lib/handlers/retryingHandler.d.ts +5 -1
  157. package/lib/handlers/retryingHandler.js +13 -9
  158. package/lib/handlers/retryingHandler.js.map +1 -1
  159. package/lib/legal/legalPrompt.d.ts +7 -4
  160. package/lib/legal/legalPrompt.js +122 -133
  161. package/lib/legal/legalPrompt.js.map +1 -1
  162. package/lib/legal/legalState.d.ts +2 -2
  163. package/lib/legal/legalState.js +52 -38
  164. package/lib/legal/legalState.js.map +1 -1
  165. package/lib/lens-core-module/loader/lensCoreFactory.js +3 -1
  166. package/lib/lens-core-module/loader/lensCoreFactory.js.map +1 -1
  167. package/lib/lensCoreWasmVersions.json +3 -3
  168. package/lib/logger/logEntries.d.ts +1 -1
  169. package/lib/logger/logEntries.js +3 -3
  170. package/lib/logger/logEntries.js.map +1 -1
  171. package/lib/logger/logger.d.ts +7 -2
  172. package/lib/logger/logger.js +9 -4
  173. package/lib/logger/logger.js.map +1 -1
  174. package/lib/media-sources/MediaStreamSource.js +9 -4
  175. package/lib/media-sources/MediaStreamSource.js.map +1 -1
  176. package/lib/metrics/businessEventsReporter.d.ts +3 -2
  177. package/lib/metrics/businessEventsReporter.js +16 -9
  178. package/lib/metrics/businessEventsReporter.js.map +1 -1
  179. package/lib/metrics/metricsHandler.d.ts +3 -2
  180. package/lib/metrics/metricsHandler.js +3 -3
  181. package/lib/metrics/metricsHandler.js.map +1 -1
  182. package/lib/metrics/operational/Count.d.ts +17 -0
  183. package/lib/metrics/operational/Count.js +28 -0
  184. package/lib/metrics/operational/Count.js.map +1 -0
  185. package/lib/metrics/operational/Histogram.d.ts +17 -0
  186. package/lib/metrics/operational/Histogram.js +23 -0
  187. package/lib/metrics/operational/Histogram.js.map +1 -0
  188. package/lib/metrics/operational/Metric.d.ts +20 -0
  189. package/lib/metrics/operational/Metric.js +26 -0
  190. package/lib/metrics/operational/Metric.js.map +1 -0
  191. package/lib/metrics/operational/Timer.d.ts +91 -0
  192. package/lib/metrics/operational/Timer.js +122 -0
  193. package/lib/metrics/operational/Timer.js.map +1 -0
  194. package/lib/metrics/{operationalMetricsReporter.d.ts → operational/operationalMetricsReporter.d.ts} +15 -4
  195. package/lib/metrics/{operationalMetricsReporter.js → operational/operationalMetricsReporter.js} +24 -8
  196. package/lib/metrics/operational/operationalMetricsReporter.js.map +1 -0
  197. package/lib/metrics/reporters/reportBenchmarks.d.ts +1 -1
  198. package/lib/metrics/reporters/reportBenchmarks.js +1 -1
  199. package/lib/metrics/reporters/reportBenchmarks.js.map +1 -1
  200. package/lib/metrics/reporters/reportGlobalException.d.ts +1 -1
  201. package/lib/metrics/reporters/reportGlobalException.js +1 -1
  202. package/lib/metrics/reporters/reportGlobalException.js.map +1 -1
  203. package/lib/metrics/reporters/reportHttpMetrics.d.ts +1 -1
  204. package/lib/metrics/reporters/reportHttpMetrics.js +1 -1
  205. package/lib/metrics/reporters/reportHttpMetrics.js.map +1 -1
  206. package/lib/metrics/reporters/reportLegalState.d.ts +1 -1
  207. package/lib/metrics/reporters/reportLegalState.js +1 -1
  208. package/lib/metrics/reporters/reportLegalState.js.map +1 -1
  209. package/lib/metrics/reporters/reportLensAndAssetDownload.d.ts +1 -1
  210. package/lib/metrics/reporters/reportLensAndAssetDownload.js +1 -1
  211. package/lib/metrics/reporters/reportLensAndAssetDownload.js.map +1 -1
  212. package/lib/metrics/reporters/reportLensValidationFailed.d.ts +1 -1
  213. package/lib/metrics/reporters/reportLensView.d.ts +2 -2
  214. package/lib/metrics/reporters/reportLensView.js +23 -17
  215. package/lib/metrics/reporters/reportLensView.js.map +1 -1
  216. package/lib/metrics/reporters/reportLensWait.d.ts +2 -2
  217. package/lib/metrics/reporters/reportLensWait.js +1 -1
  218. package/lib/metrics/reporters/reportLensWait.js.map +1 -1
  219. package/lib/metrics/reporters/reportSessionException.d.ts +1 -1
  220. package/lib/metrics/reporters/reporters.d.ts +6 -6
  221. package/lib/metrics/reporters/reporters.js +3 -3
  222. package/lib/metrics/reporters/reporters.js.map +1 -1
  223. package/lib/observable-operators/unsubscribed.d.ts +12 -0
  224. package/lib/observable-operators/unsubscribed.js +27 -0
  225. package/lib/observable-operators/unsubscribed.js.map +1 -0
  226. package/lib/remote-configuration/cofHandler.d.ts +1 -1
  227. package/lib/remote-configuration/cofHandler.js.map +1 -1
  228. package/lib/remote-configuration/remoteConfiguration.d.ts +15 -4
  229. package/lib/remote-configuration/remoteConfiguration.js +30 -5
  230. package/lib/remote-configuration/remoteConfiguration.js.map +1 -1
  231. package/lib/session/CameraKitSession.d.ts +4 -3
  232. package/lib/session/CameraKitSession.js +6 -5
  233. package/lib/session/CameraKitSession.js.map +1 -1
  234. package/lib/session/LensKeyboard.d.ts +1 -1
  235. package/lib/session/LensPerformanceMeasurement.d.ts +2 -0
  236. package/lib/session/LensPerformanceMeasurement.js +27 -4
  237. package/lib/session/LensPerformanceMeasurement.js.map +1 -1
  238. package/lib/session/lensState.d.ts +5 -4
  239. package/lib/session/lensState.js +94 -39
  240. package/lib/session/lensState.js.map +1 -1
  241. package/package.json +12 -12
  242. package/lib/metrics/operationalMetricsReporter.js.map +0 -1
@@ -1 +1 @@
1
- {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CAAC,CAAC,aAAa,CAAC,SAAS,CAAC;YAC3G,oGAAoG;YACpG,oGAAoG;YACpG,uFAAuF;YACvF,OAAO,IAAI,SAAS,CAAC,gCACd,IAAI,CAAC,SAAS,GACd,SAAS,CACqD,CAAC,CAAC;SAC1E;QACD,OAAO,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;IAC/C,CAAC;IAEO,eAAe,CACnB,EAAwD;QAExD,MAAM,KAAK,GAAG,EAAE,CAAC,KAAK,CAAC;QACvB,MAAM,YAAY,GAAmB,EAAE,CAAC,YAAY,CAAC;QAErD,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,SAA8B,EAAE,EAAE;YACvD,OAAO,EAAE,CACL,GAAI,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;gBACvB,6FAA6F;gBAC7F,kGAAkG;gBAClG,+CAA+C;gBAC/C,EAAE;gBACF,mGAAmG;gBACnG,iGAAiG;gBACjG,mGAAmG;gBACnG,oCAAoC;gBACpC,OAAO,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACxD,CAAC,CAAS,CACb,CAAC;QACN,CAAC,CAAC,CAAC;QAEH,oGAAoG;QACpG,2GAA2G;QAC3G,qGAAqG;QACrG,MAAM,SAAS,mCAAQ,IAAI,CAAC,SAAS,KAAE,CAAC,KAAK,CAAC,EAAE,OAAO,GAAE,CAAC;QAC1D,OAAO,IAAI,SAAS,CAAC,SAAoF,CAAC,CAAC;IAC/G,CAAC;CACJ","sourcesContent":["import { isMemoized, memoize, Memoized } from \"../common/memoize\";\nimport { PartialContainer } from \"./PartialContainer\";\nimport { AddService, InjectableFunction, ValidTokens } from \"./types\";\n\ntype MaybeMemoizedFactories<Services> = {\n [K in keyof Services]:\n | ((c: Container<Services>) => Services[K])\n | Memoized<(c: Container<Services>) => Services[K]>;\n};\n\nexport type Factories<Services> = {\n [K in keyof Services]: Memoized<(c: Container<Services>) => Services[K]>;\n};\n\nexport const CONTAINER = \"$container\";\nexport type ContainerToken = typeof CONTAINER;\n\n/**\n * A Container of values, indexed each by a unique token, which can be used throughout CameraKit. This is how CameraKit\n * implements simple dependency injection.\n *\n * Dependency injection is a way to decouple the *use* of a dependency from the *creation* of that dependency. This\n * improves modularity and re-usability, since components only care about the *interfaces* of dependencies (since that\n * determines their use) and not about their concrete creation. New implementations of a particular dependency may be\n * provided without the need to change any of the consumers of that dependency.\n *\n * There are a few commonly-used terms used when talking about dependency injection:\n *\n * - Container (or Injector): Maintains a registry of all available Services and understands how to create them.\n * - Service: Anything that can be provided by the Container is called a Service – this can be a value of any type.\n * - Token: Each Service is associated with a unique name, or Token. In order to obtain a Service from the Container,\n * the consumer must provide the Token corresponding to that Service.\n * - InjectableFunction: Services are created by InjectableFunctions. When adding a Service to a Container, the\n * Service provider gives the Container a InjectableFunction which, when called will return the Service. These\n * InjectableFunctions may themselves use other Services, which will be passed to them as arguments.\n *\n * Services are, by default, singletons – that is, each call to `get()` a particular Service will return a reference\n * to the same value. In other words, InjectableFunctions are only invoked once. If multiple instances of a Service are\n * desired, a new Container can be created using the `copy([Token])` method – passing a Token to this method forces the\n * new Container to recreate the corresponding Service (the InjectableFunction will be invoked again). We say that the\n * Service is then \"scoped\" to the new Container.\n *\n *\n * One common downside of many dependency injection implementations is that the dependency graph formed by the various\n * Services can only be validated at runtime. That is, if a dependency is missing or a circular dependency is found, the\n * developer must wait until runtime to discover the error. These errors can often be confusing and hard to debug.\n *\n * This implementation eliminates this issue by moving these sorts of errors to compile time. If an unknown dependency\n * is used in a InjectableFunction, for example, the code simply won't compile.\n *\n * To achieve this, we do lose the ability to implicitly define the dependency graph, as is common with many dependency\n * injection frameworks that employ decorators to define Services and their dependencies. Instead, the dependency graph\n * must be constructed explicitly, step-by-step, via successive calls to the `provide()` method. This is a suitable\n * trade-off for CameraKit, as there are a relatively small number of Services.\n *\n * Here's a simple example of Container usage:\n * ```ts\n * const fooFactory = Injectable('Foo', () => new Foo())\n * const barFactory = Injectable('Bar', ['Foo'] as const, (foo: Foo) => new Bar(foo))\n * const container = Container.empy()\n * .provide(fooFactory)\n * .provide(barFactory)\n *\n * const bar: Bar = container.get('Bar')\n * ```\n */\n/** @internal */\nexport class Container<Services = {}> {\n private readonly factories: Factories<Services>;\n\n constructor(factories: MaybeMemoizedFactories<Services>) {\n this.factories = {} as Factories<Services>;\n for (const k in factories) {\n const fn = factories[k];\n if (isMemoized(fn)) this.factories[k] = fn;\n else this.factories[k] = memoize(fn);\n }\n }\n\n /**\n * Create a new [Container] by providing a [PartialContainer] that has no dependencies.\n */\n static provides<Services>(container: PartialContainer<Services, {}> | Container<Services>): Container<Services>;\n\n /**\n * Create a new [Container] by providing a Service that has no dependencies.\n */\n static provides<Token extends string, Service>(\n fn: InjectableFunction<{}, [], Token, Service>\n ): Container<AddService<{}, Token, Service>>;\n\n static provides(\n fnOrContainer: InjectableFunction<{}, [], string, any> | PartialContainer<any, {}> | Container<any>\n ): Container<any> {\n // Although the `provides` method has overloads that match both members of the union type separately, it does\n // not match the union type itself, so the compiler forces us to branch and handle each type within the union\n // separately. (Maybe in the future the compiler will decide to infer this, but for now this is necessary.)\n if (fnOrContainer instanceof PartialContainer) return new Container({}).provides(fnOrContainer);\n if (fnOrContainer instanceof Container) return new Container({}).provides(fnOrContainer);\n return new Container({}).provides(fnOrContainer);\n }\n\n /**\n * Create a copy of this Container, optionally providing a list of Services which will be scoped to the copy.\n *\n * This can be useful, for example, if different parts of an application wish to use the same Service interface, but\n * do not want to share a reference to same Service instance.\n *\n * Say we have a Service which manages a list of Users. Our application wishes to display two lists of Users, which\n * may be edited independently. In this case it may be desirable to create a Container for each list component, with\n * the UserList Service scoped to those Containers – that way, each list component gets a unique copy of the\n * UserList Service that can be edited independently of the other.\n *\n * @param scopedServices A list of Tokens identifying Services which will be scoped to the new Container – that is,\n * if those Services had already been created by the source Container, they will be re-created by their Factory\n * functions when provided by the new Container.\n * @returns A new copy of this Container, sharing all of this Container's Services. Services corresponding to any\n * Tokens passed to this method will be re-created by the new Container (i.e. they become \"scoped\" to the new\n * Container).\n */\n copy<Tokens extends readonly (keyof Services)[]>(scopedServices?: Tokens): Container<Services> {\n const factories: MaybeMemoizedFactories<Services> = { ...this.factories };\n\n // We \"un-memoize\" scoped Service InjectableFunctions so they will create a new copy of their Service when\n // provided by the new Container – we re-memoize them so the new Container will itself only create one Service\n // instance.\n (scopedServices || []).forEach((token: keyof Services) => {\n factories[token] = this.factories[token].delegate;\n });\n return new Container(factories);\n }\n\n /**\n * Gets a reference to this Container.\n *\n * @param token The CONTAINER token.\n * @returns This Container.\n */\n get(token: ContainerToken): this;\n\n /**\n * Get a specific Service provided by this Container.\n *\n * @param token A unique string corresponding to a Service\n * @returns A Service corresponding to the given Token.\n */\n get<Token extends keyof Services>(token: Token): Services[Token];\n\n get(token: ContainerToken | keyof Services): this | Services[keyof Services] {\n if (token === CONTAINER) return this;\n const factory = this.factories[token];\n if (!factory) {\n throw new Error(\n `[Container::get] Could not find Service for Token \"${String(token)}\". This should've caused a ` +\n \"compile-time error. If the Token is 'undefined', check all your calls to the Injectable \" +\n \"function. Make sure you define dependencies using string literals or string constants that are \" +\n \"definitely initialized before the call to Injectable.\"\n );\n }\n return factory(this);\n }\n\n /**\n * Run the services in this [PartialContainer]. \"Run\" simply means that [Container::get] will be called for each\n * Service, which invokes that Service's factory function, creating the Service.\n *\n * This may be useful e.g. if services need to initialize themselves, since generally a Service factory is only\n * invoked when the Service is needed.\n *\n * Note this method cannot be used to add services to a Container. – that is, calling this method does not provide\n * the services in a new Container.\n *\n * @param container Optionally provide a [PartialContainer], which will be used as a filter – the only services\n * from *this* container that will run are those with a token that is also present in this PartialContainer.\n * @returns No mutation is done to the Container, it is returned as-is (convenient for chaining).\n */\n run<AdditionalServices, Dependencies, FulfilledDependencies extends Dependencies>(\n // FullfilledDependencies is assignable to Dependencies -- by specifying Container<FulfilledDependencies> as the\n // `this` type, we ensure this Container can provide all the Dependencies required by the PartialContainer.\n this: Container<FulfilledDependencies>,\n container: PartialContainer<AdditionalServices, Dependencies>\n ): this;\n\n /**\n * Run the given Service. \"Run\" simply means that [Container::get] will be called for this Service, which invokes\n * the Service's factory function, creating the Service.\n *\n * This may be useful e.g. if services need to initialize themselves, since generally a Service factory is only\n * invoked when the Service is needed.\n *\n * Note this method cannot be used to add services to a Container. – that is, calling this method does not provide\n * the services in a new Container.\n *\n * @param fn Optionally provide an [InjectableFunction], which will be used as a filter – the only services\n * from *this* container that will run are those with a token that is also present in this PartialContainer.\n * @returns No mutation is done to the Container, it is returned as-is (convenient for chaining).\n */\n run<Token extends string, Tokens extends readonly ValidTokens<Services>[], Service>(\n fn: InjectableFunction<Services, Tokens, Token, Service>\n ): this;\n\n run<Token extends string, Tokens extends readonly ValidTokens<Services>[], Service, AdditionalServices>(\n fnOrContainer:\n | InjectableFunction<Services, Tokens, Token, Service>\n | PartialContainer<AdditionalServices, Services>\n ): this {\n if (fnOrContainer instanceof PartialContainer) {\n const runnableContainer = this.provides(fnOrContainer);\n for (const token of fnOrContainer.getTokens()) {\n runnableContainer.get(token);\n }\n } else {\n this.provides(fnOrContainer).get(fnOrContainer.token);\n }\n return this;\n }\n\n /**\n * Create a new Container from this Container with additional services from a given [PartialContainer].\n *\n * Services in the provided PartialContainer take precedence if there are service token conflicts.\n *\n * Services from the provided PartialContainer become scoped to the new Container – that is, if PartialContainer A\n * is provided to Container X and Container Y, each resultant Container will contain its own copy of the services\n * from PartialContainer A.\n *\n * @param container A [PartialContainer] providing additional services.\n */\n provides<AdditionalServices, Dependencies, FulfilledDependencies extends Dependencies>(\n // FullfilledDependencies is assignable to Dependencies -- by specifying Container<FulfilledDependencies> as the\n // `this` type, we ensure this Container can provide all the Dependencies required by the PartialContainer.\n this: Container<FulfilledDependencies>,\n container: PartialContainer<AdditionalServices, Dependencies>\n ): Container<Services & AdditionalServices>;\n\n /**\n * Creates a new Container from this Container with additional services from another Container.\n *\n * Services in the provided PartialContainer take precedence if there are service token conflicts.\n *\n * Services from the provided Container become scoped to both Containers (the one from which they were provided\n * and the new Container returned by this method) - that is, if Container A is provided to Container B,\n * they will share the same instances of any Services provided by Container A.\n * If Container B should re-create new instances of the Services from Container A,\n * Container A must first be copied before providing it here.\n *\n * @param container A [Container] providing additional services.\n */\n provides<AdditionalServices>(container: Container<AdditionalServices>): Container<Services & AdditionalServices>;\n\n /**\n * Create a new Container which provides a Service created by the given [InjectableFunction].\n *\n * The InjectableFunction contains metadata specifying the Token by which the created Service will be known, as well\n * as an ordered list of Tokens to be resolved and provided to the InjectableFunction as arguments.\n *\n * If any of these required dependencies are missing from the Container (or if there is a mismatch between the types\n * of those dependencies and the arguments of the InjectableFunction), a compiler error will be raised.\n *\n * @param fn A factory function, taking dependencies as arguments, which returns the Service.\n */\n provides<Token extends string, Tokens extends readonly ValidTokens<Services>[], Service>(\n fn: InjectableFunction<Services, Tokens, Token, Service>\n ): Container<AddService<Services, Token, Service>>;\n\n provides<Token extends string, Tokens extends readonly ValidTokens<Services>[], Service, AdditionalServices>(\n fnOrContainer:\n | InjectableFunction<Services, Tokens, Token, Service>\n | PartialContainer<AdditionalServices, Services>\n | Container<AdditionalServices>\n ): Container<any> {\n if (fnOrContainer instanceof PartialContainer || fnOrContainer instanceof Container) {\n const factories =\n fnOrContainer instanceof PartialContainer ? fnOrContainer.getFactories(this) : fnOrContainer.factories;\n // Safety: `this.factories` and `factories` are both properly type checked, so merging them produces\n // a Factories object with keys from both Services and AdditionalServices. The compiler is unable to\n // infer that Factories<A> & Factories<B> == Factories<A & B>, so the cast is required.\n return new Container({\n ...this.factories,\n ...factories,\n } as unknown as MaybeMemoizedFactories<Services & AdditionalServices>);\n }\n return this.providesService(fnOrContainer);\n }\n\n private providesService<Token extends string, Tokens extends readonly ValidTokens<Services>[], Service>(\n fn: InjectableFunction<Services, Tokens, Token, Service>\n ): Container<AddService<Services, Token, Service>> {\n const token = fn.token;\n const dependencies: readonly any[] = fn.dependencies;\n\n const factory = memoize((container: Container<Services>) => {\n return fn(\n ...(dependencies.map((t) => {\n // To support overwriting an already-existing service with a new implementation, it should be\n // possibleto do `provide(A, [A], a => createNewServiceFromOld(a))` – that is, inject a dependency\n // with the same token as this service's token.\n //\n // To avoid a circular dependency (in which the factory for service A depends on itself), we always\n // use the service defined in the *parent* container (i.e. this) when injecting a dependency with\n // the same token as the service we're providing. If we did not do this, calling `container.get(t)`\n // would result in an infinite loop.\n return t === token ? this.get(t) : container.get(t);\n }) as any)\n );\n });\n\n // Safety: `token` and `factory` are property type checked, so extending `this.factories` produces a\n // MaybeMemoizedFactories object with the expected set of services – but when using the spread operation to\n // merge two objects, the compiler widens the Token type to string. So we must re-narrow via casting.\n const factories = { ...this.factories, [token]: factory };\n return new Container(factories as unknown as MaybeMemoizedFactories<AddService<Services, Token, Service>>);\n }\n}\n"]}
1
+ {"version":3,"file":"Container.js","sourceRoot":"","sources":["../../src/dependency-injection/Container.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAY,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAatD,MAAM,CAAC,MAAM,SAAS,GAAG,YAAY,CAAC;AAGtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,gBAAgB;AAChB,MAAM,OAAO,SAAS;IAalB,MAAM,CAAC,QAAQ,CACX,aAAmG;QAEnG,6GAA6G;QAC7G,6GAA6G;QAC7G,2GAA2G;QAC3G,IAAI,aAAa,YAAY,gBAAgB;YAAE,OAAO,IAAI,SAAS,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;QAChG,IAAI,aAAa,YAAY,SAAS;YAAE,OAAO,IAAI,SAAS,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,CA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K,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACxD,CAAC,CAAS,CACb,CAAC;QACN,CAAC,CAAC,CAAC;QAEH,oGAAoG;QACpG,2GAA2G;QAC3G,qGAAqG;QACrG,MAAM,SAAS,mCAAQ,IAAI,CAAC,SAAS,KAAE,CAAC,KAAK,CAAC,EAAE,OAAO,GAAE,CAAC;QAC1D,OAAO,IAAI,SAAS,CAAC,SAAoF,CAAC,CAAC;IAC/G,CAAC;CACJ","sourcesContent":["import { isMemoized, memoize, Memoized } from \"../common/memoize\";\nimport { PartialContainer } from \"./PartialContainer\";\nimport { AddService, InjectableFunction, ValidTokens } from \"./types\";\n\ntype MaybeMemoizedFactories<Services> = {\n [K in keyof Services]:\n | ((c: Container<Services>) => Services[K])\n | Memoized<(c: Container<Services>) => Services[K]>;\n};\n\nexport type Factories<Services> = {\n [K in keyof Services]: Memoized<(c: Container<Services>) => Services[K]>;\n};\n\nexport const CONTAINER = \"$container\";\nexport type ContainerToken = typeof CONTAINER;\n\n/**\n * A Container of values, indexed each by a unique token, which can be used throughout CameraKit. This is how CameraKit\n * implements simple dependency injection.\n *\n * Dependency injection is a way to decouple the *use* of a dependency from the *creation* of that dependency. This\n * improves modularity and re-usability, since components only care about the *interfaces* of dependencies (since that\n * determines their use) and not about their concrete creation. New implementations of a particular dependency may be\n * provided without the need to change any of the consumers of that dependency.\n *\n * There are a few commonly-used terms used when talking about dependency injection:\n *\n * - Container (or Injector): Maintains a registry of all available Services and understands how to create them.\n * - Service: Anything that can be provided by the Container is called a Service – this can be a value of any type.\n * - Token: Each Service is associated with a unique name, or Token. In order to obtain a Service from the Container,\n * the consumer must provide the Token corresponding to that Service.\n * - InjectableFunction: Services are created by InjectableFunctions. When adding a Service to a Container, the\n * Service provider gives the Container a InjectableFunction which, when called will return the Service. These\n * InjectableFunctions may themselves use other Services, which will be passed to them as arguments.\n *\n * Services are, by default, singletons – that is, each call to `get()` a particular Service will return a reference\n * to the same value. In other words, InjectableFunctions are only invoked once. If multiple instances of a Service are\n * desired, a new Container can be created using the `copy([Token])` method – passing a Token to this method forces the\n * new Container to recreate the corresponding Service (the InjectableFunction will be invoked again). We say that the\n * Service is then \"scoped\" to the new Container.\n *\n *\n * One common downside of many dependency injection implementations is that the dependency graph formed by the various\n * Services can only be validated at runtime. That is, if a dependency is missing or a circular dependency is found, the\n * developer must wait until runtime to discover the error. These errors can often be confusing and hard to debug.\n *\n * This implementation eliminates this issue by moving these sorts of errors to compile time. If an unknown dependency\n * is used in a InjectableFunction, for example, the code simply won't compile.\n *\n * To achieve this, we do lose the ability to implicitly define the dependency graph, as is common with many dependency\n * injection frameworks that employ decorators to define Services and their dependencies. Instead, the dependency graph\n * must be constructed explicitly, step-by-step, via successive calls to the `provide()` method. This is a suitable\n * trade-off for CameraKit, as there are a relatively small number of Services.\n *\n * Here's a simple example of Container usage:\n * ```ts\n * const fooFactory = Injectable('Foo', () => new Foo())\n * const barFactory = Injectable('Bar', ['Foo'] as const, (foo: Foo) => new Bar(foo))\n * const container = Container.empy()\n * .provide(fooFactory)\n * .provide(barFactory)\n *\n * const bar: Bar = container.get('Bar')\n * ```\n */\n/** @internal */\nexport class Container<Services = {}> {\n /**\n * Create a new [Container] by providing a [PartialContainer] that has no dependencies.\n */\n static provides<Services>(container: PartialContainer<Services, {}> | Container<Services>): Container<Services>;\n\n /**\n * Create a new [Container] by providing a Service that has no dependencies.\n */\n static provides<Token extends string, Service>(\n fn: InjectableFunction<{}, [], Token, Service>\n ): Container<AddService<{}, Token, Service>>;\n\n static provides(\n fnOrContainer: InjectableFunction<{}, [], string, any> | PartialContainer<any, {}> | Container<any>\n ): Container<any> {\n // Although the `provides` method has overloads that match both members of the union type separately, it does\n // not match the union type itself, so the compiler forces us to branch and handle each type within the union\n // separately. (Maybe in the future the compiler will decide to infer this, but for now this is necessary.)\n if (fnOrContainer instanceof PartialContainer) return new Container({}).provides(fnOrContainer);\n if (fnOrContainer instanceof Container) return new Container({}).provides(fnOrContainer);\n return new Container({}).provides(fnOrContainer);\n }\n\n private readonly factories: Factories<Services>;\n\n constructor(factories: MaybeMemoizedFactories<Services>) {\n this.factories = {} as Factories<Services>;\n for (const k in factories) {\n const fn = factories[k];\n if (isMemoized(fn)) this.factories[k] = fn;\n else this.factories[k] = memoize(fn);\n }\n }\n\n /**\n * Create a copy of this Container, optionally providing a list of Services which will be scoped to the copy.\n *\n * This can be useful, for example, if different parts of an application wish to use the same Service interface, but\n * do not want to share a reference to same Service instance.\n *\n * Say we have a Service which manages a list of Users. Our application wishes to display two lists of Users, which\n * may be edited independently. In this case it may be desirable to create a Container for each list component, with\n * the UserList Service scoped to those Containers – that way, each list component gets a unique copy of the\n * UserList Service that can be edited independently of the other.\n *\n * @param scopedServices A list of Tokens identifying Services which will be scoped to the new Container – that is,\n * if those Services had already been created by the source Container, they will be re-created by their Factory\n * functions when provided by the new Container.\n * @returns A new copy of this Container, sharing all of this Container's Services. Services corresponding to any\n * Tokens passed to this method will be re-created by the new Container (i.e. they become \"scoped\" to the new\n * Container).\n */\n copy<Tokens extends readonly (keyof Services)[]>(scopedServices?: Tokens): Container<Services> {\n const factories: MaybeMemoizedFactories<Services> = { ...this.factories };\n\n // We \"un-memoize\" scoped Service InjectableFunctions so they will create a new copy of their Service when\n // provided by the new Container – we re-memoize them so the new Container will itself only create one Service\n // instance.\n (scopedServices || []).forEach((token: keyof Services) => {\n factories[token] = this.factories[token].delegate;\n });\n return new Container(factories);\n }\n\n /**\n * Gets a reference to this Container.\n *\n * @param token The CONTAINER token.\n * @returns This Container.\n */\n get(token: ContainerToken): this;\n\n /**\n * Get a specific Service provided by this Container.\n *\n * @param token A unique string corresponding to a Service\n * @returns A Service corresponding to the given Token.\n */\n get<Token extends keyof Services>(token: Token): Services[Token];\n\n get(token: ContainerToken | keyof Services): this | Services[keyof Services] {\n if (token === CONTAINER) return this;\n const factory = this.factories[token];\n if (!factory) {\n throw new Error(\n `[Container::get] Could not find Service for Token \"${String(token)}\". This should've caused a ` +\n \"compile-time error. If the Token is 'undefined', check all your calls to the Injectable \" +\n \"function. Make sure you define dependencies using string literals or string constants that are \" +\n \"definitely initialized before the call to Injectable.\"\n );\n }\n return factory(this);\n }\n\n /**\n * Run the services in this [PartialContainer]. \"Run\" simply means that [Container::get] will be called for each\n * Service, which invokes that Service's factory function, creating the Service.\n *\n * This may be useful e.g. if services need to initialize themselves, since generally a Service factory is only\n * invoked when the Service is needed.\n *\n * Note this method cannot be used to add services to a Container. – that is, calling this method does not provide\n * the services in a new Container.\n *\n * @param container Optionally provide a [PartialContainer], which will be used as a filter – the only services\n * from *this* container that will run are those with a token that is also present in this PartialContainer.\n * @returns No mutation is done to the Container, it is returned as-is (convenient for chaining).\n */\n run<AdditionalServices, Dependencies, FulfilledDependencies extends Dependencies>(\n // FullfilledDependencies is assignable to Dependencies -- by specifying Container<FulfilledDependencies> as the\n // `this` type, we ensure this Container can provide all the Dependencies required by the PartialContainer.\n this: Container<FulfilledDependencies>,\n container: PartialContainer<AdditionalServices, Dependencies>\n ): this;\n\n /**\n * Run the given Service. \"Run\" simply means that [Container::get] will be called for this Service, which invokes\n * the Service's factory function, creating the Service.\n *\n * This may be useful e.g. if services need to initialize themselves, since generally a Service factory is only\n * invoked when the Service is needed.\n *\n * Note this method cannot be used to add services to a Container. – that is, calling this method does not provide\n * the services in a new Container.\n *\n * @param fn Optionally provide an [InjectableFunction], which will be used as a filter – the only services\n * from *this* container that will run are those with a token that is also present in this PartialContainer.\n * @returns No mutation is done to the Container, it is returned as-is (convenient for chaining).\n */\n run<Token extends string, Tokens extends readonly ValidTokens<Services>[], Service>(\n fn: InjectableFunction<Services, Tokens, Token, Service>\n ): this;\n\n run<Token extends string, Tokens extends readonly ValidTokens<Services>[], Service, AdditionalServices>(\n fnOrContainer:\n | InjectableFunction<Services, Tokens, Token, Service>\n | PartialContainer<AdditionalServices, Services>\n ): this {\n if (fnOrContainer instanceof PartialContainer) {\n const runnableContainer = this.provides(fnOrContainer);\n for (const token of fnOrContainer.getTokens()) {\n runnableContainer.get(token);\n }\n } else {\n this.provides(fnOrContainer).get(fnOrContainer.token);\n }\n return this;\n }\n\n /**\n * Create a new Container from this Container with additional services from a given [PartialContainer].\n *\n * Services in the provided PartialContainer take precedence if there are service token conflicts.\n *\n * Services from the provided PartialContainer become scoped to the new Container – that is, if PartialContainer A\n * is provided to Container X and Container Y, each resultant Container will contain its own copy of the services\n * from PartialContainer A.\n *\n * @param container A [PartialContainer] providing additional services.\n */\n provides<AdditionalServices, Dependencies, FulfilledDependencies extends Dependencies>(\n // FullfilledDependencies is assignable to Dependencies -- by specifying Container<FulfilledDependencies> as the\n // `this` type, we ensure this Container can provide all the Dependencies required by the PartialContainer.\n this: Container<FulfilledDependencies>,\n container: PartialContainer<AdditionalServices, Dependencies>\n ): Container<Services & AdditionalServices>;\n\n /**\n * Creates a new Container from this Container with additional services from another Container.\n *\n * Services in the provided PartialContainer take precedence if there are service token conflicts.\n *\n * Services from the provided Container become scoped to both Containers (the one from which they were provided\n * and the new Container returned by this method) - that is, if Container A is provided to Container B,\n * they will share the same instances of any Services provided by Container A.\n * If Container B should re-create new instances of the Services from Container A,\n * Container A must first be copied before providing it here.\n *\n * @param container A [Container] providing additional services.\n */\n provides<AdditionalServices>(container: Container<AdditionalServices>): Container<Services & AdditionalServices>;\n\n /**\n * Create a new Container which provides a Service created by the given [InjectableFunction].\n *\n * The InjectableFunction contains metadata specifying the Token by which the created Service will be known, as well\n * as an ordered list of Tokens to be resolved and provided to the InjectableFunction as arguments.\n *\n * If any of these required dependencies are missing from the Container (or if there is a mismatch between the types\n * of those dependencies and the arguments of the InjectableFunction), a compiler error will be raised.\n *\n * @param fn A factory function, taking dependencies as arguments, which returns the Service.\n */\n provides<Token extends string, Tokens extends readonly ValidTokens<Services>[], Service>(\n fn: InjectableFunction<Services, Tokens, Token, Service>\n ): Container<AddService<Services, Token, Service>>;\n\n provides<Token extends string, Tokens extends readonly ValidTokens<Services>[], Service, AdditionalServices>(\n fnOrContainer:\n | InjectableFunction<Services, Tokens, Token, Service>\n | PartialContainer<AdditionalServices, Services>\n | Container<AdditionalServices>\n ): Container<any> {\n if (fnOrContainer instanceof PartialContainer || fnOrContainer instanceof Container) {\n const factories =\n fnOrContainer instanceof PartialContainer ? fnOrContainer.getFactories(this) : fnOrContainer.factories;\n // Safety: `this.factories` and `factories` are both properly type checked, so merging them produces\n // a Factories object with keys from both Services and AdditionalServices. The compiler is unable to\n // infer that Factories<A> & Factories<B> == Factories<A & B>, so the cast is required.\n return new Container({\n ...this.factories,\n ...factories,\n } as unknown as MaybeMemoizedFactories<Services & AdditionalServices>);\n }\n return this.providesService(fnOrContainer);\n }\n\n private providesService<Token extends string, Tokens extends readonly ValidTokens<Services>[], Service>(\n fn: InjectableFunction<Services, Tokens, Token, Service>\n ): Container<AddService<Services, Token, Service>> {\n const token = fn.token;\n const dependencies: readonly any[] = fn.dependencies;\n\n const factory = memoize((container: Container<Services>) => {\n return fn(\n ...(dependencies.map((t) => {\n // To support overwriting an already-existing service with a new implementation, it should be\n // possibleto do `provide(A, [A], a => createNewServiceFromOld(a))` – that is, inject a dependency\n // with the same token as this service's token.\n //\n // To avoid a circular dependency (in which the factory for service A depends on itself), we always\n // use the service defined in the *parent* container (i.e. this) when injecting a dependency with\n // the same token as the service we're providing. If we did not do this, calling `container.get(t)`\n // would result in an infinite loop.\n return t === token ? this.get(t) : container.get(t);\n }) as any)\n );\n });\n\n // Safety: `token` and `factory` are property type checked, so extending `this.factories` produces a\n // MaybeMemoizedFactories object with the expected set of services – but when using the spread operation to\n // merge two objects, the compiler widens the Token type to string. So we must re-narrow via casting.\n const factories = { ...this.factories, [token]: factory };\n return new Container(factories as unknown as MaybeMemoizedFactories<AddService<Services, Token, Service>>);\n }\n}\n"]}
@@ -9,7 +9,7 @@ import { createCameraKitConfigurationFactory } from "../configuration";
9
9
  import { LensCoreModule } from "../lens-core-module/generated-types";
10
10
  import { metricsEventTargetFactory } from "../metrics/metricsEventTarget";
11
11
  import { metricsHandlerFactory } from "../metrics/metricsHandler";
12
- import { operationalMetricReporterFactory } from "../metrics/operationalMetricsReporter";
12
+ import { operationalMetricReporterFactory } from "../metrics/operational/operationalMetricsReporter";
13
13
  import { lensSourcesFactory } from "../extensions/LensSources";
14
14
  import { uriHandlersFactory } from "../extensions/UriHandlers";
15
15
  import { lensPersistenceStoreFactory } from "../lens/LensPersistenceStore";
@@ -20,12 +20,14 @@ import { legalPromptFactory } from "../legal/legalPrompt";
20
20
  import { logEntriesFactory } from "../logger/logEntries";
21
21
  import { reportGlobalException } from "../metrics/reporters/reportGlobalException";
22
22
  import { requestStateEventTargetFactory } from "../handlers/requestStateEmittingHandler";
23
+ import { pageVisibilityFactory } from "../common/pageVisibility";
23
24
  import { ServicesFromInjectables } from "./types";
24
25
  /**
25
26
  * All services available to be customized by client app.
26
27
  */
27
28
  export type PublicServices = ServicesFromInjectables<[
28
29
  ReturnType<typeof createCameraKitConfigurationFactory>,
30
+ typeof pageVisibilityFactory,
29
31
  typeof defaultFetchHandlerFactory,
30
32
  typeof remoteMediaAssetLoaderFactory,
31
33
  typeof lensSourcesFactory,
@@ -1 +1 @@
1
- {"version":3,"file":"RootServices.js","sourceRoot":"","sources":["../../src/dependency-injection/RootServices.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,4CAA4C,CAAC","sourcesContent":["import { lensRepositoryFactory } from \"../lens/LensRepository\";\nimport { lensCoreFactory } from \"../lens-core-module/loader/lensCoreFactory\";\nimport { remoteMediaAssetLoaderFactory } from \"../lens/assets/remoteMediaAssetLoaderFactory\";\nimport { deviceDependentAssetLoaderFactory } from \"../lens/assets/deviceDependentAssetLoader\";\nimport { staticAssetLoaderFactory } from \"../lens/assets/staticAssetLoader\";\nimport { defaultFetchHandlerFactory } from \"../handlers/defaultFetchHandler\";\nimport { cameraKitServiceFetchHandlerFactory } from \"../handlers/cameraKitServiceFetchHandlerFactory\";\nimport { createCameraKitConfigurationFactory } from \"../configuration\";\nimport { LensCoreModule } from \"../lens-core-module/generated-types\";\nimport { metricsEventTargetFactory } from \"../metrics/metricsEventTarget\";\nimport { metricsHandlerFactory } from \"../metrics/metricsHandler\";\nimport { operationalMetricReporterFactory } from \"../metrics/operationalMetricsReporter\";\nimport { lensSourcesFactory } from \"../extensions/LensSources\";\nimport { uriHandlersFactory } from \"../extensions/UriHandlers\";\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 { logEntriesFactory } from \"../logger/logEntries\";\nimport { reportGlobalException } from \"../metrics/reporters/reportGlobalException\";\nimport { requestStateEventTargetFactory } from \"../handlers/requestStateEmittingHandler\";\nimport { ServicesFromInjectables } from \"./types\";\n\n/**\n * All services available to be customized by client app.\n */\nexport type PublicServices = ServicesFromInjectables<\n [\n ReturnType<typeof createCameraKitConfigurationFactory>,\n typeof defaultFetchHandlerFactory,\n typeof remoteMediaAssetLoaderFactory,\n typeof lensSourcesFactory,\n typeof uriHandlersFactory\n ]\n>;\n\n/**\n * Define all the Services contained in CameraKit's root dependency injection container.\n *\n * Note: we do end up defining this list of Services twice (once here to create the type, once when we actually\n * create the Container inside the `bootstrapCameraKit` function). We could avoid doing this and just infer the\n * RootContainer type from the constructed container – but since we can only do that *inside* `bootstrapCameraKit`, it\n * makes it more awkward to provide a type for the `provide` user-supplied function (or use the type elsewhere, like in\n * CameraKitSession).\n *\n * There may be a way to eliminate this extra boilerplate, but for now it's required in order to present a cleaner\n * `bootstrapCameraKit` API to applications.\n */\nexport type RootServices = {\n // bootstrapCameraKit replaces the lensCoreFactory token's value with the resolved LensCoreModule (rather than the\n // Promise of the LensCoreModule), so we need to do the same re-mapping here.\n [lensCoreFactory.token]: LensCoreModule;\n} & PublicServices &\n ServicesFromInjectables<\n [\n typeof metricsEventTargetFactory,\n typeof requestStateEventTargetFactory,\n typeof cameraKitServiceFetchHandlerFactory,\n typeof remoteConfigurationFactory,\n typeof lensRepositoryFactory,\n typeof lensPersistenceStoreFactory,\n typeof metricsHandlerFactory,\n typeof operationalMetricReporterFactory,\n typeof lensAssetRepositoryFactory,\n typeof deviceDependentAssetLoaderFactory,\n typeof staticAssetLoaderFactory,\n typeof legalStateFactory,\n typeof legalPromptFactory,\n typeof logEntriesFactory,\n typeof reportGlobalException\n ]\n >;\n"]}
1
+ {"version":3,"file":"RootServices.js","sourceRoot":"","sources":["../../src/dependency-injection/RootServices.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,4CAA4C,CAAC","sourcesContent":["import { lensRepositoryFactory } from \"../lens/LensRepository\";\nimport { lensCoreFactory } from \"../lens-core-module/loader/lensCoreFactory\";\nimport { remoteMediaAssetLoaderFactory } from \"../lens/assets/remoteMediaAssetLoaderFactory\";\nimport { deviceDependentAssetLoaderFactory } from \"../lens/assets/deviceDependentAssetLoader\";\nimport { staticAssetLoaderFactory } from \"../lens/assets/staticAssetLoader\";\nimport { defaultFetchHandlerFactory } from \"../handlers/defaultFetchHandler\";\nimport { cameraKitServiceFetchHandlerFactory } from \"../handlers/cameraKitServiceFetchHandlerFactory\";\nimport { createCameraKitConfigurationFactory } from \"../configuration\";\nimport { LensCoreModule } from \"../lens-core-module/generated-types\";\nimport { metricsEventTargetFactory } from \"../metrics/metricsEventTarget\";\nimport { metricsHandlerFactory } from \"../metrics/metricsHandler\";\nimport { operationalMetricReporterFactory } from \"../metrics/operational/operationalMetricsReporter\";\nimport { lensSourcesFactory } from \"../extensions/LensSources\";\nimport { uriHandlersFactory } from \"../extensions/UriHandlers\";\nimport { lensPersistenceStoreFactory } from \"../lens/LensPersistenceStore\";\nimport { remoteConfigurationFactory } from \"../remote-configuration/remoteConfiguration\";\nimport { lensAssetRepositoryFactory } from \"../lens/assets/LensAssetRepository\";\nimport { legalStateFactory } from \"../legal/legalState\";\nimport { legalPromptFactory } from \"../legal/legalPrompt\";\nimport { logEntriesFactory } from \"../logger/logEntries\";\nimport { reportGlobalException } from \"../metrics/reporters/reportGlobalException\";\nimport { requestStateEventTargetFactory } from \"../handlers/requestStateEmittingHandler\";\nimport { pageVisibilityFactory } from \"../common/pageVisibility\";\nimport { ServicesFromInjectables } from \"./types\";\n\n/**\n * All services available to be customized by client app.\n */\nexport type PublicServices = ServicesFromInjectables<\n [\n ReturnType<typeof createCameraKitConfigurationFactory>,\n typeof pageVisibilityFactory,\n typeof defaultFetchHandlerFactory,\n typeof remoteMediaAssetLoaderFactory,\n typeof lensSourcesFactory,\n typeof uriHandlersFactory\n ]\n>;\n\n/**\n * Define all the Services contained in CameraKit's root dependency injection container.\n *\n * Note: we do end up defining this list of Services twice (once here to create the type, once when we actually\n * create the Container inside the `bootstrapCameraKit` function). We could avoid doing this and just infer the\n * RootContainer type from the constructed container – but since we can only do that *inside* `bootstrapCameraKit`, it\n * makes it more awkward to provide a type for the `provide` user-supplied function (or use the type elsewhere, like in\n * CameraKitSession).\n *\n * There may be a way to eliminate this extra boilerplate, but for now it's required in order to present a cleaner\n * `bootstrapCameraKit` API to applications.\n */\nexport type RootServices = {\n // bootstrapCameraKit replaces the lensCoreFactory token's value with the resolved LensCoreModule (rather than the\n // Promise of the LensCoreModule), so we need to do the same re-mapping here.\n [lensCoreFactory.token]: LensCoreModule;\n} & PublicServices &\n ServicesFromInjectables<\n [\n typeof metricsEventTargetFactory,\n typeof requestStateEventTargetFactory,\n typeof cameraKitServiceFetchHandlerFactory,\n typeof remoteConfigurationFactory,\n typeof lensRepositoryFactory,\n typeof lensPersistenceStoreFactory,\n typeof metricsHandlerFactory,\n typeof operationalMetricReporterFactory,\n typeof lensAssetRepositoryFactory,\n typeof deviceDependentAssetLoaderFactory,\n typeof staticAssetLoaderFactory,\n typeof legalStateFactory,\n typeof legalPromptFactory,\n typeof logEntriesFactory,\n typeof reportGlobalException\n ]\n >;\n"]}
@@ -1 +1 @@
1
- { "PACKAGE_VERSION": "0.10.0-alpha.1" }
1
+ { "PACKAGE_VERSION": "0.11.0-alpha.1" }
@@ -26,6 +26,11 @@ export interface LensSource {
26
26
  * methods are called.
27
27
  */
28
28
  export declare class LensSources {
29
+ /**
30
+ * Returns empty LensSources instance.
31
+ * @internal
32
+ */
33
+ static empty(): LensSources;
29
34
  private readonly fallbackSources;
30
35
  private readonly source;
31
36
  /**
@@ -34,11 +39,6 @@ export declare class LensSources {
34
39
  * @param source Lens source.
35
40
  */
36
41
  constructor(fallbackSources: LensSources, source: LensSource);
37
- /**
38
- * Returns empty LensSources instance.
39
- * @internal
40
- */
41
- static empty(): LensSources;
42
42
  /**
43
43
  * Returns envelopes of lens/groups taking into account group ownership.
44
44
  * @internal
@@ -8,15 +8,6 @@ import { Injectable } from "../dependency-injection/Injectable";
8
8
  * methods are called.
9
9
  */
10
10
  export class LensSources {
11
- /**
12
- * Creates an instance of Lens sources.
13
- * @param fallbackSources A fallback sources if given {@link LensSource} doesn't claim a group ownership.
14
- * @param source Lens source.
15
- */
16
- constructor(fallbackSources, source) {
17
- this.fallbackSources = fallbackSources;
18
- this.source = source;
19
- }
20
11
  /**
21
12
  * Returns empty LensSources instance.
22
13
  * @internal
@@ -27,6 +18,15 @@ export class LensSources {
27
18
  // @ts-expect-error
28
19
  return new LensSources();
29
20
  }
21
+ /**
22
+ * Creates an instance of Lens sources.
23
+ * @param fallbackSources A fallback sources if given {@link LensSource} doesn't claim a group ownership.
24
+ * @param source Lens source.
25
+ */
26
+ constructor(fallbackSources, source) {
27
+ this.fallbackSources = fallbackSources;
28
+ this.source = source;
29
+ }
30
30
  /**
31
31
  * Returns envelopes of lens/groups taking into account group ownership.
32
32
  * @internal
@@ -1 +1 @@
1
- {"version":3,"file":"LensSources.js","sourceRoot":"","sources":["../../src/extensions/LensSources.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AA0BhE;;;;;GAKG;AACH,MAAM,OAAO,WAAW;IAIpB;;;;OAIG;IACH,YAAY,eAA4B,EAAE,MAAkB;QACxD,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,KAAK;QACR,qEAAqE;QACrE,sDAAsD;QACtD,mBAAmB;QACnB,OAAO,IAAI,WAAW,EAAE,CAAC;IAC7B,CAAC;IAED;;;;;;OAMG;IACG,cAAc,CAAC,EAAE,OAAO,EAAE,MAAM,EAAwC;;;YAC1E,IAAI,MAAA,IAAI,CAAC,MAAM,0CAAE,YAAY,CAAC,OAAO,CAAC,EAAE;gBACpC,OAAO,WAAW,CAAC,MAAM,CAAC;oBACtB,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC;oBACnC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;aAC7E;YACD,OAAO,MAAA,IAAI,CAAC,eAAe,0CAAE,cAAc,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;;KACpE;CACJ;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC,aAAa,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC,CAAC","sourcesContent":["import { isUndefined } from \"../common/typeguards\";\nimport { Injectable } from \"../dependency-injection/Injectable\";\n\n/**\n * A source of a lens group.\n */\nexport interface LensSource {\n /**\n * Whether the given source is able to load lenses of the supplied group.\n * @param groupId Group ID to check.\n */\n isGroupOwner(groupId: string): boolean;\n\n /**\n * Returns an encoded lens object.\n * @param lensId Lens ID to get.\n * @param groupId Group ID the lens belongs to.\n */\n getLens(lensId: string, groupId: string): Promise<ArrayBuffer>;\n\n /**\n * Returns encoded lens objects.\n * @param groupId Group ID to get lenses of.\n */\n getLensGroup(groupId: string): Promise<ArrayBuffer[]>;\n}\n\n/**\n * A chain of {@link LensSource} objects to be registered in Camera Kit on bootstrap. Camera Kit evaluates all\n * registered {@link LensSource} objects for a group ownership during Lens retrieval ({@link CameraKit.lenses}).\n * And if a source claims the ownership, its {@link LensSource.getLens} or {@link LensSource.getLensGroup}\n * methods are called.\n */\nexport class LensSources {\n private readonly fallbackSources: LensSources | undefined;\n private readonly source: LensSource | undefined;\n\n /**\n * Creates an instance of Lens sources.\n * @param fallbackSources A fallback sources if given {@link LensSource} doesn't claim a group ownership.\n * @param source Lens source.\n */\n constructor(fallbackSources: LensSources, source: LensSource) {\n this.fallbackSources = fallbackSources;\n this.source = source;\n }\n\n /**\n * Returns empty LensSources instance.\n * @internal\n */\n static empty() {\n // NOTE: we want to keep LensSources constructor to require arguments\n // but internally we don't need them for the base case\n // @ts-expect-error\n return new LensSources();\n }\n\n /**\n * Returns envelopes of lens/groups taking into account group ownership.\n * @internal\n * @param groupId A group to test ownership and get lens envelopes of.\n * @param lensId An optional lens ID to narrow envelopes down to a single lens.\n * @returns Envelopes or undefined if not applicable.\n */\n async retrieveLenses({ groupId, lensId }: { groupId: string; lensId?: string }): Promise<ArrayBuffer[] | void> {\n if (this.source?.isGroupOwner(groupId)) {\n return isUndefined(lensId)\n ? this.source.getLensGroup(groupId)\n : this.source.getLens(lensId, groupId).then((envelope) => [envelope]);\n }\n return this.fallbackSources?.retrieveLenses({ groupId, lensId });\n }\n}\n\nexport const lensSourcesFactory = Injectable(\"lensSources\", () => LensSources.empty());\n"]}
1
+ {"version":3,"file":"LensSources.js","sourceRoot":"","sources":["../../src/extensions/LensSources.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AA0BhE;;;;;GAKG;AACH,MAAM,OAAO,WAAW;IACpB;;;OAGG;IACH,MAAM,CAAC,KAAK;QACR,qEAAqE;QACrE,sDAAsD;QACtD,mBAAmB;QACnB,OAAO,IAAI,WAAW,EAAE,CAAC;IAC7B,CAAC;IAKD;;;;OAIG;IACH,YAAY,eAA4B,EAAE,MAAkB;QACxD,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAED;;;;;;OAMG;IACG,cAAc,CAAC,EAAE,OAAO,EAAE,MAAM,EAAwC;;;YAC1E,IAAI,MAAA,IAAI,CAAC,MAAM,0CAAE,YAAY,CAAC,OAAO,CAAC,EAAE;gBACpC,OAAO,WAAW,CAAC,MAAM,CAAC;oBACtB,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC;oBACnC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;aAC7E;YACD,OAAO,MAAA,IAAI,CAAC,eAAe,0CAAE,cAAc,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;;KACpE;CACJ;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC,aAAa,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC,CAAC","sourcesContent":["import { isUndefined } from \"../common/typeguards\";\nimport { Injectable } from \"../dependency-injection/Injectable\";\n\n/**\n * A source of a lens group.\n */\nexport interface LensSource {\n /**\n * Whether the given source is able to load lenses of the supplied group.\n * @param groupId Group ID to check.\n */\n isGroupOwner(groupId: string): boolean;\n\n /**\n * Returns an encoded lens object.\n * @param lensId Lens ID to get.\n * @param groupId Group ID the lens belongs to.\n */\n getLens(lensId: string, groupId: string): Promise<ArrayBuffer>;\n\n /**\n * Returns encoded lens objects.\n * @param groupId Group ID to get lenses of.\n */\n getLensGroup(groupId: string): Promise<ArrayBuffer[]>;\n}\n\n/**\n * A chain of {@link LensSource} objects to be registered in Camera Kit on bootstrap. Camera Kit evaluates all\n * registered {@link LensSource} objects for a group ownership during Lens retrieval ({@link CameraKit.lenses}).\n * And if a source claims the ownership, its {@link LensSource.getLens} or {@link LensSource.getLensGroup}\n * methods are called.\n */\nexport class LensSources {\n /**\n * Returns empty LensSources instance.\n * @internal\n */\n static empty() {\n // NOTE: we want to keep LensSources constructor to require arguments\n // but internally we don't need them for the base case\n // @ts-expect-error\n return new LensSources();\n }\n\n private readonly fallbackSources: LensSources | undefined;\n private readonly source: LensSource | undefined;\n\n /**\n * Creates an instance of Lens sources.\n * @param fallbackSources A fallback sources if given {@link LensSource} doesn't claim a group ownership.\n * @param source Lens source.\n */\n constructor(fallbackSources: LensSources, source: LensSource) {\n this.fallbackSources = fallbackSources;\n this.source = source;\n }\n\n /**\n * Returns envelopes of lens/groups taking into account group ownership.\n * @internal\n * @param groupId A group to test ownership and get lens envelopes of.\n * @param lensId An optional lens ID to narrow envelopes down to a single lens.\n * @returns Envelopes or undefined if not applicable.\n */\n async retrieveLenses({ groupId, lensId }: { groupId: string; lensId?: string }): Promise<ArrayBuffer[] | void> {\n if (this.source?.isGroupOwner(groupId)) {\n return isUndefined(lensId)\n ? this.source.getLensGroup(groupId)\n : this.source.getLens(lensId, groupId).then((envelope) => [envelope]);\n }\n return this.fallbackSources?.retrieveLenses({ groupId, lensId });\n }\n}\n\nexport const lensSourcesFactory = Injectable(\"lensSources\", () => LensSources.empty());\n"]}
@@ -47,7 +47,7 @@ export declare const registerUriHandlers: {
47
47
  }> | 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", {
48
48
  error: import("../session/lensState").LensErrors;
49
49
  lens: Lens;
50
- }> | 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>>, args_2: UriHandlers, args_3: LensKeyboard): void;
50
+ }> | 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>>, args_2: UriHandlers, args_3: LensKeyboard): void;
51
51
  token: "registerUriHandlers";
52
52
  dependencies: readonly ["lensCore", "lensState", "UriHandlers", "lensKeyboard"];
53
53
  };
@@ -31,10 +31,13 @@ export declare enum LegalDocument_Type {
31
31
  UNRECOGNIZED = "UNRECOGNIZED"
32
32
  }
33
33
  export declare function legalDocument_TypeFromJSON(object: any): LegalDocument_Type;
34
+ export declare function legalDocument_TypeToJSON(object: LegalDocument_Type): string;
34
35
  export declare function legalDocument_TypeToNumber(object: LegalDocument_Type): number;
35
36
  export declare const LegalPrompt: {
36
37
  encode(message: LegalPrompt, writer?: _m0.Writer): _m0.Writer;
37
38
  decode(input: _m0.Reader | Uint8Array, length?: number): LegalPrompt;
39
+ fromJSON(object: any): LegalPrompt;
40
+ toJSON(message: LegalPrompt): unknown;
38
41
  fromPartial<I extends {
39
42
  documents?: {
40
43
  type?: LegalDocument_Type | undefined;
@@ -71,6 +74,8 @@ export declare const LegalPrompt: {
71
74
  export declare const LegalDocument: {
72
75
  encode(message: LegalDocument, writer?: _m0.Writer): _m0.Writer;
73
76
  decode(input: _m0.Reader | Uint8Array, length?: number): LegalDocument;
77
+ fromJSON(object: any): LegalDocument;
78
+ toJSON(message: LegalDocument): unknown;
74
79
  fromPartial<I extends {
75
80
  type?: LegalDocument_Type | undefined;
76
81
  webUrl?: string | undefined;
@@ -36,6 +36,20 @@ export function legalDocument_TypeFromJSON(object) {
36
36
  return LegalDocument_Type.UNRECOGNIZED;
37
37
  }
38
38
  }
39
+ export function legalDocument_TypeToJSON(object) {
40
+ switch (object) {
41
+ case LegalDocument_Type.UNSET:
42
+ return "UNSET";
43
+ case LegalDocument_Type.TERMS_OF_SERVICE:
44
+ return "TERMS_OF_SERVICE";
45
+ case LegalDocument_Type.PRIVACY_POLICY:
46
+ return "PRIVACY_POLICY";
47
+ case LegalDocument_Type.LEARN_MORE:
48
+ return "LEARN_MORE";
49
+ default:
50
+ return "UNKNOWN";
51
+ }
52
+ }
39
53
  export function legalDocument_TypeToNumber(object) {
40
54
  switch (object) {
41
55
  case LegalDocument_Type.UNSET:
@@ -83,6 +97,23 @@ export const LegalPrompt = {
83
97
  }
84
98
  return message;
85
99
  },
100
+ fromJSON(object) {
101
+ return {
102
+ documents: Array.isArray(object === null || object === void 0 ? void 0 : object.documents) ? object.documents.map((e) => LegalDocument.fromJSON(e)) : [],
103
+ disabled: isSet(object.disabled) ? Boolean(object.disabled) : false,
104
+ };
105
+ },
106
+ toJSON(message) {
107
+ const obj = {};
108
+ if (message.documents) {
109
+ obj.documents = message.documents.map((e) => (e ? LegalDocument.toJSON(e) : undefined));
110
+ }
111
+ else {
112
+ obj.documents = [];
113
+ }
114
+ message.disabled !== undefined && (obj.disabled = message.disabled);
115
+ return obj;
116
+ },
86
117
  fromPartial(object) {
87
118
  var _a, _b;
88
119
  const message = createBaseLegalPrompt();
@@ -136,6 +167,22 @@ export const LegalDocument = {
136
167
  }
137
168
  return message;
138
169
  },
170
+ fromJSON(object) {
171
+ return {
172
+ type: isSet(object.type) ? legalDocument_TypeFromJSON(object.type) : LegalDocument_Type.UNSET,
173
+ webUrl: isSet(object.webUrl) ? String(object.webUrl) : "",
174
+ version: isSet(object.version) ? String(object.version) : "",
175
+ timestamp: isSet(object.timestamp) ? fromJsonTimestamp(object.timestamp) : undefined,
176
+ };
177
+ },
178
+ toJSON(message) {
179
+ const obj = {};
180
+ message.type !== undefined && (obj.type = legalDocument_TypeToJSON(message.type));
181
+ message.webUrl !== undefined && (obj.webUrl = message.webUrl);
182
+ message.version !== undefined && (obj.version = message.version);
183
+ message.timestamp !== undefined && (obj.timestamp = message.timestamp.toISOString());
184
+ return obj;
185
+ },
139
186
  fromPartial(object) {
140
187
  var _a, _b, _c, _d;
141
188
  const message = createBaseLegalDocument();
@@ -157,8 +204,22 @@ function fromTimestamp(t) {
157
204
  millis += t.nanos / 1000000;
158
205
  return new Date(millis);
159
206
  }
207
+ function fromJsonTimestamp(o) {
208
+ if (o instanceof Date) {
209
+ return o;
210
+ }
211
+ else if (typeof o === "string") {
212
+ return new Date(o);
213
+ }
214
+ else {
215
+ return fromTimestamp(Timestamp.fromJSON(o));
216
+ }
217
+ }
160
218
  if (_m0.util.Long !== Long) {
161
219
  _m0.util.Long = Long;
162
220
  _m0.configure();
163
221
  }
222
+ function isSet(value) {
223
+ return value !== null && value !== undefined;
224
+ }
164
225
  //# sourceMappingURL=legal_prompt.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"legal_prompt.js","sourceRoot":"","sources":["../../../../../src/generated-proto/pb_schema/camera_kit/v3/legal_prompt.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,GAAG,MAAM,oBAAoB,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAC5D,MAAM,CAAC,MAAM,e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../../google/protobuf/timestamp\";\nexport const protobufPackage = \"com.snap.camerakit.v3\";\n/** Legal information that should be presented to a user as a prompt each time its (doccument) contents change. */\nexport interface LegalPrompt {\n /** A set of documents to present in a legal prompt for a user to agree, deny or ignore. */\n documents: LegalDocument[];\n /** True if the legal prompt should be disabled, false otherwise. */\n disabled: boolean;\n}\n/** Reference to a legal and versioned document which content users can acccess by visiting a url. */\nexport interface LegalDocument {\n /** The type of this legal document. */\n type: LegalDocument_Type;\n /** Web link to the full legal document, intented to be presented in a browser to retain Snap's branding and formatting. */\n webUrl: string;\n /** Version of this legal document. */\n version: string;\n /** Timestamp when this document was made available. */\n timestamp: Date | undefined;\n}\n/** All known types of legal documents that may be provided to a user. */\nexport enum LegalDocument_Type {\n /** UNSET - Default unset field. */\n UNSET = \"UNSET\",\n /** TERMS_OF_SERVICE - Represents terms of service type of a document. */\n TERMS_OF_SERVICE = \"TERMS_OF_SERVICE\",\n /** PRIVACY_POLICY - Represents privacy policy type of a document. */\n PRIVACY_POLICY = \"PRIVACY_POLICY\",\n /** LEARN_MORE - Represents additional legal information type of a document. */\n LEARN_MORE = \"LEARN_MORE\",\n UNRECOGNIZED = \"UNRECOGNIZED\"\n}\nexport function legalDocument_TypeFromJSON(object: any): LegalDocument_Type {\n switch (object) {\n case 0:\n case \"UNSET\":\n return LegalDocument_Type.UNSET;\n case 1:\n case \"TERMS_OF_SERVICE\":\n return LegalDocument_Type.TERMS_OF_SERVICE;\n case 2:\n case \"PRIVACY_POLICY\":\n return LegalDocument_Type.PRIVACY_POLICY;\n case 3:\n case \"LEARN_MORE\":\n return LegalDocument_Type.LEARN_MORE;\n case -1:\n case \"UNRECOGNIZED\":\n default:\n return LegalDocument_Type.UNRECOGNIZED;\n }\n}\nexport function legalDocument_TypeToNumber(object: LegalDocument_Type): number {\n switch (object) {\n case LegalDocument_Type.UNSET:\n return 0;\n case LegalDocument_Type.TERMS_OF_SERVICE:\n return 1;\n case LegalDocument_Type.PRIVACY_POLICY:\n return 2;\n case LegalDocument_Type.LEARN_MORE:\n return 3;\n default:\n return 0;\n }\n}\nfunction createBaseLegalPrompt(): LegalPrompt {\n return { documents: [], disabled: false };\n}\nexport const LegalPrompt = {\n encode(message: LegalPrompt, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {\n for (const v of message.documents) {\n LegalDocument.encode(v!, writer.uint32(10).fork()).ldelim();\n }\n if (message.disabled === true) {\n writer.uint32(16).bool(message.disabled);\n }\n return writer;\n },\n decode(input: _m0.Reader | Uint8Array, length?: number): LegalPrompt {\n const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);\n let end = length === undefined ? reader.len : reader.pos + length;\n const message = createBaseLegalPrompt();\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n message.documents.push(LegalDocument.decode(reader, reader.uint32()));\n break;\n case 2:\n message.disabled = reader.bool();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return message;\n },\n fromPartial<I extends Exact<DeepPartial<LegalPrompt>, I>>(object: I): LegalPrompt {\n const message = createBaseLegalPrompt();\n message.documents = object.documents?.map((e) => LegalDocument.fromPartial(e)) || [];\n message.disabled = object.disabled ?? false;\n return message;\n },\n};\nfunction createBaseLegalDocument(): LegalDocument {\n return { type: LegalDocument_Type.UNSET, webUrl: \"\", version: \"\", timestamp: undefined };\n}\nexport const LegalDocument = {\n encode(message: LegalDocument, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {\n if (message.type !== LegalDocument_Type.UNSET) {\n writer.uint32(8).int32(legalDocument_TypeToNumber(message.type));\n }\n if (message.webUrl !== \"\") {\n writer.uint32(18).string(message.webUrl);\n }\n if (message.version !== \"\") {\n writer.uint32(26).string(message.version);\n }\n if (message.timestamp !== undefined) {\n Timestamp.encode(toTimestamp(message.timestamp), writer.uint32(34).fork()).ldelim();\n }\n return writer;\n },\n decode(input: _m0.Reader | Uint8Array, length?: number): LegalDocument {\n const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);\n let end = length === undefined ? reader.len : reader.pos + length;\n const message = createBaseLegalDocument();\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n message.type = legalDocument_TypeFromJSON(reader.int32());\n break;\n case 2:\n message.webUrl = reader.string();\n break;\n case 3:\n message.version = reader.string();\n break;\n case 4:\n message.timestamp = fromTimestamp(Timestamp.decode(reader, reader.uint32()));\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return message;\n },\n fromPartial<I extends Exact<DeepPartial<LegalDocument>, I>>(object: I): LegalDocument {\n const message = createBaseLegalDocument();\n message.type = object.type ?? LegalDocument_Type.UNSET;\n message.webUrl = object.webUrl ?? \"\";\n message.version = object.version ?? \"\";\n message.timestamp = object.timestamp ?? undefined;\n return message;\n },\n};\ntype Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;\nexport type DeepPartial<T> = T extends Builtin ? T : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {\n $case: string;\n} ? {\n [K in keyof Omit<T, \"$case\">]?: DeepPartial<T[K]>;\n} & {\n $case: T[\"$case\"];\n} : T extends {} ? {\n [K in keyof T]?: DeepPartial<T[K]>;\n} : Partial<T>;\ntype KeysOfUnion<T> = T extends T ? keyof T : never;\nexport type Exact<P, I extends P> = P extends Builtin ? P : P & {\n [K in keyof P]: Exact<P[K], I[K]>;\n} & Record<Exclude<keyof I, KeysOfUnion<P>>, never>;\n// @ts-ignore\nfunction toTimestamp(date: Date): Timestamp {\n const seconds = date.getTime() / 1000;\n const nanos = (date.getTime() % 1000) * 1000000;\n return { seconds, nanos };\n}\nfunction fromTimestamp(t: Timestamp): Date {\n let millis = t.seconds * 1000;\n millis += t.nanos / 1000000;\n return new Date(millis);\n}\nif (_m0.util.Long !== Long) {\n _m0.util.Long = Long as any;\n _m0.configure();\n}\n"]}
1
+ {"version":3,"file":"legal_prompt.js","sourceRoot":"","sources":["../../../../../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IAAI,CAAC,YAAY,IAAI,EAAE;QACnB,OAAO,CAAC,CAAC;KACZ;SACI,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE;QAC5B,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC;KACtB;SACI;QACD,OAAO,aAAa,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;KAC/C;AACL,CAAC;AACD,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,EAAE;IACxB,GAAG,CAAC,IAAI,CAAC,IAAI,GAAG,IAAW,CAAC;IAC5B,GAAG,CAAC,SAAS,EAAE,CAAC;CACnB;AACD,SAAS,KAAK,CAAC,KAAU;IACrB,OAAO,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAC;AACjD,CAAC","sourcesContent":["/* eslint-disable */\nimport Long from \"long\";\nimport _m0 from \"protobufjs/minimal\";\nimport { Timestamp } from \"../../google/protobuf/timestamp\";\nexport const protobufPackage = \"com.snap.camerakit.v3\";\n/** Legal information that should be presented to a user as a prompt each time its (doccument) contents change. */\nexport interface LegalPrompt {\n /** A set of documents to present in a legal prompt for a user to agree, deny or ignore. */\n documents: LegalDocument[];\n /** True if the legal prompt should be disabled, false otherwise. */\n disabled: boolean;\n}\n/** Reference to a legal and versioned document which content users can acccess by visiting a url. */\nexport interface LegalDocument {\n /** The type of this legal document. */\n type: LegalDocument_Type;\n /** Web link to the full legal document, intented to be presented in a browser to retain Snap's branding and formatting. */\n webUrl: string;\n /** Version of this legal document. */\n version: string;\n /** Timestamp when this document was made available. */\n timestamp: Date | undefined;\n}\n/** All known types of legal documents that may be provided to a user. */\nexport enum LegalDocument_Type {\n /** UNSET - Default unset field. */\n UNSET = \"UNSET\",\n /** TERMS_OF_SERVICE - Represents terms of service type of a document. */\n TERMS_OF_SERVICE = \"TERMS_OF_SERVICE\",\n /** PRIVACY_POLICY - Represents privacy policy type of a document. */\n PRIVACY_POLICY = \"PRIVACY_POLICY\",\n /** LEARN_MORE - Represents additional legal information type of a document. */\n LEARN_MORE = \"LEARN_MORE\",\n UNRECOGNIZED = \"UNRECOGNIZED\"\n}\nexport function legalDocument_TypeFromJSON(object: any): LegalDocument_Type {\n switch (object) {\n case 0:\n case \"UNSET\":\n return LegalDocument_Type.UNSET;\n case 1:\n case \"TERMS_OF_SERVICE\":\n return LegalDocument_Type.TERMS_OF_SERVICE;\n case 2:\n case \"PRIVACY_POLICY\":\n return LegalDocument_Type.PRIVACY_POLICY;\n case 3:\n case \"LEARN_MORE\":\n return LegalDocument_Type.LEARN_MORE;\n case -1:\n case \"UNRECOGNIZED\":\n default:\n return LegalDocument_Type.UNRECOGNIZED;\n }\n}\nexport function legalDocument_TypeToJSON(object: LegalDocument_Type): string {\n switch (object) {\n case LegalDocument_Type.UNSET:\n return \"UNSET\";\n case LegalDocument_Type.TERMS_OF_SERVICE:\n return \"TERMS_OF_SERVICE\";\n case LegalDocument_Type.PRIVACY_POLICY:\n return \"PRIVACY_POLICY\";\n case LegalDocument_Type.LEARN_MORE:\n return \"LEARN_MORE\";\n default:\n return \"UNKNOWN\";\n }\n}\nexport function legalDocument_TypeToNumber(object: LegalDocument_Type): number {\n switch (object) {\n case LegalDocument_Type.UNSET:\n return 0;\n case LegalDocument_Type.TERMS_OF_SERVICE:\n return 1;\n case LegalDocument_Type.PRIVACY_POLICY:\n return 2;\n case LegalDocument_Type.LEARN_MORE:\n return 3;\n default:\n return 0;\n }\n}\nfunction createBaseLegalPrompt(): LegalPrompt {\n return { documents: [], disabled: false };\n}\nexport const LegalPrompt = {\n encode(message: LegalPrompt, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {\n for (const v of message.documents) {\n LegalDocument.encode(v!, writer.uint32(10).fork()).ldelim();\n }\n if (message.disabled === true) {\n writer.uint32(16).bool(message.disabled);\n }\n return writer;\n },\n decode(input: _m0.Reader | Uint8Array, length?: number): LegalPrompt {\n const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);\n let end = length === undefined ? reader.len : reader.pos + length;\n const message = createBaseLegalPrompt();\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n message.documents.push(LegalDocument.decode(reader, reader.uint32()));\n break;\n case 2:\n message.disabled = reader.bool();\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return message;\n },\n fromJSON(object: any): LegalPrompt {\n return {\n documents: Array.isArray(object?.documents) ? object.documents.map((e: any) => LegalDocument.fromJSON(e)) : [],\n disabled: isSet(object.disabled) ? Boolean(object.disabled) : false,\n };\n },\n toJSON(message: LegalPrompt): unknown {\n const obj: any = {};\n if (message.documents) {\n obj.documents = message.documents.map((e) => (e ? LegalDocument.toJSON(e) : undefined));\n }\n else {\n obj.documents = [];\n }\n message.disabled !== undefined && (obj.disabled = message.disabled);\n return obj;\n },\n fromPartial<I extends Exact<DeepPartial<LegalPrompt>, I>>(object: I): LegalPrompt {\n const message = createBaseLegalPrompt();\n message.documents = object.documents?.map((e) => LegalDocument.fromPartial(e)) || [];\n message.disabled = object.disabled ?? false;\n return message;\n },\n};\nfunction createBaseLegalDocument(): LegalDocument {\n return { type: LegalDocument_Type.UNSET, webUrl: \"\", version: \"\", timestamp: undefined };\n}\nexport const LegalDocument = {\n encode(message: LegalDocument, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {\n if (message.type !== LegalDocument_Type.UNSET) {\n writer.uint32(8).int32(legalDocument_TypeToNumber(message.type));\n }\n if (message.webUrl !== \"\") {\n writer.uint32(18).string(message.webUrl);\n }\n if (message.version !== \"\") {\n writer.uint32(26).string(message.version);\n }\n if (message.timestamp !== undefined) {\n Timestamp.encode(toTimestamp(message.timestamp), writer.uint32(34).fork()).ldelim();\n }\n return writer;\n },\n decode(input: _m0.Reader | Uint8Array, length?: number): LegalDocument {\n const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);\n let end = length === undefined ? reader.len : reader.pos + length;\n const message = createBaseLegalDocument();\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1:\n message.type = legalDocument_TypeFromJSON(reader.int32());\n break;\n case 2:\n message.webUrl = reader.string();\n break;\n case 3:\n message.version = reader.string();\n break;\n case 4:\n message.timestamp = fromTimestamp(Timestamp.decode(reader, reader.uint32()));\n break;\n default:\n reader.skipType(tag & 7);\n break;\n }\n }\n return message;\n },\n fromJSON(object: any): LegalDocument {\n return {\n type: isSet(object.type) ? legalDocument_TypeFromJSON(object.type) : LegalDocument_Type.UNSET,\n webUrl: isSet(object.webUrl) ? String(object.webUrl) : \"\",\n version: isSet(object.version) ? String(object.version) : \"\",\n timestamp: isSet(object.timestamp) ? fromJsonTimestamp(object.timestamp) : undefined,\n };\n },\n toJSON(message: LegalDocument): unknown {\n const obj: any = {};\n message.type !== undefined && (obj.type = legalDocument_TypeToJSON(message.type));\n message.webUrl !== undefined && (obj.webUrl = message.webUrl);\n message.version !== undefined && (obj.version = message.version);\n message.timestamp !== undefined && (obj.timestamp = message.timestamp.toISOString());\n return obj;\n },\n fromPartial<I extends Exact<DeepPartial<LegalDocument>, I>>(object: I): LegalDocument {\n const message = createBaseLegalDocument();\n message.type = object.type ?? LegalDocument_Type.UNSET;\n message.webUrl = object.webUrl ?? \"\";\n message.version = object.version ?? \"\";\n message.timestamp = object.timestamp ?? undefined;\n return message;\n },\n};\ntype Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;\nexport type DeepPartial<T> = T extends Builtin ? T : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {\n $case: string;\n} ? {\n [K in keyof Omit<T, \"$case\">]?: DeepPartial<T[K]>;\n} & {\n $case: T[\"$case\"];\n} : T extends {} ? {\n [K in keyof T]?: DeepPartial<T[K]>;\n} : Partial<T>;\ntype KeysOfUnion<T> = T extends T ? keyof T : never;\nexport type Exact<P, I extends P> = P extends Builtin ? P : P & {\n [K in keyof P]: Exact<P[K], I[K]>;\n} & Record<Exclude<keyof I, KeysOfUnion<P>>, never>;\n// @ts-ignore\nfunction toTimestamp(date: Date): Timestamp {\n const seconds = date.getTime() / 1000;\n const nanos = (date.getTime() % 1000) * 1000000;\n return { seconds, nanos };\n}\nfunction fromTimestamp(t: Timestamp): Date {\n let millis = t.seconds * 1000;\n millis += t.nanos / 1000000;\n return new Date(millis);\n}\nfunction fromJsonTimestamp(o: any): Date {\n if (o instanceof Date) {\n return o;\n }\n else if (typeof o === \"string\") {\n return new Date(o);\n }\n else {\n return fromTimestamp(Timestamp.fromJSON(o));\n }\n}\nif (_m0.util.Long !== Long) {\n _m0.util.Long = Long as any;\n _m0.configure();\n}\nfunction isSet(value: any): boolean {\n return value !== null && value !== undefined;\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import _m0 from "protobufjs/minimal";
2
2
  import { RankingData } from "./ranking";
3
3
  import { Lens } from "./lens";
4
+ import { LegalPrompt } from "./legal_prompt";
4
5
  import { OperationalMetricsBundle } from "./operational_metrics";
5
6
  import { Any } from "../../google/protobuf/any";
6
7
  import { ExtensionEventBase } from "./business_events";
@@ -69,6 +70,13 @@ export interface GetInitializationConfigResponse {
69
70
  * Such applications are configured with "https://kit.snapchat.com/feature/api/kit.camera.g.sdk" SnapKitAuthZ feature.
70
71
  */
71
72
  childrenProtectionActRestricted: boolean;
73
+ /**
74
+ * Legal information that should be presented to a user as a prompt.
75
+ * The prompt is disabled for ARES partners that have other contractual obligations than ordinary CameraKit partners.
76
+ * Please note, that the SDK still needs to check the CAMERA_KIT_LEGAL_PROMPT COF rule
77
+ * if 'legal_prompt.disabled = false' until data is unified in a single API.
78
+ */
79
+ legalPrompt: LegalPrompt | undefined;
72
80
  }
73
81
  export interface SetOperationalMetricsRequest {
74
82
  /** Metrics bundle */
@@ -1036,10 +1044,51 @@ export declare const GetInitializationConfigResponse: {
1036
1044
  appVendorUuidOptIn?: boolean | undefined;
1037
1045
  watermarkEnabled?: boolean | undefined;
1038
1046
  childrenProtectionActRestricted?: boolean | undefined;
1047
+ legalPrompt?: {
1048
+ documents?: {
1049
+ type?: import("./legal_prompt").LegalDocument_Type | undefined;
1050
+ webUrl?: string | undefined;
1051
+ version?: string | undefined;
1052
+ timestamp?: Date | undefined;
1053
+ }[] | undefined;
1054
+ disabled?: boolean | undefined;
1055
+ } | undefined;
1039
1056
  } & {
1040
1057
  appVendorUuidOptIn?: boolean | undefined;
1041
1058
  watermarkEnabled?: boolean | undefined;
1042
1059
  childrenProtectionActRestricted?: boolean | undefined;
1060
+ legalPrompt?: ({
1061
+ documents?: {
1062
+ type?: import("./legal_prompt").LegalDocument_Type | undefined;
1063
+ webUrl?: string | undefined;
1064
+ version?: string | undefined;
1065
+ timestamp?: Date | undefined;
1066
+ }[] | undefined;
1067
+ disabled?: boolean | undefined;
1068
+ } & {
1069
+ documents?: ({
1070
+ type?: import("./legal_prompt").LegalDocument_Type | undefined;
1071
+ webUrl?: string | undefined;
1072
+ version?: string | undefined;
1073
+ timestamp?: Date | undefined;
1074
+ }[] & ({
1075
+ type?: import("./legal_prompt").LegalDocument_Type | undefined;
1076
+ webUrl?: string | undefined;
1077
+ version?: string | undefined;
1078
+ timestamp?: Date | undefined;
1079
+ } & {
1080
+ type?: import("./legal_prompt").LegalDocument_Type | undefined;
1081
+ webUrl?: string | undefined;
1082
+ version?: string | undefined;
1083
+ timestamp?: Date | undefined;
1084
+ } & Record<Exclude<keyof I["legalPrompt"]["documents"][number], keyof import("./legal_prompt").LegalDocument>, never>)[] & Record<Exclude<keyof I["legalPrompt"]["documents"], keyof {
1085
+ type?: import("./legal_prompt").LegalDocument_Type | undefined;
1086
+ webUrl?: string | undefined;
1087
+ version?: string | undefined;
1088
+ timestamp?: Date | undefined;
1089
+ }[]>, never>) | undefined;
1090
+ disabled?: boolean | undefined;
1091
+ } & Record<Exclude<keyof I["legalPrompt"], keyof LegalPrompt>, never>) | undefined;
1043
1092
  } & Record<Exclude<keyof I, keyof GetInitializationConfigResponse>, never>>(object: I): GetInitializationConfigResponse;
1044
1093
  };
1045
1094
  export declare const SetOperationalMetricsRequest: {
@@ -3,6 +3,7 @@ import Long from "long";
3
3
  import _m0 from "protobufjs/minimal";
4
4
  import { RankingData } from "./ranking";
5
5
  import { Lens } from "./lens";
6
+ import { LegalPrompt } from "./legal_prompt";
6
7
  import { OperationalMetricsBundle } from "./operational_metrics";
7
8
  import { Any } from "../../google/protobuf/any";
8
9
  import { ExtensionEventBase } from "./business_events";
@@ -443,7 +444,12 @@ export const GetInitializationConfigRequest = {
443
444
  },
444
445
  };
445
446
  function createBaseGetInitializationConfigResponse() {
446
- return { appVendorUuidOptIn: false, watermarkEnabled: false, childrenProtectionActRestricted: false };
447
+ return {
448
+ appVendorUuidOptIn: false,
449
+ watermarkEnabled: false,
450
+ childrenProtectionActRestricted: false,
451
+ legalPrompt: undefined,
452
+ };
447
453
  }
448
454
  export const GetInitializationConfigResponse = {
449
455
  decode(input, length) {
@@ -462,6 +468,9 @@ export const GetInitializationConfigResponse = {
462
468
  case 3:
463
469
  message.childrenProtectionActRestricted = reader.bool();
464
470
  break;
471
+ case 4:
472
+ message.legalPrompt = LegalPrompt.decode(reader, reader.uint32());
473
+ break;
465
474
  default:
466
475
  reader.skipType(tag & 7);
467
476
  break;
@@ -476,6 +485,7 @@ export const GetInitializationConfigResponse = {
476
485
  childrenProtectionActRestricted: isSet(object.childrenProtectionActRestricted)
477
486
  ? Boolean(object.childrenProtectionActRestricted)
478
487
  : false,
488
+ legalPrompt: isSet(object.legalPrompt) ? LegalPrompt.fromJSON(object.legalPrompt) : undefined,
479
489
  };
480
490
  },
481
491
  toJSON(message) {
@@ -484,6 +494,8 @@ export const GetInitializationConfigResponse = {
484
494
  message.watermarkEnabled !== undefined && (obj.watermarkEnabled = message.watermarkEnabled);
485
495
  message.childrenProtectionActRestricted !== undefined &&
486
496
  (obj.childrenProtectionActRestricted = message.childrenProtectionActRestricted);
497
+ message.legalPrompt !== undefined &&
498
+ (obj.legalPrompt = message.legalPrompt ? LegalPrompt.toJSON(message.legalPrompt) : undefined);
487
499
  return obj;
488
500
  },
489
501
  fromPartial(object) {
@@ -492,6 +504,10 @@ export const GetInitializationConfigResponse = {
492
504
  message.appVendorUuidOptIn = (_a = object.appVendorUuidOptIn) !== null && _a !== void 0 ? _a : false;
493
505
  message.watermarkEnabled = (_b = object.watermarkEnabled) !== null && _b !== void 0 ? _b : false;
494
506
  message.childrenProtectionActRestricted = (_c = object.childrenProtectionActRestricted) !== null && _c !== void 0 ? _c : false;
507
+ message.legalPrompt =
508
+ object.legalPrompt !== undefined && object.legalPrompt !== null
509
+ ? LegalPrompt.fromPartial(object.legalPrompt)
510
+ : undefined;
495
511
  return message;
496
512
  },
497
513
  };