@snap/camera-kit 0.9.1 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (305) hide show
  1. package/README.md +18 -15
  2. package/docs/html/assets/search.js +1 -1
  3. package/docs/html/classes/CameraKit.html +116 -98
  4. package/docs/html/classes/CameraKitSession.html +175 -152
  5. package/docs/html/classes/CameraKitSource.html +109 -99
  6. package/docs/html/classes/LensPerformanceMeasurement.html +98 -92
  7. package/docs/html/classes/LensPerformanceMetrics.html +83 -79
  8. package/docs/html/classes/LensRepository.html +120 -107
  9. package/docs/html/classes/LensSources.html +86 -80
  10. package/docs/html/classes/Transform2D.html +98 -92
  11. package/docs/html/classes/TypedCustomEvent.html +83 -80
  12. package/docs/html/classes/TypedEventTarget.html +92 -89
  13. package/docs/html/functions/Injectable.html +87 -78
  14. package/docs/html/functions/bootstrapCameraKit.html +89 -84
  15. package/docs/html/functions/createExtension.html +76 -73
  16. package/docs/html/functions/createImageSource.html +80 -75
  17. package/docs/html/functions/createMediaStreamSource.html +81 -76
  18. package/docs/html/functions/createUserMediaSource.html +84 -75
  19. package/docs/html/functions/createVideoSource.html +80 -75
  20. package/docs/html/functions/estimateLensPerformance.html +76 -73
  21. package/docs/html/functions/getRequiredBootstrapURLs.html +78 -74
  22. package/docs/html/functions/lensSourcesFactory.html +74 -72
  23. package/docs/html/functions/uriHandlersFactory.html +76 -73
  24. package/docs/html/index.html +80 -78
  25. package/docs/html/interfaces/CameraKitBootstrapConfiguration.html +107 -98
  26. package/docs/html/interfaces/CameraKitSourceSubscriber.html +82 -79
  27. package/docs/html/interfaces/ComputedFrameMetrics.html +94 -82
  28. package/docs/html/interfaces/CreateSessionOptions.html +86 -81
  29. package/docs/html/interfaces/EstimatedLensPerformance.html +85 -82
  30. package/docs/html/interfaces/Lens.html +120 -102
  31. package/docs/html/interfaces/LensSource.html +102 -92
  32. package/docs/html/interfaces/MediaStreamSourceOptions.html +80 -78
  33. package/docs/html/interfaces/Preview.html +135 -0
  34. package/docs/html/interfaces/Snapcode.html +143 -0
  35. package/docs/html/interfaces/UriCancelRequest.html +80 -78
  36. package/docs/html/interfaces/UriHandler.html +102 -91
  37. package/docs/html/interfaces/UriRequest.html +89 -87
  38. package/docs/html/interfaces/UriResponse.html +89 -87
  39. package/docs/html/interfaces/VideoSourceOptions.html +77 -75
  40. package/docs/html/modules.html +153 -149
  41. package/docs/html/types/AssetLoader.html +75 -72
  42. package/docs/html/types/AssetTiming.html +75 -72
  43. package/docs/html/types/BenchmarkError.html +73 -71
  44. package/docs/html/types/BootstrapError.html +75 -72
  45. package/docs/html/types/CacheKeyNotFoundError.html +73 -71
  46. package/docs/html/types/CameraKitDeviceInfo.html +75 -72
  47. package/docs/html/types/CameraKitSessionEventListener.html +75 -72
  48. package/docs/html/types/CameraKitSessionEvents.html +82 -72
  49. package/docs/html/types/CameraKitSourceError.html +73 -71
  50. package/docs/html/types/CameraKitSourceInfo.html +73 -71
  51. package/docs/html/types/CameraKitSourceOptions.html +75 -72
  52. package/docs/html/types/ConfigurationError.html +75 -72
  53. package/docs/html/types/Keyboard.html +85 -78
  54. package/docs/html/types/KeyboardEvents.html +84 -72
  55. package/docs/html/types/LegalError.html +73 -71
  56. package/docs/html/types/LensAssetError.html +75 -72
  57. package/docs/html/types/LensContentValidationError.html +73 -71
  58. package/docs/html/types/LensError.html +73 -71
  59. package/docs/html/types/LensExecutionError.html +75 -72
  60. package/docs/html/types/LensImagePickerError.html +75 -72
  61. package/docs/html/types/LensLaunchParams.html +75 -72
  62. package/docs/html/types/LensMetricsEvents.html +75 -72
  63. package/docs/html/types/LensPerformanceCluster.html +75 -72
  64. package/docs/html/types/LensView.html +75 -72
  65. package/docs/html/types/LensWait.html +75 -72
  66. package/docs/html/types/PersistentStoreError.html +75 -72
  67. package/docs/html/types/PlatformNotSupportedError.html +75 -72
  68. package/docs/html/types/PublicContainer.html +75 -72
  69. package/docs/html/types/RenderTarget.html +75 -72
  70. package/docs/html/types/Uri.html +73 -71
  71. package/docs/html/types/UriHandlers.html +75 -72
  72. package/docs/html/types/WebGLError.html +73 -71
  73. package/docs/html/variables/extensionRequestContext.html +75 -72
  74. package/docs/md/README.md +18 -15
  75. package/docs/md/classes/CameraKit.md +14 -1
  76. package/docs/md/classes/CameraKitSession.md +1 -2
  77. package/docs/md/classes/CameraKitSource.md +1 -1
  78. package/docs/md/classes/LensPerformanceMeasurement.md +1 -1
  79. package/docs/md/classes/LensPerformanceMetrics.md +1 -1
  80. package/docs/md/classes/LensRepository.md +1 -1
  81. package/docs/md/classes/LensSources.md +1 -1
  82. package/docs/md/classes/Transform2D.md +1 -1
  83. package/docs/md/classes/TypedCustomEvent.md +1 -1
  84. package/docs/md/classes/TypedEventTarget.md +1 -1
  85. package/docs/md/interfaces/CameraKitBootstrapConfiguration.md +1 -1
  86. package/docs/md/interfaces/CameraKitSourceSubscriber.md +1 -1
  87. package/docs/md/interfaces/ComputedFrameMetrics.md +15 -1
  88. package/docs/md/interfaces/CreateSessionOptions.md +1 -1
  89. package/docs/md/interfaces/EstimatedLensPerformance.md +1 -1
  90. package/docs/md/interfaces/Lens.md +14 -3
  91. package/docs/md/interfaces/LensSource.md +1 -1
  92. package/docs/md/interfaces/MediaStreamSourceOptions.md +1 -1
  93. package/docs/md/interfaces/Preview.md +19 -0
  94. package/docs/md/interfaces/Snapcode.md +28 -0
  95. package/docs/md/interfaces/UriCancelRequest.md +1 -1
  96. package/docs/md/interfaces/UriHandler.md +1 -1
  97. package/docs/md/interfaces/UriRequest.md +1 -1
  98. package/docs/md/interfaces/UriResponse.md +1 -1
  99. package/docs/md/interfaces/VideoSourceOptions.md +1 -1
  100. package/docs/md/modules.md +11 -3
  101. package/lib/CameraKit.d.ts +29 -16
  102. package/lib/CameraKit.js +34 -5
  103. package/lib/CameraKit.js.map +1 -1
  104. package/lib/__tests__/data.js +9 -1
  105. package/lib/__tests__/data.js.map +1 -1
  106. package/lib/assertPlatformSupported.js +1 -1
  107. package/lib/assertPlatformSupported.js.map +1 -1
  108. package/lib/benchmark/webglUtils.js +2 -2
  109. package/lib/benchmark/webglUtils.js.map +1 -1
  110. package/lib/bootstrapCameraKit.js +9 -5
  111. package/lib/bootstrapCameraKit.js.map +1 -1
  112. package/lib/common/__mocks__/loadScript.d.ts +1 -1
  113. package/lib/common/__mocks__/loadScript.js +1 -1
  114. package/lib/common/__mocks__/loadScript.js.map +1 -1
  115. package/lib/common/dialog.d.ts +16 -0
  116. package/lib/common/dialog.js +146 -0
  117. package/lib/common/dialog.js.map +1 -0
  118. package/lib/common/hash.d.ts +5 -0
  119. package/lib/common/hash.js +17 -0
  120. package/lib/common/hash.js.map +1 -0
  121. package/lib/common/loadScript.d.ts +6 -1
  122. package/lib/common/loadScript.js +9 -2
  123. package/lib/common/loadScript.js.map +1 -1
  124. package/lib/common/localization.d.ts +17 -10
  125. package/lib/common/localization.js +653 -18
  126. package/lib/common/localization.js.map +1 -1
  127. package/lib/common/pageVisibility.d.ts +34 -20
  128. package/lib/common/pageVisibility.js +57 -48
  129. package/lib/common/pageVisibility.js.map +1 -1
  130. package/lib/common/validate.js +2 -2
  131. package/lib/common/validate.js.map +1 -1
  132. package/lib/dependency-injection/Container.d.ts +2 -2
  133. package/lib/dependency-injection/Container.js +10 -10
  134. package/lib/dependency-injection/Container.js.map +1 -1
  135. package/lib/dependency-injection/RootServices.d.ts +5 -1
  136. package/lib/dependency-injection/RootServices.js.map +1 -1
  137. package/lib/environment.json +1 -1
  138. package/lib/events/scan.js +1 -1
  139. package/lib/events/scan.js.map +1 -1
  140. package/lib/extensions/LensSources.d.ts +5 -5
  141. package/lib/extensions/LensSources.js +9 -9
  142. package/lib/extensions/LensSources.js.map +1 -1
  143. package/lib/extensions/UriHandlers.d.ts +1 -1
  144. package/lib/generated-proto/pb_schema/camera_kit/v3/business_events.d.ts +17 -0
  145. package/lib/generated-proto/pb_schema/camera_kit/v3/business_events.js +63 -1
  146. package/lib/generated-proto/pb_schema/camera_kit/v3/business_events.js.map +1 -1
  147. package/lib/generated-proto/pb_schema/camera_kit/v3/export.d.ts +38 -1
  148. package/lib/generated-proto/pb_schema/camera_kit/v3/legal_prompt.d.ts +5 -0
  149. package/lib/generated-proto/pb_schema/camera_kit/v3/legal_prompt.js +61 -0
  150. package/lib/generated-proto/pb_schema/camera_kit/v3/legal_prompt.js.map +1 -1
  151. package/lib/generated-proto/pb_schema/camera_kit/v3/lens.d.ts +64 -3
  152. package/lib/generated-proto/pb_schema/camera_kit/v3/lens.js +70 -2
  153. package/lib/generated-proto/pb_schema/camera_kit/v3/lens.js.map +1 -1
  154. package/lib/generated-proto/pb_schema/camera_kit/v3/service.d.ts +506 -3
  155. package/lib/generated-proto/pb_schema/camera_kit/v3/service.js +125 -3
  156. package/lib/generated-proto/pb_schema/camera_kit/v3/service.js.map +1 -1
  157. package/lib/generated-proto/pb_schema/cdp/cof/circumstance_service.d.ts +1917 -1852
  158. package/lib/generated-proto/pb_schema/cdp/cof/circumstance_service.js +55 -132
  159. package/lib/generated-proto/pb_schema/cdp/cof/circumstance_service.js.map +1 -1
  160. package/lib/generated-proto/pb_schema/cdp/cof/config_request.d.ts +8 -1
  161. package/lib/generated-proto/pb_schema/cdp/cof/config_request.js.map +1 -1
  162. package/lib/generated-proto/pb_schema/cdp/cof/config_response.d.ts +265 -0
  163. package/lib/generated-proto/pb_schema/cdp/cof/config_result.d.ts +628 -1
  164. package/lib/generated-proto/pb_schema/cdp/cof/config_result.js +140 -2
  165. package/lib/generated-proto/pb_schema/cdp/cof/config_result.js.map +1 -1
  166. package/lib/generated-proto/pb_schema/common/ruid.d.ts +2 -0
  167. package/lib/generated-proto/pb_schema/common/ruid.js +2 -0
  168. package/lib/generated-proto/pb_schema/common/ruid.js.map +1 -1
  169. package/lib/generated-proto/pb_schema/common/value.d.ts +22 -0
  170. package/lib/generated-proto/pb_schema/common/value.js +45 -0
  171. package/lib/generated-proto/pb_schema/common/value.js.map +1 -1
  172. package/lib/generated-proto/pb_schema/lenses/launchdata.d.ts +2 -0
  173. package/lib/generated-proto/pb_schema/lenses/launchdata.js +12 -0
  174. package/lib/generated-proto/pb_schema/lenses/launchdata.js.map +1 -1
  175. package/lib/handlers/HandlerChainBuilder.js +7 -2
  176. package/lib/handlers/HandlerChainBuilder.js.map +1 -1
  177. package/lib/handlers/batchingHandler.d.ts +8 -2
  178. package/lib/handlers/batchingHandler.js +5 -8
  179. package/lib/handlers/batchingHandler.js.map +1 -1
  180. package/lib/handlers/mappingHandler.d.ts +5 -1
  181. package/lib/handlers/mappingHandler.js +6 -4
  182. package/lib/handlers/mappingHandler.js.map +1 -1
  183. package/lib/handlers/rateLimitingHandler.d.ts +5 -1
  184. package/lib/handlers/rateLimitingHandler.js +6 -4
  185. package/lib/handlers/rateLimitingHandler.js.map +1 -1
  186. package/lib/handlers/requestStateEmittingHandler.d.ts +18 -5
  187. package/lib/handlers/requestStateEmittingHandler.js +12 -8
  188. package/lib/handlers/requestStateEmittingHandler.js.map +1 -1
  189. package/lib/handlers/responseCachingHandler.d.ts +1 -1
  190. package/lib/handlers/responseCachingHandler.js +1 -1
  191. package/lib/handlers/responseCachingHandler.js.map +1 -1
  192. package/lib/handlers/retryingHandler.d.ts +5 -1
  193. package/lib/handlers/retryingHandler.js +13 -9
  194. package/lib/handlers/retryingHandler.js.map +1 -1
  195. package/lib/index.d.ts +1 -1
  196. package/lib/index.js.map +1 -1
  197. package/lib/legal/legalPrompt.d.ts +7 -4
  198. package/lib/legal/legalPrompt.js +122 -133
  199. package/lib/legal/legalPrompt.js.map +1 -1
  200. package/lib/legal/legalState.d.ts +2 -2
  201. package/lib/legal/legalState.js +52 -38
  202. package/lib/legal/legalState.js.map +1 -1
  203. package/lib/lens/Lens.d.ts +32 -3
  204. package/lib/lens/Lens.js +10 -3
  205. package/lib/lens/Lens.js.map +1 -1
  206. package/lib/lens/LensLaunchParams.js +6 -4
  207. package/lib/lens/LensLaunchParams.js.map +1 -1
  208. package/lib/lens/LensPersistenceStore.js +1 -1
  209. package/lib/lens/LensPersistenceStore.js.map +1 -1
  210. package/lib/lens/LensRepository.d.ts +3 -2
  211. package/lib/lens/LensRepository.js +6 -5
  212. package/lib/lens/LensRepository.js.map +1 -1
  213. package/lib/lens/assets/LensAssetRepository.d.ts +5 -3
  214. package/lib/lens/assets/LensAssetRepository.js +21 -12
  215. package/lib/lens/assets/LensAssetRepository.js.map +1 -1
  216. package/lib/lens/assets/LensAssetsProvider.js +1 -1
  217. package/lib/lens/assets/LensAssetsProvider.js.map +1 -1
  218. package/lib/lens/lensEnvelopeUtil.js +1 -1
  219. package/lib/lens/lensEnvelopeUtil.js.map +1 -1
  220. package/lib/lens-client-interface/imagePicker.js +2 -2
  221. package/lib/lens-client-interface/imagePicker.js.map +1 -1
  222. package/lib/lens-client-interface/lensClientInterface.js +1 -1
  223. package/lib/lens-client-interface/lensClientInterface.js.map +1 -1
  224. package/lib/lens-core-module/loader/lensCoreFactory.js +4 -2
  225. package/lib/lens-core-module/loader/lensCoreFactory.js.map +1 -1
  226. package/lib/lensCoreWasmVersions.json +3 -3
  227. package/lib/logger/logEntries.d.ts +1 -1
  228. package/lib/logger/logEntries.js +3 -3
  229. package/lib/logger/logEntries.js.map +1 -1
  230. package/lib/logger/logger.d.ts +7 -2
  231. package/lib/logger/logger.js +9 -4
  232. package/lib/logger/logger.js.map +1 -1
  233. package/lib/media-sources/FunctionSource.js +1 -1
  234. package/lib/media-sources/FunctionSource.js.map +1 -1
  235. package/lib/media-sources/MediaStreamSource.d.ts +5 -1
  236. package/lib/media-sources/MediaStreamSource.js +14 -5
  237. package/lib/media-sources/MediaStreamSource.js.map +1 -1
  238. package/lib/metrics/businessEventsReporter.d.ts +3 -2
  239. package/lib/metrics/businessEventsReporter.js +16 -9
  240. package/lib/metrics/businessEventsReporter.js.map +1 -1
  241. package/lib/metrics/metricsHandler.d.ts +3 -2
  242. package/lib/metrics/metricsHandler.js +3 -3
  243. package/lib/metrics/metricsHandler.js.map +1 -1
  244. package/lib/metrics/operational/Count.d.ts +17 -0
  245. package/lib/metrics/operational/Count.js +28 -0
  246. package/lib/metrics/operational/Count.js.map +1 -0
  247. package/lib/metrics/operational/Histogram.d.ts +17 -0
  248. package/lib/metrics/operational/Histogram.js +23 -0
  249. package/lib/metrics/operational/Histogram.js.map +1 -0
  250. package/lib/metrics/operational/Metric.d.ts +20 -0
  251. package/lib/metrics/operational/Metric.js +26 -0
  252. package/lib/metrics/operational/Metric.js.map +1 -0
  253. package/lib/metrics/operational/Timer.d.ts +91 -0
  254. package/lib/metrics/operational/Timer.js +122 -0
  255. package/lib/metrics/operational/Timer.js.map +1 -0
  256. package/lib/metrics/{operationalMetricsReporter.d.ts → operational/operationalMetricsReporter.d.ts} +15 -4
  257. package/lib/metrics/{operationalMetricsReporter.js → operational/operationalMetricsReporter.js} +24 -8
  258. package/lib/metrics/operational/operationalMetricsReporter.js.map +1 -0
  259. package/lib/metrics/reporters/reportBenchmarks.d.ts +1 -1
  260. package/lib/metrics/reporters/reportBenchmarks.js +1 -1
  261. package/lib/metrics/reporters/reportBenchmarks.js.map +1 -1
  262. package/lib/metrics/reporters/reportGlobalException.d.ts +1 -1
  263. package/lib/metrics/reporters/reportGlobalException.js +1 -1
  264. package/lib/metrics/reporters/reportGlobalException.js.map +1 -1
  265. package/lib/metrics/reporters/reportHttpMetrics.d.ts +4 -4
  266. package/lib/metrics/reporters/reportHttpMetrics.js +3 -3
  267. package/lib/metrics/reporters/reportHttpMetrics.js.map +1 -1
  268. package/lib/metrics/reporters/reportLegalState.d.ts +1 -1
  269. package/lib/metrics/reporters/reportLegalState.js +1 -1
  270. package/lib/metrics/reporters/reportLegalState.js.map +1 -1
  271. package/lib/metrics/reporters/reportLensAndAssetDownload.d.ts +4 -4
  272. package/lib/metrics/reporters/reportLensAndAssetDownload.js +7 -3
  273. package/lib/metrics/reporters/reportLensAndAssetDownload.js.map +1 -1
  274. package/lib/metrics/reporters/reportLensValidationFailed.d.ts +1 -1
  275. package/lib/metrics/reporters/reportLensView.d.ts +2 -2
  276. package/lib/metrics/reporters/reportLensView.js +23 -17
  277. package/lib/metrics/reporters/reportLensView.js.map +1 -1
  278. package/lib/metrics/reporters/reportLensWait.d.ts +2 -2
  279. package/lib/metrics/reporters/reportLensWait.js +1 -1
  280. package/lib/metrics/reporters/reportLensWait.js.map +1 -1
  281. package/lib/metrics/reporters/reportSessionException.d.ts +1 -1
  282. package/lib/metrics/reporters/reporters.d.ts +7 -6
  283. package/lib/metrics/reporters/reporters.js +3 -3
  284. package/lib/metrics/reporters/reporters.js.map +1 -1
  285. package/lib/observable-operators/unsubscribed.d.ts +12 -0
  286. package/lib/observable-operators/unsubscribed.js +27 -0
  287. package/lib/observable-operators/unsubscribed.js.map +1 -0
  288. package/lib/remote-configuration/cofHandler.d.ts +3 -2
  289. package/lib/remote-configuration/cofHandler.js +8 -4
  290. package/lib/remote-configuration/cofHandler.js.map +1 -1
  291. package/lib/remote-configuration/remoteConfiguration.d.ts +16 -4
  292. package/lib/remote-configuration/remoteConfiguration.js +32 -6
  293. package/lib/remote-configuration/remoteConfiguration.js.map +1 -1
  294. package/lib/session/CameraKitSession.d.ts +4 -4
  295. package/lib/session/CameraKitSession.js +10 -9
  296. package/lib/session/CameraKitSession.js.map +1 -1
  297. package/lib/session/LensKeyboard.d.ts +1 -1
  298. package/lib/session/LensPerformanceMeasurement.d.ts +2 -0
  299. package/lib/session/LensPerformanceMeasurement.js +27 -4
  300. package/lib/session/LensPerformanceMeasurement.js.map +1 -1
  301. package/lib/session/lensState.d.ts +5 -4
  302. package/lib/session/lensState.js +95 -41
  303. package/lib/session/lensState.js.map +1 -1
  304. package/package.json +12 -12
  305. package/lib/metrics/operationalMetricsReporter.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"bootstrapCameraKit.js","sourceRoot":"","sources":["../src/bootstrapCameraKit.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EA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,CAAC,iCAAiC,CAAC;iBAC3C,QAAQ,CAAC,wBAAwB,CAAC;iBAClC,QAAQ,CAAC,0BAA0B,CAAC;iBACpC,QAAQ,CAAC,qBAAqB,CAAC;iBAC/B,QAAQ,CAAC,kBAAkB,CAAC;iBAC5B,QAAQ,CAAC,iBAAiB,CAAC;iBAC3B,QAAQ,CAAC,gBAAgB,CAAC;gBAC3B,wGAAwG;gBACxG,0GAA0G;gBAC1G,4GAA4G;gBAC5G,iCAAiC;iBAChC,GAAG,CAAC,2BAA2B,CAAC,CAAC;YAEtC,MAAM,SAAS,GAAG,SAAS,CAAC,GAAG,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;YAExD,MAAM,eAAe,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,WAAW,CAAC;YACxD,MAAM,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAC,gCAAgC,CAAC,KAAK,CAAC,CAAC;YACvE,QAAQ,CAAC,KAAK,CAAC,gBAAgB,EAAE,eAAe,CAAC,CAAC;YAElD,OAAO,SAAS,CAAC;SACpB;QAAC,OAAO,KAAK,EAAE;YACZ,IAAI,eAAe,CAAC,KAAK,CAAC,EAAE;gBACxB,KAAK,GAAG,cAAc,CAAC,iCAAiC,EAAE,KAAK,CAAC,CAAC;aACpE;YACD,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACpB,MAAM,KAAK,CAAC;SACf;IACL,CAAC;CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,UAAU,eAAe;IAC3B,OAAO,IAAI,gBAAgB,CAAC,EAAE,CAAC,CAAC;AACpC,CAAC","sourcesContent":["import { lensRepositoryFactory } from \"./lens/LensRepository\";\nimport { Container } from \"./dependency-injection/Container\";\nimport { CameraKit, cameraKitFactory } from \"./CameraKit\";\nimport { lensCoreFactory } from \"./lens-core-module/loader/lensCoreFactory\";\nimport { Injectable } from \"./dependency-injection/Injectable\";\nimport { remoteMediaAssetLoaderFactory } from \"./lens/assets/remoteMediaAssetLoaderFactory\";\nimport { deviceDependentAssetLoaderFactory } from \"./lens/assets/deviceDependentAssetLoader\";\nimport { staticAssetLoaderFactory } from \"./lens/assets/staticAssetLoader\";\nimport { defaultFetchHandlerFactory } from \"./handlers/defaultFetchHandler\";\nimport { cameraKitServiceFetchHandlerFactory } from \"./handlers/cameraKitServiceFetchHandlerFactory\";\nimport { CameraKitBootstrapConfiguration, createCameraKitConfigurationFactory } from \"./configuration\";\nimport { PublicServices } from \"./dependency-injection/RootServices\";\nimport { PartialContainer } from \"./dependency-injection/PartialContainer\";\nimport { metricsHandlerFactory } from \"./metrics/metricsHandler\";\nimport { operationalMetricReporterFactory } from \"./metrics/operationalMetricsReporter\";\nimport { lensSourcesFactory } from \"./extensions/LensSources\";\nimport { uriHandlersFactory } from \"./extensions/UriHandlers\";\nimport { assert } from \"./common/assertions\";\nimport { isSafeString } from \"./common/typeguards\";\nimport { metricsEventTargetFactory } from \"./metrics/metricsEventTarget\";\nimport { reportGloballyScopedMetrics } from \"./metrics/reporters/reporters\";\nimport { getLogger } from \"./logger/logger\";\nimport { logEntriesFactory } from \"./logger/logEntries\";\nimport { assertPlatformSupported } from \"./assertPlatformSupported\";\nimport { lensPersistenceStoreFactory } from \"./lens/LensPersistenceStore\";\nimport { remoteConfigurationFactory } from \"./remote-configuration/remoteConfiguration\";\nimport { lensAssetRepositoryFactory } from \"./lens/assets/LensAssetRepository\";\nimport { legalStateFactory } from \"./legal/legalState\";\nimport { legalPromptFactory } from \"./legal/legalPrompt\";\nimport { bootstrapError, ConfigurationError, configurationError, PlatformNotSupportedError } from \"./namedErrors\";\nimport { businessEventsReporterFactory } from \"./metrics/businessEventsReporter\";\nimport { reportGlobalException } from \"./metrics/reporters/reportGlobalException\";\nimport { registerLogEntriesSubscriber } from \"./logger/registerLogEntriesSubscriber\";\n\nconst logger = getLogger(\"bootstrapCameraKit\");\n\n// The following errors are not wrapped with BootstrapError and bubble up as is.\nconst nonWrappableErrors: [ConfigurationError[\"name\"], PlatformNotSupportedError[\"name\"]] = [\n \"ConfigurationError\",\n \"PlatformNotSupportedError\",\n];\n\n/**\n * Returns true if given error has to be wrapped with BoostrapError.\n */\nfunction shouldWrapError(error: unknown): boolean {\n if (error instanceof Error) {\n return !nonWrappableErrors.some((name) => error.name === name);\n }\n return true;\n}\n\n/**\n * For more advanced use-cases, this DI Container holds services for which a custom implementation may be provided by\n * the application.\n *\n * @category Bootstrapping and Configuration\n */\nexport type PublicContainer = Container<PublicServices>;\n\n/**\n * Bootstrap CameraKit. This will download the WebAssembly code which powers CameraKit's rendering engine, and return\n * an instance of {@link CameraKit}.\n *\n * CameraKit must be provided with some configuration (the application's API token), and there are some additional\n * configurations which are optional.\n *\n * Descriptions of the available configurations can be found in the documentation for\n * {@link CameraKitBootstrapConfiguration}\n *\n * ---\n *\n * There is also a second, more advanced way to modify CameraKit to provide greater flexibility to support less common\n * use cases.\n *\n * This requires some knowledge of CameraKit's dependency injection system, and allows applications to provide their\n * own custom implementations of certain CameraKit components. This functionality will only be needed by applications\n * with very specific, more advanced requirements.\n *\n * @example\n * ```ts\n * // The most common way to bootstrap:\n * const cameraKit = await bootstrapCameraKit({ apiToken: myApiToken })\n *\n * // For special advanced use-cases, it is possible to provide custom implementations for certain CameraKit components.\n * const cameraKit = await bootstrapCameraKit(config, (container) => {\n * return container.provides(myCustomRemoteMediaAssetLoaderFactory)\n * })\n * ```\n *\n * @param configuration Configure CameraKit with e.g. credentials, global resource endpoints, etc.\n * @param provide Optional function that can make modifications to CameraKit's root DI container.\n * @returns A {@link CameraKit} instance, which is the entry point to CameraKit's API.\n *\n * @throws\n * - {@link ConfigurationError} when provided configuration object is invalid\n * - {@link PlatformNotSupportedError} when current platform is not supported by CameraKit\n * - {@link BootstrapError} when a failure occurs while initializing CameraKit and downloading the render engine\n * WebAssembly binary.\n *\n * @category Bootstrapping and Configuration\n */\nexport async function bootstrapCameraKit(\n configuration: CameraKitBootstrapConfiguration,\n provide?: (c: PublicContainer) => PublicContainer\n): Promise<CameraKit> {\n try {\n const startTimeMs = performance.now();\n\n assert(isSafeString(configuration.apiToken), configurationError(\"Unsafe apiToken\"));\n\n const configurationFactory = createCameraKitConfigurationFactory(configuration);\n\n // Public container holds services which applications can overwrite with their own implementations.\n const defaultPublicContainer = Container.provides(configurationFactory)\n .provides(defaultFetchHandlerFactory)\n .provides(remoteMediaAssetLoaderFactory)\n .provides(lensSourcesFactory)\n .provides(uriHandlersFactory);\n\n const publicContainer = provide ? provide(defaultPublicContainer) : defaultPublicContainer;\n\n // Now that the client's provide() function has completed and the configuration override is ready,\n // we create another container to initialize the logger. This ensures that logging is available\n // as we continue bootstrapping. We don't initialize the logger as part of the defaultPublicContainer\n // because we don't want applications to provide their own logger implementations,\n // and we're not interested in errors thrown by their provide() function.\n // Below is the minimum required container to report errors to Blizzard.\n const telemetryContainer = Container.provides(publicContainer)\n .provides(logEntriesFactory)\n .provides(cameraKitServiceFetchHandlerFactory)\n .provides(metricsEventTargetFactory)\n .provides(metricsHandlerFactory)\n .provides(operationalMetricReporterFactory)\n .provides(reportGlobalException)\n .run(businessEventsReporterFactory)\n .run(registerLogEntriesSubscriber);\n\n // Run the exception logger so that it can subscribe to log events -- we can't use `Container.run()` because\n // reportGlobalException is also used as a dependency by other Services (and run does not provide Services,\n // it just runs them once).\n telemetryContainer.get(reportGlobalException.token);\n\n // At this point, logger is configured to report to console and Blizzard.\n\n assertPlatformSupported();\n\n // LensCore is a foundational component which must be created asynchronously.\n // But it's annoying for every consumer of LensCore to have to wait on Promise<LensCore>\n // (which means they become async themselves). So we'll create a DI container which provides Promise<LensCore>,\n // wait for that promise once here, then create a new DI container that just contains LensCore.\n const lensCore = await telemetryContainer.provides(lensCoreFactory).get(lensCoreFactory.token);\n\n const container = telemetryContainer\n .provides(Injectable(lensCoreFactory.token, () => lensCore))\n .provides(remoteConfigurationFactory)\n .provides(lensPersistenceStoreFactory)\n .provides(deviceDependentAssetLoaderFactory)\n .provides(staticAssetLoaderFactory)\n .provides(lensAssetRepositoryFactory)\n .provides(lensRepositoryFactory)\n .provides(legalPromptFactory)\n .provides(legalStateFactory)\n .provides(cameraKitFactory)\n // We'll run a PartialContainer containing reporters for globally-scoped metrics. Running this container\n // allows each metric reporter to initialize itself (e.g. by adding event listeners to detect when certain\n // actions occur). This PartialContainer also includes the service which listens to locally-reported metrics\n // and sends them to our backend.\n .run(reportGloballyScopedMetrics);\n\n const cameraKit = container.get(cameraKitFactory.token);\n\n const bootstrapTimeMs = performance.now() - startTimeMs;\n const reporter = container.get(operationalMetricReporterFactory.token);\n reporter.timer(\"bootstrap_time\", bootstrapTimeMs);\n\n return cameraKit;\n } catch (error) {\n if (shouldWrapError(error)) {\n error = bootstrapError(\"Failed to bootstrap Camera Kit.\", error);\n }\n logger.error(error);\n throw error;\n }\n}\n\n/**\n * Extensions offer a way to provide custom implementations of certain parts of the CameraKit SDK.\n *\n * This enables more advanced use-cases, in which the default behavior of the SDK is substantially altered. For example,\n * replacing the default implementation that loads remote lens assets with a custom implementation that returns\n * different assets based on some business logic within the application.\n *\n * An extension is implemented as a [PartialContainer] – a collection of factory functions, each with its own\n * dependencies, which each provide some \"Service.\" A Service can be of any type, and the CameraKit SDK defines its\n * own Services, some of which can be overridden by providing a custom implementation of the type via an extension.\n *\n * Here's an example of how extensions might be used:\n * ```ts\n * import { bootstrapCameraKit, createExtension, remoteMediaAssetLoaderFactory } from '@snap/camera-kit'\n *\n * const myCustomRemoteAssetLoader = Injectable(\n * remoteMediaAssetLoaderFactory.token,\n * [remoteMediaAssetLoaderFactory.token] as const,\n * (defaultLoader: AssetLoader): AssetLoader => {\n * return async (asset, lens) => {\n * if (lens?.id === MY_SPECIAL_LENS) {\n * return (await fetch('my/asset.glb')).arrayBuffer()\n * }\n * return defaultLoader(asset, lens)\n * }\n * },\n * )\n *\n * const myExtension = createExtension().provides(myCustomeRemoteAssetLoader)\n * const cameraKit = bootstrapCameraKit(config, container => container.provides(myExtension))\n * ```\n *\n * This also enables greater modularity – the person/team creating the extension can do so in their own package, which\n * could be shared by many applications that all require the same functionality.\n *\n * @returns A {@link PartialContainer} which can be used to create a collection of Services, and can later be provided\n * to CameraKit's DI container during {@link bootstrapCameraKit}.\n *\n * @category Bootstrapping and Configuration\n */\nexport function createExtension(): PartialContainer {\n return new PartialContainer({});\n}\n"]}
