@snap/camera-kit 1.0.1 → 1.1.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 (264) hide show
  1. package/README.md +1 -1
  2. package/dist/CameraKit.d.ts +4 -0
  3. package/dist/CameraKit.d.ts.map +1 -1
  4. package/dist/CameraKit.js +8 -2
  5. package/dist/CameraKit.js.map +1 -1
  6. package/dist/RootServices.d.ts +4 -2
  7. package/dist/RootServices.d.ts.map +1 -1
  8. package/dist/RootServices.js.map +1 -1
  9. package/dist/bootstrapCameraKit.d.ts.map +1 -1
  10. package/dist/bootstrapCameraKit.js +4 -2
  11. package/dist/bootstrapCameraKit.js.map +1 -1
  12. package/dist/clients/remoteApiSpecsClient.d.ts +10 -0
  13. package/dist/clients/remoteApiSpecsClient.d.ts.map +1 -0
  14. package/dist/clients/remoteApiSpecsClient.js +6 -0
  15. package/dist/clients/remoteApiSpecsClient.js.map +1 -0
  16. package/dist/common/typeguards.d.ts +3 -0
  17. package/dist/common/typeguards.d.ts.map +1 -1
  18. package/dist/common/typeguards.js +12 -0
  19. package/dist/common/typeguards.js.map +1 -1
  20. package/dist/configuration.d.ts +115 -0
  21. package/dist/configuration.d.ts.map +1 -1
  22. package/dist/configuration.js +1 -0
  23. package/dist/configuration.js.map +1 -1
  24. package/dist/environment.js +1 -1
  25. package/dist/environment.js.map +1 -1
  26. package/dist/index.d.ts +3 -3
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +3 -3
  29. package/dist/index.js.map +1 -1
  30. package/dist/lensCoreWasmVersions.js +3 -3
  31. package/dist/lensCoreWasmVersions.js.map +1 -1
  32. package/dist/session/LensKeyboard.d.ts +1 -1
  33. package/dist/session/LensKeyboard.d.ts.map +1 -1
  34. package/dist/session/LensKeyboard.js.map +1 -1
  35. package/dist/uri-handlers/UriHandlers.d.ts.map +1 -0
  36. package/dist/uri-handlers/UriHandlers.js.map +1 -0
  37. package/dist/uri-handlers/internal-handlers/httpUriHandler.d.ts +35 -0
  38. package/dist/uri-handlers/internal-handlers/httpUriHandler.d.ts.map +1 -0
  39. package/dist/uri-handlers/internal-handlers/httpUriHandler.js +144 -0
  40. package/dist/uri-handlers/internal-handlers/httpUriHandler.js.map +1 -0
  41. package/dist/uri-handlers/internal-handlers/httpValidators.d.ts +9 -0
  42. package/dist/uri-handlers/internal-handlers/httpValidators.d.ts.map +1 -0
  43. package/dist/uri-handlers/internal-handlers/httpValidators.js +115 -0
  44. package/dist/uri-handlers/internal-handlers/httpValidators.js.map +1 -0
  45. package/dist/{extensions/RemoteApiServices.d.ts → uri-handlers/internal-handlers/remoteApiUriHandler.d.ts} +8 -8
  46. package/dist/uri-handlers/internal-handlers/remoteApiUriHandler.d.ts.map +1 -0
  47. package/dist/uri-handlers/internal-handlers/remoteApiUriHandler.js +121 -0
  48. package/dist/uri-handlers/internal-handlers/remoteApiUriHandler.js.map +1 -0
  49. package/dist/{extensions → uri-handlers}/uriHandlersRegister.d.ts +6 -4
  50. package/dist/uri-handlers/uriHandlersRegister.d.ts.map +1 -0
  51. package/dist/{extensions → uri-handlers}/uriHandlersRegister.js +13 -3
  52. package/dist/uri-handlers/uriHandlersRegister.js.map +1 -0
  53. package/dist/uri-handlers/uriRequestProcessor.d.ts +37 -0
  54. package/dist/uri-handlers/uriRequestProcessor.d.ts.map +1 -0
  55. package/dist/uri-handlers/uriRequestProcessor.js +69 -0
  56. package/dist/uri-handlers/uriRequestProcessor.js.map +1 -0
  57. package/docs/html/assets/hierarchy.js +1 -0
  58. package/docs/html/assets/highlight.css +9 -2
  59. package/docs/html/assets/icons.js +18 -0
  60. package/docs/html/assets/icons.svg +1 -0
  61. package/docs/html/assets/main.js +5 -4
  62. package/docs/html/assets/navigation.js +1 -1
  63. package/docs/html/assets/search.js +1 -1
  64. package/docs/html/assets/style.css +1422 -1226
  65. package/docs/html/classes/CameraKit.html +18 -16
  66. package/docs/html/classes/CameraKitSession.html +76 -51
  67. package/docs/html/classes/CameraKitSource.html +18 -18
  68. package/docs/html/classes/LensPerformanceMeasurement.html +11 -11
  69. package/docs/html/classes/LensPerformanceMetrics.html +8 -7
  70. package/docs/html/classes/LensRepository.html +25 -23
  71. package/docs/html/classes/Transform2D.html +9 -9
  72. package/docs/html/classes/TypedCustomEvent.html +5 -4
  73. package/docs/html/classes/TypedEventTarget.html +6 -6
  74. package/docs/html/enums/Lens_CameraFacing.html +5 -5
  75. package/docs/html/functions/bootstrapCameraKit.html +11 -10
  76. package/docs/html/functions/createExtension.html +7 -6
  77. package/docs/html/functions/createImageSource.html +5 -5
  78. package/docs/html/functions/createMediaStreamSource.html +5 -5
  79. package/docs/html/functions/createVideoSource.html +5 -5
  80. package/docs/html/functions/estimateLensPerformance.html +2 -2
  81. package/docs/html/functions/filePickerFactory.html +2 -2
  82. package/docs/html/functions/lensSourcesFactory.html +5 -4
  83. package/docs/html/functions/remoteApiServicesFactory.html +1 -1
  84. package/docs/html/hierarchy.html +1 -1
  85. package/docs/html/index.html +111 -88
  86. package/docs/html/interfaces/BitmojiUserInfo.html +3 -3
  87. package/docs/html/interfaces/CameraKitBootstrapConfiguration.html +40 -21
  88. package/docs/html/interfaces/CameraKitDeviceOptions.html +7 -7
  89. package/docs/html/interfaces/CameraKitSourceInfo.html +7 -7
  90. package/docs/html/interfaces/CameraKitSourceSubscriber.html +4 -4
  91. package/docs/html/interfaces/ComputedFrameMetrics.html +6 -6
  92. package/docs/html/interfaces/CreateSessionOptions.html +7 -7
  93. package/docs/html/interfaces/EstimatedLensPerformance.html +5 -5
  94. package/docs/html/interfaces/Font.html +6 -0
  95. package/docs/html/interfaces/FriendUserInfo.html +4 -4
  96. package/docs/html/interfaces/FunctionSourceOptions.html +4 -4
  97. package/docs/html/interfaces/Lens.html +21 -21
  98. package/docs/html/interfaces/LensCreator.html +3 -3
  99. package/docs/html/interfaces/LensHttpRequest.html +16 -0
  100. package/docs/html/interfaces/LensLaunchData.html +6 -6
  101. package/docs/html/interfaces/LensSource.html +5 -5
  102. package/docs/html/interfaces/LensUserData.html +10 -10
  103. package/docs/html/interfaces/LoadAssetRequest.html +10 -10
  104. package/docs/html/interfaces/MediaStreamSourceOptions.html +11 -11
  105. package/docs/html/interfaces/Preview.html +4 -4
  106. package/docs/html/interfaces/RemoteApiRequest.html +10 -10
  107. package/docs/html/interfaces/RemoteApiResponse.html +8 -8
  108. package/docs/html/interfaces/RemoteApiService.html +9 -9
  109. package/docs/html/interfaces/Snapcode.html +6 -6
  110. package/docs/html/interfaces/UriCancelRequest.html +3 -3
  111. package/docs/html/interfaces/UriRequest.html +7 -7
  112. package/docs/html/interfaces/UriResponse.html +6 -6
  113. package/docs/html/interfaces/VideoSourceOptions.html +9 -9
  114. package/docs/html/modules.html +1 -99
  115. package/docs/html/types/ArgumentValidationError.html +2 -2
  116. package/docs/html/types/AssetLoader.html +4 -4
  117. package/docs/html/types/AssetResponse.html +1 -1
  118. package/docs/html/types/AssetTiming.html +2 -2
  119. package/docs/html/types/BenchmarkError.html +1 -1
  120. package/docs/html/types/BootstrapError.html +2 -2
  121. package/docs/html/types/CacheKeyNotFoundError.html +1 -1
  122. package/docs/html/types/CameraKitSessionEventListener.html +2 -2
  123. package/docs/html/types/CameraKitSessionEvents.html +4 -3
  124. package/docs/html/types/CameraKitSourceError.html +1 -1
  125. package/docs/html/types/ConfigurationError.html +2 -2
  126. package/docs/html/types/FetchHandler.html +1 -1
  127. package/docs/html/types/FilePicker.html +5 -5
  128. package/docs/html/types/FilePickerOptions.html +2 -2
  129. package/docs/html/types/FilePickerResult.html +2 -2
  130. package/docs/html/types/Keyboard.html +9 -16
  131. package/docs/html/types/KeyboardEvents.html +2 -2
  132. package/docs/html/types/LegalError.html +1 -1
  133. package/docs/html/types/LensAbortError.html +6 -5
  134. package/docs/html/types/LensAssetError.html +2 -2
  135. package/docs/html/types/LensContentValidationError.html +1 -1
  136. package/docs/html/types/LensError.html +1 -1
  137. package/docs/html/types/LensExecutionError.html +6 -5
  138. package/docs/html/types/LensHttpHandler.html +9 -0
  139. package/docs/html/types/LensImagePickerError.html +2 -2
  140. package/docs/html/types/LensLaunchParams.html +2 -2
  141. package/docs/html/types/LensMetricsEvents.html +2 -2
  142. package/docs/html/types/LensPerformanceCluster.html +1 -1
  143. package/docs/html/types/LensView.html +3 -3
  144. package/docs/html/types/LensWait.html +2 -2
  145. package/docs/html/types/Matrix.html +2 -2
  146. package/docs/html/types/PersistentStoreError.html +2 -2
  147. package/docs/html/types/PlatformNotSupportedError.html +3 -3
  148. package/docs/html/types/PublicContainer.html +2 -2
  149. package/docs/html/types/PublicServices.html +2 -2
  150. package/docs/html/types/RemoteApiCancelRequestHandler.html +2 -2
  151. package/docs/html/types/RemoteApiRequestHandler.html +2 -2
  152. package/docs/html/types/RemoteApiServices.html +1 -1
  153. package/docs/html/types/RemoteApiStatus.html +2 -2
  154. package/docs/html/types/RenderTarget.html +3 -3
  155. package/docs/html/types/Uri.html +1 -1
  156. package/docs/html/types/WebGLError.html +1 -1
  157. package/docs/html/types/Zodiac.html +1 -1
  158. package/docs/html/variables/extensionRequestContext.html +2 -2
  159. package/docs/md/README.md +5 -3
  160. package/docs/md/classes/CameraKit.md +26 -37
  161. package/docs/md/classes/CameraKitSession.md +146 -107
  162. package/docs/md/classes/CameraKitSource.md +46 -37
  163. package/docs/md/classes/LensPerformanceMeasurement.md +18 -26
  164. package/docs/md/classes/LensPerformanceMetrics.md +8 -10
  165. package/docs/md/classes/LensRepository.md +66 -45
  166. package/docs/md/classes/Transform2D.md +19 -26
  167. package/docs/md/classes/TypedCustomEvent.md +24 -32
  168. package/docs/md/classes/TypedEventTarget.md +43 -54
  169. package/docs/md/enumerations/Lens_CameraFacing.md +31 -0
  170. package/docs/md/functions/bootstrapCameraKit.md +66 -0
  171. package/docs/md/functions/createExtension.md +50 -0
  172. package/docs/md/functions/createImageSource.md +30 -0
  173. package/docs/md/functions/createMediaStreamSource.md +30 -0
  174. package/docs/md/functions/createVideoSource.md +31 -0
  175. package/docs/md/functions/estimateLensPerformance.md +18 -0
  176. package/docs/md/functions/filePickerFactory.md +22 -0
  177. package/docs/md/functions/lensSourcesFactory.md +37 -0
  178. package/docs/md/functions/remoteApiServicesFactory.md +19 -0
  179. package/docs/md/globals.md +121 -0
  180. package/docs/md/interfaces/BitmojiUserInfo.md +9 -12
  181. package/docs/md/interfaces/CameraKitBootstrapConfiguration.md +99 -40
  182. package/docs/md/interfaces/CameraKitDeviceOptions.md +11 -17
  183. package/docs/md/interfaces/CameraKitSourceInfo.md +14 -20
  184. package/docs/md/interfaces/CameraKitSourceSubscriber.md +23 -28
  185. package/docs/md/interfaces/ComputedFrameMetrics.md +13 -19
  186. package/docs/md/interfaces/CreateSessionOptions.md +10 -13
  187. package/docs/md/interfaces/EstimatedLensPerformance.md +10 -14
  188. package/docs/md/interfaces/Font.md +25 -0
  189. package/docs/md/interfaces/FriendUserInfo.md +12 -16
  190. package/docs/md/interfaces/FunctionSourceOptions.md +6 -8
  191. package/docs/md/interfaces/Lens.md +26 -37
  192. package/docs/md/interfaces/LensCreator.md +6 -8
  193. package/docs/md/interfaces/LensHttpRequest.md +60 -0
  194. package/docs/md/interfaces/LensLaunchData.md +13 -17
  195. package/docs/md/interfaces/LensSource.md +26 -27
  196. package/docs/md/interfaces/LensUserData.md +30 -40
  197. package/docs/md/interfaces/LoadAssetRequest.md +13 -18
  198. package/docs/md/interfaces/MediaStreamSourceOptions.md +15 -22
  199. package/docs/md/interfaces/Preview.md +6 -8
  200. package/docs/md/interfaces/RemoteApiRequest.md +12 -17
  201. package/docs/md/interfaces/RemoteApiResponse.md +10 -14
  202. package/docs/md/interfaces/RemoteApiService.md +20 -19
  203. package/docs/md/interfaces/Snapcode.md +8 -11
  204. package/docs/md/interfaces/UriCancelRequest.md +7 -10
  205. package/docs/md/interfaces/UriRequest.md +15 -22
  206. package/docs/md/interfaces/UriResponse.md +14 -20
  207. package/docs/md/interfaces/VideoSourceOptions.md +13 -19
  208. package/docs/md/type-aliases/ArgumentValidationError.md +11 -0
  209. package/docs/md/type-aliases/AssetLoader.md +26 -0
  210. package/docs/md/type-aliases/AssetResponse.md +9 -0
  211. package/docs/md/type-aliases/AssetTiming.md +18 -0
  212. package/docs/md/type-aliases/BenchmarkError.md +9 -0
  213. package/docs/md/type-aliases/BootstrapError.md +12 -0
  214. package/docs/md/type-aliases/CacheKeyNotFoundError.md +9 -0
  215. package/docs/md/type-aliases/CameraKitSessionEventListener.md +11 -0
  216. package/docs/md/type-aliases/CameraKitSessionEvents.md +17 -0
  217. package/docs/md/type-aliases/CameraKitSourceError.md +9 -0
  218. package/docs/md/type-aliases/ConfigurationError.md +11 -0
  219. package/docs/md/type-aliases/FetchHandler.md +27 -0
  220. package/docs/md/type-aliases/FilePicker.md +32 -0
  221. package/docs/md/type-aliases/FilePickerOptions.md +11 -0
  222. package/docs/md/type-aliases/FilePickerResult.md +11 -0
  223. package/docs/md/type-aliases/Keyboard.md +114 -0
  224. package/docs/md/type-aliases/KeyboardEvents.md +11 -0
  225. package/docs/md/type-aliases/LegalError.md +9 -0
  226. package/docs/md/type-aliases/LensAbortError.md +22 -0
  227. package/docs/md/type-aliases/LensAssetError.md +11 -0
  228. package/docs/md/type-aliases/LensContentValidationError.md +9 -0
  229. package/docs/md/type-aliases/LensError.md +9 -0
  230. package/docs/md/type-aliases/LensExecutionError.md +23 -0
  231. package/docs/md/type-aliases/LensHttpHandler.md +41 -0
  232. package/docs/md/type-aliases/LensImagePickerError.md +12 -0
  233. package/docs/md/type-aliases/LensLaunchParams.md +11 -0
  234. package/docs/md/type-aliases/LensMetricsEvents.md +13 -0
  235. package/docs/md/type-aliases/LensPerformanceCluster.md +9 -0
  236. package/docs/md/type-aliases/LensView.md +21 -0
  237. package/docs/md/type-aliases/LensWait.md +13 -0
  238. package/docs/md/type-aliases/Matrix.md +12 -0
  239. package/docs/md/type-aliases/PersistentStoreError.md +11 -0
  240. package/docs/md/type-aliases/PlatformNotSupportedError.md +13 -0
  241. package/docs/md/type-aliases/PublicContainer.md +12 -0
  242. package/docs/md/type-aliases/PublicServices.md +11 -0
  243. package/docs/md/type-aliases/RemoteApiCancelRequestHandler.md +15 -0
  244. package/docs/md/type-aliases/RemoteApiRequestHandler.md +24 -0
  245. package/docs/md/type-aliases/RemoteApiServices.md +9 -0
  246. package/docs/md/type-aliases/RemoteApiStatus.md +11 -0
  247. package/docs/md/type-aliases/RenderTarget.md +14 -0
  248. package/docs/md/type-aliases/Uri.md +9 -0
  249. package/docs/md/type-aliases/WebGLError.md +9 -0
  250. package/docs/md/type-aliases/Zodiac.md +9 -0
  251. package/docs/md/variables/extensionRequestContext.md +11 -0
  252. package/package.json +5 -5
  253. package/dist/extensions/RemoteApiServices.d.ts.map +0 -1
  254. package/dist/extensions/RemoteApiServices.js +0 -159
  255. package/dist/extensions/RemoteApiServices.js.map +0 -1
  256. package/dist/extensions/UriHandlers.d.ts.map +0 -1
  257. package/dist/extensions/UriHandlers.js.map +0 -1
  258. package/dist/extensions/uriHandlersRegister.d.ts.map +0 -1
  259. package/dist/extensions/uriHandlersRegister.js.map +0 -1
  260. package/docs/md/.nojekyll +0 -1
  261. package/docs/md/enums/Lens_CameraFacing.md +0 -36
  262. package/docs/md/modules.md +0 -904
  263. /package/dist/{extensions → uri-handlers}/UriHandlers.d.ts +0 -0
  264. /package/dist/{extensions → uri-handlers}/UriHandlers.js +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"httpValidators.js","sourceRoot":"","sources":["../../../src/uri-handlers/internal-handlers/httpValidators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAE,gCAAgC,EAAE,MAAM,+DAA+D,CAAC;AACjH,OAAO,EAAE,iCAAiC,EAAE,MAAM,+DAA+D,CAAC;AAClH,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C,MAAM,CAAC,MAAM,0BAA0B,GAAG,wBAAwB,CAAC;AACnE,MAAM,CAAC,MAAM,sB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GAAG,CAAC,GAAG,CAAC,CAAC;IACzB,MAAM,WAAW,GAAG,IAAI,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACpD,KAAK,MAAM,KAAK,IAAI,UAAU,EAAE;QAC5B,IAAI,KAAK,CAAC,QAAQ,KAAK,iCAAiC,CAAC,KAAK;YAAE,SAAS;QAEzE,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAE/C,IAAI,KAAK,CAAC,QAAQ,EAAE;YAEhB,IAAI,UAAU,KAAK,KAAK,CAAC,YAAY,EAAE;gBACnC,MAAM,sBAAsB,CACxB,sCAAsC,KAAK,CAAC,IAAI,iBAAiB,KAAK,CAAC,YAAY,KAAK;oBACpF,cAAc,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,WAAW,IAAI,CAClD,CAAC;aACL;SACJ;aAAM,IAAI,KAAK,CAAC,QAAQ,EAAE;YAEvB,IAAI,UAAU,IAAI,SAAS,IAAI,aAAa,CAAC,UAAU,CAAC,EAAE;gBACtD,MAAM,sBAAsB,CACxB,6BAA6B,KAAK,CAAC,IAAI,0BAA0B;oBAC7D,sCAAsC,CAC7C,CAAC;aACL;SACJ;aAAM;YAEH,IAAI,UAAU,IAAI,SAAS,IAAI,aAAa,CAAC,UAAU,CAAC,EAAE;gBACtD,MAAM,sBAAsB,CAAC,6BAA6B,KAAK,CAAC,IAAI,wBAAwB,CAAC,CAAC;aACjG;SACJ;KACJ;AAEL,CAAC","sourcesContent":["import { isEmptyString } from \"../../common/typeguards\";\nimport type { RemoteApiSpec, RemoteParameter } from \"../../generated-proto/pb_schema/camera_kit/v3/remote_api_spec\";\nimport { RemoteEndpoint_HttpRequestMethod } from \"../../generated-proto/pb_schema/camera_kit/v3/remote_api_spec\";\nimport { RemoteParameter_ParameterLocation } from \"../../generated-proto/pb_schema/camera_kit/v3/remote_api_spec\";\nimport { namedError } from \"../../namedErrors\";\nimport type { UriRequest } from \"../UriHandlers\";\n\nexport const requestValidationErrorName = \"RequestValidationError\";\nexport const requestValidationError = namedError(requestValidationErrorName);\n\nexport function validateRequest(request: UriRequest, specs: RemoteApiSpec[]) {\n // 1. Given url, method and headers and spec:\n for (const spec of specs) {\n const url = `${spec.tlsRequired ? \"https://\" : \"http://\"}${spec.host}`;\n // 2. Check url starts with schema + the host. If yes trim that part and split by /\n if (!request.uri.startsWith(url)) continue;\n\n // 3. Split the rest by / and go for each part together with the path parameters.\n const path = (request.uri.split(url)[1] ?? \"\").replace(/^\\//, \"\").replace(/\\/$/, \"\");\n for (const endpoint of spec.endpoints) {\n const endpointPath = endpoint.path.replace(/^\\//, \"\").replace(/\\/$/, \"\");\n if (!path.startsWith(endpointPath)) continue;\n\n const method =\n RemoteEndpoint_HttpRequestMethod[request.method] ?? RemoteEndpoint_HttpRequestMethod.UNRECOGNIZED;\n if (!endpoint.methods.includes(method)) continue;\n\n validatePath(path.split(endpointPath)[1] ?? \"\", endpoint.parameters);\n validateHeaders(request.metadata, endpoint.parameters);\n validateQuery(request.uri, endpoint.parameters);\n // The request matches the current endpoint\n return;\n }\n }\n\n // The request does not match any of the endpoints\n throw requestValidationError(\"The request does not match any of the Remote API specifications.\");\n}\n\nexport function validatePath(path: string, parameters: RemoteParameter[]) {\n const pathComponents = path.split(\"/\").filter(Boolean);\n\n let paramIndex = 0;\n\n for (const param of parameters) {\n if (param.location !== RemoteParameter_ParameterLocation.PATH) continue;\n\n const paramNameComponent = pathComponents[paramIndex];\n const paramValueComponent = pathComponents[paramIndex + 1];\n\n if (param.constant) {\n // For constant parameters, the value must match the defaultValue\n if (paramNameComponent === param.name && paramValueComponent === param.defaultValue) {\n paramIndex += 2; // Move to the next parameter pair\n } else {\n throw requestValidationError(\n `Expected constant parameter '${param.name}' with value '${param.defaultValue}' ` +\n `at position ${paramIndex}, but found '${paramNameComponent}' and '${paramValueComponent}'.`\n );\n }\n } else if (param.optional) {\n if (paramNameComponent === param.name) {\n paramIndex += 2; // Move to the next parameter pair if optional parameter exists\n }\n // If optional and not present, continue without incrementing paramIndex\n } else {\n // For regular parameters, we just need to ensure a name/value pair exists\n if (paramNameComponent === param.name && paramValueComponent !== undefined) {\n paramIndex += 2; // Move to the next parameter pair\n } else {\n throw requestValidationError(\n `Expected parameter '${param.name}' with a value at position ${paramIndex}, ` +\n `but found '${paramNameComponent}' and '${paramValueComponent}'.`\n );\n }\n }\n }\n\n // After processing all parameters, there should be no extra path components\n if (paramIndex !== pathComponents.length) {\n const invalidPath = pathComponents.slice(paramIndex).join(\"/\");\n throw requestValidationError(\n `Unexpected extra path components starting at position ${paramIndex}: '${invalidPath}'.`\n );\n }\n}\n\nexport function validateHeaders(headers: Record<string, string>, parameters: RemoteParameter[]) {\n for (const param of parameters) {\n if (param.location !== RemoteParameter_ParameterLocation.HEADER) continue;\n\n const headerValue = headers[param.name];\n\n if (param.constant) {\n // For constant parameters, the header must exist and match defaultValue\n if (headerValue !== param.defaultValue) {\n throw requestValidationError(\n `Expected constant header '${param.name}' with value '${param.defaultValue}', ` +\n `but found '${headerValue ?? \"undefined\"}'.`\n );\n }\n } else if (param.optional) {\n // If optional, we only validate if the header exists\n if (headerValue != undefined && isEmptyString(headerValue)) {\n throw requestValidationError(\n `Header '${param.name}' is present but empty. If provided, it should not be empty.`\n );\n }\n } else {\n // For regular parameters, the header must exist and have a non-empty value\n if (headerValue == undefined || isEmptyString(headerValue)) {\n throw requestValidationError(`Required header '${param.name}' is missing or empty.`);\n }\n }\n }\n}\n\nexport function validateQuery(uri: string, parameters: RemoteParameter[]) {\n const url = new URL(uri);\n const queryParams = new URLSearchParams(url.search);\n for (const param of parameters) {\n if (param.location !== RemoteParameter_ParameterLocation.QUERY) continue;\n\n const paramValue = queryParams.get(param.name);\n\n if (param.constant) {\n // For constant parameters, the query parameter must exist and match defaultValue\n if (paramValue !== param.defaultValue) {\n throw requestValidationError(\n `Expected constant query parameter '${param.name}' with value '${param.defaultValue}', ` +\n `but found '${paramValue ?? \"undefined\"}'.`\n );\n }\n } else if (param.optional) {\n // If optional, validate only if the query parameter exists\n if (paramValue != undefined && isEmptyString(paramValue)) {\n throw requestValidationError(\n `Optional query parameter '${param.name}' is present but empty. ` +\n `If provided, it should not be empty.`\n );\n }\n } else {\n // For regular parameters, the query parameter must exist and have a non-empty value\n if (paramValue == undefined || isEmptyString(paramValue)) {\n throw requestValidationError(`Required query parameter '${param.name}' is missing or empty.`);\n }\n }\n }\n // All query parameters are valid\n}\n"]}
