@snap/camera-kit 0.16.2 → 0.18.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 (1220) hide show
  1. package/LICENSE.md +141 -3875
  2. package/README.md +1 -1
  3. package/dist/CameraKit.d.ts +334 -0
  4. package/dist/CameraKit.d.ts.map +1 -0
  5. package/dist/CameraKit.js +104 -0
  6. package/dist/CameraKit.js.map +1 -0
  7. package/dist/benchmark/benchmarkGflops.d.ts +17 -0
  8. package/dist/benchmark/benchmarkGflops.d.ts.map +1 -0
  9. package/dist/benchmark/benchmarkGflops.js +116 -0
  10. package/dist/benchmark/benchmarkGflops.js.map +1 -0
  11. package/dist/benchmark/estimateLensPerformanceCluster.d.ts +34 -0
  12. package/dist/benchmark/estimateLensPerformanceCluster.d.ts.map +1 -0
  13. package/dist/benchmark/estimateLensPerformanceCluster.js +34 -0
  14. package/dist/benchmark/estimateLensPerformanceCluster.js.map +1 -0
  15. package/dist/benchmark/webglUtils.d.ts +8 -0
  16. package/dist/benchmark/webglUtils.d.ts.map +1 -0
  17. package/dist/bootstrapCameraKit.d.ts +97 -0
  18. package/dist/bootstrapCameraKit.d.ts.map +1 -0
  19. package/dist/bootstrapCameraKit.js +117 -0
  20. package/dist/bootstrapCameraKit.js.map +1 -0
  21. package/dist/clients/createTsProtoClient.d.ts +41 -0
  22. package/dist/clients/createTsProtoClient.d.ts.map +1 -0
  23. package/dist/clients/createTsProtoClient.js +36 -0
  24. package/dist/clients/createTsProtoClient.js.map +1 -0
  25. package/dist/clients/grpcHandler.d.ts +27 -0
  26. package/dist/clients/grpcHandler.d.ts.map +1 -0
  27. package/dist/clients/grpcHandler.js +79 -0
  28. package/dist/clients/grpcHandler.js.map +1 -0
  29. package/dist/clients/lensesClient.d.ts +10 -0
  30. package/dist/clients/lensesClient.d.ts.map +1 -0
  31. package/dist/clients/lensesClient.js.map +1 -0
  32. package/dist/clients/metricsClient.d.ts +27 -0
  33. package/dist/clients/metricsClient.d.ts.map +1 -0
  34. package/dist/clients/metricsClient.js +96 -0
  35. package/dist/clients/metricsClient.js.map +1 -0
  36. package/dist/common/assertions.d.ts +28 -0
  37. package/dist/common/assertions.d.ts.map +1 -0
  38. package/dist/common/assertions.js +14 -0
  39. package/dist/common/assertions.js.map +1 -0
  40. package/dist/common/copyDefinedProperties.d.ts +14 -0
  41. package/dist/common/copyDefinedProperties.d.ts.map +1 -0
  42. package/dist/common/copyDefinedProperties.js +4 -0
  43. package/dist/common/copyDefinedProperties.js.map +1 -0
  44. package/dist/common/date.d.ts +4 -0
  45. package/dist/common/date.d.ts.map +1 -0
  46. package/dist/common/dialog.d.ts +60 -0
  47. package/dist/common/dialog.d.ts.map +1 -0
  48. package/dist/common/dialog.js +158 -0
  49. package/dist/common/dialog.js.map +1 -0
  50. package/dist/common/entries.d.ts +5 -0
  51. package/dist/common/entries.d.ts.map +1 -0
  52. package/dist/common/entries.js +3 -0
  53. package/dist/common/entries.js.map +1 -0
  54. package/dist/common/errorHelpers.d.ts +18 -0
  55. package/dist/common/errorHelpers.d.ts.map +1 -0
  56. package/dist/common/errorHelpers.js +20 -0
  57. package/dist/common/errorHelpers.js.map +1 -0
  58. package/dist/common/getFilename.d.ts +2 -0
  59. package/dist/common/getFilename.d.ts.map +1 -0
  60. package/dist/common/hash.d.ts +6 -0
  61. package/dist/common/hash.d.ts.map +1 -0
  62. package/dist/common/hash.js +13 -0
  63. package/dist/common/hash.js.map +1 -0
  64. package/dist/common/loadScript.d.ts +7 -0
  65. package/dist/common/loadScript.d.ts.map +1 -0
  66. package/dist/common/loadScript.js +13 -0
  67. package/dist/common/loadScript.js.map +1 -0
  68. package/dist/common/localization.d.ts +55 -0
  69. package/dist/common/localization.d.ts.map +1 -0
  70. package/dist/common/localization.js +622 -0
  71. package/dist/common/localization.js.map +1 -0
  72. package/dist/common/memoize.d.ts +9 -0
  73. package/dist/common/memoize.d.ts.map +1 -0
  74. package/dist/common/pageVisibility.d.ts +35 -0
  75. package/dist/common/pageVisibility.d.ts.map +1 -0
  76. package/dist/common/pageVisibility.js +52 -0
  77. package/dist/common/pageVisibility.js.map +1 -0
  78. package/dist/common/result.d.ts +37 -0
  79. package/dist/common/result.d.ts.map +1 -0
  80. package/dist/common/result.js +39 -0
  81. package/dist/common/result.js.map +1 -0
  82. package/dist/common/time.d.ts +3 -0
  83. package/dist/common/time.d.ts.map +1 -0
  84. package/dist/common/typeguards.d.ts +68 -0
  85. package/dist/common/typeguards.d.ts.map +1 -0
  86. package/dist/common/typeguards.js +68 -0
  87. package/dist/common/typeguards.js.map +1 -0
  88. package/dist/common/types.d.ts +38 -0
  89. package/dist/common/types.d.ts.map +1 -0
  90. package/dist/common/types.js.map +1 -0
  91. package/dist/common/unionBy.d.ts +29 -0
  92. package/dist/common/unionBy.d.ts.map +1 -0
  93. package/dist/common/unionBy.js +16 -0
  94. package/dist/common/unionBy.js.map +1 -0
  95. package/dist/common/validate.d.ts +16 -0
  96. package/dist/common/validate.d.ts.map +1 -0
  97. package/dist/common/validate.js +57 -0
  98. package/dist/common/validate.js.map +1 -0
  99. package/dist/configuration.d.ts +102 -0
  100. package/dist/configuration.d.ts.map +1 -0
  101. package/dist/configuration.js +30 -0
  102. package/dist/configuration.js.map +1 -0
  103. package/dist/configurationOverrides.d.ts +13 -0
  104. package/dist/configurationOverrides.d.ts.map +1 -0
  105. package/dist/configurationOverrides.js +38 -0
  106. package/dist/configurationOverrides.js.map +1 -0
  107. package/dist/dependency-injection/Container.d.ts +177 -0
  108. package/dist/dependency-injection/Container.d.ts.map +1 -0
  109. package/dist/dependency-injection/Container.js +72 -0
  110. package/dist/dependency-injection/Container.js.map +1 -0
  111. package/dist/dependency-injection/Injectable.d.ts +96 -0
  112. package/dist/dependency-injection/Injectable.d.ts.map +1 -0
  113. package/dist/dependency-injection/Injectable.js.map +1 -0
  114. package/dist/dependency-injection/PartialContainer.d.ts +86 -0
  115. package/dist/dependency-injection/PartialContainer.d.ts.map +1 -0
  116. package/dist/dependency-injection/PartialContainer.js +28 -0
  117. package/dist/dependency-injection/PartialContainer.js.map +1 -0
  118. package/dist/dependency-injection/RootServices.d.ts +74 -0
  119. package/dist/dependency-injection/RootServices.d.ts.map +1 -0
  120. package/dist/dependency-injection/RootServices.js +2 -0
  121. package/dist/dependency-injection/RootServices.js.map +1 -0
  122. package/dist/dependency-injection/types.d.ts +57 -0
  123. package/dist/dependency-injection/types.d.ts.map +1 -0
  124. package/dist/dependency-injection/types.js.map +1 -0
  125. package/dist/environment.d.ts +5 -0
  126. package/dist/environment.d.ts.map +1 -0
  127. package/dist/environment.js +2 -0
  128. package/dist/environment.js.map +1 -0
  129. package/dist/events/TypedCustomEvent.d.ts +11 -0
  130. package/dist/events/TypedCustomEvent.d.ts.map +1 -0
  131. package/dist/events/TypedCustomEvent.js +6 -0
  132. package/dist/events/TypedCustomEvent.js.map +1 -0
  133. package/dist/events/TypedEventTarget.d.ts +26 -0
  134. package/dist/events/TypedEventTarget.d.ts.map +1 -0
  135. package/dist/events/TypedEventTarget.js +42 -0
  136. package/dist/events/TypedEventTarget.js.map +1 -0
  137. package/dist/events/scan.d.ts +18 -0
  138. package/dist/events/scan.d.ts.map +1 -0
  139. package/dist/events/scan.js +29 -0
  140. package/dist/events/scan.js.map +1 -0
  141. package/dist/extensions/RemoteApiServices.d.ts +88 -0
  142. package/dist/extensions/RemoteApiServices.d.ts.map +1 -0
  143. package/dist/extensions/RemoteApiServices.js +155 -0
  144. package/dist/extensions/RemoteApiServices.js.map +1 -0
  145. package/dist/extensions/UriHandlers.d.ts +48 -0
  146. package/dist/extensions/UriHandlers.d.ts.map +1 -0
  147. package/dist/extensions/UriHandlers.js +34 -0
  148. package/dist/extensions/UriHandlers.js.map +1 -0
  149. package/dist/extensions/extensionRequestContext.d.ts +5 -0
  150. package/dist/extensions/extensionRequestContext.d.ts.map +1 -0
  151. package/dist/extensions/extensionRequestContext.js +11 -0
  152. package/dist/extensions/extensionRequestContext.js.map +1 -0
  153. package/dist/extensions/uriHandlersRegister.d.ts +22 -0
  154. package/dist/extensions/uriHandlersRegister.d.ts.map +1 -0
  155. package/dist/extensions/uriHandlersRegister.js +61 -0
  156. package/dist/extensions/uriHandlersRegister.js.map +1 -0
  157. package/dist/generated-proto/blizzard/cameraKitEvents.d.ts +9528 -0
  158. package/dist/generated-proto/blizzard/cameraKitEvents.d.ts.map +1 -0
  159. package/dist/generated-proto/pb_schema/camera_kit/v3/business_events.d.ts +80 -0
  160. package/dist/generated-proto/pb_schema/camera_kit/v3/business_events.d.ts.map +1 -0
  161. package/dist/generated-proto/pb_schema/camera_kit/v3/export.d.ts +529 -0
  162. package/dist/generated-proto/pb_schema/camera_kit/v3/export.d.ts.map +1 -0
  163. package/dist/generated-proto/pb_schema/camera_kit/v3/features/ranking_info.d.ts +35 -0
  164. package/dist/generated-proto/pb_schema/camera_kit/v3/features/ranking_info.d.ts.map +1 -0
  165. package/dist/generated-proto/pb_schema/camera_kit/v3/features/ranking_info.js +42 -0
  166. package/dist/generated-proto/pb_schema/camera_kit/v3/features/ranking_info.js.map +1 -0
  167. package/dist/generated-proto/pb_schema/camera_kit/v3/features/remote_api_info.d.ts +30 -0
  168. package/dist/generated-proto/pb_schema/camera_kit/v3/features/remote_api_info.d.ts.map +1 -0
  169. package/dist/generated-proto/pb_schema/camera_kit/v3/legal_prompt.d.ts +86 -0
  170. package/dist/generated-proto/pb_schema/camera_kit/v3/legal_prompt.d.ts.map +1 -0
  171. package/dist/generated-proto/pb_schema/camera_kit/v3/lens.d.ts +385 -0
  172. package/dist/generated-proto/pb_schema/camera_kit/v3/lens.d.ts.map +1 -0
  173. package/dist/generated-proto/pb_schema/camera_kit/v3/operational_metrics.d.ts +179 -0
  174. package/dist/generated-proto/pb_schema/camera_kit/v3/operational_metrics.d.ts.map +1 -0
  175. package/dist/generated-proto/pb_schema/camera_kit/v3/ranking.d.ts +57 -0
  176. package/dist/generated-proto/pb_schema/camera_kit/v3/ranking.d.ts.map +1 -0
  177. package/dist/generated-proto/pb_schema/camera_kit/v3/service.d.ts +2512 -0
  178. package/dist/generated-proto/pb_schema/camera_kit/v3/service.d.ts.map +1 -0
  179. package/dist/generated-proto/pb_schema/cdp/cof/benchmark.d.ts +79 -0
  180. package/dist/generated-proto/pb_schema/cdp/cof/benchmark.d.ts.map +1 -0
  181. package/dist/generated-proto/pb_schema/cdp/cof/benchmark_name.d.ts +51 -0
  182. package/dist/generated-proto/pb_schema/cdp/cof/benchmark_name.d.ts.map +1 -0
  183. package/dist/generated-proto/pb_schema/cdp/cof/circumstance_service.d.ts +25575 -0
  184. package/dist/generated-proto/pb_schema/cdp/cof/circumstance_service.d.ts.map +1 -0
  185. package/dist/generated-proto/pb_schema/cdp/cof/config_request.d.ts +280 -0
  186. package/dist/generated-proto/pb_schema/cdp/cof/config_request.d.ts.map +1 -0
  187. package/dist/generated-proto/pb_schema/cdp/cof/config_response.d.ts +3726 -0
  188. package/dist/generated-proto/pb_schema/cdp/cof/config_response.d.ts.map +1 -0
  189. package/dist/generated-proto/pb_schema/cdp/cof/config_result.d.ts +10224 -0
  190. package/dist/generated-proto/pb_schema/cdp/cof/config_result.d.ts.map +1 -0
  191. package/dist/generated-proto/pb_schema/cdp/cof/debug_info.d.ts +94 -0
  192. package/dist/generated-proto/pb_schema/cdp/cof/debug_info.d.ts.map +1 -0
  193. package/dist/generated-proto/pb_schema/cdp/cof/namespace.d.ts +9 -0
  194. package/dist/generated-proto/pb_schema/cdp/cof/namespace.d.ts.map +1 -0
  195. package/dist/generated-proto/pb_schema/common/ruid.d.ts +52 -0
  196. package/dist/generated-proto/pb_schema/common/ruid.d.ts.map +1 -0
  197. package/dist/generated-proto/pb_schema/common/value.d.ts +145 -0
  198. package/dist/generated-proto/pb_schema/common/value.d.ts.map +1 -0
  199. package/dist/generated-proto/pb_schema/google/api/annotations.d.ts +2 -0
  200. package/dist/generated-proto/pb_schema/google/api/annotations.d.ts.map +1 -0
  201. package/dist/generated-proto/pb_schema/google/api/annotations.js +8 -0
  202. package/dist/generated-proto/pb_schema/google/api/annotations.js.map +1 -0
  203. package/dist/generated-proto/pb_schema/google/api/http.d.ts +3631 -0
  204. package/dist/generated-proto/pb_schema/google/api/http.d.ts.map +1 -0
  205. package/dist/generated-proto/pb_schema/google/api/http.js +193 -0
  206. package/dist/generated-proto/pb_schema/google/api/http.js.map +1 -0
  207. package/dist/generated-proto/pb_schema/google/protobuf/any.d.ts +33 -0
  208. package/dist/generated-proto/pb_schema/google/protobuf/any.d.ts.map +1 -0
  209. package/dist/generated-proto/pb_schema/google/protobuf/descriptor.d.ts +50897 -0
  210. package/dist/generated-proto/pb_schema/google/protobuf/descriptor.d.ts.map +1 -0
  211. package/dist/generated-proto/pb_schema/google/protobuf/descriptor.js +1818 -0
  212. package/dist/generated-proto/pb_schema/google/protobuf/descriptor.js.map +1 -0
  213. package/dist/generated-proto/pb_schema/google/protobuf/timestamp.d.ts +33 -0
  214. package/dist/generated-proto/pb_schema/google/protobuf/timestamp.d.ts.map +1 -0
  215. package/dist/generated-proto/pb_schema/google/protobuf/wrappers.d.ts +120 -0
  216. package/dist/generated-proto/pb_schema/google/protobuf/wrappers.d.ts.map +1 -0
  217. package/dist/generated-proto/pb_schema/lenses/geocircle.d.ts +43 -0
  218. package/dist/generated-proto/pb_schema/lenses/geocircle.d.ts.map +1 -0
  219. package/dist/generated-proto/pb_schema/lenses/geopoint.d.ts +33 -0
  220. package/dist/generated-proto/pb_schema/lenses/geopoint.d.ts.map +1 -0
  221. package/dist/generated-proto/pb_schema/lenses/launch_params.d.ts +30 -0
  222. package/dist/generated-proto/pb_schema/lenses/launch_params.d.ts.map +1 -0
  223. package/dist/generated-proto/pb_schema/lenses/launchdata.d.ts +397 -0
  224. package/dist/generated-proto/pb_schema/lenses/launchdata.d.ts.map +1 -0
  225. package/dist/generated-proto/pb_schema/lenses/lures.d.ts +112 -0
  226. package/dist/generated-proto/pb_schema/lenses/lures.d.ts.map +1 -0
  227. package/dist/generated-proto/pb_schema/lenses/persistent_store.d.ts +30 -0
  228. package/dist/generated-proto/pb_schema/lenses/persistent_store.d.ts.map +1 -0
  229. package/dist/generated-proto/pb_schema/lenses/remote_api/remote_api_service.d.ts +570 -0
  230. package/dist/generated-proto/pb_schema/lenses/remote_api/remote_api_service.d.ts.map +1 -0
  231. package/dist/generated-proto/pb_schema/lenses/snappable.d.ts +903 -0
  232. package/dist/generated-proto/pb_schema/lenses/snappable.d.ts.map +1 -0
  233. package/dist/generated-proto/pb_schema/lenses/user_data.d.ts +230 -0
  234. package/dist/generated-proto/pb_schema/lenses/user_data.d.ts.map +1 -0
  235. package/dist/handlers/HandlerChainBuilder.d.ts +111 -0
  236. package/dist/handlers/HandlerChainBuilder.d.ts.map +1 -0
  237. package/dist/handlers/HandlerChainBuilder.js +55 -0
  238. package/dist/handlers/HandlerChainBuilder.js.map +1 -0
  239. package/dist/handlers/arrayBufferParsingHandler.d.ts +11 -0
  240. package/dist/handlers/arrayBufferParsingHandler.d.ts.map +1 -0
  241. package/dist/handlers/arrayBufferParsingHandler.js +13 -0
  242. package/dist/handlers/arrayBufferParsingHandler.js.map +1 -0
  243. package/dist/handlers/batchingHandler.d.ts +32 -0
  244. package/dist/handlers/batchingHandler.d.ts.map +1 -0
  245. package/dist/handlers/batchingHandler.js +45 -0
  246. package/dist/handlers/batchingHandler.js.map +1 -0
  247. package/dist/handlers/cameraKitServiceFetchHandlerFactory.d.ts +13 -0
  248. package/dist/handlers/cameraKitServiceFetchHandlerFactory.d.ts.map +1 -0
  249. package/dist/handlers/cameraKitServiceFetchHandlerFactory.js +14 -0
  250. package/dist/handlers/cameraKitServiceFetchHandlerFactory.js.map +1 -0
  251. package/dist/handlers/debugHandler.d.ts +9 -0
  252. package/dist/handlers/debugHandler.d.ts.map +1 -0
  253. package/dist/handlers/debugHandler.js +18 -0
  254. package/dist/handlers/debugHandler.js.map +1 -0
  255. package/dist/handlers/defaultFetchHandler.d.ts +16 -0
  256. package/dist/handlers/defaultFetchHandler.d.ts.map +1 -0
  257. package/dist/handlers/defaultFetchHandler.js +25 -0
  258. package/dist/handlers/defaultFetchHandler.js.map +1 -0
  259. package/dist/handlers/headersModifyingFetchHandler.d.ts +9 -0
  260. package/dist/handlers/headersModifyingFetchHandler.d.ts.map +1 -0
  261. package/dist/handlers/headersModifyingFetchHandler.js +10 -0
  262. package/dist/handlers/headersModifyingFetchHandler.js.map +1 -0
  263. package/dist/handlers/mappingHandler.d.ts +20 -0
  264. package/dist/handlers/mappingHandler.d.ts.map +1 -0
  265. package/dist/handlers/mappingHandler.js +44 -0
  266. package/dist/handlers/mappingHandler.js.map +1 -0
  267. package/dist/handlers/noCorsRetryingFetchHandler.d.ts +49 -0
  268. package/dist/handlers/noCorsRetryingFetchHandler.d.ts.map +1 -0
  269. package/dist/handlers/noCorsRetryingFetchHandler.js +33 -0
  270. package/dist/handlers/noCorsRetryingFetchHandler.js.map +1 -0
  271. package/dist/handlers/persistingHandler.d.ts +15 -0
  272. package/dist/handlers/persistingHandler.d.ts.map +1 -0
  273. package/dist/handlers/persistingHandler.js +43 -0
  274. package/dist/handlers/persistingHandler.js.map +1 -0
  275. package/dist/handlers/rateLimitingHandler.d.ts +25 -0
  276. package/dist/handlers/rateLimitingHandler.d.ts.map +1 -0
  277. package/dist/handlers/rateLimitingHandler.js +21 -0
  278. package/dist/handlers/rateLimitingHandler.js.map +1 -0
  279. package/dist/handlers/requestStateEmittingHandler.d.ts +42 -0
  280. package/dist/handlers/requestStateEmittingHandler.d.ts.map +1 -0
  281. package/dist/handlers/requestStateEmittingHandler.js +42 -0
  282. package/dist/handlers/requestStateEmittingHandler.js.map +1 -0
  283. package/dist/handlers/responseCachingHandler.d.ts +35 -0
  284. package/dist/handlers/responseCachingHandler.d.ts.map +1 -0
  285. package/dist/handlers/responseCachingHandler.js +83 -0
  286. package/dist/handlers/responseCachingHandler.js.map +1 -0
  287. package/dist/handlers/retryingHandler.d.ts +49 -0
  288. package/dist/handlers/retryingHandler.d.ts.map +1 -0
  289. package/dist/handlers/retryingHandler.js +62 -0
  290. package/dist/handlers/retryingHandler.js.map +1 -0
  291. package/dist/handlers/timeoutHandler.d.ts +19 -0
  292. package/dist/handlers/timeoutHandler.d.ts.map +1 -0
  293. package/dist/handlers/timeoutHandler.js +20 -0
  294. package/dist/handlers/timeoutHandler.js.map +1 -0
  295. package/dist/handlers/utils.d.ts +13 -0
  296. package/dist/handlers/utils.d.ts.map +1 -0
  297. package/dist/handlers/utils.js +7 -0
  298. package/dist/handlers/utils.js.map +1 -0
  299. package/dist/index.d.ts +43 -0
  300. package/dist/index.d.ts.map +1 -0
  301. package/dist/index.js +35 -0
  302. package/dist/index.js.map +1 -0
  303. package/dist/legal/legalPrompt.d.ts +21 -0
  304. package/dist/legal/legalPrompt.d.ts.map +1 -0
  305. package/dist/legal/legalPrompt.js +130 -0
  306. package/dist/legal/legalPrompt.js.map +1 -0
  307. package/dist/legal/legalState.d.ts +51 -0
  308. package/dist/legal/legalState.d.ts.map +1 -0
  309. package/dist/legal/legalState.js +100 -0
  310. package/dist/legal/legalState.js.map +1 -0
  311. package/dist/lens/Lens.d.ts +117 -0
  312. package/dist/lens/Lens.d.ts.map +1 -0
  313. package/dist/lens/Lens.js +74 -0
  314. package/dist/lens/Lens.js.map +1 -0
  315. package/dist/lens/LensLaunchData.d.ts +45 -0
  316. package/dist/lens/LensLaunchData.d.ts.map +1 -0
  317. package/dist/lens/LensLaunchData.js +83 -0
  318. package/dist/lens/LensLaunchData.js.map +1 -0
  319. package/dist/lens/LensPersistenceStore.d.ts +8 -0
  320. package/dist/lens/LensPersistenceStore.d.ts.map +1 -0
  321. package/dist/lens/LensPersistenceStore.js.map +1 -0
  322. package/dist/lens/LensRepository.d.ts +133 -0
  323. package/dist/lens/LensRepository.d.ts.map +1 -0
  324. package/dist/lens/LensRepository.js +147 -0
  325. package/dist/lens/LensRepository.js.map +1 -0
  326. package/dist/lens/LensSource.d.ts +44 -0
  327. package/dist/lens/LensSource.d.ts.map +1 -0
  328. package/dist/lens/LensSource.js +18 -0
  329. package/dist/lens/LensSource.js.map +1 -0
  330. package/dist/lens/assets/LensAssetRepository.d.ts +101 -0
  331. package/dist/lens/assets/LensAssetRepository.d.ts.map +1 -0
  332. package/dist/lens/assets/LensAssetRepository.js +139 -0
  333. package/dist/lens/assets/LensAssetRepository.js.map +1 -0
  334. package/dist/lens/assets/LensAssetsProvider.d.ts +28 -0
  335. package/dist/lens/assets/LensAssetsProvider.d.ts.map +1 -0
  336. package/dist/lens/assets/LensAssetsProvider.js +52 -0
  337. package/dist/lens/assets/LensAssetsProvider.js.map +1 -0
  338. package/dist/lens/assets/deviceDependentAssetLoader.d.ts +12 -0
  339. package/dist/lens/assets/deviceDependentAssetLoader.d.ts.map +1 -0
  340. package/dist/lens/assets/deviceDependentAssetLoader.js +49 -0
  341. package/dist/lens/assets/deviceDependentAssetLoader.js.map +1 -0
  342. package/dist/lens/assets/remoteMediaAssetLoaderFactory.d.ts +11 -0
  343. package/dist/lens/assets/remoteMediaAssetLoaderFactory.d.ts.map +1 -0
  344. package/dist/lens/assets/remoteMediaAssetLoaderFactory.js +18 -0
  345. package/dist/lens/assets/remoteMediaAssetLoaderFactory.js.map +1 -0
  346. package/dist/lens/assets/staticAssetLoader.d.ts +11 -0
  347. package/dist/lens/assets/staticAssetLoader.d.ts.map +1 -0
  348. package/dist/lens/assets/staticAssetLoader.js +21 -0
  349. package/dist/lens/assets/staticAssetLoader.js.map +1 -0
  350. package/dist/lens/cameraKitLensSource.d.ts +18 -0
  351. package/dist/lens/cameraKitLensSource.d.ts.map +1 -0
  352. package/dist/lens/cameraKitLensSource.js +93 -0
  353. package/dist/lens/cameraKitLensSource.js.map +1 -0
  354. package/dist/lens/fetchWatermarkLens.d.ts +12 -0
  355. package/dist/lens/fetchWatermarkLens.d.ts.map +1 -0
  356. package/dist/lens/fetchWatermarkLens.js +23 -0
  357. package/dist/lens/fetchWatermarkLens.js.map +1 -0
  358. package/dist/lens-client-interface/exif.d.ts +21 -0
  359. package/dist/lens-client-interface/exif.d.ts.map +1 -0
  360. package/dist/lens-client-interface/exif.js +51 -0
  361. package/dist/lens-client-interface/exif.js.map +1 -0
  362. package/dist/lens-client-interface/imagePicker.d.ts +9 -0
  363. package/dist/lens-client-interface/imagePicker.d.ts.map +1 -0
  364. package/dist/lens-client-interface/imagePicker.js +113 -0
  365. package/dist/lens-client-interface/imagePicker.js.map +1 -0
  366. package/dist/lens-client-interface/lensClientInterface.d.ts +14 -0
  367. package/dist/lens-client-interface/lensClientInterface.d.ts.map +1 -0
  368. package/dist/lens-client-interface/lensClientInterface.js +22 -0
  369. package/dist/lens-client-interface/lensClientInterface.js.map +1 -0
  370. package/dist/lens-core-module/generated-types.d.ts +470 -0
  371. package/dist/lens-core-module/generated-types.d.ts.map +1 -0
  372. package/dist/lens-core-module/lensCore.d.ts +59 -0
  373. package/dist/lens-core-module/lensCore.d.ts.map +1 -0
  374. package/dist/lens-core-module/lensCore.js +95 -0
  375. package/dist/lens-core-module/lensCore.js.map +1 -0
  376. package/dist/lens-core-module/lensCoreError.d.ts +16 -0
  377. package/dist/lens-core-module/lensCoreError.d.ts.map +1 -0
  378. package/dist/lens-core-module/lensCoreError.js +35 -0
  379. package/dist/lens-core-module/lensCoreError.js.map +1 -0
  380. package/dist/lens-core-module/loader/bootstrapURLs.d.ts +13 -0
  381. package/dist/lens-core-module/loader/bootstrapURLs.d.ts.map +1 -0
  382. package/dist/lens-core-module/loader/bootstrapURLs.js +32 -0
  383. package/dist/lens-core-module/loader/bootstrapURLs.js.map +1 -0
  384. package/dist/lens-core-module/loader/lensCoreFactory.d.ts +18 -0
  385. package/dist/lens-core-module/loader/lensCoreFactory.d.ts.map +1 -0
  386. package/dist/lens-core-module/loader/lensCoreFactory.js +54 -0
  387. package/dist/lens-core-module/loader/lensCoreFactory.js.map +1 -0
  388. package/dist/lensCoreWasmVersions.d.ts +7 -0
  389. package/dist/lensCoreWasmVersions.d.ts.map +1 -0
  390. package/dist/lensCoreWasmVersions.js +6 -0
  391. package/dist/lensCoreWasmVersions.js.map +1 -0
  392. package/dist/logger/errorLoggingDecorator.d.ts +10 -0
  393. package/dist/logger/errorLoggingDecorator.d.ts.map +1 -0
  394. package/dist/logger/errorLoggingDecorator.js +19 -0
  395. package/dist/logger/errorLoggingDecorator.js.map +1 -0
  396. package/dist/logger/logEntries.d.ts +16 -0
  397. package/dist/logger/logEntries.d.ts.map +1 -0
  398. package/dist/logger/logEntries.js +4 -0
  399. package/dist/logger/logEntries.js.map +1 -0
  400. package/dist/logger/logger.d.ts +41 -0
  401. package/dist/logger/logger.d.ts.map +1 -0
  402. package/dist/logger/logger.js +27 -0
  403. package/dist/logger/logger.js.map +1 -0
  404. package/dist/logger/registerLogEntriesSubscriber.d.ts +15 -0
  405. package/dist/logger/registerLogEntriesSubscriber.d.ts.map +1 -0
  406. package/dist/logger/registerLogEntriesSubscriber.js +27 -0
  407. package/dist/logger/registerLogEntriesSubscriber.js.map +1 -0
  408. package/dist/media-sources/CameraKitSource.d.ts +130 -0
  409. package/dist/media-sources/CameraKitSource.d.ts.map +1 -0
  410. package/dist/media-sources/CameraKitSource.js +96 -0
  411. package/dist/media-sources/CameraKitSource.js.map +1 -0
  412. package/dist/media-sources/FunctionSource.d.ts +42 -0
  413. package/dist/media-sources/FunctionSource.d.ts.map +1 -0
  414. package/dist/media-sources/FunctionSource.js +105 -0
  415. package/dist/media-sources/FunctionSource.js.map +1 -0
  416. package/dist/media-sources/ImageSource.d.ts +13 -0
  417. package/dist/media-sources/ImageSource.d.ts.map +1 -0
  418. package/dist/media-sources/ImageSource.js +7 -0
  419. package/dist/media-sources/ImageSource.js.map +1 -0
  420. package/dist/media-sources/MediaStreamSource.d.ts +31 -0
  421. package/dist/media-sources/MediaStreamSource.d.ts.map +1 -0
  422. package/dist/media-sources/MediaStreamSource.js +140 -0
  423. package/dist/media-sources/MediaStreamSource.js.map +1 -0
  424. package/dist/media-sources/VideoSource.d.ts +27 -0
  425. package/dist/media-sources/VideoSource.d.ts.map +1 -0
  426. package/dist/media-sources/VideoSource.js +12 -0
  427. package/dist/media-sources/VideoSource.js.map +1 -0
  428. package/dist/metrics/businessEventsReporter.d.ts +40 -0
  429. package/dist/metrics/businessEventsReporter.d.ts.map +1 -0
  430. package/dist/metrics/businessEventsReporter.js +156 -0
  431. package/dist/metrics/businessEventsReporter.js.map +1 -0
  432. package/dist/metrics/metricsEventTarget.d.ts +42 -0
  433. package/dist/metrics/metricsEventTarget.d.ts.map +1 -0
  434. package/dist/metrics/metricsEventTarget.js +4 -0
  435. package/dist/metrics/metricsEventTarget.js.map +1 -0
  436. package/dist/metrics/operational/Count.d.ts +21 -0
  437. package/dist/metrics/operational/Count.d.ts.map +1 -0
  438. package/dist/metrics/operational/Count.js +31 -0
  439. package/dist/metrics/operational/Count.js.map +1 -0
  440. package/dist/metrics/operational/Histogram.d.ts +19 -0
  441. package/dist/metrics/operational/Histogram.d.ts.map +1 -0
  442. package/dist/metrics/operational/Histogram.js +26 -0
  443. package/dist/metrics/operational/Histogram.js.map +1 -0
  444. package/dist/metrics/operational/Metric.d.ts +21 -0
  445. package/dist/metrics/operational/Metric.d.ts.map +1 -0
  446. package/dist/metrics/operational/Metric.js +23 -0
  447. package/dist/metrics/operational/Metric.js.map +1 -0
  448. package/dist/metrics/operational/Timer.d.ts +96 -0
  449. package/dist/metrics/operational/Timer.d.ts.map +1 -0
  450. package/dist/metrics/operational/Timer.js +64 -0
  451. package/dist/metrics/operational/Timer.js.map +1 -0
  452. package/dist/metrics/reporters/reportBenchmarks.d.ts +11 -0
  453. package/dist/metrics/reporters/reportBenchmarks.d.ts.map +1 -0
  454. package/dist/metrics/reporters/reportBenchmarks.js +27 -0
  455. package/dist/metrics/reporters/reportBenchmarks.js.map +1 -0
  456. package/dist/metrics/reporters/reportGlobalException.d.ts +27 -0
  457. package/dist/metrics/reporters/reportGlobalException.d.ts.map +1 -0
  458. package/dist/metrics/reporters/reportGlobalException.js +82 -0
  459. package/dist/metrics/reporters/reportGlobalException.js.map +1 -0
  460. package/dist/metrics/reporters/reportHttpMetrics.d.ts +11 -0
  461. package/dist/metrics/reporters/reportHttpMetrics.d.ts.map +1 -0
  462. package/dist/metrics/reporters/reportHttpMetrics.js +107 -0
  463. package/dist/metrics/reporters/reportHttpMetrics.js.map +1 -0
  464. package/dist/metrics/reporters/reportLegalState.d.ts +16 -0
  465. package/dist/metrics/reporters/reportLegalState.d.ts.map +1 -0
  466. package/dist/metrics/reporters/reportLegalState.js +29 -0
  467. package/dist/metrics/reporters/reportLegalState.js.map +1 -0
  468. package/dist/metrics/reporters/reportLensAndAssetDownload.d.ts +39 -0
  469. package/dist/metrics/reporters/reportLensAndAssetDownload.d.ts.map +1 -0
  470. package/dist/metrics/reporters/reportLensAndAssetDownload.js +91 -0
  471. package/dist/metrics/reporters/reportLensAndAssetDownload.js.map +1 -0
  472. package/dist/metrics/reporters/reportLensValidationFailed.d.ts +21 -0
  473. package/dist/metrics/reporters/reportLensValidationFailed.d.ts.map +1 -0
  474. package/dist/metrics/reporters/reportLensValidationFailed.js +21 -0
  475. package/dist/metrics/reporters/reportLensValidationFailed.js.map +1 -0
  476. package/dist/metrics/reporters/reportLensView.d.ts +37 -0
  477. package/dist/metrics/reporters/reportLensView.d.ts.map +1 -0
  478. package/dist/metrics/reporters/reportLensView.js +102 -0
  479. package/dist/metrics/reporters/reportLensView.js.map +1 -0
  480. package/dist/metrics/reporters/reportLensWait.d.ts +33 -0
  481. package/dist/metrics/reporters/reportLensWait.d.ts.map +1 -0
  482. package/dist/metrics/reporters/reportLensWait.js +35 -0
  483. package/dist/metrics/reporters/reportLensWait.js.map +1 -0
  484. package/dist/metrics/reporters/reportPlatformCapabilities.d.ts +13 -0
  485. package/dist/metrics/reporters/reportPlatformCapabilities.d.ts.map +1 -0
  486. package/dist/metrics/reporters/reportPlatformCapabilities.js +13 -0
  487. package/dist/metrics/reporters/reportPlatformCapabilities.js.map +1 -0
  488. package/dist/metrics/reporters/reportSessionException.d.ts +18 -0
  489. package/dist/metrics/reporters/reportSessionException.d.ts.map +1 -0
  490. package/dist/metrics/reporters/reportSessionException.js +7 -0
  491. package/dist/metrics/reporters/reportSessionException.js.map +1 -0
  492. package/dist/metrics/reporters/reportUserSession.d.ts +15 -0
  493. package/dist/metrics/reporters/reportUserSession.d.ts.map +1 -0
  494. package/dist/metrics/reporters/reportUserSession.js +61 -0
  495. package/dist/metrics/reporters/reportUserSession.js.map +1 -0
  496. package/dist/metrics/reporters/reporters.d.ts +47 -0
  497. package/dist/metrics/reporters/reporters.d.ts.map +1 -0
  498. package/dist/metrics/reporters/reporters.js +24 -0
  499. package/dist/metrics/reporters/reporters.js.map +1 -0
  500. package/dist/namedErrors.d.ts +131 -0
  501. package/dist/namedErrors.d.ts.map +1 -0
  502. package/dist/namedErrors.js +29 -0
  503. package/dist/namedErrors.js.map +1 -0
  504. package/dist/observable-operators/debounceTimeAfter.d.ts +26 -0
  505. package/dist/observable-operators/debounceTimeAfter.d.ts.map +1 -0
  506. package/dist/observable-operators/debounceTimeAfter.js +22 -0
  507. package/dist/observable-operators/debounceTimeAfter.js.map +1 -0
  508. package/dist/observable-operators/unsubscribed.d.ts +13 -0
  509. package/dist/observable-operators/unsubscribed.d.ts.map +1 -0
  510. package/dist/observable-operators/unsubscribed.js +15 -0
  511. package/dist/observable-operators/unsubscribed.js.map +1 -0
  512. package/dist/persistence/ExpiringPersistence.d.ts +22 -0
  513. package/dist/persistence/ExpiringPersistence.d.ts.map +1 -0
  514. package/dist/persistence/ExpiringPersistence.js +64 -0
  515. package/dist/persistence/ExpiringPersistence.js.map +1 -0
  516. package/dist/persistence/IndexedDBPersistence.d.ts +48 -0
  517. package/dist/persistence/IndexedDBPersistence.d.ts.map +1 -0
  518. package/dist/persistence/IndexedDBPersistence.js +127 -0
  519. package/dist/persistence/IndexedDBPersistence.js.map +1 -0
  520. package/dist/persistence/Persistence.d.ts +26 -0
  521. package/dist/persistence/Persistence.d.ts.map +1 -0
  522. package/dist/persistence/Persistence.js +4 -0
  523. package/dist/persistence/Persistence.js.map +1 -0
  524. package/dist/platform/assertPlatformSupported.d.ts +5 -0
  525. package/dist/platform/assertPlatformSupported.d.ts.map +1 -0
  526. package/dist/platform/assertPlatformSupported.js +12 -0
  527. package/dist/platform/assertPlatformSupported.js.map +1 -0
  528. package/dist/platform/cameraKitUserAgent.d.ts +3 -0
  529. package/dist/platform/cameraKitUserAgent.d.ts.map +1 -0
  530. package/dist/platform/cameraKitUserAgent.js +13 -0
  531. package/dist/platform/cameraKitUserAgent.js.map +1 -0
  532. package/dist/platform/platformCapabilities.d.ts +58 -0
  533. package/dist/platform/platformCapabilities.d.ts.map +1 -0
  534. package/dist/platform/platformCapabilities.js +98 -0
  535. package/dist/platform/platformCapabilities.js.map +1 -0
  536. package/dist/platform/platformInfo.d.ts +44 -0
  537. package/dist/platform/platformInfo.d.ts.map +1 -0
  538. package/dist/platform/platformInfo.js +156 -0
  539. package/dist/platform/platformInfo.js.map +1 -0
  540. package/dist/remote-configuration/cofHandler.d.ts +30 -0
  541. package/dist/remote-configuration/cofHandler.d.ts.map +1 -0
  542. package/dist/remote-configuration/cofHandler.js +83 -0
  543. package/dist/remote-configuration/cofHandler.js.map +1 -0
  544. package/dist/remote-configuration/preloadConfiguration.d.ts +8 -0
  545. package/dist/remote-configuration/preloadConfiguration.d.ts.map +1 -0
  546. package/dist/remote-configuration/preloadConfiguration.js +20 -0
  547. package/dist/remote-configuration/preloadConfiguration.js.map +1 -0
  548. package/dist/remote-configuration/remoteConfiguration.d.ts +36 -0
  549. package/dist/remote-configuration/remoteConfiguration.d.ts.map +1 -0
  550. package/dist/remote-configuration/remoteConfiguration.js +59 -0
  551. package/dist/remote-configuration/remoteConfiguration.js.map +1 -0
  552. package/dist/session/CameraKitSession.d.ts +257 -0
  553. package/dist/session/CameraKitSession.d.ts.map +1 -0
  554. package/dist/session/CameraKitSession.js +242 -0
  555. package/dist/session/CameraKitSession.js.map +1 -0
  556. package/dist/session/CameraKitSessionEvents.d.ts +29 -0
  557. package/dist/session/CameraKitSessionEvents.d.ts.map +1 -0
  558. package/dist/session/CameraKitSessionEvents.js +15 -0
  559. package/dist/session/CameraKitSessionEvents.js.map +1 -0
  560. package/dist/session/LensKeyboard.d.ts +90 -0
  561. package/dist/session/LensKeyboard.d.ts.map +1 -0
  562. package/dist/session/LensKeyboard.js +89 -0
  563. package/dist/session/LensKeyboard.js.map +1 -0
  564. package/dist/session/LensPerformanceMeasurement.d.ts +58 -0
  565. package/dist/session/LensPerformanceMeasurement.d.ts.map +1 -0
  566. package/dist/session/LensPerformanceMeasurement.js +63 -0
  567. package/dist/session/LensPerformanceMeasurement.js.map +1 -0
  568. package/dist/session/LensPerformanceMetrics.d.ts +32 -0
  569. package/dist/session/LensPerformanceMetrics.d.ts.map +1 -0
  570. package/dist/session/LensPerformanceMetrics.js +39 -0
  571. package/dist/session/LensPerformanceMetrics.js.map +1 -0
  572. package/dist/session/lensState.d.ts +32 -0
  573. package/dist/session/lensState.d.ts.map +1 -0
  574. package/dist/session/lensState.js +194 -0
  575. package/dist/session/lensState.js.map +1 -0
  576. package/dist/session/sessionState.d.ts +11 -0
  577. package/dist/session/sessionState.d.ts.map +1 -0
  578. package/dist/session/sessionState.js.map +1 -0
  579. package/dist/transforms/Transform2D.d.ts +27 -0
  580. package/dist/transforms/Transform2D.d.ts.map +1 -0
  581. package/dist/transforms/Transform2D.js +13 -0
  582. package/dist/transforms/Transform2D.js.map +1 -0
  583. package/dist/utils.d.ts +4 -0
  584. package/dist/utils.d.ts.map +1 -0
  585. package/docs/html/assets/navigation.js +1 -1
  586. package/docs/html/assets/search.js +1 -1
  587. package/docs/html/classes/CameraKit.html +2 -2
  588. package/docs/html/classes/CameraKitSession.html +2 -2
  589. package/docs/html/classes/CameraKitSource.html +2 -2
  590. package/docs/html/classes/LensPerformanceMeasurement.html +2 -2
  591. package/docs/html/classes/LensPerformanceMetrics.html +2 -2
  592. package/docs/html/classes/LensRepository.html +3 -3
  593. package/docs/html/classes/Transform2D.html +2 -2
  594. package/docs/html/classes/TypedCustomEvent.html +2 -2
  595. package/docs/html/classes/TypedEventTarget.html +2 -2
  596. package/docs/html/enums/Lens_CameraFacing.html +2 -2
  597. package/docs/html/functions/ConcatInjectable.html +2 -2
  598. package/docs/html/functions/Injectable.html +2 -2
  599. package/docs/html/functions/bootstrapCameraKit.html +2 -2
  600. package/docs/html/functions/createExtension.html +2 -2
  601. package/docs/html/functions/createImageSource.html +2 -2
  602. package/docs/html/functions/createMediaStreamSource.html +2 -2
  603. package/docs/html/functions/createVideoSource.html +2 -2
  604. package/docs/html/functions/estimateLensPerformance.html +2 -2
  605. package/docs/html/functions/lensSourcesFactory.html +2 -2
  606. package/docs/html/functions/remoteApiServicesFactory.html +2 -2
  607. package/docs/html/hierarchy.html +1 -1
  608. package/docs/html/index.html +3 -3
  609. package/docs/html/interfaces/BitmojiUserInfo.html +3 -0
  610. package/docs/html/interfaces/CameraKitBootstrapConfiguration.html +2 -2
  611. package/docs/html/interfaces/CameraKitDeviceOptions.html +2 -2
  612. package/docs/html/interfaces/CameraKitSourceInfo.html +2 -2
  613. package/docs/html/interfaces/CameraKitSourceSubscriber.html +2 -2
  614. package/docs/html/interfaces/ComputedFrameMetrics.html +2 -2
  615. package/docs/html/interfaces/CreateSessionOptions.html +2 -2
  616. package/docs/html/interfaces/EstimatedLensPerformance.html +2 -2
  617. package/docs/html/interfaces/FriendUserInfo.html +4 -0
  618. package/docs/html/interfaces/FunctionSourceOptions.html +2 -2
  619. package/docs/html/interfaces/Lens.html +2 -2
  620. package/docs/html/interfaces/LensCreator.html +2 -2
  621. package/docs/html/interfaces/LensLaunchData.html +3 -3
  622. package/docs/html/interfaces/LensSource.html +2 -2
  623. package/docs/html/interfaces/LensUserData.html +10 -0
  624. package/docs/html/interfaces/LoadAssetRequest.html +2 -2
  625. package/docs/html/interfaces/MediaStreamSourceOptions.html +2 -2
  626. package/docs/html/interfaces/Preview.html +2 -2
  627. package/docs/html/interfaces/RemoteApiRequest.html +2 -2
  628. package/docs/html/interfaces/RemoteApiResponse.html +4 -4
  629. package/docs/html/interfaces/RemoteApiService.html +3 -3
  630. package/docs/html/interfaces/Snapcode.html +2 -2
  631. package/docs/html/interfaces/UriCancelRequest.html +2 -2
  632. package/docs/html/interfaces/UriRequest.html +2 -2
  633. package/docs/html/interfaces/UriResponse.html +2 -2
  634. package/docs/html/interfaces/VideoSourceOptions.html +2 -2
  635. package/docs/html/modules.html +7 -3
  636. package/docs/html/types/ArgumentValidationError.html +2 -0
  637. package/docs/html/types/AssetLoader.html +2 -2
  638. package/docs/html/types/AssetResponse.html +1 -1
  639. package/docs/html/types/AssetTiming.html +2 -2
  640. package/docs/html/types/BenchmarkError.html +1 -1
  641. package/docs/html/types/BootstrapError.html +2 -2
  642. package/docs/html/types/CacheKeyNotFoundError.html +1 -1
  643. package/docs/html/types/CameraKitSessionEventListener.html +2 -2
  644. package/docs/html/types/CameraKitSessionEvents.html +2 -2
  645. package/docs/html/types/CameraKitSourceError.html +1 -1
  646. package/docs/html/types/ConfigurationError.html +2 -2
  647. package/docs/html/types/FetchHandler.html +1 -1
  648. package/docs/html/types/Keyboard.html +2 -2
  649. package/docs/html/types/KeyboardEvents.html +2 -2
  650. package/docs/html/types/LegalError.html +1 -1
  651. package/docs/html/types/LensAbortError.html +2 -2
  652. package/docs/html/types/LensAssetError.html +2 -2
  653. package/docs/html/types/LensContentValidationError.html +1 -1
  654. package/docs/html/types/LensError.html +1 -1
  655. package/docs/html/types/LensExecutionError.html +2 -2
  656. package/docs/html/types/LensImagePickerError.html +2 -2
  657. package/docs/html/types/LensLaunchParams.html +2 -2
  658. package/docs/html/types/LensMetricsEvents.html +2 -2
  659. package/docs/html/types/LensPerformanceCluster.html +1 -1
  660. package/docs/html/types/LensView.html +2 -2
  661. package/docs/html/types/LensWait.html +2 -2
  662. package/docs/html/types/Matrix.html +2 -2
  663. package/docs/html/types/PersistentStoreError.html +2 -2
  664. package/docs/html/types/PlatformNotSupportedError.html +2 -2
  665. package/docs/html/types/PublicContainer.html +2 -2
  666. package/docs/html/types/PublicServices.html +2 -2
  667. package/docs/html/types/RemoteApiCancelRequestHandler.html +2 -2
  668. package/docs/html/types/RemoteApiRequestHandler.html +2 -2
  669. package/docs/html/types/RemoteApiServices.html +1 -1
  670. package/docs/html/types/RemoteApiStatus.html +2 -2
  671. package/docs/html/types/RenderTarget.html +2 -2
  672. package/docs/html/types/Uri.html +1 -1
  673. package/docs/html/types/WebGLError.html +1 -1
  674. package/docs/html/types/Zodiac.html +1 -0
  675. package/docs/html/variables/extensionRequestContext.html +2 -2
  676. package/docs/md/README.md +1 -1
  677. package/docs/md/classes/CameraKit.md +1 -1
  678. package/docs/md/classes/CameraKitSession.md +1 -1
  679. package/docs/md/classes/CameraKitSource.md +1 -1
  680. package/docs/md/classes/LensPerformanceMeasurement.md +1 -1
  681. package/docs/md/classes/LensPerformanceMetrics.md +1 -1
  682. package/docs/md/classes/LensRepository.md +2 -2
  683. package/docs/md/classes/Transform2D.md +1 -1
  684. package/docs/md/classes/TypedCustomEvent.md +1 -1
  685. package/docs/md/classes/TypedEventTarget.md +1 -1
  686. package/docs/md/enums/Lens_CameraFacing.md +1 -1
  687. package/docs/md/interfaces/BitmojiUserInfo.md +22 -0
  688. package/docs/md/interfaces/CameraKitBootstrapConfiguration.md +1 -1
  689. package/docs/md/interfaces/CameraKitDeviceOptions.md +1 -1
  690. package/docs/md/interfaces/CameraKitSourceInfo.md +1 -1
  691. package/docs/md/interfaces/CameraKitSourceSubscriber.md +1 -1
  692. package/docs/md/interfaces/ComputedFrameMetrics.md +1 -1
  693. package/docs/md/interfaces/CreateSessionOptions.md +1 -1
  694. package/docs/md/interfaces/EstimatedLensPerformance.md +1 -1
  695. package/docs/md/interfaces/FriendUserInfo.md +29 -0
  696. package/docs/md/interfaces/FunctionSourceOptions.md +1 -1
  697. package/docs/md/interfaces/Lens.md +1 -1
  698. package/docs/md/interfaces/LensCreator.md +1 -1
  699. package/docs/md/interfaces/LensLaunchData.md +2 -21
  700. package/docs/md/interfaces/LensSource.md +1 -1
  701. package/docs/md/interfaces/LensUserData.md +71 -0
  702. package/docs/md/interfaces/LoadAssetRequest.md +1 -1
  703. package/docs/md/interfaces/MediaStreamSourceOptions.md +1 -1
  704. package/docs/md/interfaces/Preview.md +1 -1
  705. package/docs/md/interfaces/RemoteApiRequest.md +1 -1
  706. package/docs/md/interfaces/RemoteApiResponse.md +2 -2
  707. package/docs/md/interfaces/RemoteApiService.md +2 -2
  708. package/docs/md/interfaces/Snapcode.md +1 -1
  709. package/docs/md/interfaces/UriCancelRequest.md +1 -1
  710. package/docs/md/interfaces/UriRequest.md +1 -1
  711. package/docs/md/interfaces/UriResponse.md +1 -1
  712. package/docs/md/interfaces/VideoSourceOptions.md +1 -1
  713. package/docs/md/modules.md +23 -5
  714. package/package.json +14 -12
  715. package/docs/html/enums/UserData_Zodiac.html +0 -15
  716. package/docs/md/enums/UserData_Zodiac.md +0 -106
  717. package/lib/CameraKit.d.ts +0 -333
  718. package/lib/CameraKit.js +0 -176
  719. package/lib/CameraKit.js.map +0 -1
  720. package/lib/__tests__/data.d.ts +0 -14
  721. package/lib/__tests__/data.js +0 -69
  722. package/lib/__tests__/data.js.map +0 -1
  723. package/lib/__tests__/deferred.d.ts +0 -16
  724. package/lib/__tests__/deferred.js +0 -29
  725. package/lib/__tests__/deferred.js.map +0 -1
  726. package/lib/__tests__/jest.matchers.d.ts +0 -17
  727. package/lib/__tests__/jest.matchers.js +0 -67
  728. package/lib/__tests__/jest.matchers.js.map +0 -1
  729. package/lib/benchmark/benchmarkGflops.d.ts +0 -16
  730. package/lib/benchmark/benchmarkGflops.js +0 -129
  731. package/lib/benchmark/benchmarkGflops.js.map +0 -1
  732. package/lib/benchmark/estimateLensPerformanceCluster.d.ts +0 -33
  733. package/lib/benchmark/estimateLensPerformanceCluster.js +0 -48
  734. package/lib/benchmark/estimateLensPerformanceCluster.js.map +0 -1
  735. package/lib/benchmark/webglUtils.d.ts +0 -7
  736. package/lib/bootstrapCameraKit.d.ts +0 -96
  737. package/lib/bootstrapCameraKit.js +0 -220
  738. package/lib/bootstrapCameraKit.js.map +0 -1
  739. package/lib/clients/createTsProtoClient.d.ts +0 -40
  740. package/lib/clients/createTsProtoClient.js +0 -52
  741. package/lib/clients/createTsProtoClient.js.map +0 -1
  742. package/lib/clients/grpcHandler.d.ts +0 -26
  743. package/lib/clients/grpcHandler.js +0 -90
  744. package/lib/clients/grpcHandler.js.map +0 -1
  745. package/lib/clients/lensesClient.d.ts +0 -9
  746. package/lib/clients/lensesClient.js.map +0 -1
  747. package/lib/clients/metricsClient.d.ts +0 -26
  748. package/lib/clients/metricsClient.js +0 -120
  749. package/lib/clients/metricsClient.js.map +0 -1
  750. package/lib/common/__mocks__/loadScript.d.ts +0 -1
  751. package/lib/common/__mocks__/loadScript.js +0 -10
  752. package/lib/common/__mocks__/loadScript.js.map +0 -1
  753. package/lib/common/assertions.d.ts +0 -27
  754. package/lib/common/assertions.js +0 -39
  755. package/lib/common/assertions.js.map +0 -1
  756. package/lib/common/copyDefinedProperties.d.ts +0 -13
  757. package/lib/common/copyDefinedProperties.js +0 -16
  758. package/lib/common/copyDefinedProperties.js.map +0 -1
  759. package/lib/common/date.d.ts +0 -3
  760. package/lib/common/dialog.d.ts +0 -59
  761. package/lib/common/dialog.js +0 -160
  762. package/lib/common/dialog.js.map +0 -1
  763. package/lib/common/entries.d.ts +0 -4
  764. package/lib/common/entries.js +0 -5
  765. package/lib/common/entries.js.map +0 -1
  766. package/lib/common/errorHelpers.d.ts +0 -10
  767. package/lib/common/errorHelpers.js +0 -24
  768. package/lib/common/errorHelpers.js.map +0 -1
  769. package/lib/common/getFilename.d.ts +0 -1
  770. package/lib/common/hash.d.ts +0 -5
  771. package/lib/common/hash.js +0 -17
  772. package/lib/common/hash.js.map +0 -1
  773. package/lib/common/loadScript.d.ts +0 -6
  774. package/lib/common/loadScript.js +0 -18
  775. package/lib/common/loadScript.js.map +0 -1
  776. package/lib/common/localization.d.ts +0 -54
  777. package/lib/common/localization.js +0 -654
  778. package/lib/common/localization.js.map +0 -1
  779. package/lib/common/memoize.d.ts +0 -8
  780. package/lib/common/pageVisibility.d.ts +0 -34
  781. package/lib/common/pageVisibility.js +0 -71
  782. package/lib/common/pageVisibility.js.map +0 -1
  783. package/lib/common/result.d.ts +0 -36
  784. package/lib/common/result.js +0 -40
  785. package/lib/common/result.js.map +0 -1
  786. package/lib/common/time.d.ts +0 -2
  787. package/lib/common/typeguards.d.ts +0 -53
  788. package/lib/common/typeguards.js +0 -92
  789. package/lib/common/typeguards.js.map +0 -1
  790. package/lib/common/types.d.ts +0 -18
  791. package/lib/common/types.js.map +0 -1
  792. package/lib/common/unionBy.d.ts +0 -28
  793. package/lib/common/unionBy.js +0 -46
  794. package/lib/common/unionBy.js.map +0 -1
  795. package/lib/common/validate.d.ts +0 -14
  796. package/lib/common/validate.js +0 -112
  797. package/lib/common/validate.js.map +0 -1
  798. package/lib/configuration.d.ts +0 -101
  799. package/lib/configuration.js +0 -51
  800. package/lib/configuration.js.map +0 -1
  801. package/lib/configurationOverrides.d.ts +0 -12
  802. package/lib/configurationOverrides.js +0 -46
  803. package/lib/configurationOverrides.js.map +0 -1
  804. package/lib/dependency-injection/Container.d.ts +0 -176
  805. package/lib/dependency-injection/Container.js +0 -160
  806. package/lib/dependency-injection/Container.js.map +0 -1
  807. package/lib/dependency-injection/Injectable.d.ts +0 -95
  808. package/lib/dependency-injection/Injectable.js.map +0 -1
  809. package/lib/dependency-injection/PartialContainer.d.ts +0 -85
  810. package/lib/dependency-injection/PartialContainer.js +0 -85
  811. package/lib/dependency-injection/PartialContainer.js.map +0 -1
  812. package/lib/dependency-injection/RootServices.d.ts +0 -73
  813. package/lib/dependency-injection/RootServices.js +0 -2
  814. package/lib/dependency-injection/RootServices.js.map +0 -1
  815. package/lib/dependency-injection/types.d.ts +0 -56
  816. package/lib/dependency-injection/types.js.map +0 -1
  817. package/lib/environment.d.ts +0 -4
  818. package/lib/environment.js +0 -2
  819. package/lib/environment.js.map +0 -1
  820. package/lib/events/TypedCustomEvent.d.ts +0 -10
  821. package/lib/events/TypedCustomEvent.js +0 -11
  822. package/lib/events/TypedCustomEvent.js.map +0 -1
  823. package/lib/events/TypedEventTarget.d.ts +0 -25
  824. package/lib/events/TypedEventTarget.js +0 -57
  825. package/lib/events/TypedEventTarget.js.map +0 -1
  826. package/lib/events/scan.d.ts +0 -15
  827. package/lib/events/scan.js +0 -46
  828. package/lib/events/scan.js.map +0 -1
  829. package/lib/extensions/RemoteApiServices.d.ts +0 -101
  830. package/lib/extensions/RemoteApiServices.js +0 -203
  831. package/lib/extensions/RemoteApiServices.js.map +0 -1
  832. package/lib/extensions/UriHandlers.d.ts +0 -47
  833. package/lib/extensions/UriHandlers.js +0 -38
  834. package/lib/extensions/UriHandlers.js.map +0 -1
  835. package/lib/extensions/extensionRequestContext.d.ts +0 -4
  836. package/lib/extensions/extensionRequestContext.js +0 -14
  837. package/lib/extensions/extensionRequestContext.js.map +0 -1
  838. package/lib/extensions/uriHandlersRegister.d.ts +0 -21
  839. package/lib/extensions/uriHandlersRegister.js +0 -72
  840. package/lib/extensions/uriHandlersRegister.js.map +0 -1
  841. package/lib/generated-proto/blizzard/cameraKitEvents.d.ts +0 -9527
  842. package/lib/generated-proto/pb_schema/camera_kit/v3/business_events.d.ts +0 -79
  843. package/lib/generated-proto/pb_schema/camera_kit/v3/export.d.ts +0 -528
  844. package/lib/generated-proto/pb_schema/camera_kit/v3/features/ranking_info.d.ts +0 -34
  845. package/lib/generated-proto/pb_schema/camera_kit/v3/features/ranking_info.js +0 -43
  846. package/lib/generated-proto/pb_schema/camera_kit/v3/features/ranking_info.js.map +0 -1
  847. package/lib/generated-proto/pb_schema/camera_kit/v3/features/remote_api_info.d.ts +0 -29
  848. package/lib/generated-proto/pb_schema/camera_kit/v3/legal_prompt.d.ts +0 -85
  849. package/lib/generated-proto/pb_schema/camera_kit/v3/lens.d.ts +0 -384
  850. package/lib/generated-proto/pb_schema/camera_kit/v3/operational_metrics.d.ts +0 -178
  851. package/lib/generated-proto/pb_schema/camera_kit/v3/ranking.d.ts +0 -56
  852. package/lib/generated-proto/pb_schema/camera_kit/v3/service.d.ts +0 -2511
  853. package/lib/generated-proto/pb_schema/cdp/cof/benchmark.d.ts +0 -78
  854. package/lib/generated-proto/pb_schema/cdp/cof/benchmark_name.d.ts +0 -50
  855. package/lib/generated-proto/pb_schema/cdp/cof/circumstance_service.d.ts +0 -25574
  856. package/lib/generated-proto/pb_schema/cdp/cof/config_request.d.ts +0 -279
  857. package/lib/generated-proto/pb_schema/cdp/cof/config_response.d.ts +0 -3725
  858. package/lib/generated-proto/pb_schema/cdp/cof/config_result.d.ts +0 -10223
  859. package/lib/generated-proto/pb_schema/cdp/cof/debug_info.d.ts +0 -93
  860. package/lib/generated-proto/pb_schema/cdp/cof/namespace.d.ts +0 -8
  861. package/lib/generated-proto/pb_schema/common/ruid.d.ts +0 -51
  862. package/lib/generated-proto/pb_schema/common/value.d.ts +0 -144
  863. package/lib/generated-proto/pb_schema/google/api/annotations.d.ts +0 -1
  864. package/lib/generated-proto/pb_schema/google/api/annotations.js +0 -9
  865. package/lib/generated-proto/pb_schema/google/api/annotations.js.map +0 -1
  866. package/lib/generated-proto/pb_schema/google/api/http.d.ts +0 -3630
  867. package/lib/generated-proto/pb_schema/google/api/http.js +0 -194
  868. package/lib/generated-proto/pb_schema/google/api/http.js.map +0 -1
  869. package/lib/generated-proto/pb_schema/google/protobuf/any.d.ts +0 -32
  870. package/lib/generated-proto/pb_schema/google/protobuf/descriptor.d.ts +0 -50896
  871. package/lib/generated-proto/pb_schema/google/protobuf/descriptor.js +0 -1857
  872. package/lib/generated-proto/pb_schema/google/protobuf/descriptor.js.map +0 -1
  873. package/lib/generated-proto/pb_schema/google/protobuf/timestamp.d.ts +0 -32
  874. package/lib/generated-proto/pb_schema/google/protobuf/wrappers.d.ts +0 -119
  875. package/lib/generated-proto/pb_schema/lenses/geocircle.d.ts +0 -42
  876. package/lib/generated-proto/pb_schema/lenses/geopoint.d.ts +0 -32
  877. package/lib/generated-proto/pb_schema/lenses/launch_params.d.ts +0 -29
  878. package/lib/generated-proto/pb_schema/lenses/launchdata.d.ts +0 -396
  879. package/lib/generated-proto/pb_schema/lenses/lures.d.ts +0 -111
  880. package/lib/generated-proto/pb_schema/lenses/persistent_store.d.ts +0 -29
  881. package/lib/generated-proto/pb_schema/lenses/remote_api/remote_api_service.d.ts +0 -569
  882. package/lib/generated-proto/pb_schema/lenses/snappable.d.ts +0 -902
  883. package/lib/generated-proto/pb_schema/lenses/user_data.d.ts +0 -229
  884. package/lib/handlers/HandlerChainBuilder.d.ts +0 -110
  885. package/lib/handlers/HandlerChainBuilder.js +0 -199
  886. package/lib/handlers/HandlerChainBuilder.js.map +0 -1
  887. package/lib/handlers/arrayBufferParsingHandler.d.ts +0 -10
  888. package/lib/handlers/arrayBufferParsingHandler.js +0 -18
  889. package/lib/handlers/arrayBufferParsingHandler.js.map +0 -1
  890. package/lib/handlers/batchingHandler.d.ts +0 -31
  891. package/lib/handlers/batchingHandler.js +0 -76
  892. package/lib/handlers/batchingHandler.js.map +0 -1
  893. package/lib/handlers/cameraKitServiceFetchHandlerFactory.d.ts +0 -12
  894. package/lib/handlers/cameraKitServiceFetchHandlerFactory.js +0 -19
  895. package/lib/handlers/cameraKitServiceFetchHandlerFactory.js.map +0 -1
  896. package/lib/handlers/debugHandler.d.ts +0 -8
  897. package/lib/handlers/debugHandler.js +0 -27
  898. package/lib/handlers/debugHandler.js.map +0 -1
  899. package/lib/handlers/defaultFetchHandler.d.ts +0 -15
  900. package/lib/handlers/defaultFetchHandler.js +0 -38
  901. package/lib/handlers/defaultFetchHandler.js.map +0 -1
  902. package/lib/handlers/headersModifyingFetchHandler.d.ts +0 -8
  903. package/lib/handlers/headersModifyingFetchHandler.js +0 -17
  904. package/lib/handlers/headersModifyingFetchHandler.js.map +0 -1
  905. package/lib/handlers/mappingHandler.d.ts +0 -19
  906. package/lib/handlers/mappingHandler.js +0 -67
  907. package/lib/handlers/mappingHandler.js.map +0 -1
  908. package/lib/handlers/noCorsRetryingFetchHandler.d.ts +0 -48
  909. package/lib/handlers/noCorsRetryingFetchHandler.js +0 -95
  910. package/lib/handlers/noCorsRetryingFetchHandler.js.map +0 -1
  911. package/lib/handlers/persistingHandler.d.ts +0 -14
  912. package/lib/handlers/persistingHandler.js +0 -71
  913. package/lib/handlers/persistingHandler.js.map +0 -1
  914. package/lib/handlers/rateLimitingHandler.d.ts +0 -24
  915. package/lib/handlers/rateLimitingHandler.js +0 -45
  916. package/lib/handlers/rateLimitingHandler.js.map +0 -1
  917. package/lib/handlers/requestStateEmittingHandler.d.ts +0 -41
  918. package/lib/handlers/requestStateEmittingHandler.js +0 -45
  919. package/lib/handlers/requestStateEmittingHandler.js.map +0 -1
  920. package/lib/handlers/responseCachingHandler.d.ts +0 -34
  921. package/lib/handlers/responseCachingHandler.js +0 -109
  922. package/lib/handlers/responseCachingHandler.js.map +0 -1
  923. package/lib/handlers/retryingHandler.d.ts +0 -48
  924. package/lib/handlers/retryingHandler.js +0 -86
  925. package/lib/handlers/retryingHandler.js.map +0 -1
  926. package/lib/handlers/timeoutHandler.d.ts +0 -18
  927. package/lib/handlers/timeoutHandler.js +0 -30
  928. package/lib/handlers/timeoutHandler.js.map +0 -1
  929. package/lib/handlers/utils.d.ts +0 -12
  930. package/lib/handlers/utils.js +0 -19
  931. package/lib/handlers/utils.js.map +0 -1
  932. package/lib/index.d.ts +0 -42
  933. package/lib/index.js +0 -36
  934. package/lib/index.js.map +0 -1
  935. package/lib/legal/legalPrompt.d.ts +0 -20
  936. package/lib/legal/legalPrompt.js +0 -135
  937. package/lib/legal/legalPrompt.js.map +0 -1
  938. package/lib/legal/legalState.d.ts +0 -50
  939. package/lib/legal/legalState.js +0 -163
  940. package/lib/legal/legalState.js.map +0 -1
  941. package/lib/lens/Lens.d.ts +0 -115
  942. package/lib/lens/Lens.js +0 -84
  943. package/lib/lens/Lens.js.map +0 -1
  944. package/lib/lens/LensLaunchData.d.ts +0 -40
  945. package/lib/lens/LensLaunchData.js +0 -37
  946. package/lib/lens/LensLaunchData.js.map +0 -1
  947. package/lib/lens/LensPersistenceStore.d.ts +0 -7
  948. package/lib/lens/LensPersistenceStore.js.map +0 -1
  949. package/lib/lens/LensRepository.d.ts +0 -137
  950. package/lib/lens/LensRepository.js +0 -237
  951. package/lib/lens/LensRepository.js.map +0 -1
  952. package/lib/lens/LensSource.d.ts +0 -43
  953. package/lib/lens/LensSource.js +0 -42
  954. package/lib/lens/LensSource.js.map +0 -1
  955. package/lib/lens/assets/LensAssetRepository.d.ts +0 -99
  956. package/lib/lens/assets/LensAssetRepository.js +0 -184
  957. package/lib/lens/assets/LensAssetRepository.js.map +0 -1
  958. package/lib/lens/assets/LensAssetsProvider.d.ts +0 -27
  959. package/lib/lens/assets/LensAssetsProvider.js +0 -68
  960. package/lib/lens/assets/LensAssetsProvider.js.map +0 -1
  961. package/lib/lens/assets/deviceDependentAssetLoader.d.ts +0 -11
  962. package/lib/lens/assets/deviceDependentAssetLoader.js +0 -59
  963. package/lib/lens/assets/deviceDependentAssetLoader.js.map +0 -1
  964. package/lib/lens/assets/remoteMediaAssetLoaderFactory.d.ts +0 -10
  965. package/lib/lens/assets/remoteMediaAssetLoaderFactory.js +0 -27
  966. package/lib/lens/assets/remoteMediaAssetLoaderFactory.js.map +0 -1
  967. package/lib/lens/assets/staticAssetLoader.d.ts +0 -10
  968. package/lib/lens/assets/staticAssetLoader.js +0 -25
  969. package/lib/lens/assets/staticAssetLoader.js.map +0 -1
  970. package/lib/lens/cameraKitLensSource.d.ts +0 -16
  971. package/lib/lens/cameraKitLensSource.js +0 -59
  972. package/lib/lens/cameraKitLensSource.js.map +0 -1
  973. package/lib/lens-client-interface/exif.d.ts +0 -20
  974. package/lib/lens-client-interface/exif.js +0 -61
  975. package/lib/lens-client-interface/exif.js.map +0 -1
  976. package/lib/lens-client-interface/imagePicker.d.ts +0 -8
  977. package/lib/lens-client-interface/imagePicker.js +0 -128
  978. package/lib/lens-client-interface/imagePicker.js.map +0 -1
  979. package/lib/lens-client-interface/lensClientInterface.d.ts +0 -13
  980. package/lib/lens-client-interface/lensClientInterface.js +0 -30
  981. package/lib/lens-client-interface/lensClientInterface.js.map +0 -1
  982. package/lib/lens-core-module/generated-types.d.ts +0 -469
  983. package/lib/lens-core-module/lensCore.d.ts +0 -43
  984. package/lib/lens-core-module/lensCore.js +0 -59
  985. package/lib/lens-core-module/lensCore.js.map +0 -1
  986. package/lib/lens-core-module/lensCoreError.d.ts +0 -15
  987. package/lib/lens-core-module/lensCoreError.js +0 -43
  988. package/lib/lens-core-module/lensCoreError.js.map +0 -1
  989. package/lib/lens-core-module/loader/bootstrapURLs.d.ts +0 -12
  990. package/lib/lens-core-module/loader/bootstrapURLs.js +0 -48
  991. package/lib/lens-core-module/loader/bootstrapURLs.js.map +0 -1
  992. package/lib/lens-core-module/loader/lensCoreFactory.d.ts +0 -17
  993. package/lib/lens-core-module/loader/lensCoreFactory.js +0 -76
  994. package/lib/lens-core-module/loader/lensCoreFactory.js.map +0 -1
  995. package/lib/lensCoreWasmVersions.d.ts +0 -6
  996. package/lib/lensCoreWasmVersions.js +0 -6
  997. package/lib/lensCoreWasmVersions.js.map +0 -1
  998. package/lib/logger/errorLoggingDecorator.d.ts +0 -9
  999. package/lib/logger/errorLoggingDecorator.js +0 -32
  1000. package/lib/logger/errorLoggingDecorator.js.map +0 -1
  1001. package/lib/logger/logEntries.d.ts +0 -15
  1002. package/lib/logger/logEntries.js +0 -14
  1003. package/lib/logger/logEntries.js.map +0 -1
  1004. package/lib/logger/logger.d.ts +0 -40
  1005. package/lib/logger/logger.js +0 -53
  1006. package/lib/logger/logger.js.map +0 -1
  1007. package/lib/logger/registerLogEntriesSubscriber.d.ts +0 -14
  1008. package/lib/logger/registerLogEntriesSubscriber.js +0 -35
  1009. package/lib/logger/registerLogEntriesSubscriber.js.map +0 -1
  1010. package/lib/media-sources/CameraKitSource.d.ts +0 -126
  1011. package/lib/media-sources/CameraKitSource.js +0 -138
  1012. package/lib/media-sources/CameraKitSource.js.map +0 -1
  1013. package/lib/media-sources/FunctionSource.d.ts +0 -41
  1014. package/lib/media-sources/FunctionSource.js +0 -128
  1015. package/lib/media-sources/FunctionSource.js.map +0 -1
  1016. package/lib/media-sources/ImageSource.d.ts +0 -11
  1017. package/lib/media-sources/ImageSource.js +0 -16
  1018. package/lib/media-sources/ImageSource.js.map +0 -1
  1019. package/lib/media-sources/MediaStreamSource.d.ts +0 -29
  1020. package/lib/media-sources/MediaStreamSource.js +0 -137
  1021. package/lib/media-sources/MediaStreamSource.js.map +0 -1
  1022. package/lib/media-sources/VideoSource.d.ts +0 -25
  1023. package/lib/media-sources/VideoSource.js +0 -22
  1024. package/lib/media-sources/VideoSource.js.map +0 -1
  1025. package/lib/metrics/businessEventsReporter.d.ts +0 -39
  1026. package/lib/metrics/businessEventsReporter.js +0 -195
  1027. package/lib/metrics/businessEventsReporter.js.map +0 -1
  1028. package/lib/metrics/metricsEventTarget.d.ts +0 -41
  1029. package/lib/metrics/metricsEventTarget.js +0 -11
  1030. package/lib/metrics/metricsEventTarget.js.map +0 -1
  1031. package/lib/metrics/operational/Count.d.ts +0 -19
  1032. package/lib/metrics/operational/Count.js +0 -33
  1033. package/lib/metrics/operational/Count.js.map +0 -1
  1034. package/lib/metrics/operational/Histogram.d.ts +0 -17
  1035. package/lib/metrics/operational/Histogram.js +0 -27
  1036. package/lib/metrics/operational/Histogram.js.map +0 -1
  1037. package/lib/metrics/operational/Metric.d.ts +0 -20
  1038. package/lib/metrics/operational/Metric.js +0 -28
  1039. package/lib/metrics/operational/Metric.js.map +0 -1
  1040. package/lib/metrics/operational/Timer.d.ts +0 -94
  1041. package/lib/metrics/operational/Timer.js +0 -108
  1042. package/lib/metrics/operational/Timer.js.map +0 -1
  1043. package/lib/metrics/reporters/reportBenchmarks.d.ts +0 -10
  1044. package/lib/metrics/reporters/reportBenchmarks.js +0 -30
  1045. package/lib/metrics/reporters/reportBenchmarks.js.map +0 -1
  1046. package/lib/metrics/reporters/reportGlobalException.d.ts +0 -26
  1047. package/lib/metrics/reporters/reportGlobalException.js +0 -106
  1048. package/lib/metrics/reporters/reportGlobalException.js.map +0 -1
  1049. package/lib/metrics/reporters/reportHttpMetrics.d.ts +0 -10
  1050. package/lib/metrics/reporters/reportHttpMetrics.js +0 -110
  1051. package/lib/metrics/reporters/reportHttpMetrics.js.map +0 -1
  1052. package/lib/metrics/reporters/reportLegalState.d.ts +0 -15
  1053. package/lib/metrics/reporters/reportLegalState.js +0 -32
  1054. package/lib/metrics/reporters/reportLegalState.js.map +0 -1
  1055. package/lib/metrics/reporters/reportLensAndAssetDownload.d.ts +0 -38
  1056. package/lib/metrics/reporters/reportLensAndAssetDownload.js +0 -92
  1057. package/lib/metrics/reporters/reportLensAndAssetDownload.js.map +0 -1
  1058. package/lib/metrics/reporters/reportLensValidationFailed.d.ts +0 -20
  1059. package/lib/metrics/reporters/reportLensValidationFailed.js +0 -24
  1060. package/lib/metrics/reporters/reportLensValidationFailed.js.map +0 -1
  1061. package/lib/metrics/reporters/reportLensView.d.ts +0 -36
  1062. package/lib/metrics/reporters/reportLensView.js +0 -137
  1063. package/lib/metrics/reporters/reportLensView.js.map +0 -1
  1064. package/lib/metrics/reporters/reportLensWait.d.ts +0 -32
  1065. package/lib/metrics/reporters/reportLensWait.js +0 -60
  1066. package/lib/metrics/reporters/reportLensWait.js.map +0 -1
  1067. package/lib/metrics/reporters/reportPlatformCapabilities.d.ts +0 -12
  1068. package/lib/metrics/reporters/reportPlatformCapabilities.js +0 -19
  1069. package/lib/metrics/reporters/reportPlatformCapabilities.js.map +0 -1
  1070. package/lib/metrics/reporters/reportSessionException.d.ts +0 -17
  1071. package/lib/metrics/reporters/reportSessionException.js +0 -12
  1072. package/lib/metrics/reporters/reportSessionException.js.map +0 -1
  1073. package/lib/metrics/reporters/reportUserSession.d.ts +0 -14
  1074. package/lib/metrics/reporters/reportUserSession.js +0 -66
  1075. package/lib/metrics/reporters/reportUserSession.js.map +0 -1
  1076. package/lib/metrics/reporters/reporters.d.ts +0 -46
  1077. package/lib/metrics/reporters/reporters.js +0 -35
  1078. package/lib/metrics/reporters/reporters.js.map +0 -1
  1079. package/lib/namedErrors.d.ts +0 -124
  1080. package/lib/namedErrors.js +0 -58
  1081. package/lib/namedErrors.js.map +0 -1
  1082. package/lib/observable-operators/unsubscribed.d.ts +0 -12
  1083. package/lib/observable-operators/unsubscribed.js +0 -27
  1084. package/lib/observable-operators/unsubscribed.js.map +0 -1
  1085. package/lib/persistence/ExpiringPersistence.d.ts +0 -21
  1086. package/lib/persistence/ExpiringPersistence.js +0 -71
  1087. package/lib/persistence/ExpiringPersistence.js.map +0 -1
  1088. package/lib/persistence/IndexedDBPersistence.d.ts +0 -47
  1089. package/lib/persistence/IndexedDBPersistence.js +0 -190
  1090. package/lib/persistence/IndexedDBPersistence.js.map +0 -1
  1091. package/lib/persistence/Persistence.d.ts +0 -25
  1092. package/lib/persistence/Persistence.js +0 -10
  1093. package/lib/persistence/Persistence.js.map +0 -1
  1094. package/lib/platform/assertPlatformSupported.d.ts +0 -4
  1095. package/lib/platform/assertPlatformSupported.js +0 -15
  1096. package/lib/platform/assertPlatformSupported.js.map +0 -1
  1097. package/lib/platform/cameraKitUserAgent.d.ts +0 -2
  1098. package/lib/platform/cameraKitUserAgent.js +0 -20
  1099. package/lib/platform/cameraKitUserAgent.js.map +0 -1
  1100. package/lib/platform/platformCapabilities.d.ts +0 -50
  1101. package/lib/platform/platformCapabilities.js +0 -128
  1102. package/lib/platform/platformCapabilities.js.map +0 -1
  1103. package/lib/platform/platformInfo.d.ts +0 -43
  1104. package/lib/platform/platformInfo.js +0 -228
  1105. package/lib/platform/platformInfo.js.map +0 -1
  1106. package/lib/remote-configuration/cofHandler.d.ts +0 -29
  1107. package/lib/remote-configuration/cofHandler.js +0 -115
  1108. package/lib/remote-configuration/cofHandler.js.map +0 -1
  1109. package/lib/remote-configuration/preloadConfiguration.d.ts +0 -7
  1110. package/lib/remote-configuration/preloadConfiguration.js +0 -15
  1111. package/lib/remote-configuration/preloadConfiguration.js.map +0 -1
  1112. package/lib/remote-configuration/remoteConfiguration.d.ts +0 -34
  1113. package/lib/remote-configuration/remoteConfiguration.js +0 -73
  1114. package/lib/remote-configuration/remoteConfiguration.js.map +0 -1
  1115. package/lib/session/CameraKitSession.d.ts +0 -255
  1116. package/lib/session/CameraKitSession.js +0 -440
  1117. package/lib/session/CameraKitSession.js.map +0 -1
  1118. package/lib/session/CameraKitSessionEvents.d.ts +0 -37
  1119. package/lib/session/CameraKitSessionEvents.js +0 -38
  1120. package/lib/session/CameraKitSessionEvents.js.map +0 -1
  1121. package/lib/session/LensKeyboard.d.ts +0 -94
  1122. package/lib/session/LensKeyboard.js +0 -95
  1123. package/lib/session/LensKeyboard.js.map +0 -1
  1124. package/lib/session/LensPerformanceMeasurement.d.ts +0 -57
  1125. package/lib/session/LensPerformanceMeasurement.js +0 -114
  1126. package/lib/session/LensPerformanceMeasurement.js.map +0 -1
  1127. package/lib/session/LensPerformanceMetrics.d.ts +0 -31
  1128. package/lib/session/LensPerformanceMetrics.js +0 -59
  1129. package/lib/session/LensPerformanceMetrics.js.map +0 -1
  1130. package/lib/session/lensState.d.ts +0 -30
  1131. package/lib/session/lensState.js +0 -238
  1132. package/lib/session/lensState.js.map +0 -1
  1133. package/lib/session/sessionState.d.ts +0 -10
  1134. package/lib/session/sessionState.js.map +0 -1
  1135. package/lib/transforms/Transform2D.d.ts +0 -22
  1136. package/lib/transforms/Transform2D.js +0 -19
  1137. package/lib/transforms/Transform2D.js.map +0 -1
  1138. package/lib/utils.d.ts +0 -3
  1139. /package/{lib → dist}/benchmark/webglUtils.js +0 -0
  1140. /package/{lib → dist}/benchmark/webglUtils.js.map +0 -0
  1141. /package/{lib → dist}/clients/lensesClient.js +0 -0
  1142. /package/{lib → dist}/common/date.js +0 -0
  1143. /package/{lib → dist}/common/date.js.map +0 -0
  1144. /package/{lib → dist}/common/getFilename.js +0 -0
  1145. /package/{lib → dist}/common/getFilename.js.map +0 -0
  1146. /package/{lib → dist}/common/memoize.js +0 -0
  1147. /package/{lib → dist}/common/memoize.js.map +0 -0
  1148. /package/{lib → dist}/common/time.js +0 -0
  1149. /package/{lib → dist}/common/time.js.map +0 -0
  1150. /package/{lib → dist}/common/types.js +0 -0
  1151. /package/{lib → dist}/dependency-injection/Injectable.js +0 -0
  1152. /package/{lib → dist}/dependency-injection/types.js +0 -0
  1153. /package/{lib → dist}/generated-proto/blizzard/cameraKitEvents.js +0 -0
  1154. /package/{lib → dist}/generated-proto/blizzard/cameraKitEvents.js.map +0 -0
  1155. /package/{lib → dist}/generated-proto/pb_schema/camera_kit/v3/business_events.js +0 -0
  1156. /package/{lib → dist}/generated-proto/pb_schema/camera_kit/v3/business_events.js.map +0 -0
  1157. /package/{lib → dist}/generated-proto/pb_schema/camera_kit/v3/export.js +0 -0
  1158. /package/{lib → dist}/generated-proto/pb_schema/camera_kit/v3/export.js.map +0 -0
  1159. /package/{lib → dist}/generated-proto/pb_schema/camera_kit/v3/features/remote_api_info.js +0 -0
  1160. /package/{lib → dist}/generated-proto/pb_schema/camera_kit/v3/features/remote_api_info.js.map +0 -0
  1161. /package/{lib → dist}/generated-proto/pb_schema/camera_kit/v3/legal_prompt.js +0 -0
  1162. /package/{lib → dist}/generated-proto/pb_schema/camera_kit/v3/legal_prompt.js.map +0 -0
  1163. /package/{lib → dist}/generated-proto/pb_schema/camera_kit/v3/lens.js +0 -0
  1164. /package/{lib → dist}/generated-proto/pb_schema/camera_kit/v3/lens.js.map +0 -0
  1165. /package/{lib → dist}/generated-proto/pb_schema/camera_kit/v3/operational_metrics.js +0 -0
  1166. /package/{lib → dist}/generated-proto/pb_schema/camera_kit/v3/operational_metrics.js.map +0 -0
  1167. /package/{lib → dist}/generated-proto/pb_schema/camera_kit/v3/ranking.js +0 -0
  1168. /package/{lib → dist}/generated-proto/pb_schema/camera_kit/v3/ranking.js.map +0 -0
  1169. /package/{lib → dist}/generated-proto/pb_schema/camera_kit/v3/service.js +0 -0
  1170. /package/{lib → dist}/generated-proto/pb_schema/camera_kit/v3/service.js.map +0 -0
  1171. /package/{lib → dist}/generated-proto/pb_schema/cdp/cof/benchmark.js +0 -0
  1172. /package/{lib → dist}/generated-proto/pb_schema/cdp/cof/benchmark.js.map +0 -0
  1173. /package/{lib → dist}/generated-proto/pb_schema/cdp/cof/benchmark_name.js +0 -0
  1174. /package/{lib → dist}/generated-proto/pb_schema/cdp/cof/benchmark_name.js.map +0 -0
  1175. /package/{lib → dist}/generated-proto/pb_schema/cdp/cof/circumstance_service.js +0 -0
  1176. /package/{lib → dist}/generated-proto/pb_schema/cdp/cof/circumstance_service.js.map +0 -0
  1177. /package/{lib → dist}/generated-proto/pb_schema/cdp/cof/config_request.js +0 -0
  1178. /package/{lib → dist}/generated-proto/pb_schema/cdp/cof/config_request.js.map +0 -0
  1179. /package/{lib → dist}/generated-proto/pb_schema/cdp/cof/config_response.js +0 -0
  1180. /package/{lib → dist}/generated-proto/pb_schema/cdp/cof/config_response.js.map +0 -0
  1181. /package/{lib → dist}/generated-proto/pb_schema/cdp/cof/config_result.js +0 -0
  1182. /package/{lib → dist}/generated-proto/pb_schema/cdp/cof/config_result.js.map +0 -0
  1183. /package/{lib → dist}/generated-proto/pb_schema/cdp/cof/debug_info.js +0 -0
  1184. /package/{lib → dist}/generated-proto/pb_schema/cdp/cof/debug_info.js.map +0 -0
  1185. /package/{lib → dist}/generated-proto/pb_schema/cdp/cof/namespace.js +0 -0
  1186. /package/{lib → dist}/generated-proto/pb_schema/cdp/cof/namespace.js.map +0 -0
  1187. /package/{lib → dist}/generated-proto/pb_schema/common/ruid.js +0 -0
  1188. /package/{lib → dist}/generated-proto/pb_schema/common/ruid.js.map +0 -0
  1189. /package/{lib → dist}/generated-proto/pb_schema/common/value.js +0 -0
  1190. /package/{lib → dist}/generated-proto/pb_schema/common/value.js.map +0 -0
  1191. /package/{lib → dist}/generated-proto/pb_schema/google/protobuf/any.js +0 -0
  1192. /package/{lib → dist}/generated-proto/pb_schema/google/protobuf/any.js.map +0 -0
  1193. /package/{lib → dist}/generated-proto/pb_schema/google/protobuf/timestamp.js +0 -0
  1194. /package/{lib → dist}/generated-proto/pb_schema/google/protobuf/timestamp.js.map +0 -0
  1195. /package/{lib → dist}/generated-proto/pb_schema/google/protobuf/wrappers.js +0 -0
  1196. /package/{lib → dist}/generated-proto/pb_schema/google/protobuf/wrappers.js.map +0 -0
  1197. /package/{lib → dist}/generated-proto/pb_schema/lenses/geocircle.js +0 -0
  1198. /package/{lib → dist}/generated-proto/pb_schema/lenses/geocircle.js.map +0 -0
  1199. /package/{lib → dist}/generated-proto/pb_schema/lenses/geopoint.js +0 -0
  1200. /package/{lib → dist}/generated-proto/pb_schema/lenses/geopoint.js.map +0 -0
  1201. /package/{lib → dist}/generated-proto/pb_schema/lenses/launch_params.js +0 -0
  1202. /package/{lib → dist}/generated-proto/pb_schema/lenses/launch_params.js.map +0 -0
  1203. /package/{lib → dist}/generated-proto/pb_schema/lenses/launchdata.js +0 -0
  1204. /package/{lib → dist}/generated-proto/pb_schema/lenses/launchdata.js.map +0 -0
  1205. /package/{lib → dist}/generated-proto/pb_schema/lenses/lures.js +0 -0
  1206. /package/{lib → dist}/generated-proto/pb_schema/lenses/lures.js.map +0 -0
  1207. /package/{lib → dist}/generated-proto/pb_schema/lenses/persistent_store.js +0 -0
  1208. /package/{lib → dist}/generated-proto/pb_schema/lenses/persistent_store.js.map +0 -0
  1209. /package/{lib → dist}/generated-proto/pb_schema/lenses/remote_api/remote_api_service.js +0 -0
  1210. /package/{lib → dist}/generated-proto/pb_schema/lenses/remote_api/remote_api_service.js.map +0 -0
  1211. /package/{lib → dist}/generated-proto/pb_schema/lenses/snappable.js +0 -0
  1212. /package/{lib → dist}/generated-proto/pb_schema/lenses/snappable.js.map +0 -0
  1213. /package/{lib → dist}/generated-proto/pb_schema/lenses/user_data.js +0 -0
  1214. /package/{lib → dist}/generated-proto/pb_schema/lenses/user_data.js.map +0 -0
  1215. /package/{lib → dist}/lens/LensPersistenceStore.js +0 -0
  1216. /package/{lib → dist}/lens-core-module/generated-types.js +0 -0
  1217. /package/{lib → dist}/lens-core-module/generated-types.js.map +0 -0
  1218. /package/{lib → dist}/session/sessionState.js +0 -0
  1219. /package/{lib → dist}/utils.js +0 -0
  1220. /package/{lib → dist}/utils.js.map +0 -0