1
+ {"version":3,"file":"bootstrapCameraKit.js","sourceRoot":"","sources":["../src/bootstrapCameraKit.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAa,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAC/D,OAAO,EAAE,6BAA6B,EAAE,MAAM,6CAA6C,CAAC;AAC5F,OAAO,EAAE,iCAAiC,EAAE,MAAM,0CAA0C,CAAC;AAC7F,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAE,mCAAmC,EAAE,MAAM,gDAAgD,CAAC;AACrG,OAAO,EAAmC,mCAAmC,EAAE,MAAM,iBAAiB,CAAC;AAEvG,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,gCAAgC,EAAE,MAAM,kDAAkD,CAAC;AACpG,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OA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C,OAAO,KAAK,EAAE;YACZ,IAAI,eAAe,CAAC,KAAK,CAAC,EAAE;gBACxB,KAAK,GAAG,cAAc,CAAC,iDAAiD,EAAE,KAAK,CAAC,CAAC;aACpF;YACD,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACpB,MAAM,KAAK,CAAC;SACf;IACL,CAAC;CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,UAAU,eAAe;IAC3B,OAAO,IAAI,gBAAgB,CAAC,EAAE,CAAC,CAAC;AACpC,CAAC","sourcesContent":["import { lensRepositoryFactory } from \"./lens/LensRepository\";\nimport { Container } from \"./dependency-injection/Container\";\nimport { CameraKit, cameraKitFactory } from \"./CameraKit\";\nimport { lensCoreFactory } from \"./lens-core-module/loader/lensCoreFactory\";\nimport { Injectable } from \"./dependency-injection/Injectable\";\nimport { remoteMediaAssetLoaderFactory } from \"./lens/assets/remoteMediaAssetLoaderFactory\";\nimport { deviceDependentAssetLoaderFactory } from \"./lens/assets/deviceDependentAssetLoader\";\nimport { staticAssetLoaderFactory } from \"./lens/assets/staticAssetLoader\";\nimport { defaultFetchHandlerFactory } from \"./handlers/defaultFetchHandler\";\nimport { cameraKitServiceFetchHandlerFactory } from \"./handlers/cameraKitServiceFetchHandlerFactory\";\nimport { CameraKitBootstrapConfiguration, createCameraKitConfigurationFactory } from \"./configuration\";\nimport { PublicServices } from \"./dependency-injection/RootServices\";\nimport { PartialContainer } from \"./dependency-injection/PartialContainer\";\nimport { metricsHandlerFactory } from \"./metrics/metricsHandler\";\nimport { operationalMetricReporterFactory } from \"./metrics/operational/operationalMetricsReporter\";\nimport { lensSourcesFactory } from \"./extensions/LensSources\";\nimport { uriHandlersFactory } from \"./extensions/UriHandlers\";\nimport { assert } from \"./common/assertions\";\nimport { isSafeString } from \"./common/typeguards\";\nimport { metricsEventTargetFactory } from \"./metrics/metricsEventTarget\";\nimport { reportGloballyScopedMetrics } from \"./metrics/reporters/reporters\";\nimport { getLogger } from \"./logger/logger\";\nimport { logEntriesFactory } from \"./logger/logEntries\";\nimport { assertPlatformSupported } from \"./assertPlatformSupported\";\nimport { lensPersistenceStoreFactory } from \"./lens/LensPersistenceStore\";\nimport { remoteConfigurationFactory } from \"./remote-configuration/remoteConfiguration\";\nimport { lensAssetRepositoryFactory } from \"./lens/assets/LensAssetRepository\";\nimport { legalStateFactory } from \"./legal/legalState\";\nimport { legalPromptFactory } from \"./legal/legalPrompt\";\nimport { bootstrapError, ConfigurationError, configurationError, PlatformNotSupportedError } from \"./namedErrors\";\nimport { businessEventsReporterFactory } from \"./metrics/businessEventsReporter\";\nimport { reportGlobalException } from \"./metrics/reporters/reportGlobalException\";\nimport { registerLogEntriesSubscriber } from \"./logger/registerLogEntriesSubscriber\";\nimport { requestStateEventTargetFactory } from \"./handlers/requestStateEmittingHandler\";\nimport { pageVisibilityFactory } from \"./common/pageVisibility\";\n\nconst logger = getLogger(\"bootstrapCameraKit\");\n\n// The following errors are not wrapped with BootstrapError and bubble up as is.\nconst nonWrappableErrors: [ConfigurationError[\"name\"], PlatformNotSupportedError[\"name\"]] = [\n \"ConfigurationError\",\n \"PlatformNotSupportedError\",\n];\n\n/**\n * Returns true if given error has to be wrapped with BoostrapError.\n */\nfunction shouldWrapError(error: unknown): boolean {\n if (error instanceof Error) {\n return !nonWrappableErrors.some((name) => error.name === name);\n }\n return true;\n}\n\n/**\n * For more advanced use-cases, this DI Container holds services for which a custom implementation may be provided by\n * the application.\n *\n * @category Bootstrapping and Configuration\n */\nexport type PublicContainer = Container<PublicServices>;\n\n/**\n * Bootstrap CameraKit. This will download the WebAssembly code which powers CameraKit's rendering engine, and return\n * an instance of {@link CameraKit}.\n *\n * CameraKit must be provided with some configuration (the application's API token), and there are some additional\n * configurations which are optional.\n *\n * Descriptions of the available configurations can be found in the documentation for\n * {@link CameraKitBootstrapConfiguration}\n *\n * ---\n *\n * There is also a second, more advanced way to modify CameraKit to provide greater flexibility to support less common\n * use cases.\n *\n * This requires some knowledge of CameraKit's dependency injection system, and allows applications to provide their\n * own custom implementations of certain CameraKit components. This functionality will only be needed by applications\n * with very specific, more advanced requirements.\n *\n * @example\n * ```ts\n * // The most common way to bootstrap:\n * const cameraKit = await bootstrapCameraKit({ apiToken: myApiToken })\n *\n * // For special advanced use-cases, it is possible to provide custom implementations for certain CameraKit components.\n * const cameraKit = await bootstrapCameraKit(config, (container) => {\n * return container.provides(myCustomRemoteMediaAssetLoaderFactory)\n * })\n * ```\n *\n * @param configuration Configure CameraKit with e.g. credentials, global resource endpoints, etc.\n * @param provide Optional function that can make modifications to CameraKit's root DI container.\n * @returns A {@link CameraKit} instance, which is the entry point to CameraKit's API.\n *\n * @throws\n * - {@link ConfigurationError} when provided configuration object is invalid\n * - {@link PlatformNotSupportedError} when current platform is not supported by CameraKit\n * - {@link BootstrapError} when a failure occurs while initializing CameraKit and downloading the render engine\n * WebAssembly binary.\n *\n * @category Bootstrapping and Configuration\n */\nexport async function bootstrapCameraKit(\n configuration: CameraKitBootstrapConfiguration,\n provide?: (c: PublicContainer) => PublicContainer\n): Promise<CameraKit> {\n try {\n const startTimeMs = performance.now();\n\n assert(isSafeString(configuration.apiToken), configurationError(\"Invalid or unsafe apiToken provided.\"));\n\n const configurationFactory = createCameraKitConfigurationFactory(configuration);\n\n // Public container holds services which applications can overwrite with their own implementations.\n const defaultPublicContainer = Container.provides(configurationFactory)\n .provides(pageVisibilityFactory)\n .provides(defaultFetchHandlerFactory)\n .provides(remoteMediaAssetLoaderFactory)\n .provides(lensSourcesFactory)\n .provides(uriHandlersFactory);\n\n const publicContainer = provide ? provide(defaultPublicContainer) : defaultPublicContainer;\n\n // Now that the client's provide() function has completed and the configuration override is ready,\n // we create another container to initialize the logger. This ensures that logging is available\n // as we continue bootstrapping. We don't initialize the logger as part of the defaultPublicContainer\n // because we don't want applications to provide their own logger implementations,\n // and we're not interested in errors thrown by their provide() function.\n // Below is the minimum required container to report errors to Blizzard.\n const telemetryContainer = Container.provides(publicContainer)\n .provides(logEntriesFactory)\n .run(registerLogEntriesSubscriber)\n .provides(cameraKitServiceFetchHandlerFactory)\n .provides(requestStateEventTargetFactory)\n .provides(metricsEventTargetFactory)\n .provides(metricsHandlerFactory)\n .provides(operationalMetricReporterFactory)\n .provides(reportGlobalException)\n .run(businessEventsReporterFactory);\n\n // Run the exception logger so that it can subscribe to log events -- we can't use `Container.run()` because\n // reportGlobalException is also used as a dependency by other Services (and run does not provide Services,\n // it just runs them once).\n telemetryContainer.get(reportGlobalException.token);\n\n // At this point, logger is configured to report to console and Blizzard.\n\n assertPlatformSupported();\n\n // LensCore is a foundational component which must be created asynchronously.\n // But it's annoying for every consumer of LensCore to have to wait on Promise<LensCore>\n // (which means they become async themselves). So we'll create a DI container which provides Promise<LensCore>,\n // wait for that promise once here, then create a new DI container that just contains LensCore.\n const lensCore = await telemetryContainer.provides(lensCoreFactory).get(lensCoreFactory.token);\n\n const container = telemetryContainer\n .provides(Injectable(lensCoreFactory.token, () => lensCore))\n .provides(remoteConfigurationFactory)\n .provides(lensPersistenceStoreFactory)\n .provides(deviceDependentAssetLoaderFactory)\n .provides(staticAssetLoaderFactory)\n .provides(lensAssetRepositoryFactory)\n .provides(lensRepositoryFactory)\n .provides(legalPromptFactory)\n .provides(legalStateFactory)\n .provides(cameraKitFactory)\n // We'll run a PartialContainer containing reporters for globally-scoped metrics. Running this container\n // allows each metric reporter to initialize itself (e.g. by adding event listeners to detect when certain\n // actions occur). This PartialContainer also includes the service which listens to locally-reported metrics\n // and sends them to our backend.\n .run(reportGloballyScopedMetrics);\n\n const cameraKit = container.get(cameraKitFactory.token);\n\n const bootstrapTimeMs = performance.now() - startTimeMs;\n const reporter = container.get(operationalMetricReporterFactory.token);\n reporter.timer(\"bootstrap_time\", bootstrapTimeMs);\n\n return cameraKit;\n } catch (error) {\n if (shouldWrapError(error)) {\n error = bootstrapError(\"Error occurred during Camera Kit bootstrapping.\", error);\n }\n logger.error(error);\n throw error;\n }\n}\n\n/**\n * Extensions offer a way to provide custom implementations of certain parts of the CameraKit SDK.\n *\n * This enables more advanced use-cases, in which the default behavior of the SDK is substantially altered. For example,\n * replacing the default implementation that loads remote lens assets with a custom implementation that returns\n * different assets based on some business logic within the application.\n *\n * An extension is implemented as a [PartialContainer] – a collection of factory functions, each with its own\n * dependencies, which each provide some \"Service.\" A Service can be of any type, and the CameraKit SDK defines its\n * own Services, some of which can be overridden by providing a custom implementation of the type via an extension.\n *\n * Here's an example of how extensions might be used:\n * ```ts\n * import { bootstrapCameraKit, createExtension, remoteMediaAssetLoaderFactory } from '@snap/camera-kit'\n *\n * const myCustomRemoteAssetLoader = Injectable(\n * remoteMediaAssetLoaderFactory.token,\n * [remoteMediaAssetLoaderFactory.token] as const,\n * (defaultLoader: AssetLoader): AssetLoader => {\n * return async (asset, lens) => {\n * if (lens?.id === MY_SPECIAL_LENS) {\n * return (await fetch('my/asset.glb')).arrayBuffer()\n * }\n * return defaultLoader(asset, lens)\n * }\n * },\n * )\n *\n * const myExtension = createExtension().provides(myCustomeRemoteAssetLoader)\n * const cameraKit = bootstrapCameraKit(config, container => container.provides(myExtension))\n * ```\n *\n * This also enables greater modularity – the person/team creating the extension can do so in their own package, which\n * could be shared by many applications that all require the same functionality.\n *\n * @returns A {@link PartialContainer} which can be used to create a collection of Services, and can later be provided\n * to CameraKit's DI container during {@link bootstrapCameraKit}.\n *\n * @category Bootstrapping and Configuration\n */\nexport function createExtension(): PartialContainer {\n return new PartialContainer({});\n}\n"]}
@@ -1 +1 @@
1
- export declare function loadScript(): Promise<void>;
1
+ export declare function loadScript(): Promise<HTMLScriptElement>;
@@ -5,6 +5,6 @@ export function loadScript() {
5
5
  module.instantiateWasm({}, () => resolve(module));
6
6
  });