@@ -1,9 +1,9 @@
1
- import type { LensRepository } from "../lens/LensRepository";
2
- import type { Lens } from "../lens/Lens";
3
- import type { LensState } from "../session/lensState";
4
- import type { SessionState } from "../session/sessionState";
5
- import type { MetricsClient } from "../clients/metricsClient";
6
- import type { UriHandler } from "./UriHandlers";
1
+ import type { LensRepository } from "../../lens/LensRepository";
2
+ import type { Lens } from "../../lens/Lens";
3
+ import type { LensState } from "../../session/lensState";
4
+ import type { SessionState } from "../../session/sessionState";
5
+ import type { MetricsClient } from "../../clients/metricsClient";
6
+ import type { UriHandler } from "../UriHandlers";
7
7
  /**
8
8
  * Status of a Remote API response.
9
9
  */
@@ -84,5 +84,5 @@ export declare const remoteApiServicesFactory: {
84
84
  * Provides a URI handler that searches for a match within the provided services to handle Remote API requests,
85
85
  * i.e., those whose URI starts with 'app://remote-api/performApiRequest'.
86
86
  */
87
- export declare function getRemoteApiUriHandler(registeredServices: RemoteApiService[], sessionState: SessionState, lensState: LensState, lensRepository: LensRepository, metrics: MetricsClient): UriHandler;
88
- //# sourceMappingURL=RemoteApiServices.d.ts.map
87
+ export declare function createRemoteApiUriHandler(registeredServices: RemoteApiService[], sessionState: SessionState, lensState: LensState, lensRepository: LensRepository, metrics: MetricsClient): UriHandler;
88
+ //# sourceMappingURL=remoteApiUriHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remoteApiUriHandler.d.ts","sourceRoot":"","sources":["../../../src/uri-handlers/internal-handlers/remoteApiUriHandler.ts"],"names":[],"mappings":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AAC;IAElB;;;;;;OAMG;IACH,iBAAiB,CAAC,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,IAAI,GAAG,uBAAuB,GAAG,SAAS,CAAC;CACjG;AAED,MAAM,MAAM,iBAAiB,GAAG,gBAAgB,EAAE,CAAC;AAEnD,eAAO,MAAM,wBAAwB;;;;CAGnC,CAAC;AAEH;;;GAGG;AACH,wBAAgB,yBAAyB,CACrC,kBAAkB,EAAE,gBAAgB,EAAE,EACtC,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,aAAa,GACvB,UAAU,CAiHZ"}
@@ -0,0 +1,121 @@
1
+ import { Injectable } from "@snap/ts-inject";
2
+ import { RemoteApiInfo } from "../../generated-proto/pb_schema/camera_kit/v3/features/remote_api_info";
3
+ import { ResponseCode, responseCodeToNumber, } from "../../generated-proto/pb_schema/lenses/remote_api/remote_api_service";
4
+ import { getLogger } from "../../logger/logger";
5
+ import { Count } from "../../metrics/operational/Count";
6
+ import { joinMetricNames } from "../../metrics/operational/Metric";
7
+ import { createUriRequestProcessor } from "../uriRequestProcessor";
8
+ import { extractSchemeAndRoute } from "../UriHandlers";
9
+ const logger = getLogger("RemoteApiServices");
10
+ const uriResponseOkCode = 200;
11
+ const apiResponseStatusHeader = ":sc_lens_api_status";
12
+ const apiBinaryContentType = "application/octet-stream";
13
+ const remoteApiInfoProtobufTypeUrl = "type.googleapis.com/com.snap.camerakit.v3.features.RemoteApiInfo";
14
+ const remoteApiUploadImageSpecId = "af3f69c8-2e62-441f-8b1c-d3956f7b336c";
15
+ const statusToResponseCodeMap = {
16
+ success: ResponseCode.SUCCESS,
17
+ redirected: ResponseCode.REDIRECTED,
18
+ badRequest: ResponseCode.BAD_REQUEST,
19
+ accessDenied: ResponseCode.ACCESS_DENIED,
20
+ notFound: ResponseCode.NOT_FOUND,
21
+ timeout: ResponseCode.TIMEOUT,
22
+ requestTooLarge: ResponseCode.REQUEST_TOO_LARGE,
23
+ serverError: ResponseCode.SERVER_ERROR,
24
+ cancelled: ResponseCode.CANCELLED,
25
+ proxyError: ResponseCode.PROXY_ERROR,
26
+ };
27
+ export const remoteApiServicesFactory = Injectable("remoteApiServices", () => {
28
+ const remoteApiServices = [];
29
+ return remoteApiServices;
30
+ });
31
+ export function createRemoteApiUriHandler(registeredServices, sessionState, lensState, lensRepository, metrics) {
32
+ const registeredServiceMap = new Map();
33
+ for (const service of registeredServices) {
34
+ const existingServices = registeredServiceMap.get(service.apiSpecId) || [];
35
+ registeredServiceMap.set(service.apiSpecId, [...existingServices, service]);
36
+ }
37
+ return createUriRequestProcessor({
38
+ uri: "app://remote-api/performApiRequest",
39
+ lensState,
40
+ sessionState,
41
+ createLensRequestState(_request, lens) {
42
+ var _a, _b;
43
+ return {
44
+ supportedSpecIds: new Set([
45
+ ...((_b = (_a = lensRepository.getLensMetadata(lens.id)) === null || _a === void 0 ? void 0 : _a.featureMetadata) !== null && _b !== void 0 ? _b : [])
46
+ .filter((feature) => feature.typeUrl === remoteApiInfoProtobufTypeUrl)
47
+ .flatMap((any) => RemoteApiInfo.decode(any.value).apiSpecIds),
48
+ remoteApiUploadImageSpecId,
49
+ ]),
50
+ };
51
+ },
52
+ processRequest({ request, reply, lens, setCancellationHandler, state }) {
53
+ var _a;
54
+ const { route } = extractSchemeAndRoute(request.uri);
55
+ const [specId, endpointIdWithQuery] = route.split("/").slice(2);
56
+ const [endpointId] = endpointIdWithQuery.split("?");
57
+ if (!(state === null || state === void 0 ? void 0 : state.supportedSpecIds.has(specId)))
58
+ return;
59
+ if (!registeredServiceMap.has(specId))
60
+ return;
61
+ const dimensions = { specId };
62
+ const reportSingleCount = (name) => {
63
+ metrics.setOperationalMetrics(Count.count(joinMetricNames(["lens", "remote-api", name]), 1, dimensions));
64
+ };
65
+ reportSingleCount("requests");
66
+ const remoteApiRequest = {
67
+ apiSpecId: specId,
68
+ body: request.data,
69
+ endpointId,
70
+ parameters: request.metadata,
71
+ };
72
+ for (const service of (_a = registeredServiceMap.get(specId)) !== null && _a !== void 0 ? _a : []) {
73
+ let requestHandler = undefined;
74
+ try {
75
+ requestHandler = service.getRequestHandler(remoteApiRequest, lens);
76
+ }
77
+ catch (error) {
78
+ logger.warn("Client's Remote API request handler factory threw an error.", error);
79
+ }
80
+ if (requestHandler) {
81
+ reportSingleCount("handled-requests");
82
+ let cancellationHandler = undefined;
83
+ try {
84
+ cancellationHandler = requestHandler((response) => {
85
+ var _a;
86
+ reportSingleCount("responses");
87
+ const responseCode = (_a = statusToResponseCodeMap[response.status]) !== null && _a !== void 0 ? _a : ResponseCode.UNRECOGNIZED;
88
+ const uriResponse = {
89
+ code: uriResponseOkCode,
90
+ description: "",
91
+ contentType: apiBinaryContentType,
92
+ data: response.body,
93
+ metadata: Object.assign(Object.assign({}, response.metadata), { [apiResponseStatusHeader]: responseCodeToNumber(responseCode).toString() }),
94
+ };
95
+ reply(uriResponse);
96
+ });
97
+ }
98
+ catch (error) {
99
+ logger.warn("Client's Remote API request handler threw an error.", error);
100
+ }
101
+ if (typeof cancellationHandler === "function") {
102
+ setCancellationHandler(() => {
103
+ try {
104
+ cancellationHandler();
105
+ }
106
+ catch (error) {
107
+ logger.warn("Client's Remote API request cancellation handler threw an error.", error);
108
+ }
109
+ });
110
+ }
111
+ break;
112
+ }
113
+ }
114
+ },
115
+ processInternalError(error) {
116
+ logger.error(error);
117
+ metrics.setOperationalMetrics(Count.count(joinMetricNames(["lens", "remote-api", "errors"]), 1));
118
+ },
119
+ });
120
+ }
121
+ //# sourceMappingURL=remoteApiUriHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remoteApiUriHandler.js","sourceRoot":"","sources":["../../../src/uri-handlers/internal-handlers/remoteApiUriHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,wEAAwE,CAAC;AACvG,OAAO,E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YAAY,GAAG,MAAA,uBAAuB,CAAC,QAAQ,CAAC,MAAM,CAAC,mCAAI,YAAY,CAAC,YAAY,CAAC;4BAC3F,MAAM,WAAW,GAAgB;gCAC7B,IAAI,EAAE,iBAAiB;gCACvB,WAAW,EAAE,EAAE;gCACf,WAAW,EAAE,oBAAoB;gCACjC,IAAI,EAAE,QAAQ,CAAC,IAAI;gCACnB,QAAQ,kCACD,QAAQ,CAAC,QAAQ,KACpB,CAAC,uBAAuB,CAAC,EAAE,oBAAoB,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE,GAC3E;6BACJ,CAAC;4BACF,KAAK,CAAC,WAAW,CAAC,CAAC;wBACvB,CAAC,CAAC,CAAC;qBACN;oBAAC,OAAO,KAAK,EAAE;wBACZ,MAAM,CAAC,IAAI,CAAC,qDAAqD,EAAE,KAAK,CAAC,CAAC;qBAC7E;oBAED,IAAI,OAAO,mBAAmB,KAAK,UAAU,EAAE;wBAC3C,sBAAsB,CAAC,GAAG,EAAE;4BACxB,IAAI;gCACA,mBAAoB,EAAE,CAAC;6BAC1B;4BAAC,OAAO,KAAK,EAAE;gCACZ,MAAM,CAAC,IAAI,CAAC,kEAAkE,EAAE,KAAK,CAAC,CAAC;6BAC1F;wBACL,CAAC,CAAC,CAAC;qBACN;oBAED,MAAM;iBACT;aACJ;QACL,CAAC;QACD,oBAAoB,CAAC,KAAK;YAItB,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACpB,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QACrG,CAAC;KACJ,CAAC,CAAC;AACP,CAAC","sourcesContent":["import { Injectable } from \"@snap/ts-inject\";\nimport { RemoteApiInfo } from \"../../generated-proto/pb_schema/camera_kit/v3/features/remote_api_info\";\nimport {\n ResponseCode,\n responseCodeToNumber,\n} from \"../../generated-proto/pb_schema/lenses/remote_api/remote_api_service\";\nimport type { LensRepository } from \"../../lens/LensRepository\";\nimport type { Lens } from \"../../lens/Lens\";\nimport type { LensState } from \"../../session/lensState\";\nimport type { SessionState } from \"../../session/sessionState\";\nimport { getLogger } from \"../../logger/logger\";\nimport type { EnumToPublicStringLiteralMap, ExcludeKeys } from \"../../common/types\";\nimport type { MetricsClient } from \"../../clients/metricsClient\";\nimport { Count } from \"../../metrics/operational/Count\";\nimport { joinMetricNames } from \"../../metrics/operational/Metric\";\nimport { createUriRequestProcessor } from \"../uriRequestProcessor\";\nimport type { UriHandler, UriResponse } from \"../UriHandlers\";\nimport { extractSchemeAndRoute } from \"../UriHandlers\";\n\n// NOTE: There's potential for overloads when reporting metrics if reporting is triggered on each frame,\n// (i.e., when the lens sends Remote API requests every frame).\n// As of now, this isn't a concern because src/metrics/operational/operationalMetricsReporter.ts aggregates\n// \"count\" metrics into a single metric within a batch, and the Remote API service currently\n// reports only \"count\" metrics. For instance, if 30 metrics with the same name are generated per second,\n// given the current bundle size of 100 operational metrics, there will be one metrics report approximately\n// every 3.3 seconds.\n// In the future, if we opt to report \"histogram\" or other metric types, they must be approached with caution:\n// either the operationalMetricsReporter should be enhanced to aggregate such metrics,\n// or the Remote API service should manage it directly.\n// Mobiles ticket: https://jira.sc-corp.net/browse/CAMKIT-3092\n\nconst logger = getLogger(\"RemoteApiServices\");\n\nconst uriResponseOkCode = 200;\nconst apiResponseStatusHeader = \":sc_lens_api_status\";\nconst apiBinaryContentType = \"application/octet-stream\";\nconst remoteApiInfoProtobufTypeUrl = \"type.googleapis.com/com.snap.camerakit.v3.features.RemoteApiInfo\";\nconst remoteApiUploadImageSpecId = \"af3f69c8-2e62-441f-8b1c-d3956f7b336c\";\n\nconst statusToResponseCodeMap: ExcludeKeys<\n EnumToPublicStringLiteralMap<typeof ResponseCode>,\n \"responseCodeUnset\" | \"unrecognized\"\n> = {\n success: ResponseCode.SUCCESS,\n redirected: ResponseCode.REDIRECTED,\n badRequest: ResponseCode.BAD_REQUEST,\n accessDenied: ResponseCode.ACCESS_DENIED,\n notFound: ResponseCode.NOT_FOUND,\n timeout: ResponseCode.TIMEOUT,\n requestTooLarge: ResponseCode.REQUEST_TOO_LARGE,\n serverError: ResponseCode.SERVER_ERROR,\n cancelled: ResponseCode.CANCELLED,\n proxyError: ResponseCode.PROXY_ERROR,\n // NOTE: This rule helps keep the public-facing RemoteApiStatus type consistent with the proto.\n // We prefer using a separate type for TypeDoc purposes.\n} satisfies Record<RemoteApiStatus, ResponseCode>;\n\n/**\n * Status of a Remote API response.\n */\nexport type RemoteApiStatus =\n | \"success\"\n | \"redirected\"\n | \"badRequest\"\n | \"accessDenied\"\n | \"notFound\"\n | \"timeout\"\n | \"requestTooLarge\"\n | \"serverError\"\n | \"cancelled\"\n | \"proxyError\";\n\n/**\n * Remote API request sent by a lens.\n */\nexport interface RemoteApiRequest {\n /**\n * Unique id of the remote API service specification.\n */\n apiSpecId: string;\n /**\n * Unique id of the remote API service endpoint requested by this request.\n */\n endpointId: string;\n /**\n * A map of named parameters associated with the request.\n */\n parameters: Record<string, string>;\n /**\n * Additional binary request payload.\n */\n body: ArrayBuffer;\n}\n\n/**\n * Remote API response to a request sent by a lens.\n */\nexport interface RemoteApiResponse {\n /**\n * Status of the response\n */\n status: RemoteApiStatus;\n /**\n * A map of named metadata associated with the response.\n */\n metadata: Record<string, string>;\n /**\n * Additional binary request payload.\n */\n body: ArrayBuffer;\n}\n\n/**\n * Represents a Remote API request cancellation handler function.\n */\nexport type RemoteApiCancelRequestHandler = () => void;\n\n/**\n * Represents a Remote API request handler function.\n * It is provided with a reply callback that must be invoked to send a response back to the lens.\n * The reply callback can be invoked multiple times if needed.\n * Additionally, the handler can return a cancellation callback, which is triggered when the lens cancels the request.\n */\nexport type RemoteApiRequestHandler = (\n reply: (response: RemoteApiResponse) => void\n) => RemoteApiCancelRequestHandler | void;\n\n/**\n * Service to handle a lens Remote API request.\n */\nexport interface RemoteApiService {\n /**\n * Remote API spec ID(s).\n */\n apiSpecId: string;\n\n /**\n * This method is called by Camera Kit when a lens triggers a Remote API request with a corresponding spec ID.\n * If the service can handle the request, the method returns a request handler; otherwise, it returns nothing.\n * @param request Remote API request object.\n * @param lens Lens that triggers the request.\n * @returns A request handler if applicable.\n */\n getRequestHandler(request: RemoteApiRequest, lens: Lens): RemoteApiRequestHandler | undefined;\n}\n\nexport type RemoteApiServices = RemoteApiService[];\n\nexport const remoteApiServicesFactory = Injectable(\"remoteApiServices\", () => {\n const remoteApiServices: RemoteApiServices = [];\n return remoteApiServices;\n});\n\n/**\n * Provides a URI handler that searches for a match within the provided services to handle Remote API requests,\n * i.e., those whose URI starts with 'app://remote-api/performApiRequest'.\n */\nexport function createRemoteApiUriHandler(\n registeredServices: RemoteApiService[],\n sessionState: SessionState,\n lensState: LensState,\n lensRepository: LensRepository,\n metrics: MetricsClient\n): UriHandler {\n // Groups services by spec ID for faster lookups.\n const registeredServiceMap = new Map<string, RemoteApiService[]>();\n for (const service of registeredServices) {\n const existingServices = registeredServiceMap.get(service.apiSpecId) || [];\n registeredServiceMap.set(service.apiSpecId, [...existingServices, service]);\n }\n\n return createUriRequestProcessor({\n uri: \"app://remote-api/performApiRequest\",\n lensState,\n sessionState,\n createLensRequestState(_request, lens) {\n return {\n supportedSpecIds: new Set([\n // Parse lens metadata to obtain supported Remote API specs.\n ...(lensRepository.getLensMetadata(lens.id)?.featureMetadata ?? [])\n .filter((feature) => feature.typeUrl === remoteApiInfoProtobufTypeUrl)\n .flatMap((any) => RemoteApiInfo.decode(any.value).apiSpecIds),\n // Also add remoteApiUploadImageSpecId as this spec should be available for all lenses.\n // See https://jira.sc-corp.net/browse/CAMKIT-6245.\n remoteApiUploadImageSpecId,\n ]),\n };\n },\n processRequest({ request, reply, lens, setCancellationHandler, state }) {\n // Extracts the spec ID and endpoint ID from the provided Remote API request URI.\n // The given URI is expected to conform to the following specification:\n // eslint-disable-next-line max-len\n // https://docs.google.com/document/d/18fbGYDhD2N_aMTe4ZLY4QKeCSoMeJuklG28TutDzLZc/edit#bookmark=id.p2y39gwgbm4g\n const { route } = extractSchemeAndRoute(request.uri);\n const [specId, endpointIdWithQuery] = route.split(\"/\").slice(2);\n const [endpointId] = endpointIdWithQuery.split(\"?\");\n\n // only handle requests for API spec ID that current lens supports\n if (!state?.supportedSpecIds.has(specId)) return;\n\n // only handle requests if we have a registered service for it\n if (!registeredServiceMap.has(specId)) return;\n\n const dimensions = { specId };\n const reportSingleCount = (name: string) => {\n metrics.setOperationalMetrics(\n Count.count(joinMetricNames([\"lens\", \"remote-api\", name]), 1, dimensions)\n );\n };\n\n reportSingleCount(\"requests\");\n\n const remoteApiRequest: RemoteApiRequest = {\n apiSpecId: specId,\n body: request.data,\n endpointId,\n parameters: request.metadata,\n };\n\n // Looks for the first Remote API request handler.\n for (const service of registeredServiceMap.get(specId) ?? []) {\n let requestHandler: RemoteApiRequestHandler | undefined = undefined;\n try {\n requestHandler = service.getRequestHandler(remoteApiRequest, lens);\n } catch (error) {\n logger.warn(\"Client's Remote API request handler factory threw an error.\", error);\n }\n\n if (requestHandler) {\n reportSingleCount(\"handled-requests\");\n\n let cancellationHandler: RemoteApiCancelRequestHandler | void = undefined;\n try {\n // Calls client's Remote API handler to process the request.\n cancellationHandler = requestHandler((response) => {\n reportSingleCount(\"responses\");\n\n const responseCode = statusToResponseCodeMap[response.status] ?? ResponseCode.UNRECOGNIZED;\n const uriResponse: UriResponse = {\n code: uriResponseOkCode,\n description: \"\",\n contentType: apiBinaryContentType,\n data: response.body,\n metadata: {\n ...response.metadata,\n [apiResponseStatusHeader]: responseCodeToNumber(responseCode).toString(),\n },\n };\n reply(uriResponse);\n });\n } catch (error) {\n logger.warn(\"Client's Remote API request handler threw an error.\", error);\n }\n\n if (typeof cancellationHandler === \"function\") {\n setCancellationHandler(() => {\n try {\n cancellationHandler!();\n } catch (error) {\n logger.warn(\"Client's Remote API request cancellation handler threw an error.\", error);\n }\n });\n }\n\n break;\n }\n }\n },\n processInternalError(error) {\n // The expectation is that if an error occurs, it happens in our own implementation,\n // because app callbacks are wrapped with try..catch blocks.\n // Therefore, we would like to report this error.\n logger.error(error);\n metrics.setOperationalMetrics(Count.count(joinMetricNames([\"lens\", \"remote-api\", \"errors\"]), 1));\n },\n });\n}\n"]}
@@ -2,21 +2,23 @@ import type { MetricsClient } from "../clients/metricsClient";
2
2
  import type { LensKeyboard } from "../session/LensKeyboard";
3
3
  import type { LensRepository } from "../lens/LensRepository";
4
4
  import type { LensCore } from "../lens-core-module/lensCore";
5
- import type { RemoteApiServices } from "./RemoteApiServices";
5
+ import type { CameraKitConfiguration } from "../configuration";
6
+ import type { RemoteApiSpecsClient } from "../clients/remoteApiSpecsClient";
6
7
  import type { UriHandlers } from "./UriHandlers";
8
+ import type { RemoteApiServices } from "./internal-handlers/remoteApiUriHandler";
7
9
  /**
8
10
  * Registers URI handlers within LensCore.
9
11
  * @internal
10
12
  */
11
13
  export declare const registerUriHandlers: {
12
- (args_0: LensCore, args_1: import("@snap/state-management").StateMachine<import("@snap/state-management").Action<"applyLens", {
14
+ (args_0: CameraKitConfiguration, args_1: LensCore, args_2: import("@snap/state-management").StateMachine<import("@snap/state-management").Action<"applyLens", {
13
15
  lens: import("..").Lens;
14
16
  launchData?: import("..").LensLaunchData | undefined;
15
17
  }> | import("@snap/state-management").Action<"downloadComplete", import("..").Lens> | import("@snap/state-management").Action<"turnedOn", import("..").Lens> | import("@snap/state-management").Action<"resourcesLoaded", import("..").Lens> | import("@snap/state-management").Action<"firstFrameProcessed", import("..").Lens> | import("@snap/state-management").Action<"applyLensComplete", import("..").Lens> | import("@snap/state-management").Action<"applyLensFailed", {
16
18
  error: import("../session/lensState").LensErrors;
17
19
  lens: import("..").Lens;
18
- }> | import("@snap/state-management").Action<"applyLensAborted", import("..").Lens> | import("@snap/state-management").Action<"removeLens", undefined> | import("@snap/state-management").Action<"turnedOff", import("..").Lens> | import("@snap/state-management").Action<"removeLensComplete", undefined> | import("@snap/state-management").Action<"removeLensFailed", Error>, import("@snap/state-management").State<"noLensApplied", undefined> | import("@snap/state-management").State<"applyingLens", import("..").Lens> | import("@snap/state-management").State<"lensApplied", import("..").Lens>>, args_2: UriHandlers, args_3: LensKeyboard, args_4: RemoteApiServices, args_5: LensRepository, args_6: import("@snap/state-management").StateMachine<import("@snap/state-management").Action<"suspend", import("../session/CameraKitSession").CameraKitSession> | import("@snap/state-management").Action<"resume", import("../session/CameraKitSession").CameraKitSession> | import("@snap/state-management").Action<"destroy", undefined>, import("@snap/state-management").State<"inactive", undefined> | import("@snap/state-management").State<"active", import("../session/CameraKitSession").CameraKitSession> | import("@snap/state-management").State<"destroyed", undefined>>, args_7: MetricsClient): void;
20
+ }> | import("@snap/state-management").Action<"applyLensAborted", import("..").Lens> | import("@snap/state-management").Action<"removeLens", undefined> | import("@snap/state-management").Action<"turnedOff", import("..").Lens> | import("@snap/state-management").Action<"removeLensComplete", undefined> | import("@snap/state-management").Action<"removeLensFailed", Error>, import("@snap/state-management").State<"noLensApplied", undefined> | import("@snap/state-management").State<"applyingLens", import("..").Lens> | import("@snap/state-management").State<"lensApplied", import("..").Lens>>, args_3: UriHandlers, args_4: LensKeyboard, args_5: RemoteApiServices, args_6: LensRepository, args_7: import("@snap/state-management").StateMachine<import("@snap/state-management").Action<"suspend", import("../session/CameraKitSession").CameraKitSession> | import("@snap/state-management").Action<"resume", import("../session/CameraKitSession").CameraKitSession> | import("@snap/state-management").Action<"destroy", undefined>, import("@snap/state-management").State<"inactive", undefined> | import("@snap/state-management").State<"active", import("../session/CameraKitSession").CameraKitSession> | import("@snap/state-management").State<"destroyed", undefined>>, args_8: MetricsClient, args_9: RemoteApiSpecsClient): void;
19
21
  token: "registerUriHandlers";
20
- dependencies: readonly ["lensCore", "lensState", "UriHandlers", "lensKeyboard", "remoteApiServices", "LensRepository", "sessionState", "metricsClient"];
22
+ dependencies: readonly ["configuration", "lensCore", "lensState", "UriHandlers", "lensKeyboard", "remoteApiServices", "LensRepository", "sessionState", "metricsClient", "remoteApiSpecsClient"];
21
23
  };
22
24
  //# sourceMappingURL=uriHandlersRegister.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uriHandlersRegister.d.ts","sourceRoot":"","sources":["../../src/uri-handlers/uriHandlersRegister.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAE9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAI5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAM7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAG5E,OAAO,KAAK,EAAE,WAAW,EAAe,MAAM,eAAe,CAAC;AAE9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAKjF;;;GAGG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;CAsF/B,CAAC"}
@@ -7,10 +7,14 @@ import { lensRepositoryFactory } from "../lens/LensRepository";
7
7
  import { sessionStateFactory } from "../session/sessionState";
8
8
  import { getLogger } from "../logger/logger";
9
9
  import { lensCoreFactory } from "../lens-core-module/loader/lensCoreFactory";
10
- import { getRemoteApiUriHandler, remoteApiServicesFactory } from "./RemoteApiServices";
10
+ import { configurationToken } from "../configuration";
11
+ import { remoteApiSpecsClientFactory } from "../clients/remoteApiSpecsClient";
12
+ import { createHttpUriHandler } from "./internal-handlers/httpUriHandler";
11
13
  import { extractSchemeAndRoute, isUriHandlers, isUriResponse, uriHandlersFactory } from "./UriHandlers";
14
+ import { createRemoteApiUriHandler, remoteApiServicesFactory } from "./internal-handlers/remoteApiUriHandler";
12
15
  const logger = getLogger("uriHandlersRegister");
13
16
  export const registerUriHandlers = Injectable("registerUriHandlers", [
17
+ configurationToken,
14
18
  lensCoreFactory.token,
15
19
  lensStateFactory.token,
16
20
  uriHandlersFactory.token,
@@ -19,11 +23,17 @@ export const registerUriHandlers = Injectable("registerUriHandlers", [
19
23
  lensRepositoryFactory.token,
20
24
  sessionStateFactory.token,
21
25
  metricsClientFactory.token,
22
- ], (lensCore, lensState, userHandlers, lensKeyboard, remoteApiServices, lensRepository, sessionState, metrics) => {
26
+ remoteApiSpecsClientFactory.token,
27
+ ], (configuration, lensCore, lensState, userHandlers, lensKeyboard, remoteApiServices, lensRepository, sessionState, metrics, remoteApiSpecsClient) => {
23
28
  if (!isUriHandlers(userHandlers)) {
24
29
  throw new Error("Expected an array of UriHandler objects");
25
30
  }
26
- const allHandlers = userHandlers.concat(lensKeyboard.uriHandler, getRemoteApiUriHandler(remoteApiServices, sessionState, lensState, lensRepository, metrics));
31
+ const allHandlers = [
32
+ createHttpUriHandler(lensState, sessionState, remoteApiSpecsClient, configuration.lensHttpHandler),
33
+ ...userHandlers,
34
+ lensKeyboard.uriHandler,
35
+ createRemoteApiUriHandler(remoteApiServices, sessionState, lensState, lensRepository, metrics),
36
+ ];
27
37
  for (const { uri, handleRequest, cancelRequest } of allHandlers) {
28
38
  const uris = Array.isArray(uri) ? uri : [uri];
29
39
  for (const { scheme, route } of uris.map(extractSchemeAndRoute)) {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uriHandlersRegister.js","sourceRoot":"","sources":["../../src/uri-handlers/uriHandlersRegister.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEhE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAAE,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AG,SAAS,CAAC,QAAQ,EAAE,CAAC;wBACnC,IAAI,OAAO,CAAC,KAAK,EAAE,eAAe,CAAC,EAAE;4BACjC,MAAM,CAAC,IAAI,CACP,gCAAgC,OAAO,CAAC,GAAG,2BAA2B;gCAClE,iDAAiD,CACxD,CAAC;4BACF,OAAO;yBACV;wBACD,aAAa,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;qBACtC;gBACL,CAAC;aACJ,CAAC,CAAC;SACN;KACJ;AACL,CAAC,CACJ,CAAC","sourcesContent":["import { isState } from \"@snap/state-management\";\nimport { Injectable } from \"@snap/ts-inject\";\nimport type { MetricsClient } from \"../clients/metricsClient\";\nimport { metricsClientFactory } from \"../clients/metricsClient\";\nimport type { LensKeyboard } from \"../session/LensKeyboard\";\nimport { lensKeyboardFactory } from \"../session/LensKeyboard\";\nimport type { LensState } from \"../session/lensState\";\nimport { lensStateFactory } from \"../session/lensState\";\nimport type { LensRepository } from \"../lens/LensRepository\";\nimport { lensRepositoryFactory } from \"../lens/LensRepository\";\nimport type { SessionState } from \"../session/sessionState\";\nimport { sessionStateFactory } from \"../session/sessionState\";\nimport { getLogger } from \"../logger/logger\";\nimport { lensCoreFactory } from \"../lens-core-module/loader/lensCoreFactory\";\nimport type { LensCore } from \"../lens-core-module/lensCore\";\nimport type { CameraKitConfiguration } from \"../configuration\";\nimport { configurationToken } from \"../configuration\";\nimport type { RemoteApiSpecsClient } from \"../clients/remoteApiSpecsClient\";\nimport { remoteApiSpecsClientFactory } from \"../clients/remoteApiSpecsClient\";\nimport { createHttpUriHandler } from \"./internal-handlers/httpUriHandler\";\nimport type { UriHandlers, UriResponse } from \"./UriHandlers\";\nimport { extractSchemeAndRoute, isUriHandlers, isUriResponse, uriHandlersFactory } from \"./UriHandlers\";\nimport type { RemoteApiServices } from \"./internal-handlers/remoteApiUriHandler\";\nimport { createRemoteApiUriHandler, remoteApiServicesFactory } from \"./internal-handlers/remoteApiUriHandler\";\n\nconst logger = getLogger(\"uriHandlersRegister\");\n\n/**\n * Registers URI handlers within LensCore.\n * @internal\n */\nexport const registerUriHandlers = Injectable(\n \"registerUriHandlers\",\n [\n configurationToken,\n lensCoreFactory.token,\n lensStateFactory.token,\n uriHandlersFactory.token,\n lensKeyboardFactory.token,\n remoteApiServicesFactory.token,\n lensRepositoryFactory.token,\n sessionStateFactory.token,\n metricsClientFactory.token,\n remoteApiSpecsClientFactory.token,\n ] as const,\n (\n configuration: CameraKitConfiguration,\n lensCore: LensCore,\n lensState: LensState,\n userHandlers: UriHandlers,\n lensKeyboard: LensKeyboard,\n remoteApiServices: RemoteApiServices,\n lensRepository: LensRepository,\n sessionState: SessionState,\n metrics: MetricsClient,\n remoteApiSpecsClient: RemoteApiSpecsClient\n ): void => {\n if (!isUriHandlers(userHandlers)) {\n throw new Error(\"Expected an array of UriHandler objects\");\n }\n\n // Users can provide custom UriHandlers using the `uriHandlersFactory.token`.\n // However, we need to include some internally-defined handlers (e.g., Lens Keyboard and Remote API)\n // before registering the handlers with LensCore.\n // Note: The internal HTTP handler can be overridden if the user prefers to disable validation, for instance.\n const allHandlers = [\n createHttpUriHandler(lensState, sessionState, remoteApiSpecsClient, configuration.lensHttpHandler),\n ...userHandlers,\n lensKeyboard.uriHandler,\n createRemoteApiUriHandler(remoteApiServices, sessionState, lensState, lensRepository, metrics),\n ];\n\n for (const { uri, handleRequest, cancelRequest } of allHandlers) {\n const uris = Array.isArray(uri) ? uri : [uri];\n for (const { scheme, route } of uris.map(extractSchemeAndRoute)) {\n lensCore.registerUriListener(scheme, route, {\n handleRequest: (request) => {\n const reply = (response: UriResponse) => {\n if (!isUriResponse(response)) {\n throw new Error(\"Expected UriResponse object\");\n }\n lensCore.provideUriResponse(request.identifier, response);\n };\n\n // Since lenses are the only things that make URI requests, we expect to always be in the\n // \"lensApplied\" state – we'll sanity check, though, and log a warning if we're not.\n const state = lensState.getState();\n if (isState(state, \"noLensApplied\")) {\n logger.warn(\n `Got a URI request for ${request.uri}, but there is no active lens. The ` +\n `request will not be processed.`\n );\n return;\n }\n\n // NOTE: we do not handle any error thrown on an extension side when handleRequest() is called.\n // That responsibility is delegated to the extension by design and that is exactly what Android\n // and iOS SDKs do.\n handleRequest(request, reply, state.data);\n },\n cancelRequest: (request) => {\n if (cancelRequest) {\n const state = lensState.getState();\n if (isState(state, \"noLensApplied\")) {\n logger.warn(\n `Got a URI cancel request for ${request.uri}, but there is no active ` +\n `lens. The cancel request will not be processed.`\n );\n return;\n }\n cancelRequest(request, state.data);\n }\n },\n });\n }\n }\n }\n);\n"]}
@@ -0,0 +1,37 @@
1
+ import type { Lens } from "../lens/Lens";
2
+ import type { LensState } from "../session/lensState";
3
+ import type { SessionState } from "../session/sessionState";
4
+ import type { Uri, UriHandler, UriRequest, UriResponse } from "./UriHandlers";
5
+ export type UriRequestEvent = {
6
+ request: UriRequest;
7
+ reply: (response: UriResponse) => void;
8
+ lens: Lens;
9
+ };
10
+ /**
11
+ * Represents a Remote API request cancellation handler function.
12
+ */
13
+ export type RemoteApiCancelRequestHandler = () => void;
14
+ export type CreateLensRequestState<State> = (request: UriRequest, lens: Lens) => State;
15
+ export type ProcessRequest<State> = (input: {
16
+ request: UriRequest;
17
+ reply: (response: UriResponse) => void;
18
+ lens: Lens;
19
+ setCancellationHandler: (fn: () => void) => void;
20
+ state: State;
21
+ }) => void;
22
+ export type ProcessError = (error: Error) => void;
23
+ /**
24
+ * Creates a UriHandler for the provided URI.
25
+ * Handles lens and sessions state events, so provides clear abstraction for internal usages.
26
+ *
27
+ * @internal
28
+ */
29
+ export declare function createUriRequestProcessor<State = undefined>({ uri, lensState, sessionState, createLensRequestState, processRequest, processInternalError, }: {
30
+ uri: Uri | Uri[];
31
+ lensState: LensState;
32
+ sessionState: SessionState;
33
+ createLensRequestState?: CreateLensRequestState<State>;
34
+ processRequest: ProcessRequest<State>;
35
+ processInternalError: ProcessError;
36
+ }): UriHandler;
37
+ //# sourceMappingURL=uriRequestProcessor.d.ts.map
@@ -0,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E;IACC,GAAG,EAAE,GAAG,GAAG,GAAG,EAAE,CAAC;IACjB,SAAS,EAAE,SAAS,CAAC;IACrB,YAAY,EAAE,YAAY,CAAC;IAC3B,sBAAsB,CAAC,EAAE,sBAAsB,CAAC,KAAK,CAAC,CAAC;IACvD,cAAc,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC;IACtC,oBAAoB,EAAE,YAAY,CAAC;CACtC,GAAG,UAAU,CA6Eb"}
@@ -0,0 +1,69 @@
1
+ import { catchError, map, merge, retry, Subject, takeUntil, tap } from "rxjs";
2
+ import { forActions } from "@snap/state-management";
3
+ function callCancellationHandler(cancellationHandlers, ...keys) {
4
+ var _a;
5
+ for (const key of keys) {
6
+ (_a = cancellationHandlers.get(key)) === null || _a === void 0 ? void 0 : _a();
7
+ cancellationHandlers.delete(key);
8
+ }
9
+ }
10
+ function handleLensApplicationEnd(lensRequestState, ...lensIds) {
11
+ for (const lensId of lensIds) {
12
+ const state = lensRequestState.get(lensId);
13
+ if (state) {
14
+ callCancellationHandler(state.cancellationHandlers, ...state.cancellationHandlers.keys());
15
+ lensRequestState.delete(lensId);
16
+ }
17
+ }
18
+ }
19
+ export function createUriRequestProcessor({ uri, lensState, sessionState, createLensRequestState, processRequest, processInternalError, }) {
20
+ const uriRequests = new Subject();
21
+ const uriCancelRequests = new Subject();
22
+ const lensRequestState = new Map();
23
+ const lensTurnOffEvents = lensState.events.pipe(forActions("turnedOff"), tap(([action]) => handleLensApplicationEnd(lensRequestState, action.data.id)));
24
+ const uriRequestEvents = uriRequests.pipe(map(({ request, lens, reply }) => {
25
+ if (!lensRequestState.has(lens.id)) {
26
+ const custom = createLensRequestState === null || createLensRequestState === void 0 ? void 0 : createLensRequestState(request, lens);
27
+ const state = {
28
+ cancellationHandlers: new Map(),
29
+ custom: custom,
30
+ };
31
+ lensRequestState.set(lens.id, state);
32
+ }
33
+ const requestState = lensRequestState.get(lens.id);
34
+ return {
35
+ request,
36
+ reply,
37
+ lens,
38
+ state: requestState.custom,
39
+ setCancellationHandler: (fn) => {
40
+ requestState.cancellationHandlers.set(request.identifier, fn);
41
+ },
42
+ };
43
+ }), tap(processRequest));
44
+ const uriCancelRequestEvents = uriCancelRequests.pipe(tap((uriRequest) => {
45
+ var _a;
46
+ const cancellationHandlers = (_a = lensRequestState.get(uriRequest.lens.id)) === null || _a === void 0 ? void 0 : _a.cancellationHandlers;
47
+ if (cancellationHandlers) {
48
+ callCancellationHandler(cancellationHandlers, uriRequest.request.requestId);
49
+ }
50
+ }));
51
+ merge(lensTurnOffEvents, uriRequestEvents, uriCancelRequestEvents)
52
+ .pipe(catchError((error, sourcePipe) => {
53
+ processInternalError(error);
54
+ return sourcePipe;
55
+ }), retry(), takeUntil(sessionState.events.pipe(forActions("destroy"))))
56
+ .subscribe({
57
+ complete: () => handleLensApplicationEnd(lensRequestState, ...lensRequestState.keys()),
58
+ });
59
+ return {
60
+ uri,
61
+ handleRequest(request, reply, lens) {
62
+ uriRequests.next({ request, reply, lens });
63
+ },
64
+ cancelRequest(request, lens) {
65
+ uriCancelRequests.next({ request, lens });
66
+ },
67
+ };
68
+ }
69
+ //# sourceMappingURL=uriRequestProcessor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uriRequestProcessor.js","sourceRoot":"","sources":["../../src/uri-handlers/uriRequestProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAiCpD,SAAS,uBAAuB,CAC5B,oBAAmE,EACnE,GAAG,IAAiB;;IAEpB,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;QACpB,MAAA,oBAAoB,CAAC,GAAG,CAAC,GAAG,CAAC,2CAAI,CAAC;QAClC,oBAAoB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;KACpC;AACL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AwB,CAAC,gBAAgB,EAAE,GAAG,gBAAgB,CAAC,IAAI,EAAE,CAAC;KACzF,CAAC,CAAC;IAEP,OAAO;QACH,GAAG;QAEH,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI;YAC9B,WAAW,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/C,CAAC;QAED,aAAa,CAAC,OAAO,EAAE,IAAI;YACvB,iBAAiB,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QAC9C,CAAC;KACJ,CAAC;AACN,CAAC","sourcesContent":["import { catchError, map, merge, retry, Subject, takeUntil, tap } from \"rxjs\";\nimport { forActions } from \"@snap/state-management\";\nimport type { Lens } from \"../lens/Lens\";\nimport type { LensState } from \"../session/lensState\";\nimport type { SessionState } from \"../session/sessionState\";\nimport type { Uri, UriCancelRequest, UriHandler, UriRequest, UriResponse } from \"./UriHandlers\";\n\ntype LensId = string;\ntype RequestId = string;\n\nexport type UriRequestEvent = {\n request: UriRequest;\n reply: (response: UriResponse) => void;\n lens: Lens;\n};\n\ntype UriCancelRequestEvent = {\n request: UriCancelRequest;\n lens: Lens;\n};\n\ninterface LensRequestState<T = undefined> {\n cancellationHandlers: Map<RequestId, RemoteApiCancelRequestHandler>;\n custom: T;\n}\n\n/**\n * Represents a Remote API request cancellation handler function.\n */\nexport type RemoteApiCancelRequestHandler = () => void;\n\n/**\n * Invokes the cancellation handler associated with the provided key and removes it from the collection of handlers.\n */\nfunction callCancellationHandler(\n cancellationHandlers: Map<RequestId, RemoteApiCancelRequestHandler>,\n ...keys: RequestId[]\n) {\n for (const key of keys) {\n cancellationHandlers.get(key)?.();\n cancellationHandlers.delete(key);\n }\n}\n\n/**\n * Removes the specified lenses' metadata from the cache and invokes their cancellation callbacks.\n *\n * @param lensRequestState The state representing the lens cache.\n * @param lensIds An array of lens IDs to be removed from the cache\n * and for which the cancellation callbacks will be invoked.\n */\nfunction handleLensApplicationEnd(lensRequestState: Map<LensId, LensRequestState<any>>, ...lensIds: LensId[]) {\n for (const lensId of lensIds) {\n const state = lensRequestState.get(lensId);\n if (state) {\n callCancellationHandler(state.cancellationHandlers, ...state.cancellationHandlers.keys());\n lensRequestState.delete(lensId);\n }\n }\n}\n\nexport type CreateLensRequestState<State> = (request: UriRequest, lens: Lens) => State;\n\nexport type ProcessRequest<State> = (input: {\n request: UriRequest;\n reply: (response: UriResponse) => void;\n lens: Lens;\n setCancellationHandler: (fn: () => void) => void;\n state: State;\n}) => void;\n\nexport type ProcessError = (error: Error) => void;\n\n/**\n * Creates a UriHandler for the provided URI.\n * Handles lens and sessions state events, so provides clear abstraction for internal usages.\n *\n * @internal\n */\nexport function createUriRequestProcessor<State = undefined>({\n uri,\n lensState,\n sessionState,\n createLensRequestState,\n processRequest,\n processInternalError,\n}: {\n uri: Uri | Uri[];\n lensState: LensState;\n sessionState: SessionState;\n createLensRequestState?: CreateLensRequestState<State>;\n processRequest: ProcessRequest<State>;\n processInternalError: ProcessError;\n}): UriHandler {\n const uriRequests = new Subject<UriRequestEvent>();\n const uriCancelRequests = new Subject<UriCancelRequestEvent>();\n const lensRequestState = new Map<LensId, LensRequestState<State>>();\n\n const lensTurnOffEvents = lensState.events.pipe(\n forActions(\"turnedOff\"),\n tap(([action]) => handleLensApplicationEnd(lensRequestState, action.data.id))\n );\n\n const uriRequestEvents = uriRequests.pipe(\n map(({ request, lens, reply }) => {\n if (!lensRequestState.has(lens.id)) {\n const custom = createLensRequestState?.(request, lens);\n const state: LensRequestState<State> = {\n // Prepares a collection to store cancellation handlers.\n // A specific handler will be invoked when a cancellation request is issued by the lens.\n // All handlers will be invoked when the lens is replaced with another one or the session\n // is destroyed.\n cancellationHandlers: new Map(),\n // Safety: it is fine for State to be undefined\n custom: custom as State,\n };\n lensRequestState.set(lens.id, state);\n }\n const requestState = lensRequestState.get(lens.id)!;\n\n return {\n request,\n reply,\n lens,\n state: requestState.custom,\n setCancellationHandler: (fn: () => any) => {\n requestState.cancellationHandlers.set(request.identifier, fn);\n },\n };\n }),\n\n tap(processRequest)\n );\n\n const uriCancelRequestEvents = uriCancelRequests.pipe(\n tap((uriRequest) => {\n const cancellationHandlers = lensRequestState.get(uriRequest.lens.id)?.cancellationHandlers;\n if (cancellationHandlers) {\n callCancellationHandler(cancellationHandlers, uriRequest.request.requestId);\n }\n })\n );\n\n merge(lensTurnOffEvents, uriRequestEvents, uriCancelRequestEvents)\n .pipe(\n catchError((error, sourcePipe) => {\n processInternalError(error);\n // Return the source pipe so that we can retry the pipe instead of just completing it.\n return sourcePipe;\n }),\n // When the pipe completes due to an error,\n // we want to resubscribe to the original pipe to keep it alive.\n retry(),\n takeUntil(sessionState.events.pipe(forActions(\"destroy\")))\n )\n .subscribe({\n complete: () => handleLensApplicationEnd(lensRequestState, ...lensRequestState.keys()),\n });\n\n return {\n uri,\n\n handleRequest(request, reply, lens) {\n uriRequests.next({ request, reply, lens });\n },\n\n cancelRequest(request, lens) {\n uriCancelRequests.next({ request, lens });\n },\n };\n}\n"]}
@@ -0,0 +1 @@
1
+ window.hierarchyData = "H4sIAAAAAAAAA5WOsQrCMBRF/+XOUUtpWsiqm4hDwUU6hOaVBtNEktSl9N8lCFJQoU53ePe8eyZ452KAuBY8bxg8dYbaqJ0NEBMKnqewciAI7OVAXh51PNBDt3S+v3oMN20VRM5LhtEbCGgbyXeypbD7Dm37OBgwtEaGAIEY1CZ92bzJdOy1UZ5ssqtKxjPezAxFVS6cTqS0rKMnOdRu9GutfmErvGYGnvGFwkUrcv+MfwJrZuf5CWOo4FetAQAA"
@@ -21,8 +21,10 @@
21
21
  --dark-hl-9: #D4D4D4;
22
22
  --light-hl-10: #CD3131;
23
23
  --dark-hl-10: #F44747;
24
- --light-hl-11: #267F99;
25
- --dark-hl-11: #4EC9B0;
24
+ --light-hl-11: #000000;
25
+ --dark-hl-11: #C8C8C8;
26
+ --light-hl-12: #267F99;
27
+ --dark-hl-12: #4EC9B0;
26
28
  --light-code-background: #FFFFFF;
27
29
  --dark-code-background: #1E1E1E;
28
30
  }
@@ -40,6 +42,7 @@
40
42
  --hl-9: var(--light-hl-9);
41
43
  --hl-10: var(--light-hl-10);
42
44
  --hl-11: var(--light-hl-11);
45
+ --hl-12: var(--light-hl-12);
43
46
  --code-background: var(--light-code-background);
44
47
  } }
45
48
 
@@ -56,6 +59,7 @@
56
59
  --hl-9: var(--dark-hl-9);
57
60
  --hl-10: var(--dark-hl-10);
58
61
  --hl-11: var(--dark-hl-11);
62
+ --hl-12: var(--dark-hl-12);
59
63
  --code-background: var(--dark-code-background);
60
64
  } }