@@ -0,0 +1,177 @@
1
+ import type { Memoized } from "../common/memoize";
2
+ import { PartialContainer } from "./PartialContainer";
3
+ import type { AddService, InjectableFunction, ValidTokens } from "./types";
4
+ type MaybeMemoizedFactories<Services> = {
5
+ [K in keyof Services]: ((c: Container<Services>) => Services[K]) | Memoized<(c: Container<Services>) => Services[K]>;
6
+ };
7
+ export type Factories<Services> = {
8
+ [K in keyof Services]: Memoized<(c: Container<any>) => Services[K]>;
9
+ };
10
+ export declare const CONTAINER = "$container";
11
+ export type ContainerToken = typeof CONTAINER;
12
+ /**
13
+ * A Container of values, indexed each by a unique token, which can be used throughout CameraKit. This is how CameraKit
14
+ * implements simple dependency injection.
15
+ *
16
+ * Dependency injection is a way to decouple the *use* of a dependency from the *creation* of that dependency. This
17
+ * improves modularity and re-usability, since components only care about the *interfaces* of dependencies (since that
18
+ * determines their use) and not about their concrete creation. New implementations of a particular dependency may be
19
+ * provided without the need to change any of the consumers of that dependency.
20
+ *
21
+ * There are a few commonly-used terms used when talking about dependency injection:
22
+ *
23
+ * - Container (or Injector): Maintains a registry of all available Services and understands how to create them.
24
+ * - Service: Anything that can be provided by the Container is called a Service – this can be a value of any type.
25
+ * - Token: Each Service is associated with a unique name, or Token. In order to obtain a Service from the Container,
26
+ * the consumer must provide the Token corresponding to that Service.
27
+ * - InjectableFunction: Services are created by InjectableFunctions. When adding a Service to a Container, the
28
+ * Service provider gives the Container a InjectableFunction which, when called will return the Service. These
29
+ * InjectableFunctions may themselves use other Services, which will be passed to them as arguments.
30
+ *
31
+ * Services are, by default, singletons – that is, each call to `get()` a particular Service will return a reference
32
+ * to the same value. In other words, InjectableFunctions are only invoked once. If multiple instances of a Service are
33
+ * desired, a new Container can be created using the `copy([Token])` method – passing a Token to this method forces the
34
+ * new Container to recreate the corresponding Service (the InjectableFunction will be invoked again). We say that the
35
+ * Service is then "scoped" to the new Container.
36
+ *
37
+ *
38
+ * One common downside of many dependency injection implementations is that the dependency graph formed by the various
39
+ * Services can only be validated at runtime. That is, if a dependency is missing or a circular dependency is found, the
40
+ * developer must wait until runtime to discover the error. These errors can often be confusing and hard to debug.
41
+ *
42
+ * This implementation eliminates this issue by moving these sorts of errors to compile time. If an unknown dependency
43
+ * is used in a InjectableFunction, for example, the code simply won't compile.
44
+ *
45
+ * To achieve this, we do lose the ability to implicitly define the dependency graph, as is common with many dependency
46
+ * injection frameworks that employ decorators to define Services and their dependencies. Instead, the dependency graph
47
+ * must be constructed explicitly, step-by-step, via successive calls to the `provide()` method. This is a suitable
48
+ * trade-off for CameraKit, as there are a relatively small number of Services.
49
+ *
50
+ * Here's a simple example of Container usage:
51
+ * ```ts
52
+ * const fooFactory = Injectable('Foo', () => new Foo())
53
+ * const barFactory = Injectable('Bar', ['Foo'] as const, (foo: Foo) => new Bar(foo))
54
+ * const container = Container.empy()
55
+ * .provide(fooFactory)
56
+ * .provide(barFactory)
57
+ *
58
+ * const bar: Bar = container.get('Bar')
59
+ * ```
60
+ */
61
+ /** @internal */
62
+ export declare class Container<Services = {}> {
63
+ /**
64
+ * Create a new [Container] by providing a [PartialContainer] that has no dependencies.
65
+ */
66
+ static provides<Services>(container: PartialContainer<Services, {}> | Container<Services>): Container<Services>;
67
+ /**
68
+ * Create a new [Container] by providing a Service that has no dependencies.
69
+ */
70
+ static provides<Token extends string, Service>(fn: InjectableFunction<{}, [], Token, Service>): Container<AddService<{}, Token, Service>>;
71
+ private readonly factories;
72
+ constructor(factories: MaybeMemoizedFactories<Services>);
73
+ /**
74
+ * Create a copy of this Container, optionally providing a list of Services which will be scoped to the copy.
75
+ *
76
+ * This can be useful, for example, if different parts of an application wish to use the same Service interface, but
77
+ * do not want to share a reference to same Service instance.
78
+ *
79
+ * Say we have a Service which manages a list of Users. Our application wishes to display two lists of Users, which
80
+ * may be edited independently. In this case it may be desirable to create a Container for each list component, with
81
+ * the UserList Service scoped to those Containers – that way, each list component gets a unique copy of the
82
+ * UserList Service that can be edited independently of the other.
83
+ *
84
+ * @param scopedServices A list of Tokens identifying Services which will be scoped to the new Container – that is,
85
+ * if those Services had already been created by the source Container, they will be re-created by their Factory
86
+ * functions when provided by the new Container.
87
+ * @returns A new copy of this Container, sharing all of this Container's Services. Services corresponding to any
88
+ * Tokens passed to this method will be re-created by the new Container (i.e. they become "scoped" to the new
89
+ * Container).
90
+ */
91
+ copy<Tokens extends readonly (keyof Services)[]>(scopedServices?: Tokens): Container<Services>;
92
+ /**
93
+ * Gets a reference to this Container.
94
+ *
95
+ * @param token The CONTAINER token.
96
+ * @returns This Container.
97
+ */
98
+ get(token: ContainerToken): this;
99
+ /**
100
+ * Get a specific Service provided by this Container.
101
+ *
102
+ * @param token A unique string corresponding to a Service
103
+ * @returns A Service corresponding to the given Token.
104
+ */
105
+ get<Token extends keyof Services>(token: Token): Services[Token];
106
+ /**
107
+ * Run the services in this [PartialContainer]. "Run" simply means that [Container::get] will be called for each
108
+ * Service, which invokes that Service's factory function, creating the Service.
109
+ *
110
+ * This may be useful e.g. if services need to initialize themselves, since generally a Service factory is only
111
+ * invoked when the Service is needed.
112
+ *
113
+ * Note this method cannot be used to add services to a Container. – that is, calling this method does not provide
114
+ * the services in a new Container.
115
+ *
116
+ * @param container Optionally provide a [PartialContainer], which will be used as a filter – the only services
117
+ * from *this* container that will run are those with a token that is also present in this PartialContainer.
118
+ * @returns No mutation is done to the Container, it is returned as-is (convenient for chaining).
119
+ */
120
+ run<AdditionalServices, Dependencies, FulfilledDependencies extends Dependencies>(this: Container<FulfilledDependencies>, container: PartialContainer<AdditionalServices, Dependencies>): this;
121
+ /**
122
+ * Run the given Service. "Run" simply means that [Container::get] will be called for this Service, which invokes
123
+ * the Service's factory function, creating the Service.
124
+ *
125
+ * This may be useful e.g. if services need to initialize themselves, since generally a Service factory is only
126
+ * invoked when the Service is needed.
127
+ *
128
+ * Note this method cannot be used to add services to a Container. – that is, calling this method does not provide
129
+ * the services in a new Container.
130
+ *
131
+ * @param fn Optionally provide an [InjectableFunction], which will be used as a filter – the only services
132
+ * from *this* container that will run are those with a token that is also present in this PartialContainer.
133
+ * @returns No mutation is done to the Container, it is returned as-is (convenient for chaining).
134
+ */
135
+ run<Token extends string, Tokens extends readonly ValidTokens<Services>[], Service>(fn: InjectableFunction<Services, Tokens, Token, Service>): this;
136
+ /**
137
+ * Create a new Container from this Container with additional services from a given [PartialContainer].
138
+ *
139
+ * Services in the provided PartialContainer take precedence if there are service token conflicts.
140
+ *
141
+ * Services from the provided PartialContainer become scoped to the new Container – that is, if PartialContainer A
142
+ * is provided to Container X and Container Y, each resultant Container will contain its own copy of the services
143
+ * from PartialContainer A.
144
+ *
145
+ * @param container A [PartialContainer] providing additional services.
146
+ */
147
+ provides<AdditionalServices, Dependencies, FulfilledDependencies extends Dependencies>(this: Container<FulfilledDependencies>, container: PartialContainer<AdditionalServices, Dependencies>): Container<Services & AdditionalServices>;
148
+ /**
149
+ * Creates a new Container from this Container with additional services from another Container.
150
+ *
151
+ * Services in the provided PartialContainer take precedence if there are service token conflicts.
152
+ *
153
+ * Services from the provided Container become scoped to both Containers (the one from which they were provided
154
+ * and the new Container returned by this method) - that is, if Container A is provided to Container B,
155
+ * they will share the same instances of any Services provided by Container A.
156
+ * If Container B should re-create new instances of the Services from Container A,
157
+ * Container A must first be copied before providing it here.
158
+ *
159
+ * @param container A [Container] providing additional services.
160
+ */
161
+ provides<AdditionalServices>(container: Container<AdditionalServices>): Container<Services & AdditionalServices>;
162
+ /**
163
+ * Create a new Container which provides a Service created by the given [InjectableFunction].
164
+ *
165
+ * The InjectableFunction contains metadata specifying the Token by which the created Service will be known, as well
166
+ * as an ordered list of Tokens to be resolved and provided to the InjectableFunction as arguments.
167
+ *
168
+ * If any of these required dependencies are missing from the Container (or if there is a mismatch between the types
169
+ * of those dependencies and the arguments of the InjectableFunction), a compiler error will be raised.
170
+ *
171
+ * @param fn A factory function, taking dependencies as arguments, which returns the Service.
172
+ */
173
+ provides<Token extends string, Tokens extends readonly ValidTokens<Services>[], Service>(fn: InjectableFunction<Services, Tokens, Token, Service>): Container<AddService<Services, Token, Service>>;
174
+ private providesService;
175
+ }
176
+ export {};
177
+ //# sourceMappingURL=Container.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Container.d.ts","sourceRoot":"","sources":["../../src/dependency-injection/Container.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3E,KAAK,sBAAsB,CAAC,QAAQ,IAAI;KACnC,CAAC,IAAI,MAAM,QAAQ,GACd,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,QAAQ,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,GACzC,QAAQ,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,QAAQ,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC;CAC1D,CAAC;AAEF,MAAM,MAAM,SAAS,CAAC,QAAQ,IAAI;KAmB7B,CAAC,IAAI,MAAM,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC;CACtE,CAAC;AAEF,eAAO,MAAM,SAAS,eAAe,CAAC;AACtC,MAAM,MAAM,cAAc,GAAG,OAAO,SAAS,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,gBAAgB;AAChB,qBAAa,SAAS,CAAC,QAAQ,GAAG,EAAE;IAChC;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,SAAS,EAAE,gBAAgB,CAAC,QAAQ,EAAE,EAAE,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC;IAE/G;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,KAAK,SAAS,MAAM,EAAE,OAAO,EACzC,EAAE,EAAE,kBAAkB,CAAC,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,GAC/C,SAAS,CAAC,UAAU,CAAC,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IAa5C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAsB;gBAEpC,SAAS,EAAE,sBAAsB,CAAC,QAAQ,CAAC;IASvD;;;;;;;;;;;;;;;;;OAiBG;IACH,IAAI,CAAC,MAAM,SAAS,SAAS,CAAC,MAAM,QAAQ,CAAC,EAAE,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC;IAY9F;;;;;OAKG;IACH,GAAG,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI;IAEhC;;;;;OAKG;IACH,GAAG,CAAC,KAAK,SAAS,MAAM,QAAQ,EAAE,KAAK,EAAE,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;IAgBhE;;;;;;;;;;;;;OAaG;IACH,GAAG,CAAC,kBAAkB,EAAE,YAAY,EAAE,qBAAqB,SAAS,YAAY,EAG5E,IAAI,EAAE,SAAS,CAAC,qBAAqB,CAAC,EACtC,SAAS,EAAE,gBAAgB,CAAC,kBAAkB,EAAE,YAAY,CAAC,GAC9D,IAAI;IAEP;;;;;;;;;;;;;OAaG;IACH,GAAG,CAAC,KAAK,SAAS,MAAM,EAAE,MAAM,SAAS,SAAS,WAAW,CAAC,QAAQ,CAAC,EAAE,EAAE,OAAO,EAC9E,EAAE,EAAE,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,GACzD,IAAI;IAkBP;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,kBAAkB,EAAE,YAAY,EAAE,qBAAqB,SAAS,YAAY,EAGjF,IAAI,EAAE,SAAS,CAAC,qBAAqB,CAAC,EACtC,SAAS,EAAE,gBAAgB,CAAC,kBAAkB,EAAE,YAAY,CAAC,GAC9D,SAAS,CAAC,QAAQ,GAAG,kBAAkB,CAAC;IAE3C;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,kBAAkB,EAAE,SAAS,EAAE,SAAS,CAAC,kBAAkB,CAAC,GAAG,SAAS,CAAC,QAAQ,GAAG,kBAAkB,CAAC;IAEhH;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,KAAK,SAAS,MAAM,EAAE,MAAM,SAAS,SAAS,WAAW,CAAC,QAAQ,CAAC,EAAE,EAAE,OAAO,EACnF,EAAE,EAAE,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,GACzD,SAAS,CAAC,UAAU,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IAsBlD,OAAO,CAAC,eAAe;CA4B1B"}
@@ -0,0 +1,72 @@
1
+ import { isMemoized, memoize } from "../common/memoize";
2
+ import { PartialContainer } from "./PartialContainer";
3
+ export const CONTAINER = "$container";
4
+ export class Container {
5
+ static provides(fnOrContainer) {
6
+ if (fnOrContainer instanceof PartialContainer)
7
+ return new Container({}).provides(fnOrContainer);
8
+ if (fnOrContainer instanceof Container)
9
+ return new Container({}).provides(fnOrContainer);
10
+ return new Container({}).provides(fnOrContainer);
11
+ }
12
+ constructor(factories) {
13
+ this.factories = {};
14
+ for (const k in factories) {
15
+ const fn = factories[k];
16
+ if (isMemoized(fn))
17
+ this.factories[k] = fn;
18
+ else
19
+ this.factories[k] = memoize(fn);
20
+ }
21
+ }
22
+ copy(scopedServices) {
23
+ const factories = Object.assign({}, this.factories);
24
+ (scopedServices || []).forEach((token) => {
25
+ factories[token] = this.factories[token].delegate;
26
+ });
27
+ return new Container(factories);
28
+ }
29
+ get(token) {
30
+ if (token === CONTAINER)
31
+ return this;
32
+ const factory = this.factories[token];
33
+ if (!factory) {
34
+ throw new Error(`[Container::get] Could not find Service for Token "${String(token)}". This should've caused a ` +
35
+ "compile-time error. If the Token is 'undefined', check all your calls to the Injectable " +
36
+ "function. Make sure you define dependencies using string literals or string constants that are " +
37
+ "definitely initialized before the call to Injectable.");
38
+ }
39
+ return factory(this);
40
+ }
41
+ run(fnOrContainer) {
42
+ if (fnOrContainer instanceof PartialContainer) {
43
+ const runnableContainer = this.provides(fnOrContainer);
44
+ for (const token of fnOrContainer.getTokens()) {
45
+ runnableContainer.get(token);
46
+ }
47
+ }
48
+ else {
49
+ this.provides(fnOrContainer).get(fnOrContainer.token);
50
+ }
51
+ return this;
52
+ }
53
+ provides(fnOrContainer) {
54
+ if (fnOrContainer instanceof PartialContainer || fnOrContainer instanceof Container) {
55
+ const factories = fnOrContainer instanceof PartialContainer ? fnOrContainer.getFactories(this) : fnOrContainer.factories;
56
+ return new Container(Object.assign(Object.assign({}, this.factories), factories));
57
+ }
58
+ return this.providesService(fnOrContainer);
59
+ }
60
+ providesService(fn) {
61
+ const token = fn.token;
62
+ const dependencies = fn.dependencies;
63
+ const factory = memoize((container) => {
64
+ return fn(...dependencies.map((t) => {
65
+ return t === token ? this.get(t) : container.get(t);
66
+ }));
67
+ });
68
+ const factories = Object.assign(Object.assign({}, this.factories), { [token]: factory });
69
+ return new Container(factories);
70
+ }
71
+ }
72
+ //# sourceMappingURL=Container.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Container.js","sourceRoot":"","sources":["../../src/dependency-injection/Container.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AA+BtD,MAAM,CAAC,MAAM,SAAS,GAAG,YAAY,CAAC;AAqDtC,MAAM,OAAO,SAAS;IAalB,MAAM,CAAC,QAAQ,CACX,aAAmG;QAKnG,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,CAAC;QACzF,OAAO,IAAI,SAAS,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;IACrD,CAAC;IAID,YAAY,SAA2C;QACnD,IAAI,CAAC,SAAS,GAAG,EAAyB,CAAC;QAC3C,KAAK,MAAM,CAAC,IAAI,SAAS,EAAE;YACvB,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;YACxB,IAAI,UAAU,CAAC,EAAE,CAAC;gBAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;;gBACtC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,EAAE,CAAC,CAAC;SACxC;IACL,CAAC;IAoBD,IAAI,CAA6C,cAAuB;QACpE,MAAM,SAAS,qBAA0C,IAAI,CAAC,SAAS,CAAE,CAAC;QAK1E,CAAC,cAAc,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,KAAqB,EAAE,EAAE;YACrD,SAAS,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC;QACtD,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,SAAS,CAAC,SAAS,CAAC,CAAC;IACpC,CAAC;IAkBD,GAAG,CAAC,KAAsC;QACtC,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO,IAAI,CAAC;QACrC,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACtC,IAAI,CAAC,OAAO,EAAE;YACV,MAAM,IAAI,KAAK,CACX,sDAAsD,MAAM,CAAC,KAAK,CAAC,6BAA6B;gBAC5F,0FAA0F;gBAC1F,iGAAiG;gBACjG,uDAAuD,CAC9D,CAAC;SACL;QACD,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IAyCD,GAAG,CACC,aAEoD;QAEpD,IAAI,aAAa,YAAY,gBAAgB,EAAE;YAC3C,MAAM,iBAAiB,GAAG,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;YACvD,KAAK,MAAM,KAAK,IAAI,aAAa,CAAC,SAAS,EAAE,EAAE;gBAC3C,iBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;aAChC;SACJ;aAAM;YACH,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;SACzD;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAkDD,QAAQ,CACJ,aAGmC;QAEnC,IAAI,aAAa,YAAY,gBAAgB,IAAI,aAAa,YAAY,SAAS,EAAE;YACjF,MAAM,SAAS,GACX,aAAa,YAAY,gBAAgB,CAAC,CAAC,CAAC,aAAa,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,SAAS,CAAC;YAI3G,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;gBASvB,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;QAKH,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 type { Memoized } from \"../common/memoize\";\nimport { isMemoized, memoize } from \"../common/memoize\";\nimport { PartialContainer } from \"./PartialContainer\";\nimport type { 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 // We'd like the Container type constructor to be covariant -- if type A ≤ B (that is, if A is more\n // specific than B), we would like Container<A> ≤ Container<B>.\n //\n // But here in this Factories type (which is used to type the `factories` property of Container), we want to use\n // our type variable in *both* a covariant and contravariant position -- we use the keys of Services as the index\n // type (covariant), but we also want to use Container<Services> as the argument of the factory function\n // (contravariant).\n //\n // This would result the Container type (by virtue of containing the `factories` property) being *invariant* -- that\n // is, only if types A and B are each assignable to the other will Container<B> be assignable to Container<A>.\n //\n // To avoid this, we use Container<any> in the contravariant position -- that way the Services type variable is only\n // used in covariant position and our Container type constructor remains covariant.\n //\n // Safety: this does mean that calling the factory function (as is done in `Container.get()`) is not type safe.\n // But we only use this type as a private property of Container, which still type checks the constructor argument\n // used to populate the `factories` property. So there's no way we can end up with a `factories` property containing\n // functions which require Services not provided by the Container.\n [K in keyof Services]: Memoized<(c: Container<any>) => 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 properly 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"]}
@@ -0,0 +1,96 @@
1
+ import type { InjectableFunction, ServicesFromTokenizedParams } from "./types";
2
+ /**
3
+ * Create an Injectable factory function with no dependencies (i.e. the factory function has no arguments).
4
+ *
5
+ * Ex:
6
+ * ```ts
7
+ * const createMyService = Injectable(
8
+ * 'MyService',
9
+ * () => { return ... },
10
+ * )
11
+ * ```
12
+ *
13
+ * @param token A unique string Token which will correspond to the created Service.
14
+ * @param fn A function with no arguments which returns the Service.
15
+ */
16
+ export declare function Injectable<Token extends string, Service>(token: Token, fn: () => Service): InjectableFunction<any, [], Token, Service>;
17
+ /**
18
+ * Create an Injectable factory function with dependencies (i.e. the factory function has arguments).
19
+ *
20
+ * **Note:** the list of dependencies must contain only string literals or string consts.
21
+ *
22
+ * Ex:
23
+ * ```ts
24
+ * const DependencyB = 'DependencyB'
25
+ * const createMyService = Injectable(
26
+ * 'MyService',
27
+ * ['DependencyA', DependencyB] as const,
28
+ * (a: A, b: B) => { return ... },
29
+ * )
30
+ * ```
31
+ *
32
+ * @param token A unique string Token which will correspond to the created Service.
33
+ * @param dependencies A *readonly* list of Tokens corresponding to dependencies (i.e. arguments to the Factory), which
34
+ * will be resolved by the Container to which this Injectable is provided.
35
+ * @param fn A function with arguments matching in type and length to the given list of dependencies. When called, it
36
+ * must return the Service.
37
+ */
38
+ export declare function Injectable<Token extends string, Tokens extends readonly string[], Params extends readonly any[], Service>(token: Token, dependencies: Tokens, fn: (...args: Tokens["length"] extends Params["length"] ? Params : void[]) => Service): Tokens["length"] extends Params["length"] ? InjectableFunction<ServicesFromTokenizedParams<Tokens, Params>, Tokens, Token, Service> : never;
39
+ /**
40
+ * Create an Injectable factory function without dependencies (i.e. the factory function has no arguments) that appends
41
+ * a Service onto an existing array of Services of the same type.
42
+ *
43
+ * Ex:
44
+ * ```ts
45
+ * import { myServiceFactory, MyService } from './my-service'
46
+ *
47
+ * const createMyService = ConcatInjectable(
48
+ * myServiceFactory.token,
49
+ * (): MyService => { return ... },
50
+ * )
51
+ *
52
+ * // Consumers then do:
53
+ * const myConsumingServiceFactory = Injectable(
54
+ * 'myConsumingService',
55
+ * [myServiceFactory.token] as const,
56
+ * (myServices: MyService[]) => { return ... }
57
+ * )
58
+ * ```
59
+ *
60
+ * @param token A string Token identifying an existing Service that has an Array type, to which will be appended the
61
+ * Service created by this factory function.
62
+ * @param fn A function with no arguments which returns the Service.
63
+ */
64
+ export declare function ConcatInjectable<Token extends string, Service>(token: Token, fn: () => Service): InjectableFunction<{
65
+ [T in keyof Token]: Service[];
66
+ }, [], Token, Service[]>;
67
+ /**
68
+ * Create an Injectable factory function with dependencies (i.e. the factory function has arguments) that appends
69
+ * a Service onto an existing array of Services of the same type.
70
+ *
71
+ * Ex:
72
+ * ```ts
73
+ * import { myServiceFactory, MyService } from './my-service'
74
+ *
75
+ * const createMyService = ConcatInjectable(
76
+ * myServiceFactory.token,
77
+ * ['DependencyA', 'DependencyB'] as const,
78
+ * (a: A, b: B): MyService => { return ... },
79
+ * )
80
+ *
81
+ * // Consumers then do:
82
+ * const myConsumingServiceFactory = Injectable(
83
+ * 'myConsumingService',
84
+ * [myServiceFactory.token] as const,
85
+ * (myServices: MyService[]) => { return ... }
86
+ * )
87
+ * ```
88
+ *
89
+ * @param token A string Token identifying an existing Service that has an Array type, to which will be appended the
90
+ * Service created by this factory function.
91
+ * @param dependencies A *readonly* list of Tokens corresponding to dependencies (i.e. arguments to the Factory), which
92
+ * will be resolved by the Container to which this Injectable is provided.
93
+ * @param fn A function with no arguments which returns the Service.
94
+ */
95
+ export declare function ConcatInjectable<Token extends string, Tokens extends readonly string[], Params extends readonly any[], Service>(token: Token, dependencies: Tokens, fn: (...args: Tokens["length"] extends Params["length"] ? Params : void[]) => Service): InjectableFunction<ServicesFromTokenizedParams<Tokens, Params>, Tokens, Token, Service[]>;
96
+ //# sourceMappingURL=Injectable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Injectable.d.ts","sourceRoot":"","sources":["../../src/dependency-injection/Injectable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AAE/E;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CAAC,KAAK,SAAS,MAAM,EAAE,OAAO,EACpD,KAAK,EAAE,KAAK,EACZ,EAAE,EAAE,MAAM,OAAO,GAClB,kBAAkB,CAAC,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,UAAU,CACtB,KAAK,SAAS,MAAM,EACpB,MAAM,SAAS,SAAS,MAAM,EAAE,EAChC,MAAM,SAAS,SAAS,GAAG,EAAE,EAC7B,OAAO,EAEP,KAAK,EAAE,KAAK,EACZ,YAAY,EAAE,MAAM,EAIpB,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,SAAS,MAAM,CAAC,QAAQ,CAAC,GAAG,MAAM,GAAG,IAAI,EAAE,KAAK,OAAO,GACtF,MAAM,CAAC,QAAQ,CAAC,SAAS,MAAM,CAAC,QAAQ,CAAC,GACtC,kBAAkB,CAAC,2BAA2B,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,GACvF,KAAK,CAAC;AA+BZ;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,SAAS,MAAM,EAAE,OAAO,EAC1D,KAAK,EAAE,KAAK,EACZ,EAAE,EAAE,MAAM,OAAO,GAClB,kBAAkB,CAAC;KAAG,CAAC,IAAI,MAAM,KAAK,GAAG,OAAO,EAAE;CAAE,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;AAE/E;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,gBAAgB,CAC5B,KAAK,SAAS,MAAM,EACpB,MAAM,SAAS,SAAS,MAAM,EAAE,EAChC,MAAM,SAAS,SAAS,GAAG,EAAE,EAC7B,OAAO,EAEP,KAAK,EAAE,KAAK,EACZ,YAAY,EAAE,MAAM,EACpB,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,SAAS,MAAM,CAAC,QAAQ,CAAC,GAAG,MAAM,GAAG,IAAI,EAAE,KAAK,OAAO,GACtF,kBAAkB,CAAC,2BAA2B,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Injectable.js","sourceRoot":"","sources":["../../src/dependency-injection/Injectable.ts"],"names":[],"mappings":"AA0DA,MAAM,UAAU,UAAU,CACtB,KAAa,EACb,gBAAkD,EAClD,OAAiC;IAEjC,MAAM,YAAY,GAAa,KAAK,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC;IACvF,MAAM,EAAE,GAAG,OAAO,gBAAgB,KAAK,UAAU,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,OAAO,CAAC;IAE/E,IAAI,CAAC,EAAE,EAAE;QACL,MAAM,IAAI,SAAS,CACf,0FAA0F;YACtF,oBAAoB,CAC3B,CAAC;KACL;IAED,IAAI,EAAE,CAAC,MAAM,KAAK,YAAY,CAAC,MAAM,EAAE;QACnC,MAAM,IAAI,SAAS,CACf,4FAA4F;YACxF,GAAG,EAAE,CAAC,MAAM,SAAS,YAAY,CAAC,MAAM,+BAA+B;YACvE,mBAAmB,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,EAAE,CACxD,CAAC;KACL;IAED,MAAM,OAAO,GAAG,CAAC,GAAG,IAAW,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;IAChD,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC;IACtB,OAAO,CAAC,YAAY,GAAG,YAAY,CAAC;IACpC,OAAO,OAAO,CAAC;AACnB,CAAC;AAuED,MAAM,UAAU,gBAAgB,CAC5B,KAAa,EACb,gBAAkD,EAClD,OAAiC;IAEjC,MAAM,YAAY,GAAa,KAAK,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC;IACvF,MAAM,EAAE,GAAG,OAAO,gBAAgB,KAAK,UAAU,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,OAAO,CAAC;IAE/E,IAAI,CAAC,EAAE,EAAE;QACL,MAAM,IAAI,SAAS,CACf,gGAAgG;YAC5F,oBAAoB,CAC3B,CAAC;KACL;IAED,IAAI,EAAE,CAAC,MAAM,KAAK,YAAY,CAAC,MAAM,EAAE;QACnC,MAAM,IAAI,SAAS,CACf,4FAA4F;YACxF,GAAG,EAAE,CAAC,MAAM,SAAS,YAAY,CAAC,MAAM,+BAA+B;YACvE,mBAAmB,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,EAAE,CACxD,CAAC;KACL;IAED,MAAM,OAAO,GAAG,CAAC,KAAY,EAAE,GAAG,IAAW,EAAE,EAAE;QAC7C,OAAO,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IACrC,CAAC,CAAC;IACF,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC;IACtB,OAAO,CAAC,YAAY,GAAG,CAAC,KAAK,EAAE,GAAG,YAAY,CAAC,CAAC;IAChD,OAAO,OAAO,CAAC;AACnB,CAAC","sourcesContent":["import type { InjectableFunction, ServicesFromTokenizedParams } from \"./types\";\n\n/**\n * Create an Injectable factory function with no dependencies (i.e. the factory function has no arguments).\n *\n * Ex:\n * ```ts\n * const createMyService = Injectable(\n * 'MyService',\n * () => { return ... },\n * )\n * ```\n *\n * @param token A unique string Token which will correspond to the created Service.\n * @param fn A function with no arguments which returns the Service.\n */\nexport function Injectable<Token extends string, Service>(\n token: Token,\n fn: () => Service\n): InjectableFunction<any, [], Token, Service>;\n\n/**\n * Create an Injectable factory function with dependencies (i.e. the factory function has arguments).\n *\n * **Note:** the list of dependencies must contain only string literals or string consts.\n *\n * Ex:\n * ```ts\n * const DependencyB = 'DependencyB'\n * const createMyService = Injectable(\n * 'MyService',\n * ['DependencyA', DependencyB] as const,\n * (a: A, b: B) => { return ... },\n * )\n * ```\n *\n * @param token A unique string Token which will correspond to the created Service.\n * @param dependencies A *readonly* list of Tokens corresponding to dependencies (i.e. arguments to the Factory), which\n * will be resolved by the Container to which this Injectable is provided.\n * @param fn A function with arguments matching in type and length to the given list of dependencies. When called, it\n * must return the Service.\n */\nexport function Injectable<\n Token extends string,\n Tokens extends readonly string[],\n Params extends readonly any[],\n Service\n>(\n token: Token,\n dependencies: Tokens,\n // The function arity (number of arguments) must match the number of dependencies specified – if they don't, we'll\n // force a compiler error by saying the arguments should be `void[]`. We'll also throw at runtime, so the return\n // type will be `never`.\n fn: (...args: Tokens[\"length\"] extends Params[\"length\"] ? Params : void[]) => Service\n): Tokens[\"length\"] extends Params[\"length\"]\n ? InjectableFunction<ServicesFromTokenizedParams<Tokens, Params>, Tokens, Token, Service>\n : never;\n\nexport function Injectable(\n token: string,\n dependenciesOrFn?: readonly string[] | (() => any),\n maybeFn?: (...args: any[]) => any\n): InjectableFunction<any, readonly string[], string, any> {\n const dependencies: string[] = Array.isArray(dependenciesOrFn) ? dependenciesOrFn : [];\n const fn = typeof dependenciesOrFn === \"function\" ? dependenciesOrFn : maybeFn;\n\n if (!fn) {\n throw new TypeError(\n \"[Injectable] Received invalid arguments. The factory function must be either the second \" +\n \"or third argument.\"\n );\n }\n\n if (fn.length !== dependencies.length) {\n throw new TypeError(\n \"[Injectable] Function arity does not match the number of dependencies. Function has arity \" +\n `${fn.length}, but ${dependencies.length} dependencies were specified.` +\n `\\nDependencies: ${JSON.stringify(dependencies)}`\n );\n }\n\n const factory = (...args: any[]) => fn(...args);\n factory.token = token;\n factory.dependencies = dependencies;\n return factory;\n}\n\n/**\n * Create an Injectable factory function without dependencies (i.e. the factory function has no arguments) that appends\n * a Service onto an existing array of Services of the same type.\n *\n * Ex:\n * ```ts\n * import { myServiceFactory, MyService } from './my-service'\n *\n * const createMyService = ConcatInjectable(\n * myServiceFactory.token,\n * (): MyService => { return ... },\n * )\n *\n * // Consumers then do:\n * const myConsumingServiceFactory = Injectable(\n * 'myConsumingService',\n * [myServiceFactory.token] as const,\n * (myServices: MyService[]) => { return ... }\n * )\n * ```\n *\n * @param token A string Token identifying an existing Service that has an Array type, to which will be appended the\n * Service created by this factory function.\n * @param fn A function with no arguments which returns the Service.\n */\nexport function ConcatInjectable<Token extends string, Service>(\n token: Token,\n fn: () => Service\n): InjectableFunction<{ [T in keyof Token]: Service[] }, [], Token, Service[]>;\n\n/**\n * Create an Injectable factory function with dependencies (i.e. the factory function has arguments) that appends\n * a Service onto an existing array of Services of the same type.\n *\n * Ex:\n * ```ts\n * import { myServiceFactory, MyService } from './my-service'\n *\n * const createMyService = ConcatInjectable(\n * myServiceFactory.token,\n * ['DependencyA', 'DependencyB'] as const,\n * (a: A, b: B): MyService => { return ... },\n * )\n *\n * // Consumers then do:\n * const myConsumingServiceFactory = Injectable(\n * 'myConsumingService',\n * [myServiceFactory.token] as const,\n * (myServices: MyService[]) => { return ... }\n * )\n * ```\n *\n * @param token A string Token identifying an existing Service that has an Array type, to which will be appended the\n * Service created by this factory function.\n * @param dependencies A *readonly* list of Tokens corresponding to dependencies (i.e. arguments to the Factory), which\n * will be resolved by the Container to which this Injectable is provided.\n * @param fn A function with no arguments which returns the Service.\n */\nexport function ConcatInjectable<\n Token extends string,\n Tokens extends readonly string[],\n Params extends readonly any[],\n Service\n>(\n token: Token,\n dependencies: Tokens,\n fn: (...args: Tokens[\"length\"] extends Params[\"length\"] ? Params : void[]) => Service\n): InjectableFunction<ServicesFromTokenizedParams<Tokens, Params>, Tokens, Token, Service[]>;\n\nexport function ConcatInjectable(\n token: string,\n dependenciesOrFn?: readonly string[] | (() => any),\n maybeFn?: (...args: any[]) => any\n): InjectableFunction<any, readonly string[], string, any[]> {\n const dependencies: string[] = Array.isArray(dependenciesOrFn) ? dependenciesOrFn : [];\n const fn = typeof dependenciesOrFn === \"function\" ? dependenciesOrFn : maybeFn;\n\n if (!fn) {\n throw new TypeError(\n \"[ConcatInjectable] Received invalid arguments. The factory function must be either the second \" +\n \"or third argument.\"\n );\n }\n\n if (fn.length !== dependencies.length) {\n throw new TypeError(\n \"[Injectable] Function arity does not match the number of dependencies. Function has arity \" +\n `${fn.length}, but ${dependencies.length} dependencies were specified.` +\n `\\nDependencies: ${JSON.stringify(dependencies)}`\n );\n }\n\n const factory = (array: any[], ...args: any[]) => {\n return array.concat(fn(...args));\n };\n factory.token = token;\n factory.dependencies = [token, ...dependencies];\n return factory;\n}\n"]}
@@ -0,0 +1,86 @@
1
+ import type { Memoized } from "../common/memoize";
2
+ import type { Container } from "./Container";
3
+ import type { AddService, InjectableFunction, ServicesFromTokenizedParams, ValidTokens } from "./types";
4
+ type AddDependencies<ParentDependencies, Dependencies> = ParentDependencies extends any ? {
5
+ [K in keyof ParentDependencies | keyof Dependencies]: K extends keyof ParentDependencies ? ParentDependencies[K] : K extends keyof Dependencies ? Dependencies[K] : never;
6
+ } : never;
7
+ type ExcludeKey<T, U> = T extends any ? {
8
+ [K in Exclude<keyof T, U>]: T[K];
9
+ } : never;
10
+ type PartialInjectableFunction<Params extends readonly any[], Tokens extends readonly string[], Token extends string, Service> = {
11
+ (...args: Params): Service;
12
+ token: Token;
13
+ dependencies: Tokens;
14
+ };
15
+ type Injectables<Services, Dependencies> = {
16
+ [K in keyof Services]: K extends string ? InjectableFunction<Services & Dependencies, readonly ValidTokens<Services & Dependencies>[], K, Services[K]> : never;
17
+ };
18
+ type PartialContainerFactories<Services, Dependecies> = {
19
+ [K in keyof Services]: Memoized<(c: Container<Partial<Services> & Dependecies>) => Services[K]>;
20
+ };
21
+ /**
22
+ * Similar to [Container], with the exception that Services may be provided to a PartialContainer which *does not*
23
+ * contain all of that Services dependencies.
24
+ *
25
+ * For this to remain safe, Services can not be resolved by PartialContainer – it has no `get` method.
26
+ *
27
+ * Instead, the PartialContainer must be provided to a [Container] which *does* contain all the dependencies required
28
+ * by all the Service in the PartialContainer. The resulting [Container] can then resolve these Services.
29
+ *
30
+ * PartialContainers are used to create a collection of Services which can then be provided via a simple one-line syntax
31
+ * to an existing Container (which fulfills the collection's dependencies). It is an organizational tool, allowing
32
+ * coherent groupings of Services to be defined in one place, then combined elsewhere to form a complete [Container].
33
+ *
34
+ * Here's an example of PartialContainer usage:
35
+ * ```ts
36
+ * // We can provide fooFactory, even though the PartialContainer doesn't fulfill the Bar dependency.
37
+ * const fooFactory = Injectable('Foo', ['Bar'] as const, (bar: Bar) => new Foo(bar))
38
+ * const partialContainer = new PartialContainer({}).provide(fooFactory)
39
+ *
40
+ * const barFactory = Injectable('Bar', () => new Bar())
41
+ * const dependenciesContainer = Container.provides(barFactory)
42
+ *
43
+ * const combinedContainer = dependenciesContainer.provides(partialContainer)
44
+ *
45
+ * // We can resolve Foo, because the combined container includes Bar, so all of Foo's dependencies are now met.
46
+ * const foo = combinedContainer.get('Foo')
47
+ * ```
48
+ */
49
+ /** @internal */
50
+ export declare class PartialContainer<Services = {}, Dependencies = {}> {
51
+ private readonly injectables;
52
+ constructor(injectables: Injectables<Services, Dependencies>);
53
+ /**
54
+ * Create a new PartialContainer which provides a Service created by the given InjectableFunction.
55
+ *
56
+ * The InjectableFunction contains metadata specifying the Token by which the created Service will be known, as well
57
+ * as an ordered list of Tokens to be resolved and provided to the InjectableFunction as arguments.
58
+ *
59
+ * This dependencies are allowed to be missing from the PartialContainer, but these dependencies are maintained as a
60
+ * parameter of the returned PartialContainer. This allows `[Container.provides]` to type check the dependencies and
61
+ * ensure they can be provided by the Container.
62
+ *
63
+ * @param fn A InjectableFunction, taking dependencies as arguments, which returns the Service.
64
+ */
65
+ provides<AdditionalDependencies extends readonly any[], Tokens extends readonly string[], Token extends string, Service>(fn: PartialInjectableFunction<AdditionalDependencies, Tokens, Token, Service>): PartialContainer<AddService<Services, Token, Service>, ExcludeKey<AddDependencies<ExcludeKey<Dependencies, Token>, ServicesFromTokenizedParams<Tokens, AdditionalDependencies>>, keyof Services>>;
66
+ /**
67
+ * In order to create a [Container], the InjectableFunctions maintained by the PartialContainer must be memoized
68
+ * into Factories that can resolve their dependencies and return the correct Service.
69
+ *
70
+ * In particular, this requires access to a "parent" Container to avoid infinite looping in cases where Service A
71
+ * depends on Service A – this is allowed (as long as the parent container provides Service A), but requires access
72
+ * to the parent Container to provide the parent implementation of Service A.
73
+ *
74
+ * This also means that Services provided by a PartialContainer to a Container via this function will always be
75
+ * scoped to the Container. In other words, if a PartialContainer containing Service A is provided to both
76
+ * Container X and Container Y, when Service A is resolved by Container X the InjectableFunction used to create
77
+ * Service A will be invoked – and when Service A is resolved by Container Y, the InjectableFunction will be invoked
78
+ * again.
79
+ *
80
+ * @param parent A [Container] which provides all the required Dependencies of this PartialContainer.
81
+ */
82
+ getFactories(parent: Container<Dependencies>): PartialContainerFactories<Services, Dependencies>;
83
+ getTokens(): Array<keyof Services>;
84
+ }
85
+ export {};
86
+ //# sourceMappingURL=PartialContainer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PartialContainer.d.ts","sourceRoot":"","sources":["../../src/dependency-injection/PartialContainer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAIxG,KAAK,eAAe,CAAC,kBAAkB,EAAE,YAAY,IAAI,kBAAkB,SAAS,GAAG,GAEjF;KACK,CAAC,IAAI,MAAM,kBAAkB,GAAG,MAAM,YAAY,GAAG,CAAC,SAAS,MAAM,kBAAkB,GAClF,kBAAkB,CAAC,CAAC,CAAC,GACrB,CAAC,SAAS,MAAM,YAAY,GAC5B,YAAY,CAAC,CAAC,CAAC,GACf,KAAK;CACd,GACD,KAAK,CAAC;AAEZ,KAAK,UAAU,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,GAAG,GAAG;KAAG,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,GAAG,KAAK,CAAC;AAErF,KAAK,yBAAyB,CAC1B,MAAM,SAAS,SAAS,GAAG,EAAE,EAC7B,MAAM,SAAS,SAAS,MAAM,EAAE,EAChC,KAAK,SAAS,MAAM,EACpB,OAAO,IACP;IACA,CAAC,GAAG,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAC3B,KAAK,EAAE,KAAK,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,KAAK,WAAW,CAAC,QAAQ,EAAE,YAAY,IAAI;KACtC,CAAC,IAAI,MAAM,QAAQ,GAAG,CAAC,SAAS,MAAM,GACjC,kBAAkB,CAAC,QAAQ,GAAG,YAAY,EAAE,SAAS,WAAW,CAAC,QAAQ,GAAG,YAAY,CAAC,EAAE,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,GAC5G,KAAK;CACd,CAAC;AAEF,KAAK,yBAAyB,CAAC,QAAQ,EAAE,WAAW,IAAI;KACnD,CAAC,IAAI,MAAM,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,WAAW,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC;CAClG,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,gBAAgB;AAChB,qBAAa,gBAAgB,CAAC,QAAQ,GAAG,EAAE,EAAE,YAAY,GAAG,EAAE;IAC9C,OAAO,CAAC,QAAQ,CAAC,WAAW;gBAAX,WAAW,EAAE,WAAW,CAAC,QAAQ,EAAE,YAAY,CAAC;IAE7E;;;;;;;;;;;OAWG;IACH,QAAQ,CACJ,sBAAsB,SAAS,SAAS,GAAG,EAAE,EAC7C,MAAM,SAAS,SAAS,MAAM,EAAE,EAChC,KAAK,SAAS,MAAM,EACpB,OAAO,EAEP,EAAE,EAAE,yBAAyB,CAAC,sBAAsB,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,GAC9E,gBAAgB,CACf,UAAU,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,EAIpC,UAAU,CACN,eAAe,CACX,UAAU,CAAC,YAAY,EAAE,KAAK,CAAC,EAC/B,2BAA2B,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAC9D,EACD,MAAM,QAAQ,CACjB,CACJ;IAID;;;;;;;;;;;;;;;OAeG;IACH,YAAY,CAAC,MAAM,EAAE,SAAS,CAAC,YAAY,CAAC,GAAG,yBAAyB,CAAC,QAAQ,EAAE,YAAY,CAAC;IAmBhG,SAAS,IAAI,KAAK,CAAC,MAAM,QAAQ,CAAC;CAGrC"}
@@ -0,0 +1,28 @@
1
+ import { entries } from "../common/entries";
2
+ import { memoize } from "../common/memoize";
3
+ export class PartialContainer {
4
+ constructor(injectables) {
5
+ this.injectables = injectables;
6
+ }
7
+ provides(fn) {
8
+ return new PartialContainer(Object.assign(Object.assign({}, this.injectables), { [fn.token]: fn }));
9
+ }
10
+ getFactories(parent) {
11
+ return Object.fromEntries(entries(this.injectables).map(([token, fn]) => {
12
+ return [
13
+ token,
14
+ memoize((c) => {
15
+ return fn(...fn.dependencies.map((t) => {
16
+ return t === token
17
+ ? parent.get(t)
18
+ : c.get(t);
19
+ }));
20
+ }),
21
+ ];
22
+ }));
23
+ }
24
+ getTokens() {
25
+ return Object.keys(this.injectables);
26
+ }
27
+ }
28
+ //# sourceMappingURL=PartialContainer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PartialContainer.js","sourceRoot":"","sources":["../../src/dependency-injection/PartialContainer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAqE5C,MAAM,OAAO,gBAAgB;IACzB,YAA6B,WAAgD;QAAhD,gBAAW,GAAX,WAAW,CAAqC;IAAG,CAAC;IAcjF,QAAQ,CAMJ,EAA6E;QAc7E,OAAO,IAAI,gBAAgB,CAAC,gCAAK,IAAI,CAAC,WAAW,KAAE,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,EAAE,GAAS,CAAC,CAAC;IAChF,CAAC;IAkBD,YAAY,CAAC,MAA+B;QACxC,OAAO,MAAM,CAAC,WAAW,CACrB,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,EAAE;YAC1C,OAAO;gBACH,KAAK;gBACL,OAAO,CAAC,CAAC,CAAqC,EAAE,EAAE;oBAC9C,OAAO,EAAE,CACL,GAAI,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;wBAC1B,OAAO,CAAC,KAAK,KAAK;4BACd,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAuB,CAAC;4BACrC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAkC,CAAC,CAAC;oBACpD,CAAC,CAAS,CACb,CAAC;gBACN,CAAC,CAAC;aACL,CAAC;QACN,CAAC,CAAC,CACgD,CAAC;IAC3D,CAAC;IAED,SAAS;QACL,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAA0B,CAAC;IAClE,CAAC;CACJ","sourcesContent":["import { entries } from \"../common/entries\";\nimport type { Memoized } from \"../common/memoize\";\nimport { memoize } from \"../common/memoize\";\nimport type { Container } from \"./Container\";\nimport type { AddService, InjectableFunction, ServicesFromTokenizedParams, ValidTokens } from \"./types\";\n\n// Using a conditional type forces TS language services to evaluate the type -- so when showing e.g. type hints, we\n// will see the mapped type instead of the AddDependencies type alias. This produces better hints.\ntype AddDependencies<ParentDependencies, Dependencies> = ParentDependencies extends any\n ? // A mapped type produces better, more concise type hints than an intersection type.\n {\n [K in keyof ParentDependencies | keyof Dependencies]: K extends keyof ParentDependencies\n ? ParentDependencies[K]\n : K extends keyof Dependencies\n ? Dependencies[K]\n : never;\n }\n : never;\n\ntype ExcludeKey<T, U> = T extends any ? { [K in Exclude<keyof T, U>]: T[K] } : never;\n\ntype PartialInjectableFunction<\n Params extends readonly any[],\n Tokens extends readonly string[],\n Token extends string,\n Service\n> = {\n (...args: Params): Service;\n token: Token;\n dependencies: Tokens;\n};\n\ntype Injectables<Services, Dependencies> = {\n [K in keyof Services]: K extends string\n ? InjectableFunction<Services & Dependencies, readonly ValidTokens<Services & Dependencies>[], K, Services[K]>\n : never;\n};\n\ntype PartialContainerFactories<Services, Dependecies> = {\n [K in keyof Services]: Memoized<(c: Container<Partial<Services> & Dependecies>) => Services[K]>;\n};\n\n/**\n * Similar to [Container], with the exception that Services may be provided to a PartialContainer which *does not*\n * contain all of that Services dependencies.\n *\n * For this to remain safe, Services can not be resolved by PartialContainer – it has no `get` method.\n *\n * Instead, the PartialContainer must be provided to a [Container] which *does* contain all the dependencies required\n * by all the Service in the PartialContainer. The resulting [Container] can then resolve these Services.\n *\n * PartialContainers are used to create a collection of Services which can then be provided via a simple one-line syntax\n * to an existing Container (which fulfills the collection's dependencies). It is an organizational tool, allowing\n * coherent groupings of Services to be defined in one place, then combined elsewhere to form a complete [Container].\n *\n * Here's an example of PartialContainer usage:\n * ```ts\n * // We can provide fooFactory, even though the PartialContainer doesn't fulfill the Bar dependency.\n * const fooFactory = Injectable('Foo', ['Bar'] as const, (bar: Bar) => new Foo(bar))\n * const partialContainer = new PartialContainer({}).provide(fooFactory)\n *\n * const barFactory = Injectable('Bar', () => new Bar())\n * const dependenciesContainer = Container.provides(barFactory)\n *\n * const combinedContainer = dependenciesContainer.provides(partialContainer)\n *\n * // We can resolve Foo, because the combined container includes Bar, so all of Foo's dependencies are now met.\n * const foo = combinedContainer.get('Foo')\n * ```\n */\n/** @internal */\nexport class PartialContainer<Services = {}, Dependencies = {}> {\n constructor(private readonly injectables: Injectables<Services, Dependencies>) {}\n\n /**\n * Create a new PartialContainer 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 * This dependencies are allowed to be missing from the PartialContainer, but these dependencies are maintained as a\n * parameter of the returned PartialContainer. This allows `[Container.provides]` to type check the dependencies and\n * ensure they can be provided by the Container.\n *\n * @param fn A InjectableFunction, taking dependencies as arguments, which returns the Service.\n */\n provides<\n AdditionalDependencies extends readonly any[],\n Tokens extends readonly string[],\n Token extends string,\n Service\n >(\n fn: PartialInjectableFunction<AdditionalDependencies, Tokens, Token, Service>\n ): PartialContainer<\n AddService<Services, Token, Service>,\n // The dependencies of the new PartialContainer are the combined dependencies of this container and the\n // PartialInjectableFunction -- but we exclude any dependencies already provided by this container (i.e. this\n // container's Services) as well as the new Service being provided.\n ExcludeKey<\n AddDependencies<\n ExcludeKey<Dependencies, Token>,\n ServicesFromTokenizedParams<Tokens, AdditionalDependencies>\n >,\n keyof Services\n >\n > {\n return new PartialContainer({ ...this.injectables, [fn.token]: fn } as any);\n }\n\n /**\n * In order to create a [Container], the InjectableFunctions maintained by the PartialContainer must be memoized\n * into Factories that can resolve their dependencies and return the correct Service.\n *\n * In particular, this requires access to a \"parent\" Container to avoid infinite looping in cases where Service A\n * depends on Service A – this is allowed (as long as the parent container provides Service A), but requires access\n * to the parent Container to provide the parent implementation of Service A.\n *\n * This also means that Services provided by a PartialContainer to a Container via this function will always be\n * scoped to the Container. In other words, if a PartialContainer containing Service A is provided to both\n * Container X and Container Y, when Service A is resolved by Container X the InjectableFunction used to create\n * Service A will be invoked – and when Service A is resolved by Container Y, the InjectableFunction will be invoked\n * again.\n *\n * @param parent A [Container] which provides all the required Dependencies of this PartialContainer.\n */\n getFactories(parent: Container<Dependencies>): PartialContainerFactories<Services, Dependencies> {\n return Object.fromEntries(\n entries(this.injectables).map(([token, fn]) => {\n return [\n token,\n memoize((c: Container<Services & Dependencies>) => {\n return fn(\n ...(fn.dependencies.map((t) => {\n return t === token\n ? parent.get(t as keyof Dependencies)\n : c.get(t as keyof Services & Dependencies);\n }) as any)\n );\n }),\n ];\n })\n ) as PartialContainerFactories<Services, Dependencies>;\n }\n\n getTokens(): Array<keyof Services> {\n return Object.keys(this.injectables) as Array<keyof Services>;\n }\n}\n"]}