@snap/camera-kit 0.13.2 → 0.14.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/docs/html/assets/search.js +1 -1
- package/docs/html/classes/CameraKit.html +4 -3
- package/docs/html/classes/CameraKitSession.html +4 -3
- package/docs/html/classes/CameraKitSource.html +4 -3
- package/docs/html/classes/LensPerformanceMeasurement.html +4 -3
- package/docs/html/classes/LensPerformanceMetrics.html +4 -3
- package/docs/html/classes/LensRepository.html +6 -5
- package/docs/html/classes/LensSources.html +4 -3
- package/docs/html/classes/Transform2D.html +4 -3
- package/docs/html/classes/TypedCustomEvent.html +4 -3
- package/docs/html/classes/TypedEventTarget.html +4 -3
- package/docs/html/functions/Injectable.html +4 -3
- package/docs/html/functions/bootstrapCameraKit.html +4 -3
- package/docs/html/functions/createExtension.html +4 -3
- package/docs/html/functions/createImageSource.html +4 -3
- package/docs/html/functions/createMediaStreamSource.html +4 -3
- package/docs/html/functions/createUserMediaSource.html +4 -3
- package/docs/html/functions/createVideoSource.html +4 -3
- package/docs/html/functions/estimateLensPerformance.html +4 -3
- package/docs/html/functions/getRequiredBootstrapURLs.html +4 -3
- package/docs/html/functions/lensSourcesFactory.html +4 -3
- package/docs/html/functions/remoteApiServicesFactory.html +4 -3
- package/docs/html/index.html +5 -4
- package/docs/html/interfaces/CameraKitBootstrapConfiguration.html +16 -5
- package/docs/html/interfaces/CameraKitSourceSubscriber.html +5 -4
- package/docs/html/interfaces/ComputedFrameMetrics.html +4 -3
- package/docs/html/interfaces/CreateSessionOptions.html +4 -3
- package/docs/html/interfaces/EstimatedLensPerformance.html +4 -3
- package/docs/html/interfaces/Lens.html +13 -3
- package/docs/html/interfaces/LensSource.html +4 -3
- package/docs/html/interfaces/MediaStreamSourceOptions.html +4 -3
- package/docs/html/interfaces/Preview.html +4 -3
- package/docs/html/interfaces/RemoteApiRequest.html +4 -3
- package/docs/html/interfaces/RemoteApiResponse.html +4 -3
- package/docs/html/interfaces/RemoteApiService.html +4 -3
- package/docs/html/interfaces/Snapcode.html +4 -3
- package/docs/html/interfaces/UriCancelRequest.html +4 -3
- package/docs/html/interfaces/UriRequest.html +4 -3
- package/docs/html/interfaces/UriResponse.html +4 -3
- package/docs/html/interfaces/VideoSourceOptions.html +4 -3
- package/docs/html/modules.html +6 -4
- package/docs/html/types/AssetLoader.html +4 -3
- package/docs/html/types/AssetTiming.html +4 -3
- package/docs/html/types/BenchmarkError.html +4 -3
- package/docs/html/types/BootstrapError.html +4 -3
- package/docs/html/types/CacheKeyNotFoundError.html +4 -3
- package/docs/html/types/CameraKitDeviceInfo.html +4 -3
- package/docs/html/types/CameraKitDeviceOptions.html +4 -3
- package/docs/html/types/CameraKitSessionEventListener.html +4 -3
- package/docs/html/types/CameraKitSessionEvents.html +6 -5
- package/docs/html/types/CameraKitSourceError.html +4 -3
- package/docs/html/types/CameraKitSourceInfo.html +4 -3
- package/docs/html/types/CameraKitSourceOptions.html +4 -3
- package/docs/html/types/ConfigurationError.html +4 -3
- package/docs/html/types/Keyboard.html +4 -3
- package/docs/html/types/KeyboardEvents.html +4 -3
- package/docs/html/types/LegalError.html +4 -3
- package/docs/html/types/LensAbortError.html +119 -0
- package/docs/html/types/LensAssetError.html +4 -3
- package/docs/html/types/LensContentValidationError.html +4 -3
- package/docs/html/types/LensError.html +4 -3
- package/docs/html/types/LensExecutionError.html +4 -3
- package/docs/html/types/LensImagePickerError.html +4 -3
- package/docs/html/types/LensLaunchParams.html +4 -3
- package/docs/html/types/LensMetricsEvents.html +4 -3
- package/docs/html/types/LensPerformanceCluster.html +4 -3
- package/docs/html/types/LensView.html +4 -3
- package/docs/html/types/LensWait.html +4 -3
- package/docs/html/types/PersistentStoreError.html +4 -3
- package/docs/html/types/PlatformNotSupportedError.html +4 -3
- package/docs/html/types/PublicContainer.html +4 -3
- package/docs/html/types/RemoteApiRequestHandler.html +4 -3
- package/docs/html/types/RemoteApiServices.html +4 -3
- package/docs/html/types/RemoteApiStatus.html +4 -3
- package/docs/html/types/RenderTarget.html +4 -3
- package/docs/html/types/Uri.html +4 -3
- package/docs/html/types/WebGLError.html +4 -3
- package/docs/html/variables/extensionRequestContext.html +4 -3
- package/docs/md/classes/CameraKit.md +1 -1
- package/docs/md/classes/CameraKitSession.md +1 -1
- package/docs/md/classes/CameraKitSource.md +1 -1
- package/docs/md/classes/LensPerformanceMeasurement.md +1 -1
- package/docs/md/classes/LensPerformanceMetrics.md +1 -1
- package/docs/md/classes/LensRepository.md +3 -3
- package/docs/md/classes/LensSources.md +1 -1
- package/docs/md/classes/Transform2D.md +1 -1
- package/docs/md/classes/TypedCustomEvent.md +1 -1
- package/docs/md/classes/TypedEventTarget.md +1 -1
- package/docs/md/interfaces/CameraKitBootstrapConfiguration.md +13 -2
- package/docs/md/interfaces/CameraKitSourceSubscriber.md +3 -3
- package/docs/md/interfaces/ComputedFrameMetrics.md +1 -1
- package/docs/md/interfaces/CreateSessionOptions.md +1 -1
- package/docs/md/interfaces/EstimatedLensPerformance.md +1 -1
- package/docs/md/interfaces/Lens.md +11 -1
- package/docs/md/interfaces/LensSource.md +1 -1
- package/docs/md/interfaces/MediaStreamSourceOptions.md +1 -1
- package/docs/md/interfaces/Preview.md +1 -1
- package/docs/md/interfaces/RemoteApiRequest.md +1 -1
- package/docs/md/interfaces/RemoteApiResponse.md +1 -1
- package/docs/md/interfaces/RemoteApiService.md +1 -1
- package/docs/md/interfaces/Snapcode.md +1 -1
- package/docs/md/interfaces/UriCancelRequest.md +1 -1
- package/docs/md/interfaces/UriRequest.md +1 -1
- package/docs/md/interfaces/UriResponse.md +1 -1
- package/docs/md/interfaces/VideoSourceOptions.md +1 -1
- package/docs/md/modules.md +24 -4
- package/lib/CameraKit.d.ts +139 -7
- package/lib/CameraKit.js +19 -19
- package/lib/CameraKit.js.map +1 -1
- package/lib/__tests__/data.d.ts +9 -4
- package/lib/__tests__/data.js +19 -9
- package/lib/__tests__/data.js.map +1 -1
- package/lib/bootstrapCameraKit.js +2 -2
- package/lib/bootstrapCameraKit.js.map +1 -1
- package/lib/common/localization.js +7 -31
- package/lib/common/localization.js.map +1 -1
- package/lib/configuration.d.ts +7 -0
- package/lib/configuration.js +1 -0
- package/lib/configuration.js.map +1 -1
- package/lib/configurationOverrides.d.ts +2 -2
- package/lib/configurationOverrides.js +11 -6
- package/lib/configurationOverrides.js.map +1 -1
- package/lib/dependency-injection/RootServices.d.ts +2 -2
- package/lib/dependency-injection/RootServices.js.map +1 -1
- package/lib/environment.json +1 -1
- package/lib/extensions/extensionRequestContext.js +4 -4
- package/lib/extensions/extensionRequestContext.js.map +1 -1
- package/lib/extensions/uriHandlersRegister.d.ts +2 -2
- package/lib/extensions/uriHandlersRegister.js.map +1 -1
- package/lib/generated-proto/blizzard/cameraKitEvents.d.ts +272 -0
- package/lib/generated-proto/blizzard/cameraKitEvents.js +38 -24
- package/lib/generated-proto/blizzard/cameraKitEvents.js.map +1 -1
- package/lib/handlers/cameraKitServiceFetchHandlerFactory.js +2 -2
- package/lib/handlers/cameraKitServiceFetchHandlerFactory.js.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/lens/Lens.d.ts +9 -1
- package/lib/lens/Lens.js +2 -1
- package/lib/lens/Lens.js.map +1 -1
- package/lib/lens/LensPersistenceStore.d.ts +2 -2
- package/lib/lens/LensPersistenceStore.js.map +1 -1
- package/lib/lens/LensRepository.d.ts +2 -2
- package/lib/lens/LensRepository.js +5 -4
- package/lib/lens/LensRepository.js.map +1 -1
- package/lib/lens/assets/LensAssetRepository.d.ts +4 -4
- package/lib/lens/assets/LensAssetRepository.js +1 -3
- package/lib/lens/assets/LensAssetRepository.js.map +1 -1
- package/lib/lens/assets/LensAssetsProvider.d.ts +9 -3
- package/lib/lens/assets/LensAssetsProvider.js +12 -5
- package/lib/lens/assets/LensAssetsProvider.js.map +1 -1
- package/lib/lens-client-interface/imagePicker.d.ts +2 -2
- package/lib/lens-client-interface/imagePicker.js.map +1 -1
- package/lib/lens-client-interface/lensClientInterface.d.ts +2 -2
- package/lib/lens-client-interface/lensClientInterface.js.map +1 -1
- package/lib/lens-core-module/generated-types.d.ts +4 -2
- package/lib/lens-core-module/generated-types.js.map +1 -1
- package/lib/lens-core-module/index.d.ts +1 -0
- package/lib/lens-core-module/index.js +1 -0
- package/lib/lens-core-module/index.js.map +1 -1
- package/lib/lens-core-module/lensCore.d.ts +41 -0
- package/lib/lens-core-module/lensCore.js +54 -0
- package/lib/lens-core-module/lensCore.js.map +1 -0
- package/lib/lens-core-module/lensCoreError.d.ts +15 -0
- package/lib/lens-core-module/lensCoreError.js +43 -0
- package/lib/lens-core-module/lensCoreError.js.map +1 -0
- package/lib/lens-core-module/loader/lensCoreFactory.d.ts +1 -2
- package/lib/lens-core-module/loader/lensCoreFactory.js +24 -26
- package/lib/lens-core-module/loader/lensCoreFactory.js.map +1 -1
- package/lib/lensCoreWasmVersions.json +3 -3
- package/lib/logger/registerLogEntriesSubscriber.js +2 -2
- package/lib/logger/registerLogEntriesSubscriber.js.map +1 -1
- package/lib/media-sources/CameraKitSource.d.ts +3 -3
- package/lib/media-sources/CameraKitSource.js +22 -31
- package/lib/media-sources/CameraKitSource.js.map +1 -1
- package/lib/media-sources/FunctionSource.js +33 -36
- package/lib/media-sources/FunctionSource.js.map +1 -1
- package/lib/media-sources/MediaStreamSource.js +11 -15
- package/lib/media-sources/MediaStreamSource.js.map +1 -1
- package/lib/metrics/businessEventsReporter.js +114 -108
- package/lib/metrics/businessEventsReporter.js.map +1 -1
- package/lib/metrics/reporters/reportGlobalException.js +25 -7
- package/lib/metrics/reporters/reportGlobalException.js.map +1 -1
- package/lib/metrics/reporters/reportHttpMetrics.js +2 -2
- package/lib/metrics/reporters/reportHttpMetrics.js.map +1 -1
- package/lib/metrics/reporters/reportLensView.js +5 -3
- package/lib/metrics/reporters/reportLensView.js.map +1 -1
- package/lib/metrics/reporters/reportLensWait.js +8 -2
- package/lib/metrics/reporters/reportLensWait.js.map +1 -1
- package/lib/metrics/reporters/reportPlatformCapabilities.d.ts +12 -0
- package/lib/metrics/reporters/reportPlatformCapabilities.js +18 -0
- package/lib/metrics/reporters/reportPlatformCapabilities.js.map +1 -0
- package/lib/metrics/reporters/reporters.d.ts +2 -1
- package/lib/metrics/reporters/reporters.js +3 -1
- package/lib/metrics/reporters/reporters.js.map +1 -1
- package/lib/namedErrors.d.ts +17 -0
- package/lib/namedErrors.js +2 -0
- package/lib/namedErrors.js.map +1 -1
- package/lib/platform/assertPlatformSupported.d.ts +4 -0
- package/lib/platform/assertPlatformSupported.js +15 -0
- package/lib/platform/assertPlatformSupported.js.map +1 -0
- package/lib/platform/cameraKitUserAgent.d.ts +2 -0
- package/lib/platform/cameraKitUserAgent.js +20 -0
- package/lib/platform/cameraKitUserAgent.js.map +1 -0
- package/lib/platform/platformCapabilities.d.ts +50 -0
- package/lib/platform/platformCapabilities.js +121 -0
- package/lib/platform/platformCapabilities.js.map +1 -0
- package/lib/{common/cameraKitUserAgent.d.ts → platform/platformInfo.d.ts} +13 -10
- package/lib/{common/cameraKitUserAgent.js → platform/platformInfo.js} +94 -100
- package/lib/platform/platformInfo.js.map +1 -0
- package/lib/remote-configuration/cofHandler.js +2 -2
- package/lib/remote-configuration/cofHandler.js.map +1 -1
- package/lib/remote-configuration/preloadConfiguration.d.ts +2 -2
- package/lib/remote-configuration/preloadConfiguration.js.map +1 -1
- package/lib/session/CameraKitSession.d.ts +3 -3
- package/lib/session/CameraKitSession.js +23 -30
- package/lib/session/CameraKitSession.js.map +1 -1
- package/lib/session/CameraKitSessionEvents.d.ts +7 -3
- package/lib/session/CameraKitSessionEvents.js +17 -0
- package/lib/session/CameraKitSessionEvents.js.map +1 -1
- package/lib/session/LensPerformanceMetrics.d.ts +2 -2
- package/lib/session/LensPerformanceMetrics.js +4 -3
- package/lib/session/LensPerformanceMetrics.js.map +1 -1
- package/lib/session/lensState.d.ts +2 -2
- package/lib/session/lensState.js +36 -37
- package/lib/session/lensState.js.map +1 -1
- package/package.json +2 -2
- package/lib/assertPlatformSupported.d.ts +0 -6
- package/lib/assertPlatformSupported.js +0 -21
- package/lib/assertPlatformSupported.js.map +0 -1
- package/lib/common/cameraKitUserAgent.js.map +0 -1
- package/lib/common/locale.d.ts +0 -2
- package/lib/common/locale.js +0 -11
- package/lib/common/locale.js.map +0 -1
package/lib/namedErrors.d.ts
CHANGED
|
@@ -83,6 +83,23 @@ export declare const platformNotSupportedError: (message: string, cause?: unknow
|
|
|
83
83
|
export type LensExecutionError = NamedError<"LensExecutionError">;
|
|
84
84
|
/** @internal */
|
|
85
85
|
export declare const lensExecutionError: (message: string, cause?: unknown) => LensExecutionError;
|
|
86
|
+
/**
|
|
87
|
+
* This error occurs when a session becomes inoperable.
|
|
88
|
+
*
|
|
89
|
+
* It's always a good idea to handle this error and update the user experience accordingly.
|
|
90
|
+
* For example, you could show a message to a user.
|
|
91
|
+
*
|
|
92
|
+
* ```ts
|
|
93
|
+
* cameraKitSession.events.addEventListener('error', ({ detail }) => {
|
|
94
|
+
* if (detail.error.name === 'LensAbortError') {
|
|
95
|
+
* console.log(`Camera Kit encountered an unrecoverable error and became inoperable. Please refresh the page.`)
|
|
96
|
+
* }
|
|
97
|
+
* })
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
export type LensAbortError = NamedError<"LensAbortError">;
|
|
101
|
+
/** @internal */
|
|
102
|
+
export declare const lensAbortError: (message: string, cause?: unknown) => LensAbortError;
|
|
86
103
|
/**
|
|
87
104
|
* Error thrown when LensCore asked to store lens data, but CameraKit failed storing that.
|
|
88
105
|
*/
|
package/lib/namedErrors.js
CHANGED
|
@@ -48,6 +48,8 @@ export const platformNotSupportedError = namedError("PlatformNotSupportedError")
|
|
|
48
48
|
/** @internal */
|
|
49
49
|
export const lensExecutionError = namedError("LensExecutionError");
|
|
50
50
|
/** @internal */
|
|
51
|
+
export const lensAbortError = namedError("LensAbortError");
|
|
52
|
+
/** @internal */
|
|
51
53
|
export const persistentStoreError = namedError("PersistentStoreError");
|
|
52
54
|
/** @internal */
|
|
53
55
|
export const lensAssetError = namedError("LensAssetError");
|
package/lib/namedErrors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"namedErrors.js","sourceRoot":"","sources":["../src/namedErrors.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,yFAAyF;AAczF;;GAEG;AACH,SAAS,eAAe,CAAC,KAAa;IAClC,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC9C,OAAO,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACvC,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU,CAKxB,IAAW;IACT,OAAO,CAAC,OAAe,EAAE,KAAe,EAAU,EAAE;QAChD,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAC5C,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC;QAClB,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,eAAe,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC1D,4EAA4E;QAC5E,OAAO,KAAe,CAAC;IAC3B,CAAC,CAAC;AACN,CAAC;AAGD,gBAAgB;AAChB,MAAM,CAAC,MAAM,UAAU,GAAG,UAAU,CAAa,YAAY,CAAC,CAAC;AAG/D,gBAAgB;AAChB,MAAM,CAAC,MAAM,0BAA0B,GAAG,UAAU,CAA6B,4BAA4B,CAAC,CAAC;AAG/G,gBAAgB;AAChB,MAAM,CAAC,MAAM,SAAS,GAAG,UAAU,CAAY,WAAW,CAAC,CAAC;AAG5D,gBAAgB;AAChB,MAAM,CAAC,MAAM,oBAAoB,GAAG,UAAU,CAAuB,sBAAsB,CAAC,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uB,sBAAsB,CAAC,CAAC;AAM7F,gBAAgB;AAChB,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAiB,gBAAgB,CAAC,CAAC;AAS3E,gBAAgB;AAChB,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAiB,gBAAgB,CAAC,CAAC","sourcesContent":["// NOTE: All errors thrown in the CameraKit package have to be defined here.\n// Error types are not infered from error factories for API doc purposes and consistency.\n\n/**\n * Helper type to extract type generic parameter.\n */\ntype ExtractName<P> = P extends NamedError<infer T> ? T : never;\n\n/**\n * All errors are expected to have \"Error\" suffix.\n */\ntype ErrorName = `${string}Error`;\n\ntype NamedError<Name extends ErrorName> = Error & { name: Name };\n\n/**\n * Removes the top trace line from the stack.\n */\nfunction cleanErrorStack(stack: string): string {\n const [first, _, ...rest] = stack.split(\"\\n\");\n return [first, ...rest].join(\"\\n\");\n}\n\n/**\n * Creates error factory that ensures Error.prototype.name field value.\n *\n * NOTE: exported only for unit tests.\n *\n * @param name Error name.\n * @returns Error factory function.\n * @internal\n */\nexport function namedError<\n // default to never to ensure the type argument is specified\n TError extends NamedError<TName> = never,\n // default to provided error name to make this type argument optional to reduce boilerplate\n TName extends ErrorName = ExtractName<TError>\n>(name: TName) {\n return (message: string, cause?: unknown): TError => {\n const error = new Error(message, { cause });\n error.name = name;\n error.stack = error.stack && cleanErrorStack(error.stack);\n // Safety: we set name above and therefore sure the type of error is correct\n return error as TError;\n };\n}\n\nexport type LegalError = NamedError<\"LegalError\">;\n/** @internal */\nexport const legalError = namedError<LegalError>(\"LegalError\");\n\nexport type LensContentValidationError = NamedError<\"LensContentValidationError\">;\n/** @internal */\nexport const lensContentValidationError = namedError<LensContentValidationError>(\"LensContentValidationError\");\n\nexport type LensError = NamedError<\"LensError\">;\n/** @internal */\nexport const lensError = namedError<LensError>(\"LensError\");\n\nexport type CameraKitSourceError = NamedError<\"CameraKitSourceError\">;\n/** @internal */\nexport const cameraKitSourceError = namedError<CameraKitSourceError>(\"CameraKitSourceError\");\n\n/**\n * The error triggered when a lens prompts the user to select an image, but the image fails to be successfully delivered\n * to the lens.\n */\nexport type LensImagePickerError = NamedError<\"LensImagePickerError\">;\n/** @internal */\nexport const lensImagePickerError = namedError<LensImagePickerError>(\"LensImagePickerError\");\n\nexport type CacheKeyNotFoundError = NamedError<\"CacheKeyNotFoundError\">;\n/** @internal */\nexport const cacheKeyNotFoundError = namedError<CacheKeyNotFoundError>(\"CacheKeyNotFoundError\");\n\n/**\n * Thrown by {@link bootstrapCameraKit} if provided configuration is invalid.\n *\n * @category Bootstrapping and Configuration\n */\nexport type ConfigurationError = NamedError<\"ConfigurationError\">;\n/** @internal */\nexport const configurationError = namedError<ConfigurationError>(\"ConfigurationError\");\n\nexport type WebGLError = NamedError<\"WebGLError\">;\n/** @internal */\nexport const webGLError = namedError<WebGLError>(\"WebGLError\");\n\nexport type BenchmarkError = NamedError<\"BenchmarkError\">;\n/** @internal */\nexport const benchmarkError = namedError<BenchmarkError>(\"BenchmarkError\");\n\n/**\n * Thrown by {@link bootstrapCameraKit} when the current platform is not supported by CameraKit.\n *\n * This can happen if the browser doesn't support a required feature (e.g. WebGL).\n *\n * @category Bootstrapping and Configuration\n */\nexport type PlatformNotSupportedError = NamedError<\"PlatformNotSupportedError\">;\n/** @internal */\nexport const platformNotSupportedError = namedError<PlatformNotSupportedError>(\"PlatformNotSupportedError\");\n\n/**\n * This error occurs if a Lens is unable to continue rendering.\n *\n * If this error occurs, Camera Kit automatically removes the Lens from the session.\n * It's always a good idea to handle this error and update the user experience accordingly.\n * For example, you could remove the faulty Lens from your Lens selection UI.\n *\n * ```ts\n * cameraKitSession.events.addEventListener('error', ({ detail }) => {\n * if (detail.error.name === 'LensExecutionError') {\n * console.log(`Lens ${detail.lens.name} encountered an error and was removed. Please pick a different lens.`)\n * }\n * })\n * ```\n */\nexport type LensExecutionError = NamedError<\"LensExecutionError\">;\n/** @internal */\nexport const lensExecutionError = namedError<LensExecutionError>(\"LensExecutionError\");\n\n/**\n * This error occurs when a session becomes inoperable.\n *\n * It's always a good idea to handle this error and update the user experience accordingly.\n * For example, you could show a message to a user.\n *\n * ```ts\n * cameraKitSession.events.addEventListener('error', ({ detail }) => {\n * if (detail.error.name === 'LensAbortError') {\n * console.log(`Camera Kit encountered an unrecoverable error and became inoperable. Please refresh the page.`)\n * }\n * })\n * ```\n */\nexport type LensAbortError = NamedError<\"LensAbortError\">;\n/** @internal */\nexport const lensAbortError = namedError<LensAbortError>(\"LensAbortError\");\n\n/**\n * Error thrown when LensCore asked to store lens data, but CameraKit failed storing that.\n */\nexport type PersistentStoreError = NamedError<\"PersistentStoreError\">;\n/** @internal */\nexport const persistentStoreError = namedError<PersistentStoreError>(\"PersistentStoreError\");\n\n/**\n * Error thrown when LensCore asked to provide an asset, but CameraKit failed providing that.\n */\nexport type LensAssetError = NamedError<\"LensAssetError\">;\n/** @internal */\nexport const lensAssetError = namedError<LensAssetError>(\"LensAssetError\");\n\n/**\n * Thrown by {@link bootstrapCameraKit} if an error occurs during SDK initializion or while downloading the render\n * engine WebAssembly.\n *\n * @category Bootstrapping and Configuration\n */\nexport type BootstrapError = NamedError<\"BootstrapError\">;\n/** @internal */\nexport const bootstrapError = namedError<BootstrapError>(\"BootstrapError\");\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { getPlatformCapabilities } from "./platformCapabilities";
|
|
3
|
+
/**
|
|
4
|
+
* Throw if the current platform is not capable of running Camera Kit.
|
|
5
|
+
*/
|
|
6
|
+
export function assertPlatformSupported() {
|
|
7
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
8
|
+
const { wasm, webgl } = yield getPlatformCapabilities();
|
|
9
|
+
if (!wasm.supported)
|
|
10
|
+
throw wasm.error;
|
|
11
|
+
if (!webgl.supported)
|
|
12
|
+
throw webgl.error;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=assertPlatformSupported.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assertPlatformSupported.js","sourceRoot":"","sources":["../../src/platform/assertPlatformSupported.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEjE;;GAEG;AACH,MAAM,UAAgB,uBAAuB;;QACzC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,uBAAuB,EAAE,CAAC;QACxD,IAAI,CAAC,IAAI,CAAC,SAAS;YAAE,MAAM,IAAI,CAAC,KAAK,CAAC;QACtC,IAAI,CAAC,KAAK,CAAC,SAAS;YAAE,MAAM,KAAK,CAAC,KAAK,CAAC;IAC5C,CAAC;CAAA","sourcesContent":["import { getPlatformCapabilities } from \"./platformCapabilities\";\n\n/**\n * Throw if the current platform is not capable of running Camera Kit.\n */\nexport async function assertPlatformSupported(): Promise<void> {\n const { wasm, webgl } = await getPlatformCapabilities();\n if (!wasm.supported) throw wasm.error;\n if (!webgl.supported) throw webgl.error;\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { memoize } from "../common/memoize";
|
|
2
|
+
import { getConfigurationOverrides } from "../configurationOverrides";
|
|
3
|
+
import { getPlatformInfo } from "./platformInfo";
|
|
4
|
+
/** @internal */
|
|
5
|
+
export const getCameraKitUserAgent = memoize(function getCameraKitUserAgent() {
|
|
6
|
+
var _a;
|
|
7
|
+
const { browser, deviceModel, origin, osName, osVersion, sdkShortVersion, lensCore } = getPlatformInfo();
|
|
8
|
+
// Set this to `DEBUG` manually while testing / root-causing.
|
|
9
|
+
const { userAgentFlavor } = (_a = getConfigurationOverrides()) !== null && _a !== void 0 ? _a : { userAgentFlavor: "release" };
|
|
10
|
+
const flavor = userAgentFlavor === "release" ? "" : "DEBUG ";
|
|
11
|
+
// This full string is defined here:
|
|
12
|
+
// eslint-disable-next-line max-len
|
|
13
|
+
// https://github.sc-corp.net/Snapchat/useragent/blob/9333afe7cc6ac00503ad46cb234bcf94006dff98/java/useragent/src/main/java/snapchat/client/UserAgent.java#L124
|
|
14
|
+
return (`CameraKitWeb/${sdkShortVersion} ${flavor}(${deviceModel}; ${osName} ${osVersion}) ` +
|
|
15
|
+
`${browser.brand}/${browser.version} Core/${lensCore.version} ` +
|
|
16
|
+
// We overload appId, using the origin instead of the true appId parsed from the apiToken -- we do this because
|
|
17
|
+
// origin is human-readable, and this is used to populate the appId dimension in operational metrics.
|
|
18
|
+
`AppId/${origin}`);
|
|
19
|
+
});
|
|
20
|
+
//# sourceMappingURL=cameraKitUserAgent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cameraKitUserAgent.js","sourceRoot":"","sources":["../../src/platform/cameraKitUserAgent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,gBAAgB;AAChB,MAAM,CAAC,MAAM,qBAAqB,GAAG,OAAO,CAAC,SAAS,qBAAqB;;IACvE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,QAAQ,EAAE,GAAG,eAAe,EAAE,CAAC;IAEzG,6DAA6D;IAC7D,MAAM,EAAE,eAAe,EAAE,GAAG,MAAA,yBAAyB,EAAE,mCAAI,EAAE,eAAe,EAAE,SAAS,EAAE,CAAC;IAC1F,MAAM,MAAM,GAAkB,eAAe,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;IAE5E,oCAAoC;IACpC,mCAAmC;IACnC,+JAA+J;IAC/J,OAAO,CACH,gBAAgB,eAAe,IAAI,MAAM,IAAI,WAAW,KAAK,MAAM,IAAI,SAAS,IAAI;QACpF,GAAG,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,OAAO,SAAS,QAAQ,CAAC,OAAO,GAAG;QAC/D,+GAA+G;QAC/G,qGAAqG;QACrG,SAAS,MAAM,EAAE,CACpB,CAAC;AACN,CAAC,CAAC,CAAC","sourcesContent":["import { memoize } from \"../common/memoize\";\nimport { getConfigurationOverrides } from \"../configurationOverrides\";\nimport { getPlatformInfo } from \"./platformInfo\";\n\n/** @internal */\nexport const getCameraKitUserAgent = memoize(function getCameraKitUserAgent(): string {\n const { browser, deviceModel, origin, osName, osVersion, sdkShortVersion, lensCore } = getPlatformInfo();\n\n // Set this to `DEBUG` manually while testing / root-causing.\n const { userAgentFlavor } = getConfigurationOverrides() ?? { userAgentFlavor: \"release\" };\n const flavor: \"\" | \"DEBUG \" = userAgentFlavor === \"release\" ? \"\" : \"DEBUG \";\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 return (\n `CameraKitWeb/${sdkShortVersion} ${flavor}(${deviceModel}; ${osName} ${osVersion}) ` +\n `${browser.brand}/${browser.version} Core/${lensCore.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});\n"]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { XrCapabilities } from "../lens-core-module";
|
|
2
|
+
/** @internal */
|
|
3
|
+
export type SupportedCapability<T> = T & {
|
|
4
|
+
supported: true;
|
|
5
|
+
};
|
|
6
|
+
/** @internal */
|
|
7
|
+
export type UnsupportedCapability = {
|
|
8
|
+
supported: false;
|
|
9
|
+
error: Error;
|
|
10
|
+
};
|
|
11
|
+
/** @internal */
|
|
12
|
+
export type Capability<T = void> = SupportedCapability<T> | UnsupportedCapability;
|
|
13
|
+
type WebGlCapability = Capability<{
|
|
14
|
+
maxTextureSize: number;
|
|
15
|
+
}>;
|
|
16
|
+
type WasmCapability = Capability<{
|
|
17
|
+
wasmFeatures: number;
|
|
18
|
+
}>;
|
|
19
|
+
/**
|
|
20
|
+
* Because there may be a large number of WASM-related capabilities, and because these may correspond to various builds
|
|
21
|
+
* of LensCore, we encode the various WASM capabilities into a single number by bitwise OR-ing together the numbers
|
|
22
|
+
* corresponding to each capability.
|
|
23
|
+
*
|
|
24
|
+
* Since each combindation of capabilities is represented by a single number, we can easily map between that number and
|
|
25
|
+
* the corresponding LensCore build name that makes use of those capabilities.
|
|
26
|
+
*
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
export declare enum WasmFeatures {
|
|
30
|
+
Default = 0,
|
|
31
|
+
SIMD = 1,
|
|
32
|
+
ExceptionHandling = 2
|
|
33
|
+
}
|
|
34
|
+
type WebXrCapability = Capability<XrCapabilities>;
|
|
35
|
+
/** @internal */
|
|
36
|
+
export interface PlatformCapabilities {
|
|
37
|
+
webgl: WebGlCapability;
|
|
38
|
+
wasm: WasmCapability;
|
|
39
|
+
webxr: WebXrCapability;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Get information about the current platform capabilities, including:
|
|
43
|
+
* - WebGL support and various WebGL parameters.
|
|
44
|
+
* - WASM support and support for various WASM features.
|
|
45
|
+
* - WebXR support and support for various WebXR features.
|
|
46
|
+
*
|
|
47
|
+
* @internal
|
|
48
|
+
*/
|
|
49
|
+
export declare const getPlatformCapabilities: import("../common/memoize").Memoized<() => Promise<PlatformCapabilities>>;
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { exceptions, simd } from "wasm-feature-detect";
|
|
3
|
+
import { memoize } from "../common/memoize";
|
|
4
|
+
import { platformNotSupportedError } from "../namedErrors";
|
|
5
|
+
import { getPlatformInfo } from "./platformInfo";
|
|
6
|
+
// This required minimum max texture size is based on data from
|
|
7
|
+
// https://web3dsurvey.com/webgl/parameters/MAX_TEXTURE_SIZE. Checking for a reasonable minimum MAX_TEXTURE_SIZE avoids
|
|
8
|
+
// attempting to run lenses on platforms that will not support them -- most commonly, we've seen some platforms that
|
|
9
|
+
// report 0 MAX_TEXTURE_SIZE, which will cause errors for all lenses.
|
|
10
|
+
const minRequiredMaxTextureSize = 1024;
|
|
11
|
+
/**
|
|
12
|
+
* @returns An object with fields describing support for various WebGL features.
|
|
13
|
+
*
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
function getWebGlSupport() {
|
|
17
|
+
const ctx = document.createElement("canvas").getContext("webgl2");
|
|
18
|
+
if (!ctx)
|
|
19
|
+
return {
|
|
20
|
+
supported: false,
|
|
21
|
+
error: platformNotSupportedError("CameraKit requires WebGL2, but this browser does not support WebGL2."),
|
|
22
|
+
};
|
|
23
|
+
const maxTextureSize = ctx.getParameter(ctx.MAX_TEXTURE_SIZE);
|
|
24
|
+
const supported = maxTextureSize >= minRequiredMaxTextureSize;
|
|
25
|
+
return supported
|
|
26
|
+
? { supported, maxTextureSize }
|
|
27
|
+
: {
|
|
28
|
+
supported,
|
|
29
|
+
error: platformNotSupportedError(`CameraKit requires WebGL's MAX_TEXTURE_SIZE exceed a minimum value of ` +
|
|
30
|
+
`${minRequiredMaxTextureSize}, but the browser's reported MAX_TEXTURE_SIZE is ${maxTextureSize}.`),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Because there may be a large number of WASM-related capabilities, and because these may correspond to various builds
|
|
35
|
+
* of LensCore, we encode the various WASM capabilities into a single number by bitwise OR-ing together the numbers
|
|
36
|
+
* corresponding to each capability.
|
|
37
|
+
*
|
|
38
|
+
* Since each combindation of capabilities is represented by a single number, we can easily map between that number and
|
|
39
|
+
* the corresponding LensCore build name that makes use of those capabilities.
|
|
40
|
+
*
|
|
41
|
+
* @internal
|
|
42
|
+
*/
|
|
43
|
+
export var WasmFeatures;
|
|
44
|
+
(function (WasmFeatures) {
|
|
45
|
+
WasmFeatures[WasmFeatures["Default"] = 0] = "Default";
|
|
46
|
+
WasmFeatures[WasmFeatures["SIMD"] = 1] = "SIMD";
|
|
47
|
+
WasmFeatures[WasmFeatures["ExceptionHandling"] = 2] = "ExceptionHandling";
|
|
48
|
+
})(WasmFeatures || (WasmFeatures = {}));
|
|
49
|
+
/**
|
|
50
|
+
* @returns A non-negative integer representing the combination of supported WebAssembly features, or -1 if WebAssembly
|
|
51
|
+
* is not supported at all.
|
|
52
|
+
*
|
|
53
|
+
* @internal
|
|
54
|
+
*/
|
|
55
|
+
function getWebAssemblyCapabilities() {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
if (globalThis.WebAssembly === undefined)
|
|
58
|
+
return {
|
|
59
|
+
supported: false,
|
|
60
|
+
error: platformNotSupportedError("CameraKit requires WebAssembly, but this browser does not support WebAssembly."),
|
|
61
|
+
};
|
|
62
|
+
return {
|
|
63
|
+
supported: true,
|
|
64
|
+
wasmFeatures: (yield Promise.all([
|
|
65
|
+
simd().then((supported) => {
|
|
66
|
+
// Although Safari 16.4 reports SIMD support, LensCore encounters rendering bugs when using
|
|
67
|
+
// SIMD in Safari 16.4. We will disable SIMD for now until Safari stabilizes the feature.
|
|
68
|
+
if (getPlatformInfo().browser.brand === "Safari")
|
|
69
|
+
return WasmFeatures.Default;
|
|
70
|
+
return supported ? WasmFeatures.SIMD : WasmFeatures.Default;
|
|
71
|
+
}),
|
|
72
|
+
exceptions().then((supported) => (supported ? WasmFeatures.ExceptionHandling : WasmFeatures.Default)),
|
|
73
|
+
])).reduce((features, feature) => features | feature, WasmFeatures.Default),
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* @returns A Promise containing an object with fields describing the support of various WebXR features. This object's
|
|
79
|
+
* type is defined by LensCore, as they consume these capabilities and adjust behavior accordingly.
|
|
80
|
+
*
|
|
81
|
+
* @internal
|
|
82
|
+
*/
|
|
83
|
+
function getWebXrCapabilities() {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
const notSupported = {
|
|
86
|
+
supported: false,
|
|
87
|
+
error: platformNotSupportedError(`Use of this feature requires WebXR support for immersive AR sessions, but ` +
|
|
88
|
+
`this browser does not support immersive AR sessions.`),
|
|
89
|
+
};
|
|
90
|
+
if (!isSecureContext)
|
|
91
|
+
return notSupported;
|
|
92
|
+
if (!navigator.xr)
|
|
93
|
+
return notSupported;
|
|
94
|
+
const isImmersiveArSupported = yield navigator.xr.isSessionSupported("immersive-ar");
|
|
95
|
+
return isImmersiveArSupported
|
|
96
|
+
? {
|
|
97
|
+
supported: true,
|
|
98
|
+
sixDofSupported: true,
|
|
99
|
+
sceneDepthSupported: true,
|
|
100
|
+
}
|
|
101
|
+
: notSupported;
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Get information about the current platform capabilities, including:
|
|
106
|
+
* - WebGL support and various WebGL parameters.
|
|
107
|
+
* - WASM support and support for various WASM features.
|
|
108
|
+
* - WebXR support and support for various WebXR features.
|
|
109
|
+
*
|
|
110
|
+
* @internal
|
|
111
|
+
*/
|
|
112
|
+
export const getPlatformCapabilities = memoize(function getPlatformCapabilities() {
|
|
113
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
114
|
+
return {
|
|
115
|
+
webgl: getWebGlSupport(),
|
|
116
|
+
wasm: yield getWebAssemblyCapabilities(),
|
|
117
|
+
webxr: yield getWebXrCapabilities(),
|
|
118
|
+
};
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
//# sourceMappingURL=platformCapabilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platformCapabilities.js","sourceRoot":"","sources":["../../src/platform/platformCapabilities.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CA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C,SAAe,uBAAuB;;QACjF,OAAO;YACH,KAAK,EAAE,eAAe,EAAE;YACxB,IAAI,EAAE,MAAM,0BAA0B,EAAE;YACxC,KAAK,EAAE,MAAM,oBAAoB,EAAE;SACtC,CAAC;IACN,CAAC;CAAA,CAAC,CAAC","sourcesContent":["import { exceptions, simd } from \"wasm-feature-detect\";\nimport { memoize } from \"../common/memoize\";\nimport { XrCapabilities } from \"../lens-core-module\";\nimport { platformNotSupportedError } from \"../namedErrors\";\nimport { getPlatformInfo } from \"./platformInfo\";\n\n/** @internal */\nexport type SupportedCapability<T> = T & { supported: true };\n/** @internal */\nexport type UnsupportedCapability = { supported: false; error: Error };\n/** @internal */\nexport type Capability<T = void> = SupportedCapability<T> | UnsupportedCapability;\n\n//-----------\n// WebGL\n//-----------\n\ntype WebGlCapability = Capability<{ maxTextureSize: number }>;\n\n// This required minimum max texture size is based on data from\n// https://web3dsurvey.com/webgl/parameters/MAX_TEXTURE_SIZE. Checking for a reasonable minimum MAX_TEXTURE_SIZE avoids\n// attempting to run lenses on platforms that will not support them -- most commonly, we've seen some platforms that\n// report 0 MAX_TEXTURE_SIZE, which will cause errors for all lenses.\nconst minRequiredMaxTextureSize = 1024;\n\n/**\n * @returns An object with fields describing support for various WebGL features.\n *\n * @internal\n */\nfunction getWebGlSupport(): WebGlCapability {\n const ctx = document.createElement(\"canvas\").getContext(\"webgl2\");\n if (!ctx)\n return {\n supported: false,\n error: platformNotSupportedError(\"CameraKit requires WebGL2, but this browser does not support WebGL2.\"),\n };\n const maxTextureSize = ctx.getParameter(ctx.MAX_TEXTURE_SIZE);\n const supported = maxTextureSize >= minRequiredMaxTextureSize;\n return supported\n ? { supported, maxTextureSize }\n : {\n supported,\n error: platformNotSupportedError(\n `CameraKit requires WebGL's MAX_TEXTURE_SIZE exceed a minimum value of ` +\n `${minRequiredMaxTextureSize}, but the browser's reported MAX_TEXTURE_SIZE is ${maxTextureSize}.`\n ),\n };\n}\n\n//-----------\n// WASM\n//-----------\n\ntype WasmCapability = Capability<{ wasmFeatures: number }>;\n\n/**\n * Because there may be a large number of WASM-related capabilities, and because these may correspond to various builds\n * of LensCore, we encode the various WASM capabilities into a single number by bitwise OR-ing together the numbers\n * corresponding to each capability.\n *\n * Since each combindation of capabilities is represented by a single number, we can easily map between that number and\n * the corresponding LensCore build name that makes use of those capabilities.\n *\n * @internal\n */\nexport enum WasmFeatures {\n Default = 0b00000000,\n SIMD = 0b00000001,\n ExceptionHandling = 0b00000010,\n}\n\n/**\n * @returns A non-negative integer representing the combination of supported WebAssembly features, or -1 if WebAssembly\n * is not supported at all.\n *\n * @internal\n */\nasync function getWebAssemblyCapabilities(): Promise<WasmCapability> {\n if (globalThis.WebAssembly === undefined)\n return {\n supported: false,\n error: platformNotSupportedError(\n \"CameraKit requires WebAssembly, but this browser does not support WebAssembly.\"\n ),\n };\n return {\n supported: true,\n wasmFeatures: (\n await Promise.all([\n simd().then((supported) => {\n // Although Safari 16.4 reports SIMD support, LensCore encounters rendering bugs when using\n // SIMD in Safari 16.4. We will disable SIMD for now until Safari stabilizes the feature.\n if (getPlatformInfo().browser.brand === \"Safari\") return WasmFeatures.Default;\n return supported ? WasmFeatures.SIMD : WasmFeatures.Default;\n }),\n exceptions().then((supported) => (supported ? WasmFeatures.ExceptionHandling : WasmFeatures.Default)),\n ])\n ).reduce((features, feature) => features | feature, WasmFeatures.Default),\n };\n}\n\n//-----------\n// WebXR\n//-----------\n\ntype WebXrCapability = Capability<XrCapabilities>;\n\n/**\n * @returns A Promise containing an object with fields describing the support of various WebXR features. This object's\n * type is defined by LensCore, as they consume these capabilities and adjust behavior accordingly.\n *\n * @internal\n */\nasync function getWebXrCapabilities(): Promise<WebXrCapability> {\n const notSupported: WebXrCapability = {\n supported: false,\n error: platformNotSupportedError(\n `Use of this feature requires WebXR support for immersive AR sessions, but ` +\n `this browser does not support immersive AR sessions.`\n ),\n };\n if (!isSecureContext) return notSupported;\n if (!navigator.xr) return notSupported;\n const isImmersiveArSupported = await navigator.xr.isSessionSupported(\"immersive-ar\");\n return isImmersiveArSupported\n ? {\n supported: true,\n sixDofSupported: true,\n sceneDepthSupported: true,\n }\n : notSupported;\n}\n\n/** @internal */\nexport interface PlatformCapabilities {\n webgl: WebGlCapability;\n wasm: WasmCapability;\n webxr: WebXrCapability;\n}\n\n/**\n * Get information about the current platform capabilities, including:\n * - WebGL support and various WebGL parameters.\n * - WASM support and support for various WASM features.\n * - WebXR support and support for various WebXR features.\n *\n * @internal\n */\nexport const getPlatformCapabilities = memoize(async function getPlatformCapabilities(): Promise<PlatformCapabilities> {\n return {\n webgl: getWebGlSupport(),\n wasm: await getWebAssemblyCapabilities(),\n webxr: await getWebXrCapabilities(),\n };\n});\n"]}
|
|
@@ -17,23 +17,26 @@ declare global {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
/** @internal */
|
|
20
|
-
export interface
|
|
21
|
-
osType: string;
|
|
22
|
-
osVersion: string;
|
|
23
|
-
locale: string;
|
|
20
|
+
export interface PlatformInfo {
|
|
24
21
|
sdkShortVersion: string;
|
|
25
22
|
sdkLongVersion: string;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
lensCore: {
|
|
24
|
+
version: string;
|
|
25
|
+
buildNumber: string;
|
|
26
|
+
baseUrl: string;
|
|
27
|
+
};
|
|
29
28
|
browser: {
|
|
30
29
|
brand: string;
|
|
31
30
|
version: string;
|
|
32
31
|
};
|
|
32
|
+
osName: string;
|
|
33
|
+
osVersion: string;
|
|
34
|
+
deviceModel: string;
|
|
35
|
+
locale: string;
|
|
36
|
+
fullLocale: string;
|
|
33
37
|
origin: string;
|
|
34
|
-
|
|
35
|
-
connectionType: ConnectionType | undefined;
|
|
38
|
+
connectionType: ConnectionType;
|
|
36
39
|
}
|
|
37
40
|
/** @internal */
|
|
38
|
-
export declare const
|
|
41
|
+
export declare const getPlatformInfo: import("../common/memoize").Memoized<() => PlatformInfo>;
|
|
39
42
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { memoize } from "../common/memoize";
|
|
2
|
+
import { isRecord } from "../common/typeguards";
|
|
1
3
|
import environment from "../environment.json";
|
|
2
4
|
import lensCoreWasm from "../lensCoreWasmVersions.json";
|
|
3
|
-
import { locale } from "./locale";
|
|
4
|
-
import { isRecord } from "./typeguards";
|
|
5
5
|
/**
|
|
6
6
|
* Some user agents may not properly implement the NavigatorUAData interface, so we have to do our own validation here
|
|
7
7
|
* to make sure we're dealing with a well-formed value.
|
|
@@ -16,7 +16,66 @@ function isNavigatorUAData(value) {
|
|
|
16
16
|
typeof value["platform"] === "string");
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* In the future, we may invest in more robust device-detection (e.g. a UA string database), but for now this will give
|
|
20
|
+
* us some sense of device usage.
|
|
21
|
+
*/
|
|
22
|
+
function parseDeviceModel(userAgent) {
|
|
23
|
+
// from user agent like "(Linux; Android 11; Pixel 2)" extact "Pixel 2"
|
|
24
|
+
const userAgentWithModel = userAgent.match(/;[^;]+?;([^\)]+?)\)/);
|
|
25
|
+
if (userAgentWithModel) {
|
|
26
|
+
return userAgentWithModel[1].trim();
|
|
27
|
+
}
|
|
28
|
+
// from user agent like "... (iPad; CPU OS 15_1 like Mac OS X) ..." extract "IPad"
|
|
29
|
+
const userAgentWithModel2 = userAgent.match(/\(([^;]+);/);
|
|
30
|
+
if (userAgentWithModel2) {
|
|
31
|
+
return userAgentWithModel2[1].trim();
|
|
32
|
+
}
|
|
33
|
+
return "unknown";
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The origin may be useful to identify the running application (e.g. to attribute metrics).
|
|
37
|
+
*
|
|
38
|
+
* We need to handle cases in which we run inside a child browsing context (e.g. an iframe), which may not have a
|
|
39
|
+
* hostname – in this case we'll check each ancestor context until we find a valid hostname.
|
|
40
|
+
*/
|
|
41
|
+
function parseOrigin() {
|
|
42
|
+
var _a, _b, _c;
|
|
43
|
+
if (location.hostname !== "")
|
|
44
|
+
return location.hostname;
|
|
45
|
+
// Firefox does not implement ancestorOrigins, so we need a fallback.
|
|
46
|
+
// Context here: https://github.com/whatwg/html/issues/1918
|
|
47
|
+
const possibleOrigins = location.ancestorOrigins === undefined && typeof window !== "undefined"
|
|
48
|
+
? [window.parent.origin, (_b = (_a = window.top) === null || _a === void 0 ? void 0 : _a.origin) !== null && _b !== void 0 ? _b : ""]
|
|
49
|
+
: (_c = location.ancestorOrigins) !== null && _c !== void 0 ? _c : [];
|
|
50
|
+
for (let origin of possibleOrigins) {
|
|
51
|
+
try {
|
|
52
|
+
origin = new URL(origin).hostname;
|
|
53
|
+
if (origin)
|
|
54
|
+
return origin;
|
|
55
|
+
}
|
|
56
|
+
catch (_) { }
|
|
57
|
+
}
|
|
58
|
+
return "unknown";
|
|
59
|
+
}
|
|
60
|
+
function parseOSName(userAgent) {
|
|
61
|
+
const knownPlatforms = new Map([
|
|
62
|
+
["android", "android"],
|
|
63
|
+
["linux", "linux"],
|
|
64
|
+
["iphone os", "ios"],
|
|
65
|
+
["ipad", "ipados"],
|
|
66
|
+
["mac os", "macos"],
|
|
67
|
+
["macos", "macos"],
|
|
68
|
+
["windows", "windows"],
|
|
69
|
+
]);
|
|
70
|
+
const normalizedUserAgent = userAgent.toLowerCase();
|
|
71
|
+
for (const [match, platform] of knownPlatforms.entries()) {
|
|
72
|
+
if (normalizedUserAgent.includes(match))
|
|
73
|
+
return platform;
|
|
74
|
+
}
|
|
75
|
+
return "unknown";
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Parse the OS (a.k.a. platform) version.
|
|
20
79
|
*
|
|
21
80
|
* From limited testing, this seems to often produce incorrect results – the userAgent string does not typically include
|
|
22
81
|
* the actual OS version.
|
|
@@ -28,7 +87,7 @@ function isNavigatorUAData(value) {
|
|
|
28
87
|
*
|
|
29
88
|
* So, at least for now, we'll be satisfied with the incorrect version number.
|
|
30
89
|
*/
|
|
31
|
-
function
|
|
90
|
+
function parseOSVersion(userAgent) {
|
|
32
91
|
// possible platform version values inside of user agent string
|
|
33
92
|
// " 11;"
|
|
34
93
|
// " 10_15_7)"
|
|
@@ -41,23 +100,6 @@ function parsePlatformVersion(userAgent) {
|
|
|
41
100
|
}
|
|
42
101
|
return "";
|
|
43
102
|
}
|
|
44
|
-
/**
|
|
45
|
-
* In the future, we may invest in more robust device-detection (e.g. a UA string database), but for now this will give
|
|
46
|
-
* us some sense of device usage.
|
|
47
|
-
*/
|
|
48
|
-
function parseDeviceModel(userAgent) {
|
|
49
|
-
// from user agent like "(Linux; Android 11; Pixel 2)" extact "Pixel 2"
|
|
50
|
-
const userAgentWithModel = userAgent.match(/;[^;]+?;([^\)]+?)\)/);
|
|
51
|
-
if (userAgentWithModel) {
|
|
52
|
-
return userAgentWithModel[1].trim();
|
|
53
|
-
}
|
|
54
|
-
// from user agent like "... (iPad; CPU OS 15_1 like Mac OS X) ..." extract "IPad"
|
|
55
|
-
const userAgentWithModel2 = userAgent.match(/\(([^;]+);/);
|
|
56
|
-
if (userAgentWithModel2) {
|
|
57
|
-
return userAgentWithModel2[1].trim();
|
|
58
|
-
}
|
|
59
|
-
return "unknown";
|
|
60
|
-
}
|
|
61
103
|
/**
|
|
62
104
|
* Some browsers (e.g. Safari) do not support the `Navigator.userAgentData` API. We'll attempt a sort of polyfill by
|
|
63
105
|
* parsing the data found in [NavigatorUAData](https://developer.mozilla.org/en-US/docs/Web/API/NavigatorUAData) from
|
|
@@ -96,7 +138,7 @@ function parseUserAgentData(userAgent) {
|
|
|
96
138
|
// We'll set it to false, but this should not be used – instead, we'll need to rely on more sophisticated methods
|
|
97
139
|
// (e.g. a userAgent database) to determine actual device.
|
|
98
140
|
const mobile = false;
|
|
99
|
-
const platform =
|
|
141
|
+
const platform = parseOSName(userAgent);
|
|
100
142
|
return {
|
|
101
143
|
brands: [brand],
|
|
102
144
|
mobile,
|
|
@@ -105,6 +147,7 @@ function parseUserAgentData(userAgent) {
|
|
|
105
147
|
}
|
|
106
148
|
function normalizeBrands(brands) {
|
|
107
149
|
const knownBrands = new Map([
|
|
150
|
+
["Google Chrome", "Chrome"],
|
|
108
151
|
["Chrome", "Chrome"],
|
|
109
152
|
["Chromium", "Chrome"],
|
|
110
153
|
["Firefox", "Firefox"],
|
|
@@ -139,96 +182,47 @@ function normalizeUserAgentData(userAgentData) {
|
|
|
139
182
|
return {
|
|
140
183
|
brands: normalizeBrands(userAgentData.brands),
|
|
141
184
|
mobile: userAgentData.mobile,
|
|
142
|
-
platform:
|
|
185
|
+
platform: parseOSName(userAgentData.platform),
|
|
143
186
|
};
|
|
144
187
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
["android", "android"],
|
|
148
|
-
["linux", "linux"],
|
|
149
|
-
["iphone os", "ios"],
|
|
150
|
-
["ipad", "ipados"],
|
|
151
|
-
["mac os", "macos"],
|
|
152
|
-
["macos", "macos"],
|
|
153
|
-
["windows", "windows"],
|
|
154
|
-
]);
|
|
155
|
-
const normalizedUserAgent = userAgent.toLowerCase();
|
|
156
|
-
for (const [match, platform] of knownPlatforms.entries()) {
|
|
157
|
-
if (normalizedUserAgent.includes(match))
|
|
158
|
-
return platform;
|
|
159
|
-
}
|
|
160
|
-
return "unknown";
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* We'll use the application's origin as an identifier – this isn't used for any kind of authentication, but it may be
|
|
164
|
-
* useful metadata to have in the future.
|
|
165
|
-
*
|
|
166
|
-
* We also need to handle cases in which the SDK is used in a child browsing context (e.g. an iframe), which may not
|
|
167
|
-
* have a hostname – in this case we'll check each ancestor context until we find a valid hostname.
|
|
168
|
-
*/
|
|
169
|
-
function parseApplicationOrigin() {
|
|
188
|
+
/** @internal */
|
|
189
|
+
export const getPlatformInfo = memoize(function getPlatformIno() {
|
|
170
190
|
var _a, _b, _c;
|
|
171
|
-
let origin = location.hostname;
|
|
172
|
-
// Firefox does not implement ancestorOrigins, so we need a fallback.
|
|
173
|
-
// Context here: https://github.com/whatwg/html/issues/1918
|
|
174
|
-
const ancestorOrigins = location.ancestorOrigins === undefined
|
|
175
|
-
? typeof window !== "undefined"
|
|
176
|
-
? [window.parent.origin, (_b = (_a = window.top) === null || _a === void 0 ? void 0 : _a.origin) !== null && _b !== void 0 ? _b : ""]
|
|
177
|
-
: []
|
|
178
|
-
: Array.from((_c = location.ancestorOrigins) !== null && _c !== void 0 ? _c : []);
|
|
179
|
-
while (origin === "" && ancestorOrigins.length > 0) {
|
|
180
|
-
// Safety: ancestorOrigins must contain at least one element, so shift() will always be defined.
|
|
181
|
-
origin = new URL(ancestorOrigins.shift()).hostname;
|
|
182
|
-
}
|
|
183
|
-
return origin;
|
|
184
|
-
}
|
|
185
|
-
function getCameraKitUserAgent() {
|
|
186
|
-
var _a, _b;
|
|
187
|
-
const userAgent = (_a = navigator.userAgent) !== null && _a !== void 0 ? _a : "";
|
|
188
191
|
// [NavigatorUAData](https://developer.mozilla.org/en-US/docs/Web/API/NavigatorUAData) is currently only
|
|
189
192
|
// available on Chromium-based browsers – it's nice because it gives us clear, well-documented information. But
|
|
190
193
|
// we'll have to fallback to parsing the userAgent string when it's not available.
|
|
194
|
+
const userAgent = navigator.userAgent;
|
|
191
195
|
const userAgentData = isNavigatorUAData(navigator.userAgentData)
|
|
192
196
|
? normalizeUserAgentData(navigator.userAgentData)
|
|
193
197
|
: parseUserAgentData(userAgent);
|
|
194
|
-
const
|
|
198
|
+
const osVersion = parseOSVersion(userAgent);
|
|
195
199
|
const deviceModel = parseDeviceModel(userAgent);
|
|
196
|
-
// In cases where we've parsed the userAgent string to find the brand, there will only ever be a single brand –
|
|
197
|
-
// in browsers which support NavigatorUAData there could be more than one (e.g. Chrome and Chromium), but they
|
|
198
|
-
// should be equivalent for our purposes.
|
|
199
|
-
const browser = userAgentData.brands[0];
|
|
200
|
-
const origin = parseApplicationOrigin();
|
|
201
|
-
const sdkLongVersion = environment.PACKAGE_VERSION;
|
|
202
200
|
// Remove any `-prerelease` or `+buildmetadata` portions from the semver string.
|
|
203
|
-
const sdkShortVersion =
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
//
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
`${
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
`Core/${lensCoreWasm.version} ` +
|
|
214
|
-
// We overload appId, using the origin instead of the true appId parsed from the apiToken -- we do this because
|
|
215
|
-
// origin is human-readable, and this is used to populate the appId dimension in operational metrics.
|
|
216
|
-
`AppId/${origin}`;
|
|
201
|
+
const sdkShortVersion = environment.PACKAGE_VERSION.replace(/[-+]\S+$/, "");
|
|
202
|
+
const locale = navigator.language;
|
|
203
|
+
// The full locale string includes all the languages with qvalues -- this is needed for some API calls.
|
|
204
|
+
// More on qvalues: https://developer.mozilla.org/en-US/docs/Glossary/Quality_values
|
|
205
|
+
const fullLocale = ((_a = navigator.languages) !== null && _a !== void 0 ? _a : [])
|
|
206
|
+
.map((lang, index) => {
|
|
207
|
+
const qvalue = Math.max(0, (10 - index) / 10);
|
|
208
|
+
return `${lang};q=${qvalue.toFixed(1)}`;
|
|
209
|
+
})
|
|
210
|
+
.join(", ") || locale;
|
|
217
211
|
return {
|
|
218
|
-
osType: userAgentData.platform,
|
|
219
|
-
osVersion: platformVersion,
|
|
220
|
-
locale,
|
|
221
212
|
sdkShortVersion,
|
|
222
|
-
sdkLongVersion,
|
|
223
|
-
|
|
224
|
-
|
|
213
|
+
sdkLongVersion: environment.PACKAGE_VERSION,
|
|
214
|
+
lensCore: lensCoreWasm,
|
|
215
|
+
// In cases where we've parsed the userAgent string to find the brand, there will only ever be a single brand –
|
|
216
|
+
// in browsers which support NavigatorUAData there could be more than one (e.g. Chrome and Chromium), but they
|
|
217
|
+
// should be equivalent for our purposes -- either way we're okay just picking the first one.
|
|
218
|
+
browser: userAgentData.brands[0],
|
|
219
|
+
osName: userAgentData.platform,
|
|
220
|
+
osVersion,
|
|
225
221
|
deviceModel,
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
connectionType: (_b = navigator.connection) === null || _b === void 0 ? void 0 : _b.type,
|
|
222
|
+
locale,
|
|
223
|
+
fullLocale,
|
|
224
|
+
origin: parseOrigin(),
|
|
225
|
+
connectionType: (_c = (_b = navigator.connection) === null || _b === void 0 ? void 0 : _b.type) !== null && _c !== void 0 ? _c : "unknown",
|
|
230
226
|
};
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
export const cameraKitUserAgent = getCameraKitUserAgent();
|
|
234
|
-
//# sourceMappingURL=cameraKitUserAgent.js.map
|
|
227
|
+
});
|
|
228
|
+
//# sourceMappingURL=platformInfo.js.map
|