61
65
 
@@ -72,6 +76,7 @@
72
76
  --hl-9: var(--light-hl-9);
73
77
  --hl-10: var(--light-hl-10);
74
78
  --hl-11: var(--light-hl-11);
79
+ --hl-12: var(--light-hl-12);
75
80
  --code-background: var(--light-code-background);
76
81
  }
77
82
 
@@ -88,6 +93,7 @@
88
93
  --hl-9: var(--dark-hl-9);
89
94
  --hl-10: var(--dark-hl-10);
90
95
  --hl-11: var(--dark-hl-11);
96
+ --hl-12: var(--dark-hl-12);
91
97
  --code-background: var(--dark-code-background);
92
98
  }
93
99
 
@@ -103,4 +109,5 @@
103
109
  .hl-9 { color: var(--hl-9); }
104
110
  .hl-10 { color: var(--hl-10); }
105
111
  .hl-11 { color: var(--hl-11); }
112
+ .hl-12 { color: var(--hl-12); }
106
113
  pre, code { background: var(--code-background); }
@@ -0,0 +1,18 @@
1
+ (function() {
2
+ addIcons();
3
+ function addIcons() {
4
+ if (document.readyState === "loading") return document.addEventListener("DOMContentLoaded", addIcons);
5
+ const svg = document.body.appendChild(document.createElementNS("http://www.w3.org/2000/svg", "svg"));
6
+ svg.innerHTML = `<g id="icon-1" class="tsd-no-select"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-module)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><text fill="var(--color-icon-text)" x="50%" y="50%" dominant-baseline="central" text-anchor="middle">M</text></g><g id="icon-2" class="tsd-no-select"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-module)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><text fill="var(--color-icon-text)" x="50%" y="50%" dominant-baseline="central" text-anchor="middle">M</text></g><g id="icon-4" class="tsd-no-select"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-namespace)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><text fill="var(--color-icon-text)" x="50%" y="50%" dominant-baseline="central" text-anchor="middle">N</text></g><g id="icon-8" class="tsd-no-select"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-enum)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><text fill="var(--color-icon-text)" x="50%" y="50%" dominant-baseline="central" text-anchor="middle">E</text></g><g id="icon-16" class="tsd-no-select"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-property)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><text fill="var(--color-icon-text)" x="50%" y="50%" dominant-baseline="central" text-anchor="middle">P</text></g><g id="icon-32" class="tsd-no-select"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-variable)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><text fill="var(--color-icon-text)" x="50%" y="50%" dominant-baseline="central" text-anchor="middle">V</text></g><g id="icon-64" class="tsd-no-select"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-function)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><text fill="var(--color-icon-text)" x="50%" y="50%" dominant-baseline="central" text-anchor="middle">F</text></g><g id="icon-128" class="tsd-no-select"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-class)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><text fill="var(--color-icon-text)" x="50%" y="50%" dominant-baseline="central" text-anchor="middle">C</text></g><g id="icon-256" class="tsd-no-select"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-interface)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><text fill="var(--color-icon-text)" x="50%" y="50%" dominant-baseline="central" text-anchor="middle">I</text></g><g id="icon-512" class="tsd-no-select"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-constructor)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><text fill="var(--color-icon-text)" x="50%" y="50%" dominant-baseline="central" text-anchor="middle">C</text></g><g id="icon-1024" class="tsd-no-select"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-property)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><text fill="var(--color-icon-text)" x="50%" y="50%" dominant-baseline="central" text-anchor="middle">P</text></g><g id="icon-2048" class="tsd-no-select"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-method)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><text fill="var(--color-icon-text)" x="50%" y="50%" dominant-baseline="central" text-anchor="middle">M</text></g><g id="icon-4096" class="tsd-no-select"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-function)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><text fill="var(--color-icon-text)" x="50%" y="50%" dominant-baseline="central" text-anchor="middle">F</text></g><g id="icon-8192" class="tsd-no-select"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-property)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><text fill="var(--color-icon-text)" x="50%" y="50%" dominant-baseline="central" text-anchor="middle">P</text></g><g id="icon-16384" class="tsd-no-select"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-constructor)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><text fill="var(--color-icon-text)" x="50%" y="50%" dominant-baseline="central" text-anchor="middle">C</text></g><g id="icon-32768" class="tsd-no-select"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-property)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><text fill="var(--color-icon-text)" x="50%" y="50%" dominant-baseline="central" text-anchor="middle">P</text></g><g id="icon-65536" class="tsd-no-select"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-type-alias)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><text fill="var(--color-icon-text)" x="50%" y="50%" dominant-baseline="central" text-anchor="middle">T</text></g><g id="icon-131072" class="tsd-no-select"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-type-alias)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><text fill="var(--color-icon-text)" x="50%" y="50%" dominant-baseline="central" text-anchor="middle">T</text></g><g id="icon-262144" class="tsd-no-select"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-accessor)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><text fill="var(--color-icon-text)" x="50%" y="50%" dominant-baseline="central" text-anchor="middle">A</text></g><g id="icon-524288" class="tsd-no-select"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-accessor)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><text fill="var(--color-icon-text)" x="50%" y="50%" dominant-baseline="central" text-anchor="middle">A</text></g><g id="icon-1048576" class="tsd-no-select"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-accessor)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><text fill="var(--color-icon-text)" x="50%" y="50%" dominant-baseline="central" text-anchor="middle">A</text></g><g id="icon-2097152" class="tsd-no-select"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-type-alias)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><text fill="var(--color-icon-text)" x="50%" y="50%" dominant-baseline="central" text-anchor="middle">T</text></g><g id="icon-4194304" class="tsd-no-select"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-reference)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><text fill="var(--color-icon-text)" x="50%" y="50%" dominant-baseline="central" text-anchor="middle">R</text></g><g id="icon-8388608" class="tsd-no-select"><rect fill="var(--color-icon-background)" stroke="var(--color-document)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><g stroke="var(--color-icon-text)" fill="none" stroke-width="1.5"><polygon points="6,5 6,19 18,19, 18,10 13,5"></polygon><line x1="9" y1="9" x2="13" y2="9"></line><line x1="9" y1="12" x2="15" y2="12"></line><line x1="9" y1="15" x2="15" y2="15"></line></g></g><g id="icon-folder" class="tsd-no-select"><rect fill="var(--color-icon-background)" stroke="var(--color-document)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><g stroke="var(--color-icon-text)" fill="none" stroke-width="1.5"><polygon points="5,5 10,5 12,8 19,8 19,18 5,18"></polygon></g></g><g id="icon-chevronDown" class="tsd-no-select"><path d="M4.93896 8.531L12 15.591L19.061 8.531L16.939 6.409L12 11.349L7.06098 6.409L4.93896 8.531Z" fill="var(--color-icon-text)"></path></g><g id="icon-chevronSmall" class="tsd-no-select"><path d="M1.5 5.50969L8 11.6609L14.5 5.50969L12.5466 3.66086L8 7.96494L3.45341 3.66086L1.5 5.50969Z" fill="var(--color-icon-text)"></path></g><g id="icon-checkbox" class="tsd-no-select"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></g><g id="icon-menu" class="tsd-no-select"><rect x="1" y="3" width="14" height="2" fill="var(--color-icon-text)"></rect><rect x="1" y="7" width="14" height="2" fill="var(--color-icon-text)"></rect><rect x="1" y="11" width="14" height="2" fill="var(--color-icon-text)"></rect></g><g id="icon-search" class="tsd-no-select"><path d="M15.7824 13.833L12.6666 10.7177C12.5259 10.5771 12.3353 10.499 12.1353 10.499H11.6259C12.4884 9.39596 13.001 8.00859 13.001 6.49937C13.001 2.90909 10.0914 0 6.50048 0C2.90959 0 0 2.90909 0 6.49937C0 10.0896 2.90959 12.9987 6.50048 12.9987C8.00996 12.9987 9.39756 12.4863 10.5008 11.6239V12.1332C10.5008 12.3332 10.5789 12.5238 10.7195 12.6644L13.8354 15.7797C14.1292 16.0734 14.6042 16.0734 14.8948 15.7797L15.7793 14.8954C16.0731 14.6017 16.0731 14.1267 15.7824 13.833ZM6.50048 10.499C4.29094 10.499 2.50018 8.71165 2.50018 6.49937C2.50018 4.29021 4.28781 2.49976 6.50048 2.49976C8.71001 2.49976 10.5008 4.28708 10.5008 6.49937C10.5008 8.70852 8.71314 10.499 6.50048 10.499Z" fill="var(--color-icon-text)"></path></g><g id="icon-anchor" class="tsd-no-select"><g stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></g></g><g id="icon-alertNote" class="tsd-no-select"><path fill="var(--color-alert-note)" d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-6.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13ZM6.5 7.75A.75.75 0 0 1 7.25 7h1a.75.75 0 0 1 .75.75v2.75h.25a.75.75 0 0 1 0 1.5h-2a.75.75 0 0 1 0-1.5h.25v-2h-.25a.75.75 0 0 1-.75-.75ZM8 6a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"></path></g><g id="icon-alertTip" class="tsd-no-select"><path fill="var(--color-alert-tip)" d="M8 1.5c-2.363 0-4 1.69-4 3.75 0 .984.424 1.625.984 2.304l.214.253c.223.264.47.556.673.848.284.411.537.896.621 1.49a.75.75 0 0 1-1.484.211c-.04-.282-.163-.547-.37-.847a8.456 8.456 0 0 0-.542-.68c-.084-.1-.173-.205-.268-.32C3.201 7.75 2.5 6.766 2.5 5.25 2.5 2.31 4.863 0 8 0s5.5 2.31 5.5 5.25c0 1.516-.701 2.5-1.328 3.259-.095.115-.184.22-.268.319-.207.245-.383.453-.541.681-.208.3-.33.565-.37.847a.751.751 0 0 1-1.485-.212c.084-.593.337-1.078.621-1.489.203-.292.45-.584.673-.848.075-.088.147-.173.213-.253.561-.679.985-1.32.985-2.304 0-2.06-1.637-3.75-4-3.75ZM5.75 12h4.5a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1 0-1.5ZM6 15.25a.75.75 0 0 1 .75-.75h2.5a.75.75 0 0 1 0 1.5h-2.5a.75.75 0 0 1-.75-.75Z"></path></g><g id="icon-alertImportant" class="tsd-no-select"><path fill="var(--color-alert-important)" d="M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v9.5A1.75 1.75 0 0 1 14.25 13H8.06l-2.573 2.573A1.458 1.458 0 0 1 3 14.543V13H1.75A1.75 1.75 0 0 1 0 11.25Zm1.75-.25a.25.25 0 0 0-.25.25v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25Zm7 2.25v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 9a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></g><g id="icon-alertWarning" class="tsd-no-select"><path fill="var(--color-alert-warning)" d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></g><g id="icon-alertCaution" class="tsd-no-select"><path fill="var(--color-alert-caution)" d="M4.47.22A.749.749 0 0 1 5 0h6c.199 0 .389.079.53.22l4.25 4.25c.141.14.22.331.22.53v6a.749.749 0 0 1-.22.53l-4.25 4.25A.749.749 0 0 1 11 16H5a.749.749 0 0 1-.53-.22L.22 11.53A.749.749 0 0 1 0 11V5c0-.199.079-.389.22-.53Zm.84 1.28L1.5 5.31v5.38l3.81 3.81h5.38l3.81-3.81V5.31L10.69 1.5ZM8 4a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 4Zm0 8a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"></path></g>`;
7
+ svg.style.display = "none";
8
+ if (location.protocol === "file:") updateUseElements();
9
+ }
10
+
11
+ function updateUseElements() {
12
+ document.querySelectorAll("use").forEach(el => {
13
+ if (el.getAttribute("href").includes("#icon-")) {
14
+ el.setAttribute("href", el.getAttribute("href").replace(/.*#/, "#"));
15
+ }
16
+ });
17
+ }
18
+ })()