@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,89 @@
|
|
|
1
|
+
import { TypedCustomEvent } from "../events/TypedCustomEvent";
|
|
2
|
+
import { TypedEventListener, TypedEventListenerOptions } from "../events/TypedEventTarget";
|
|
3
|
+
import { UriHandler } from "../extensions/UriHandlers";
|
|
4
|
+
import { Lens } from "../lens/Lens";
|
|
5
|
+
import { LensState } from "./lensState";
|
|
6
|
+
/**
|
|
7
|
+
* Events emitted by {@link Keyboard}.
|
|
8
|
+
*/
|
|
9
|
+
export declare type KeyboardEvents = TypedCustomEvent<"active", {
|
|
10
|
+
element: HTMLTextAreaElement;
|
|
11
|
+
active: boolean;
|
|
12
|
+
lens?: Lens;
|
|
13
|
+
}>;
|
|
14
|
+
/**
|
|
15
|
+
* Keyboard is an API enabling lenses to consume and render user-generated text.
|
|
16
|
+
*
|
|
17
|
+
* Applications that wish to use lenses that expect user-generated text will need to use this API to integrate text
|
|
18
|
+
* input into their user experience.
|
|
19
|
+
*
|
|
20
|
+
* There are two ways to do this:
|
|
21
|
+
* 1. Add the provided DOM element (an HTMLTextAreaElement) to the page. When the user updates this element with text,
|
|
22
|
+
* that text will be sent to the currently active lens.
|
|
23
|
+
* 2. Use the {@link sendInputToLens} method to send text strings to the currently active lens directly.
|
|
24
|
+
*
|
|
25
|
+
* Lenses will also signal to the application when text input is expected -- applications should add an event listener
|
|
26
|
+
* and ensure the user is able to input text when the `active` event is received.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* cameraKitSession.keyboard.addEventListener('active', ({ detail }) => {
|
|
31
|
+
* const { element, active } = detail
|
|
32
|
+
* if (active) document.body.appendChild(element)
|
|
33
|
+
* else element.remove()
|
|
34
|
+
* })
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @category Lenses
|
|
38
|
+
*/
|
|
39
|
+
export declare type Keyboard = {
|
|
40
|
+
addEventListener: (type: "active", callback: TypedEventListener<KeyboardEvents>, options?: TypedEventListenerOptions) => void;
|
|
41
|
+
removeEventListener: (type: "active", callback: TypedEventListener<KeyboardEvents>) => void;
|
|
42
|
+
/**
|
|
43
|
+
* Get an HTMLTextAreaElement that communicates text to the active Lens.
|
|
44
|
+
*/
|
|
45
|
+
getElement: () => HTMLTextAreaElement;
|
|
46
|
+
/**
|
|
47
|
+
* Send text to the active Lens. Also updates the provided HTMLTextAreaElement.
|
|
48
|
+
*
|
|
49
|
+
* @param text String to render. This can include escape sequences, such as the newline character ( \n ) for
|
|
50
|
+
* multi-line input.
|
|
51
|
+
*/
|
|
52
|
+
sendInputToLens: (text: string) => void;
|
|
53
|
+
/**
|
|
54
|
+
* Clears the provided HTMLTextAreaElement, and emits the "active" event with `active == false`, allowing the
|
|
55
|
+
* application to e.g. remove relevant text input elements from the DOM.
|
|
56
|
+
*/
|
|
57
|
+
dismiss: () => void;
|
|
58
|
+
};
|
|
59
|
+
/** @internal */
|
|
60
|
+
export declare class LensKeyboard {
|
|
61
|
+
private readonly lensState;
|
|
62
|
+
readonly uriHandler: UriHandler;
|
|
63
|
+
private readonly events;
|
|
64
|
+
private readonly element;
|
|
65
|
+
private active;
|
|
66
|
+
private handleReply;
|
|
67
|
+
constructor(lensState: LensState);
|
|
68
|
+
dismiss(): void;
|
|
69
|
+
getElement(): HTMLTextAreaElement;
|
|
70
|
+
sendInputToLens(text: string): void;
|
|
71
|
+
addEventListener(type: "active", callback: TypedEventListener<KeyboardEvents>, options?: TypedEventListenerOptions): void;
|
|
72
|
+
removeEventListener(type: "active", callback: TypedEventListener<KeyboardEvents>): void;
|
|
73
|
+
toPublicInterface(): Keyboard;
|
|
74
|
+
private updateStatus;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* @internal
|
|
78
|
+
*/
|
|
79
|
+
export declare const lensKeyboardFactory: {
|
|
80
|
+
(args_0: import("@snap/state-management").StateMachine<import("@snap/state-management").Action<"applyLens", {
|
|
81
|
+
lens: Lens;
|
|
82
|
+
launchParams?: import("..").LensLaunchParams | undefined;
|
|
83
|
+
}> | import("@snap/state-management").Action<"downloadComplete", Lens> | import("@snap/state-management").Action<"turnedOn", Lens> | import("@snap/state-management").Action<"resourcesLoaded", Lens> | import("@snap/state-management").Action<"firstFrameProcessed", Lens> | import("@snap/state-management").Action<"applyLensComplete", Lens> | import("@snap/state-management").Action<"applyLensFailed", {
|
|
84
|
+
error: import("./lensState").LensErrors;
|
|
85
|
+
lens: Lens;
|
|
86
|
+
}> | import("@snap/state-management").Action<"removeLens", undefined> | import("@snap/state-management").Action<"turnedOff", Lens> | import("@snap/state-management").Action<"removeLensComplete", undefined> | import("@snap/state-management").Action<"removeLensFailed", Error>, import("@snap/state-management").State<"noLensApplied", undefined> | import("@snap/state-management").State<"applyingLens", Lens> | import("@snap/state-management").State<"lensApplied", Lens>>): LensKeyboard;
|
|
87
|
+
token: "lensKeyboard";
|
|
88
|
+
dependencies: readonly ["lensState"];
|
|
89
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { isState, forActions } from "@snap/state-management";
|
|
2
|
+
import { Injectable } from "../dependency-injection/Injectable";
|
|
3
|
+
import { TypedCustomEvent } from "../events/TypedCustomEvent";
|
|
4
|
+
import { TypedEventTarget } from "../events/TypedEventTarget";
|
|
5
|
+
import { lensStateFactory } from "./lensState";
|
|
6
|
+
/** @internal */
|
|
7
|
+
export class LensKeyboard {
|
|
8
|
+
constructor(lensState) {
|
|
9
|
+
this.lensState = lensState;
|
|
10
|
+
this.active = false;
|
|
11
|
+
this.element = document.createElement("textarea");
|
|
12
|
+
this.element.addEventListener("keypress", (event) => {
|
|
13
|
+
if (event.code === "Enter" && !event.shiftKey) {
|
|
14
|
+
event.preventDefault();
|
|
15
|
+
this.handleReply(this.element.value);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
this.events = new TypedEventTarget();
|
|
19
|
+
this.handleReply = () => { };
|
|
20
|
+
this.uriHandler = {
|
|
21
|
+
uri: "app://textInput/requestKeyboard",
|
|
22
|
+
handleRequest: (_request, reply) => {
|
|
23
|
+
this.element.autofocus = true;
|
|
24
|
+
this.handleReply = (text) => {
|
|
25
|
+
const opt = {
|
|
26
|
+
text: text,
|
|
27
|
+
start: text.length,
|
|
28
|
+
end: text.length,
|
|
29
|
+
done: true,
|
|
30
|
+
shouldNotify: true,
|
|
31
|
+
};
|
|
32
|
+
const output = new TextEncoder().encode(JSON.stringify(opt));
|
|
33
|
+
reply({
|
|
34
|
+
code: 200,
|
|
35
|
+
description: "",
|
|
36
|
+
contentType: "application/json",
|
|
37
|
+
data: output,
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
this.active = true;
|
|
41
|
+
this.updateStatus();
|
|
42
|
+
this.element.focus();
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
lensState.events.pipe(forActions("turnedOff")).subscribe(() => {
|
|
46
|
+
this.dismiss();
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
dismiss() {
|
|
50
|
+
if (this.active) {
|
|
51
|
+
this.active = false;
|
|
52
|
+
this.element.value = "";
|
|
53
|
+
this.updateStatus();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
getElement() {
|
|
57
|
+
return this.element;
|
|
58
|
+
}
|
|
59
|
+
sendInputToLens(text) {
|
|
60
|
+
this.element.value = text;
|
|
61
|
+
this.handleReply(text);
|
|
62
|
+
}
|
|
63
|
+
addEventListener(type, callback, options) {
|
|
64
|
+
this.events.addEventListener(type, callback, options);
|
|
65
|
+
}
|
|
66
|
+
removeEventListener(type, callback) {
|
|
67
|
+
this.events.removeEventListener(type, callback);
|
|
68
|
+
}
|
|
69
|
+
toPublicInterface() {
|
|
70
|
+
return {
|
|
71
|
+
addEventListener: this.addEventListener.bind(this),
|
|
72
|
+
removeEventListener: this.removeEventListener.bind(this),
|
|
73
|
+
getElement: this.getElement.bind(this),
|
|
74
|
+
sendInputToLens: this.sendInputToLens.bind(this),
|
|
75
|
+
dismiss: this.dismiss.bind(this),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
updateStatus() {
|
|
79
|
+
const state = this.lensState.getState();
|
|
80
|
+
// If lens keyboard status is changing, we know a lens must be applied.
|
|
81
|
+
if (isState(state, "noLensApplied"))
|
|
82
|
+
return;
|
|
83
|
+
this.events.dispatchEvent(new TypedCustomEvent("active", {
|
|
84
|
+
element: this.element,
|
|
85
|
+
active: this.active,
|
|
86
|
+
// If the keyboard is up, it has been triggered by an active lens.
|
|
87
|
+
lens: state.data,
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* @internal
|
|
93
|
+
*/
|
|
94
|
+
export const lensKeyboardFactory = Injectable("lensKeyboard", [lensStateFactory.token], (lensState) => new LensKeyboard(lensState));
|
|
95
|
+
//# sourceMappingURL=LensKeyboard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LensKeyboard.js","sourceRoot":"","sources":["../../src/session/LensKeyboard.ts"],"names":[],"mappings":"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","sourcesContent":["import { isState, forActions } from \"@snap/state-management\";\nimport { Injectable } from \"../dependency-injection/Injectable\";\nimport { TypedCustomEvent } from \"../events/TypedCustomEvent\";\nimport { TypedEventListener, TypedEventListenerOptions, TypedEventTarget } from \"../events/TypedEventTarget\";\nimport { UriHandler } from \"../extensions/UriHandlers\";\nimport { Lens } from \"../lens/Lens\";\nimport { LensState, lensStateFactory } from \"./lensState\";\n\n/**\n * Events emitted by {@link Keyboard}.\n */\nexport type KeyboardEvents = TypedCustomEvent<\n \"active\",\n {\n element: HTMLTextAreaElement;\n active: boolean;\n lens?: Lens;\n }\n>;\n\n/**\n * Keyboard is an API enabling lenses to consume and render user-generated text.\n *\n * Applications that wish to use lenses that expect user-generated text will need to use this API to integrate text\n * input into their user experience.\n *\n * There are two ways to do this:\n * 1. Add the provided DOM element (an HTMLTextAreaElement) to the page. When the user updates this element with text,\n * that text will be sent to the currently active lens.\n * 2. Use the {@link sendInputToLens} method to send text strings to the currently active lens directly.\n *\n * Lenses will also signal to the application when text input is expected -- applications should add an event listener\n * and ensure the user is able to input text when the `active` event is received.\n *\n * @example\n * ```ts\n * cameraKitSession.keyboard.addEventListener('active', ({ detail }) => {\n * const { element, active } = detail\n * if (active) document.body.appendChild(element)\n * else element.remove()\n * })\n * ```\n *\n * @category Lenses\n */\nexport type Keyboard = {\n addEventListener: (\n type: \"active\",\n callback: TypedEventListener<KeyboardEvents>,\n options?: TypedEventListenerOptions\n ) => void;\n removeEventListener: (type: \"active\", callback: TypedEventListener<KeyboardEvents>) => void;\n\n /**\n * Get an HTMLTextAreaElement that communicates text to the active Lens.\n */\n getElement: () => HTMLTextAreaElement;\n\n /**\n * Send text to the active Lens. Also updates the provided HTMLTextAreaElement.\n *\n * @param text String to render. This can include escape sequences, such as the newline character ( \\n ) for\n * multi-line input.\n */\n sendInputToLens: (text: string) => void;\n\n /**\n * Clears the provided HTMLTextAreaElement, and emits the \"active\" event with `active == false`, allowing the\n * application to e.g. remove relevant text input elements from the DOM.\n */\n dismiss: () => void;\n};\n\n/** @internal */\nexport class LensKeyboard {\n public readonly uriHandler: UriHandler;\n private readonly events: TypedEventTarget<KeyboardEvents>;\n private readonly element: HTMLTextAreaElement;\n private active: boolean;\n private handleReply: (text: string) => void;\n\n constructor(private readonly lensState: LensState) {\n this.active = false;\n this.element = document.createElement(\"textarea\");\n this.element.addEventListener(\"keypress\", (event: KeyboardEvent) => {\n if (event.code === \"Enter\" && !event.shiftKey) {\n event.preventDefault();\n this.handleReply(this.element.value);\n }\n });\n this.events = new TypedEventTarget<KeyboardEvents>();\n this.handleReply = () => {};\n this.uriHandler = {\n uri: \"app://textInput/requestKeyboard\",\n handleRequest: (_request, reply) => {\n this.element.autofocus = true;\n this.handleReply = (text: string) => {\n const opt = {\n text: text,\n start: text.length,\n end: text.length,\n done: true,\n shouldNotify: true,\n };\n const output = new TextEncoder().encode(JSON.stringify(opt));\n reply({\n code: 200,\n description: \"\",\n contentType: \"application/json\",\n data: output,\n });\n };\n this.active = true;\n this.updateStatus();\n this.element.focus();\n },\n };\n lensState.events.pipe(forActions(\"turnedOff\")).subscribe(() => {\n this.dismiss();\n });\n }\n\n dismiss(): void {\n if (this.active) {\n this.active = false;\n this.element.value = \"\";\n this.updateStatus();\n }\n }\n\n getElement(): HTMLTextAreaElement {\n return this.element;\n }\n\n sendInputToLens(text: string): void {\n this.element.value = text;\n this.handleReply(text);\n }\n\n addEventListener(\n type: \"active\",\n callback: TypedEventListener<KeyboardEvents>,\n options?: TypedEventListenerOptions\n ): void {\n this.events.addEventListener(type, callback, options);\n }\n\n removeEventListener(type: \"active\", callback: TypedEventListener<KeyboardEvents>): void {\n this.events.removeEventListener(type, callback);\n }\n\n toPublicInterface(): Keyboard {\n return {\n addEventListener: this.addEventListener.bind(this),\n removeEventListener: this.removeEventListener.bind(this),\n getElement: this.getElement.bind(this),\n sendInputToLens: this.sendInputToLens.bind(this),\n dismiss: this.dismiss.bind(this),\n };\n }\n\n private updateStatus(): void {\n const state = this.lensState.getState();\n // If lens keyboard status is changing, we know a lens must be applied.\n if (isState(state, \"noLensApplied\")) return;\n this.events.dispatchEvent(\n new TypedCustomEvent(\"active\", {\n element: this.element,\n active: this.active,\n // If the keyboard is up, it has been triggered by an active lens.\n lens: state.data,\n })\n );\n }\n}\n\n/**\n * @internal\n */\nexport const lensKeyboardFactory = Injectable(\n \"lensKeyboard\",\n [lensStateFactory.token] as const,\n (lensState: LensState) => new LensKeyboard(lensState)\n);\n"]}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @category Rendering
|
|
3
|
+
* @category Metrics
|
|
4
|
+
*/
|
|
5
|
+
export interface ComputedFrameMetrics {
|
|
6
|
+
avgFps: number;
|
|
7
|
+
lensFrameProcessingTimeMsAvg: number;
|
|
8
|
+
lensFrameProcessingTimeMsStd: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Represents an ongoing measurement of rendering metrics.
|
|
12
|
+
*
|
|
13
|
+
* An instance of this class is obtained by calling {@link LensPerformanceMetrics.beginMeasurement}. Then it may be
|
|
14
|
+
* used to record rendering performance metrics, reset measurement, or end the measurement.
|
|
15
|
+
*
|
|
16
|
+
* @category Rendering
|
|
17
|
+
* @category Metrics
|
|
18
|
+
*/
|
|
19
|
+
export declare class LensPerformanceMeasurement {
|
|
20
|
+
private instances;
|
|
21
|
+
private state;
|
|
22
|
+
private priorFrameCompletedTime?;
|
|
23
|
+
constructor(instances: Set<LensPerformanceMeasurement>);
|
|
24
|
+
/** @internal */
|
|
25
|
+
update(processingTimeMs: number): void;
|
|
26
|
+
/**
|
|
27
|
+
* Return a {@link ComputedFrameMetrics} object, containing lens performance metrics.
|
|
28
|
+
*
|
|
29
|
+
* This method may be called multiple times, each time reporting values computed since the time when this instance
|
|
30
|
+
* was created.
|
|
31
|
+
*/
|
|
32
|
+
measure(): ComputedFrameMetrics;
|
|
33
|
+
/**
|
|
34
|
+
* Reset the measured perforamance statistics (averages, std deviations). This is equivalent to using
|
|
35
|
+
* {@link LensPerformanceMetrics.beginMeasurement} to create a new LensPerformanceMeasurement instance, but may be
|
|
36
|
+
* more convenient.
|
|
37
|
+
*/
|
|
38
|
+
reset(): void;
|
|
39
|
+
/**
|
|
40
|
+
* Stop measuring performance statistics.
|
|
41
|
+
*
|
|
42
|
+
* This instance will not be garbage collected until this method is called. Therefore it is important to call this
|
|
43
|
+
* method at the appropriate time to avoid leaking memory -- particularly if your application creates many
|
|
44
|
+
* LensPerformanceMeasurement instances.
|
|
45
|
+
*/
|
|
46
|
+
end(): void;
|
|
47
|
+
/**
|
|
48
|
+
* In order to calculate the mean, variance, and standard deviation for the processing times
|
|
49
|
+
* we are using Welford's online algorithm.
|
|
50
|
+
* https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Welford's_online_algorithm
|
|
51
|
+
*
|
|
52
|
+
* @param processingTimeMs Processing time that is returned from registered callback
|
|
53
|
+
*/
|
|
54
|
+
private computeRunningStats;
|
|
55
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
const defaultFrameMetricsState = {
|
|
2
|
+
avgFps: 0,
|
|
3
|
+
averageProcessingTime: 0,
|
|
4
|
+
procFrameCount: 0,
|
|
5
|
+
procFrameMean: 0,
|
|
6
|
+
procFrameD2: 0,
|
|
7
|
+
};
|
|
8
|
+
// This duration is chosen to be larger than we expect frame processing to reasonably take on any device, but smaller
|
|
9
|
+
// than the duration of a manual rendering pause (e.g. a user clicking a pause button followed by a play button).
|
|
10
|
+
//
|
|
11
|
+
// This also defines the min avgFps that will be reported – if we see avgFps at `1 / frameDurationThresholdSec`
|
|
12
|
+
// consistently, it's safe to assume actual fps is probably even lower.
|
|
13
|
+
const frameDurationThreshold = 1;
|
|
14
|
+
/**
|
|
15
|
+
* Represents an ongoing measurement of rendering metrics.
|
|
16
|
+
*
|
|
17
|
+
* An instance of this class is obtained by calling {@link LensPerformanceMetrics.beginMeasurement}. Then it may be
|
|
18
|
+
* used to record rendering performance metrics, reset measurement, or end the measurement.
|
|
19
|
+
*
|
|
20
|
+
* @category Rendering
|
|
21
|
+
* @category Metrics
|
|
22
|
+
*/
|
|
23
|
+
export class LensPerformanceMeasurement {
|
|
24
|
+
constructor(instances) {
|
|
25
|
+
this.instances = instances;
|
|
26
|
+
this.state = Object.assign({}, defaultFrameMetricsState);
|
|
27
|
+
this.instances.add(this);
|
|
28
|
+
}
|
|
29
|
+
/** @internal */
|
|
30
|
+
update(processingTimeMs) {
|
|
31
|
+
this.computeRunningStats(processingTimeMs);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Return a {@link ComputedFrameMetrics} object, containing lens performance metrics.
|
|
35
|
+
*
|
|
36
|
+
* This method may be called multiple times, each time reporting values computed since the time when this instance
|
|
37
|
+
* was created.
|
|
38
|
+
*/
|
|
39
|
+
measure() {
|
|
40
|
+
return {
|
|
41
|
+
avgFps: this.state.avgFps,
|
|
42
|
+
lensFrameProcessingTimeMsAvg: this.state.procFrameMean,
|
|
43
|
+
lensFrameProcessingTimeMsStd: Math.sqrt(this.state.procFrameD2 / this.state.procFrameCount),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Reset the measured perforamance statistics (averages, std deviations). This is equivalent to using
|
|
48
|
+
* {@link LensPerformanceMetrics.beginMeasurement} to create a new LensPerformanceMeasurement instance, but may be
|
|
49
|
+
* more convenient.
|
|
50
|
+
*/
|
|
51
|
+
reset() {
|
|
52
|
+
this.state = Object.assign({}, defaultFrameMetricsState);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Stop measuring performance statistics.
|
|
56
|
+
*
|
|
57
|
+
* This instance will not be garbage collected until this method is called. Therefore it is important to call this
|
|
58
|
+
* method at the appropriate time to avoid leaking memory -- particularly if your application creates many
|
|
59
|
+
* LensPerformanceMeasurement instances.
|
|
60
|
+
*/
|
|
61
|
+
end() {
|
|
62
|
+
this.instances.delete(this);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* In order to calculate the mean, variance, and standard deviation for the processing times
|
|
66
|
+
* we are using Welford's online algorithm.
|
|
67
|
+
* https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Welford's_online_algorithm
|
|
68
|
+
*
|
|
69
|
+
* @param processingTimeMs Processing time that is returned from registered callback
|
|
70
|
+
*/
|
|
71
|
+
computeRunningStats(processingTimeMs) {
|
|
72
|
+
// calculate mean and delta squared for variance and standard deviation
|
|
73
|
+
const delta = processingTimeMs - this.state.procFrameMean;
|
|
74
|
+
this.state.procFrameCount += 1;
|
|
75
|
+
this.state.procFrameMean += delta / this.state.procFrameCount;
|
|
76
|
+
const delta2 = processingTimeMs - this.state.procFrameMean;
|
|
77
|
+
this.state.procFrameD2 += delta * delta2;
|
|
78
|
+
// Determine average fps
|
|
79
|
+
if (this.priorFrameCompletedTime === undefined) {
|
|
80
|
+
this.priorFrameCompletedTime = performance.now();
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
const frameDurationSec = (performance.now() - this.priorFrameCompletedTime) / 1000;
|
|
84
|
+
if (frameDurationSec < frameDurationThreshold) {
|
|
85
|
+
this.state.avgFps = (this.state.avgFps + 1 / frameDurationSec) / 2;
|
|
86
|
+
}
|
|
87
|
+
this.priorFrameCompletedTime = performance.now();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=LensPerformanceMeasurement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LensPerformanceMeasurement.js","sourceRoot":"","sources":["../../src/session/LensPerformanceMeasurement.ts"],"names":[],"mappings":"AAQA,MAAM,wBAAwB,GAAsB;IAChD,MAAM,EAAE,CAAC;IACT,qBAAqB,EAAE,CAAC;IACxB,cAAc,EAAE,CAAC;IACjB,aAAa,EAAE,CAAC;IAChB,WAAW,EAAE,CAAC;CACjB,CAAC;AAEF,qHAAqH;AACrH,iHAAiH;AACjH,EAAE;AACF,+GAA+G;AAC/G,uEAAuE;AACvE,MAAM,sBAAsB,GAAW,CAAC,CAAC;AAYzC;;;;;;;;GAQG;AACH,MAAM,OAAO,0BAA0B;IAInC,YAAoB,SAA0C;QAA1C,cAAS,GAAT,SAAS,CAAiC;QAHtD,UAAK,qBAA2B,wBAAwB,EAAG;QAI/D,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAED,gBAAgB;IAChB,MAAM,CAAC,gBAAwB;QAC3B,IAAI,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;IAC/C,CAAC;IAED;;;;;OAKG;IACH,OAAO;QACH,OAAO;YACH,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM;YACzB,4BAA4B,EAAE,IAAI,CAAC,KAAK,CAAC,aAAa;YACtD,4BAA4B,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC;SAC9F,CAAC;IACN,CAAC;IAED;;;;OAIG;IACH,KAAK;QACD,IAAI,CAAC,KAAK,qBAAQ,wBAAwB,CAAE,CAAC;IACjD,CAAC;IAED;;;;;;OAMG;IACH,GAAG;QACC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IACD;;;;;;OAMG;IACK,mBAAmB,CAAC,gBAAwB;QAChD,uEAAuE;QACvE,MAAM,KAAK,GAAG,gBAAgB,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC;QAC1D,IAAI,CAAC,KAAK,CAAC,cAAc,IAAI,CAAC,CAAC;QAC/B,IAAI,CAAC,KAAK,CAAC,aAAa,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC;QAE9D,MAAM,MAAM,GAAG,gBAAgB,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC;QAC3D,IAAI,CAAC,KAAK,CAAC,WAAW,IAAI,KAAK,GAAG,MAAM,CAAC;QAEzC,wBAAwB;QACxB,IAAI,IAAI,CAAC,uBAAuB,KAAK,SAAS,EAAE;YAC5C,IAAI,CAAC,uBAAuB,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;SACpD;aAAM;YACH,MAAM,gBAAgB,GAAG,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,uBAAuB,CAAC,GAAG,IAAI,CAAC;YACnF,IAAI,gBAAgB,GAAG,sBAAsB,EAAE;gBAC3C,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;aACtE;YACD,IAAI,CAAC,uBAAuB,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;SACpD;IACL,CAAC;CACJ","sourcesContent":["interface FrameMetricsState {\n avgFps: number;\n averageProcessingTime: number;\n procFrameCount: number;\n procFrameMean: number;\n procFrameD2: number;\n}\n\nconst defaultFrameMetricsState: FrameMetricsState = {\n avgFps: 0,\n averageProcessingTime: 0,\n procFrameCount: 0,\n procFrameMean: 0,\n procFrameD2: 0,\n};\n\n// This duration is chosen to be larger than we expect frame processing to reasonably take on any device, but smaller\n// than the duration of a manual rendering pause (e.g. a user clicking a pause button followed by a play button).\n//\n// This also defines the min avgFps that will be reported – if we see avgFps at `1 / frameDurationThresholdSec`\n// consistently, it's safe to assume actual fps is probably even lower.\nconst frameDurationThreshold: number = 1;\n\n/**\n * @category Rendering\n * @category Metrics\n */\nexport interface ComputedFrameMetrics {\n avgFps: number;\n lensFrameProcessingTimeMsAvg: number;\n lensFrameProcessingTimeMsStd: number;\n}\n\n/**\n * Represents an ongoing measurement of rendering metrics.\n *\n * An instance of this class is obtained by calling {@link LensPerformanceMetrics.beginMeasurement}. Then it may be\n * used to record rendering performance metrics, reset measurement, or end the measurement.\n *\n * @category Rendering\n * @category Metrics\n */\nexport class LensPerformanceMeasurement {\n private state: FrameMetricsState = { ...defaultFrameMetricsState };\n private priorFrameCompletedTime?: number;\n\n constructor(private instances: Set<LensPerformanceMeasurement>) {\n this.instances.add(this);\n }\n\n /** @internal */\n update(processingTimeMs: number): void {\n this.computeRunningStats(processingTimeMs);\n }\n\n /**\n * Return a {@link ComputedFrameMetrics} object, containing lens performance metrics.\n *\n * This method may be called multiple times, each time reporting values computed since the time when this instance\n * was created.\n */\n measure(): ComputedFrameMetrics {\n return {\n avgFps: this.state.avgFps,\n lensFrameProcessingTimeMsAvg: this.state.procFrameMean,\n lensFrameProcessingTimeMsStd: Math.sqrt(this.state.procFrameD2 / this.state.procFrameCount),\n };\n }\n\n /**\n * Reset the measured perforamance statistics (averages, std deviations). This is equivalent to using\n * {@link LensPerformanceMetrics.beginMeasurement} to create a new LensPerformanceMeasurement instance, but may be\n * more convenient.\n */\n reset(): void {\n this.state = { ...defaultFrameMetricsState };\n }\n\n /**\n * Stop measuring performance statistics.\n *\n * This instance will not be garbage collected until this method is called. Therefore it is important to call this\n * method at the appropriate time to avoid leaking memory -- particularly if your application creates many\n * LensPerformanceMeasurement instances.\n */\n end(): void {\n this.instances.delete(this);\n }\n /**\n * In order to calculate the mean, variance, and standard deviation for the processing times\n * we are using Welford's online algorithm.\n * https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Welford's_online_algorithm\n *\n * @param processingTimeMs Processing time that is returned from registered callback\n */\n private computeRunningStats(processingTimeMs: number) {\n // calculate mean and delta squared for variance and standard deviation\n const delta = processingTimeMs - this.state.procFrameMean;\n this.state.procFrameCount += 1;\n this.state.procFrameMean += delta / this.state.procFrameCount;\n\n const delta2 = processingTimeMs - this.state.procFrameMean;\n this.state.procFrameD2 += delta * delta2;\n\n // Determine average fps\n if (this.priorFrameCompletedTime === undefined) {\n this.priorFrameCompletedTime = performance.now();\n } else {\n const frameDurationSec = (performance.now() - this.priorFrameCompletedTime) / 1000;\n if (frameDurationSec < frameDurationThreshold) {\n this.state.avgFps = (this.state.avgFps + 1 / frameDurationSec) / 2;\n }\n this.priorFrameCompletedTime = performance.now();\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { LensCoreModule } from "../lens-core-module";
|
|
2
|
+
import { LensPerformanceMeasurement } from "./LensPerformanceMeasurement";
|
|
3
|
+
/**
|
|
4
|
+
* Use to measure lens rendering performance.
|
|
5
|
+
*
|
|
6
|
+
* The {@link LensPerformanceMetrics.beginMeasurement} method is used to start measuring rendering performance. After
|
|
7
|
+
* a measurement has begun, performance metrics can be read using {@link LensPerformanceMeasurement}.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* const measurement = cameraKitSession.metrics.beginMeasurement()
|
|
12
|
+
* // some time later
|
|
13
|
+
* console.log(measurement.measure())
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @category Rendering
|
|
17
|
+
* @category Metrics
|
|
18
|
+
*/
|
|
19
|
+
export declare class LensPerformanceMetrics {
|
|
20
|
+
private lensCore;
|
|
21
|
+
private readonly measurementInstances;
|
|
22
|
+
/** @internal */
|
|
23
|
+
constructor(lensCore: LensCoreModule);
|
|
24
|
+
/**
|
|
25
|
+
* Begin a measurement window, during which time rendering metrics will be gathered.
|
|
26
|
+
*
|
|
27
|
+
* @returns A {@link LensPerformanceMeasurement} representing an ongoing measurement of aggregated rendering
|
|
28
|
+
* metrics, from which specific metrics can be obtained.
|
|
29
|
+
*/
|
|
30
|
+
beginMeasurement(): LensPerformanceMeasurement;
|
|
31
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { errorLoggingDecorator } from "../logger/errorLoggingDecorator";
|
|
3
|
+
import { getLogger } from "../logger/logger";
|
|
4
|
+
import { LensPerformanceMeasurement } from "./LensPerformanceMeasurement";
|
|
5
|
+
const logger = getLogger("RenderingMetrics");
|
|
6
|
+
const log = errorLoggingDecorator(logger);
|
|
7
|
+
/**
|
|
8
|
+
* Use to measure lens rendering performance.
|
|
9
|
+
*
|
|
10
|
+
* The {@link LensPerformanceMetrics.beginMeasurement} method is used to start measuring rendering performance. After
|
|
11
|
+
* a measurement has begun, performance metrics can be read using {@link LensPerformanceMeasurement}.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const measurement = cameraKitSession.metrics.beginMeasurement()
|
|
16
|
+
* // some time later
|
|
17
|
+
* console.log(measurement.measure())
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @category Rendering
|
|
21
|
+
* @category Metrics
|
|
22
|
+
*/
|
|
23
|
+
export class LensPerformanceMetrics {
|
|
24
|
+
/** @internal */
|
|
25
|
+
constructor(lensCore) {
|
|
26
|
+
this.lensCore = lensCore;
|
|
27
|
+
this.measurementInstances = new Set();
|
|
28
|
+
this.lensCore.setOnFrameProcessedCallback({
|
|
29
|
+
onFrameProcessed: ({ processingTimeMs }) => {
|
|
30
|
+
try {
|
|
31
|
+
for (const measurement of this.measurementInstances.values()) {
|
|
32
|
+
measurement.update(processingTimeMs);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
logger.error(error);
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
onFailure: (error) => logger.error(`Failed registering setOnFrameProcessedCallback with error: ${error.message}`),
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Begin a measurement window, during which time rendering metrics will be gathered.
|
|
44
|
+
*
|
|
45
|
+
* @returns A {@link LensPerformanceMeasurement} representing an ongoing measurement of aggregated rendering
|
|
46
|
+
* metrics, from which specific metrics can be obtained.
|
|
47
|
+
*/
|
|
48
|
+
beginMeasurement() {
|
|
49
|
+
return new LensPerformanceMeasurement(this.measurementInstances);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
__decorate([
|
|
53
|
+
log,
|
|
54
|
+
__metadata("design:type", Function),
|
|
55
|
+
__metadata("design:paramtypes", []),
|
|
56
|
+
__metadata("design:returntype", LensPerformanceMeasurement)
|
|
57
|
+
], LensPerformanceMetrics.prototype, "beginMeasurement", null);
|
|
58
|
+
//# sourceMappingURL=LensPerformanceMetrics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LensPerformanceMetrics.js","sourceRoot":"","sources":["../../src/session/LensPerformanceMetrics.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAExE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAE1E,MAAM,MAAM,GAAG,SAAS,CAAC,kBAAkB,CAAC,CAAC;AAC7C,MAAM,GAAG,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;AAE1C;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,sBAAsB;IAG/B,gBAAgB;IAChB,YAAoB,QAAwB;QAAxB,aAAQ,GAAR,QAAQ,CAAgB;QACxC,IAAI,CAAC,oBAAoB,GAAG,IAAI,GAAG,EAAE,CAAC;QACtC,IAAI,CAAC,QAAQ,CAAC,2BAA2B,CAAC;YACtC,gBAAgB,EAAE,CAAC,EAAE,gBAAgB,EAAE,EAAE,EAAE;gBACvC,IAAI;oBACA,KAAK,MAAM,WAAW,IAAI,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE,EAAE;wBAC1D,WAAW,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;qBACxC;iBACJ;gBAAC,OAAO,KAAK,EAAE;oBACZ,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;iBACvB;YACL,CAAC;YACD,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CACjB,MAAM,CAAC,KAAK,CAAC,8DAA8D,KAAK,CAAC,OAAO,EAAE,CAAC;SAClG,CAAC,CAAC;IACP,CAAC;IAED;;;;;OAKG;IAEH,gBAAgB;QACZ,OAAO,IAAI,0BAA0B,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;IACrE,CAAC;CACJ;AAJG;IAAC,GAAG;;;oCACgB,0BAA0B;8DAE7C","sourcesContent":["import { errorLoggingDecorator } from \"../logger/errorLoggingDecorator\";\nimport { LensCoreModule } from \"../lens-core-module\";\nimport { getLogger } from \"../logger/logger\";\nimport { LensPerformanceMeasurement } from \"./LensPerformanceMeasurement\";\n\nconst logger = getLogger(\"RenderingMetrics\");\nconst log = errorLoggingDecorator(logger);\n\n/**\n * Use to measure lens rendering performance.\n *\n * The {@link LensPerformanceMetrics.beginMeasurement} method is used to start measuring rendering performance. After\n * a measurement has begun, performance metrics can be read using {@link LensPerformanceMeasurement}.\n *\n * @example\n * ```ts\n * const measurement = cameraKitSession.metrics.beginMeasurement()\n * // some time later\n * console.log(measurement.measure())\n * ```\n *\n * @category Rendering\n * @category Metrics\n */\nexport class LensPerformanceMetrics {\n private readonly measurementInstances: Set<LensPerformanceMeasurement>;\n\n /** @internal */\n constructor(private lensCore: LensCoreModule) {\n this.measurementInstances = new Set();\n this.lensCore.setOnFrameProcessedCallback({\n onFrameProcessed: ({ processingTimeMs }) => {\n try {\n for (const measurement of this.measurementInstances.values()) {\n measurement.update(processingTimeMs);\n }\n } catch (error) {\n logger.error(error);\n }\n },\n onFailure: (error) =>\n logger.error(`Failed registering setOnFrameProcessedCallback with error: ${error.message}`),\n });\n }\n\n /**\n * Begin a measurement window, during which time rendering metrics will be gathered.\n *\n * @returns A {@link LensPerformanceMeasurement} representing an ongoing measurement of aggregated rendering\n * metrics, from which specific metrics can be obtained.\n */\n @log\n beginMeasurement(): LensPerformanceMeasurement {\n return new LensPerformanceMeasurement(this.measurementInstances);\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Keyboard } from "./LensKeyboard";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/session/index.ts"],"names":[],"mappings":"","sourcesContent":["export { Keyboard } from \"./LensKeyboard\";\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { StateMachine } from "@snap/state-management";
|
|
2
|
+
import { Lens } from "../lens/Lens";
|
|
3
|
+
import { LensRepository } from "../lens/LensRepository";
|
|
4
|
+
import { LensCoreModule } from "../lens-core-module";
|
|
5
|
+
import { IndexedDBPersistence } from "../persistence/IndexedDBPersistence";
|
|
6
|
+
import { LensLaunchParams } from "../lens/LensLaunchParams";
|
|
7
|
+
import { LensAssetRepository } from "../lens/assets/LensAssetRepository";
|
|
8
|
+
import { LegalError, LensContentValidationError, LensError } from "../namedErrors";
|
|
9
|
+
declare const createLensState: () => StateMachine<import("@snap/state-management").Action<"applyLens", {
|
|
10
|
+
lens: Lens;
|
|
11
|
+
launchParams?: LensLaunchParams | undefined;
|
|
12
|
+
}> | import("@snap/state-management").Action<"downloadComplete", Lens> | import("@snap/state-management").Action<"turnedOn", Lens> | import("@snap/state-management").Action<"resourcesLoaded", Lens> | import("@snap/state-management").Action<"firstFrameProcessed", Lens> | import("@snap/state-management").Action<"applyLensComplete", Lens> | import("@snap/state-management").Action<"applyLensFailed", {
|
|
13
|
+
error: LensErrors;
|
|
14
|
+
lens: Lens;
|
|
15
|
+
}> | import("@snap/state-management").Action<"removeLens", undefined> | import("@snap/state-management").Action<"turnedOff", Lens> | import("@snap/state-management").Action<"removeLensComplete", undefined> | import("@snap/state-management").Action<"removeLensFailed", Error>, import("@snap/state-management").State<"noLensApplied", undefined> | import("@snap/state-management").State<"applyingLens", Lens> | import("@snap/state-management").State<"lensApplied", Lens>>;
|
|
16
|
+
export declare type LensErrors = LegalError | LensContentValidationError | LensError;
|
|
17
|
+
export declare type LensState = ReturnType<typeof createLensState>;
|
|
18
|
+
export declare const lensStateFactory: {
|
|
19
|
+
(args_0: LensCoreModule, args_1: LensRepository, args_2: LensAssetRepository, args_3: IndexedDBPersistence<ArrayBuffer>, args_4: StateMachine<import("@snap/state-management").Action<"requestLegalPrompt", undefined> | import("@snap/state-management").Action<"accept", string> | import("@snap/state-management").Action<"reject", string>, import("@snap/state-management").State<"unknown", undefined> | import("@snap/state-management").State<"accepted", undefined> | import("@snap/state-management").State<"rejected", undefined>>): StateMachine<import("@snap/state-management").Action<"applyLens", {
|
|
20
|
+
lens: Lens;
|
|
21
|
+
launchParams?: LensLaunchParams | undefined;
|
|
22
|
+
}> | import("@snap/state-management").Action<"downloadComplete", Lens> | import("@snap/state-management").Action<"turnedOn", Lens> | import("@snap/state-management").Action<"resourcesLoaded", Lens> | import("@snap/state-management").Action<"firstFrameProcessed", Lens> | import("@snap/state-management").Action<"applyLensComplete", Lens> | import("@snap/state-management").Action<"applyLensFailed", {
|
|
23
|
+
error: LensErrors;
|
|
24
|
+
lens: Lens;
|
|
25
|
+
}> | import("@snap/state-management").Action<"removeLens", undefined> | import("@snap/state-management").Action<"turnedOff", Lens> | import("@snap/state-management").Action<"removeLensComplete", undefined> | import("@snap/state-management").Action<"removeLensFailed", Error>, import("@snap/state-management").State<"noLensApplied", undefined> | import("@snap/state-management").State<"applyingLens", Lens> | import("@snap/state-management").State<"lensApplied", Lens>>;
|
|
26
|
+
token: "lensState";
|
|
27
|
+
dependencies: readonly ["lensCore", "LensRepository", "lensAssetRepository", "lensPersistenceStore", "legalState"];
|
|
28
|
+
};
|
|
29
|
+
export {};
|