@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 @@
|
|
|
1
|
+
{"version":3,"file":"bootstrapCameraKit.js","sourceRoot":"","sources":["../src/bootstrapCameraKit.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAa,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAC/D,OAAO,EAAE,6BAA6B,EAAE,MAAM,6CAA6C,CAAC;AAC5F,OAAO,EAAE,iCAAiC,EAAE,MAAM,0CAA0C,CAAC;AAC7F,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAE,mCAAmC,EAAE,MAAM,gDAAgD,CAAC;AACrG,OAAO,EAAmC,mCAAmC,EAAE,MAAM,iBAAiB,CAAC;AAEvG,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,gCAAgC,EAAE,MAAM,sCAAsC,CAAC;AACxF,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM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C,EAAE,KAAK,CAAC,CAAC;aACpE;YACD,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACpB,MAAM,KAAK,CAAC;SACf;IACL,CAAC;CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,UAAU,eAAe;IAC3B,OAAO,IAAI,gBAAgB,CAAC,EAAE,CAAC,CAAC;AACpC,CAAC","sourcesContent":["import { lensRepositoryFactory } from \"./lens/LensRepository\";\nimport { Container } from \"./dependency-injection/Container\";\nimport { CameraKit, cameraKitFactory } from \"./CameraKit\";\nimport { lensCoreFactory } from \"./lens-core-module/loader/lensCoreFactory\";\nimport { Injectable } from \"./dependency-injection/Injectable\";\nimport { remoteMediaAssetLoaderFactory } from \"./lens/assets/remoteMediaAssetLoaderFactory\";\nimport { deviceDependentAssetLoaderFactory } from \"./lens/assets/deviceDependentAssetLoader\";\nimport { staticAssetLoaderFactory } from \"./lens/assets/staticAssetLoader\";\nimport { defaultFetchHandlerFactory } from \"./handlers/defaultFetchHandler\";\nimport { cameraKitServiceFetchHandlerFactory } from \"./handlers/cameraKitServiceFetchHandlerFactory\";\nimport { CameraKitBootstrapConfiguration, createCameraKitConfigurationFactory } from \"./configuration\";\nimport { PublicServices } from \"./dependency-injection/RootServices\";\nimport { PartialContainer } from \"./dependency-injection/PartialContainer\";\nimport { metricsHandlerFactory } from \"./metrics/metricsHandler\";\nimport { operationalMetricReporterFactory } from \"./metrics/operationalMetricsReporter\";\nimport { lensSourcesFactory } from \"./extensions/LensSources\";\nimport { uriHandlersFactory } from \"./extensions/UriHandlers\";\nimport { assert } from \"./common/assertions\";\nimport { isSafeString } from \"./common/typeguards\";\nimport { metricsEventTargetFactory } from \"./metrics/metricsEventTarget\";\nimport { reportGloballyScopedMetrics } from \"./metrics/reporters/reporters\";\nimport { getLogger } from \"./logger/logger\";\nimport { logEntriesFactory } from \"./logger/logEntries\";\nimport { assertPlatformSupported } from \"./assertPlatformSupported\";\nimport { lensPersistenceStoreFactory } from \"./lens/LensPersistenceStore\";\nimport { remoteConfigurationFactory } from \"./remote-configuration/remoteConfiguration\";\nimport { lensAssetRepositoryFactory } from \"./lens/assets/LensAssetRepository\";\nimport { legalStateFactory } from \"./legal/legalState\";\nimport { legalPromptFactory } from \"./legal/legalPrompt\";\nimport { bootstrapError, ConfigurationError, configurationError, PlatformNotSupportedError } from \"./namedErrors\";\nimport { businessEventsReporterFactory } from \"./metrics/businessEventsReporter\";\nimport { reportGlobalException } from \"./metrics/reporters/reportGlobalException\";\nimport { registerLogEntriesSubscriber } from \"./logger/registerLogEntriesSubscriber\";\n\nconst logger = getLogger(\"bootstrapCameraKit\");\n\n// The following errors are not wrapped with BootstrapError and bubble up as is.\nconst nonWrappableErrors: [ConfigurationError[\"name\"], PlatformNotSupportedError[\"name\"]] = [\n \"ConfigurationError\",\n \"PlatformNotSupportedError\",\n];\n\n/**\n * Returns true if given error has to be wrapped with BoostrapError.\n */\nfunction shouldWrapError(error: unknown): boolean {\n if (error instanceof Error) {\n return !nonWrappableErrors.some((name) => error.name === name);\n }\n return true;\n}\n\n/**\n * For more advanced use-cases, this DI Container holds services for which a custom implementation may be provided by\n * the application.\n *\n * @category Bootstrapping and Configuration\n */\nexport type PublicContainer = Container<PublicServices>;\n\n/**\n * Bootstrap CameraKit. This will download the WebAssembly code which powers CameraKit's rendering engine, and return\n * an instance of {@link CameraKit}.\n *\n * CameraKit must be provided with some configuration (the application's API token), and there are some additional\n * configurations which are optional.\n *\n * Descriptions of the available configurations can be found in the documentation for\n * {@link CameraKitBootstrapConfiguration}\n *\n * ---\n *\n * There is also a second, more advanced way to modify CameraKit to provide greater flexibility to support less common\n * use cases.\n *\n * This requires some knowledge of CameraKit's dependency injection system, and allows applications to provide their\n * own custom implementations of certain CameraKit components. This functionality will only be needed by applications\n * with very specific, more advanced requirements.\n *\n * @example\n * ```ts\n * // The most common way to bootstrap:\n * const cameraKit = await bootstrapCameraKit({ apiToken: myApiToken })\n *\n * // For special advanced use-cases, it is possible to provide custom implementations for certain CameraKit components.\n * const cameraKit = await bootstrapCameraKit(config, (container) => {\n * return container.provides(myCustomRemoteMediaAssetLoaderFactory)\n * })\n * ```\n *\n * @param configuration Configure CameraKit with e.g. credentials, global resource endpoints, etc.\n * @param provide Optional function that can make modifications to CameraKit's root DI container.\n * @returns A {@link CameraKit} instance, which is the entry point to CameraKit's API.\n *\n * @throws\n * - {@link ConfigurationError} when provided configuration object is invalid\n * - {@link PlatformNotSupportedError} when current platform is not supported by CameraKit\n * - {@link BootstrapError} when a failure occurs while initializing CameraKit and downloading the render engine\n * WebAssembly binary.\n *\n * @category Bootstrapping and Configuration\n */\nexport async function bootstrapCameraKit(\n configuration: CameraKitBootstrapConfiguration,\n provide?: (c: PublicContainer) => PublicContainer\n): Promise<CameraKit> {\n try {\n const startTimeMs = performance.now();\n\n assert(isSafeString(configuration.apiToken), configurationError(\"Unsafe apiToken\"));\n\n const configurationFactory = createCameraKitConfigurationFactory(configuration);\n\n // Public container holds services which applications can overwrite with their own implementations.\n const defaultPublicContainer = Container.provides(configurationFactory)\n .provides(defaultFetchHandlerFactory)\n .provides(remoteMediaAssetLoaderFactory)\n .provides(lensSourcesFactory)\n .provides(uriHandlersFactory);\n\n const publicContainer = provide ? provide(defaultPublicContainer) : defaultPublicContainer;\n\n // Now that the client's provide() function has completed and the configuration override is ready,\n // we create another container to initialize the logger. This ensures that logging is available\n // as we continue bootstrapping. We don't initialize the logger as part of the defaultPublicContainer\n // because we don't want applications to provide their own logger implementations,\n // and we're not interested in errors thrown by their provide() function.\n // Below is the minimum required container to report errors to Blizzard.\n const telemetryContainer = Container.provides(publicContainer)\n .provides(logEntriesFactory)\n .provides(cameraKitServiceFetchHandlerFactory)\n .provides(metricsEventTargetFactory)\n .provides(metricsHandlerFactory)\n .provides(operationalMetricReporterFactory)\n .provides(reportGlobalException)\n .run(businessEventsReporterFactory)\n .run(registerLogEntriesSubscriber);\n\n // Run the exception logger so that it can subscribe to log events -- we can't use `Container.run()` because\n // reportGlobalException is also used as a dependency by other Services (and run does not provide Services,\n // it just runs them once).\n telemetryContainer.get(reportGlobalException.token);\n\n // At this point, logger is configured to report to console and Blizzard.\n\n assertPlatformSupported();\n\n // LensCore is a foundational component which must be created asynchronously.\n // But it's annoying for every consumer of LensCore to have to wait on Promise<LensCore>\n // (which means they become async themselves). So we'll create a DI container which provides Promise<LensCore>,\n // wait for that promise once here, then create a new DI container that just contains LensCore.\n const lensCore = await telemetryContainer.provides(lensCoreFactory).get(lensCoreFactory.token);\n\n const container = telemetryContainer\n .provides(Injectable(lensCoreFactory.token, () => lensCore))\n .provides(remoteConfigurationFactory)\n .provides(lensPersistenceStoreFactory)\n .provides(deviceDependentAssetLoaderFactory)\n .provides(staticAssetLoaderFactory)\n .provides(lensAssetRepositoryFactory)\n .provides(lensRepositoryFactory)\n .provides(legalPromptFactory)\n .provides(legalStateFactory)\n .provides(cameraKitFactory)\n // We'll run a PartialContainer containing reporters for globally-scoped metrics. Running this container\n // allows each metric reporter to initialize itself (e.g. by adding event listeners to detect when certain\n // actions occur). This PartialContainer also includes the service which listens to locally-reported metrics\n // and sends them to our backend.\n .run(reportGloballyScopedMetrics);\n\n const cameraKit = container.get(cameraKitFactory.token);\n\n const bootstrapTimeMs = performance.now() - startTimeMs;\n const reporter = container.get(operationalMetricReporterFactory.token);\n reporter.timer(\"bootstrap_time\", bootstrapTimeMs);\n\n return cameraKit;\n } catch (error) {\n if (shouldWrapError(error)) {\n error = bootstrapError(\"Failed to bootstrap Camera Kit.\", error);\n }\n logger.error(error);\n throw error;\n }\n}\n\n/**\n * Extensions offer a way to provide custom implementations of certain parts of the CameraKit SDK.\n *\n * This enables more advanced use-cases, in which the default behavior of the SDK is substantially altered. For example,\n * replacing the default implementation that loads remote lens assets with a custom implementation that returns\n * different assets based on some business logic within the application.\n *\n * An extension is implemented as a [PartialContainer] – a collection of factory functions, each with its own\n * dependencies, which each provide some \"Service.\" A Service can be of any type, and the CameraKit SDK defines its\n * own Services, some of which can be overridden by providing a custom implementation of the type via an extension.\n *\n * Here's an example of how extensions might be used:\n * ```ts\n * import { bootstrapCameraKit, createExtension, remoteMediaAssetLoaderFactory } from '@snap/camera-kit'\n *\n * const myCustomRemoteAssetLoader = Injectable(\n * remoteMediaAssetLoaderFactory.token,\n * [remoteMediaAssetLoaderFactory.token] as const,\n * (defaultLoader: AssetLoader): AssetLoader => {\n * return async (asset, lens) => {\n * if (lens?.id === MY_SPECIAL_LENS) {\n * return (await fetch('my/asset.glb')).arrayBuffer()\n * }\n * return defaultLoader(asset, lens)\n * }\n * },\n * )\n *\n * const myExtension = createExtension().provides(myCustomeRemoteAssetLoader)\n * const cameraKit = bootstrapCameraKit(config, container => container.provides(myExtension))\n * ```\n *\n * This also enables greater modularity – the person/team creating the extension can do so in their own package, which\n * could be shared by many applications that all require the same functionality.\n *\n * @returns A {@link PartialContainer} which can be used to create a collection of Services, and can later be provided\n * to CameraKit's DI container during {@link bootstrapCameraKit}.\n *\n * @category Bootstrapping and Configuration\n */\nexport function createExtension(): PartialContainer {\n return new PartialContainer({});\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function loadScript(): Promise<void>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function loadScript() {
|
|
2
|
+
global.createLensesModule = jest.fn().mockImplementation((module) => {
|
|
3
|
+
return new Promise((resolve) => {
|
|
4
|
+
module.getCoreVersion = () => 0;
|
|
5
|
+
module.instantiateWasm({}, () => resolve(module));
|
|
6
|
+
});
|
|
7
|
+
});
|
|
8
|
+
return Promise.resolve();
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=loadScript.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadScript.js","sourceRoot":"","sources":["../../../src/common/__mocks__/loadScript.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,UAAU;IACtB,MAAM,CAAC,kBAAkB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,kBAAkB,CAAC,CAAC,MAAkB,EAAE,EAAE;QAC5E,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC3B,MAAM,CAAC,cAAc,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC;YAChC,MAAM,CAAC,eAAgB,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;QACvD,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;AAC7B,CAAC","sourcesContent":["import { InitialEmscriptenModule, LensCoreModule } from \"../../lens-core-module/generated-types\";\n\ntype MockModule = InitialEmscriptenModule & Partial<LensCoreModule>;\n\nexport function loadScript(): Promise<void> {\n global.createLensesModule = jest.fn().mockImplementation((module: MockModule) => {\n return new Promise((resolve) => {\n module.getCoreVersion = () => 0;\n module.instantiateWasm!({}, () => resolve(module));\n });\n });\n return Promise.resolve();\n}\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Assert a particular code path is unreachable, e.g. to perform a compile-time exhaustiveness check.
|
|
3
|
+
*
|
|
4
|
+
* Ex:
|
|
5
|
+
* ```ts
|
|
6
|
+
* interface A { type: 'a' }
|
|
7
|
+
* interface B { type: 'b' }
|
|
8
|
+
* type TaggedUnion = A | B
|
|
9
|
+
*
|
|
10
|
+
* function exhaustiveSwitch(value: TaggedUnion) {
|
|
11
|
+
* switch (value.type) {
|
|
12
|
+
* case 'a': // do something with A
|
|
13
|
+
* case 'b': // do something with B
|
|
14
|
+
* // this will fail to compile if we add another type to TaggedUnion and forget to add a corresponding case
|
|
15
|
+
* // to the switch statement.
|
|
16
|
+
* default: assertUnreachable(value)
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function assertUnreachable(_: never): never;
|
|
22
|
+
/**
|
|
23
|
+
* Assert that a condition is true. Otherwise, throws an error.
|
|
24
|
+
* @param condition Condition to test.
|
|
25
|
+
* @param error Optional error message or error instance to throw.
|
|
26
|
+
*/
|
|
27
|
+
export declare function assert(condition: boolean, error?: string | Error): asserts condition;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Assert a particular code path is unreachable, e.g. to perform a compile-time exhaustiveness check.
|
|
3
|
+
*
|
|
4
|
+
* Ex:
|
|
5
|
+
* ```ts
|
|
6
|
+
* interface A { type: 'a' }
|
|
7
|
+
* interface B { type: 'b' }
|
|
8
|
+
* type TaggedUnion = A | B
|
|
9
|
+
*
|
|
10
|
+
* function exhaustiveSwitch(value: TaggedUnion) {
|
|
11
|
+
* switch (value.type) {
|
|
12
|
+
* case 'a': // do something with A
|
|
13
|
+
* case 'b': // do something with B
|
|
14
|
+
* // this will fail to compile if we add another type to TaggedUnion and forget to add a corresponding case
|
|
15
|
+
* // to the switch statement.
|
|
16
|
+
* default: assertUnreachable(value)
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export function assertUnreachable(_) {
|
|
22
|
+
throw new Error("Reached unreachable code at runtime.");
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Assert that a condition is true. Otherwise, throws an error.
|
|
26
|
+
* @param condition Condition to test.
|
|
27
|
+
* @param error Optional error message or error instance to throw.
|
|
28
|
+
*/
|
|
29
|
+
export function assert(condition, error = "Assertion failed") {
|
|
30
|
+
if (!condition) {
|
|
31
|
+
if (error instanceof Error) {
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
throw new Error(error);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=assertions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assertions.js","sourceRoot":"","sources":["../../src/common/assertions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,iBAAiB,CAAC,CAAQ;IACtC,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;AAC5D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,MAAM,CAAC,SAAkB,EAAE,QAAwB,kBAAkB;IACjF,IAAI,CAAC,SAAS,EAAE;QACZ,IAAI,KAAK,YAAY,KAAK,EAAE;YACxB,MAAM,KAAK,CAAC;SACf;aAAM;YACH,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;SAC1B;KACJ;AACL,CAAC","sourcesContent":["/**\n * Assert a particular code path is unreachable, e.g. to perform a compile-time exhaustiveness check.\n *\n * Ex:\n * ```ts\n * interface A { type: 'a' }\n * interface B { type: 'b' }\n * type TaggedUnion = A | B\n *\n * function exhaustiveSwitch(value: TaggedUnion) {\n * switch (value.type) {\n * case 'a': // do something with A\n * case 'b': // do something with B\n * // this will fail to compile if we add another type to TaggedUnion and forget to add a corresponding case\n * // to the switch statement.\n * default: assertUnreachable(value)\n * }\n * }\n * ```\n */\nexport function assertUnreachable(_: never): never {\n throw new Error(\"Reached unreachable code at runtime.\");\n}\n\n/**\n * Assert that a condition is true. Otherwise, throws an error.\n * @param condition Condition to test.\n * @param error Optional error message or error instance to throw.\n */\nexport function assert(condition: boolean, error: string | Error = \"Assertion failed\"): asserts condition {\n if (!condition) {\n if (error instanceof Error) {\n throw error;\n } else {\n throw new Error(error);\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
declare type BrandArray = Array<{
|
|
2
|
+
brand: string;
|
|
3
|
+
version: string;
|
|
4
|
+
}>;
|
|
5
|
+
interface NavigatorUAData {
|
|
6
|
+
brands: BrandArray;
|
|
7
|
+
mobile: boolean;
|
|
8
|
+
platform: string;
|
|
9
|
+
}
|
|
10
|
+
declare global {
|
|
11
|
+
interface Navigator {
|
|
12
|
+
userAgentData?: NavigatorUAData;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/** @internal */
|
|
16
|
+
export interface CameraKitUserAgent {
|
|
17
|
+
osType: string;
|
|
18
|
+
osVersion: string;
|
|
19
|
+
locale: string;
|
|
20
|
+
sdkShortVersion: string;
|
|
21
|
+
sdkLongVersion: string;
|
|
22
|
+
flavor: "release" | "debug";
|
|
23
|
+
lensCoreVersion: string;
|
|
24
|
+
deviceModel: string;
|
|
25
|
+
browser: {
|
|
26
|
+
brand: string;
|
|
27
|
+
version: string;
|
|
28
|
+
};
|
|
29
|
+
origin: string;
|
|
30
|
+
userAgent: string;
|
|
31
|
+
}
|
|
32
|
+
/** @internal */
|
|
33
|
+
export declare const cameraKitUserAgent: CameraKitUserAgent;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import environment from "../environment.json";
|
|
2
|
+
import lensCoreWasm from "../lensCoreWasmVersions.json";
|
|
3
|
+
import { locale } from "./locale";
|
|
4
|
+
/**
|
|
5
|
+
* Parse the platform (i.e. OS) version.
|
|
6
|
+
*
|
|
7
|
+
* From limited testing, this seems to often produce incorrect results – the userAgent string does not typically include
|
|
8
|
+
* the actual OS version.
|
|
9
|
+
*
|
|
10
|
+
* Better results could be obtained from [NavigatorUAData.getHighEntropyValues]
|
|
11
|
+
* (https://developer.mozilla.org/en-US/docs/Web/API/NavigatorUAData/getHighEntropyValues), but this presents two
|
|
12
|
+
* problems: 1) it's currently only supported on Chrome and 2) browsers may prompt the user for permission to share
|
|
13
|
+
* this information.
|
|
14
|
+
*
|
|
15
|
+
* So, at least for now, we'll be satisfied with the incorrect version number.
|
|
16
|
+
*/
|
|
17
|
+
function parsePlatformVersion(userAgent) {
|
|
18
|
+
// possible platform version values inside of user agent string
|
|
19
|
+
// " 11;"
|
|
20
|
+
// " 10_15_7)"
|
|
21
|
+
// " 13_5_1 "
|
|
22
|
+
// " 10.0;"
|
|
23
|
+
// " 15_1 "
|
|
24
|
+
const versionMatch = userAgent.match(/\s([\d][\d_.]*[\d])(;|\)|\s)/);
|
|
25
|
+
if (versionMatch != null) {
|
|
26
|
+
return versionMatch[1].replace(/_/g, ".");
|
|
27
|
+
}
|
|
28
|
+
return "";
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* In the future, we may invest in more robust device-detection (e.g. a UA string database), but for now this will give
|
|
32
|
+
* us some sense of device usage.
|
|
33
|
+
*/
|
|
34
|
+
function parseDeviceModel(userAgent) {
|
|
35
|
+
// from user agent like "(Linux; Android 11; Pixel 2)" extact "Pixel 2"
|
|
36
|
+
const userAgentWithModel = userAgent.match(/;[^;]+?;([^\)]+?)\)/);
|
|
37
|
+
if (userAgentWithModel) {
|
|
38
|
+
return userAgentWithModel[1].trim();
|
|
39
|
+
}
|
|
40
|
+
// from user agent like "... (iPad; CPU OS 15_1 like Mac OS X) ..." extract "IPad"
|
|
41
|
+
const userAgentWithModel2 = userAgent.match(/\(([^;]+);/);
|
|
42
|
+
if (userAgentWithModel2) {
|
|
43
|
+
return userAgentWithModel2[1].trim();
|
|
44
|
+
}
|
|
45
|
+
return "unknown";
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Some browsers (e.g. Safari) do not support the `Navigator.userAgentData` API. We'll attempt a sort of polyfill by
|
|
49
|
+
* parsing the data found in [NavigatorUAData](https://developer.mozilla.org/en-US/docs/Web/API/NavigatorUAData) from
|
|
50
|
+
* the raw user agent string.
|
|
51
|
+
*/
|
|
52
|
+
function parseUserAgentData(userAgent) {
|
|
53
|
+
let brand;
|
|
54
|
+
// Parse UA string for Chromium-based browsers (e.g. Chrome, Edge)
|
|
55
|
+
if (/Chrome/.test(userAgent)) {
|
|
56
|
+
const versionMatch = userAgent.match(/Chrome\/([\d.]+)/);
|
|
57
|
+
brand = {
|
|
58
|
+
brand: "Chrome",
|
|
59
|
+
version: versionMatch !== null ? versionMatch[1] : "unknown",
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
// Parse UA string for Safari (very important for this to only be done if Chrome is not found – Chrome userAgent
|
|
63
|
+
// strings will contain "Safari")
|
|
64
|
+
else if (/Safari/.test(userAgent)) {
|
|
65
|
+
let versionMatch = userAgent.match(/Version\/([\d.]+)/);
|
|
66
|
+
if (versionMatch === null)
|
|
67
|
+
versionMatch = userAgent.match(/Safari\/([\d.]+)/);
|
|
68
|
+
brand = {
|
|
69
|
+
brand: "Safari",
|
|
70
|
+
version: versionMatch !== null ? versionMatch[1] : "unknown",
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
// Parse UA for unknown browser.
|
|
74
|
+
// TODO: will be changed, default value support should be added on a COF server side.
|
|
75
|
+
else {
|
|
76
|
+
brand = {
|
|
77
|
+
brand: "Firefox",
|
|
78
|
+
version: "0",
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
// We're not using `mobile` for anything, and we have no consistent way to determine this from the UA string.
|
|
82
|
+
// We'll set it to false, but this should not be used – instead, we'll need to rely on more sophisticated methods
|
|
83
|
+
// (e.g. a userAgent database) to determine actual device.
|
|
84
|
+
const mobile = false;
|
|
85
|
+
const platform = parsePlaftformName(userAgent);
|
|
86
|
+
return {
|
|
87
|
+
brands: [brand],
|
|
88
|
+
mobile,
|
|
89
|
+
platform,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function normalizeBrands(brands) {
|
|
93
|
+
const knownBrands = new Map([
|
|
94
|
+
["Chrome", "Chrome"],
|
|
95
|
+
["Chromium", "Chrome"],
|
|
96
|
+
["Firefox", "Firefox"],
|
|
97
|
+
["Microsoft Edge", "Chrome"],
|
|
98
|
+
["Safari", "Safari"],
|
|
99
|
+
]);
|
|
100
|
+
const normalizedBrands = brands
|
|
101
|
+
.filter(({ brand }) => knownBrands.has(brand))
|
|
102
|
+
.map((brand) => {
|
|
103
|
+
return {
|
|
104
|
+
// Safety: we've filtered out brands which do not appear as keys in `knownBrands`, so this cannot return
|
|
105
|
+
// undefined.
|
|
106
|
+
brand: knownBrands.get(brand.brand),
|
|
107
|
+
version: brand.version,
|
|
108
|
+
};
|
|
109
|
+
});
|
|
110
|
+
// TODO: default "unknown" value should be added on COF server side. For now we'll use Firefox.
|
|
111
|
+
if (normalizedBrands.length === 0)
|
|
112
|
+
return [{ brand: "Firefox", version: "0" }];
|
|
113
|
+
return normalizedBrands;
|
|
114
|
+
}
|
|
115
|
+
/* eslint-disable max-len */
|
|
116
|
+
/**
|
|
117
|
+
* We must ensure the data we get from `navigator.userAgentData` is normalized to match what our backend expects to
|
|
118
|
+
* see in our custom CameraKitWeb userAgent string.
|
|
119
|
+
*
|
|
120
|
+
* This string is defined here:
|
|
121
|
+
* https://github.sc-corp.net/Snapchat/useragent/blob/9333afe7cc6ac00503ad46cb234bcf94006dff98/java/useragent/src/main/java/snapchat/client/UserAgent.java#L124
|
|
122
|
+
*/
|
|
123
|
+
/* eslint-enable */
|
|
124
|
+
function normalizeUserAgentData(userAgentData) {
|
|
125
|
+
return {
|
|
126
|
+
brands: normalizeBrands(userAgentData.brands),
|
|
127
|
+
mobile: userAgentData.mobile,
|
|
128
|
+
platform: parsePlaftformName(userAgentData.platform),
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
function parsePlaftformName(userAgent) {
|
|
132
|
+
const knownPlatforms = new Map([
|
|
133
|
+
["android", "android"],
|
|
134
|
+
["linux", "linux"],
|
|
135
|
+
["iphone os", "ios"],
|
|
136
|
+
["ipad", "ipados"],
|
|
137
|
+
["mac os", "macos"],
|
|
138
|
+
["macos", "macos"],
|
|
139
|
+
["windows", "windows"],
|
|
140
|
+
]);
|
|
141
|
+
const normalizedUserAgent = userAgent.toLowerCase();
|
|
142
|
+
for (const [match, platform] of knownPlatforms.entries()) {
|
|
143
|
+
if (normalizedUserAgent.includes(match))
|
|
144
|
+
return platform;
|
|
145
|
+
}
|
|
146
|
+
return "unknown";
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* We'll use the application's origin as an identifier – this isn't used for any kind of authentication, but it may be
|
|
150
|
+
* useful metadata to have in the future.
|
|
151
|
+
*
|
|
152
|
+
* We also need to handle cases in which the SDK is used in a child browsing context (e.g. an iframe), which may not
|
|
153
|
+
* have a hostname – in this case we'll check each ancestor context until we find a valid hostname.
|
|
154
|
+
*/
|
|
155
|
+
function parseApplicationOrigin() {
|
|
156
|
+
var _a, _b;
|
|
157
|
+
let origin = location.hostname;
|
|
158
|
+
// Firefox does not implement ancestorOrigins, so we need a fallback.
|
|
159
|
+
// Context here: https://github.com/whatwg/html/issues/1918
|
|
160
|
+
const ancestorOrigins = location.ancestorOrigins === undefined
|
|
161
|
+
? [window.parent.origin, (_b = (_a = window.top) === null || _a === void 0 ? void 0 : _a.origin) !== null && _b !== void 0 ? _b : ""]
|
|
162
|
+
: Array.from(location.ancestorOrigins);
|
|
163
|
+
while (origin === "" && ancestorOrigins.length > 0) {
|
|
164
|
+
// Safety: ancestorOrigins must contain at least one element, so shift() will always be defined.
|
|
165
|
+
origin = new URL(ancestorOrigins.shift()).hostname;
|
|
166
|
+
}
|
|
167
|
+
return origin;
|
|
168
|
+
}
|
|
169
|
+
function getCameraKitUserAgent() {
|
|
170
|
+
const userAgent = navigator.userAgent;
|
|
171
|
+
// [NavigatorUAData](https://developer.mozilla.org/en-US/docs/Web/API/NavigatorUAData) is currently only
|
|
172
|
+
// available on Chromium-based browsers – it's nice because it gives us clear, well-documented information. But
|
|
173
|
+
// we'll have to fallback to parsing the userAgent string when it's not available.
|
|
174
|
+
const userAgentData = navigator.userAgentData !== undefined
|
|
175
|
+
? normalizeUserAgentData(navigator.userAgentData)
|
|
176
|
+
: parseUserAgentData(userAgent);
|
|
177
|
+
const platformVersion = parsePlatformVersion(userAgent);
|
|
178
|
+
const deviceModel = parseDeviceModel(userAgent);
|
|
179
|
+
// In cases where we've parsed the userAgent string to find the brand, there will only ever be a single brand –
|
|
180
|
+
// in browsers which support NavigatorUAData there could be more than one (e.g. Chrome and Chromium), but they
|
|
181
|
+
// should be equivalent for our purposes.
|
|
182
|
+
const browser = userAgentData.brands[0];
|
|
183
|
+
const origin = parseApplicationOrigin();
|
|
184
|
+
const sdkLongVersion = environment.PACKAGE_VERSION;
|
|
185
|
+
// Remove any `-prerelease` or `+buildmetadata` portions from the semver string.
|
|
186
|
+
const sdkShortVersion = sdkLongVersion.replace(/[-+]\S+$/, "");
|
|
187
|
+
// Set this to `debug` manually while testing / root-causing.
|
|
188
|
+
const flavor = "release";
|
|
189
|
+
// This full string is defined here:
|
|
190
|
+
// eslint-disable-next-line max-len
|
|
191
|
+
// https://github.sc-corp.net/Snapchat/useragent/blob/9333afe7cc6ac00503ad46cb234bcf94006dff98/java/useragent/src/main/java/snapchat/client/UserAgent.java#L124
|
|
192
|
+
const cameraKitUserAgent = `CameraKitWeb/${sdkShortVersion} ` +
|
|
193
|
+
`${flavor === "release" ? "" : "DEBUG"}` +
|
|
194
|
+
`(${deviceModel}; ${userAgentData.platform} ${platformVersion}) ` +
|
|
195
|
+
`${browser.brand}/${browser.version} ` +
|
|
196
|
+
`Core/${lensCoreWasm.version} ` +
|
|
197
|
+
// We overload appId, using the origin instead of the true appId parsed from the apiToken -- we do this because
|
|
198
|
+
// origin is human-readable, and this is used to populate the appId dimension in operational metrics.
|
|
199
|
+
`AppId/${origin}`;
|
|
200
|
+
return {
|
|
201
|
+
osType: userAgentData.platform,
|
|
202
|
+
osVersion: platformVersion,
|
|
203
|
+
locale,
|
|
204
|
+
sdkShortVersion,
|
|
205
|
+
sdkLongVersion,
|
|
206
|
+
flavor,
|
|
207
|
+
lensCoreVersion: `${lensCoreWasm.version}`,
|
|
208
|
+
deviceModel,
|
|
209
|
+
browser,
|
|
210
|
+
origin,
|
|
211
|
+
userAgent: cameraKitUserAgent,
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
/** @internal */
|
|
215
|
+
export const cameraKitUserAgent = getCameraKitUserAgent();
|
|
216
|
+
//# sourceMappingURL=cameraKitUserAgent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"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MAAM,GAAG,sBAAsB,EAAE,CAAC;IAExC,MAAM,cAAc,GAAG,WAAW,CAAC,eAAe,CAAC;IACnD,gFAAgF;IAChF,MAAM,eAAe,GAAG,cAAc,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IAE/D,6DAA6D;IAC7D,MAAM,MAAM,GAAwB,SAAS,CAAC;IAE9C,oCAAoC;IACpC,mCAAmC;IACnC,+JAA+J;IAC/J,MAAM,kBAAkB,GACpB,gBAAgB,eAAe,GAAG;QAClC,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE;QACxC,IAAI,WAAW,KAAK,aAAa,CAAC,QAAQ,IAAI,eAAe,IAAI;QACjE,GAAG,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,OAAO,GAAG;QACtC,QAAQ,YAAY,CAAC,OAAO,GAAG;QAC/B,+GAA+G;QAC/G,qGAAqG;QACrG,SAAS,MAAM,EAAE,CAAC;IAEtB,OAAO;QACH,MAAM,EAAE,aAAa,CAAC,QAAQ;QAC9B,SAAS,EAAE,eAAe;QAC1B,MAAM;QACN,eAAe;QACf,cAAc;QACd,MAAM;QACN,eAAe,EAAE,GAAG,YAAY,CAAC,OAAO,EAAE;QAC1C,WAAW;QACX,OAAO;QACP,MAAM;QACN,SAAS,EAAE,kBAAkB;KAChC,CAAC;AACN,CAAC;AAiBD,gBAAgB;AAChB,MAAM,CAAC,MAAM,kBAAkB,GAAG,qBAAqB,EAAE,CAAC","sourcesContent":["import environment from \"../environment.json\";\nimport lensCoreWasm from \"../lensCoreWasmVersions.json\";\nimport { locale } from \"./locale\";\n\ntype BrandArray = Array<{ brand: string; version: string }>;\n\ninterface NavigatorUAData {\n brands: BrandArray;\n mobile: boolean;\n platform: string;\n}\n\ndeclare global {\n interface Navigator {\n userAgentData?: NavigatorUAData;\n }\n}\n\n/**\n * Parse the platform (i.e. OS) version.\n *\n * From limited testing, this seems to often produce incorrect results – the userAgent string does not typically include\n * the actual OS version.\n *\n * Better results could be obtained from [NavigatorUAData.getHighEntropyValues]\n * (https://developer.mozilla.org/en-US/docs/Web/API/NavigatorUAData/getHighEntropyValues), but this presents two\n * problems: 1) it's currently only supported on Chrome and 2) browsers may prompt the user for permission to share\n * this information.\n *\n * So, at least for now, we'll be satisfied with the incorrect version number.\n */\nfunction parsePlatformVersion(userAgent: string) {\n // possible platform version values inside of user agent string\n // \" 11;\"\n // \" 10_15_7)\"\n // \" 13_5_1 \"\n // \" 10.0;\"\n // \" 15_1 \"\n const versionMatch = userAgent.match(/\\s([\\d][\\d_.]*[\\d])(;|\\)|\\s)/);\n\n if (versionMatch != null) {\n return versionMatch[1].replace(/_/g, \".\");\n }\n\n return \"\";\n}\n\n/**\n * In the future, we may invest in more robust device-detection (e.g. a UA string database), but for now this will give\n * us some sense of device usage.\n */\nfunction parseDeviceModel(userAgent: string) {\n // from user agent like \"(Linux; Android 11; Pixel 2)\" extact \"Pixel 2\"\n const userAgentWithModel = userAgent.match(/;[^;]+?;([^\\)]+?)\\)/);\n\n if (userAgentWithModel) {\n return userAgentWithModel[1].trim();\n }\n\n // from user agent like \"... (iPad; CPU OS 15_1 like Mac OS X) ...\" extract \"IPad\"\n const userAgentWithModel2 = userAgent.match(/\\(([^;]+);/);\n\n if (userAgentWithModel2) {\n return userAgentWithModel2[1].trim();\n }\n\n return \"unknown\";\n}\n\n/**\n * Some browsers (e.g. Safari) do not support the `Navigator.userAgentData` API. We'll attempt a sort of polyfill by\n * parsing the data found in [NavigatorUAData](https://developer.mozilla.org/en-US/docs/Web/API/NavigatorUAData) from\n * the raw user agent string.\n */\nfunction parseUserAgentData(userAgent: string): NavigatorUAData {\n let brand: BrandArray[number];\n\n // Parse UA string for Chromium-based browsers (e.g. Chrome, Edge)\n if (/Chrome/.test(userAgent)) {\n const versionMatch = userAgent.match(/Chrome\\/([\\d.]+)/);\n brand = {\n brand: \"Chrome\",\n version: versionMatch !== null ? versionMatch[1] : \"unknown\",\n };\n }\n\n // Parse UA string for Safari (very important for this to only be done if Chrome is not found – Chrome userAgent\n // strings will contain \"Safari\")\n else if (/Safari/.test(userAgent)) {\n let versionMatch = userAgent.match(/Version\\/([\\d.]+)/);\n if (versionMatch === null) versionMatch = userAgent.match(/Safari\\/([\\d.]+)/);\n brand = {\n brand: \"Safari\",\n version: versionMatch !== null ? versionMatch[1] : \"unknown\",\n };\n }\n\n // Parse UA for unknown browser.\n // TODO: will be changed, default value support should be added on a COF server side.\n else {\n brand = {\n brand: \"Firefox\",\n version: \"0\",\n };\n }\n\n // We're not using `mobile` for anything, and we have no consistent way to determine this from the UA string.\n // We'll set it to false, but this should not be used – instead, we'll need to rely on more sophisticated methods\n // (e.g. a userAgent database) to determine actual device.\n const mobile = false;\n const platform = parsePlaftformName(userAgent);\n\n return {\n brands: [brand],\n mobile,\n platform,\n };\n}\n\n/* eslint-disable max-len */\n/**\n * The `brands` array found in [NavigatorUAData](https://developer.mozilla.org/en-US/docs/Web/API/NavigatorUAData) is\n * intentionally designed to discourage standardized processing. This method of extracting brand information will be\n * inherently brittle, and it relies on us matching some well-known brands.\n *\n * For more detail from the spec:\n * See https://wicg.github.io/ua-client-hints/#monkeypatch-html-windoworworkerglobalscope\n * And https://wicg.github.io/ua-client-hints/#grease\n *\n * We also must match the list of known brands allowed by the backend, defined here:\n * https://github.sc-corp.net/Snapchat/useragent/blob/9333afe7cc6ac00503ad46cb234bcf94006dff98/java/useragent/src/main/java/snapchat/client/UserAgent.java#L124\n */\n/* eslint-enable */\ntype KnownBrand = \"Chrome\" | \"Safari\" | \"Firefox\";\nfunction normalizeBrands(brands: BrandArray): BrandArray {\n const knownBrands = new Map<string, KnownBrand>([\n [\"Chrome\", \"Chrome\"],\n [\"Chromium\", \"Chrome\"],\n [\"Firefox\", \"Firefox\"],\n [\"Microsoft Edge\", \"Chrome\"],\n [\"Safari\", \"Safari\"],\n ]);\n\n const normalizedBrands = brands\n .filter(({ brand }) => knownBrands.has(brand))\n .map((brand) => {\n return {\n // Safety: we've filtered out brands which do not appear as keys in `knownBrands`, so this cannot return\n // undefined.\n brand: knownBrands.get(brand.brand)!,\n version: brand.version,\n };\n });\n\n // TODO: default \"unknown\" value should be added on COF server side. For now we'll use Firefox.\n if (normalizedBrands.length === 0) return [{ brand: \"Firefox\", version: \"0\" }];\n return normalizedBrands;\n}\n\n/* eslint-disable max-len */\n/**\n * We must ensure the data we get from `navigator.userAgentData` is normalized to match what our backend expects to\n * see in our custom CameraKitWeb userAgent string.\n *\n * This string is defined here:\n * https://github.sc-corp.net/Snapchat/useragent/blob/9333afe7cc6ac00503ad46cb234bcf94006dff98/java/useragent/src/main/java/snapchat/client/UserAgent.java#L124\n */\n/* eslint-enable */\nfunction normalizeUserAgentData(userAgentData: NavigatorUAData): NavigatorUAData {\n return {\n brands: normalizeBrands(userAgentData.brands),\n mobile: userAgentData.mobile,\n platform: parsePlaftformName(userAgentData.platform),\n };\n}\n\n/* eslint-disable max-len */\n/**\n * The backend defines the allowed list of known platforms which will pass their RegEx test when found in our custom\n * CameraKitWeb userAgent string.\n *\n * See https://github.sc-corp.net/Snapchat/useragent/blob/9333afe7cc6ac00503ad46cb234bcf94006dff98/java/useragent/src/main/java/snapchat/client/UserAgent.java#L124\n */\n/* eslint-enable */\ntype KnownPlatform = \"macos\" | \"windows\" | \"linux\" | \"android\" | \"ios\" | \"ipados\" | \"unknown\";\nfunction parsePlaftformName(userAgent: string): KnownPlatform {\n const knownPlatforms = new Map<string, KnownPlatform>([\n [\"android\", \"android\"],\n [\"linux\", \"linux\"],\n [\"iphone os\", \"ios\"],\n [\"ipad\", \"ipados\"],\n [\"mac os\", \"macos\"],\n [\"macos\", \"macos\"],\n [\"windows\", \"windows\"],\n ]);\n\n const normalizedUserAgent = userAgent.toLowerCase();\n for (const [match, platform] of knownPlatforms.entries()) {\n if (normalizedUserAgent.includes(match)) return platform;\n }\n return \"unknown\";\n}\n\n/**\n * We'll use the application's origin as an identifier – this isn't used for any kind of authentication, but it may be\n * useful metadata to have in the future.\n *\n * We also need to handle cases in which the SDK is used in a child browsing context (e.g. an iframe), which may not\n * have a hostname – in this case we'll check each ancestor context until we find a valid hostname.\n */\nfunction parseApplicationOrigin(): string {\n let origin = location.hostname;\n // Firefox does not implement ancestorOrigins, so we need a fallback.\n // Context here: https://github.com/whatwg/html/issues/1918\n const ancestorOrigins =\n location.ancestorOrigins === undefined\n ? [window.parent.origin, window.top?.origin ?? \"\"]\n : Array.from(location.ancestorOrigins);\n\n while (origin === \"\" && ancestorOrigins.length > 0) {\n // Safety: ancestorOrigins must contain at least one element, so shift() will always be defined.\n origin = new URL(ancestorOrigins.shift()!).hostname;\n }\n return origin;\n}\n\nfunction getCameraKitUserAgent(): CameraKitUserAgent {\n const userAgent = navigator.userAgent;\n // [NavigatorUAData](https://developer.mozilla.org/en-US/docs/Web/API/NavigatorUAData) is currently only\n // available on Chromium-based browsers – it's nice because it gives us clear, well-documented information. But\n // we'll have to fallback to parsing the userAgent string when it's not available.\n const userAgentData =\n navigator.userAgentData !== undefined\n ? normalizeUserAgentData(navigator.userAgentData)\n : parseUserAgentData(userAgent);\n\n const platformVersion = parsePlatformVersion(userAgent);\n const deviceModel = parseDeviceModel(userAgent);\n\n // In cases where we've parsed the userAgent string to find the brand, there will only ever be a single brand –\n // in browsers which support NavigatorUAData there could be more than one (e.g. Chrome and Chromium), but they\n // should be equivalent for our purposes.\n const browser = userAgentData.brands[0];\n const origin = parseApplicationOrigin();\n\n const sdkLongVersion = environment.PACKAGE_VERSION;\n // Remove any `-prerelease` or `+buildmetadata` portions from the semver string.\n const sdkShortVersion = sdkLongVersion.replace(/[-+]\\S+$/, \"\");\n\n // Set this to `debug` manually while testing / root-causing.\n const flavor: \"release\" | \"debug\" = \"release\";\n\n // This full string is defined here:\n // eslint-disable-next-line max-len\n // https://github.sc-corp.net/Snapchat/useragent/blob/9333afe7cc6ac00503ad46cb234bcf94006dff98/java/useragent/src/main/java/snapchat/client/UserAgent.java#L124\n const cameraKitUserAgent =\n `CameraKitWeb/${sdkShortVersion} ` +\n `${flavor === \"release\" ? \"\" : \"DEBUG\"}` +\n `(${deviceModel}; ${userAgentData.platform} ${platformVersion}) ` +\n `${browser.brand}/${browser.version} ` +\n `Core/${lensCoreWasm.version} ` +\n // We overload appId, using the origin instead of the true appId parsed from the apiToken -- we do this because\n // origin is human-readable, and this is used to populate the appId dimension in operational metrics.\n `AppId/${origin}`;\n\n return {\n osType: userAgentData.platform,\n osVersion: platformVersion,\n locale,\n sdkShortVersion,\n sdkLongVersion,\n flavor,\n lensCoreVersion: `${lensCoreWasm.version}`,\n deviceModel,\n browser,\n origin,\n userAgent: cameraKitUserAgent,\n };\n}\n\n/** @internal */\nexport interface CameraKitUserAgent {\n osType: string;\n osVersion: string;\n locale: string;\n sdkShortVersion: string;\n sdkLongVersion: string;\n flavor: \"release\" | \"debug\";\n lensCoreVersion: string;\n deviceModel: string;\n browser: { brand: string; version: string };\n origin: string;\n userAgent: string;\n}\n\n/** @internal */\nexport const cameraKitUserAgent = getCameraKitUserAgent();\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copy only those properties of an object which are not undefined.
|
|
3
|
+
*
|
|
4
|
+
* This can be useful when using `Object.assign(foo, bar)` or `{ ...foo, ...bar }` to copy values from one object to
|
|
5
|
+
* another. There's a (rather annoying) difference between a property not existing in an object and that property
|
|
6
|
+
* existing but having an undefined value. When copying values using either of the methods above, it's generally
|
|
7
|
+
* expected that undefined properties won't overwrite defined properties. But that's not the behavior – this helper
|
|
8
|
+
* function is needed to ensure undefined properties in `bar` don't clobber corresponding properties in `foo`.
|
|
9
|
+
*
|
|
10
|
+
* @param obj Any object, possibly with properties whose values are undefined.
|
|
11
|
+
* @returns A copy of the input object, without keys whose values were undefined.
|
|
12
|
+
*/
|
|
13
|
+
export declare function copyDefinedProperties<T extends {}>(obj: T): T;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copy only those properties of an object which are not undefined.
|
|
3
|
+
*
|
|
4
|
+
* This can be useful when using `Object.assign(foo, bar)` or `{ ...foo, ...bar }` to copy values from one object to
|
|
5
|
+
* another. There's a (rather annoying) difference between a property not existing in an object and that property
|
|
6
|
+
* existing but having an undefined value. When copying values using either of the methods above, it's generally
|
|
7
|
+
* expected that undefined properties won't overwrite defined properties. But that's not the behavior – this helper
|
|
8
|
+
* function is needed to ensure undefined properties in `bar` don't clobber corresponding properties in `foo`.
|
|
9
|
+
*
|
|
10
|
+
* @param obj Any object, possibly with properties whose values are undefined.
|
|
11
|
+
* @returns A copy of the input object, without keys whose values were undefined.
|
|
12
|
+
*/
|
|
13
|
+
export function copyDefinedProperties(obj) {
|
|
14
|
+
return Object.fromEntries(Object.entries(obj).filter(([_, value]) => value !== undefined));
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=copyDefinedProperties.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copyDefinedProperties.js","sourceRoot":"","sources":["../../src/common/copyDefinedProperties.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,qBAAqB,CAAe,GAAM;IACtD,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAAM,CAAC;AACpG,CAAC","sourcesContent":["/**\n * Copy only those properties of an object which are not undefined.\n *\n * This can be useful when using `Object.assign(foo, bar)` or `{ ...foo, ...bar }` to copy values from one object to\n * another. There's a (rather annoying) difference between a property not existing in an object and that property\n * existing but having an undefined value. When copying values using either of the methods above, it's generally\n * expected that undefined properties won't overwrite defined properties. But that's not the behavior – this helper\n * function is needed to ensure undefined properties in `bar` don't clobber corresponding properties in `foo`.\n *\n * @param obj Any object, possibly with properties whose values are undefined.\n * @returns A copy of the input object, without keys whose values were undefined.\n */\nexport function copyDefinedProperties<T extends {}>(obj: T): T {\n return Object.fromEntries(Object.entries(obj).filter(([_, value]) => value !== undefined)) as T;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entries.js","sourceRoot":"","sources":["../../src/common/entries.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAC5G,MAAM,CAAC,MAAM,OAAO,GAAG,CAAiD,CAAI,EAAgC,EAAE,CAC1G,MAAM,CAAC,OAAO,CAAC,CAAC,CAAiC,CAAC","sourcesContent":["// `Object.entries` does not use `keyof` types, so it loses type specificity. We'll fix this with a wrapper.\nexport const entries = <T extends { [s: string]: U } | ArrayLike<U>, U>(o: T): Array<[keyof T, T[keyof T]]> =>\n Object.entries(o) as Array<[keyof T, T[keyof T]]>;\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a stack trace for a given error, and also appends the stack trace of any nested error, if one exists.
|
|
3
|
+
* @param error Error to stringify.
|
|
4
|
+
* @returns Error stack trace.
|
|
5
|
+
*/
|
|
6
|
+
export declare function stringifyError(error: Error): string;
|
|
7
|
+
/**
|
|
8
|
+
* If given a value of type Error, return it – otherwise wrap the value in an Error.
|
|
9
|
+
*/
|
|
10
|
+
export declare function ensureError(error: unknown): Error;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a stack trace for a given error, and also appends the stack trace of any nested error, if one exists.
|
|
3
|
+
* @param error Error to stringify.
|
|
4
|
+
* @returns Error stack trace.
|
|
5
|
+
*/
|
|
6
|
+
export function stringifyError(error) {
|
|
7
|
+
var _a;
|
|
8
|
+
const outer = (_a = error.stack) !== null && _a !== void 0 ? _a : "";
|
|
9
|
+
return error.cause ? `${outer}\nCaused By: ${stringifyError(ensureError(error.cause))}` : outer;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* If given a value of type Error, return it – otherwise wrap the value in an Error.
|
|
13
|
+
*/
|
|
14
|
+
export function ensureError(error) {
|
|
15
|
+
if (error instanceof Error)
|
|
16
|
+
return error;
|
|
17
|
+
try {
|
|
18
|
+
return new Error(`Non-Error type exception thrown. Serialized error value: ${JSON.stringify(error)}`);
|
|
19
|
+
}
|
|
20
|
+
catch (_) {
|
|
21
|
+
return new Error("Non-Error type exception thrown. Original error value could not be serialized.");
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=errorHelpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorHelpers.js","sourceRoot":"","sources":["../../src/common/errorHelpers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,KAAY;;IACvC,MAAM,KAAK,GAAG,MAAA,KAAK,CAAC,KAAK,mCAAI,EAAE,CAAC;IAChC,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,gBAAgB,cAAc,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;AACpG,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,KAAc;IACtC,IAAI,KAAK,YAAY,KAAK;QAAE,OAAO,KAAK,CAAC;IAEzC,IAAI;QACA,OAAO,IAAI,KAAK,CAAC,4DAA4D,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;KACzG;IAAC,OAAO,CAAC,EAAE;QACR,OAAO,IAAI,KAAK,CAAC,gFAAgF,CAAC,CAAC;KACtG;AACL,CAAC","sourcesContent":["/**\n * Returns a stack trace for a given error, and also appends the stack trace of any nested error, if one exists.\n * @param error Error to stringify.\n * @returns Error stack trace.\n */\nexport function stringifyError(error: Error): string {\n const outer = error.stack ?? \"\";\n return error.cause ? `${outer}\\nCaused By: ${stringifyError(ensureError(error.cause))}` : outer;\n}\n\n/**\n * If given a value of type Error, return it – otherwise wrap the value in an Error.\n */\nexport function ensureError(error: unknown): Error {\n if (error instanceof Error) return error;\n\n try {\n return new Error(`Non-Error type exception thrown. Serialized error value: ${JSON.stringify(error)}`);\n } catch (_) {\n return new Error(\"Non-Error type exception thrown. Original error value could not be serialized.\");\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getFilename(lensUri: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getFilename.js","sourceRoot":"","sources":["../../src/common/getFilename.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,WAAW,CAAC,OAAe;IACvC,OAAO,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;AAC3D,CAAC","sourcesContent":["export function getFilename(lensUri: string) {\n return lensUri.substring(lensUri.lastIndexOf(\"/\") + 1);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC","sourcesContent":["export * from \"./getFilename\";\nexport * from \"./loadScript\";\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function loadScript(scriptUri: string): Promise<void>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function loadScript(scriptUri) {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
const scriptElement = document.createElement("script");
|
|
4
|
+
scriptElement.src = scriptUri;
|
|
5
|
+
scriptElement.async = true;
|
|
6
|
+
scriptElement.addEventListener("load", () => resolve(), { once: true });
|
|
7
|
+
scriptElement.addEventListener("error", (event) => reject(event), { once: true });
|
|
8
|
+
document.body.appendChild(scriptElement);
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=loadScript.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadScript.js","sourceRoot":"","sources":["../../src/common/loadScript.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,UAAU,CAAC,SAAiB;IACxC,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACzC,MAAM,aAAa,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QACvD,aAAa,CAAC,GAAG,GAAG,SAAS,CAAC;QAC9B,aAAa,CAAC,KAAK,GAAG,IAAI,CAAC;QAC3B,aAAa,CAAC,gBAAgB,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QACxE,aAAa,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAClF,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["export function loadScript(scriptUri: string) {\n return new Promise<void>((resolve, reject) => {\n const scriptElement = document.createElement(\"script\");\n scriptElement.src = scriptUri;\n scriptElement.async = true;\n scriptElement.addEventListener(\"load\", () => resolve(), { once: true });\n scriptElement.addEventListener(\"error\", (event) => reject(event), { once: true });\n document.body.appendChild(scriptElement);\n });\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const locale = navigator.language;
|
|
2
|
+
// Below adds qvalue to languages as per a backend issue:
|
|
3
|
+
// https://github.sc-corp.net/Snapchat/phantom/pull/196781
|
|
4
|
+
// More on qvalues: https://developer.mozilla.org/en-US/docs/Glossary/Quality_values
|
|
5
|
+
export const fullLocale = navigator.languages
|
|
6
|
+
.map((lang, index) => {
|
|
7
|
+
const qvalue = Math.max(0, (10 - index) / 10);
|
|
8
|
+
return `${lang};q=${qvalue.toFixed(1)}`;
|
|
9
|
+
})
|
|
10
|
+
.join(", ");
|
|
11
|
+
//# sourceMappingURL=locale.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locale.js","sourceRoot":"","sources":["../../src/common/locale.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC;AAEzC,yDAAyD;AACzD,0DAA0D;AAC1D,oFAAoF;AACpF,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAC,SAAS;KACxC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;IACjB,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;IAC9C,OAAO,GAAG,IAAI,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;AAC5C,CAAC,CAAC;KACD,IAAI,CAAC,IAAI,CAAC,CAAC","sourcesContent":["export const locale = navigator.language;\n\n// Below adds qvalue to languages as per a backend issue:\n// https://github.sc-corp.net/Snapchat/phantom/pull/196781\n// More on qvalues: https://developer.mozilla.org/en-US/docs/Glossary/Quality_values\nexport const fullLocale = navigator.languages\n .map((lang, index) => {\n const qvalue = Math.max(0, (10 - index) / 10);\n return `${lang};q=${qvalue.toFixed(1)}`;\n })\n .join(\", \");\n"]}
|