@snap/camera-kit 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -15
- package/docs/html/assets/search.js +1 -1
- package/docs/html/classes/CameraKit.html +5 -3
- package/docs/html/classes/CameraKitSession.html +5 -4
- package/docs/html/classes/CameraKitSource.html +5 -3
- package/docs/html/classes/LensPerformanceMeasurement.html +5 -3
- package/docs/html/classes/LensPerformanceMetrics.html +5 -3
- package/docs/html/classes/LensRepository.html +5 -3
- package/docs/html/classes/LensSources.html +5 -3
- package/docs/html/classes/Transform2D.html +5 -3
- package/docs/html/classes/TypedCustomEvent.html +5 -3
- package/docs/html/classes/TypedEventTarget.html +5 -3
- package/docs/html/functions/Injectable.html +5 -3
- package/docs/html/functions/bootstrapCameraKit.html +5 -3
- package/docs/html/functions/createExtension.html +5 -3
- package/docs/html/functions/createImageSource.html +5 -3
- package/docs/html/functions/createMediaStreamSource.html +6 -4
- package/docs/html/functions/createUserMediaSource.html +9 -3
- package/docs/html/functions/createVideoSource.html +5 -3
- package/docs/html/functions/estimateLensPerformance.html +5 -3
- package/docs/html/functions/getRequiredBootstrapURLs.html +5 -3
- package/docs/html/functions/lensSourcesFactory.html +5 -3
- package/docs/html/functions/uriHandlersFactory.html +5 -3
- package/docs/html/index.html +11 -9
- package/docs/html/interfaces/CameraKitBootstrapConfiguration.html +5 -3
- package/docs/html/interfaces/CameraKitSourceSubscriber.html +5 -3
- package/docs/html/interfaces/ComputedFrameMetrics.html +5 -3
- package/docs/html/interfaces/CreateSessionOptions.html +5 -3
- package/docs/html/interfaces/EstimatedLensPerformance.html +5 -3
- package/docs/html/interfaces/Lens.html +16 -6
- package/docs/html/interfaces/LensSource.html +5 -3
- package/docs/html/interfaces/MediaStreamSourceOptions.html +5 -3
- package/docs/html/interfaces/Preview.html +133 -0
- package/docs/html/interfaces/Snapcode.html +140 -0
- package/docs/html/interfaces/UriCancelRequest.html +5 -3
- package/docs/html/interfaces/UriHandler.html +5 -3
- package/docs/html/interfaces/UriRequest.html +5 -3
- package/docs/html/interfaces/UriResponse.html +5 -3
- package/docs/html/interfaces/VideoSourceOptions.html +5 -3
- package/docs/html/modules.html +8 -4
- package/docs/html/types/AssetLoader.html +5 -3
- package/docs/html/types/AssetTiming.html +5 -3
- package/docs/html/types/BenchmarkError.html +5 -3
- package/docs/html/types/BootstrapError.html +5 -3
- package/docs/html/types/CacheKeyNotFoundError.html +5 -3
- package/docs/html/types/CameraKitDeviceInfo.html +5 -3
- package/docs/html/types/CameraKitSessionEventListener.html +5 -3
- package/docs/html/types/CameraKitSessionEvents.html +5 -3
- package/docs/html/types/CameraKitSourceError.html +5 -3
- package/docs/html/types/CameraKitSourceInfo.html +5 -3
- package/docs/html/types/CameraKitSourceOptions.html +5 -3
- package/docs/html/types/ConfigurationError.html +5 -3
- package/docs/html/types/Keyboard.html +5 -3
- package/docs/html/types/KeyboardEvents.html +5 -3
- package/docs/html/types/LegalError.html +5 -3
- package/docs/html/types/LensAssetError.html +5 -3
- package/docs/html/types/LensContentValidationError.html +5 -3
- package/docs/html/types/LensError.html +5 -3
- package/docs/html/types/LensExecutionError.html +5 -3
- package/docs/html/types/LensImagePickerError.html +5 -3
- package/docs/html/types/LensLaunchParams.html +5 -3
- package/docs/html/types/LensMetricsEvents.html +5 -3
- package/docs/html/types/LensPerformanceCluster.html +5 -3
- package/docs/html/types/LensView.html +5 -3
- package/docs/html/types/LensWait.html +5 -3
- package/docs/html/types/PersistentStoreError.html +5 -3
- package/docs/html/types/PlatformNotSupportedError.html +5 -3
- package/docs/html/types/PublicContainer.html +5 -3
- package/docs/html/types/RenderTarget.html +5 -3
- package/docs/html/types/Uri.html +5 -3
- package/docs/html/types/UriHandlers.html +5 -3
- package/docs/html/types/WebGLError.html +5 -3
- package/docs/html/variables/extensionRequestContext.html +5 -3
- package/docs/md/README.md +18 -15
- package/docs/md/classes/CameraKit.md +1 -1
- package/docs/md/classes/CameraKitSession.md +1 -2
- 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 +1 -1
- package/docs/md/classes/LensSources.md +1 -1
- package/docs/md/classes/Transform2D.md +1 -1
- package/docs/md/classes/TypedCustomEvent.md +1 -1
- package/docs/md/classes/TypedEventTarget.md +1 -1
- package/docs/md/interfaces/CameraKitBootstrapConfiguration.md +1 -1
- package/docs/md/interfaces/CameraKitSourceSubscriber.md +1 -1
- package/docs/md/interfaces/ComputedFrameMetrics.md +1 -1
- package/docs/md/interfaces/CreateSessionOptions.md +1 -1
- package/docs/md/interfaces/EstimatedLensPerformance.md +1 -1
- package/docs/md/interfaces/Lens.md +14 -3
- package/docs/md/interfaces/LensSource.md +1 -1
- package/docs/md/interfaces/MediaStreamSourceOptions.md +1 -1
- package/docs/md/interfaces/Preview.md +19 -0
- package/docs/md/interfaces/Snapcode.md +28 -0
- package/docs/md/interfaces/UriCancelRequest.md +1 -1
- package/docs/md/interfaces/UriHandler.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 +11 -3
- package/lib/CameraKit.d.ts +10 -6
- package/lib/CameraKit.js +2 -1
- package/lib/CameraKit.js.map +1 -1
- package/lib/__tests__/data.js +9 -1
- package/lib/__tests__/data.js.map +1 -1
- package/lib/assertPlatformSupported.js +1 -1
- package/lib/assertPlatformSupported.js.map +1 -1
- package/lib/benchmark/webglUtils.js +2 -2
- package/lib/benchmark/webglUtils.js.map +1 -1
- package/lib/bootstrapCameraKit.js +4 -2
- package/lib/bootstrapCameraKit.js.map +1 -1
- package/lib/common/validate.js +2 -2
- package/lib/common/validate.js.map +1 -1
- package/lib/dependency-injection/RootServices.d.ts +2 -0
- package/lib/dependency-injection/RootServices.js.map +1 -1
- package/lib/environment.json +1 -1
- package/lib/events/scan.js +1 -1
- package/lib/events/scan.js.map +1 -1
- package/lib/generated-proto/pb_schema/camera_kit/v3/business_events.d.ts +17 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/business_events.js +63 -1
- package/lib/generated-proto/pb_schema/camera_kit/v3/business_events.js.map +1 -1
- package/lib/generated-proto/pb_schema/camera_kit/v3/export.d.ts +38 -1
- package/lib/generated-proto/pb_schema/camera_kit/v3/lens.d.ts +64 -3
- package/lib/generated-proto/pb_schema/camera_kit/v3/lens.js +70 -2
- package/lib/generated-proto/pb_schema/camera_kit/v3/lens.js.map +1 -1
- package/lib/generated-proto/pb_schema/camera_kit/v3/service.d.ts +457 -3
- package/lib/generated-proto/pb_schema/camera_kit/v3/service.js +109 -3
- package/lib/generated-proto/pb_schema/camera_kit/v3/service.js.map +1 -1
- package/lib/generated-proto/pb_schema/cdp/cof/circumstance_service.d.ts +1339 -1852
- package/lib/generated-proto/pb_schema/cdp/cof/circumstance_service.js +55 -132
- package/lib/generated-proto/pb_schema/cdp/cof/circumstance_service.js.map +1 -1
- package/lib/generated-proto/pb_schema/cdp/cof/config_request.d.ts +8 -1
- package/lib/generated-proto/pb_schema/cdp/cof/config_request.js.map +1 -1
- package/lib/generated-proto/pb_schema/cdp/cof/config_response.d.ts +181 -0
- package/lib/generated-proto/pb_schema/cdp/cof/config_result.d.ts +406 -0
- package/lib/generated-proto/pb_schema/cdp/cof/config_result.js +42 -0
- package/lib/generated-proto/pb_schema/cdp/cof/config_result.js.map +1 -1
- package/lib/generated-proto/pb_schema/common/ruid.d.ts +2 -0
- package/lib/generated-proto/pb_schema/common/ruid.js +2 -0
- package/lib/generated-proto/pb_schema/common/ruid.js.map +1 -1
- package/lib/generated-proto/pb_schema/common/value.d.ts +22 -0
- package/lib/generated-proto/pb_schema/common/value.js +45 -0
- package/lib/generated-proto/pb_schema/common/value.js.map +1 -1
- package/lib/generated-proto/pb_schema/lenses/launchdata.d.ts +2 -0
- package/lib/generated-proto/pb_schema/lenses/launchdata.js +12 -0
- package/lib/generated-proto/pb_schema/lenses/launchdata.js.map +1 -1
- package/lib/handlers/HandlerChainBuilder.d.ts +15 -0
- package/lib/handlers/HandlerChainBuilder.js +8 -1
- package/lib/handlers/HandlerChainBuilder.js.map +1 -1
- package/lib/handlers/requestStateEmittingHandler.d.ts +18 -5
- package/lib/handlers/requestStateEmittingHandler.js +12 -8
- package/lib/handlers/requestStateEmittingHandler.js.map +1 -1
- package/lib/handlers/responseCachingHandler.d.ts +10 -2
- package/lib/handlers/responseCachingHandler.js +13 -4
- package/lib/handlers/responseCachingHandler.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js.map +1 -1
- package/lib/lens/Lens.d.ts +32 -3
- package/lib/lens/Lens.js +10 -3
- package/lib/lens/Lens.js.map +1 -1
- package/lib/lens/LensLaunchParams.js +6 -4
- package/lib/lens/LensLaunchParams.js.map +1 -1
- package/lib/lens/LensPersistenceStore.js +1 -1
- package/lib/lens/LensPersistenceStore.js.map +1 -1
- package/lib/lens/LensRepository.d.ts +3 -2
- package/lib/lens/LensRepository.js +6 -5
- package/lib/lens/LensRepository.js.map +1 -1
- package/lib/lens/assets/LensAssetRepository.d.ts +5 -3
- package/lib/lens/assets/LensAssetRepository.js +21 -12
- package/lib/lens/assets/LensAssetRepository.js.map +1 -1
- package/lib/lens/assets/LensAssetsProvider.js +1 -1
- package/lib/lens/assets/LensAssetsProvider.js.map +1 -1
- package/lib/lens/lensEnvelopeUtil.js +1 -1
- package/lib/lens/lensEnvelopeUtil.js.map +1 -1
- package/lib/lens-client-interface/imagePicker.js +2 -2
- package/lib/lens-client-interface/imagePicker.js.map +1 -1
- package/lib/lens-client-interface/lensClientInterface.js +1 -1
- package/lib/lens-client-interface/lensClientInterface.js.map +1 -1
- package/lib/lens-core-module/loader/lensCoreFactory.js +1 -1
- package/lib/lens-core-module/loader/lensCoreFactory.js.map +1 -1
- package/lib/lensCoreWasmVersions.json +3 -3
- package/lib/media-sources/FunctionSource.js +1 -1
- package/lib/media-sources/FunctionSource.js.map +1 -1
- package/lib/media-sources/MediaStreamSource.d.ts +5 -1
- package/lib/media-sources/MediaStreamSource.js +30 -6
- package/lib/media-sources/MediaStreamSource.js.map +1 -1
- package/lib/metrics/reporters/reportHttpMetrics.d.ts +3 -3
- package/lib/metrics/reporters/reportHttpMetrics.js +2 -2
- package/lib/metrics/reporters/reportHttpMetrics.js.map +1 -1
- package/lib/metrics/reporters/reportLensAndAssetDownload.d.ts +3 -3
- package/lib/metrics/reporters/reportLensAndAssetDownload.js +6 -2
- package/lib/metrics/reporters/reportLensAndAssetDownload.js.map +1 -1
- package/lib/metrics/reporters/reporters.d.ts +3 -2
- package/lib/remote-configuration/cofHandler.d.ts +4 -1
- package/lib/remote-configuration/cofHandler.js +10 -6
- package/lib/remote-configuration/cofHandler.js.map +1 -1
- package/lib/remote-configuration/remoteConfiguration.d.ts +5 -3
- package/lib/remote-configuration/remoteConfiguration.js +6 -4
- package/lib/remote-configuration/remoteConfiguration.js.map +1 -1
- package/lib/session/CameraKitSession.d.ts +0 -1
- package/lib/session/CameraKitSession.js +4 -4
- package/lib/session/CameraKitSession.js.map +1 -1
- package/lib/session/lensState.js +2 -3
- package/lib/session/lensState.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[CameraKit Web SDK - v0.
|
|
1
|
+
[CameraKit Web SDK - v0.10.0-alpha.1](../README.md) / [Exports](../modules.md) / CameraKitBootstrapConfiguration
|
|
2
2
|
|
|
3
3
|
# Interface: CameraKitBootstrapConfiguration
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[CameraKit Web SDK - v0.
|
|
1
|
+
[CameraKit Web SDK - v0.10.0-alpha.1](../README.md) / [Exports](../modules.md) / Lens
|
|
2
2
|
|
|
3
3
|
# Interface: Lens
|
|
4
4
|
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
- [cameraFacingPreference](Lens.md#camerafacingpreference)
|
|
14
14
|
- [preview](Lens.md#preview)
|
|
15
15
|
- [lensCreator](Lens.md#lenscreator)
|
|
16
|
+
- [snapcode](Lens.md#snapcode)
|
|
16
17
|
|
|
17
18
|
## Properties
|
|
18
19
|
|
|
@@ -71,9 +72,9 @@ ___
|
|
|
71
72
|
|
|
72
73
|
### preview
|
|
73
74
|
|
|
74
|
-
• **preview**: `undefined` \| `Preview`
|
|
75
|
+
• **preview**: `undefined` \| [`Preview`](Preview.md)
|
|
75
76
|
|
|
76
|
-
Preview
|
|
77
|
+
Preview representing this lens, if available.
|
|
77
78
|
|
|
78
79
|
___
|
|
79
80
|
|
|
@@ -82,3 +83,13 @@ ___
|
|
|
82
83
|
• **lensCreator**: `undefined` \| `LensCreator`
|
|
83
84
|
|
|
84
85
|
Information about the lens creator.
|
|
86
|
+
|
|
87
|
+
___
|
|
88
|
+
|
|
89
|
+
### snapcode
|
|
90
|
+
|
|
91
|
+
• **snapcode**: `undefined` \| [`Snapcode`](Snapcode.md)
|
|
92
|
+
|
|
93
|
+
A [snapcode](https://scan.snapchat.com/snapcodes) that represents the lens if available.
|
|
94
|
+
|
|
95
|
+
The snapcode points to the lens in the Snapchat app, when used on mobile, or a dedicated web page.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
[CameraKit Web SDK - v0.10.0-alpha.1](../README.md) / [Exports](../modules.md) / Preview
|
|
2
|
+
|
|
3
|
+
# Interface: Preview
|
|
4
|
+
|
|
5
|
+
Lens preview.
|
|
6
|
+
|
|
7
|
+
## Table of contents
|
|
8
|
+
|
|
9
|
+
### Properties
|
|
10
|
+
|
|
11
|
+
- [imageUrl](Preview.md#imageurl)
|
|
12
|
+
|
|
13
|
+
## Properties
|
|
14
|
+
|
|
15
|
+
### imageUrl
|
|
16
|
+
|
|
17
|
+
• **imageUrl**: `string`
|
|
18
|
+
|
|
19
|
+
Link to a lens preview image.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
[CameraKit Web SDK - v0.10.0-alpha.1](../README.md) / [Exports](../modules.md) / Snapcode
|
|
2
|
+
|
|
3
|
+
# Interface: Snapcode
|
|
4
|
+
|
|
5
|
+
[Snapcode](https://scan.snapchat.com/snapcodes) representing a lens.
|
|
6
|
+
|
|
7
|
+
## Table of contents
|
|
8
|
+
|
|
9
|
+
### Properties
|
|
10
|
+
|
|
11
|
+
- [imageUrl](Snapcode.md#imageurl)
|
|
12
|
+
- [deepLink](Snapcode.md#deeplink)
|
|
13
|
+
|
|
14
|
+
## Properties
|
|
15
|
+
|
|
16
|
+
### imageUrl
|
|
17
|
+
|
|
18
|
+
• **imageUrl**: `string`
|
|
19
|
+
|
|
20
|
+
Snapcode image URL scannable with Snapchat app.
|
|
21
|
+
|
|
22
|
+
___
|
|
23
|
+
|
|
24
|
+
### deepLink
|
|
25
|
+
|
|
26
|
+
• **deepLink**: `string`
|
|
27
|
+
|
|
28
|
+
Deeplink URL that directs to a lens web page.
|
package/docs/md/modules.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
[CameraKit Web SDK - v0.
|
|
1
|
+
[CameraKit Web SDK - v0.10.0-alpha.1](README.md) / Exports
|
|
2
2
|
|
|
3
|
-
# CameraKit Web SDK - v0.
|
|
3
|
+
# CameraKit Web SDK - v0.10.0-alpha.1
|
|
4
4
|
|
|
5
5
|
## Table of contents
|
|
6
6
|
|
|
@@ -28,6 +28,8 @@
|
|
|
28
28
|
- [UriResponse](interfaces/UriResponse.md)
|
|
29
29
|
- [UriCancelRequest](interfaces/UriCancelRequest.md)
|
|
30
30
|
- [Lens](interfaces/Lens.md)
|
|
31
|
+
- [Preview](interfaces/Preview.md)
|
|
32
|
+
- [Snapcode](interfaces/Snapcode.md)
|
|
31
33
|
- [CameraKitSourceSubscriber](interfaces/CameraKitSourceSubscriber.md)
|
|
32
34
|
- [MediaStreamSourceOptions](interfaces/MediaStreamSourceOptions.md)
|
|
33
35
|
- [VideoSourceOptions](interfaces/VideoSourceOptions.md)
|
|
@@ -773,6 +775,12 @@ Create a [CameraKitSource](classes/CameraKitSource.md) from a user's media devic
|
|
|
773
775
|
[MediaDevices.getUserMedia](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia) to get a
|
|
774
776
|
MediaStream and then calls [createMediaStreamSource](modules.md#createmediastreamsource).
|
|
775
777
|
|
|
778
|
+
**`Deprecated`**
|
|
779
|
+
|
|
780
|
+
The helper will be removed in one of the future releases.
|
|
781
|
+
Consumer apps are responsible for acquiring a media stream,
|
|
782
|
+
which can then be supplied to [createMediaStreamSource](modules.md#createmediastreamsource).
|
|
783
|
+
|
|
776
784
|
#### Parameters
|
|
777
785
|
|
|
778
786
|
| Name | Type | Description |
|
|
@@ -799,7 +807,7 @@ Create a [CameraKitSource](classes/CameraKitSource.md) from any
|
|
|
799
807
|
|
|
800
808
|
| Name | Type | Description |
|
|
801
809
|
| :------ | :------ | :------ |
|
|
802
|
-
| `stream` | `MediaStream` | Any MediaStream, such as obtained via `canvas.captureStream()` |
|
|
810
|
+
| `stream` | `MediaStream` | Any MediaStream, such as obtained via `canvas.captureStream()` or `mediaDevices.getUserMedia()`. |
|
|
803
811
|
| `options` | [`CameraKitSourceOptions`](modules.md#camerakitsourceoptions)<[`MediaStreamSourceOptions`](interfaces/MediaStreamSourceOptions.md)\> | |
|
|
804
812
|
|
|
805
813
|
#### Returns
|
package/lib/CameraKit.d.ts
CHANGED
|
@@ -112,18 +112,22 @@ export declare const cameraKitFactory: {
|
|
|
112
112
|
(): MetricsEventTarget;
|
|
113
113
|
token: "metricsEventTarget";
|
|
114
114
|
dependencies: [];
|
|
115
|
+
}, {
|
|
116
|
+
(): import("./handlers/requestStateEmittingHandler").RequestStateEventTarget;
|
|
117
|
+
token: "requestStateEventTarget";
|
|
118
|
+
dependencies: [];
|
|
115
119
|
}, {
|
|
116
120
|
(args_0: import("./configuration").CameraKitConfiguration, args_1: import("./handlers").FetchHandler): import("./handlers/HandlerChainBuilder").Handler<RequestInfo, Response, RequestInit | undefined>;
|
|
117
121
|
token: "cameraKitServiceFetchHandler";
|
|
118
122
|
dependencies: readonly ["configuration", "defaultFetchHandler"];
|
|
119
123
|
}, {
|
|
120
|
-
(args_0: import("./configuration").CameraKitConfiguration): import("./remote-configuration/remoteConfiguration").RemoteConfiguration;
|
|
124
|
+
(args_0: import("./configuration").CameraKitConfiguration, args_1: import("./handlers/requestStateEmittingHandler").RequestStateEventTarget, args_2: import("./metrics/operationalMetricsReporter").OperationalMetricsReporter): import("./remote-configuration/remoteConfiguration").RemoteConfiguration;
|
|
121
125
|
token: "remoteConfiguration";
|
|
122
|
-
dependencies: readonly ["configuration"];
|
|
126
|
+
dependencies: readonly ["configuration", "requestStateEventTarget", "operationalMetricsReporter"];
|
|
123
127
|
}, {
|
|
124
|
-
(args_0: import("./handlers").
|
|
128
|
+
(args_0: import("./handlers/requestStateEmittingHandler").RequestStateEventTarget, args_1: import("./handlers").FetchHandler, args_2: import("./handlers").FetchHandler, args_3: import("./lens").LensSources, args_4: import("./lens").LensAssetRepository): LensRepository;
|
|
125
129
|
token: "LensRepository";
|
|
126
|
-
dependencies: readonly ["cameraKitServiceFetchHandler", "defaultFetchHandler", "lensSources", "lensAssetRepository"];
|
|
130
|
+
dependencies: readonly ["requestStateEventTarget", "cameraKitServiceFetchHandler", "defaultFetchHandler", "lensSources", "lensAssetRepository"];
|
|
127
131
|
}, {
|
|
128
132
|
(args_0: LensCoreModule): import("./persistence/IndexedDBPersistence").IndexedDBPersistence<ArrayBuffer>;
|
|
129
133
|
token: "lensPersistenceStore";
|
|
@@ -137,9 +141,9 @@ export declare const cameraKitFactory: {
|
|
|
137
141
|
token: "operationalMetricsReporter";
|
|
138
142
|
dependencies: readonly ["metricsHandler"];
|
|
139
143
|
}, {
|
|
140
|
-
(args_0: LensCoreModule, args_1: import("./lens").AssetLoader, args_2: import("./lens").AssetLoader, args_3: import("./lens").AssetLoader, args_4: MetricsEventTarget): import("./lens").LensAssetRepository;
|
|
144
|
+
(args_0: LensCoreModule, args_1: import("./lens").AssetLoader, args_2: import("./lens").AssetLoader, args_3: import("./lens").AssetLoader, args_4: MetricsEventTarget, args_5: import("./handlers/requestStateEmittingHandler").RequestStateEventTarget): import("./lens").LensAssetRepository;
|
|
141
145
|
token: "lensAssetRepository";
|
|
142
|
-
dependencies: readonly ["lensCore", "deviceDependentAssetLoader", "remoteMediaAssetLoader", "staticAssetLoader", "metricsEventTarget"];
|
|
146
|
+
dependencies: readonly ["lensCore", "deviceDependentAssetLoader", "remoteMediaAssetLoader", "staticAssetLoader", "metricsEventTarget", "requestStateEventTarget"];
|
|
143
147
|
}, {
|
|
144
148
|
(args_0: import("./handlers").FetchHandler, args_1: import("./remote-configuration/remoteConfiguration").RemoteConfiguration): import("./lens").AssetLoader;
|
|
145
149
|
token: "deviceDependentAssetLoader";
|
package/lib/CameraKit.js
CHANGED
|
@@ -83,7 +83,8 @@ export class CameraKit {
|
|
|
83
83
|
createSession({ liveRenderTarget, renderWhileTabHidden, } = {}) {
|
|
84
84
|
return __awaiter(this, void 0, void 0, function* () {
|
|
85
85
|
// Any error happened during lens rendering can be processed by subscribing to sessionErrors
|
|
86
|
-
const exceptionHandler = (
|
|
86
|
+
const exceptionHandler = (error) => logger.error(lensExecutionError("Error occurred during lens execution. " +
|
|
87
|
+
"The lens cannot be rendered and will be removed from the CameraKitSession.", error));
|
|
87
88
|
/**
|
|
88
89
|
* If/when we add support for multiple concurrent sessions, we'll need to create a copy of the LensCore WASM
|
|
89
90
|
* module. If we move managing web workers into JS, spawing a new worker thread with its own copy of LensCore
|
package/lib/CameraKit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CameraKit.js","sourceRoot":"","sources":["../src/CameraKit.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,qBAAqB,EAAkB,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAa,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM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C,QAAQ,CAAC,cAAc,CAAC,qBAAqB;oBACxD,SAAS;oBACT,SAAS;iBACZ,CAAC,CAAC;YACP,CAAC,CAAC,CAAC;YAEH,2GAA2G;YAC3G,wGAAwG;YACxG,MAAM,gBAAgB,GAAG,IAAI,CAAC,SAAS;gBACnC,oGAAoG;gBACpG,mCAAmC;iBAClC,IAAI,EAAE;iBAEN,QAAQ,CAAC,mBAAmB,CAAC;iBAC7B,QAAQ,CAAC,gBAAgB,CAAC;iBAC1B,QAAQ,CAAC,mBAAmB,CAAC;iBAC7B,QAAQ,CAAC,uBAAuB,CAAC;iBAEjC,GAAG,CAAC,0BAA0B,CAAC;iBAC/B,GAAG,CAAC,kCAAkC,CAAC;gBAExC,uGAAuG;gBACvG,0GAA0G;gBAC1G,kBAAkB;iBACjB,GAAG,CAAC,0BAA0B,CAAC;gBAEhC,0GAA0G;gBAC1G,oCAAoC;iBACnC,GAAG,CAAC,mBAAmB,CAAC,CAAC;YAE9B,OAAO,gBAAgB,CAAC,GAAG,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAC;QAC/D,CAAC;KAAA;CACJ;AA9DS;IADL,GAAG;;;;8CA8DH;AAGL,gBAAgB;AAChB,MAAM,CAAC,MAAM,gBAAgB,GAAG,UAAU,CACtC,WAAW,EACX,CAAC,qBAAqB,CAAC,KAAK,EAAE,yBAAyB,CAAC,KAAK,EAAE,eAAe,CAAC,KAAK,EAAE,SAAS,CAAU,EACzG,CACI,cAA8B,EAC9B,OAA2B,EAC3B,QAAwB,EACxB,SAAkC,EACpC,EAAE,CAAC,IAAI,SAAS,CAAC,cAAc,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,CACnE,CAAC","sourcesContent":["import { lensRepositoryFactory, LensRepository } from \"./lens/LensRepository\";\nimport { CONTAINER, Container } from \"./dependency-injection/Container\";\nimport { Injectable } from \"./dependency-injection/Injectable\";\nimport { LensCoreError, LensCoreModule } from \"./lens-core-module/generated-types\";\nimport { CameraKitSession, cameraKitSessionFactory } from \"./session/CameraKitSession\";\nimport { registerLensAssetsProvider } from \"./lens/assets/LensAssetsProvider\";\nimport { lensCoreFactory } from \"./lens-core-module/loader/lensCoreFactory\";\nimport { configurationToken } from \"./configuration\";\nimport { RootServices } from \"./dependency-injection/RootServices\";\nimport { registerUriHandlers } from \"./extensions/UriHandlers\";\nimport { MetricsEventTarget, metricsEventTargetFactory } from \"./metrics/metricsEventTarget\";\nimport { reportSessionScopedMetrics } from \"./metrics/reporters/reporters\";\nimport { lensStateFactory } from \"./session/lensState\";\nimport { lensKeyboardFactory } from \"./session/LensKeyboard\";\nimport { registerLensClientInterfaceHandler } from \"./lens-client-interface/lensClientInterface\";\nimport { sessionStateFactory } from \"./session/sessionState\";\nimport { lensExecutionError } from \"./namedErrors\";\nimport { getLogger } from \"./logger/logger\";\nimport { errorLoggingDecorator } from \"./logger/errorLoggingDecorator\";\nimport { TypedEventTarget } from \"./events/TypedEventTarget\";\nimport { TypedCustomEvent } from \"./events/TypedCustomEvent\";\nimport { LensView } from \"./metrics/reporters/reportLensView\";\nimport { LensWait } from \"./metrics/reporters/reportLensWait\";\n\nconst logger = getLogger(\"CameraKit\");\nconst log = errorLoggingDecorator(logger);\n\n/**\n * Metrics event names that are exposed to apps.\n */\nconst publicMetricsEventNames: Array<LensMetricsEvents[\"detail\"][\"name\"]> = [\"lensView\", \"lensWait\"];\n\n/**\n * Lens metrics events.\n *\n * These events are emitted by {@link CameraKit} to report lens usage, performance, apply latency, etc.\n *\n * @category Lenses\n * @category Metrics\n */\nexport type LensMetricsEvents =\n | TypedCustomEvent<LensView[\"name\"], LensView>\n | TypedCustomEvent<LensWait[\"name\"], LensWait>;\n\n/**\n * Options available when creating a {@link CameraKitSession}.\n *\n * @category Rendering\n */\nexport interface CreateSessionOptions {\n /**\n * Optionally provide an existing canvas element, on which the Live RenderTarget will be rendered.\n *\n * If this is not provided, CameraKit will create a new canvas element which can be added to the DOM.\n */\n liveRenderTarget?: HTMLCanvasElement;\n\n /**\n * Browsers optimize tabs when they are hidden - for example, by pausing the execution of requestAnimationFrame\n * callbacks.\n *\n * If you need the CameraKitSession to continue rendering even when the tab is in the background, set this to true.\n * There is a small performance penalty, and it's a good practice to only render in the background if absolutely\n * necessary.\n */\n renderWhileTabHidden?: boolean;\n}\n\n/**\n * The entry point to the CameraKit SDK's API. Most of CameraKit's features are accessed via this class.\n *\n * Applications obtain an instance of CameraKit by calling {@link bootstrapCameraKit}.\n *\n * @example\n * ```ts\n * const cameraKit = await bootstrapCameraKit(config)\n * ```\n *\n * Then this class can be used to:\n * - Create a {@link CameraKitSession} instance, which provides the API for setting up media inputs, applying Lenses,\n * and obtaining rendered `<canvas>` outputs.\n * - Query for lenses using {@link LensRepository}.\n * - Listen for lens usage metrics events using {@link MetricsEventTarget}.\n *\n * @category Rendering\n * @category Lenses\n */\nexport class CameraKit {\n /** @deprecated Use {@link lensRepository} */\n readonly lenses: { repository: LensRepository };\n\n /**\n * Business metrics (e.g. each time a lens is viewed) are emitted here.\n */\n readonly metrics: TypedEventTarget<LensMetricsEvents> = new TypedEventTarget();\n\n /** @internal */\n constructor(\n /**\n * Used to query for lenses and lens groups.\n */\n readonly lensRepository: LensRepository,\n\n private readonly lensCore: LensCoreModule,\n private readonly container: Container<RootServices>,\n allMetrics: MetricsEventTarget\n ) {\n this.lenses = { repository: this.lensRepository };\n // Proxy only a subset of all metrics events to the public-facing emitter -- applications don't need to\n // know about most events.\n publicMetricsEventNames.forEach((eventName) => {\n allMetrics.addEventListener(eventName, (e) => this.metrics.dispatchEvent(e));\n });\n }\n\n /**\n * Create a CameraKitSession.\n *\n * This initializes the rendering engine and returns a {@link CameraKitSession} instance, which provides access\n * to Lens rendering.\n *\n * @example\n * ```ts\n * const cameraKit = await bootstrapCameraKit(config)\n * const session = await cameraKit.createSession()\n *\n * const lens = await cameraKit.lensRepository.loadLens(lensId, groupId)\n * session.applyLens(lens)\n * ```\n *\n * @param options\n */\n @log\n async createSession({\n liveRenderTarget,\n renderWhileTabHidden,\n }: CreateSessionOptions = {}): Promise<CameraKitSession> {\n // Any error happened during lens rendering can be processed by subscribing to sessionErrors\n const exceptionHandler = (e: LensCoreError) => logger.error(lensExecutionError(\"Lens execution error.\", e));\n\n /**\n * If/when we add support for multiple concurrent sessions, we'll need to create a copy of the LensCore WASM\n * module. If we move managing web workers into JS, spawing a new worker thread with its own copy of LensCore\n * probably becomes a lot more straightforward.\n *\n * Currently chromium has a bug preventing rendering while tab is hidden when LensCore is in worker mode.\n * In order to process tab while it is hidden, the current stopgap is to pass in renderWhileTabHidden as true,\n * which will initiate session in non worker mode, and set the RenderLoopMode to `SetTimeout`.\n */\n await new Promise<void>((onSuccess, onFailure) => {\n this.lensCore.initialize({\n canvas: liveRenderTarget,\n shouldUseWorker: !renderWhileTabHidden && this.container.get(configurationToken).shouldUseWorker,\n exceptionHandler,\n onSuccess,\n onFailure,\n });\n });\n\n await new Promise<void>((onSuccess, onFailure) => {\n this.lensCore.setRenderLoopMode({\n mode: renderWhileTabHidden\n ? this.lensCore.RenderLoopMode.SetTimeout\n : this.lensCore.RenderLoopMode.RequestAnimationFrame,\n onSuccess,\n onFailure,\n });\n });\n\n // Each session gets its own DI Container – some Services provided by this Container may be shared with the\n // root CameraKit Container, but others may be scoped to the session by passing their token to `copy()`.\n const sessionContainer = this.container\n // Right now this is a no-op. If/when we add support for multiple concurrent sessions, we may end up\n // scoping LensCore to the session.\n .copy()\n\n .provides(sessionStateFactory)\n .provides(lensStateFactory)\n .provides(lensKeyboardFactory)\n .provides(cameraKitSessionFactory)\n\n .run(registerLensAssetsProvider)\n .run(registerLensClientInterfaceHandler)\n\n // We'll run a PartialContainer containing reporters for session-scoped metrics. Running this container\n // allows each metric reporter to initialize itself (e.g. by adding event listeners to detect when certain\n // actions occur).\n .run(reportSessionScopedMetrics)\n\n // UriHandlers may have dependencies on session-scoped services (e.g. LensState, LensKeyboard), so they'll\n // be registered with LensCore here.\n .run(registerUriHandlers);\n\n return sessionContainer.get(cameraKitSessionFactory.token);\n }\n}\n\n/** @internal */\nexport const cameraKitFactory = Injectable(\n \"CameraKit\",\n [lensRepositoryFactory.token, metricsEventTargetFactory.token, lensCoreFactory.token, CONTAINER] as const,\n (\n lensRepository: LensRepository,\n metrics: MetricsEventTarget,\n lensCore: LensCoreModule,\n container: Container<RootServices>\n ) => new CameraKit(lensRepository, lensCore, container, metrics)\n);\n"]}
|
|
1
|
+
{"version":3,"file":"CameraKit.js","sourceRoot":"","sources":["../src/CameraKit.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,qBAAqB,EAAkB,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAa,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAE/D,OAAO,EAAoB,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AACvF,OAAO,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAsB,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAC7F,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,kCAAkC,EAAE,MAAM,6CAA6C,CAAC;AACjG,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;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AC,MAAM,gBAAgB,GAAG,UAAU,CACtC,WAAW,EACX,CAAC,qBAAqB,CAAC,KAAK,EAAE,yBAAyB,CAAC,KAAK,EAAE,eAAe,CAAC,KAAK,EAAE,SAAS,CAAU,EACzG,CACI,cAA8B,EAC9B,OAA2B,EAC3B,QAAwB,EACxB,SAAkC,EACpC,EAAE,CAAC,IAAI,SAAS,CAAC,cAAc,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,CACnE,CAAC","sourcesContent":["import { lensRepositoryFactory, LensRepository } from \"./lens/LensRepository\";\nimport { CONTAINER, Container } from \"./dependency-injection/Container\";\nimport { Injectable } from \"./dependency-injection/Injectable\";\nimport { LensCoreError, LensCoreModule } from \"./lens-core-module/generated-types\";\nimport { CameraKitSession, cameraKitSessionFactory } from \"./session/CameraKitSession\";\nimport { registerLensAssetsProvider } from \"./lens/assets/LensAssetsProvider\";\nimport { lensCoreFactory } from \"./lens-core-module/loader/lensCoreFactory\";\nimport { configurationToken } from \"./configuration\";\nimport { RootServices } from \"./dependency-injection/RootServices\";\nimport { registerUriHandlers } from \"./extensions/UriHandlers\";\nimport { MetricsEventTarget, metricsEventTargetFactory } from \"./metrics/metricsEventTarget\";\nimport { reportSessionScopedMetrics } from \"./metrics/reporters/reporters\";\nimport { lensStateFactory } from \"./session/lensState\";\nimport { lensKeyboardFactory } from \"./session/LensKeyboard\";\nimport { registerLensClientInterfaceHandler } from \"./lens-client-interface/lensClientInterface\";\nimport { sessionStateFactory } from \"./session/sessionState\";\nimport { lensExecutionError } from \"./namedErrors\";\nimport { getLogger } from \"./logger/logger\";\nimport { errorLoggingDecorator } from \"./logger/errorLoggingDecorator\";\nimport { TypedEventTarget } from \"./events/TypedEventTarget\";\nimport { TypedCustomEvent } from \"./events/TypedCustomEvent\";\nimport { LensView } from \"./metrics/reporters/reportLensView\";\nimport { LensWait } from \"./metrics/reporters/reportLensWait\";\n\nconst logger = getLogger(\"CameraKit\");\nconst log = errorLoggingDecorator(logger);\n\n/**\n * Metrics event names that are exposed to apps.\n */\nconst publicMetricsEventNames: Array<LensMetricsEvents[\"detail\"][\"name\"]> = [\"lensView\", \"lensWait\"];\n\n/**\n * Lens metrics events.\n *\n * These events are emitted by {@link CameraKit} to report lens usage, performance, apply latency, etc.\n *\n * @category Lenses\n * @category Metrics\n */\nexport type LensMetricsEvents =\n | TypedCustomEvent<LensView[\"name\"], LensView>\n | TypedCustomEvent<LensWait[\"name\"], LensWait>;\n\n/**\n * Options available when creating a {@link CameraKitSession}.\n *\n * @category Rendering\n */\nexport interface CreateSessionOptions {\n /**\n * Optionally provide an existing canvas element, on which the Live RenderTarget will be rendered.\n *\n * If this is not provided, CameraKit will create a new canvas element which can be added to the DOM.\n */\n liveRenderTarget?: HTMLCanvasElement;\n\n /**\n * Browsers optimize tabs when they are hidden - for example, by pausing the execution of requestAnimationFrame\n * callbacks.\n *\n * If you need the CameraKitSession to continue rendering even when the tab is in the background, set this to true.\n * There is a small performance penalty, and it's a good practice to only render in the background if absolutely\n * necessary.\n */\n renderWhileTabHidden?: boolean;\n}\n\n/**\n * The entry point to the CameraKit SDK's API. Most of CameraKit's features are accessed via this class.\n *\n * Applications obtain an instance of CameraKit by calling {@link bootstrapCameraKit}.\n *\n * @example\n * ```ts\n * const cameraKit = await bootstrapCameraKit(config)\n * ```\n *\n * Then this class can be used to:\n * - Create a {@link CameraKitSession} instance, which provides the API for setting up media inputs, applying Lenses,\n * and obtaining rendered `<canvas>` outputs.\n * - Query for lenses using {@link LensRepository}.\n * - Listen for lens usage metrics events using {@link MetricsEventTarget}.\n *\n * @category Rendering\n * @category Lenses\n */\nexport class CameraKit {\n /** @deprecated Use {@link lensRepository} */\n readonly lenses: { repository: LensRepository };\n\n /**\n * Business metrics (e.g. each time a lens is viewed) are emitted here.\n */\n readonly metrics: TypedEventTarget<LensMetricsEvents> = new TypedEventTarget();\n\n /** @internal */\n constructor(\n /**\n * Used to query for lenses and lens groups.\n */\n readonly lensRepository: LensRepository,\n\n private readonly lensCore: LensCoreModule,\n private readonly container: Container<RootServices>,\n allMetrics: MetricsEventTarget\n ) {\n this.lenses = { repository: this.lensRepository };\n // Proxy only a subset of all metrics events to the public-facing emitter -- applications don't need to\n // know about most events.\n publicMetricsEventNames.forEach((eventName) => {\n allMetrics.addEventListener(eventName, (e) => this.metrics.dispatchEvent(e));\n });\n }\n\n /**\n * Create a CameraKitSession.\n *\n * This initializes the rendering engine and returns a {@link CameraKitSession} instance, which provides access\n * to Lens rendering.\n *\n * @example\n * ```ts\n * const cameraKit = await bootstrapCameraKit(config)\n * const session = await cameraKit.createSession()\n *\n * const lens = await cameraKit.lensRepository.loadLens(lensId, groupId)\n * session.applyLens(lens)\n * ```\n *\n * @param options\n */\n @log\n async createSession({\n liveRenderTarget,\n renderWhileTabHidden,\n }: CreateSessionOptions = {}): Promise<CameraKitSession> {\n // Any error happened during lens rendering can be processed by subscribing to sessionErrors\n const exceptionHandler = (error: LensCoreError) =>\n logger.error(\n lensExecutionError(\n \"Error occurred during lens execution. \" +\n \"The lens cannot be rendered and will be removed from the CameraKitSession.\",\n error\n )\n );\n\n /**\n * If/when we add support for multiple concurrent sessions, we'll need to create a copy of the LensCore WASM\n * module. If we move managing web workers into JS, spawing a new worker thread with its own copy of LensCore\n * probably becomes a lot more straightforward.\n *\n * Currently chromium has a bug preventing rendering while tab is hidden when LensCore is in worker mode.\n * In order to process tab while it is hidden, the current stopgap is to pass in renderWhileTabHidden as true,\n * which will initiate session in non worker mode, and set the RenderLoopMode to `SetTimeout`.\n */\n await new Promise<void>((onSuccess, onFailure) => {\n this.lensCore.initialize({\n canvas: liveRenderTarget,\n shouldUseWorker: !renderWhileTabHidden && this.container.get(configurationToken).shouldUseWorker,\n exceptionHandler,\n onSuccess,\n onFailure,\n });\n });\n\n await new Promise<void>((onSuccess, onFailure) => {\n this.lensCore.setRenderLoopMode({\n mode: renderWhileTabHidden\n ? this.lensCore.RenderLoopMode.SetTimeout\n : this.lensCore.RenderLoopMode.RequestAnimationFrame,\n onSuccess,\n onFailure,\n });\n });\n\n // Each session gets its own DI Container – some Services provided by this Container may be shared with the\n // root CameraKit Container, but others may be scoped to the session by passing their token to `copy()`.\n const sessionContainer = this.container\n // Right now this is a no-op. If/when we add support for multiple concurrent sessions, we may end up\n // scoping LensCore to the session.\n .copy()\n\n .provides(sessionStateFactory)\n .provides(lensStateFactory)\n .provides(lensKeyboardFactory)\n .provides(cameraKitSessionFactory)\n\n .run(registerLensAssetsProvider)\n .run(registerLensClientInterfaceHandler)\n\n // We'll run a PartialContainer containing reporters for session-scoped metrics. Running this container\n // allows each metric reporter to initialize itself (e.g. by adding event listeners to detect when certain\n // actions occur).\n .run(reportSessionScopedMetrics)\n\n // UriHandlers may have dependencies on session-scoped services (e.g. LensState, LensKeyboard), so they'll\n // be registered with LensCore here.\n .run(registerUriHandlers);\n\n return sessionContainer.get(cameraKitSessionFactory.token);\n }\n}\n\n/** @internal */\nexport const cameraKitFactory = Injectable(\n \"CameraKit\",\n [lensRepositoryFactory.token, metricsEventTargetFactory.token, lensCoreFactory.token, CONTAINER] as const,\n (\n lensRepository: LensRepository,\n metrics: MetricsEventTarget,\n lensCore: LensCoreModule,\n container: Container<RootServices>\n ) => new CameraKit(lensRepository, lensCore, container, metrics)\n);\n"]}
|
package/lib/__tests__/data.js
CHANGED
|
@@ -7,7 +7,15 @@ export function createLensFixture(name, content) {
|
|
|
7
7
|
id: name,
|
|
8
8
|
name,
|
|
9
9
|
vendorData: {},
|
|
10
|
-
content: Object.assign({ iconUrlBolt: "https://bolt.com/iconUrl1", lnsSha256: "", lnsUrlBolt: "", preview: {
|
|
10
|
+
content: Object.assign({ iconUrlBolt: "https://bolt.com/iconUrl1", lnsSha256: "", lnsUrlBolt: "", preview: {
|
|
11
|
+
imageUrl: "https://bolt.com/previewUrl1",
|
|
12
|
+
imageSequenceSize: 100,
|
|
13
|
+
imageSequenceWebpUrlPattern: "http://images.com/face-%d.com",
|
|
14
|
+
}, assetManifest: [], defaultHintId: "", hintTranslations: {} }, content),
|
|
15
|
+
scannable: {
|
|
16
|
+
snapcodeImageUrl: "https://snapcodeImageUrl.com",
|
|
17
|
+
snapcodeDeeplink: "https://snapcodeDeeplink.com",
|
|
18
|
+
},
|
|
11
19
|
isThirdParty: false,
|
|
12
20
|
cameraFacingPreference: Lens_CameraFacing.UNRECOGNIZED,
|
|
13
21
|
featureMetadata: [],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data.js","sourceRoot":"","sources":["../../src/__tests__/data.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,OAAO,EAA2B,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAGrE,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,EAAE,CAAU,CAAC;AACpE,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,IAAI,EAAE,EAAE,EAAE,CAAU,CAAC;AAEnE,MAAM,UAAU,iBAAiB,CAAC,IAAY,EAAE,OAA+B;IAC3E,OAAO;QACH,EAAE,EAAE,IAAI;QACR,IAAI;QACJ,UAAU,EAAE,EAAE;QACd,OAAO,kBACH,WAAW,EAAE,2BAA2B,EACxC,SAAS,EAAE,EAAE,EACb,UAAU,EAAE,EAAE,EACd,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"data.js","sourceRoot":"","sources":["../../src/__tests__/data.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,OAAO,EAA2B,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAGrE,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,EAAE,CAAU,CAAC;AACpE,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,IAAI,EAAE,EAAE,EAAE,CAAU,C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,cAAc,EAAE,EAAE,UAAU,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,qBAAqB,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;QACjF,6IAA6I;QAC7I,eAAe,EAAE,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,EAAS;QAC9C,6IAA6I;QAC7I,gBAAgB,EAAE,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,EAAS;QACtD,+IAA+I;QAC/I,wBAAwB,EAAE,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;QAC7G,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE;QACrB,uBAAuB,EAAE,IAAI,CAAC,EAAE,EAAE;QAClC,2BAA2B,EAAE,IAAI,CAAC,EAAE,EAAE;QACtC,iBAAiB,EAAE,IAAI,CAAC,EAAE,EAAE;QAC5B,iBAAiB,EAAE,IAAI,CAAC,EAAE,EAAE;QAC5B,2BAA2B,EAAE,IAAI,CAAC,EAAE,EAAE;QACtC,gCAAgC,EAAE,IAAI,CAAC,EAAE,EAAE;QAC3C,oBAAoB,EAAE,IAAI,CAAC,EAAE,EAAE;QAC/B,oBAAoB,EAAE,IAAI,CAAC,EAAE,EAAE;QAC/B,mCAAmC,EAAE,IAAI,CAAC,EAAE,EAAE;KACjD,CAAC;AACN,CAAC","sourcesContent":["/* eslint-disable max-len */\nimport { ContentProto, LensProto, Lens_CameraFacing } from \"../lens\";\nimport { LensCoreModule, AssetType as LensCoreAssetType } from \"../lens-core-module/generated-types\";\n\nexport const falsyValues = [false, null, undefined, 0, \"\"] as const;\nexport const truthyValues = [true, 1, {}, new Date(), []] as const;\n\nexport function createLensFixture(name: string, content?: Partial<ContentProto>): LensProto {\n return {\n id: name,\n name,\n vendorData: {},\n content: {\n iconUrlBolt: \"https://bolt.com/iconUrl1\",\n lnsSha256: \"\",\n lnsUrlBolt: \"\",\n preview: {\n imageUrl: \"https://bolt.com/previewUrl1\",\n imageSequenceSize: 100,\n imageSequenceWebpUrlPattern: \"http://images.com/face-%d.com\",\n },\n assetManifest: [],\n defaultHintId: \"\",\n hintTranslations: {},\n ...content,\n },\n scannable: {\n snapcodeImageUrl: \"https://snapcodeImageUrl.com\",\n snapcodeDeeplink: \"https://snapcodeDeeplink.com\",\n },\n isThirdParty: false,\n cameraFacingPreference: Lens_CameraFacing.UNRECOGNIZED,\n featureMetadata: [],\n lensCreator: {\n displayName: \"\",\n },\n };\n}\n\nexport type LensCoreMock = Pick<\n jest.Mocked<LensCoreModule>,\n | \"AssetType\"\n | \"CanvasType\"\n | \"InterfaceAction\"\n | \"InterfaceControl\"\n | \"ExternalMediaOrientation\"\n | \"initialize\"\n | \"setRemoteAssetsProvider\"\n | \"provideRemoteAssetsResponse\"\n | \"getOutputCanvases\"\n | \"setRenderLoopMode\"\n | \"RenderLoopMode\"\n | \"setOnFrameProcessedCallback\"\n | \"setClientInterfaceRequestHandler\"\n | \"provideExternalImage\"\n | \"provideExternalVideo\"\n | \"registerSavePersistentStoreCallback\"\n>;\n\n// NOTE: type of the record ensures newly added asset types break compilation\nexport const AssetType: Record<keyof LensCoreModule[\"AssetType\"], LensCoreAssetType> = {\n DeviceDependent: { value: 3 },\n RemoteMediaByUrl: { value: 6 },\n Static: { value: 1 },\n URL: { value: 2 },\n BitmojiDynamicAsset: { value: 4 },\n};\n\nexport function createLensCore(): LensCoreMock {\n return {\n AssetType,\n CanvasType: { Preview: { value: 1 }, Capture: { value: 2 }, None: { value: 0 }, All: { value: 3 } },\n RenderLoopMode: { SetTimeout: { value: 1 }, RequestAnimationFrame: { value: 0 } },\n // https://github.sc-corp.net/Snapchat/LensCore/blob/502b54b9a663203bcdf3b90c63214cdf8cc1e713/Src/CoreManager/ClientInterfaceDelegate.hpp#L39\n InterfaceAction: { Show: { value: 3 } } as any,\n // https://github.sc-corp.net/Snapchat/LensCore/blob/502b54b9a663203bcdf3b90c63214cdf8cc1e713/Src/CoreManager/ClientInterfaceDelegate.hpp#L21\n InterfaceControl: { ImagePicker: { value: 1 } } as any,\n // https://github.sc-corp.net/Snapchat/LensCore/blob/2d538ecc41f67dd2c199e0ff0eefd96aac6f22dc/Src/Common/IExternalMediaFilePickedObserver.h#L21\n ExternalMediaOrientation: { CW0: { value: 0 }, CW90: { value: 1 }, CW180: { value: 2 }, CW270: { value: 3 } },\n initialize: jest.fn(),\n setRemoteAssetsProvider: jest.fn(),\n provideRemoteAssetsResponse: jest.fn(),\n getOutputCanvases: jest.fn(),\n setRenderLoopMode: jest.fn(),\n setOnFrameProcessedCallback: jest.fn(),\n setClientInterfaceRequestHandler: jest.fn(),\n provideExternalImage: jest.fn(),\n provideExternalVideo: jest.fn(),\n registerSavePersistentStoreCallback: jest.fn(),\n };\n}\n"]}
|
|
@@ -5,6 +5,6 @@ import { platformNotSupportedError } from "./namedErrors";
|
|
|
5
5
|
*/
|
|
6
6
|
export function assertPlatformSupported() {
|
|
7
7
|
const canvas = document.createElement("canvas");
|
|
8
|
-
assert(!!canvas.getContext("webgl2") || !!canvas.getContext("webgl"), platformNotSupportedError("
|
|
8
|
+
assert(!!canvas.getContext("webgl2") || !!canvas.getContext("webgl"), platformNotSupportedError("Camera Kit cannot be bootstrapped because the browser does not support WebGL canvas rendering context."));
|
|
9
9
|
}
|
|
10
10
|
//# sourceMappingURL=assertPlatformSupported.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertPlatformSupported.js","sourceRoot":"","sources":["../src/assertPlatformSupported.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAE1D;;GAEG;AACH,MAAM,UAAU,uBAAuB;IACnC,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChD,MAAM,CACF,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,EAC7D,yBAAyB,CACrB
|
|
1
|
+
{"version":3,"file":"assertPlatformSupported.js","sourceRoot":"","sources":["../src/assertPlatformSupported.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAE1D;;GAEG;AACH,MAAM,UAAU,uBAAuB;IACnC,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChD,MAAM,CACF,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,EAC7D,yBAAyB,CACrB,wGAAwG,CAC3G,CACJ,CAAC;AACN,CAAC","sourcesContent":["import { assert } from \"./common/assertions\";\nimport { platformNotSupportedError } from \"./namedErrors\";\n\n/**\n * Assert current platform is supported.\n */\nexport function assertPlatformSupported() {\n const canvas = document.createElement(\"canvas\");\n assert(\n !!canvas.getContext(\"webgl2\") || !!canvas.getContext(\"webgl\"),\n platformNotSupportedError(\n \"Camera Kit cannot be bootstrapped because the browser does not support WebGL canvas rendering context.\"\n )\n );\n}\n"]}
|
|
@@ -15,7 +15,7 @@ export function createProgram(gl, vertexSource, fragmentSource) {
|
|
|
15
15
|
if (!success) {
|
|
16
16
|
const message = gl.getProgramInfoLog(program);
|
|
17
17
|
gl.deleteProgram(program);
|
|
18
|
-
throw webGLError(`WebGLProgram linking failed with status: ${message}
|
|
18
|
+
throw webGLError(`WebGLProgram linking failed with status: ${message}.`);
|
|
19
19
|
}
|
|
20
20
|
return program;
|
|
21
21
|
}
|
|
@@ -29,7 +29,7 @@ export function createShader(gl, source, type) {
|
|
|
29
29
|
if (!success) {
|
|
30
30
|
const message = gl.getShaderInfoLog(shader);
|
|
31
31
|
gl.deleteShader(shader);
|
|
32
|
-
throw webGLError(`WebGLShader (type ${type}) compilation failed with status: ${message}
|
|
32
|
+
throw webGLError(`WebGLShader (type ${type}) compilation failed with status: ${message}.`);
|
|
33
33
|
}
|
|
34
34
|
return shader;
|
|
35
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webglUtils.js","sourceRoot":"","sources":["../../src/benchmark/webglUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,MAAM,wBAAwB,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,UAAU,CAAC,oBAAoB,IAAI,GAAG,CAAC,CAAC;AAE3F,MAAM,UAAU,aAAa,CAAC,EAA0B,EAAE,YAAoB,EAAE,cAAsB;IAClG,MAAM,YAAY,GAAG,YAAY,CAAC,EAAE,EAAE,YAAY,EAAE,EAAE,CAAC,aAAa,CAAC,CAAC;IACtE,MAAM,cAAc,GAAG,YAAY,CAAC,EAAE,EAAE,cAAc,EAAE,EAAE,CAAC,eAAe,CAAC,CAAC;IAC5E,MAAM,OAAO,GAAG,EAAE,CAAC,aAAa,EAAE,CAAC;IACnC,IAAI,CAAC,OAAO;QAAE,MAAM,wBAAwB,CAAC,cAAc,CAAC,CAAC;IAC7D,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IACvC,EAAE,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;IAE9B,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IACzC,EAAE,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;IAEhC,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAExB,MAAM,OAAO,GAAG,EAAE,CA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AE,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;AAC7D,CAAC;AAED,MAAM,UAAU,YAAY,CACxB,EAA0B,EAC1B,OAAqB,EACrB,IAAY,EACZ,IAAsC;IAEtC,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,kBAAkB,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,EAA0B;IAClD,MAAM,IAAI,GAAG,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,0BAA0B,EAAE,CAAC,CAAC,CAAC;IAC5D,IAAI,CAAC,IAAI;QAAE,MAAM,wBAAwB,CAAC,WAAW,CAAC,CAAC;IACvD,EAAE,CAAC,KAAK,EAAE,CAAC;IACX,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACnC,MAAM,WAAW,GAAG,GAAS,EAAE;YAC3B,MAAM,MAAM,GAAG,EAAE,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YAC7C,QAAQ,MAAM,EAAE;gBACZ,KAAK,EAAE,CAAC,eAAe;oBACnB,UAAU,CAAC,WAAW,CAAC,CAAC;oBACxB,OAAO;gBACX,KAAK,EAAE,CAAC,WAAW;oBACf,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;oBACpB,OAAO,MAAM,EAAE,CAAC;gBACpB,KAAK,EAAE,CAAC,gBAAgB,CAAC;gBACzB,KAAK,EAAE,CAAC,mBAAmB;oBACvB,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;oBACpB,OAAO,OAAO,EAAE,CAAC;aACxB;QACL,CAAC,CAAC;QACF,WAAW,EAAE,CAAC;IAClB,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import { webGLError } from \"../namedErrors\";\n\nconst webGLEntityCreationError = (name: string) => webGLError(`Could not create ${name}.`);\n\nexport function createProgram(gl: WebGL2RenderingContext, vertexSource: string, fragmentSource: string): WebGLProgram {\n const vertexShader = createShader(gl, vertexSource, gl.VERTEX_SHADER);\n const fragmentShader = createShader(gl, fragmentSource, gl.FRAGMENT_SHADER);\n const program = gl.createProgram();\n if (!program) throw webGLEntityCreationError(\"WebGLProgram\");\n gl.attachShader(program, vertexShader);\n gl.deleteShader(vertexShader);\n\n gl.attachShader(program, fragmentShader);\n gl.deleteShader(fragmentShader);\n\n gl.linkProgram(program);\n\n const success = gl.getProgramParameter(program, gl.LINK_STATUS);\n if (!success) {\n const message = gl.getProgramInfoLog(program);\n gl.deleteProgram(program);\n throw webGLError(`WebGLProgram linking failed with status: ${message}.`);\n }\n\n return program;\n}\n\nexport function createShader(gl: WebGL2RenderingContext, source: string, type: number): WebGLShader {\n const shader = gl.createShader(type);\n if (!shader) throw webGLEntityCreationError(`WebGLShader (type ${type})`);\n gl.shaderSource(shader, source);\n gl.compileShader(shader);\n const success = gl.getShaderParameter(shader, gl.COMPILE_STATUS);\n if (!success) {\n const message = gl.getShaderInfoLog(shader);\n gl.deleteShader(shader);\n throw webGLError(`WebGLShader (type ${type}) compilation failed with status: ${message}.`);\n }\n return shader;\n}\n\nexport function createTexture(gl: WebGL2RenderingContext, width: number, height: number): WebGLTexture {\n const texture = gl.createTexture();\n if (!texture) throw webGLEntityCreationError(\"WebGLTexture\");\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);\n return texture;\n}\n\nexport function createFramebuffer(gl: WebGL2RenderingContext, texture: WebGLTexture): WebGLFramebuffer {\n const framebuffer = gl.createFramebuffer();\n if (!framebuffer) throw webGLEntityCreationError(\"WebGLFramebuffer\");\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);\n return framebuffer;\n}\n\nexport function setUniform1i(gl: WebGL2RenderingContext, program: WebGLProgram, name: string, data: number): void {\n gl.uniform1i(gl.getUniformLocation(program, name), data);\n}\n\nexport function setUniform4f(\n gl: WebGL2RenderingContext,\n program: WebGLProgram,\n name: string,\n data: [number, number, number, number]\n): void {\n gl.uniform4f(gl.getUniformLocation(program, name), ...data);\n}\n\nexport function promiseSync(gl: WebGL2RenderingContext): Promise<void> {\n const sync = gl.fenceSync(gl.SYNC_GPU_COMMANDS_COMPLETE, 0);\n if (!sync) throw webGLEntityCreationError(\"WebGLSync\");\n gl.flush();\n return new Promise((resolve, reject) => {\n const waitForSync = (): void => {\n const glEnum = gl.clientWaitSync(sync, 0, 0);\n switch (glEnum) {\n case gl.TIMEOUT_EXPIRED:\n setTimeout(waitForSync);\n return;\n case gl.WAIT_FAILED:\n gl.deleteSync(sync);\n return reject();\n case gl.ALREADY_SIGNALED:\n case gl.CONDITION_SATISFIED:\n gl.deleteSync(sync);\n return resolve();\n }\n };\n waitForSync();\n });\n}\n"]}
|
|
@@ -31,6 +31,7 @@ import { bootstrapError, configurationError } from "./namedErrors";
|
|
|
31
31
|
import { businessEventsReporterFactory } from "./metrics/businessEventsReporter";
|
|
32
32
|
import { reportGlobalException } from "./metrics/reporters/reportGlobalException";
|
|
33
33
|
import { registerLogEntriesSubscriber } from "./logger/registerLogEntriesSubscriber";
|
|
34
|
+
import { requestStateEventTargetFactory } from "./handlers/requestStateEmittingHandler";
|
|
34
35
|
const logger = getLogger("bootstrapCameraKit");
|
|
35
36
|
// The following errors are not wrapped with BootstrapError and bubble up as is.
|
|
36
37
|
const nonWrappableErrors = [
|
|
@@ -92,7 +93,7 @@ export function bootstrapCameraKit(configuration, provide) {
|
|
|
92
93
|
return __awaiter(this, void 0, void 0, function* () {
|
|
93
94
|
try {
|
|
94
95
|
const startTimeMs = performance.now();
|
|
95
|
-
assert(isSafeString(configuration.apiToken), configurationError("
|
|
96
|
+
assert(isSafeString(configuration.apiToken), configurationError("Invalid or unsafe apiToken provided."));
|
|
96
97
|
const configurationFactory = createCameraKitConfigurationFactory(configuration);
|
|
97
98
|
// Public container holds services which applications can overwrite with their own implementations.
|
|
98
99
|
const defaultPublicContainer = Container.provides(configurationFactory)
|
|
@@ -110,6 +111,7 @@ export function bootstrapCameraKit(configuration, provide) {
|
|
|
110
111
|
const telemetryContainer = Container.provides(publicContainer)
|
|
111
112
|
.provides(logEntriesFactory)
|
|
112
113
|
.provides(cameraKitServiceFetchHandlerFactory)
|
|
114
|
+
.provides(requestStateEventTargetFactory)
|
|
113
115
|
.provides(metricsEventTargetFactory)
|
|
114
116
|
.provides(metricsHandlerFactory)
|
|
115
117
|
.provides(operationalMetricReporterFactory)
|
|
@@ -151,7 +153,7 @@ export function bootstrapCameraKit(configuration, provide) {
|
|
|
151
153
|
}
|
|
152
154
|
catch (error) {
|
|
153
155
|
if (shouldWrapError(error)) {
|
|
154
|
-
error = bootstrapError("
|
|
156
|
+
error = bootstrapError("Error occurred during Camera Kit bootstrapping.", error);
|
|
155
157
|
}
|
|
156
158
|
logger.error(error);
|
|
157
159
|
throw error;
|
|
@@ -1 +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,M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,CAAC,0BAA0B,CAAC;iBACpC,QAAQ,CAAC,qBAAqB,CAAC;iBAC/B,QAAQ,CAAC,kBAAkB,CAAC;iBAC5B,QAAQ,CAAC,iBAAiB,CAAC;iBAC3B,QAAQ,CAAC,gBAAgB,CAAC;gBAC3B,wGAAwG;gBACxG,0GAA0G;gBAC1G,4GAA4G;gBAC5G,iCAAiC;iBAChC,GAAG,CAAC,2BAA2B,CAAC,CAAC;YAEtC,MAAM,SAAS,GAAG,SAAS,CAAC,GAAG,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;YAExD,MAAM,eAAe,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,WAAW,CAAC;YACxD,MAAM,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAC,gCAAgC,CAAC,KAAK,CAAC,CAAC;YACvE,QAAQ,CAAC,KAAK,CAAC,gBAAgB,EAAE,eAAe,CAAC,CAAC;YAElD,OAAO,SAAS,CAAC;SACpB;QAAC,OAAO,KAAK,EAAE;YACZ,IAAI,eAAe,CAAC,KAAK,CAAC,EAAE;gBACxB,KAAK,GAAG,cAAc,CAAC,iCAAiC,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"]}
|
|
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,0BAA0B,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,yBA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K,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\";\nimport { requestStateEventTargetFactory } from \"./handlers/requestStateEmittingHandler\";\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(\"Invalid or unsafe apiToken provided.\"));\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(requestStateEventTargetFactory)\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(\"Error occurred during Camera Kit bootstrapping.\", 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"]}
|
package/lib/common/validate.js
CHANGED
|
@@ -53,8 +53,8 @@ export function validate(target, key, descriptor) {
|
|
|
53
53
|
}
|
|
54
54
|
if (!isValueOfType(arg, type)) {
|
|
55
55
|
const { methodPath, argPosition, argTypeName } = getArgumentInfo(target, key, i, arg);
|
|
56
|
-
throw new Error(`The ${argPosition} argument to
|
|
57
|
-
|
|
56
|
+
throw new Error(`The ${argPosition} argument to ${methodPath} method is of type ` +
|
|
57
|
+
`${argTypeName}, which is not assignable to parameter of type ${type.name}.`);
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
return method.apply(this, arguments);
|