7
7
  });
8
- return Promise.resolve();
8
+ return Promise.resolve(document.createElement("script"));
9
9
  }
10
10
  //# sourceMappingURL=loadScript.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"loadScript.js","sourceRoot":"","sources":["../../../src/common/__mocks__/loadScript.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,UAAU;IACtB,MAAM,CAAC,kBAAkB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,kBAAkB,CAAC,CAAC,MAAkB,EAAE,EAAE;QAC5E,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC3B,MAAM,CAAC,cAAc,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC;YAChC,MAAM,CAAC,eAAgB,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;QACvD,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;AAC7B,CAAC","sourcesContent":["import { InitialEmscriptenModule, LensCoreModule } from \"../../lens-core-module/generated-types\";\n\ntype MockModule = InitialEmscriptenModule & Partial<LensCoreModule>;\n\nexport function loadScript(): Promise<void> {\n global.createLensesModule = jest.fn().mockImplementation((module: MockModule) => {\n return new Promise((resolve) => {\n module.getCoreVersion = () => 0;\n module.instantiateWasm!({}, () => resolve(module));\n });\n });\n return Promise.resolve();\n}\n"]}
1
+ {"version":3,"file":"loadScript.js","sourceRoot":"","sources":["../../../src/common/__mocks__/loadScript.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,UAAU;IACtB,MAAM,CAAC,kBAAkB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,kBAAkB,CAAC,CAAC,MAAkB,EAAE,EAAE;QAC5E,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC3B,MAAM,CAAC,cAAc,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC;YAChC,MAAM,CAAC,eAAgB,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;QACvD,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC7D,CAAC","sourcesContent":["import { InitialEmscriptenModule, LensCoreModule } from \"../../lens-core-module/generated-types\";\n\ntype MockModule = InitialEmscriptenModule & Partial<LensCoreModule>;\n\nexport function loadScript(): Promise<HTMLScriptElement> {\n global.createLensesModule = jest.fn().mockImplementation((module: MockModule) => {\n return new Promise((resolve) => {\n module.getCoreVersion = () => 0;\n module.instantiateWasm!({}, () => resolve(module));\n });\n });\n return Promise.resolve(document.createElement(\"script\"));\n}\n"]}
@@ -0,0 +1,16 @@
1
+ interface DialogOptions<Keys extends string> {
2
+ container: HTMLElement;
3
+ body?: string;
4
+ title?: string;
5
+ dataTestId?: string;
6
+ dismissButtonText?: string;
7
+ buttons?: DialogButton<Keys>[];
8
+ }
9
+ interface DialogButton<Key extends string> {
10
+ text: string;
11
+ key: Key;
12
+ isSecondary?: boolean;
13
+ }
14
+ type DismissKey = "dismiss";
15
+ export declare function showDialog<Keys extends string>(options: DialogOptions<Keys>): Promise<Keys | DismissKey>;
16
+ export {};
@@ -0,0 +1,146 @@
1
+ import { fromEvent, map, merge, take } from "rxjs";
2
+ const stylesCss = `
3
+ dialog {
4
+ display: flex;
5
+ flex-direction: column;
6
+
7
+ background-color: #fff;
8
+ border: #efefef 1px solid;
9
+ border-radius: 20px;
10
+ box-shadow: 0px 10px 20px rgba(0, 0, 0, 0.3);
11
+
12
+ max-width: 80vw;
13
+ max-height: 80vh;
14
+ padding: 44px 0 24px 0;
15
+
16
+ font-size: 16px;
17
+ font-family: sans-serif;
18
+ font-style: normal;
19
+ font-weight: 600;
20
+ line-height: 24px;
21
+ }
22
+
23
+ dialog::backdrop {
24
+ background-color: rgba(0, 0, 0, 0.4);
25
+ }
26
+
27
+ .title {
28
+ color: #16191C;
29
+ padding: 0 32px;
30
+ text-align: center;
31
+ }
32
+
33
+ .body {
34
+ color: #656D78;
35
+ font-size: 14px;
36
+ font-weight: 500;
37
+ margin-top: 16px;
38
+ max-width: 350px;
39
+ padding: 0 32px;
40
+ overflow: auto;
41
+ }
42
+
43
+ a {
44
+ color: rgb(78, 171, 248);
45
+ }
46
+
47
+ button {
48
+ cursor: pointer;
49
+ }
50
+
51
+ button.dismiss {
52
+ position: absolute;
53
+ top: 7px;
54
+ right: 7px;
55
+ padding: 0;
56
+ height: 36px;
57
+ width: 36px;
58
+ margin: 0;
59
+ background-color: transparent;
60
+ border: 0;
61
+ }
62
+
63
+ .buttons {
64
+ margin-top: 8px;
65
+ padding: 0 32px;
66
+ }
67
+
68
+ .buttons button {
69
+ background: #0FADFF;
70
+ border: 0;
71
+ border-radius: 25px;
72
+
73
+ width: 100%;
74
+ padding: 1rem;
75
+ margin-top: 8px;
76
+
77
+ color: #fff;
78
+ font-weight: inherit;
79
+ font-family: inherit;
80
+ font-size: inherit;
81
+ font-style: inherit;
82
+ }
83
+
84
+ .buttons button.secondary {
85
+ background-color: transparent;
86
+ color: #656D78;
87
+ }
88
+ `;
89
+ function getDismissButtonHtml(button) {
90
+ /* eslint-disable max-len */
91
+ return `
92
+ <button class="dismiss" autofocus data-key=${button.key}>
93
+ <svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
94
+ <title>${button.text}</title>
95
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M12.6763 11.2621C12.2858 10.8716 11.6527 10.8716 11.2621 11.2621C10.8716 11.6527 10.8716 12.2858 11.2621 12.6763L16.5858 18L11.2621 23.3237C10.8716 23.7142 10.8716 24.3474 11.2621 24.7379C11.6527 25.1284 12.2858 25.1284 12.6764 24.7379L18 19.4142L23.3237 24.7379C23.7142 25.1284 24.3474 25.1284 24.7379 24.7379C25.1284 24.3474 25.1284 23.7142 24.7379 23.3237L19.4142 18L24.7379 12.6763C25.1284 12.2858 25.1284 11.6527 24.7379 11.2621C24.3474 10.8716 23.7142 10.8716 23.3237 11.2621L18 16.5858L12.6763 11.2621Z" fill="black" fill-opacity="0.4"/>
96
+ </svg>
97
+ </button>`;
98
+ /* eslint-enable */
99
+ }
100
+ function getTitleHtml(title) {
101
+ return title ? `<div class="title">${title}</div>` : "";
102
+ }
103
+ function getBodyHtml(body) {
104
+ return body ? `<div class="body">${body}</div>` : "";
105
+ }
106
+ function getButtonHtml(button) {
107
+ return `
108
+ <button data-key="${button.key}" class="${button.isSecondary ? "secondary" : ""}">
109
+ ${button.text}
110
+ </button>`;
111
+ }
112
+ function getButtonsHtml(buttons) {
113
+ if (buttons.length === 0)
114
+ return "";
115
+ return `
116
+ <div class="buttons">
117
+ ${buttons.map((b) => getButtonHtml(b)).join("\n")}
118
+ </div>`;
119
+ }
120
+ export function showDialog(options) {
121
+ return new Promise((res) => {
122
+ var _a, _b;
123
+ const element = document.createElement("div");
124
+ if (options.dataTestId)
125
+ element.setAttribute("data-testid", options.dataTestId);
126
+ const shadow = element.attachShadow({ mode: "open" });
127
+ const style = document.createElement("style");
128
+ shadow.appendChild(style);
129
+ style.innerHTML = stylesCss;
130
+ const prompt = document.createElement("dialog");
131
+ shadow.appendChild(prompt);
132
+ prompt.innerHTML = `
133
+ ${getDismissButtonHtml({ key: "dismiss", text: (_a = options.dismissButtonText) !== null && _a !== void 0 ? _a : "Dismiss" })}
134
+ ${getTitleHtml(options.title)}
135
+ ${getBodyHtml(options.body)}
136
+ ${getButtonsHtml((_b = options.buttons) !== null && _b !== void 0 ? _b : [])}
137
+ `;
138
+ const buttonsElements = Array.from(prompt.querySelectorAll("button"));
139
+ merge(...buttonsElements.map((b) => fromEvent(b, "click").pipe(map(() => b.dataset.key))), fromEvent(prompt, "cancel").pipe(map(() => "dismiss")))
140
+ .pipe(take(1))
141
+ .subscribe({ next: res, complete: () => element.remove() });
142
+ options.container.appendChild(element);
143
+ prompt.showModal();
144
+ });
145
+ }
146
+ //# sourceMappingURL=dialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dialog.js","sourceRoot":"","sources":["../../src/common/dialog.ts"],"names":[],"mapp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I,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;aACb,SAAS,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAChE,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QACvC,MAAM,CAAC,SAAS,EAAE,CAAC;IACvB,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import { fromEvent, map, merge, take } from \"rxjs\";\n\ninterface DialogOptions<Keys extends string> {\n container: HTMLElement;\n body?: string;\n title?: string;\n dataTestId?: string;\n dismissButtonText?: string;\n buttons?: DialogButton<Keys>[];\n}\n\ninterface DialogButton<Key extends string> {\n text: string;\n key: Key;\n isSecondary?: boolean;\n}\n\ntype DismissKey = \"dismiss\";\n\nconst stylesCss = `\ndialog {\n display: flex;\n flex-direction: column;\n\n background-color: #fff;\n border: #efefef 1px solid;\n border-radius: 20px;\n box-shadow: 0px 10px 20px rgba(0, 0, 0, 0.3);\n\n max-width: 80vw;\n max-height: 80vh;\n padding: 44px 0 24px 0;\n\n font-size: 16px;\n font-family: sans-serif;\n font-style: normal;\n font-weight: 600;\n line-height: 24px;\n}\n\ndialog::backdrop {\n background-color: rgba(0, 0, 0, 0.4);\n}\n\n.title {\n color: #16191C;\n padding: 0 32px;\n text-align: center;\n}\n\n.body {\n color: #656D78;\n font-size: 14px;\n font-weight: 500;\n margin-top: 16px;\n max-width: 350px;\n padding: 0 32px;\n overflow: auto;\n}\n\na {\n color: rgb(78, 171, 248);\n}\n\nbutton {\n cursor: pointer;\n}\n\nbutton.dismiss {\n position: absolute;\n top: 7px;\n right: 7px;\n padding: 0;\n height: 36px;\n width: 36px;\n margin: 0;\n background-color: transparent;\n border: 0;\n}\n\n.buttons {\n margin-top: 8px;\n padding: 0 32px;\n}\n\n.buttons button {\n background: #0FADFF;\n border: 0;\n border-radius: 25px;\n\n width: 100%;\n padding: 1rem;\n margin-top: 8px;\n\n color: #fff;\n font-weight: inherit;\n font-family: inherit;\n font-size: inherit;\n font-style: inherit;\n}\n\n.buttons button.secondary {\n background-color: transparent;\n color: #656D78;\n}\n`;\n\nfunction getDismissButtonHtml(button: DialogButton<DismissKey>) {\n /* eslint-disable max-len */\n return `\n <button class=\"dismiss\" autofocus data-key=${button.key}>\n <svg width=\"36\" height=\"36\" viewBox=\"0 0 36 36\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <title>${button.text}</title>\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M12.6763 11.2621C12.2858 10.8716 11.6527 10.8716 11.2621 11.2621C10.8716 11.6527 10.8716 12.2858 11.2621 12.6763L16.5858 18L11.2621 23.3237C10.8716 23.7142 10.8716 24.3474 11.2621 24.7379C11.6527 25.1284 12.2858 25.1284 12.6764 24.7379L18 19.4142L23.3237 24.7379C23.7142 25.1284 24.3474 25.1284 24.7379 24.7379C25.1284 24.3474 25.1284 23.7142 24.7379 23.3237L19.4142 18L24.7379 12.6763C25.1284 12.2858 25.1284 11.6527 24.7379 11.2621C24.3474 10.8716 23.7142 10.8716 23.3237 11.2621L18 16.5858L12.6763 11.2621Z\" fill=\"black\" fill-opacity=\"0.4\"/>\n </svg>\n </button>`;\n /* eslint-enable */\n}\n\nfunction getTitleHtml(title: string | undefined) {\n return title ? `<div class=\"title\">${title}</div>` : \"\";\n}\n\nfunction getBodyHtml(body: string | undefined) {\n return body ? `<div class=\"body\">${body}</div>` : \"\";\n}\n\nfunction getButtonHtml<Key extends string>(button: DialogButton<Key>) {\n return `\n <button data-key=\"${button.key}\" class=\"${button.isSecondary ? \"secondary\" : \"\"}\">\n ${button.text}\n </button>`;\n}\n\nfunction getButtonsHtml<Key extends string>(buttons: DialogButton<Key>[]) {\n if (buttons.length === 0) return \"\";\n return `\n <div class=\"buttons\">\n ${buttons.map((b) => getButtonHtml(b)).join(\"\\n\")}\n </div>`;\n}\n\nexport function showDialog<Keys extends string>(options: DialogOptions<Keys>): Promise<Keys | DismissKey> {\n return new Promise((res) => {\n const element = document.createElement(\"div\");\n if (options.dataTestId) element.setAttribute(\"data-testid\", options.dataTestId);\n const shadow = element.attachShadow({ mode: \"open\" });\n\n const style = document.createElement(\"style\");\n shadow.appendChild(style);\n style.innerHTML = stylesCss;\n\n const prompt = document.createElement(\"dialog\");\n shadow.appendChild(prompt);\n\n prompt.innerHTML = `\n ${getDismissButtonHtml({ key: \"dismiss\", text: options.dismissButtonText ?? \"Dismiss\" })}\n ${getTitleHtml(options.title)}\n ${getBodyHtml(options.body)}\n ${getButtonsHtml(options.buttons ?? [])}\n `;\n\n const buttonsElements = Array.from(prompt.querySelectorAll(\"button\"));\n merge(\n ...buttonsElements.map((b) => fromEvent(b, \"click\").pipe(map(() => b.dataset.key as Keys))),\n fromEvent(prompt, \"cancel\").pipe(map(() => \"dismiss\" as const))\n )\n .pipe(take(1))\n .subscribe({ next: res, complete: () => element.remove() });\n options.container.appendChild(element);\n prompt.showModal();\n });\n}\n"]}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Fast, simple hashing function from github.com/bryc
3
+ * https://github.com/bryc/code/blob/master/jshash/experimental/cyrb53.js
4
+ */
5
+ export declare const computeHash: (str: string) => string;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Fast, simple hashing function from github.com/bryc
3
+ * https://github.com/bryc/code/blob/master/jshash/experimental/cyrb53.js
4
+ */
5
+ export const computeHash = (str) => {
6
+ let h1 = 0xdeadbeef;
7
+ let h2 = 0x41c6ce57;
8
+ for (let i = 0; i < str.length; i++) {
9
+ const ch = str.charCodeAt(i);
10
+ h1 = Math.imul(h1 ^ ch, 2654435761);
11
+ h2 = Math.imul(h2 ^ ch, 1597334677);
12
+ }
13
+ h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^ Math.imul(h2 ^ (h2 >>> 13), 3266489909);
14
+ h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^ Math.imul(h1 ^ (h1 >>> 13), 3266489909);
15
+ return (4294967296 * (2097151 & h2) + (h1 >>> 0)).toString(16);
16
+ };
17
+ //# sourceMappingURL=hash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hash.js","sourceRoot":"","sources":["../../src/common/hash.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,GAAW,EAAU,EAAE;IAC/C,IAAI,EAAE,GAAG,UAAU,CAAC;IACpB,IAAI,EAAE,GAAG,UAAU,CAAC;IACpB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACjC,MAAM,EAAE,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAC7B,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,EAAE,UAAU,CAAC,CAAC;QACpC,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,EAAE,UAAU,CAAC,CAAC;KACvC;IACD,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,UAAU,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,UAAU,CAAC,CAAC;IACvF,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,UAAU,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,UAAU,CAAC,CAAC;IACvF,OAAO,CAAC,UAAU,GAAG,CAAC,OAAO,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AACnE,CAAC,CAAC","sourcesContent":["/**\n * Fast, simple hashing function from github.com/bryc\n * https://github.com/bryc/code/blob/master/jshash/experimental/cyrb53.js\n */\nexport const computeHash = (str: string): string => {\n let h1 = 0xdeadbeef;\n let h2 = 0x41c6ce57;\n for (let i = 0; i < str.length; i++) {\n const ch = str.charCodeAt(i);\n h1 = Math.imul(h1 ^ ch, 2654435761);\n h2 = Math.imul(h2 ^ ch, 1597334677);\n }\n h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^ Math.imul(h2 ^ (h2 >>> 13), 3266489909);\n h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^ Math.imul(h1 ^ (h1 >>> 13), 3266489909);\n return (4294967296 * (2097151 & h2) + (h1 >>> 0)).toString(16);\n};\n"]}
@@ -1 +1,6 @@
1
- export declare function loadScript(scriptUri: string): Promise<void>;
1
+ /**
2
+ * Adds script element to document body and starts downloading provided script URL.
3
+ * @param scriptUri Script URL.
4
+ * @returns Script element added.
5
+ */
6
+ export declare function loadScript(scriptUri: string): Promise<HTMLScriptElement>;
@@ -1,10 +1,17 @@
1
+ import { fromEvent, merge, take, tap } from "rxjs";
2
+ /**
3
+ * Adds script element to document body and starts downloading provided script URL.
4
+ * @param scriptUri Script URL.
5
+ * @returns Script element added.
6
+ */
1
7
  export function loadScript(scriptUri) {
2
8
  return new Promise((resolve, reject) => {
3
9
  const scriptElement = document.createElement("script");
4
10
  scriptElement.src = scriptUri;
5
11
  scriptElement.async = true;
6
- scriptElement.addEventListener("load", () => resolve(), { once: true });
7
- scriptElement.addEventListener("error", (event) => reject(event), { once: true });
12
+ merge(fromEvent(scriptElement, "load").pipe(tap(() => resolve(scriptElement))), fromEvent(scriptElement, "error").pipe(tap((e) => reject(e))))
13
+ .pipe(take(1))
14
+ .subscribe();
8
15
  document.body.appendChild(scriptElement);
9
16
  });
10
17
  }
@@ -1 +1 @@
1
- {"version":3,"file":"loadScript.js","sourceRoot":"","sources":["../../src/common/loadScript.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,UAAU,CAAC,SAAiB;IACxC,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACzC,MAAM,aAAa,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QACvD,aAAa,CAAC,GAAG,GAAG,SAAS,CAAC;QAC9B,aAAa,CAAC,KAAK,GAAG,IAAI,CAAC;QAC3B,aAAa,CAAC,gBAAgB,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QACxE,aAAa,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAClF,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["export function loadScript(scriptUri: string) {\n return new Promise<void>((resolve, reject) => {\n const scriptElement = document.createElement(\"script\");\n scriptElement.src = scriptUri;\n scriptElement.async = true;\n scriptElement.addEventListener(\"load\", () => resolve(), { once: true });\n scriptElement.addEventListener(\"error\", (event) => reject(event), { once: true });\n document.body.appendChild(scriptElement);\n });\n}\n"]}
1
+ {"version":3,"file":"loadScript.js","sourceRoot":"","sources":["../../src/common/loadScript.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEnD;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,SAAiB;IACxC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACnC,MAAM,aAAa,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QACvD,aAAa,CAAC,GAAG,GAAG,SAAS,CAAC;QAC9B,aAAa,CAAC,KAAK,GAAG,IAAI,CAAC;QAC3B,KAAK,CACD,SAAS,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,EACxE,SAAS,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAChE;aACI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;aACb,SAAS,EAAE,CAAC;QACjB,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import { fromEvent, merge, take, tap } from \"rxjs\";\n\n/**\n * Adds script element to document body and starts downloading provided script URL.\n * @param scriptUri Script URL.\n * @returns Script element added.\n */\nexport function loadScript(scriptUri: string): Promise<HTMLScriptElement> {\n return new Promise((resolve, reject) => {\n const scriptElement = document.createElement(\"script\");\n scriptElement.src = scriptUri;\n scriptElement.async = true;\n merge(\n fromEvent(scriptElement, \"load\").pipe(tap(() => resolve(scriptElement))),\n fromEvent(scriptElement, \"error\").pipe(tap((e) => reject(e)))\n )\n .pipe(take(1))\n .subscribe();\n document.body.appendChild(scriptElement);\n });\n}\n"]}
@@ -23,18 +23,10 @@
23
23
  *
24
24
  * See https://github.com/microsoft/TypeScript/pull/49552
25
25
  */
26
- /**
27
- * We use the en_US string object to define all localizable stringIds and their types (either a TemplateFunction or a
28
- * plain string).
29
- */
30
- type LocalizableStrings = typeof en_US;
31
26
  type TemplateFunction<K extends readonly string[], V extends {
32
27
  [key in K[number]]: string;
33
28
  }> = (values: V) => string;
34
- /**
35
- * Strings for each language are defined blow.
36
- */
37
- declare const en_US: {
29
+ interface LocalizableStrings {
38
30
  legalPromptMessage: TemplateFunction<readonly ["privacyPolicyUrl", "termsOfServiceUrl", "learnMoreUrl"], {
39
31
  privacyPolicyUrl: string;
40
32
  termsOfServiceUrl: string;
@@ -42,6 +34,21 @@ declare const en_US: {
42
34
  }>;
43
35
  legalPromptAccept: string;
44
36
  legalPromptReject: string;
45
- };
37
+ legalPromptTermsOfService: string;
38
+ legalPromptVariantGMessage: string;
39
+ legalPromptVariantGAdultOrChild: string;
40
+ legalPromptVariantGFindYourParent: string;
41
+ legalPromptVariantGIAmGuardian: string;
42
+ legalPromptVariantGCancel: string;
43
+ legalPromptVariantGAdult: string;
44
+ legalPromptVariantGChild: string;
45
+ }
46
+ /**
47
+ * The most closest locale with a translation.
48
+ */
49
+ export declare const supportedLocale: "en-US" | "ar" | "bn-BD" | "bn-IN" | "da-DK" | "de-DE" | "el-GR" | "en-GB" | "es" | "es-AR" | "es-ES" | "es-MX" | "fi-FI" | "fil-PH" | "fr-FR" | "gu-IN" | "hi-IN" | "id-ID" | "it-IT" | "ja-JP" | "kn-IN" | "ko-KR" | "ml-IN" | "mr-IN" | "ms-MY" | "nb-NO" | "nl-NL" | "pa" | "pl-PL" | "pt-BR" | "pt-PT" | "ro-RO" | "ru-RU" | "sv-SE" | "ta-IN" | "te-IN" | "th-TH" | "tr-TR" | "ur-PK" | "vi-VN" | "zh-Hans" | "zh-Hant";
50
+ /**
51
+ * Returns localized string by its ID.
52
+ */
46
53
  export declare function localizedString<ID extends keyof LocalizableStrings>(stringId: ID): LocalizableStrings[ID];
47
54
  export {};