@snap/camera-kit 0.7.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/LICENSE.md +6247 -0
- package/README.md +166 -0
- package/docs/html/.nojekyll +1 -0
- package/docs/html/assets/highlight.css +106 -0
- package/docs/html/assets/main.js +54 -0
- package/docs/html/assets/search.js +1 -0
- package/docs/html/assets/style.css +1225 -0
- package/docs/html/assets/widgets.png +0 -0
- package/docs/html/assets/widgets@2x.png +0 -0
- package/docs/html/classes/CameraKit.html +121 -0
- package/docs/html/classes/CameraKitSession.html +347 -0
- package/docs/html/classes/CameraKitSource.html +152 -0
- package/docs/html/classes/LensPerformanceMeasurement.html +115 -0
- package/docs/html/classes/LensPerformanceMetrics.html +76 -0
- package/docs/html/classes/LensRepository.html +171 -0
- package/docs/html/classes/LensSources.html +82 -0
- package/docs/html/classes/Transform2D.html +99 -0
- package/docs/html/classes/TypedCustomEvent.html +109 -0
- package/docs/html/classes/TypedEventTarget.html +146 -0
- package/docs/html/functions/Injectable.html +193 -0
- package/docs/html/functions/bootstrapCameraKit.html +158 -0
- package/docs/html/functions/createExtension.html +127 -0
- package/docs/html/functions/createImageSource.html +123 -0
- package/docs/html/functions/createMediaStreamSource.html +123 -0
- package/docs/html/functions/createUserMediaSource.html +127 -0
- package/docs/html/functions/createVideoSource.html +124 -0
- package/docs/html/functions/estimateLensPerformance.html +116 -0
- package/docs/html/functions/getRequiredBootstrapURLs.html +124 -0
- package/docs/html/functions/lensSourcesFactory.html +116 -0
- package/docs/html/functions/uriHandlersFactory.html +118 -0
- package/docs/html/index.html +208 -0
- package/docs/html/interfaces/CameraKitBootstrapConfiguration.html +132 -0
- package/docs/html/interfaces/CameraKitSourceSubscriber.html +121 -0
- package/docs/html/interfaces/ComputedFrameMetrics.html +70 -0
- package/docs/html/interfaces/CreateSessionOptions.html +77 -0
- package/docs/html/interfaces/EstimatedLensPerformance.html +78 -0
- package/docs/html/interfaces/Lens.html +115 -0
- package/docs/html/interfaces/LensSource.html +113 -0
- package/docs/html/interfaces/MediaStreamSourceOptions.html +65 -0
- package/docs/html/interfaces/UriCancelRequest.html +65 -0
- package/docs/html/interfaces/UriHandler.html +128 -0
- package/docs/html/interfaces/UriRequest.html +80 -0
- package/docs/html/interfaces/UriResponse.html +80 -0
- package/docs/html/interfaces/VideoSourceOptions.html +60 -0
- package/docs/html/modules.html +198 -0
- package/docs/html/types/AssetLoader.html +126 -0
- package/docs/html/types/AssetTiming.html +116 -0
- package/docs/html/types/BenchmarkError.html +107 -0
- package/docs/html/types/BootstrapError.html +110 -0
- package/docs/html/types/CacheKeyNotFoundError.html +107 -0
- package/docs/html/types/CameraKitDeviceInfo.html +114 -0
- package/docs/html/types/CameraKitSessionEventListener.html +109 -0
- package/docs/html/types/CameraKitSessionEvents.html +118 -0
- package/docs/html/types/CameraKitSourceError.html +107 -0
- package/docs/html/types/CameraKitSourceInfo.html +107 -0
- package/docs/html/types/CameraKitSourceOptions.html +113 -0
- package/docs/html/types/ConfigurationError.html +109 -0
- package/docs/html/types/Keyboard.html +196 -0
- package/docs/html/types/KeyboardEvents.html +109 -0
- package/docs/html/types/LegalError.html +107 -0
- package/docs/html/types/LensAssetError.html +109 -0
- package/docs/html/types/LensContentValidationError.html +107 -0
- package/docs/html/types/LensError.html +107 -0
- package/docs/html/types/LensExecutionError.html +114 -0
- package/docs/html/types/LensImagePickerError.html +110 -0
- package/docs/html/types/LensLaunchParams.html +109 -0
- package/docs/html/types/LensMetricsEvents.html +110 -0
- package/docs/html/types/LensPerformanceCluster.html +107 -0
- package/docs/html/types/LensView.html +119 -0
- package/docs/html/types/LensWait.html +111 -0
- package/docs/html/types/PersistentStoreError.html +109 -0
- package/docs/html/types/PlatformNotSupportedError.html +110 -0
- package/docs/html/types/PublicContainer.html +110 -0
- package/docs/html/types/RenderTarget.html +111 -0
- package/docs/html/types/Uri.html +107 -0
- package/docs/html/types/UriHandlers.html +109 -0
- package/docs/html/types/WebGLError.html +107 -0
- package/docs/html/variables/extensionRequestContext.html +109 -0
- package/docs/md/.nojekyll +1 -0
- package/docs/md/README.md +168 -0
- package/docs/md/classes/CameraKit.md +94 -0
- package/docs/md/classes/CameraKitSession.md +359 -0
- package/docs/md/classes/CameraKitSource.md +110 -0
- package/docs/md/classes/LensPerformanceMeasurement.md +77 -0
- package/docs/md/classes/LensPerformanceMetrics.md +37 -0
- package/docs/md/classes/LensRepository.md +145 -0
- package/docs/md/classes/LensSources.md +29 -0
- package/docs/md/classes/Transform2D.md +55 -0
- package/docs/md/classes/TypedCustomEvent.md +65 -0
- package/docs/md/classes/TypedEventTarget.md +103 -0
- package/docs/md/interfaces/CameraKitBootstrapConfiguration.md +106 -0
- package/docs/md/interfaces/CameraKitSourceSubscriber.md +55 -0
- package/docs/md/interfaces/ComputedFrameMetrics.md +29 -0
- package/docs/md/interfaces/CreateSessionOptions.md +35 -0
- package/docs/md/interfaces/EstimatedLensPerformance.md +38 -0
- package/docs/md/interfaces/Lens.md +84 -0
- package/docs/md/interfaces/LensSource.md +68 -0
- package/docs/md/interfaces/MediaStreamSourceOptions.md +22 -0
- package/docs/md/interfaces/UriCancelRequest.md +22 -0
- package/docs/md/interfaces/UriHandler.md +63 -0
- package/docs/md/interfaces/UriRequest.md +43 -0
- package/docs/md/interfaces/UriResponse.md +43 -0
- package/docs/md/interfaces/VideoSourceOptions.md +15 -0
- package/docs/md/modules.md +827 -0
- package/lib/CameraKit.d.ts +170 -0
- package/lib/CameraKit.js +145 -0
- package/lib/CameraKit.js.map +1 -0
- package/lib/__tests__/data.d.ts +9 -0
- package/lib/__tests__/data.js +50 -0
- package/lib/__tests__/data.js.map +1 -0
- package/lib/__tests__/deferred.d.ts +16 -0
- package/lib/__tests__/deferred.js +29 -0
- package/lib/__tests__/deferred.js.map +1 -0
- package/lib/__tests__/jest.matchers.d.ts +17 -0
- package/lib/__tests__/jest.matchers.js +67 -0
- package/lib/__tests__/jest.matchers.js.map +1 -0
- package/lib/assertPlatformSupported.d.ts +4 -0
- package/lib/assertPlatformSupported.js +10 -0
- package/lib/assertPlatformSupported.js.map +1 -0
- package/lib/benchmark/benchmarkGflops.d.ts +16 -0
- package/lib/benchmark/benchmarkGflops.js +129 -0
- package/lib/benchmark/benchmarkGflops.js.map +1 -0
- package/lib/benchmark/estimateLensPerformanceCluster.d.ts +33 -0
- package/lib/benchmark/estimateLensPerformanceCluster.js +48 -0
- package/lib/benchmark/estimateLensPerformanceCluster.js.map +1 -0
- package/lib/benchmark/webglUtils.d.ts +7 -0
- package/lib/benchmark/webglUtils.js +87 -0
- package/lib/benchmark/webglUtils.js.map +1 -0
- package/lib/bootstrapCameraKit.d.ts +96 -0
- package/lib/bootstrapCameraKit.js +204 -0
- package/lib/bootstrapCameraKit.js.map +1 -0
- package/lib/common/__mocks__/loadScript.d.ts +1 -0
- package/lib/common/__mocks__/loadScript.js +10 -0
- package/lib/common/__mocks__/loadScript.js.map +1 -0
- package/lib/common/assertions.d.ts +27 -0
- package/lib/common/assertions.js +39 -0
- package/lib/common/assertions.js.map +1 -0
- package/lib/common/cameraKitUserAgent.d.ts +34 -0
- package/lib/common/cameraKitUserAgent.js +216 -0
- package/lib/common/cameraKitUserAgent.js.map +1 -0
- package/lib/common/copyDefinedProperties.d.ts +13 -0
- package/lib/common/copyDefinedProperties.js +16 -0
- package/lib/common/copyDefinedProperties.js.map +1 -0
- package/lib/common/entries.d.ts +3 -0
- package/lib/common/entries.js +3 -0
- package/lib/common/entries.js.map +1 -0
- package/lib/common/errorHelpers.d.ts +10 -0
- package/lib/common/errorHelpers.js +24 -0
- package/lib/common/errorHelpers.js.map +1 -0
- package/lib/common/getFilename.d.ts +1 -0
- package/lib/common/getFilename.js +4 -0
- package/lib/common/getFilename.js.map +1 -0
- package/lib/common/index.d.ts +2 -0
- package/lib/common/index.js +3 -0
- package/lib/common/index.js.map +1 -0
- package/lib/common/loadScript.d.ts +1 -0
- package/lib/common/loadScript.js +11 -0
- package/lib/common/loadScript.js.map +1 -0
- package/lib/common/locale.d.ts +2 -0
- package/lib/common/locale.js +11 -0
- package/lib/common/locale.js.map +1 -0
- package/lib/common/localization.d.ts +43 -0
- package/lib/common/localization.js +43 -0
- package/lib/common/localization.js.map +1 -0
- package/lib/common/memoize.d.ts +8 -0
- package/lib/common/memoize.js +15 -0
- package/lib/common/memoize.js.map +1 -0
- package/lib/common/pageVisibility.d.ts +20 -0
- package/lib/common/pageVisibility.js +62 -0
- package/lib/common/pageVisibility.js.map +1 -0
- package/lib/common/time.d.ts +1 -0
- package/lib/common/time.js +2 -0
- package/lib/common/time.js.map +1 -0
- package/lib/common/typeguards.d.ts +53 -0
- package/lib/common/typeguards.js +92 -0
- package/lib/common/typeguards.js.map +1 -0
- package/lib/common/types.d.ts +10 -0
- package/lib/common/types.js +2 -0
- package/lib/common/types.js.map +1 -0
- package/lib/common/validate.d.ts +14 -0
- package/lib/common/validate.js +104 -0
- package/lib/common/validate.js.map +1 -0
- package/lib/configuration.d.ts +92 -0
- package/lib/configuration.js +36 -0
- package/lib/configuration.js.map +1 -0
- package/lib/configurationOverrides.d.ts +12 -0
- package/lib/configurationOverrides.js +41 -0
- package/lib/configurationOverrides.js.map +1 -0
- package/lib/dependency-injection/Container.d.ts +177 -0
- package/lib/dependency-injection/Container.js +160 -0
- package/lib/dependency-injection/Container.js.map +1 -0
- package/lib/dependency-injection/Injectable.d.ts +39 -0
- package/lib/dependency-injection/Injectable.js +18 -0
- package/lib/dependency-injection/Injectable.js.map +1 -0
- package/lib/dependency-injection/PartialContainer.d.ts +81 -0
- package/lib/dependency-injection/PartialContainer.js +85 -0
- package/lib/dependency-injection/PartialContainer.js.map +1 -0
- package/lib/dependency-injection/RootServices.d.ts +62 -0
- package/lib/dependency-injection/RootServices.js +2 -0
- package/lib/dependency-injection/RootServices.js.map +1 -0
- package/lib/dependency-injection/types.d.ts +56 -0
- package/lib/dependency-injection/types.js +2 -0
- package/lib/dependency-injection/types.js.map +1 -0
- package/lib/environment.json +1 -0
- package/lib/events/TypedCustomEvent.d.ts +10 -0
- package/lib/events/TypedCustomEvent.js +11 -0
- package/lib/events/TypedCustomEvent.js.map +1 -0
- package/lib/events/TypedEventTarget.d.ts +25 -0
- package/lib/events/TypedEventTarget.js +57 -0
- package/lib/events/TypedEventTarget.js.map +1 -0
- package/lib/events/scan.d.ts +15 -0
- package/lib/events/scan.js +46 -0
- package/lib/events/scan.js.map +1 -0
- package/lib/extensions/LensSources.d.ts +58 -0
- package/lib/extensions/LensSources.js +50 -0
- package/lib/extensions/LensSources.js.map +1 -0
- package/lib/extensions/UriHandlers.d.ts +54 -0
- package/lib/extensions/UriHandlers.js +93 -0
- package/lib/extensions/UriHandlers.js.map +1 -0
- package/lib/extensions/extensionRequestContext.d.ts +4 -0
- package/lib/extensions/extensionRequestContext.js +14 -0
- package/lib/extensions/extensionRequestContext.js.map +1 -0
- package/lib/generated-proto/blizzard/cameraKitEvents.d.ts +5603 -0
- package/lib/generated-proto/blizzard/cameraKitEvents.js +522 -0
- package/lib/generated-proto/blizzard/cameraKitEvents.js.map +1 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/business_events.d.ts +98 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/business_events.js +260 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/business_events.js.map +1 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/export.d.ts +543 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/export.js +429 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/export.js.map +1 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/legal_prompt.d.ts +100 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/legal_prompt.js +164 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/legal_prompt.js.map +1 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/lens.d.ts +395 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/lens.js +644 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/lens.js.map +1 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/operational_metrics.d.ts +185 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/operational_metrics.js +172 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/operational_metrics.js.map +1 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/ranking.d.ts +86 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/ranking.js +234 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/ranking.js.map +1 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/service.d.ts +854 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/service.js +629 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/service.js.map +1 -0
- package/lib/generated-proto/pb_schema/cdp/cof/benchmark.d.ts +86 -0
- package/lib/generated-proto/pb_schema/cdp/cof/benchmark.js +185 -0
- package/lib/generated-proto/pb_schema/cdp/cof/benchmark.js.map +1 -0
- package/lib/generated-proto/pb_schema/cdp/cof/benchmark_name.d.ts +95 -0
- package/lib/generated-proto/pb_schema/cdp/cof/benchmark_name.js +104 -0
- package/lib/generated-proto/pb_schema/cdp/cof/benchmark_name.js.map +1 -0
- package/lib/generated-proto/pb_schema/cdp/cof/circumstance_service.d.ts +10212 -0
- package/lib/generated-proto/pb_schema/cdp/cof/circumstance_service.js +1300 -0
- package/lib/generated-proto/pb_schema/cdp/cof/circumstance_service.js.map +1 -0
- package/lib/generated-proto/pb_schema/cdp/cof/config_request.d.ts +401 -0
- package/lib/generated-proto/pb_schema/cdp/cof/config_request.js +525 -0
- package/lib/generated-proto/pb_schema/cdp/cof/config_request.js.map +1 -0
- package/lib/generated-proto/pb_schema/cdp/cof/config_response.d.ts +1287 -0
- package/lib/generated-proto/pb_schema/cdp/cof/config_response.js +135 -0
- package/lib/generated-proto/pb_schema/cdp/cof/config_response.js.map +1 -0
- package/lib/generated-proto/pb_schema/cdp/cof/config_result.d.ts +4208 -0
- package/lib/generated-proto/pb_schema/cdp/cof/config_result.js +1053 -0
- package/lib/generated-proto/pb_schema/cdp/cof/config_result.js.map +1 -0
- package/lib/generated-proto/pb_schema/cdp/cof/debug_info.d.ts +102 -0
- package/lib/generated-proto/pb_schema/cdp/cof/debug_info.js +165 -0
- package/lib/generated-proto/pb_schema/cdp/cof/debug_info.js.map +1 -0
- package/lib/generated-proto/pb_schema/cdp/cof/namespace.d.ts +8 -0
- package/lib/generated-proto/pb_schema/cdp/cof/namespace.js +17 -0
- package/lib/generated-proto/pb_schema/cdp/cof/namespace.js.map +1 -0
- package/lib/generated-proto/pb_schema/common/ruid.d.ts +75 -0
- package/lib/generated-proto/pb_schema/common/ruid.js +96 -0
- package/lib/generated-proto/pb_schema/common/ruid.js.map +1 -0
- package/lib/generated-proto/pb_schema/common/value.d.ts +131 -0
- package/lib/generated-proto/pb_schema/common/value.js +204 -0
- package/lib/generated-proto/pb_schema/common/value.js.map +1 -0
- package/lib/generated-proto/pb_schema/google/api/annotations.d.ts +1 -0
- package/lib/generated-proto/pb_schema/google/api/annotations.js +9 -0
- package/lib/generated-proto/pb_schema/google/api/annotations.js.map +1 -0
- package/lib/generated-proto/pb_schema/google/api/http.d.ts +3636 -0
- package/lib/generated-proto/pb_schema/google/api/http.js +271 -0
- package/lib/generated-proto/pb_schema/google/api/http.js.map +1 -0
- package/lib/generated-proto/pb_schema/google/protobuf/any.d.ts +139 -0
- package/lib/generated-proto/pb_schema/google/protobuf/any.js +94 -0
- package/lib/generated-proto/pb_schema/google/protobuf/any.js.map +1 -0
- package/lib/generated-proto/pb_schema/google/protobuf/descriptor.d.ts +50968 -0
- package/lib/generated-proto/pb_schema/google/protobuf/descriptor.js +2962 -0
- package/lib/generated-proto/pb_schema/google/protobuf/descriptor.js.map +1 -0
- package/lib/generated-proto/pb_schema/google/protobuf/timestamp.d.ts +98 -0
- package/lib/generated-proto/pb_schema/google/protobuf/timestamp.js +82 -0
- package/lib/generated-proto/pb_schema/google/protobuf/timestamp.js.map +1 -0
- package/lib/generated-proto/pb_schema/google/protobuf/wrappers.d.ts +173 -0
- package/lib/generated-proto/pb_schema/google/protobuf/wrappers.js +332 -0
- package/lib/generated-proto/pb_schema/google/protobuf/wrappers.js.map +1 -0
- package/lib/generated-proto/pb_schema/lenses/geocircle.d.ts +42 -0
- package/lib/generated-proto/pb_schema/lenses/geocircle.js +52 -0
- package/lib/generated-proto/pb_schema/lenses/geocircle.js.map +1 -0
- package/lib/generated-proto/pb_schema/lenses/geopoint.d.ts +32 -0
- package/lib/generated-proto/pb_schema/lenses/geopoint.js +50 -0
- package/lib/generated-proto/pb_schema/lenses/geopoint.js.map +1 -0
- package/lib/generated-proto/pb_schema/lenses/launch_params.d.ts +29 -0
- package/lib/generated-proto/pb_schema/lenses/launch_params.js +43 -0
- package/lib/generated-proto/pb_schema/lenses/launch_params.js.map +1 -0
- package/lib/generated-proto/pb_schema/lenses/launchdata.d.ts +365 -0
- package/lib/generated-proto/pb_schema/lenses/launchdata.js +216 -0
- package/lib/generated-proto/pb_schema/lenses/launchdata.js.map +1 -0
- package/lib/generated-proto/pb_schema/lenses/lures.d.ts +113 -0
- package/lib/generated-proto/pb_schema/lenses/lures.js +64 -0
- package/lib/generated-proto/pb_schema/lenses/lures.js.map +1 -0
- package/lib/generated-proto/pb_schema/lenses/persistent_store.d.ts +29 -0
- package/lib/generated-proto/pb_schema/lenses/persistent_store.js +43 -0
- package/lib/generated-proto/pb_schema/lenses/persistent_store.js.map +1 -0
- package/lib/generated-proto/pb_schema/lenses/snappable.d.ts +921 -0
- package/lib/generated-proto/pb_schema/lenses/snappable.js +954 -0
- package/lib/generated-proto/pb_schema/lenses/snappable.js.map +1 -0
- package/lib/generated-proto/pb_schema/lenses/user_data.d.ts +247 -0
- package/lib/generated-proto/pb_schema/lenses/user_data.js +362 -0
- package/lib/generated-proto/pb_schema/lenses/user_data.js.map +1 -0
- package/lib/handlers/HandlerChainBuilder.d.ts +95 -0
- package/lib/handlers/HandlerChainBuilder.js +187 -0
- package/lib/handlers/HandlerChainBuilder.js.map +1 -0
- package/lib/handlers/arrayBufferParsingHandler.d.ts +10 -0
- package/lib/handlers/arrayBufferParsingHandler.js +18 -0
- package/lib/handlers/arrayBufferParsingHandler.js.map +1 -0
- package/lib/handlers/batchingHandler.d.ts +25 -0
- package/lib/handlers/batchingHandler.js +79 -0
- package/lib/handlers/batchingHandler.js.map +1 -0
- package/lib/handlers/cameraKitServiceFetchHandlerFactory.d.ts +12 -0
- package/lib/handlers/cameraKitServiceFetchHandlerFactory.js +19 -0
- package/lib/handlers/cameraKitServiceFetchHandlerFactory.js.map +1 -0
- package/lib/handlers/debugHandler.d.ts +8 -0
- package/lib/handlers/debugHandler.js +27 -0
- package/lib/handlers/debugHandler.js.map +1 -0
- package/lib/handlers/defaultFetchHandler.d.ts +15 -0
- package/lib/handlers/defaultFetchHandler.js +29 -0
- package/lib/handlers/defaultFetchHandler.js.map +1 -0
- package/lib/handlers/headersModifyingFetchHandler.d.ts +8 -0
- package/lib/handlers/headersModifyingFetchHandler.js +13 -0
- package/lib/handlers/headersModifyingFetchHandler.js.map +1 -0
- package/lib/handlers/index.d.ts +2 -0
- package/lib/handlers/index.js +3 -0
- package/lib/handlers/index.js.map +1 -0
- package/lib/handlers/mappingHandler.d.ts +15 -0
- package/lib/handlers/mappingHandler.js +65 -0
- package/lib/handlers/mappingHandler.js.map +1 -0
- package/lib/handlers/noCorsRetryingFetchHandler.d.ts +48 -0
- package/lib/handlers/noCorsRetryingFetchHandler.js +94 -0
- package/lib/handlers/noCorsRetryingFetchHandler.js.map +1 -0
- package/lib/handlers/persistingHandler.d.ts +14 -0
- package/lib/handlers/persistingHandler.js +71 -0
- package/lib/handlers/persistingHandler.js.map +1 -0
- package/lib/handlers/rateLimitingHandler.d.ts +20 -0
- package/lib/handlers/rateLimitingHandler.js +43 -0
- package/lib/handlers/rateLimitingHandler.js.map +1 -0
- package/lib/handlers/requestStateEmittingHandler.d.ts +29 -0
- package/lib/handlers/requestStateEmittingHandler.js +43 -0
- package/lib/handlers/requestStateEmittingHandler.js.map +1 -0
- package/lib/handlers/responseCachingHandler.d.ts +27 -0
- package/lib/handlers/responseCachingHandler.js +94 -0
- package/lib/handlers/responseCachingHandler.js.map +1 -0
- package/lib/handlers/retryingHandler.d.ts +37 -0
- package/lib/handlers/retryingHandler.js +73 -0
- package/lib/handlers/retryingHandler.js.map +1 -0
- package/lib/handlers/timeoutHandler.d.ts +18 -0
- package/lib/handlers/timeoutHandler.js +30 -0
- package/lib/handlers/timeoutHandler.js.map +1 -0
- package/lib/index.d.ts +33 -0
- package/lib/index.js +32 -0
- package/lib/index.js.map +1 -0
- package/lib/legal/legalPrompt.d.ts +17 -0
- package/lib/legal/legalPrompt.js +144 -0
- package/lib/legal/legalPrompt.js.map +1 -0
- package/lib/legal/legalState.d.ts +50 -0
- package/lib/legal/legalState.js +149 -0
- package/lib/legal/legalState.js.map +1 -0
- package/lib/lens/Lens.d.ts +71 -0
- package/lib/lens/Lens.js +63 -0
- package/lib/lens/Lens.js.map +1 -0
- package/lib/lens/LensLaunchParams.d.ts +19 -0
- package/lib/lens/LensLaunchParams.js +38 -0
- package/lib/lens/LensLaunchParams.js.map +1 -0
- package/lib/lens/LensPersistenceStore.d.ts +7 -0
- package/lib/lens/LensPersistenceStore.js +20 -0
- package/lib/lens/LensPersistenceStore.js.map +1 -0
- package/lib/lens/LensRepository.d.ts +134 -0
- package/lib/lens/LensRepository.js +239 -0
- package/lib/lens/LensRepository.js.map +1 -0
- package/lib/lens/assets/LensAssetRepository.d.ts +66 -0
- package/lib/lens/assets/LensAssetRepository.js +179 -0
- package/lib/lens/assets/LensAssetRepository.js.map +1 -0
- package/lib/lens/assets/LensAssetsProvider.d.ts +21 -0
- package/lib/lens/assets/LensAssetsProvider.js +41 -0
- package/lib/lens/assets/LensAssetsProvider.js.map +1 -0
- package/lib/lens/assets/deviceDependentAssetLoader.d.ts +11 -0
- package/lib/lens/assets/deviceDependentAssetLoader.js +58 -0
- package/lib/lens/assets/deviceDependentAssetLoader.js.map +1 -0
- package/lib/lens/assets/remoteMediaAssetLoaderFactory.d.ts +10 -0
- package/lib/lens/assets/remoteMediaAssetLoaderFactory.js +26 -0
- package/lib/lens/assets/remoteMediaAssetLoaderFactory.js.map +1 -0
- package/lib/lens/assets/staticAssetLoader.d.ts +10 -0
- package/lib/lens/assets/staticAssetLoader.js +24 -0
- package/lib/lens/assets/staticAssetLoader.js.map +1 -0
- package/lib/lens/index.d.ts +7 -0
- package/lib/lens/index.js +7 -0
- package/lib/lens/index.js.map +1 -0
- package/lib/lens/lensEnvelopeUtil.d.ts +5 -0
- package/lib/lens/lensEnvelopeUtil.js +19 -0
- package/lib/lens/lensEnvelopeUtil.js.map +1 -0
- package/lib/lens/lensHttpUtil.d.ts +4 -0
- package/lib/lens/lensHttpUtil.js +30 -0
- package/lib/lens/lensHttpUtil.js.map +1 -0
- package/lib/lens-client-interface/exif.d.ts +20 -0
- package/lib/lens-client-interface/exif.js +61 -0
- package/lib/lens-client-interface/exif.js.map +1 -0
- package/lib/lens-client-interface/imagePicker.d.ts +7 -0
- package/lib/lens-client-interface/imagePicker.js +128 -0
- package/lib/lens-client-interface/imagePicker.js.map +1 -0
- package/lib/lens-client-interface/lensClientInterface.d.ts +13 -0
- package/lib/lens-client-interface/lensClientInterface.js +30 -0
- package/lib/lens-client-interface/lensClientInterface.js.map +1 -0
- package/lib/lens-core-module/generated-types.d.ts +426 -0
- package/lib/lens-core-module/generated-types.js +2 -0
- package/lib/lens-core-module/generated-types.js.map +1 -0
- package/lib/lens-core-module/index.d.ts +2 -0
- package/lib/lens-core-module/index.js +3 -0
- package/lib/lens-core-module/index.js.map +1 -0
- package/lib/lens-core-module/loader/index.d.ts +1 -0
- package/lib/lens-core-module/loader/index.js +2 -0
- package/lib/lens-core-module/loader/index.js.map +1 -0
- package/lib/lens-core-module/loader/lensCoreFactory.d.ts +30 -0
- package/lib/lens-core-module/loader/lensCoreFactory.js +121 -0
- package/lib/lens-core-module/loader/lensCoreFactory.js.map +1 -0
- package/lib/lensCoreWasmVersions.json +5 -0
- package/lib/logger/errorLoggingDecorator.d.ts +9 -0
- package/lib/logger/errorLoggingDecorator.js +32 -0
- package/lib/logger/errorLoggingDecorator.js.map +1 -0
- package/lib/logger/logEntries.d.ts +15 -0
- package/lib/logger/logEntries.js +14 -0
- package/lib/logger/logEntries.js.map +1 -0
- package/lib/logger/logger.d.ts +35 -0
- package/lib/logger/logger.js +48 -0
- package/lib/logger/logger.js.map +1 -0
- package/lib/logger/registerLogEntriesSubscriber.d.ts +14 -0
- package/lib/logger/registerLogEntriesSubscriber.js +23 -0
- package/lib/logger/registerLogEntriesSubscriber.js.map +1 -0
- package/lib/media-sources/CameraKitSource.d.ts +88 -0
- package/lib/media-sources/CameraKitSource.js +140 -0
- package/lib/media-sources/CameraKitSource.js.map +1 -0
- package/lib/media-sources/FunctionSource.d.ts +30 -0
- package/lib/media-sources/FunctionSource.js +132 -0
- package/lib/media-sources/FunctionSource.js.map +1 -0
- package/lib/media-sources/ImageSource.d.ts +13 -0
- package/lib/media-sources/ImageSource.js +28 -0
- package/lib/media-sources/ImageSource.js.map +1 -0
- package/lib/media-sources/MediaStreamSource.d.ts +41 -0
- package/lib/media-sources/MediaStreamSource.js +146 -0
- package/lib/media-sources/MediaStreamSource.js.map +1 -0
- package/lib/media-sources/VideoSource.d.ts +21 -0
- package/lib/media-sources/VideoSource.js +38 -0
- package/lib/media-sources/VideoSource.js.map +1 -0
- package/lib/metrics/businessEventsReporter.d.ts +37 -0
- package/lib/metrics/businessEventsReporter.js +160 -0
- package/lib/metrics/businessEventsReporter.js.map +1 -0
- package/lib/metrics/metricsEventTarget.d.ts +41 -0
- package/lib/metrics/metricsEventTarget.js +11 -0
- package/lib/metrics/metricsEventTarget.js.map +1 -0
- package/lib/metrics/metricsHandler.d.ts +9 -0
- package/lib/metrics/metricsHandler.js +13 -0
- package/lib/metrics/metricsHandler.js.map +1 -0
- package/lib/metrics/operationalMetricsReporter.d.ts +52 -0
- package/lib/metrics/operationalMetricsReporter.js +108 -0
- package/lib/metrics/operationalMetricsReporter.js.map +1 -0
- package/lib/metrics/reporters/reportBenchmarks.d.ts +10 -0
- package/lib/metrics/reporters/reportBenchmarks.js +29 -0
- package/lib/metrics/reporters/reportBenchmarks.js.map +1 -0
- package/lib/metrics/reporters/reportGlobalException.d.ts +19 -0
- package/lib/metrics/reporters/reportGlobalException.js +68 -0
- package/lib/metrics/reporters/reportGlobalException.js.map +1 -0
- package/lib/metrics/reporters/reportHttpMetrics.d.ts +17 -0
- package/lib/metrics/reporters/reportHttpMetrics.js +92 -0
- package/lib/metrics/reporters/reportHttpMetrics.js.map +1 -0
- package/lib/metrics/reporters/reportLegalState.d.ts +15 -0
- package/lib/metrics/reporters/reportLegalState.js +34 -0
- package/lib/metrics/reporters/reportLegalState.js.map +1 -0
- package/lib/metrics/reporters/reportLensAndAssetDownload.d.ts +38 -0
- package/lib/metrics/reporters/reportLensAndAssetDownload.js +88 -0
- package/lib/metrics/reporters/reportLensAndAssetDownload.js.map +1 -0
- package/lib/metrics/reporters/reportLensValidationFailed.d.ts +20 -0
- package/lib/metrics/reporters/reportLensValidationFailed.js +24 -0
- package/lib/metrics/reporters/reportLensValidationFailed.js.map +1 -0
- package/lib/metrics/reporters/reportLensView.d.ts +36 -0
- package/lib/metrics/reporters/reportLensView.js +101 -0
- package/lib/metrics/reporters/reportLensView.js.map +1 -0
- package/lib/metrics/reporters/reportLensWait.d.ts +33 -0
- package/lib/metrics/reporters/reportLensWait.js +56 -0
- package/lib/metrics/reporters/reportLensWait.js.map +1 -0
- package/lib/metrics/reporters/reportSessionException.d.ts +17 -0
- package/lib/metrics/reporters/reportSessionException.js +12 -0
- package/lib/metrics/reporters/reportSessionException.js.map +1 -0
- package/lib/metrics/reporters/reportUserSession.d.ts +14 -0
- package/lib/metrics/reporters/reportUserSession.js +67 -0
- package/lib/metrics/reporters/reportUserSession.js.map +1 -0
- package/lib/metrics/reporters/reporters.d.ts +44 -0
- package/lib/metrics/reporters/reporters.js +33 -0
- package/lib/metrics/reporters/reporters.js.map +1 -0
- package/lib/namedErrors.d.ts +107 -0
- package/lib/namedErrors.js +56 -0
- package/lib/namedErrors.js.map +1 -0
- package/lib/persistence/ExpiringPersistence.d.ts +20 -0
- package/lib/persistence/ExpiringPersistence.js +58 -0
- package/lib/persistence/ExpiringPersistence.js.map +1 -0
- package/lib/persistence/IndexedDBPersistence.d.ts +47 -0
- package/lib/persistence/IndexedDBPersistence.js +180 -0
- package/lib/persistence/IndexedDBPersistence.js.map +1 -0
- package/lib/persistence/Persistence.d.ts +25 -0
- package/lib/persistence/Persistence.js +10 -0
- package/lib/persistence/Persistence.js.map +1 -0
- package/lib/remote-configuration/cofHandler.d.ts +21 -0
- package/lib/remote-configuration/cofHandler.js +75 -0
- package/lib/remote-configuration/cofHandler.js.map +1 -0
- package/lib/remote-configuration/remoteConfiguration.d.ts +13 -0
- package/lib/remote-configuration/remoteConfiguration.js +43 -0
- package/lib/remote-configuration/remoteConfiguration.js.map +1 -0
- package/lib/session/CameraKitSession.d.ts +252 -0
- package/lib/session/CameraKitSession.js +439 -0
- package/lib/session/CameraKitSession.js.map +1 -0
- package/lib/session/CameraKitSessionEvents.d.ts +33 -0
- package/lib/session/CameraKitSessionEvents.js +21 -0
- package/lib/session/CameraKitSessionEvents.js.map +1 -0
- package/lib/session/LensKeyboard.d.ts +89 -0
- package/lib/session/LensKeyboard.js +95 -0
- package/lib/session/LensKeyboard.js.map +1 -0
- package/lib/session/LensPerformanceMeasurement.d.ts +55 -0
- package/lib/session/LensPerformanceMeasurement.js +91 -0
- package/lib/session/LensPerformanceMeasurement.js.map +1 -0
- package/lib/session/LensPerformanceMetrics.d.ts +31 -0
- package/lib/session/LensPerformanceMetrics.js +58 -0
- package/lib/session/LensPerformanceMetrics.js.map +1 -0
- package/lib/session/index.d.ts +1 -0
- package/lib/session/index.js +2 -0
- package/lib/session/index.js.map +1 -0
- package/lib/session/lensState.d.ts +29 -0
- package/lib/session/lensState.js +160 -0
- package/lib/session/lensState.js.map +1 -0
- package/lib/session/sessionState.d.ts +10 -0
- package/lib/session/sessionState.js +12 -0
- package/lib/session/sessionState.js.map +1 -0
- package/lib/transforms/Transform2D.d.ts +17 -0
- package/lib/transforms/Transform2D.js +18 -0
- package/lib/transforms/Transform2D.js.map +1 -0
- package/lib/transforms/index.d.ts +1 -0
- package/lib/transforms/index.js +2 -0
- package/lib/transforms/index.js.map +1 -0
- package/package.json +62 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Logger } from "./logger";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a class member decorator that logs errors thrown during the member invocation.
|
|
4
|
+
* If the member returns a Promise, promise rejections are handled.
|
|
5
|
+
* Any caught errors are re-thrown.
|
|
6
|
+
* @param logger The logger to report errors to.
|
|
7
|
+
* @return A decorator function.
|
|
8
|
+
*/
|
|
9
|
+
export declare function errorLoggingDecorator(logger: Logger): (_target: any, _propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a class member decorator that logs errors thrown during the member invocation.
|
|
3
|
+
* If the member returns a Promise, promise rejections are handled.
|
|
4
|
+
* Any caught errors are re-thrown.
|
|
5
|
+
* @param logger The logger to report errors to.
|
|
6
|
+
* @return A decorator function.
|
|
7
|
+
*/
|
|
8
|
+
export function errorLoggingDecorator(logger) {
|
|
9
|
+
const handleError = (error) => logger.error(error);
|
|
10
|
+
return function (_target, _propertyKey, descriptor) {
|
|
11
|
+
const methodName = descriptor.value ? "value" : "get";
|
|
12
|
+
const originalMethod = descriptor[methodName];
|
|
13
|
+
descriptor[methodName] = function (...args) {
|
|
14
|
+
try {
|
|
15
|
+
// "this" refers to original scope this function is called in
|
|
16
|
+
const result = originalMethod.apply(this, args);
|
|
17
|
+
if (result instanceof Promise) {
|
|
18
|
+
// in case of a promise we don't return our promise chain
|
|
19
|
+
// that logs an error because we want callers to handle the error as well
|
|
20
|
+
result.catch(handleError);
|
|
21
|
+
}
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
handleError(error);
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
return descriptor;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=errorLoggingDecorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorLoggingDecorator.js","sourceRoot":"","sources":["../../src/logger/errorLoggingDecorator.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAc;IAChD,MAAM,WAAW,GAAG,CAAC,KAAc,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC5D,OAAO,UAAU,OAAY,EAAE,YAAoB,EAAE,UAA8B;QAC/E,MAAM,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;QACtD,MAAM,cAAc,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC;QAC9C,UAAU,CAAC,UAAU,CAAC,GAAG,UAAU,GAAG,IAAW;YAC7C,IAAI;gBACA,6DAA6D;gBAC7D,MAAM,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBAChD,IAAI,MAAM,YAAY,OAAO,EAAE;oBAC3B,yDAAyD;oBACzD,yEAAyE;oBACzE,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;iBAC7B;gBACD,OAAO,MAAM,CAAC;aACjB;YAAC,OAAO,KAAK,EAAE;gBACZ,WAAW,CAAC,KAAK,CAAC,CAAC;gBACnB,MAAM,KAAK,CAAC;aACf;QACL,CAAC,CAAC;QACF,OAAO,UAAU,CAAC;IACtB,CAAC,CAAC;AACN,CAAC","sourcesContent":["import { Logger } from \"./logger\";\n\n/**\n * Creates a class member decorator that logs errors thrown during the member invocation.\n * If the member returns a Promise, promise rejections are handled.\n * Any caught errors are re-thrown.\n * @param logger The logger to report errors to.\n * @return A decorator function.\n */\nexport function errorLoggingDecorator(logger: Logger) {\n const handleError = (error: unknown) => logger.error(error);\n return function (_target: any, _propertyKey: string, descriptor: PropertyDescriptor) {\n const methodName = descriptor.value ? \"value\" : \"get\";\n const originalMethod = descriptor[methodName];\n descriptor[methodName] = function (...args: any[]) {\n try {\n // \"this\" refers to original scope this function is called in\n const result = originalMethod.apply(this, args);\n if (result instanceof Promise) {\n // in case of a promise we don't return our promise chain\n // that logs an error because we want callers to handle the error as well\n result.catch(handleError);\n }\n return result;\n } catch (error) {\n handleError(error);\n throw error;\n }\n };\n return descriptor;\n };\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The factory creates new logEntries subject.
|
|
3
|
+
*
|
|
4
|
+
* NOTE: The factory calls `initLogger()`, which overrides the global `logEntrySubject`.
|
|
5
|
+
* This is currently necessary to avoid sharing the same subject between multiple `CameraKit` instances.
|
|
6
|
+
* In the future, we may throw an error when bootstrapping more than a single `CameraKit`,
|
|
7
|
+
* that will allow us to have a single log entry subject.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare const logEntriesFactory: {
|
|
12
|
+
(): import("rxjs").Observable<import("./logger").LogEntry>;
|
|
13
|
+
token: "logEntries";
|
|
14
|
+
dependencies: [];
|
|
15
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Injectable } from "../dependency-injection/Injectable";
|
|
2
|
+
import { initLogger } from "./logger";
|
|
3
|
+
/**
|
|
4
|
+
* The factory creates new logEntries subject.
|
|
5
|
+
*
|
|
6
|
+
* NOTE: The factory calls `initLogger()`, which overrides the global `logEntrySubject`.
|
|
7
|
+
* This is currently necessary to avoid sharing the same subject between multiple `CameraKit` instances.
|
|
8
|
+
* In the future, we may throw an error when bootstrapping more than a single `CameraKit`,
|
|
9
|
+
* that will allow us to have a single log entry subject.
|
|
10
|
+
*
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export const logEntriesFactory = Injectable("logEntries", () => initLogger().asObservable());
|
|
14
|
+
//# sourceMappingURL=logEntries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logEntries.js","sourceRoot":"","sources":["../../src/logger/logEntries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,UAAU,CAAC,YAAY,EAAE,GAAG,EAAE,CAAC,UAAU,EAAE,CAAC,YAAY,EAAE,CAAC,CAAC","sourcesContent":["import { Injectable } from \"../dependency-injection/Injectable\";\nimport { initLogger } from \"./logger\";\n\n/**\n * The factory creates new logEntries subject.\n *\n * NOTE: The factory calls `initLogger()`, which overrides the global `logEntrySubject`.\n * This is currently necessary to avoid sharing the same subject between multiple `CameraKit` instances.\n * In the future, we may throw an error when bootstrapping more than a single `CameraKit`,\n * that will allow us to have a single log entry subject.\n *\n * @internal\n */\nexport const logEntriesFactory = Injectable(\"logEntries\", () => initLogger().asObservable());\n"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Subject } from "rxjs";
|
|
2
|
+
/**
|
|
3
|
+
* This map associates log level names with their corresponding level value.
|
|
4
|
+
* This means that a configured log level will match all log entries with a level value greater than
|
|
5
|
+
* or equal to the configured value.
|
|
6
|
+
*/
|
|
7
|
+
export declare const logLevelMap: {
|
|
8
|
+
error: number;
|
|
9
|
+
warn: number;
|
|
10
|
+
log: number;
|
|
11
|
+
info: number;
|
|
12
|
+
debug: number;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Initializes new logger subject.
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export declare function initLogger(): Subject<LogEntry>;
|
|
19
|
+
export interface LogEntry {
|
|
20
|
+
time: Date;
|
|
21
|
+
module: string;
|
|
22
|
+
level: keyof Logger;
|
|
23
|
+
messages: any[];
|
|
24
|
+
}
|
|
25
|
+
export declare type LogLevelName = keyof typeof logLevelMap;
|
|
26
|
+
export declare type Logger = Record<LogLevelName, (message?: any, ...optionalParams: any[]) => void>;
|
|
27
|
+
/**
|
|
28
|
+
* Gets logger for a given module.
|
|
29
|
+
*
|
|
30
|
+
* @internal
|
|
31
|
+
*
|
|
32
|
+
* @param module Module name.
|
|
33
|
+
* @returns Logger instance.
|
|
34
|
+
*/
|
|
35
|
+
export declare function getLogger(module: string): Logger;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Subject } from "rxjs";
|
|
2
|
+
import { entries } from "../common/entries";
|
|
3
|
+
/**
|
|
4
|
+
* The subsject is created and overrdien in initLogger().
|
|
5
|
+
* The function has to be called each time new instance of CameraKit is bootstrapped.
|
|
6
|
+
*/
|
|
7
|
+
let logEntriesSubject = new Subject();
|
|
8
|
+
/**
|
|
9
|
+
* This map associates log level names with their corresponding level value.
|
|
10
|
+
* This means that a configured log level will match all log entries with a level value greater than
|
|
11
|
+
* or equal to the configured value.
|
|
12
|
+
*/
|
|
13
|
+
export const logLevelMap = {
|
|
14
|
+
error: 3,
|
|
15
|
+
warn: 2,
|
|
16
|
+
log: 1,
|
|
17
|
+
info: 1,
|
|
18
|
+
debug: 0,
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Initializes new logger subject.
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
export function initLogger() {
|
|
25
|
+
return (logEntriesSubject = new Subject());
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Gets logger for a given module.
|
|
29
|
+
*
|
|
30
|
+
* @internal
|
|
31
|
+
*
|
|
32
|
+
* @param module Module name.
|
|
33
|
+
* @returns Logger instance.
|
|
34
|
+
*/
|
|
35
|
+
export function getLogger(module) {
|
|
36
|
+
return entries(logLevelMap).reduce((logger, [level]) => {
|
|
37
|
+
logger[level] = (...messages) => {
|
|
38
|
+
logEntriesSubject.next({
|
|
39
|
+
time: new Date(),
|
|
40
|
+
module,
|
|
41
|
+
level,
|
|
42
|
+
messages,
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
return logger;
|
|
46
|
+
}, {});
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C;;;GAGG;AACH,IAAI,iBAAiB,GAAG,IAAI,OAAO,EAAY,CAAC;AAEhD;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACvB,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,CAAC;IACP,GAAG,EAAE,CAAC;IACN,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,CAAC;CACX,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,UAAU;IACtB,OAAO,CAAC,iBAAiB,GAAG,IAAI,OAAO,EAAY,CAAC,CAAC;AACzD,CAAC;AAYD;;;;;;;GAOG;AACH,MAAM,UAAU,SAAS,CAAC,MAAc;IACpC,OAAO,OAAO,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,EAAE,EAAE;QACnD,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,QAAe,EAAE,EAAE;YACnC,iBAAiB,CAAC,IAAI,CAAC;gBACnB,IAAI,EAAE,IAAI,IAAI,EAAE;gBAChB,MAAM;gBACN,KAAK;gBACL,QAAQ;aACX,CAAC,CAAC;QACP,CAAC,CAAC;QACF,OAAO,MAAM,CAAC;IAClB,CAAC,EAAE,EAAY,CAAC,CAAC;AACrB,CAAC","sourcesContent":["import { Subject } from \"rxjs\";\nimport { entries } from \"../common/entries\";\n\n/**\n * The subsject is created and overrdien in initLogger().\n * The function has to be called each time new instance of CameraKit is bootstrapped.\n */\nlet logEntriesSubject = new Subject<LogEntry>();\n\n/**\n * This map associates log level names with their corresponding level value.\n * This means that a configured log level will match all log entries with a level value greater than\n * or equal to the configured value.\n */\nexport const logLevelMap = {\n error: 3,\n warn: 2,\n log: 1,\n info: 1,\n debug: 0,\n};\n\n/**\n * Initializes new logger subject.\n * @internal\n */\nexport function initLogger() {\n return (logEntriesSubject = new Subject<LogEntry>());\n}\n\nexport interface LogEntry {\n time: Date;\n module: string;\n level: keyof Logger;\n messages: any[];\n}\n\nexport type LogLevelName = keyof typeof logLevelMap;\nexport type Logger = Record<LogLevelName, (message?: any, ...optionalParams: any[]) => void>;\n\n/**\n * Gets logger for a given module.\n *\n * @internal\n *\n * @param module Module name.\n * @returns Logger instance.\n */\nexport function getLogger(module: string): Logger {\n return entries(logLevelMap).reduce((logger, [level]) => {\n logger[level] = (...messages: any[]) => {\n logEntriesSubject.next({\n time: new Date(),\n module,\n level,\n messages,\n });\n };\n return logger;\n }, {} as Logger);\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Observable } from "rxjs";
|
|
2
|
+
import { CameraKitConfiguration } from "../configuration";
|
|
3
|
+
import { LogEntry } from "./logger";
|
|
4
|
+
/**
|
|
5
|
+
* The factory subscribes to log entry events and, based on the configured log level,
|
|
6
|
+
* forwards matching log entries to the logger specified in the CameraKit configuration object.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export declare const registerLogEntriesSubscriber: {
|
|
11
|
+
(args_0: CameraKitConfiguration, args_1: Observable<LogEntry>): void;
|
|
12
|
+
token: "registerLogEntriesSubscriber";
|
|
13
|
+
dependencies: readonly ["configuration", "logEntries"];
|
|
14
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { filter } from "rxjs";
|
|
2
|
+
import { configurationToken } from "../configuration";
|
|
3
|
+
import { Injectable } from "../dependency-injection/Injectable";
|
|
4
|
+
import { logEntriesFactory } from "./logEntries";
|
|
5
|
+
import { logLevelMap } from "./logger";
|
|
6
|
+
/**
|
|
7
|
+
* The factory subscribes to log entry events and, based on the configured log level,
|
|
8
|
+
* forwards matching log entries to the logger specified in the CameraKit configuration object.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export const registerLogEntriesSubscriber = Injectable("registerLogEntriesSubscriber", [configurationToken, logEntriesFactory.token], (configuration, logEntries) => {
|
|
13
|
+
logEntries
|
|
14
|
+
.pipe(filter((entry) => logLevelMap[entry.level] >= logLevelMap[configuration.logLevel]))
|
|
15
|
+
.subscribe((logEntry) => {
|
|
16
|
+
switch (configuration.logger) {
|
|
17
|
+
case "console":
|
|
18
|
+
console[logEntry.level](`[CameraKit.${logEntry.module}]`, ...logEntry.messages);
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=registerLogEntriesSubscriber.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registerLogEntriesSubscriber.js","sourceRoot":"","sources":["../../src/logger/registerLogEntriesSubscriber.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAc,MAAM,MAAM,CAAC;AAC1C,OAAO,EAA0B,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAY,WAAW,EAAE,MAAM,UAAU,CAAC;AAEjD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,UAAU,CAClD,8BAA8B,EAC9B,CAAC,kBAAkB,EAAE,iBAAiB,CAAC,KAAK,CAAU,EACtD,CAAC,aAAqC,EAAE,UAAgC,EAAE,EAAE;IACxE,UAAU;SACL,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,WAAW,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC;SACxF,SAAS,CAAC,CAAC,QAAQ,EAAE,EAAE;QACpB,QAAQ,aAAa,CAAC,MAAM,EAAE;YAC1B,KAAK,SAAS;gBACV,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,cAAc,QAAQ,CAAC,MAAM,GAAG,EAAE,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;gBAChF,MAAM;SACb;IACL,CAAC,CAAC,CAAC;AACX,CAAC,CACJ,CAAC","sourcesContent":["import { filter, Observable } from \"rxjs\";\nimport { CameraKitConfiguration, configurationToken } from \"../configuration\";\nimport { Injectable } from \"../dependency-injection/Injectable\";\nimport { logEntriesFactory } from \"./logEntries\";\nimport { LogEntry, logLevelMap } from \"./logger\";\n\n/**\n * The factory subscribes to log entry events and, based on the configured log level,\n * forwards matching log entries to the logger specified in the CameraKit configuration object.\n *\n * @internal\n */\nexport const registerLogEntriesSubscriber = Injectable(\n \"registerLogEntriesSubscriber\",\n [configurationToken, logEntriesFactory.token] as const,\n (configuration: CameraKitConfiguration, logEntries: Observable<LogEntry>) => {\n logEntries\n .pipe(filter((entry) => logLevelMap[entry.level] >= logLevelMap[configuration.logLevel]))\n .subscribe((logEntry) => {\n switch (configuration.logger) {\n case \"console\":\n console[logEntry.level](`[CameraKit.${logEntry.module}]`, ...logEntry.messages);\n break;\n }\n });\n }\n);\n"]}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { LensCoreModule, UseMediaElementInput } from "../lens-core-module/generated-types";
|
|
2
|
+
import { Transform2D } from "../transforms";
|
|
3
|
+
/**
|
|
4
|
+
* When creating a {@link CameraKitSource}, passing a CameraKitSourceSubscriber allows logic to implemented which will
|
|
5
|
+
* run whenever that source is attached/detached from a CameraKitSession.
|
|
6
|
+
*
|
|
7
|
+
* @category Rendering
|
|
8
|
+
*/
|
|
9
|
+
export interface CameraKitSourceSubscriber {
|
|
10
|
+
readonly onAttach?: (source: CameraKitSource, lensCore: LensCoreModule, reportError: (error: Error) => void) => void | Promise<void>;
|
|
11
|
+
readonly onDetach?: (reportError: (error: Error) => void) => void | Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
/** @category Rendering */
|
|
14
|
+
export declare type CameraKitDeviceInfo = {
|
|
15
|
+
cameraType: "front" | "back";
|
|
16
|
+
fpsLimit: number;
|
|
17
|
+
};
|
|
18
|
+
export declare type CameraKitSourceInfo = Pick<UseMediaElementInput, "media" | "replayTrackingData" | "useManualFrameProcessing">;
|
|
19
|
+
/** @category Rendering */
|
|
20
|
+
export declare type CameraKitSourceOptions<T = {}> = Partial<T> & Partial<CameraKitDeviceInfo>;
|
|
21
|
+
/**
|
|
22
|
+
* This general-purpose class represents a source of media for a {@link CameraKitSession}.
|
|
23
|
+
*
|
|
24
|
+
* When an instance is passed to {@link CameraKitSession.setSource | CameraKitSession.setSource}, it will be "attached"
|
|
25
|
+
* to the session. Later it may be "detached" from the session.
|
|
26
|
+
*
|
|
27
|
+
* Passing a {@link CameraKitSourceSubscriber} to the constructor allows callers to specify behavior
|
|
28
|
+
* that will occur when the source is attached and detached. This can be used to e.g. update the render size.
|
|
29
|
+
*
|
|
30
|
+
* @category Rendering
|
|
31
|
+
*/
|
|
32
|
+
export declare class CameraKitSource {
|
|
33
|
+
private readonly sourceInfo;
|
|
34
|
+
private readonly subscriber;
|
|
35
|
+
private lensCore?;
|
|
36
|
+
private readonly deviceInfo;
|
|
37
|
+
constructor(sourceInfo: CameraKitSourceInfo, subscriber?: CameraKitSourceSubscriber, deviceInfo?: Partial<CameraKitDeviceInfo>);
|
|
38
|
+
/**
|
|
39
|
+
* Called by {@link CameraKitSession} when this source is set as that session's source.
|
|
40
|
+
*
|
|
41
|
+
* @param lensCore
|
|
42
|
+
* @param reportError Calling this function will report an error back to the session.
|
|
43
|
+
* @returns Rejects if any calls to LensCore or CameraKitSource.subscriber.onAttach fail.
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
attach(lensCore: LensCoreModule, reportError: (error: Error) => void): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Make a copy of the source, sharing the same {@link CameraKitSourceSubscriber}.
|
|
49
|
+
*
|
|
50
|
+
* @param deviceInfo Optionally provide new device info for the copy (e.g. to change the camera type).
|
|
51
|
+
* @returns The new {@link CameraKitSource}
|
|
52
|
+
*/
|
|
53
|
+
copy(deviceInfo?: Partial<CameraKitDeviceInfo>): CameraKitSource;
|
|
54
|
+
/**
|
|
55
|
+
* Called by {@link CameraKitSession} when it must remove this source.
|
|
56
|
+
*
|
|
57
|
+
* @param reportError Calling this function will report an error back to the session.
|
|
58
|
+
* @returns
|
|
59
|
+
* @internal
|
|
60
|
+
*/
|
|
61
|
+
detach(reportError: (error: Error) => void): void | Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Set the resolution used to render this source.
|
|
64
|
+
*
|
|
65
|
+
* It’s important to distinguish render size from display size. The size at which the output canvases are displayed
|
|
66
|
+
* on a web page is determined by the CSS of the page. It is distinct from the size at which LensCore renders
|
|
67
|
+
* Lenses. Performance is dominated by render size, while any display scaling can most often be thought of as free.
|
|
68
|
+
*
|
|
69
|
+
* If greater performance is required, a smaller render size may boost frame-rate. It does come at a cost, including
|
|
70
|
+
* loss of accuracy in various tracking and computer-vision algorithms (since they'll be operating on fewer pixels).
|
|
71
|
+
*
|
|
72
|
+
* The size of the Live and Capture {@link RenderTarget} is always the same.
|
|
73
|
+
*
|
|
74
|
+
* @todo Currently it's only valid to call `setRenderSize` after `CameraKitSession.play` has been called. This
|
|
75
|
+
* constraint should be removed, so callers don't have to understand the underlying LensCore state machine.
|
|
76
|
+
*
|
|
77
|
+
* @param width pixels
|
|
78
|
+
* @param height pixels
|
|
79
|
+
* @returns Promise resolves when the render size has been successfully updated.
|
|
80
|
+
*/
|
|
81
|
+
setRenderSize(width: number, height: number): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Apply a 2D transformation to the source (e.g. translation, rotation, scale).
|
|
84
|
+
*
|
|
85
|
+
* @param transform Specifies the 3x3 matrix describing the transformation.
|
|
86
|
+
*/
|
|
87
|
+
setTransform(transform: Transform2D): Promise<void>;
|
|
88
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/member-ordering */
|
|
2
|
+
import { __awaiter, __decorate, __metadata } from "tslib";
|
|
3
|
+
import { validate } from "../common/validate";
|
|
4
|
+
import { Transform2D } from "../transforms";
|
|
5
|
+
const defaultDeviceInfo = {
|
|
6
|
+
cameraType: "front",
|
|
7
|
+
fpsLimit: Number.POSITIVE_INFINITY,
|
|
8
|
+
};
|
|
9
|
+
const createNotAttachedError = (message) => new Error(`${message}. This CameraKitSource is not attached to a CameraKitSession.`);
|
|
10
|
+
/**
|
|
11
|
+
* This general-purpose class represents a source of media for a {@link CameraKitSession}.
|
|
12
|
+
*
|
|
13
|
+
* When an instance is passed to {@link CameraKitSession.setSource | CameraKitSession.setSource}, it will be "attached"
|
|
14
|
+
* to the session. Later it may be "detached" from the session.
|
|
15
|
+
*
|
|
16
|
+
* Passing a {@link CameraKitSourceSubscriber} to the constructor allows callers to specify behavior
|
|
17
|
+
* that will occur when the source is attached and detached. This can be used to e.g. update the render size.
|
|
18
|
+
*
|
|
19
|
+
* @category Rendering
|
|
20
|
+
*/
|
|
21
|
+
export class CameraKitSource {
|
|
22
|
+
constructor(sourceInfo, subscriber = {}, deviceInfo = {}) {
|
|
23
|
+
this.sourceInfo = sourceInfo;
|
|
24
|
+
this.subscriber = subscriber;
|
|
25
|
+
this.deviceInfo = Object.assign(Object.assign({}, defaultDeviceInfo), deviceInfo);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Called by {@link CameraKitSession} when this source is set as that session's source.
|
|
29
|
+
*
|
|
30
|
+
* @param lensCore
|
|
31
|
+
* @param reportError Calling this function will report an error back to the session.
|
|
32
|
+
* @returns Rejects if any calls to LensCore or CameraKitSource.subscriber.onAttach fail.
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
35
|
+
attach(lensCore, reportError) {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
if (this.lensCore) {
|
|
38
|
+
throw new Error("Cannot attach. This CameraKitCustomSource has already been attached to " +
|
|
39
|
+
"a CameraKitSession. To re-attach, create a copy of this CameraKitCustomSource.");
|
|
40
|
+
}
|
|
41
|
+
this.lensCore = lensCore;
|
|
42
|
+
yield new Promise((onSuccess, onFailure) => {
|
|
43
|
+
lensCore.useMediaElement({
|
|
44
|
+
autoplayNewMedia: false,
|
|
45
|
+
autoplayPreviewCanvas: false,
|
|
46
|
+
media: this.sourceInfo.media,
|
|
47
|
+
pauseExistingMedia: false,
|
|
48
|
+
replayTrackingData: this.sourceInfo.replayTrackingData,
|
|
49
|
+
requestWebcam: false,
|
|
50
|
+
startOnFrontCamera: this.deviceInfo.cameraType === "front",
|
|
51
|
+
useManualFrameProcessing: this.sourceInfo.useManualFrameProcessing,
|
|
52
|
+
onSuccess,
|
|
53
|
+
onFailure,
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
yield new Promise((onSuccess, onFailure) => {
|
|
57
|
+
// LensCore uses 0 to remove the limit.
|
|
58
|
+
const fps = this.deviceInfo.fpsLimit < Number.POSITIVE_INFINITY ? this.deviceInfo.fpsLimit : 0;
|
|
59
|
+
lensCore.setFPSLimit({ fps, onSuccess, onFailure });
|
|
60
|
+
});
|
|
61
|
+
if (this.subscriber.onAttach)
|
|
62
|
+
yield this.subscriber.onAttach(this, lensCore, reportError);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Make a copy of the source, sharing the same {@link CameraKitSourceSubscriber}.
|
|
67
|
+
*
|
|
68
|
+
* @param deviceInfo Optionally provide new device info for the copy (e.g. to change the camera type).
|
|
69
|
+
* @returns The new {@link CameraKitSource}
|
|
70
|
+
*/
|
|
71
|
+
copy(deviceInfo = {}) {
|
|
72
|
+
return new CameraKitSource(this.sourceInfo, this.subscriber, Object.assign(Object.assign({}, this.deviceInfo), deviceInfo));
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Called by {@link CameraKitSession} when it must remove this source.
|
|
76
|
+
*
|
|
77
|
+
* @param reportError Calling this function will report an error back to the session.
|
|
78
|
+
* @returns
|
|
79
|
+
* @internal
|
|
80
|
+
*/
|
|
81
|
+
detach(reportError) {
|
|
82
|
+
if (!this.lensCore)
|
|
83
|
+
return Promise.reject(createNotAttachedError("Cannot detach"));
|
|
84
|
+
if (this.subscriber.onDetach)
|
|
85
|
+
return this.subscriber.onDetach(reportError);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Set the resolution used to render this source.
|
|
89
|
+
*
|
|
90
|
+
* It’s important to distinguish render size from display size. The size at which the output canvases are displayed
|
|
91
|
+
* on a web page is determined by the CSS of the page. It is distinct from the size at which LensCore renders
|
|
92
|
+
* Lenses. Performance is dominated by render size, while any display scaling can most often be thought of as free.
|
|
93
|
+
*
|
|
94
|
+
* If greater performance is required, a smaller render size may boost frame-rate. It does come at a cost, including
|
|
95
|
+
* loss of accuracy in various tracking and computer-vision algorithms (since they'll be operating on fewer pixels).
|
|
96
|
+
*
|
|
97
|
+
* The size of the Live and Capture {@link RenderTarget} is always the same.
|
|
98
|
+
*
|
|
99
|
+
* @todo Currently it's only valid to call `setRenderSize` after `CameraKitSession.play` has been called. This
|
|
100
|
+
* constraint should be removed, so callers don't have to understand the underlying LensCore state machine.
|
|
101
|
+
*
|
|
102
|
+
* @param width pixels
|
|
103
|
+
* @param height pixels
|
|
104
|
+
* @returns Promise resolves when the render size has been successfully updated.
|
|
105
|
+
*/
|
|
106
|
+
setRenderSize(width, height) {
|
|
107
|
+
return new Promise((onSuccess, onFailure) => {
|
|
108
|
+
if (!this.lensCore)
|
|
109
|
+
return onFailure(createNotAttachedError("Cannot setRenderSize"));
|
|
110
|
+
const target = { width, height };
|
|
111
|
+
this.lensCore.setRenderSize({ mode: "explicit", target, onSuccess, onFailure });
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Apply a 2D transformation to the source (e.g. translation, rotation, scale).
|
|
116
|
+
*
|
|
117
|
+
* @param transform Specifies the 3x3 matrix describing the transformation.
|
|
118
|
+
*/
|
|
119
|
+
setTransform(transform) {
|
|
120
|
+
return new Promise((onSuccess, onFailure) => {
|
|
121
|
+
if (!this.lensCore)
|
|
122
|
+
return onFailure(createNotAttachedError("Cannot setTransform"));
|
|
123
|
+
const matrix = new Float32Array(transform.matrix);
|
|
124
|
+
this.lensCore.setInputTransform({ matrix, onSuccess, onFailure });
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
__decorate([
|
|
129
|
+
validate,
|
|
130
|
+
__metadata("design:type", Function),
|
|
131
|
+
__metadata("design:paramtypes", [Number, Number]),
|
|
132
|
+
__metadata("design:returntype", Promise)
|
|
133
|
+
], CameraKitSource.prototype, "setRenderSize", null);
|
|
134
|
+
__decorate([
|
|
135
|
+
validate,
|
|
136
|
+
__metadata("design:type", Function),
|
|
137
|
+
__metadata("design:paramtypes", [Transform2D]),
|
|
138
|
+
__metadata("design:returntype", Promise)
|
|
139
|
+
], CameraKitSource.prototype, "setTransform", null);
|
|
140
|
+
//# sourceMappingURL=CameraKitSource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CameraKitSource.js","sourceRoot":"","sources":["../../src/media-sources/CameraKitSource.ts"],"names":[],"mappings":"AAAA,uDAAuD;;AAEvD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,iBAAiB,GAAwB;IAC3C,UAAU,EAAE,OAAO;IACnB,QAAQ,EAAE,MAAM,CAAC,iBAAiB;CACrC,CAAC;AAEF,MAAM,sBAAsB,GAAG,CAAC,OAAe,EAAE,EAAE,CAC/C,IAAI,KAAK,CAAC,GAAG,OAAO,+DAA+D,CAAC,CAAC;AA+BzF;;;;;;;;;;GAUG;AACH,MAAM,OAAO,eAAe;IAIxB,YACqB,UAA+B,EAC/B,aAAwC,EAAE,EAC3D,aAA2C,EAAE;QAF5B,eAAU,GAAV,UAAU,CAAqB;QAC/B,eAAU,GAAV,UAAU,CAAgC;QAG3D,IAAI,CAAC,UAAU,mCAAQ,iBAAiB,GAAK,UAAU,CAAE,CAAC;IAC9D,CAAC;IAED;;;;;;;OAOG;IACG,MAAM,CAAC,QAAwB,EAAE,WAAmC;;YACtE,IAAI,IAAI,CAAC,QAAQ,EAAE;gBACf,MAAM,IAAI,KAAK,CACX,yEAAyE;oBACrE,gFAAgF,CACvF,CAAC;aACL;YAED,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;YAEzB,MAAM,IAAI,OAAO,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE;gBACvC,QAAQ,CAAC,eAAe,CAAC;oBACrB,gBAAgB,EAAE,KAAK;oBACvB,qBAAqB,EAAE,KAAK;oBAC5B,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,KAAK;oBAC5B,kBAAkB,EAAE,KAAK;oBACzB,kBAAkB,EAAE,IAAI,CAAC,UAAU,CAAC,kBAAkB;oBACtD,aAAa,EAAE,KAAK;oBACpB,kBAAkB,EAAE,IAAI,CAAC,UAAU,CAAC,UAAU,KAAK,OAAO;oBAC1D,wBAAwB,EAAE,IAAI,CAAC,UAAU,CAAC,wBAAwB;oBAClE,SAAS;oBACT,SAAS;iBACZ,CAAC,CAAC;YACP,CAAC,CAAC,CAAC;YAEH,MAAM,IAAI,OAAO,CAAO,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE;gBAC7C,uCAAuC;gBACvC,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,QAAQ,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC/F,QAAQ,CAAC,WAAW,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,CAAC;YACxD,CAAC,CAAC,CAAC;YAEH,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ;gBAAE,MAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;QAC9F,CAAC;KAAA;IAED;;;;;OAKG;IACH,IAAI,CAAC,aAA2C,EAAE;QAC9C,OAAO,IAAI,eAAe,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,kCAAO,IAAI,CAAC,UAAU,GAAK,UAAU,EAAG,CAAC;IACxG,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,WAAmC;QACtC,IAAI,CAAC,IAAI,CAAC,QAAQ;YAAE,OAAO,OAAO,CAAC,MAAM,CAAC,sBAAsB,CAAC,eAAe,CAAC,CAAC,CAAC;QACnF,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ;YAAE,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAC/E,CAAC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IAEH,aAAa,CAAC,KAAa,EAAE,MAAc;QACvC,OAAO,IAAI,OAAO,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE;YACxC,IAAI,CAAC,IAAI,CAAC,QAAQ;gBAAE,OAAO,SAAS,CAAC,sBAAsB,CAAC,sBAAsB,CAAC,CAAC,CAAC;YACrF,MAAM,MAAM,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;YACjC,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,CAAC;QACpF,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;;;OAIG;IAEH,YAAY,CAAC,SAAsB;QAC/B,OAAO,IAAI,OAAO,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE;YACxC,IAAI,CAAC,IAAI,CAAC,QAAQ;gBAAE,OAAO,SAAS,CAAC,sBAAsB,CAAC,qBAAqB,CAAC,CAAC,CAAC;YACpF,MAAM,MAAM,GAAG,IAAI,YAAY,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;YAClD,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,CAAC;QACtE,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAtBG;IAAC,QAAQ;;;;oDAOR;AAOD;IAAC,QAAQ;;qCACe,WAAW;;mDAMlC","sourcesContent":["/* eslint-disable @typescript-eslint/member-ordering */\n\nimport { validate } from \"../common/validate\";\nimport { LensCoreModule, UseMediaElementInput } from \"../lens-core-module/generated-types\";\nimport { Transform2D } from \"../transforms\";\n\nconst defaultDeviceInfo: CameraKitDeviceInfo = {\n cameraType: \"front\",\n fpsLimit: Number.POSITIVE_INFINITY,\n};\n\nconst createNotAttachedError = (message: string) =>\n new Error(`${message}. This CameraKitSource is not attached to a CameraKitSession.`);\n\n/**\n * When creating a {@link CameraKitSource}, passing a CameraKitSourceSubscriber allows logic to implemented which will\n * run whenever that source is attached/detached from a CameraKitSession.\n *\n * @category Rendering\n */\nexport interface CameraKitSourceSubscriber {\n readonly onAttach?: (\n source: CameraKitSource,\n lensCore: LensCoreModule,\n reportError: (error: Error) => void\n ) => void | Promise<void>;\n readonly onDetach?: (reportError: (error: Error) => void) => void | Promise<void>;\n}\n\n/** @category Rendering */\nexport type CameraKitDeviceInfo = {\n cameraType: \"front\" | \"back\";\n fpsLimit: number;\n};\n\nexport type CameraKitSourceInfo = Pick<\n UseMediaElementInput,\n \"media\" | \"replayTrackingData\" | \"useManualFrameProcessing\"\n>;\n\n/** @category Rendering */\nexport type CameraKitSourceOptions<T = {}> = Partial<T> & Partial<CameraKitDeviceInfo>;\n\n/**\n * This general-purpose class represents a source of media for a {@link CameraKitSession}.\n *\n * When an instance is passed to {@link CameraKitSession.setSource | CameraKitSession.setSource}, it will be \"attached\"\n * to the session. Later it may be \"detached\" from the session.\n *\n * Passing a {@link CameraKitSourceSubscriber} to the constructor allows callers to specify behavior\n * that will occur when the source is attached and detached. This can be used to e.g. update the render size.\n *\n * @category Rendering\n */\nexport class CameraKitSource {\n private lensCore?: LensCoreModule;\n private readonly deviceInfo: CameraKitDeviceInfo;\n\n constructor(\n private readonly sourceInfo: CameraKitSourceInfo,\n private readonly subscriber: CameraKitSourceSubscriber = {},\n deviceInfo: Partial<CameraKitDeviceInfo> = {}\n ) {\n this.deviceInfo = { ...defaultDeviceInfo, ...deviceInfo };\n }\n\n /**\n * Called by {@link CameraKitSession} when this source is set as that session's source.\n *\n * @param lensCore\n * @param reportError Calling this function will report an error back to the session.\n * @returns Rejects if any calls to LensCore or CameraKitSource.subscriber.onAttach fail.\n * @internal\n */\n async attach(lensCore: LensCoreModule, reportError: (error: Error) => void): Promise<void> {\n if (this.lensCore) {\n throw new Error(\n \"Cannot attach. This CameraKitCustomSource has already been attached to \" +\n \"a CameraKitSession. To re-attach, create a copy of this CameraKitCustomSource.\"\n );\n }\n\n this.lensCore = lensCore;\n\n await new Promise((onSuccess, onFailure) => {\n lensCore.useMediaElement({\n autoplayNewMedia: false,\n autoplayPreviewCanvas: false,\n media: this.sourceInfo.media,\n pauseExistingMedia: false,\n replayTrackingData: this.sourceInfo.replayTrackingData,\n requestWebcam: false,\n startOnFrontCamera: this.deviceInfo.cameraType === \"front\",\n useManualFrameProcessing: this.sourceInfo.useManualFrameProcessing,\n onSuccess,\n onFailure,\n });\n });\n\n await new Promise<void>((onSuccess, onFailure) => {\n // LensCore uses 0 to remove the limit.\n const fps = this.deviceInfo.fpsLimit < Number.POSITIVE_INFINITY ? this.deviceInfo.fpsLimit : 0;\n lensCore.setFPSLimit({ fps, onSuccess, onFailure });\n });\n\n if (this.subscriber.onAttach) await this.subscriber.onAttach(this, lensCore, reportError);\n }\n\n /**\n * Make a copy of the source, sharing the same {@link CameraKitSourceSubscriber}.\n *\n * @param deviceInfo Optionally provide new device info for the copy (e.g. to change the camera type).\n * @returns The new {@link CameraKitSource}\n */\n copy(deviceInfo: Partial<CameraKitDeviceInfo> = {}): CameraKitSource {\n return new CameraKitSource(this.sourceInfo, this.subscriber, { ...this.deviceInfo, ...deviceInfo });\n }\n\n /**\n * Called by {@link CameraKitSession} when it must remove this source.\n *\n * @param reportError Calling this function will report an error back to the session.\n * @returns\n * @internal\n */\n detach(reportError: (error: Error) => void): void | Promise<void> {\n if (!this.lensCore) return Promise.reject(createNotAttachedError(\"Cannot detach\"));\n if (this.subscriber.onDetach) return this.subscriber.onDetach(reportError);\n }\n\n /**\n * Set the resolution used to render this source.\n *\n * It’s important to distinguish render size from display size. The size at which the output canvases are displayed\n * on a web page is determined by the CSS of the page. It is distinct from the size at which LensCore renders\n * Lenses. Performance is dominated by render size, while any display scaling can most often be thought of as free.\n *\n * If greater performance is required, a smaller render size may boost frame-rate. It does come at a cost, including\n * loss of accuracy in various tracking and computer-vision algorithms (since they'll be operating on fewer pixels).\n *\n * The size of the Live and Capture {@link RenderTarget} is always the same.\n *\n * @todo Currently it's only valid to call `setRenderSize` after `CameraKitSession.play` has been called. This\n * constraint should be removed, so callers don't have to understand the underlying LensCore state machine.\n *\n * @param width pixels\n * @param height pixels\n * @returns Promise resolves when the render size has been successfully updated.\n */\n @validate\n setRenderSize(width: number, height: number): Promise<void> {\n return new Promise((onSuccess, onFailure) => {\n if (!this.lensCore) return onFailure(createNotAttachedError(\"Cannot setRenderSize\"));\n const target = { width, height };\n this.lensCore.setRenderSize({ mode: \"explicit\", target, onSuccess, onFailure });\n });\n }\n\n /**\n * Apply a 2D transformation to the source (e.g. translation, rotation, scale).\n *\n * @param transform Specifies the 3x3 matrix describing the transformation.\n */\n @validate\n setTransform(transform: Transform2D): Promise<void> {\n return new Promise((onSuccess, onFailure) => {\n if (!this.lensCore) return onFailure(createNotAttachedError(\"Cannot setTransform\"));\n const matrix = new Float32Array(transform.matrix);\n this.lensCore.setInputTransform({ matrix, onSuccess, onFailure });\n });\n }\n}\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { CameraKitSource, CameraKitSourceOptions } from "./CameraKitSource";
|
|
2
|
+
/** @internal */
|
|
3
|
+
export declare type FrameFormat = "rgb" | "yuv" | "nv12";
|
|
4
|
+
/** @internal */
|
|
5
|
+
export interface FrameInput {
|
|
6
|
+
format?: FrameFormat;
|
|
7
|
+
imageData: ImageData;
|
|
8
|
+
timestampMillis: number;
|
|
9
|
+
}
|
|
10
|
+
/** @internal */
|
|
11
|
+
export interface FrameOutput {
|
|
12
|
+
live: ImageData;
|
|
13
|
+
capture: ImageData;
|
|
14
|
+
}
|
|
15
|
+
/** @internal */
|
|
16
|
+
export interface MediaSourceFunction {
|
|
17
|
+
(render: (frame: FrameInput) => Promise<FrameOutput>): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Creates a {@link CameraKitSource} from a function which provides per-frame pixel data to CameraKit.
|
|
21
|
+
*
|
|
22
|
+
* @param sourceFunction This function will be called in a requestAnimationFrame loop. Each time it is called, it is
|
|
23
|
+
* passed a `render` function. It may call `render` and CameraKit will process the pixel data passed to `render` and
|
|
24
|
+
* return a Promise of the processed pixels (along with rendering them to the normal output canvases).
|
|
25
|
+
* @param options
|
|
26
|
+
* @param options.cameraType By default we set this to 'front', which is the camera type most Lenses expect.
|
|
27
|
+
*
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
30
|
+
export declare const createFunctionSource: (sourceFunction: MediaSourceFunction, options?: Omit<CameraKitSourceOptions, "fpsLimit">) => CameraKitSource;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { CameraKitSource } from "./CameraKitSource";
|
|
3
|
+
const getYUVImageData = (canvas, lensCore) => __awaiter(void 0, void 0, void 0, function* () {
|
|
4
|
+
const { width, height } = canvas;
|
|
5
|
+
// A YUV buffer has lower-res UV channels, so the total number of bytes works out like so:
|
|
6
|
+
const outputBuffer = new ArrayBuffer((width * height * 3) / 2);
|
|
7
|
+
yield new Promise((onSuccess, onFailure) => {
|
|
8
|
+
lensCore.imageToYuvBuffer({ image: canvas, width, height, outputBuffer, onSuccess, onFailure });
|
|
9
|
+
});
|
|
10
|
+
const pixels = new Uint8ClampedArray(outputBuffer);
|
|
11
|
+
return new ImageData(pixels, width, height);
|
|
12
|
+
});
|
|
13
|
+
const getRGBImageData = (output, imageReader2D) => {
|
|
14
|
+
if (imageReader2D === null)
|
|
15
|
+
return new ImageData(0, 0);
|
|
16
|
+
imageReader2D.drawImage(output, 0, 0);
|
|
17
|
+
return imageReader2D.getImageData(0, 0, output.width, output.height);
|
|
18
|
+
};
|
|
19
|
+
const getImageBitmap = (imageData, format) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
|
+
switch (format) {
|
|
21
|
+
case "nv12":
|
|
22
|
+
case "yuv":
|
|
23
|
+
if (!window.VideoFrame)
|
|
24
|
+
return Promise.reject(new Error(`Cannot process frame. ImageData in ${format} ` + `is not supported by this browser.`));
|
|
25
|
+
const frame = new VideoFrame(imageData.data.buffer, {
|
|
26
|
+
format: "NV12",
|
|
27
|
+
codedWidth: imageData.width,
|
|
28
|
+
codedHeight: imageData.height,
|
|
29
|
+
timestamp: 0,
|
|
30
|
+
});
|
|
31
|
+
return createImageBitmap(frame);
|
|
32
|
+
case "rgb":
|
|
33
|
+
return createImageBitmap(imageData);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
/**
|
|
37
|
+
* Creates a {@link CameraKitSource} from a function which provides per-frame pixel data to CameraKit.
|
|
38
|
+
*
|
|
39
|
+
* @param sourceFunction This function will be called in a requestAnimationFrame loop. Each time it is called, it is
|
|
40
|
+
* passed a `render` function. It may call `render` and CameraKit will process the pixel data passed to `render` and
|
|
41
|
+
* return a Promise of the processed pixels (along with rendering them to the normal output canvases).
|
|
42
|
+
* @param options
|
|
43
|
+
* @param options.cameraType By default we set this to 'front', which is the camera type most Lenses expect.
|
|
44
|
+
*
|
|
45
|
+
* @internal
|
|
46
|
+
*/
|
|
47
|
+
export const createFunctionSource = (sourceFunction, options = {}) => {
|
|
48
|
+
let width = 0;
|
|
49
|
+
let height = 0;
|
|
50
|
+
let shouldProcessFrame = true;
|
|
51
|
+
// We require an auxiliary canvas that we can use to read back pixel data (unless we're in YUV mode, in which case
|
|
52
|
+
// we use LensCore to convert between formats and we don't need this canvas).
|
|
53
|
+
const imageReaderCanvas = document.createElement("canvas");
|
|
54
|
+
const imageReader2D = imageReaderCanvas.getContext("2d");
|
|
55
|
+
const subscriber = {
|
|
56
|
+
onAttach: (source, lensCore, reportError) => {
|
|
57
|
+
const outputs = lensCore.getOutputCanvases();
|
|
58
|
+
const output = {
|
|
59
|
+
live: outputs[lensCore.CanvasType.Preview.value],
|
|
60
|
+
capture: outputs[lensCore.CanvasType.Capture.value],
|
|
61
|
+
};
|
|
62
|
+
const processFrame = (source, lensCore, reportError) => requestAnimationFrame(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
63
|
+
var _a;
|
|
64
|
+
if (!shouldProcessFrame)
|
|
65
|
+
return;
|
|
66
|
+
try {
|
|
67
|
+
yield sourceFunction(({ format, imageData, timestampMillis }) => {
|
|
68
|
+
const frameOutput = new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
|
|
69
|
+
const inputFrame = yield getImageBitmap(imageData, format !== null && format !== void 0 ? format : "rgb");
|
|
70
|
+
if (inputFrame.width !== width || inputFrame.height !== height) {
|
|
71
|
+
width = imageReaderCanvas.width = inputFrame.width;
|
|
72
|
+
height = imageReaderCanvas.height = inputFrame.height;
|
|
73
|
+
// We don't await this promise, because we want to continue to process frames and
|
|
74
|
+
// let LensCore manage the concurrency between setting resolution and processing a
|
|
75
|
+
// frame.
|
|
76
|
+
source.setRenderSize(width, height);
|
|
77
|
+
}
|
|
78
|
+
lensCore.processFrame({
|
|
79
|
+
inputFrame,
|
|
80
|
+
timestampMillis,
|
|
81
|
+
onSuccess: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
82
|
+
// Closing releases graphics resources associated with the frame, now that is
|
|
83
|
+
// has been processed.
|
|
84
|
+
inputFrame.close();
|
|
85
|
+
switch (format !== null && format !== void 0 ? format : "rgb") {
|
|
86
|
+
case "nv12":
|
|
87
|
+
case "yuv":
|
|
88
|
+
const [live, capture] = yield Promise.all([
|
|
89
|
+
getYUVImageData(output.live, lensCore),
|
|
90
|
+
getYUVImageData(output.capture, lensCore),
|
|
91
|
+
]).catch((error) => {
|
|
92
|
+
reject(error);
|
|
93
|
+
return [undefined, undefined];
|
|
94
|
+
});
|
|
95
|
+
// if either of these is undefined, we'll have already rejected
|
|
96
|
+
// the promise, so we can return.
|
|
97
|
+
if (!live || !capture)
|
|
98
|
+
return;
|
|
99
|
+
return resolve({ live, capture });
|
|
100
|
+
case "rgb":
|
|
101
|
+
return resolve({
|
|
102
|
+
live: getRGBImageData(output.live, imageReader2D),
|
|
103
|
+
capture: getRGBImageData(output.capture, imageReader2D),
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}),
|
|
107
|
+
onFailure: (error) => {
|
|
108
|
+
inputFrame.close();
|
|
109
|
+
reject(error);
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
}));
|
|
113
|
+
// Even if there's an error processing the frame, we do want to attempt to process the next
|
|
114
|
+
// frame. We expect `sourceFunction` to handle a rejected `frameOutput` Promise.
|
|
115
|
+
frameOutput.finally(() => processFrame(source, lensCore, reportError));
|
|
116
|
+
return frameOutput;
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
reportError(new Error("Failure to process frame, which was not handled by the provided " +
|
|
121
|
+
`MediaSourceFunction ${(_a = sourceFunction.name) !== null && _a !== void 0 ? _a : "anonymous"}.`, { cause: error }));
|
|
122
|
+
}
|
|
123
|
+
}));
|
|
124
|
+
processFrame(source, lensCore, reportError);
|
|
125
|
+
},
|
|
126
|
+
onDetach: () => {
|
|
127
|
+
shouldProcessFrame = false;
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
return new CameraKitSource({ useManualFrameProcessing: true }, subscriber, options);
|
|
131
|
+
};
|
|
132
|
+
//# sourceMappingURL=FunctionSource.js.map
|