@snap/camera-kit 0.11.0 → 0.13.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.
- package/README.md +264 -67
- package/docs/html/assets/search.js +1 -1
- package/docs/html/classes/CameraKit.html +12 -7
- package/docs/html/classes/CameraKitSession.html +27 -7
- package/docs/html/classes/CameraKitSource.html +26 -17
- package/docs/html/classes/LensPerformanceMeasurement.html +12 -7
- package/docs/html/classes/LensPerformanceMetrics.html +12 -7
- package/docs/html/classes/LensRepository.html +12 -7
- package/docs/html/classes/LensSources.html +12 -7
- package/docs/html/classes/Transform2D.html +12 -7
- package/docs/html/classes/TypedCustomEvent.html +12 -7
- package/docs/html/classes/TypedEventTarget.html +12 -7
- package/docs/html/functions/Injectable.html +12 -7
- package/docs/html/functions/bootstrapCameraKit.html +12 -7
- package/docs/html/functions/createExtension.html +12 -7
- package/docs/html/functions/createImageSource.html +12 -7
- package/docs/html/functions/createMediaStreamSource.html +12 -7
- package/docs/html/functions/createUserMediaSource.html +12 -7
- package/docs/html/functions/createVideoSource.html +12 -7
- package/docs/html/functions/estimateLensPerformance.html +12 -7
- package/docs/html/functions/getRequiredBootstrapURLs.html +12 -7
- package/docs/html/functions/lensSourcesFactory.html +12 -7
- package/docs/html/functions/{uriHandlersFactory.html → remoteApiServicesFactory.html} +16 -14
- package/docs/html/index.html +194 -50
- package/docs/html/interfaces/CameraKitBootstrapConfiguration.html +12 -7
- package/docs/html/interfaces/CameraKitSourceSubscriber.html +12 -7
- package/docs/html/interfaces/ComputedFrameMetrics.html +12 -7
- package/docs/html/interfaces/CreateSessionOptions.html +12 -7
- package/docs/html/interfaces/EstimatedLensPerformance.html +12 -7
- package/docs/html/interfaces/Lens.html +12 -7
- package/docs/html/interfaces/LensSource.html +16 -11
- package/docs/html/interfaces/MediaStreamSourceOptions.html +12 -7
- package/docs/html/interfaces/Preview.html +12 -7
- package/docs/html/interfaces/RemoteApiRequest.html +164 -0
- package/docs/html/interfaces/RemoteApiResponse.html +156 -0
- package/docs/html/interfaces/{UriHandler.html → RemoteApiService.html} +34 -68
- package/docs/html/interfaces/Snapcode.html +12 -7
- package/docs/html/interfaces/UriCancelRequest.html +12 -7
- package/docs/html/interfaces/UriRequest.html +20 -10
- package/docs/html/interfaces/UriResponse.html +12 -7
- package/docs/html/interfaces/VideoSourceOptions.html +12 -7
- package/docs/html/modules.html +22 -12
- package/docs/html/types/AssetLoader.html +12 -7
- package/docs/html/types/AssetTiming.html +12 -7
- package/docs/html/types/BenchmarkError.html +12 -7
- package/docs/html/types/BootstrapError.html +12 -7
- package/docs/html/types/CacheKeyNotFoundError.html +12 -7
- package/docs/html/types/CameraKitDeviceInfo.html +19 -9
- package/docs/html/types/CameraKitDeviceOptions.html +119 -0
- package/docs/html/types/CameraKitSessionEventListener.html +12 -7
- package/docs/html/types/CameraKitSessionEvents.html +12 -7
- package/docs/html/types/CameraKitSourceError.html +12 -7
- package/docs/html/types/CameraKitSourceInfo.html +12 -7
- package/docs/html/types/CameraKitSourceOptions.html +13 -8
- package/docs/html/types/ConfigurationError.html +12 -7
- package/docs/html/types/Keyboard.html +12 -7
- package/docs/html/types/KeyboardEvents.html +12 -7
- package/docs/html/types/LegalError.html +12 -7
- package/docs/html/types/LensAssetError.html +12 -7
- package/docs/html/types/LensContentValidationError.html +12 -7
- package/docs/html/types/LensError.html +12 -7
- package/docs/html/types/LensExecutionError.html +12 -7
- package/docs/html/types/LensImagePickerError.html +12 -7
- package/docs/html/types/LensLaunchParams.html +12 -7
- package/docs/html/types/LensMetricsEvents.html +12 -7
- package/docs/html/types/LensPerformanceCluster.html +12 -7
- package/docs/html/types/LensView.html +12 -7
- package/docs/html/types/LensWait.html +12 -7
- package/docs/html/types/PersistentStoreError.html +12 -7
- package/docs/html/types/PlatformNotSupportedError.html +12 -7
- package/docs/html/types/PublicContainer.html +12 -7
- package/docs/html/types/RemoteApiRequestHandler.html +141 -0
- package/docs/html/types/{UriHandlers.html → RemoteApiServices.html} +15 -13
- package/docs/html/types/RemoteApiStatus.html +114 -0
- package/docs/html/types/RenderTarget.html +12 -7
- package/docs/html/types/Uri.html +12 -7
- package/docs/html/types/WebGLError.html +12 -7
- package/docs/html/variables/extensionRequestContext.html +12 -7
- package/docs/md/README.md +264 -67
- package/docs/md/classes/CameraKit.md +1 -1
- package/docs/md/classes/CameraKitSession.md +19 -1
- package/docs/md/classes/CameraKitSource.md +19 -7
- package/docs/md/classes/LensPerformanceMeasurement.md +1 -1
- package/docs/md/classes/LensPerformanceMetrics.md +1 -1
- package/docs/md/classes/LensRepository.md +1 -1
- package/docs/md/classes/LensSources.md +1 -1
- package/docs/md/classes/Transform2D.md +1 -1
- package/docs/md/classes/TypedCustomEvent.md +1 -1
- package/docs/md/classes/TypedEventTarget.md +1 -1
- package/docs/md/interfaces/CameraKitBootstrapConfiguration.md +1 -1
- package/docs/md/interfaces/CameraKitSourceSubscriber.md +1 -1
- package/docs/md/interfaces/ComputedFrameMetrics.md +1 -1
- package/docs/md/interfaces/CreateSessionOptions.md +1 -1
- package/docs/md/interfaces/EstimatedLensPerformance.md +1 -1
- package/docs/md/interfaces/Lens.md +1 -1
- package/docs/md/interfaces/LensSource.md +3 -3
- package/docs/md/interfaces/MediaStreamSourceOptions.md +1 -1
- package/docs/md/interfaces/Preview.md +1 -1
- package/docs/md/interfaces/RemoteApiRequest.md +46 -0
- package/docs/md/interfaces/RemoteApiResponse.md +37 -0
- package/docs/md/interfaces/RemoteApiService.md +45 -0
- package/docs/md/interfaces/Snapcode.md +1 -1
- package/docs/md/interfaces/UriCancelRequest.md +1 -1
- package/docs/md/interfaces/UriRequest.md +9 -2
- package/docs/md/interfaces/UriResponse.md +1 -1
- package/docs/md/interfaces/VideoSourceOptions.md +1 -1
- package/docs/md/modules.md +66 -15
- package/lib/CameraKit.d.ts +16 -6
- package/lib/CameraKit.js +3 -1
- package/lib/CameraKit.js.map +1 -1
- package/lib/__tests__/data.d.ts +1 -1
- package/lib/__tests__/data.js +1 -0
- package/lib/__tests__/data.js.map +1 -1
- package/lib/assertPlatformSupported.d.ts +3 -1
- package/lib/assertPlatformSupported.js +13 -2
- package/lib/assertPlatformSupported.js.map +1 -1
- package/lib/bootstrapCameraKit.js +13 -9
- package/lib/bootstrapCameraKit.js.map +1 -1
- package/lib/common/any.d.ts +17 -0
- package/lib/common/any.js +36 -0
- package/lib/common/any.js.map +1 -0
- package/lib/common/cameraKitUserAgent.d.ts +5 -0
- package/lib/common/cameraKitUserAgent.js +18 -2
- package/lib/common/cameraKitUserAgent.js.map +1 -1
- package/lib/common/date.d.ts +3 -0
- package/lib/common/date.js +13 -0
- package/lib/common/date.js.map +1 -0
- package/lib/common/dialog.d.ts +43 -0
- package/lib/common/dialog.js +26 -12
- package/lib/common/dialog.js.map +1 -1
- package/lib/common/errorHelpers.js +1 -1
- package/lib/common/errorHelpers.js.map +1 -1
- package/lib/common/time.d.ts +1 -0
- package/lib/common/time.js +1 -0
- package/lib/common/time.js.map +1 -1
- package/lib/common/types.d.ts +8 -0
- package/lib/common/types.js.map +1 -1
- package/lib/configuration.d.ts +2 -0
- package/lib/configuration.js +1 -0
- package/lib/configuration.js.map +1 -1
- package/lib/dependency-injection/RootServices.d.ts +4 -0
- package/lib/dependency-injection/RootServices.js.map +1 -1
- package/lib/environment.json +1 -1
- package/lib/extensions/LensSources.d.ts +2 -2
- package/lib/extensions/LensSources.js +7 -3
- package/lib/extensions/LensSources.js.map +1 -1
- package/lib/extensions/RemoteApiServices.d.ts +101 -0
- package/lib/extensions/RemoteApiServices.js +198 -0
- package/lib/extensions/RemoteApiServices.js.map +1 -0
- package/lib/extensions/UriHandlers.d.ts +10 -17
- package/lib/extensions/UriHandlers.js +5 -60
- package/lib/extensions/UriHandlers.js.map +1 -1
- package/lib/extensions/uriHandlersRegister.d.ts +21 -0
- package/lib/extensions/uriHandlersRegister.js +72 -0
- package/lib/extensions/uriHandlersRegister.js.map +1 -0
- package/lib/generated-proto/blizzard/cameraKitEvents.js.map +1 -1
- package/lib/generated-proto/pb_schema/camera_kit/v3/business_events.d.ts +0 -26
- package/lib/generated-proto/pb_schema/camera_kit/v3/business_events.js +0 -15
- package/lib/generated-proto/pb_schema/camera_kit/v3/business_events.js.map +1 -1
- package/lib/generated-proto/pb_schema/camera_kit/v3/export.d.ts +0 -59
- package/lib/generated-proto/pb_schema/camera_kit/v3/export.js +0 -10
- package/lib/generated-proto/pb_schema/camera_kit/v3/export.js.map +1 -1
- package/lib/generated-proto/pb_schema/camera_kit/v3/features/remote_api_info.d.ts +31 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/features/remote_api_info.js +43 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/features/remote_api_info.js.map +1 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/legal_prompt.d.ts +0 -13
- package/lib/generated-proto/pb_schema/camera_kit/v3/legal_prompt.js +0 -7
- package/lib/generated-proto/pb_schema/camera_kit/v3/legal_prompt.js.map +1 -1
- package/lib/generated-proto/pb_schema/camera_kit/v3/lens.d.ts +0 -55
- package/lib/generated-proto/pb_schema/camera_kit/v3/lens.js +0 -12
- package/lib/generated-proto/pb_schema/camera_kit/v3/lens.js.map +1 -1
- package/lib/generated-proto/pb_schema/camera_kit/v3/operational_metrics.d.ts +0 -5
- package/lib/generated-proto/pb_schema/camera_kit/v3/operational_metrics.js +0 -7
- package/lib/generated-proto/pb_schema/camera_kit/v3/operational_metrics.js.map +1 -1
- package/lib/generated-proto/pb_schema/camera_kit/v3/ranking.d.ts +0 -23
- package/lib/generated-proto/pb_schema/camera_kit/v3/ranking.js +0 -15
- package/lib/generated-proto/pb_schema/camera_kit/v3/ranking.js.map +1 -1
- package/lib/generated-proto/pb_schema/camera_kit/v3/service.d.ts +0 -62
- package/lib/generated-proto/pb_schema/camera_kit/v3/service.js +0 -1
- package/lib/generated-proto/pb_schema/camera_kit/v3/service.js.map +1 -1
- package/lib/generated-proto/pb_schema/cdp/cof/benchmark.d.ts +0 -8
- package/lib/generated-proto/pb_schema/cdp/cof/benchmark.js +0 -1
- package/lib/generated-proto/pb_schema/cdp/cof/benchmark.js.map +1 -1
- package/lib/generated-proto/pb_schema/cdp/cof/benchmark_name.d.ts +0 -45
- package/lib/generated-proto/pb_schema/cdp/cof/benchmark_name.js +0 -46
- package/lib/generated-proto/pb_schema/cdp/cof/benchmark_name.js.map +1 -1
- package/lib/generated-proto/pb_schema/cdp/cof/circumstance_service.d.ts +0 -104
- package/lib/generated-proto/pb_schema/cdp/cof/circumstance_service.js +0 -1
- package/lib/generated-proto/pb_schema/cdp/cof/circumstance_service.js.map +1 -1
- package/lib/generated-proto/pb_schema/cdp/cof/config_request.d.ts +0 -129
- package/lib/generated-proto/pb_schema/cdp/cof/config_request.js +0 -24
- package/lib/generated-proto/pb_schema/cdp/cof/config_request.js.map +1 -1
- package/lib/generated-proto/pb_schema/cdp/cof/config_response.d.ts +0 -22
- package/lib/generated-proto/pb_schema/cdp/cof/config_response.js +0 -1
- package/lib/generated-proto/pb_schema/cdp/cof/config_response.js.map +1 -1
- package/lib/generated-proto/pb_schema/cdp/cof/config_result.d.ts +0 -510
- package/lib/generated-proto/pb_schema/cdp/cof/config_result.js +0 -415
- package/lib/generated-proto/pb_schema/cdp/cof/config_result.js.map +1 -1
- package/lib/generated-proto/pb_schema/cdp/cof/debug_info.d.ts +0 -9
- package/lib/generated-proto/pb_schema/cdp/cof/debug_info.js +0 -3
- package/lib/generated-proto/pb_schema/cdp/cof/debug_info.js.map +1 -1
- package/lib/generated-proto/pb_schema/cdp/cof/namespace.d.ts +1 -1
- package/lib/generated-proto/pb_schema/cdp/cof/namespace.js +1 -2
- package/lib/generated-proto/pb_schema/cdp/cof/namespace.js.map +1 -1
- package/lib/generated-proto/pb_schema/common/ruid.d.ts +0 -27
- package/lib/generated-proto/pb_schema/common/ruid.js +0 -20
- package/lib/generated-proto/pb_schema/common/ruid.js.map +1 -1
- package/lib/generated-proto/pb_schema/common/value.d.ts +0 -9
- package/lib/generated-proto/pb_schema/common/value.js +0 -1
- package/lib/generated-proto/pb_schema/common/value.js.map +1 -1
- package/lib/generated-proto/pb_schema/google/protobuf/any.d.ts +0 -105
- package/lib/generated-proto/pb_schema/google/protobuf/any.js +0 -1
- package/lib/generated-proto/pb_schema/google/protobuf/any.js.map +1 -1
- package/lib/generated-proto/pb_schema/google/protobuf/timestamp.d.ts +0 -64
- package/lib/generated-proto/pb_schema/google/protobuf/timestamp.js +0 -1
- package/lib/generated-proto/pb_schema/google/protobuf/timestamp.js.map +1 -1
- package/lib/generated-proto/pb_schema/google/protobuf/wrappers.d.ts +0 -54
- package/lib/generated-proto/pb_schema/google/protobuf/wrappers.js +0 -1
- package/lib/generated-proto/pb_schema/google/protobuf/wrappers.js.map +1 -1
- package/lib/generated-proto/pb_schema/lenses/geocircle.js +0 -1
- package/lib/generated-proto/pb_schema/lenses/geocircle.js.map +1 -1
- package/lib/generated-proto/pb_schema/lenses/geopoint.js +0 -1
- package/lib/generated-proto/pb_schema/lenses/geopoint.js.map +1 -1
- package/lib/generated-proto/pb_schema/lenses/launch_params.js +0 -1
- package/lib/generated-proto/pb_schema/lenses/launch_params.js.map +1 -1
- package/lib/generated-proto/pb_schema/lenses/launchdata.d.ts +0 -2
- package/lib/generated-proto/pb_schema/lenses/launchdata.js +0 -3
- package/lib/generated-proto/pb_schema/lenses/launchdata.js.map +1 -1
- package/lib/generated-proto/pb_schema/lenses/lures.d.ts +0 -2
- package/lib/generated-proto/pb_schema/lenses/lures.js +0 -1
- package/lib/generated-proto/pb_schema/lenses/lures.js.map +1 -1
- package/lib/generated-proto/pb_schema/lenses/persistent_store.js +0 -1
- package/lib/generated-proto/pb_schema/lenses/persistent_store.js.map +1 -1
- package/lib/generated-proto/pb_schema/lenses/remote_api/remote_api_service.d.ts +569 -0
- package/lib/generated-proto/pb_schema/lenses/remote_api/remote_api_service.js +1175 -0
- package/lib/generated-proto/pb_schema/lenses/remote_api/remote_api_service.js.map +1 -0
- package/lib/generated-proto/pb_schema/lenses/snappable.d.ts +0 -19
- package/lib/generated-proto/pb_schema/lenses/snappable.js +0 -2
- package/lib/generated-proto/pb_schema/lenses/snappable.js.map +1 -1
- package/lib/generated-proto/pb_schema/lenses/user_data.d.ts +0 -18
- package/lib/generated-proto/pb_schema/lenses/user_data.js +0 -1
- package/lib/generated-proto/pb_schema/lenses/user_data.js.map +1 -1
- package/lib/handlers/defaultFetchHandler.js +17 -4
- package/lib/handlers/defaultFetchHandler.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/legal/legalPrompt.js +29 -27
- package/lib/legal/legalPrompt.js.map +1 -1
- package/lib/legal/legalState.js +1 -1
- package/lib/legal/legalState.js.map +1 -1
- package/lib/lens/LensRepository.d.ts +5 -3
- package/lib/lens/LensRepository.js +8 -5
- package/lib/lens/LensRepository.js.map +1 -1
- package/lib/lens/assets/LensAssetsProvider.js +18 -3
- package/lib/lens/assets/LensAssetsProvider.js.map +1 -1
- package/lib/lens/lensHttpUtil.d.ts +3 -2
- package/lib/lens/lensHttpUtil.js +31 -9
- package/lib/lens/lensHttpUtil.js.map +1 -1
- package/lib/lens-core-module/generated-types.d.ts +42 -1
- package/lib/lens-core-module/generated-types.js.map +1 -1
- package/lib/lensCoreWasmVersions.json +3 -3
- package/lib/logger/registerLogEntriesSubscriber.js +13 -1
- package/lib/logger/registerLogEntriesSubscriber.js.map +1 -1
- package/lib/media-sources/CameraKitSource.d.ts +13 -3
- package/lib/media-sources/CameraKitSource.js +2 -8
- package/lib/media-sources/CameraKitSource.js.map +1 -1
- package/lib/media-sources/FunctionSource.d.ts +1 -1
- package/lib/media-sources/FunctionSource.js +1 -1
- package/lib/media-sources/FunctionSource.js.map +1 -1
- package/lib/media-sources/ImageSource.d.ts +1 -1
- package/lib/media-sources/ImageSource.js +1 -1
- package/lib/media-sources/ImageSource.js.map +1 -1
- package/lib/media-sources/MediaStreamSource.d.ts +1 -1
- package/lib/media-sources/MediaStreamSource.js +6 -1
- package/lib/media-sources/MediaStreamSource.js.map +1 -1
- package/lib/media-sources/VideoSource.d.ts +1 -1
- package/lib/media-sources/VideoSource.js +1 -1
- package/lib/media-sources/VideoSource.js.map +1 -1
- package/lib/metrics/businessEventsReporter.d.ts +4 -2
- package/lib/metrics/businessEventsReporter.js +134 -68
- package/lib/metrics/businessEventsReporter.js.map +1 -1
- package/lib/metrics/operational/operationalMetricsReporter.d.ts +3 -2
- package/lib/metrics/operational/operationalMetricsReporter.js +31 -11
- package/lib/metrics/operational/operationalMetricsReporter.js.map +1 -1
- package/lib/metrics/reporters/reportHttpMetrics.d.ts +0 -7
- package/lib/metrics/reporters/reportHttpMetrics.js +3 -2
- package/lib/metrics/reporters/reportHttpMetrics.js.map +1 -1
- package/lib/metrics/reporters/reportLensView.d.ts +1 -1
- package/lib/metrics/reporters/reportLensView.js +41 -13
- package/lib/metrics/reporters/reportLensView.js.map +1 -1
- package/lib/metrics/reporters/reportUserSession.js +15 -16
- package/lib/metrics/reporters/reportUserSession.js.map +1 -1
- package/lib/metrics/reporters/reporters.d.ts +1 -1
- package/lib/persistence/ExpiringPersistence.d.ts +2 -1
- package/lib/persistence/ExpiringPersistence.js +15 -1
- package/lib/persistence/ExpiringPersistence.js.map +1 -1
- package/lib/persistence/IndexedDBPersistence.d.ts +1 -1
- package/lib/persistence/IndexedDBPersistence.js +11 -1
- package/lib/persistence/IndexedDBPersistence.js.map +1 -1
- package/lib/persistence/Persistence.d.ts +1 -1
- package/lib/persistence/Persistence.js.map +1 -1
- package/lib/remote-configuration/cofHandler.d.ts +10 -6
- package/lib/remote-configuration/cofHandler.js +77 -67
- package/lib/remote-configuration/cofHandler.js.map +1 -1
- package/lib/remote-configuration/preloadConfiguration.d.ts +7 -0
- package/lib/remote-configuration/preloadConfiguration.js +15 -0
- package/lib/remote-configuration/preloadConfiguration.js.map +1 -0
- package/lib/remote-configuration/remoteConfiguration.d.ts +14 -7
- package/lib/remote-configuration/remoteConfiguration.js +15 -15
- package/lib/remote-configuration/remoteConfiguration.js.map +1 -1
- package/lib/session/CameraKitSession.d.ts +7 -2
- package/lib/session/CameraKitSession.js +1 -0
- package/lib/session/CameraKitSession.js.map +1 -1
- package/lib/session/sessionState.d.ts +2 -2
- package/lib/session/sessionState.js +3 -3
- package/lib/session/sessionState.js.map +1 -1
- package/package.json +2 -1
- package/docs/md/interfaces/UriHandler.md +0 -63
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[CameraKit Web SDK - v0.
|
|
1
|
+
[CameraKit Web SDK - v0.13.0-alpha.1](../README.md) / [Exports](../modules.md) / LensSource
|
|
2
2
|
|
|
3
3
|
# Interface: LensSource
|
|
4
4
|
|
|
@@ -34,7 +34,7 @@ ___
|
|
|
34
34
|
|
|
35
35
|
### getLens
|
|
36
36
|
|
|
37
|
-
▸ **getLens**(`lensId`, `groupId`): `Promise`<`ArrayBuffer`\>
|
|
37
|
+
▸ `Optional` **getLens**(`lensId`, `groupId`): `Promise`<`ArrayBuffer`\>
|
|
38
38
|
|
|
39
39
|
Returns an encoded lens object.
|
|
40
40
|
|
|
@@ -53,7 +53,7 @@ ___
|
|
|
53
53
|
|
|
54
54
|
### getLensGroup
|
|
55
55
|
|
|
56
|
-
▸ **getLensGroup**(`groupId`): `Promise`<`ArrayBuffer`[]\>
|
|
56
|
+
▸ `Optional` **getLensGroup**(`groupId`): `Promise`<`ArrayBuffer`[]\>
|
|
57
57
|
|
|
58
58
|
Returns encoded lens objects.
|
|
59
59
|
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
[CameraKit Web SDK - v0.13.0-alpha.1](../README.md) / [Exports](../modules.md) / RemoteApiRequest
|
|
2
|
+
|
|
3
|
+
# Interface: RemoteApiRequest
|
|
4
|
+
|
|
5
|
+
Remote API request sent by a lens.
|
|
6
|
+
|
|
7
|
+
## Table of contents
|
|
8
|
+
|
|
9
|
+
### Properties
|
|
10
|
+
|
|
11
|
+
- [apiSpecId](RemoteApiRequest.md#apispecid)
|
|
12
|
+
- [endpointId](RemoteApiRequest.md#endpointid)
|
|
13
|
+
- [parameters](RemoteApiRequest.md#parameters)
|
|
14
|
+
- [body](RemoteApiRequest.md#body)
|
|
15
|
+
|
|
16
|
+
## Properties
|
|
17
|
+
|
|
18
|
+
### apiSpecId
|
|
19
|
+
|
|
20
|
+
• **apiSpecId**: `string`
|
|
21
|
+
|
|
22
|
+
Unique id of the remote API service specification.
|
|
23
|
+
|
|
24
|
+
___
|
|
25
|
+
|
|
26
|
+
### endpointId
|
|
27
|
+
|
|
28
|
+
• **endpointId**: `string`
|
|
29
|
+
|
|
30
|
+
Unique id of the remote API service endpoint requested by this request.
|
|
31
|
+
|
|
32
|
+
___
|
|
33
|
+
|
|
34
|
+
### parameters
|
|
35
|
+
|
|
36
|
+
• **parameters**: `Record`<`string`, `string`\>
|
|
37
|
+
|
|
38
|
+
A map of named parameters associated with the request.
|
|
39
|
+
|
|
40
|
+
___
|
|
41
|
+
|
|
42
|
+
### body
|
|
43
|
+
|
|
44
|
+
• **body**: `ArrayBuffer`
|
|
45
|
+
|
|
46
|
+
Additional binary request payload.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
[CameraKit Web SDK - v0.13.0-alpha.1](../README.md) / [Exports](../modules.md) / RemoteApiResponse
|
|
2
|
+
|
|
3
|
+
# Interface: RemoteApiResponse
|
|
4
|
+
|
|
5
|
+
Remote API response to a request sent by a lens.
|
|
6
|
+
|
|
7
|
+
## Table of contents
|
|
8
|
+
|
|
9
|
+
### Properties
|
|
10
|
+
|
|
11
|
+
- [status](RemoteApiResponse.md#status)
|
|
12
|
+
- [metadata](RemoteApiResponse.md#metadata)
|
|
13
|
+
- [body](RemoteApiResponse.md#body)
|
|
14
|
+
|
|
15
|
+
## Properties
|
|
16
|
+
|
|
17
|
+
### status
|
|
18
|
+
|
|
19
|
+
• **status**: ``"timeout"`` \| ``"success"`` \| ``"redirected"`` \| ``"cancelled"`` \| ``"notFound"`` \| ``"badRequest"`` \| ``"accessDenied"`` \| ``"requestTooLarge"`` \| ``"serverError"`` \| ``"proxyError"``
|
|
20
|
+
|
|
21
|
+
Status of the response
|
|
22
|
+
|
|
23
|
+
___
|
|
24
|
+
|
|
25
|
+
### metadata
|
|
26
|
+
|
|
27
|
+
• **metadata**: `Record`<`string`, `string`\>
|
|
28
|
+
|
|
29
|
+
A map of named metadata associated with the response.
|
|
30
|
+
|
|
31
|
+
___
|
|
32
|
+
|
|
33
|
+
### body
|
|
34
|
+
|
|
35
|
+
• **body**: `ArrayBuffer`
|
|
36
|
+
|
|
37
|
+
Additional binary request payload.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
[CameraKit Web SDK - v0.13.0-alpha.1](../README.md) / [Exports](../modules.md) / RemoteApiService
|
|
2
|
+
|
|
3
|
+
# Interface: RemoteApiService
|
|
4
|
+
|
|
5
|
+
Service to handle a lens Remote API request.
|
|
6
|
+
|
|
7
|
+
## Table of contents
|
|
8
|
+
|
|
9
|
+
### Properties
|
|
10
|
+
|
|
11
|
+
- [apiSpecId](RemoteApiService.md#apispecid)
|
|
12
|
+
|
|
13
|
+
### Methods
|
|
14
|
+
|
|
15
|
+
- [getRequestHandler](RemoteApiService.md#getrequesthandler)
|
|
16
|
+
|
|
17
|
+
## Properties
|
|
18
|
+
|
|
19
|
+
### apiSpecId
|
|
20
|
+
|
|
21
|
+
• **apiSpecId**: `string`
|
|
22
|
+
|
|
23
|
+
Remote API spec ID(s).
|
|
24
|
+
|
|
25
|
+
## Methods
|
|
26
|
+
|
|
27
|
+
### getRequestHandler
|
|
28
|
+
|
|
29
|
+
▸ **getRequestHandler**(`request`, `lens`): `undefined` \| [`RemoteApiRequestHandler`](../modules.md#remoteapirequesthandler)
|
|
30
|
+
|
|
31
|
+
This method is called by Camera Kit when a lens triggers a Remote API request with a corresponding spec ID.
|
|
32
|
+
If the service can handle the request, the method returns a request handler; otherwise, it returns nothing.
|
|
33
|
+
|
|
34
|
+
#### Parameters
|
|
35
|
+
|
|
36
|
+
| Name | Type | Description |
|
|
37
|
+
| :------ | :------ | :------ |
|
|
38
|
+
| `request` | [`RemoteApiRequest`](RemoteApiRequest.md) | Remote API request object. |
|
|
39
|
+
| `lens` | [`Lens`](Lens.md) | Lens that trigges the request. |
|
|
40
|
+
|
|
41
|
+
#### Returns
|
|
42
|
+
|
|
43
|
+
`undefined` \| [`RemoteApiRequestHandler`](../modules.md#remoteapirequesthandler)
|
|
44
|
+
|
|
45
|
+
A request handler if applicable.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[CameraKit Web SDK - v0.
|
|
1
|
+
[CameraKit Web SDK - v0.13.0-alpha.1](../README.md) / [Exports](../modules.md) / UriRequest
|
|
2
2
|
|
|
3
3
|
# Interface: UriRequest
|
|
4
4
|
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
- [method](UriRequest.md#method)
|
|
12
12
|
- [contentType](UriRequest.md#contenttype)
|
|
13
13
|
- [data](UriRequest.md#data)
|
|
14
|
+
- [metadata](UriRequest.md#metadata)
|
|
14
15
|
|
|
15
16
|
## Properties
|
|
16
17
|
|
|
@@ -28,7 +29,7 @@ ___
|
|
|
28
29
|
|
|
29
30
|
### method
|
|
30
31
|
|
|
31
|
-
• **method**: ``"
|
|
32
|
+
• **method**: ``"POST"`` \| ``"GET"``
|
|
32
33
|
|
|
33
34
|
___
|
|
34
35
|
|
|
@@ -41,3 +42,9 @@ ___
|
|
|
41
42
|
### data
|
|
42
43
|
|
|
43
44
|
• **data**: `ArrayBuffer`
|
|
45
|
+
|
|
46
|
+
___
|
|
47
|
+
|
|
48
|
+
### metadata
|
|
49
|
+
|
|
50
|
+
• **metadata**: `Record`<`string`, `string`\>
|
package/docs/md/modules.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
[CameraKit Web SDK - v0.
|
|
1
|
+
[CameraKit Web SDK - v0.13.0-alpha.1](README.md) / Exports
|
|
2
2
|
|
|
3
|
-
# CameraKit Web SDK - v0.
|
|
3
|
+
# CameraKit Web SDK - v0.13.0-alpha.1
|
|
4
4
|
|
|
5
5
|
## Table of contents
|
|
6
6
|
|
|
@@ -23,7 +23,9 @@
|
|
|
23
23
|
- [EstimatedLensPerformance](interfaces/EstimatedLensPerformance.md)
|
|
24
24
|
- [CameraKitBootstrapConfiguration](interfaces/CameraKitBootstrapConfiguration.md)
|
|
25
25
|
- [LensSource](interfaces/LensSource.md)
|
|
26
|
-
- [
|
|
26
|
+
- [RemoteApiRequest](interfaces/RemoteApiRequest.md)
|
|
27
|
+
- [RemoteApiResponse](interfaces/RemoteApiResponse.md)
|
|
28
|
+
- [RemoteApiService](interfaces/RemoteApiService.md)
|
|
27
29
|
- [UriRequest](interfaces/UriRequest.md)
|
|
28
30
|
- [UriResponse](interfaces/UriResponse.md)
|
|
29
31
|
- [UriCancelRequest](interfaces/UriCancelRequest.md)
|
|
@@ -40,12 +42,15 @@
|
|
|
40
42
|
- [LensMetricsEvents](modules.md#lensmetricsevents)
|
|
41
43
|
- [LensPerformanceCluster](modules.md#lensperformancecluster)
|
|
42
44
|
- [PublicContainer](modules.md#publiccontainer)
|
|
43
|
-
- [
|
|
45
|
+
- [RemoteApiStatus](modules.md#remoteapistatus)
|
|
46
|
+
- [RemoteApiRequestHandler](modules.md#remoteapirequesthandler)
|
|
47
|
+
- [RemoteApiServices](modules.md#remoteapiservices)
|
|
44
48
|
- [Uri](modules.md#uri)
|
|
45
49
|
- [LensLaunchParams](modules.md#lenslaunchparams)
|
|
46
50
|
- [AssetTiming](modules.md#assettiming)
|
|
47
51
|
- [AssetLoader](modules.md#assetloader)
|
|
48
52
|
- [CameraKitDeviceInfo](modules.md#camerakitdeviceinfo)
|
|
53
|
+
- [CameraKitDeviceOptions](modules.md#camerakitdeviceoptions)
|
|
49
54
|
- [CameraKitSourceInfo](modules.md#camerakitsourceinfo)
|
|
50
55
|
- [CameraKitSourceOptions](modules.md#camerakitsourceoptions)
|
|
51
56
|
- [LensView](modules.md#lensview)
|
|
@@ -81,7 +86,7 @@
|
|
|
81
86
|
- [createExtension](modules.md#createextension)
|
|
82
87
|
- [Injectable](modules.md#injectable)
|
|
83
88
|
- [lensSourcesFactory](modules.md#lenssourcesfactory)
|
|
84
|
-
- [
|
|
89
|
+
- [remoteApiServicesFactory](modules.md#remoteapiservicesfactory)
|
|
85
90
|
- [getRequiredBootstrapURLs](modules.md#getrequiredbootstrapurls)
|
|
86
91
|
- [createImageSource](modules.md#createimagesource)
|
|
87
92
|
- [createUserMediaSource](modules.md#createusermediasource)
|
|
@@ -460,11 +465,42 @@ should decrease – we measure between the request to apply a lens and when the
|
|
|
460
465
|
|
|
461
466
|
## Other
|
|
462
467
|
|
|
463
|
-
###
|
|
468
|
+
### RemoteApiStatus
|
|
464
469
|
|
|
465
|
-
Ƭ **
|
|
470
|
+
Ƭ **RemoteApiStatus**: keyof typeof `statusToResponseCodeMap`
|
|
466
471
|
|
|
467
|
-
|
|
472
|
+
Status of a Remote API response.
|
|
473
|
+
|
|
474
|
+
___
|
|
475
|
+
|
|
476
|
+
### RemoteApiRequestHandler
|
|
477
|
+
|
|
478
|
+
Ƭ **RemoteApiRequestHandler**: (`reply`: (`response`: [`RemoteApiResponse`](interfaces/RemoteApiResponse.md)) => `void`) => `RemoteApiCancelRequestHandler` \| `void`
|
|
479
|
+
|
|
480
|
+
#### Type declaration
|
|
481
|
+
|
|
482
|
+
▸ (`reply`): `RemoteApiCancelRequestHandler` \| `void`
|
|
483
|
+
|
|
484
|
+
Represents a Remote API request handler function.
|
|
485
|
+
It is provided with a reply callback that must be invoked to send a response back to the lens.
|
|
486
|
+
The reply callback can be invoked multiple times if needed.
|
|
487
|
+
Additionally, the handler can return a cancellation callback, which is triggered when the lens cancels the request.
|
|
488
|
+
|
|
489
|
+
##### Parameters
|
|
490
|
+
|
|
491
|
+
| Name | Type |
|
|
492
|
+
| :------ | :------ |
|
|
493
|
+
| `reply` | (`response`: [`RemoteApiResponse`](interfaces/RemoteApiResponse.md)) => `void` |
|
|
494
|
+
|
|
495
|
+
##### Returns
|
|
496
|
+
|
|
497
|
+
`RemoteApiCancelRequestHandler` \| `void`
|
|
498
|
+
|
|
499
|
+
___
|
|
500
|
+
|
|
501
|
+
### RemoteApiServices
|
|
502
|
+
|
|
503
|
+
Ƭ **RemoteApiServices**: [`RemoteApiService`](interfaces/RemoteApiService.md)[]
|
|
468
504
|
|
|
469
505
|
___
|
|
470
506
|
|
|
@@ -679,11 +715,9 @@ ___
|
|
|
679
715
|
|
|
680
716
|
___
|
|
681
717
|
|
|
682
|
-
###
|
|
683
|
-
|
|
684
|
-
▸ **uriHandlersFactory**(`...args`): [`UriHandlers`](modules.md#urihandlers)
|
|
718
|
+
### remoteApiServicesFactory
|
|
685
719
|
|
|
686
|
-
|
|
720
|
+
▸ **remoteApiServicesFactory**(`...args`): [`RemoteApiServices`](modules.md#remoteapiservices)
|
|
687
721
|
|
|
688
722
|
#### Parameters
|
|
689
723
|
|
|
@@ -693,7 +727,7 @@ An extension point for client URI handlers.
|
|
|
693
727
|
|
|
694
728
|
#### Returns
|
|
695
729
|
|
|
696
|
-
[`
|
|
730
|
+
[`RemoteApiServices`](modules.md#remoteapiservices)
|
|
697
731
|
|
|
698
732
|
## Rendering
|
|
699
733
|
|
|
@@ -701,18 +735,35 @@ An extension point for client URI handlers.
|
|
|
701
735
|
|
|
702
736
|
Ƭ **CameraKitDeviceInfo**: `Object`
|
|
703
737
|
|
|
738
|
+
**`Deprecated`**
|
|
739
|
+
|
|
740
|
+
use [CameraKitDeviceOptions](modules.md#camerakitdeviceoptions)
|
|
741
|
+
|
|
742
|
+
#### Type declaration
|
|
743
|
+
|
|
744
|
+
| Name | Type | Description |
|
|
745
|
+
| :------ | :------ | :------ |
|
|
746
|
+
| `cameraType` | ``"front"`` \| ``"back"`` | **`Deprecated`** "front" and "back" are deprecated please use "user" or "enviroment" for cameraType instead |
|
|
747
|
+
| `fpsLimit` | `number` | - |
|
|
748
|
+
|
|
749
|
+
___
|
|
750
|
+
|
|
751
|
+
### CameraKitDeviceOptions
|
|
752
|
+
|
|
753
|
+
Ƭ **CameraKitDeviceOptions**: `Object`
|
|
754
|
+
|
|
704
755
|
#### Type declaration
|
|
705
756
|
|
|
706
757
|
| Name | Type |
|
|
707
758
|
| :------ | :------ |
|
|
708
|
-
| `cameraType` | ``"
|
|
759
|
+
| `cameraType` | ``"user"`` \| ``"environment"`` |
|
|
709
760
|
| `fpsLimit` | `number` |
|
|
710
761
|
|
|
711
762
|
___
|
|
712
763
|
|
|
713
764
|
### CameraKitSourceOptions
|
|
714
765
|
|
|
715
|
-
Ƭ **CameraKitSourceOptions**<`T`\>: `Partial`<`T`\> & `Partial`<[`CameraKitDeviceInfo`](modules.md#camerakitdeviceinfo)\>
|
|
766
|
+
Ƭ **CameraKitSourceOptions**<`T`\>: `Partial`<`T`\> & `Partial`<[`CameraKitDeviceInfo`](modules.md#camerakitdeviceinfo) \| [`CameraKitDeviceOptions`](modules.md#camerakitdeviceoptions)\>
|
|
716
767
|
|
|
717
768
|
#### Type parameters
|
|
718
769
|
|
package/lib/CameraKit.d.ts
CHANGED
|
@@ -130,13 +130,23 @@ export declare const cameraKitFactory: {
|
|
|
130
130
|
token: "cameraKitServiceFetchHandler";
|
|
131
131
|
dependencies: readonly ["configuration", "defaultFetchHandler"];
|
|
132
132
|
}, {
|
|
133
|
-
(args_0: import("./configuration").CameraKitConfiguration, args_1: import("./handlers/requestStateEmittingHandler").RequestStateEventTarget, args_2: import("./metrics/operational/operationalMetricsReporter").OperationalMetricsReporter
|
|
133
|
+
(args_0: import("./configuration").CameraKitConfiguration, args_1: import("./handlers/requestStateEmittingHandler").RequestStateEventTarget, args_2: import("./metrics/operational/operationalMetricsReporter").OperationalMetricsReporter): import("./handlers/HandlerChainBuilder").Handler<Partial<import("./generated-proto/pb_schema/cdp/cof/config_request").ConfigTargetingRequest>, import("./generated-proto/pb_schema/cdp/cof/config_response").ConfigTargetingResponse, import("./remote-configuration/cofHandler").Metadata & {
|
|
134
|
+
signal?: AbortSignal | null | undefined;
|
|
135
|
+
isSideEffect?: boolean | undefined;
|
|
136
|
+
}>;
|
|
137
|
+
token: "cofHandler";
|
|
138
|
+
dependencies: readonly ["configuration", "requestStateEventTarget", "operationalMetricsReporter"];
|
|
139
|
+
}, {
|
|
140
|
+
(args_0: import("./configuration").CameraKitConfiguration, args_1: import("./handlers/HandlerChainBuilder").Handler<Partial<import("./generated-proto/pb_schema/cdp/cof/config_request").ConfigTargetingRequest>, import("./generated-proto/pb_schema/cdp/cof/config_response").ConfigTargetingResponse, import("./remote-configuration/cofHandler").Metadata & {
|
|
141
|
+
signal?: AbortSignal | null | undefined;
|
|
142
|
+
isSideEffect?: boolean | undefined;
|
|
143
|
+
}>, args_2: import("./handlers").FetchHandler): import("./remote-configuration/remoteConfiguration").RemoteConfiguration;
|
|
134
144
|
token: "remoteConfiguration";
|
|
135
|
-
dependencies: readonly ["configuration", "
|
|
145
|
+
dependencies: readonly ["configuration", "cofHandler", "cameraKitServiceFetchHandler"];
|
|
136
146
|
}, {
|
|
137
|
-
(args_0: import("./handlers/requestStateEmittingHandler").RequestStateEventTarget, args_1: import("./handlers").FetchHandler, args_2: import("./handlers").FetchHandler, args_3: import("./lens").LensSources, args_4: import("./lens").LensAssetRepository): LensRepository;
|
|
147
|
+
(args_0: import("./handlers/requestStateEmittingHandler").RequestStateEventTarget, args_1: import("./handlers").FetchHandler, args_2: import("./handlers").FetchHandler, args_3: import("./lens").LensSources, args_4: import("./lens").LensAssetRepository, args_5: import("./configuration").CameraKitConfiguration): LensRepository;
|
|
138
148
|
token: "LensRepository";
|
|
139
|
-
dependencies: readonly ["requestStateEventTarget", "cameraKitServiceFetchHandler", "defaultFetchHandler", "lensSources", "lensAssetRepository"];
|
|
149
|
+
dependencies: readonly ["requestStateEventTarget", "cameraKitServiceFetchHandler", "defaultFetchHandler", "lensSources", "lensAssetRepository", "configuration"];
|
|
140
150
|
}, {
|
|
141
151
|
(args_0: LensCoreModule): import("./persistence/IndexedDBPersistence").IndexedDBPersistence<ArrayBuffer>;
|
|
142
152
|
token: "lensPersistenceStore";
|
|
@@ -146,9 +156,9 @@ export declare const cameraKitFactory: {
|
|
|
146
156
|
token: "metricsHandler";
|
|
147
157
|
dependencies: readonly ["cameraKitServiceFetchHandler", "pageVisibility"];
|
|
148
158
|
}, {
|
|
149
|
-
(args_0: import("./handlers").FetchHandler, args_1: PageVisibility): import("./metrics/operational/operationalMetricsReporter").OperationalMetricsReporter;
|
|
159
|
+
(args_0: import("./handlers").FetchHandler, args_1: PageVisibility, args_2: import("./configuration").CameraKitConfiguration): import("./metrics/operational/operationalMetricsReporter").OperationalMetricsReporter;
|
|
150
160
|
token: "operationalMetricsReporter";
|
|
151
|
-
dependencies: readonly ["metricsHandler", "pageVisibility"];
|
|
161
|
+
dependencies: readonly ["metricsHandler", "pageVisibility", "configuration"];
|
|
152
162
|
}, {
|
|
153
163
|
(args_0: LensCoreModule, args_1: import("./lens").AssetLoader, args_2: import("./lens").AssetLoader, args_3: import("./lens").AssetLoader, args_4: MetricsEventTarget, args_5: import("./handlers/requestStateEmittingHandler").RequestStateEventTarget): import("./lens").LensAssetRepository;
|
|
154
164
|
token: "lensAssetRepository";
|
package/lib/CameraKit.js
CHANGED
|
@@ -6,7 +6,7 @@ import { cameraKitSessionFactory } from "./session/CameraKitSession";
|
|
|
6
6
|
import { registerLensAssetsProvider } from "./lens/assets/LensAssetsProvider";
|
|
7
7
|
import { lensCoreFactory } from "./lens-core-module/loader/lensCoreFactory";
|
|
8
8
|
import { configurationToken } from "./configuration";
|
|
9
|
-
import { registerUriHandlers } from "./extensions/
|
|
9
|
+
import { registerUriHandlers } from "./extensions/uriHandlersRegister";
|
|
10
10
|
import { metricsEventTargetFactory } from "./metrics/metricsEventTarget";
|
|
11
11
|
import { reportSessionScopedMetrics } from "./metrics/reporters/reporters";
|
|
12
12
|
import { lensStateFactory } from "./session/lensState";
|
|
@@ -18,6 +18,7 @@ import { getLogger, resetLogger } from "./logger/logger";
|
|
|
18
18
|
import { errorLoggingDecorator } from "./logger/errorLoggingDecorator";
|
|
19
19
|
import { TypedEventTarget } from "./events/TypedEventTarget";
|
|
20
20
|
import { pageVisibilityFactory } from "./common/pageVisibility";
|
|
21
|
+
import { setPreloadedConfiguration } from "./remote-configuration/preloadConfiguration";
|
|
21
22
|
const logger = getLogger("CameraKit");
|
|
22
23
|
const log = errorLoggingDecorator(logger);
|
|
23
24
|
/**
|
|
@@ -127,6 +128,7 @@ export class CameraKit {
|
|
|
127
128
|
.provides(cameraKitSessionFactory)
|
|
128
129
|
.run(registerLensAssetsProvider)
|
|
129
130
|
.run(registerLensClientInterfaceHandler)
|
|
131
|
+
.run(setPreloadedConfiguration)
|
|
130
132
|
// We'll run a PartialContainer containing reporters for session-scoped metrics. Running this container
|
|
131
133
|
// allows each metric reporter to initialize itself (e.g. by adding event listeners to detect when certain
|
|
132
134
|
// actions occur).
|
package/lib/CameraKit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CameraKit.js","sourceRoot":"","sources":["../src/CameraKit.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,qBAAqB,EAAkB,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAa,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAE/D,OAAO,EAAoB,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AACvF,OAAO,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAsB,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAC7F,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,gBA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Ac,EAAE,SAAS,EAAE,OAAO,CAAC,CACnF,CAAC","sourcesContent":["import { lensRepositoryFactory, LensRepository } from \"./lens/LensRepository\";\nimport { CONTAINER, Container } from \"./dependency-injection/Container\";\nimport { Injectable } from \"./dependency-injection/Injectable\";\nimport { LensCoreError, LensCoreModule } from \"./lens-core-module/generated-types\";\nimport { CameraKitSession, cameraKitSessionFactory } from \"./session/CameraKitSession\";\nimport { registerLensAssetsProvider } from \"./lens/assets/LensAssetsProvider\";\nimport { lensCoreFactory } from \"./lens-core-module/loader/lensCoreFactory\";\nimport { configurationToken } from \"./configuration\";\nimport { RootServices } from \"./dependency-injection/RootServices\";\nimport { registerUriHandlers } from \"./extensions/UriHandlers\";\nimport { MetricsEventTarget, metricsEventTargetFactory } from \"./metrics/metricsEventTarget\";\nimport { reportSessionScopedMetrics } from \"./metrics/reporters/reporters\";\nimport { lensStateFactory } from \"./session/lensState\";\nimport { lensKeyboardFactory } from \"./session/LensKeyboard\";\nimport { registerLensClientInterfaceHandler } from \"./lens-client-interface/lensClientInterface\";\nimport { sessionStateFactory } from \"./session/sessionState\";\nimport { lensExecutionError } from \"./namedErrors\";\nimport { getLogger, resetLogger } from \"./logger/logger\";\nimport { errorLoggingDecorator } from \"./logger/errorLoggingDecorator\";\nimport { TypedEventTarget } from \"./events/TypedEventTarget\";\nimport { TypedCustomEvent } from \"./events/TypedCustomEvent\";\nimport { LensView } from \"./metrics/reporters/reportLensView\";\nimport { LensWait } from \"./metrics/reporters/reportLensWait\";\nimport { PageVisibility, pageVisibilityFactory } from \"./common/pageVisibility\";\n\nconst logger = getLogger(\"CameraKit\");\nconst log = errorLoggingDecorator(logger);\n\n/**\n * Metrics event names that are exposed to apps.\n */\nconst publicMetricsEventNames: Array<LensMetricsEvents[\"detail\"][\"name\"]> = [\"lensView\", \"lensWait\"];\n\n/**\n * Lens metrics events.\n *\n * These events are emitted by {@link CameraKit} to report lens usage, performance, apply latency, etc.\n *\n * @category Lenses\n * @category Metrics\n */\nexport type LensMetricsEvents =\n | TypedCustomEvent<LensView[\"name\"], LensView>\n | TypedCustomEvent<LensWait[\"name\"], LensWait>;\n\n/**\n * Options available when creating a {@link CameraKitSession}.\n *\n * @category Rendering\n */\nexport interface CreateSessionOptions {\n /**\n * Optionally provide an existing canvas element, on which the Live RenderTarget will be rendered.\n *\n * If this is not provided, CameraKit will create a new canvas element which can be added to the DOM.\n */\n liveRenderTarget?: HTMLCanvasElement;\n\n /**\n * Browsers optimize tabs when they are hidden - for example, by pausing the execution of requestAnimationFrame\n * callbacks.\n *\n * If you need the CameraKitSession to continue rendering even when the tab is in the background, set this to true.\n * There is a small performance penalty, and it's a good practice to only render in the background if absolutely\n * necessary.\n */\n renderWhileTabHidden?: boolean;\n}\n\n/**\n * The entry point to the CameraKit SDK's API. Most of CameraKit's features are accessed via this class.\n *\n * Applications obtain an instance of CameraKit by calling {@link bootstrapCameraKit}.\n *\n * @example\n * ```ts\n * const cameraKit = await bootstrapCameraKit(config)\n * ```\n *\n * Then this class can be used to:\n * - Create a {@link CameraKitSession} instance, which provides the API for setting up media inputs, applying Lenses,\n * and obtaining rendered `<canvas>` outputs.\n * - Query for lenses using {@link LensRepository}.\n * - Listen for lens usage metrics events using {@link MetricsEventTarget}.\n *\n * @category Rendering\n * @category Lenses\n */\nexport class CameraKit {\n /** @deprecated Use {@link lensRepository} */\n readonly lenses: { repository: LensRepository };\n\n /**\n * Business metrics (e.g. each time a lens is viewed) are emitted here.\n */\n readonly metrics: TypedEventTarget<LensMetricsEvents> = new TypedEventTarget();\n\n private sessions: CameraKitSession[] = [];\n\n /** @internal */\n constructor(\n /**\n * Used to query for lenses and lens groups.\n */\n readonly lensRepository: LensRepository,\n\n private readonly lensCore: LensCoreModule,\n private readonly pageVisibility: PageVisibility,\n private readonly container: Container<RootServices>,\n allMetrics: MetricsEventTarget\n ) {\n this.lenses = { repository: this.lensRepository };\n // Proxy only a subset of all metrics events to the public-facing emitter -- applications don't need to\n // know about most events.\n publicMetricsEventNames.forEach((eventName) => {\n allMetrics.addEventListener(eventName, (e) => this.metrics.dispatchEvent(e));\n });\n }\n\n /**\n * Create a CameraKitSession.\n *\n * This initializes the rendering engine and returns a {@link CameraKitSession} instance, which provides access\n * to Lens rendering.\n *\n * @example\n * ```ts\n * const cameraKit = await bootstrapCameraKit(config)\n * const session = await cameraKit.createSession()\n *\n * const lens = await cameraKit.lensRepository.loadLens(lensId, groupId)\n * session.applyLens(lens)\n * ```\n *\n * @param options\n */\n @log\n async createSession({\n liveRenderTarget,\n renderWhileTabHidden,\n }: CreateSessionOptions = {}): Promise<CameraKitSession> {\n // Any error happened during lens rendering can be processed by subscribing to sessionErrors\n const exceptionHandler = (error: LensCoreError) =>\n logger.error(\n lensExecutionError(\n \"Error occurred during lens execution. \" +\n \"The lens cannot be rendered and will be removed from the CameraKitSession.\",\n error\n )\n );\n\n /**\n * If/when we add support for multiple concurrent sessions, we'll need to create a copy of the LensCore WASM\n * module. If we move managing web workers into JS, spawing a new worker thread with its own copy of LensCore\n * probably becomes a lot more straightforward.\n *\n * Currently chromium has a bug preventing rendering while tab is hidden when LensCore is in worker mode.\n * In order to process tab while it is hidden, the current stopgap is to pass in renderWhileTabHidden as true,\n * which will initiate session in non worker mode, and set the RenderLoopMode to `SetTimeout`.\n */\n await new Promise<void>((onSuccess, onFailure) => {\n this.lensCore.initialize({\n canvas: liveRenderTarget,\n shouldUseWorker: !renderWhileTabHidden && this.container.get(configurationToken).shouldUseWorker,\n exceptionHandler,\n onSuccess,\n onFailure,\n });\n });\n\n await new Promise<void>((onSuccess, onFailure) => {\n this.lensCore.setRenderLoopMode({\n mode: renderWhileTabHidden\n ? this.lensCore.RenderLoopMode.SetTimeout\n : this.lensCore.RenderLoopMode.RequestAnimationFrame,\n onSuccess,\n onFailure,\n });\n });\n\n // Each session gets its own DI Container – some Services provided by this Container may be shared with the\n // root CameraKit Container, but others may be scoped to the session by passing their token to `copy()`.\n const sessionContainer = this.container\n // Right now this is a no-op. If/when we add support for multiple concurrent sessions, we may end up\n // scoping LensCore to the session.\n .copy()\n\n .provides(sessionStateFactory)\n .provides(lensStateFactory)\n .provides(lensKeyboardFactory)\n .provides(cameraKitSessionFactory)\n\n .run(registerLensAssetsProvider)\n .run(registerLensClientInterfaceHandler)\n\n // We'll run a PartialContainer containing reporters for session-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).\n .run(reportSessionScopedMetrics)\n\n // UriHandlers may have dependencies on session-scoped services (e.g. LensState, LensKeyboard), so they'll\n // be registered with LensCore here.\n .run(registerUriHandlers);\n\n const session = sessionContainer.get(cameraKitSessionFactory.token);\n this.sessions.push(session);\n return session;\n }\n\n /**\n * Destroys all sessions and frees all resources.\n */\n @log\n async destroy() {\n resetLogger();\n this.pageVisibility.destroy();\n await Promise.all(this.sessions.map((session) => session.destroy()));\n this.sessions = [];\n }\n}\n\n/** @internal */\nexport const cameraKitFactory = Injectable(\n \"CameraKit\",\n [\n lensRepositoryFactory.token,\n metricsEventTargetFactory.token,\n lensCoreFactory.token,\n pageVisibilityFactory.token,\n CONTAINER,\n ] as const,\n (\n lensRepository: LensRepository,\n metrics: MetricsEventTarget,\n lensCore: LensCoreModule,\n pageVisibility: PageVisibility,\n container: Container<RootServices>\n ) => new CameraKit(lensRepository, lensCore, pageVisibility, container, metrics)\n);\n"]}
|
|
1
|
+
{"version":3,"file":"CameraKit.js","sourceRoot":"","sources":["../src/CameraKit.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,qBAAqB,EAAkB,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAa,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAE/D,OAAO,EAAoB,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AACvF,OAAO,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,2CAA2C,C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gBAAgB;AAChB,MAAM,CAAC,MAAM,gBAAgB,GAAG,UAAU,CACtC,WAAW,EACX;IACI,qBAAqB,CAAC,KAAK;IAC3B,yBAAyB,CAAC,KAAK;IAC/B,eAAe,CAAC,KAAK;IACrB,qBAAqB,CAAC,KAAK;IAC3B,SAAS;CACH,EACV,CACI,cAA8B,EAC9B,OAA2B,EAC3B,QAAwB,EACxB,cAA8B,EAC9B,SAAkC,EACpC,EAAE,CAAC,IAAI,SAAS,CAAC,cAAc,EAAE,QAAQ,EAAE,cAAc,EAAE,SAAS,EAAE,OAAO,CAAC,CACnF,CAAC","sourcesContent":["import { lensRepositoryFactory, LensRepository } from \"./lens/LensRepository\";\nimport { CONTAINER, Container } from \"./dependency-injection/Container\";\nimport { Injectable } from \"./dependency-injection/Injectable\";\nimport { LensCoreError, LensCoreModule } from \"./lens-core-module/generated-types\";\nimport { CameraKitSession, cameraKitSessionFactory } from \"./session/CameraKitSession\";\nimport { registerLensAssetsProvider } from \"./lens/assets/LensAssetsProvider\";\nimport { lensCoreFactory } from \"./lens-core-module/loader/lensCoreFactory\";\nimport { configurationToken } from \"./configuration\";\nimport { RootServices } from \"./dependency-injection/RootServices\";\nimport { registerUriHandlers } from \"./extensions/uriHandlersRegister\";\nimport { MetricsEventTarget, metricsEventTargetFactory } from \"./metrics/metricsEventTarget\";\nimport { reportSessionScopedMetrics } from \"./metrics/reporters/reporters\";\nimport { lensStateFactory } from \"./session/lensState\";\nimport { lensKeyboardFactory } from \"./session/LensKeyboard\";\nimport { registerLensClientInterfaceHandler } from \"./lens-client-interface/lensClientInterface\";\nimport { sessionStateFactory } from \"./session/sessionState\";\nimport { lensExecutionError } from \"./namedErrors\";\nimport { getLogger, resetLogger } from \"./logger/logger\";\nimport { errorLoggingDecorator } from \"./logger/errorLoggingDecorator\";\nimport { TypedEventTarget } from \"./events/TypedEventTarget\";\nimport { TypedCustomEvent } from \"./events/TypedCustomEvent\";\nimport { LensView } from \"./metrics/reporters/reportLensView\";\nimport { LensWait } from \"./metrics/reporters/reportLensWait\";\nimport { PageVisibility, pageVisibilityFactory } from \"./common/pageVisibility\";\nimport { setPreloadedConfiguration } from \"./remote-configuration/preloadConfiguration\";\n\nconst logger = getLogger(\"CameraKit\");\nconst log = errorLoggingDecorator(logger);\n\n/**\n * Metrics event names that are exposed to apps.\n */\nconst publicMetricsEventNames: Array<LensMetricsEvents[\"detail\"][\"name\"]> = [\"lensView\", \"lensWait\"];\n\n/**\n * Lens metrics events.\n *\n * These events are emitted by {@link CameraKit} to report lens usage, performance, apply latency, etc.\n *\n * @category Lenses\n * @category Metrics\n */\nexport type LensMetricsEvents =\n | TypedCustomEvent<LensView[\"name\"], LensView>\n | TypedCustomEvent<LensWait[\"name\"], LensWait>;\n\n/**\n * Options available when creating a {@link CameraKitSession}.\n *\n * @category Rendering\n */\nexport interface CreateSessionOptions {\n /**\n * Optionally provide an existing canvas element, on which the Live RenderTarget will be rendered.\n *\n * If this is not provided, CameraKit will create a new canvas element which can be added to the DOM.\n */\n liveRenderTarget?: HTMLCanvasElement;\n\n /**\n * Browsers optimize tabs when they are hidden - for example, by pausing the execution of requestAnimationFrame\n * callbacks.\n *\n * If you need the CameraKitSession to continue rendering even when the tab is in the background, set this to true.\n * There is a small performance penalty, and it's a good practice to only render in the background if absolutely\n * necessary.\n */\n renderWhileTabHidden?: boolean;\n}\n\n/**\n * The entry point to the CameraKit SDK's API. Most of CameraKit's features are accessed via this class.\n *\n * Applications obtain an instance of CameraKit by calling {@link bootstrapCameraKit}.\n *\n * @example\n * ```ts\n * const cameraKit = await bootstrapCameraKit(config)\n * ```\n *\n * Then this class can be used to:\n * - Create a {@link CameraKitSession} instance, which provides the API for setting up media inputs, applying Lenses,\n * and obtaining rendered `<canvas>` outputs.\n * - Query for lenses using {@link LensRepository}.\n * - Listen for lens usage metrics events using {@link MetricsEventTarget}.\n *\n * @category Rendering\n * @category Lenses\n */\nexport class CameraKit {\n /** @deprecated Use {@link lensRepository} */\n readonly lenses: { repository: LensRepository };\n\n /**\n * Business metrics (e.g. each time a lens is viewed) are emitted here.\n */\n readonly metrics: TypedEventTarget<LensMetricsEvents> = new TypedEventTarget();\n\n private sessions: CameraKitSession[] = [];\n\n /** @internal */\n constructor(\n /**\n * Used to query for lenses and lens groups.\n */\n readonly lensRepository: LensRepository,\n\n private readonly lensCore: LensCoreModule,\n private readonly pageVisibility: PageVisibility,\n private readonly container: Container<RootServices>,\n allMetrics: MetricsEventTarget\n ) {\n this.lenses = { repository: this.lensRepository };\n // Proxy only a subset of all metrics events to the public-facing emitter -- applications don't need to\n // know about most events.\n publicMetricsEventNames.forEach((eventName) => {\n allMetrics.addEventListener(eventName, (e) => this.metrics.dispatchEvent(e));\n });\n }\n\n /**\n * Create a CameraKitSession.\n *\n * This initializes the rendering engine and returns a {@link CameraKitSession} instance, which provides access\n * to Lens rendering.\n *\n * @example\n * ```ts\n * const cameraKit = await bootstrapCameraKit(config)\n * const session = await cameraKit.createSession()\n *\n * const lens = await cameraKit.lensRepository.loadLens(lensId, groupId)\n * session.applyLens(lens)\n * ```\n *\n * @param options\n */\n @log\n async createSession({\n liveRenderTarget,\n renderWhileTabHidden,\n }: CreateSessionOptions = {}): Promise<CameraKitSession> {\n // Any error happened during lens rendering can be processed by subscribing to sessionErrors\n const exceptionHandler = (error: LensCoreError) =>\n logger.error(\n lensExecutionError(\n \"Error occurred during lens execution. \" +\n \"The lens cannot be rendered and will be removed from the CameraKitSession.\",\n error\n )\n );\n\n /**\n * If/when we add support for multiple concurrent sessions, we'll need to create a copy of the LensCore WASM\n * module. If we move managing web workers into JS, spawing a new worker thread with its own copy of LensCore\n * probably becomes a lot more straightforward.\n *\n * Currently chromium has a bug preventing rendering while tab is hidden when LensCore is in worker mode.\n * In order to process tab while it is hidden, the current stopgap is to pass in renderWhileTabHidden as true,\n * which will initiate session in non worker mode, and set the RenderLoopMode to `SetTimeout`.\n */\n await new Promise<void>((onSuccess, onFailure) => {\n this.lensCore.initialize({\n canvas: liveRenderTarget,\n shouldUseWorker: !renderWhileTabHidden && this.container.get(configurationToken).shouldUseWorker,\n exceptionHandler,\n onSuccess,\n onFailure,\n });\n });\n\n await new Promise<void>((onSuccess, onFailure) => {\n this.lensCore.setRenderLoopMode({\n mode: renderWhileTabHidden\n ? this.lensCore.RenderLoopMode.SetTimeout\n : this.lensCore.RenderLoopMode.RequestAnimationFrame,\n onSuccess,\n onFailure,\n });\n });\n\n // Each session gets its own DI Container – some Services provided by this Container may be shared with the\n // root CameraKit Container, but others may be scoped to the session by passing their token to `copy()`.\n const sessionContainer = this.container\n // Right now this is a no-op. If/when we add support for multiple concurrent sessions, we may end up\n // scoping LensCore to the session.\n .copy()\n\n .provides(sessionStateFactory)\n .provides(lensStateFactory)\n .provides(lensKeyboardFactory)\n .provides(cameraKitSessionFactory)\n\n .run(registerLensAssetsProvider)\n .run(registerLensClientInterfaceHandler)\n .run(setPreloadedConfiguration)\n\n // We'll run a PartialContainer containing reporters for session-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).\n .run(reportSessionScopedMetrics)\n\n // UriHandlers may have dependencies on session-scoped services (e.g. LensState, LensKeyboard), so they'll\n // be registered with LensCore here.\n .run(registerUriHandlers);\n\n const session = sessionContainer.get(cameraKitSessionFactory.token);\n this.sessions.push(session);\n return session;\n }\n\n /**\n * Destroys all sessions and frees all resources.\n */\n @log\n async destroy() {\n resetLogger();\n this.pageVisibility.destroy();\n await Promise.all(this.sessions.map((session) => session.destroy()));\n this.sessions = [];\n }\n}\n\n/** @internal */\nexport const cameraKitFactory = Injectable(\n \"CameraKit\",\n [\n lensRepositoryFactory.token,\n metricsEventTargetFactory.token,\n lensCoreFactory.token,\n pageVisibilityFactory.token,\n CONTAINER,\n ] as const,\n (\n lensRepository: LensRepository,\n metrics: MetricsEventTarget,\n lensCore: LensCoreModule,\n pageVisibility: PageVisibility,\n container: Container<RootServices>\n ) => new CameraKit(lensRepository, lensCore, pageVisibility, container, metrics)\n);\n"]}
|
package/lib/__tests__/data.d.ts
CHANGED
|
@@ -4,6 +4,6 @@ import { LensCoreModule, AssetType as LensCoreAssetType } from "../lens-core-mod
|
|
|
4
4
|
export declare const falsyValues: readonly [false, null, undefined, 0, ""];
|
|
5
5
|
export declare const truthyValues: readonly [true, 1, {}, Date, readonly []];
|
|
6
6
|
export declare function createLensFixture(name: string, content?: Partial<ContentProto>): LensProto;
|
|
7
|
-
export type LensCoreMock = Pick<jest.Mocked<LensCoreModule>, "AssetType" | "CanvasType" | "InterfaceAction" | "InterfaceControl" | "ExternalMediaOrientation" | "initialize" | "setRemoteAssetsProvider" | "provideRemoteAssetsResponse" | "getOutputCanvases" | "setRenderLoopMode" | "RenderLoopMode" | "setOnFrameProcessedCallback" | "setClientInterfaceRequestHandler" | "provideExternalImage" | "provideExternalVideo" | "registerSavePersistentStoreCallback">;
|
|
7
|
+
export type LensCoreMock = Pick<jest.Mocked<LensCoreModule>, "AssetType" | "CanvasType" | "InterfaceAction" | "InterfaceControl" | "ExternalMediaOrientation" | "initialize" | "setRemoteAssetsProvider" | "provideRemoteAssetsResponse" | "getOutputCanvases" | "setRenderLoopMode" | "RenderLoopMode" | "setPreloadedConfiguration" | "setOnFrameProcessedCallback" | "setClientInterfaceRequestHandler" | "provideExternalImage" | "provideExternalVideo" | "registerSavePersistentStoreCallback">;
|
|
8
8
|
export declare const AssetType: Record<keyof LensCoreModule["AssetType"], LensCoreAssetType>;
|
|
9
9
|
export declare function createLensCore(): LensCoreMock;
|
package/lib/__tests__/data.js
CHANGED
|
@@ -47,6 +47,7 @@ export function createLensCore() {
|
|
|
47
47
|
setRemoteAssetsProvider: jest.fn(),
|
|
48
48
|
provideRemoteAssetsResponse: jest.fn(),
|
|
49
49
|
getOutputCanvases: jest.fn(),
|
|
50
|
+
setPreloadedConfiguration: jest.fn(),
|
|
50
51
|
setRenderLoopMode: jest.fn(),
|
|
51
52
|
setOnFrameProcessedCallback: jest.fn(),
|
|
52
53
|
setClientInterfaceRequestHandler: jest.fn(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data.js","sourceRoot":"","sources":["../../src/__tests__/data.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,OAAO,EAA2B,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAGrE,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,EAAE,CAAU,CAAC;AACpE,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,IAAI,EAAE,EAAE,EAAE,CAAU,CAAC;AAEnE,MAAM,UAAU,iBAAiB,CAAC,IAAY,EAAE,OAA+B;IAC3E,OAAO;QACH,EAAE,EAAE,IAAI;QACR,IAAI;QACJ,UAAU,EAAE,EAAE;QACd,OAAO,kBACH,WAAW,EAAE,2BAA2B,EACxC,SAAS,EAAE,EAAE,EACb,UAAU,EAAE,EAAE,EACd,OAAO,EAAE;gBACL,QAAQ,EAAE,8BAA8B;gBACxC,iBAAiB,EAAE,GAAG;gBACtB,2BAA2B,EAAE,+BAA+B;aAC/D,EACD,aAAa,EAAE,EAAE,EACjB,aAAa,EAAE,EAAE,EACjB,gBAAgB,EAAE,EAAE,IACjB,OAAO,CACb;QACD,SAAS,EAAE;YACP,gBAAgB,EAAE,8BAA8B;YAChD,gBAAgB,EAAE,8BAA8B;SACnD;QACD,YAAY,EAAE,KAAK;QACnB,sBAAsB,EAAE,iBAAiB,CAAC,YAAY;QACtD,eAAe,EAAE,EAAE;QACnB,WAAW,EAAE;YACT,WAAW,EAAE,EAAE;SAClB;KACJ,CAAC;AACN,CAAC;
|
|
1
|
+
{"version":3,"file":"data.js","sourceRoot":"","sources":["../../src/__tests__/data.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,OAAO,EAA2B,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAGrE,MAAM,CAAC,MAAM,WAA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C;AACN,CAAC","sourcesContent":["/* eslint-disable max-len */\nimport { ContentProto, LensProto, Lens_CameraFacing } from \"../lens\";\nimport { LensCoreModule, AssetType as LensCoreAssetType } from \"../lens-core-module/generated-types\";\n\nexport const falsyValues = [false, null, undefined, 0, \"\"] as const;\nexport const truthyValues = [true, 1, {}, new Date(), []] as const;\n\nexport function createLensFixture(name: string, content?: Partial<ContentProto>): LensProto {\n return {\n id: name,\n name,\n vendorData: {},\n content: {\n iconUrlBolt: \"https://bolt.com/iconUrl1\",\n lnsSha256: \"\",\n lnsUrlBolt: \"\",\n preview: {\n imageUrl: \"https://bolt.com/previewUrl1\",\n imageSequenceSize: 100,\n imageSequenceWebpUrlPattern: \"http://images.com/face-%d.com\",\n },\n assetManifest: [],\n defaultHintId: \"\",\n hintTranslations: {},\n ...content,\n },\n scannable: {\n snapcodeImageUrl: \"https://snapcodeImageUrl.com\",\n snapcodeDeeplink: \"https://snapcodeDeeplink.com\",\n },\n isThirdParty: false,\n cameraFacingPreference: Lens_CameraFacing.UNRECOGNIZED,\n featureMetadata: [],\n lensCreator: {\n displayName: \"\",\n },\n };\n}\n\nexport type LensCoreMock = Pick<\n jest.Mocked<LensCoreModule>,\n | \"AssetType\"\n | \"CanvasType\"\n | \"InterfaceAction\"\n | \"InterfaceControl\"\n | \"ExternalMediaOrientation\"\n | \"initialize\"\n | \"setRemoteAssetsProvider\"\n | \"provideRemoteAssetsResponse\"\n | \"getOutputCanvases\"\n | \"setRenderLoopMode\"\n | \"RenderLoopMode\"\n | \"setPreloadedConfiguration\"\n | \"setOnFrameProcessedCallback\"\n | \"setClientInterfaceRequestHandler\"\n | \"provideExternalImage\"\n | \"provideExternalVideo\"\n | \"registerSavePersistentStoreCallback\"\n>;\n\n// NOTE: type of the record ensures newly added asset types break compilation\nexport const AssetType: Record<keyof LensCoreModule[\"AssetType\"], LensCoreAssetType> = {\n DeviceDependent: { value: 3 },\n RemoteMediaByUrl: { value: 6 },\n Static: { value: 1 },\n URL: { value: 2 },\n BitmojiDynamicAsset: { value: 4 },\n};\n\nexport function createLensCore(): LensCoreMock {\n return {\n AssetType,\n CanvasType: { Preview: { value: 1 }, Capture: { value: 2 }, None: { value: 0 }, All: { value: 3 } },\n RenderLoopMode: { SetTimeout: { value: 1 }, RequestAnimationFrame: { value: 0 } },\n // https://github.sc-corp.net/Snapchat/LensCore/blob/502b54b9a663203bcdf3b90c63214cdf8cc1e713/Src/CoreManager/ClientInterfaceDelegate.hpp#L39\n InterfaceAction: { Show: { value: 3 } } as any,\n // https://github.sc-corp.net/Snapchat/LensCore/blob/502b54b9a663203bcdf3b90c63214cdf8cc1e713/Src/CoreManager/ClientInterfaceDelegate.hpp#L21\n InterfaceControl: { ImagePicker: { value: 1 } } as any,\n // https://github.sc-corp.net/Snapchat/LensCore/blob/2d538ecc41f67dd2c199e0ff0eefd96aac6f22dc/Src/Common/IExternalMediaFilePickedObserver.h#L21\n ExternalMediaOrientation: { CW0: { value: 0 }, CW90: { value: 1 }, CW180: { value: 2 }, CW270: { value: 3 } },\n initialize: jest.fn(),\n setRemoteAssetsProvider: jest.fn(),\n provideRemoteAssetsResponse: jest.fn(),\n getOutputCanvases: jest.fn(),\n setPreloadedConfiguration: jest.fn(),\n setRenderLoopMode: jest.fn(),\n setOnFrameProcessedCallback: jest.fn(),\n setClientInterfaceRequestHandler: jest.fn(),\n provideExternalImage: jest.fn(),\n provideExternalVideo: jest.fn(),\n registerSavePersistentStoreCallback: jest.fn(),\n };\n}\n"]}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Assert current platform
|
|
2
|
+
* Assert that the current platform supports the necessary WebGL features.
|
|
3
|
+
* Specifically, it checks for WebGL or WebGL2 support and ensures that
|
|
4
|
+
* the maximum texture size is at least 1024.
|
|
3
5
|
*/
|
|
4
6
|
export declare function assertPlatformSupported(): void;
|
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
import { assert } from "./common/assertions";
|
|
2
2
|
import { platformNotSupportedError } from "./namedErrors";
|
|
3
|
+
const minTextureSize = 1024;
|
|
3
4
|
/**
|
|
4
|
-
* Assert current platform
|
|
5
|
+
* Assert that the current platform supports the necessary WebGL features.
|
|
6
|
+
* Specifically, it checks for WebGL or WebGL2 support and ensures that
|
|
7
|
+
* the maximum texture size is at least 1024.
|
|
5
8
|
*/
|
|
6
9
|
export function assertPlatformSupported() {
|
|
7
10
|
const canvas = document.createElement("canvas");
|
|
8
|
-
|
|
11
|
+
const webglContext = canvas.getContext("webgl2") || canvas.getContext("webgl");
|
|
12
|
+
const maxTextureSize = webglContext === null || webglContext === void 0 ? void 0 : webglContext.getParameter(webglContext.MAX_TEXTURE_SIZE);
|
|
13
|
+
assert(!!webglContext, platformNotSupportedError("Camera Kit cannot be bootstrapped because the browser does not support WebGL canvas rendering context."));
|
|
14
|
+
// Assert that the maximum texture size supported by WebGL is at least 1024.
|
|
15
|
+
// This is based on the information available at https://web3dsurvey.com/webgl/parameters/MAX_TEXTURE_SIZE
|
|
16
|
+
// and ensures that the application avoids future errors due to incompatibility with smaller texture sizes.
|
|
17
|
+
assert(maxTextureSize >= minTextureSize, platformNotSupportedError(
|
|
18
|
+
// eslint-disable-next-line max-len
|
|
19
|
+
`Camera Kit cannot be bootstrapped because this browser's WebGL MAX_TEXTURE_SIZE is ${maxTextureSize}, which is below the minimum requirement of ${minTextureSize}.`));
|
|
9
20
|
}
|
|
10
21
|
//# sourceMappingURL=assertPlatformSupported.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertPlatformSupported.js","sourceRoot":"","sources":["../src/assertPlatformSupported.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAE1D
|
|
1
|
+
{"version":3,"file":"assertPlatformSupported.js","sourceRoot":"","sources":["../src/assertPlatformSupported.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAE1D,MAAM,cAAc,GAAG,IAAI,CAAC;AAE5B;;;;GAIG;AACH,MAAM,UAAU,uBAAuB;IACnC,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChD,MAAM,YAAY,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAC/E,MAAM,cAAc,GAAG,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,YAAY,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC;IAEjF,MAAM,CACF,CAAC,CAAC,YAAY,EACd,yBAAyB,CACrB,wGAAwG,CAC3G,CACJ,CAAC;IAEF,4EAA4E;IAC5E,0GAA0G;IAC1G,2GAA2G;IAC3G,MAAM,CACF,cAAc,IAAI,cAAc,EAChC,yBAAyB;IACrB,mCAAmC;IACnC,sFAAsF,cAAc,+CAA+C,cAAc,GAAG,CACvK,CACJ,CAAC;AACN,CAAC","sourcesContent":["import { assert } from \"./common/assertions\";\nimport { platformNotSupportedError } from \"./namedErrors\";\n\nconst minTextureSize = 1024;\n\n/**\n * Assert that the current platform supports the necessary WebGL features.\n * Specifically, it checks for WebGL or WebGL2 support and ensures that\n * the maximum texture size is at least 1024.\n */\nexport function assertPlatformSupported() {\n const canvas = document.createElement(\"canvas\");\n const webglContext = canvas.getContext(\"webgl2\") || canvas.getContext(\"webgl\");\n const maxTextureSize = webglContext?.getParameter(webglContext.MAX_TEXTURE_SIZE);\n\n assert(\n !!webglContext,\n platformNotSupportedError(\n \"Camera Kit cannot be bootstrapped because the browser does not support WebGL canvas rendering context.\"\n )\n );\n\n // Assert that the maximum texture size supported by WebGL is at least 1024.\n // This is based on the information available at https://web3dsurvey.com/webgl/parameters/MAX_TEXTURE_SIZE\n // and ensures that the application avoids future errors due to incompatibility with smaller texture sizes.\n assert(\n maxTextureSize >= minTextureSize,\n platformNotSupportedError(\n // eslint-disable-next-line max-len\n `Camera Kit cannot be bootstrapped because this browser's WebGL MAX_TEXTURE_SIZE is ${maxTextureSize}, which is below the minimum requirement of ${minTextureSize}.`\n )\n );\n}\n"]}
|