@snap/camera-kit 0.23.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1122 -537
- package/README.md +1 -1
- package/dist/CameraKit.d.ts +3 -3
- package/dist/CameraKit.d.ts.map +1 -1
- package/dist/CameraKit.js +1 -2
- package/dist/CameraKit.js.map +1 -1
- package/dist/RootServices.d.ts +78 -0
- package/dist/RootServices.d.ts.map +1 -0
- package/dist/RootServices.js.map +1 -0
- package/dist/bootstrapCameraKit.d.ts +3 -4
- package/dist/bootstrapCameraKit.d.ts.map +1 -1
- package/dist/bootstrapCameraKit.js +8 -8
- package/dist/bootstrapCameraKit.js.map +1 -1
- package/dist/clients/createTsProtoClient.d.ts +2 -2
- package/dist/clients/createTsProtoClient.d.ts.map +1 -1
- package/dist/clients/createTsProtoClient.js.map +1 -1
- package/dist/clients/grpcHandler.d.ts.map +1 -1
- package/dist/clients/grpcHandler.js +1 -1
- package/dist/clients/grpcHandler.js.map +1 -1
- package/dist/clients/lensesClient.js +1 -1
- package/dist/clients/lensesClient.js.map +1 -1
- package/dist/clients/metricsClient.d.ts.map +1 -1
- package/dist/clients/metricsClient.js +1 -1
- package/dist/clients/metricsClient.js.map +1 -1
- package/dist/common/pageVisibility.js +1 -1
- package/dist/common/pageVisibility.js.map +1 -1
- package/dist/configuration.d.ts.map +1 -1
- package/dist/configuration.js +1 -1
- package/dist/configuration.js.map +1 -1
- package/dist/environment.d.ts.map +1 -1
- package/dist/environment.js +1 -1
- package/dist/environment.js.map +1 -1
- package/dist/extensions/RemoteApiServices.js +1 -1
- package/dist/extensions/RemoteApiServices.js.map +1 -1
- package/dist/extensions/UriHandlers.js +1 -1
- package/dist/extensions/UriHandlers.js.map +1 -1
- package/dist/extensions/uriHandlersRegister.d.ts.map +1 -1
- package/dist/extensions/uriHandlersRegister.js +1 -1
- package/dist/extensions/uriHandlersRegister.js.map +1 -1
- package/dist/generated-proto/blizzard/cameraKitEvents.d.ts +45 -9270
- package/dist/generated-proto/blizzard/cameraKitEvents.d.ts.map +1 -1
- package/dist/generated-proto/blizzard/cameraKitEvents.js +300 -123
- package/dist/generated-proto/blizzard/cameraKitEvents.js.map +1 -1
- package/dist/generated-proto/pb_schema/camera_kit/v3/business_events.d.ts +12 -32
- package/dist/generated-proto/pb_schema/camera_kit/v3/business_events.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/camera_kit/v3/business_events.js +77 -37
- package/dist/generated-proto/pb_schema/camera_kit/v3/business_events.js.map +1 -1
- package/dist/generated-proto/pb_schema/camera_kit/v3/export.d.ts +19 -454
- package/dist/generated-proto/pb_schema/camera_kit/v3/export.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/camera_kit/v3/export.js +219 -118
- package/dist/generated-proto/pb_schema/camera_kit/v3/export.js.map +1 -1
- package/dist/generated-proto/pb_schema/camera_kit/v3/features/ranking_info.d.ts +12 -12
- package/dist/generated-proto/pb_schema/camera_kit/v3/features/ranking_info.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/camera_kit/v3/features/ranking_info.js +16 -13
- package/dist/generated-proto/pb_schema/camera_kit/v3/features/ranking_info.js.map +1 -1
- package/dist/generated-proto/pb_schema/camera_kit/v3/features/remote_api_info.d.ts +12 -12
- package/dist/generated-proto/pb_schema/camera_kit/v3/features/remote_api_info.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/camera_kit/v3/features/remote_api_info.js +16 -13
- package/dist/generated-proto/pb_schema/camera_kit/v3/features/remote_api_info.js.map +1 -1
- package/dist/generated-proto/pb_schema/camera_kit/v3/legal_prompt.d.ts +13 -54
- package/dist/generated-proto/pb_schema/camera_kit/v3/legal_prompt.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/camera_kit/v3/legal_prompt.js +61 -34
- package/dist/generated-proto/pb_schema/camera_kit/v3/legal_prompt.js.map +1 -1
- package/dist/generated-proto/pb_schema/camera_kit/v3/lens.d.ts +19 -299
- package/dist/generated-proto/pb_schema/camera_kit/v3/lens.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/camera_kit/v3/lens.js +294 -133
- package/dist/generated-proto/pb_schema/camera_kit/v3/lens.js.map +1 -1
- package/dist/generated-proto/pb_schema/camera_kit/v3/operational_metrics.d.ts +14 -148
- package/dist/generated-proto/pb_schema/camera_kit/v3/operational_metrics.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/camera_kit/v3/operational_metrics.js +74 -48
- package/dist/generated-proto/pb_schema/camera_kit/v3/operational_metrics.js.map +1 -1
- package/dist/generated-proto/pb_schema/camera_kit/v3/ranking.d.ts +12 -18
- package/dist/generated-proto/pb_schema/camera_kit/v3/ranking.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/camera_kit/v3/ranking.js +34 -19
- package/dist/generated-proto/pb_schema/camera_kit/v3/ranking.js.map +1 -1
- package/dist/generated-proto/pb_schema/camera_kit/v3/remote_api_spec.d.ts +19 -516
- package/dist/generated-proto/pb_schema/camera_kit/v3/remote_api_spec.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/camera_kit/v3/remote_api_spec.js +164 -80
- package/dist/generated-proto/pb_schema/camera_kit/v3/remote_api_spec.js.map +1 -1
- package/dist/generated-proto/pb_schema/camera_kit/v3/service.d.ts +80 -2371
- package/dist/generated-proto/pb_schema/camera_kit/v3/service.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/camera_kit/v3/service.js +847 -174
- package/dist/generated-proto/pb_schema/camera_kit/v3/service.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/app_launch_type.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/app_launch_type.js +0 -6
- package/dist/generated-proto/pb_schema/cdp/cof/app_launch_type.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/benchmark.d.ts +18 -59
- package/dist/generated-proto/pb_schema/cdp/cof/benchmark.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/benchmark.js +88 -52
- package/dist/generated-proto/pb_schema/cdp/cof/benchmark.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/benchmark_name.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/benchmark_name.js +0 -6
- package/dist/generated-proto/pb_schema/cdp/cof/benchmark_name.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/billboard_provided_signals.d.ts +12 -106
- package/dist/generated-proto/pb_schema/cdp/cof/billboard_provided_signals.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/billboard_provided_signals.js +328 -140
- package/dist/generated-proto/pb_schema/cdp/cof/billboard_provided_signals.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/bolt_provided_signals.d.ts +12 -18
- package/dist/generated-proto/pb_schema/cdp/cof/bolt_provided_signals.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/bolt_provided_signals.js +35 -20
- package/dist/generated-proto/pb_schema/cdp/cof/bolt_provided_signals.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/camera_provided_signals.d.ts +12 -34
- package/dist/generated-proto/pb_schema/cdp/cof/camera_provided_signals.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/camera_provided_signals.js +86 -39
- package/dist/generated-proto/pb_schema/cdp/cof/camera_provided_signals.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/circumstance_service.d.ts +47 -28591
- package/dist/generated-proto/pb_schema/cdp/cof/circumstance_service.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/circumstance_service.js +644 -348
- package/dist/generated-proto/pb_schema/cdp/cof/circumstance_service.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/cognac_provided_signals.d.ts +12 -12
- package/dist/generated-proto/pb_schema/cdp/cof/cognac_provided_signals.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/cognac_provided_signals.js +16 -13
- package/dist/generated-proto/pb_schema/cdp/cof/cognac_provided_signals.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/config_request.d.ts +18 -214
- package/dist/generated-proto/pb_schema/cdp/cof/config_request.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/config_request.js +362 -157
- package/dist/generated-proto/pb_schema/cdp/cof/config_request.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/config_response.d.ts +20 -3801
- package/dist/generated-proto/pb_schema/cdp/cof/config_response.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/config_response.js +144 -46
- package/dist/generated-proto/pb_schema/cdp/cof/config_response.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/config_result.d.ts +49 -10060
- package/dist/generated-proto/pb_schema/cdp/cof/config_result.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/config_result.js +443 -182
- package/dist/generated-proto/pb_schema/cdp/cof/config_result.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/contact_authorization_status.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/contact_authorization_status.js +0 -6
- package/dist/generated-proto/pb_schema/cdp/cof/contact_authorization_status.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/content_manager_provided_signals.d.ts +12 -12
- package/dist/generated-proto/pb_schema/cdp/cof/content_manager_provided_signals.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/content_manager_provided_signals.js +16 -13
- package/dist/generated-proto/pb_schema/cdp/cof/content_manager_provided_signals.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/creative_tools_provided_signals.d.ts +12 -14
- package/dist/generated-proto/pb_schema/cdp/cof/creative_tools_provided_signals.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/creative_tools_provided_signals.js +24 -17
- package/dist/generated-proto/pb_schema/cdp/cof/creative_tools_provided_signals.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/debug_info.d.ts +14 -56
- package/dist/generated-proto/pb_schema/cdp/cof/debug_info.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/debug_info.js +78 -45
- package/dist/generated-proto/pb_schema/cdp/cof/debug_info.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/discover_feed_provided_signals.d.ts +28 -0
- package/dist/generated-proto/pb_schema/cdp/cof/discover_feed_provided_signals.d.ts.map +1 -0
- package/dist/generated-proto/pb_schema/cdp/cof/discover_feed_provided_signals.js +89 -0
- package/dist/generated-proto/pb_schema/cdp/cof/discover_feed_provided_signals.js.map +1 -0
- package/dist/generated-proto/pb_schema/cdp/cof/feature_provided_signals.d.ts +28 -1103
- package/dist/generated-proto/pb_schema/cdp/cof/feature_provided_signals.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/feature_provided_signals.js +358 -210
- package/dist/generated-proto/pb_schema/cdp/cof/feature_provided_signals.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/lenses_provided_signals.d.ts +12 -16
- package/dist/generated-proto/pb_schema/cdp/cof/lenses_provided_signals.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/lenses_provided_signals.js +31 -23
- package/dist/generated-proto/pb_schema/cdp/cof/lenses_provided_signals.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/mdp_media_attribution.d.ts +13 -15
- package/dist/generated-proto/pb_schema/cdp/cof/mdp_media_attribution.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/mdp_media_attribution.js +22 -15
- package/dist/generated-proto/pb_schema/cdp/cof/mdp_media_attribution.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/media_provided_signals.d.ts +12 -14
- package/dist/generated-proto/pb_schema/cdp/cof/media_provided_signals.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/media_provided_signals.js +22 -15
- package/dist/generated-proto/pb_schema/cdp/cof/media_provided_signals.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/namespace.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/namespace.js +0 -6
- package/dist/generated-proto/pb_schema/cdp/cof/namespace.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/opera_provided_signals.d.ts +12 -16
- package/dist/generated-proto/pb_schema/cdp/cof/opera_provided_signals.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/opera_provided_signals.js +29 -18
- package/dist/generated-proto/pb_schema/cdp/cof/opera_provided_signals.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/perception_provided_signals.d.ts +12 -12
- package/dist/generated-proto/pb_schema/cdp/cof/perception_provided_signals.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/perception_provided_signals.js +16 -13
- package/dist/generated-proto/pb_schema/cdp/cof/perception_provided_signals.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/recipients_provided_signals.d.ts +12 -12
- package/dist/generated-proto/pb_schema/cdp/cof/recipients_provided_signals.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/recipients_provided_signals.js +16 -13
- package/dist/generated-proto/pb_schema/cdp/cof/recipients_provided_signals.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/routing_provided_signals.d.ts +12 -12
- package/dist/generated-proto/pb_schema/cdp/cof/routing_provided_signals.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/routing_provided_signals.js +16 -13
- package/dist/generated-proto/pb_schema/cdp/cof/routing_provided_signals.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/snap_kit_provided_signals.d.ts +12 -12
- package/dist/generated-proto/pb_schema/cdp/cof/snap_kit_provided_signals.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/snap_kit_provided_signals.js +16 -13
- package/dist/generated-proto/pb_schema/cdp/cof/snap_kit_provided_signals.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/upload_provided_signals.d.ts +12 -18
- package/dist/generated-proto/pb_schema/cdp/cof/upload_provided_signals.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/upload_provided_signals.js +35 -20
- package/dist/generated-proto/pb_schema/cdp/cof/upload_provided_signals.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/media/snap_source.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/media/snap_source.js +0 -6
- package/dist/generated-proto/pb_schema/cdp/media/snap_source.js.map +1 -1
- package/dist/generated-proto/pb_schema/common/ruid.d.ts +12 -16
- package/dist/generated-proto/pb_schema/common/ruid.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/common/ruid.js +28 -17
- package/dist/generated-proto/pb_schema/common/ruid.js.map +1 -1
- package/dist/generated-proto/pb_schema/common/value.d.ts +25 -123
- package/dist/generated-proto/pb_schema/common/value.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/common/value.js +136 -71
- package/dist/generated-proto/pb_schema/common/value.js.map +1 -1
- package/dist/generated-proto/pb_schema/content/asset.d.ts +12 -14
- package/dist/generated-proto/pb_schema/content/asset.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/content/asset.js +22 -15
- package/dist/generated-proto/pb_schema/content/asset.js.map +1 -1
- package/dist/generated-proto/pb_schema/content/media_reference.d.ts +13 -46
- package/dist/generated-proto/pb_schema/content/media_reference.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/content/media_reference.js +86 -47
- package/dist/generated-proto/pb_schema/content/media_reference.js.map +1 -1
- package/dist/generated-proto/pb_schema/content/media_source.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/content/media_source.js +0 -6
- package/dist/generated-proto/pb_schema/content/media_source.js.map +1 -1
- package/dist/generated-proto/pb_schema/content/media_types.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/content/media_types.js +0 -6
- package/dist/generated-proto/pb_schema/content/media_types.js.map +1 -1
- package/dist/generated-proto/pb_schema/google/api/annotations.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/google/api/annotations.js +0 -6
- package/dist/generated-proto/pb_schema/google/api/annotations.js.map +1 -1
- package/dist/generated-proto/pb_schema/google/api/http.d.ts +15 -3336
- package/dist/generated-proto/pb_schema/google/api/http.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/google/api/http.js +129 -68
- package/dist/generated-proto/pb_schema/google/api/http.js.map +1 -1
- package/dist/generated-proto/pb_schema/google/protobuf/any.d.ts +12 -14
- package/dist/generated-proto/pb_schema/google/protobuf/any.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/google/protobuf/any.js +24 -17
- package/dist/generated-proto/pb_schema/google/protobuf/any.js.map +1 -1
- package/dist/generated-proto/pb_schema/google/protobuf/descriptor.d.ts +126 -50157
- package/dist/generated-proto/pb_schema/google/protobuf/descriptor.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/google/protobuf/descriptor.js +1162 -563
- package/dist/generated-proto/pb_schema/google/protobuf/descriptor.js.map +1 -1
- package/dist/generated-proto/pb_schema/google/protobuf/timestamp.d.ts +12 -14
- package/dist/generated-proto/pb_schema/google/protobuf/timestamp.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/google/protobuf/timestamp.js +23 -19
- package/dist/generated-proto/pb_schema/google/protobuf/timestamp.js.map +1 -1
- package/dist/generated-proto/pb_schema/google/protobuf/wrappers.d.ts +20 -84
- package/dist/generated-proto/pb_schema/google/protobuf/wrappers.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/google/protobuf/wrappers.js +141 -77
- package/dist/generated-proto/pb_schema/google/protobuf/wrappers.js.map +1 -1
- package/dist/generated-proto/pb_schema/lenses/geocircle.d.ts +12 -23
- package/dist/generated-proto/pb_schema/lenses/geocircle.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/lenses/geocircle.js +26 -18
- package/dist/generated-proto/pb_schema/lenses/geocircle.js.map +1 -1
- package/dist/generated-proto/pb_schema/lenses/geopoint.d.ts +12 -14
- package/dist/generated-proto/pb_schema/lenses/geopoint.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/lenses/geopoint.js +22 -15
- package/dist/generated-proto/pb_schema/lenses/geopoint.js.map +1 -1
- package/dist/generated-proto/pb_schema/lenses/launch_params.d.ts +12 -12
- package/dist/generated-proto/pb_schema/lenses/launch_params.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/lenses/launch_params.js +18 -15
- package/dist/generated-proto/pb_schema/lenses/launch_params.js.map +1 -1
- package/dist/generated-proto/pb_schema/lenses/launchdata.d.ts +15 -324
- package/dist/generated-proto/pb_schema/lenses/launchdata.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/lenses/launchdata.js +112 -66
- package/dist/generated-proto/pb_schema/lenses/launchdata.js.map +1 -1
- package/dist/generated-proto/pb_schema/lenses/lures.d.ts +12 -91
- package/dist/generated-proto/pb_schema/lenses/lures.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/lenses/lures.js +37 -28
- package/dist/generated-proto/pb_schema/lenses/lures.js.map +1 -1
- package/dist/generated-proto/pb_schema/lenses/persistent_store.d.ts +12 -12
- package/dist/generated-proto/pb_schema/lenses/persistent_store.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/lenses/persistent_store.js +18 -15
- package/dist/generated-proto/pb_schema/lenses/persistent_store.js.map +1 -1
- package/dist/generated-proto/pb_schema/lenses/remote_api/remote_api_service.d.ts +30 -396
- package/dist/generated-proto/pb_schema/lenses/remote_api/remote_api_service.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/lenses/remote_api/remote_api_service.js +520 -240
- package/dist/generated-proto/pb_schema/lenses/remote_api/remote_api_service.js.map +1 -1
- package/dist/generated-proto/pb_schema/lenses/remote_api/remote_api_spec.d.ts +30 -2429
- package/dist/generated-proto/pb_schema/lenses/remote_api/remote_api_spec.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/lenses/remote_api/remote_api_spec.js +991 -440
- package/dist/generated-proto/pb_schema/lenses/remote_api/remote_api_spec.js.map +1 -1
- package/dist/generated-proto/pb_schema/lenses/snappable.d.ts +27 -783
- package/dist/generated-proto/pb_schema/lenses/snappable.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/lenses/snappable.js +502 -245
- package/dist/generated-proto/pb_schema/lenses/snappable.js.map +1 -1
- package/dist/generated-proto/pb_schema/lenses/user_data.d.ts +15 -174
- package/dist/generated-proto/pb_schema/lenses/user_data.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/lenses/user_data.js +144 -77
- package/dist/generated-proto/pb_schema/lenses/user_data.js.map +1 -1
- package/dist/generated-proto/pb_schema/snapdoc/capture_characteristics.d.ts +12 -14
- package/dist/generated-proto/pb_schema/snapdoc/capture_characteristics.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/snapdoc/capture_characteristics.js +24 -17
- package/dist/generated-proto/pb_schema/snapdoc/capture_characteristics.js.map +1 -1
- package/dist/generated-proto/pb_schema/snapdoc/extensions.d.ts +14 -18
- package/dist/generated-proto/pb_schema/snapdoc/extensions.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/snapdoc/extensions.js +29 -18
- package/dist/generated-proto/pb_schema/snapdoc/extensions.js.map +1 -1
- package/dist/generated-proto/pb_schema/snapdoc/media.d.ts +52 -576
- package/dist/generated-proto/pb_schema/snapdoc/media.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/snapdoc/media.js +615 -318
- package/dist/generated-proto/pb_schema/snapdoc/media.js.map +1 -1
- package/dist/generated-proto/pb_schema/snapdoc/media_codec_formats.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/snapdoc/media_codec_formats.js +0 -6
- package/dist/generated-proto/pb_schema/snapdoc/media_codec_formats.js.map +1 -1
- package/dist/generated-proto/pb_schema/snapdoc/media_file_formats.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/snapdoc/media_file_formats.js +0 -6
- package/dist/generated-proto/pb_schema/snapdoc/media_file_formats.js.map +1 -1
- package/dist/generated-proto/pb_schema/snapdoc/media_id.d.ts +12 -12
- package/dist/generated-proto/pb_schema/snapdoc/media_id.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/snapdoc/media_id.js +17 -17
- package/dist/generated-proto/pb_schema/snapdoc/media_id.js.map +1 -1
- package/dist/generated-proto/pb_schema/snapdoc/snap_component_type.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/snapdoc/snap_component_type.js +0 -6
- package/dist/generated-proto/pb_schema/snapdoc/snap_component_type.js.map +1 -1
- package/dist/handlers/cameraKitServiceFetchHandlerFactory.d.ts.map +1 -1
- package/dist/handlers/cameraKitServiceFetchHandlerFactory.js +1 -1
- package/dist/handlers/cameraKitServiceFetchHandlerFactory.js.map +1 -1
- package/dist/handlers/defaultFetchHandler.js +1 -1
- package/dist/handlers/defaultFetchHandler.js.map +1 -1
- package/dist/handlers/requestStateEmittingHandler.js +1 -1
- package/dist/handlers/requestStateEmittingHandler.js.map +1 -1
- package/dist/index.d.ts +3 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/dist/legal/legalPrompt.js +1 -1
- package/dist/legal/legalPrompt.js.map +1 -1
- package/dist/legal/legalState.js +1 -1
- package/dist/legal/legalState.js.map +1 -1
- package/dist/lens/LensPersistenceStore.js +1 -1
- package/dist/lens/LensPersistenceStore.js.map +1 -1
- package/dist/lens/LensRepository.js +1 -1
- package/dist/lens/LensRepository.js.map +1 -1
- package/dist/lens/LensSource.js +1 -1
- package/dist/lens/LensSource.js.map +1 -1
- package/dist/lens/assets/LensAssetRepository.js +1 -1
- package/dist/lens/assets/LensAssetRepository.js.map +1 -1
- package/dist/lens/assets/LensAssetsProvider.js +1 -1
- package/dist/lens/assets/LensAssetsProvider.js.map +1 -1
- package/dist/lens/assets/deviceDependentAssetLoader.js +1 -1
- package/dist/lens/assets/deviceDependentAssetLoader.js.map +1 -1
- package/dist/lens/assets/remoteMediaAssetLoaderFactory.js +1 -1
- package/dist/lens/assets/remoteMediaAssetLoaderFactory.js.map +1 -1
- package/dist/lens/assets/staticAssetLoader.js +1 -1
- package/dist/lens/assets/staticAssetLoader.js.map +1 -1
- package/dist/lens/cameraKitLensSource.d.ts.map +1 -1
- package/dist/lens/cameraKitLensSource.js +6 -6
- package/dist/lens/cameraKitLensSource.js.map +1 -1
- package/dist/lens/fetchWatermarkLens.d.ts.map +1 -1
- package/dist/lens/fetchWatermarkLens.js +1 -1
- package/dist/lens/fetchWatermarkLens.js.map +1 -1
- package/dist/lens/userDataAccessResolver.d.ts +52 -0
- package/dist/lens/userDataAccessResolver.d.ts.map +1 -0
- package/dist/lens/userDataAccessResolver.js +3 -0
- package/dist/lens/userDataAccessResolver.js.map +1 -0
- package/dist/lens-client-interface/filePicker.d.ts.map +1 -1
- package/dist/lens-client-interface/filePicker.js +1 -1
- package/dist/lens-client-interface/filePicker.js.map +1 -1
- package/dist/lens-client-interface/lensClientInterface.js +1 -1
- package/dist/lens-client-interface/lensClientInterface.js.map +1 -1
- package/dist/lens-core-module/loader/lensCoreFactory.d.ts.map +1 -1
- package/dist/lens-core-module/loader/lensCoreFactory.js +1 -1
- package/dist/lens-core-module/loader/lensCoreFactory.js.map +1 -1
- package/dist/lensCoreWasmVersions.js +3 -3
- package/dist/lensCoreWasmVersions.js.map +1 -1
- package/dist/logger/logEntries.js +1 -1
- package/dist/logger/logEntries.js.map +1 -1
- package/dist/logger/registerLogEntriesSubscriber.d.ts.map +1 -1
- package/dist/logger/registerLogEntriesSubscriber.js +1 -1
- package/dist/logger/registerLogEntriesSubscriber.js.map +1 -1
- package/dist/media-sources/CameraKitSource.d.ts +6 -0
- package/dist/media-sources/CameraKitSource.d.ts.map +1 -1
- package/dist/media-sources/CameraKitSource.js +2 -2
- package/dist/media-sources/CameraKitSource.js.map +1 -1
- package/dist/metrics/businessEventsReporter.js +1 -1
- package/dist/metrics/businessEventsReporter.js.map +1 -1
- package/dist/metrics/metricsEventTarget.js +1 -1
- package/dist/metrics/metricsEventTarget.js.map +1 -1
- package/dist/metrics/reporters/reportBenchmarks.d.ts.map +1 -1
- package/dist/metrics/reporters/reportBenchmarks.js +1 -1
- package/dist/metrics/reporters/reportBenchmarks.js.map +1 -1
- package/dist/metrics/reporters/reportGlobalException.js +1 -1
- package/dist/metrics/reporters/reportGlobalException.js.map +1 -1
- package/dist/metrics/reporters/reportHttpMetrics.js +1 -1
- package/dist/metrics/reporters/reportHttpMetrics.js.map +1 -1
- package/dist/metrics/reporters/reportLegalState.js +1 -1
- package/dist/metrics/reporters/reportLegalState.js.map +1 -1
- package/dist/metrics/reporters/reportLensAndAssetDownload.d.ts.map +1 -1
- package/dist/metrics/reporters/reportLensAndAssetDownload.js +1 -1
- package/dist/metrics/reporters/reportLensAndAssetDownload.js.map +1 -1
- package/dist/metrics/reporters/reportLensValidationFailed.js +1 -1
- package/dist/metrics/reporters/reportLensValidationFailed.js.map +1 -1
- package/dist/metrics/reporters/reportLensView.js +1 -1
- package/dist/metrics/reporters/reportLensView.js.map +1 -1
- package/dist/metrics/reporters/reportLensWait.js +1 -1
- package/dist/metrics/reporters/reportLensWait.js.map +1 -1
- package/dist/metrics/reporters/reportPlatformCapabilities.d.ts.map +1 -1
- package/dist/metrics/reporters/reportPlatformCapabilities.js +1 -1
- package/dist/metrics/reporters/reportPlatformCapabilities.js.map +1 -1
- package/dist/metrics/reporters/reportSessionException.js +1 -1
- package/dist/metrics/reporters/reportSessionException.js.map +1 -1
- package/dist/metrics/reporters/reportUserSession.js +1 -1
- package/dist/metrics/reporters/reportUserSession.js.map +1 -1
- package/dist/metrics/reporters/reporters.d.ts +1 -1
- package/dist/metrics/reporters/reporters.d.ts.map +1 -1
- package/dist/metrics/reporters/reporters.js +1 -1
- package/dist/metrics/reporters/reporters.js.map +1 -1
- package/dist/remote-configuration/cofHandler.d.ts.map +1 -1
- package/dist/remote-configuration/cofHandler.js +1 -1
- package/dist/remote-configuration/cofHandler.js.map +1 -1
- package/dist/remote-configuration/preloadConfiguration.js +1 -1
- package/dist/remote-configuration/preloadConfiguration.js.map +1 -1
- package/dist/remote-configuration/remoteConfiguration.d.ts.map +1 -1
- package/dist/remote-configuration/remoteConfiguration.js +1 -1
- package/dist/remote-configuration/remoteConfiguration.js.map +1 -1
- package/dist/session/CameraKitSession.d.ts +6 -1
- package/dist/session/CameraKitSession.d.ts.map +1 -1
- package/dist/session/CameraKitSession.js +1 -1
- package/dist/session/CameraKitSession.js.map +1 -1
- package/dist/session/LensKeyboard.js +1 -1
- package/dist/session/LensKeyboard.js.map +1 -1
- package/dist/session/lensState.d.ts +3 -2
- package/dist/session/lensState.d.ts.map +1 -1
- package/dist/session/lensState.js +9 -3
- package/dist/session/lensState.js.map +1 -1
- package/dist/session/sessionState.js +1 -1
- package/dist/session/sessionState.js.map +1 -1
- package/docs/html/assets/navigation.js +1 -1
- package/docs/html/assets/search.js +1 -1
- package/docs/html/classes/CameraKit.html +2 -2
- package/docs/html/classes/CameraKitSession.html +7 -3
- package/docs/html/classes/CameraKitSource.html +6 -2
- package/docs/html/classes/LensPerformanceMeasurement.html +2 -2
- package/docs/html/classes/LensPerformanceMetrics.html +2 -2
- package/docs/html/classes/LensRepository.html +2 -2
- package/docs/html/classes/Transform2D.html +2 -2
- package/docs/html/classes/TypedCustomEvent.html +2 -2
- package/docs/html/classes/TypedEventTarget.html +2 -2
- package/docs/html/enums/Lens_CameraFacing.html +2 -2
- package/docs/html/functions/bootstrapCameraKit.html +2 -2
- package/docs/html/functions/createExtension.html +2 -2
- package/docs/html/functions/createImageSource.html +2 -2
- package/docs/html/functions/createMediaStreamSource.html +2 -2
- package/docs/html/functions/createVideoSource.html +2 -2
- package/docs/html/functions/estimateLensPerformance.html +2 -2
- package/docs/html/functions/filePickerFactory.html +2 -4
- package/docs/html/functions/lensSourcesFactory.html +3 -5
- package/docs/html/functions/remoteApiServicesFactory.html +1 -3
- package/docs/html/hierarchy.html +1 -1
- package/docs/html/index.html +3 -3
- package/docs/html/interfaces/BitmojiUserInfo.html +2 -2
- package/docs/html/interfaces/CameraKitBootstrapConfiguration.html +2 -2
- package/docs/html/interfaces/CameraKitDeviceOptions.html +2 -2
- package/docs/html/interfaces/CameraKitSourceInfo.html +2 -2
- package/docs/html/interfaces/CameraKitSourceSubscriber.html +2 -2
- package/docs/html/interfaces/ComputedFrameMetrics.html +2 -2
- package/docs/html/interfaces/CreateSessionOptions.html +2 -2
- package/docs/html/interfaces/EstimatedLensPerformance.html +2 -2
- package/docs/html/interfaces/FriendUserInfo.html +2 -2
- package/docs/html/interfaces/FunctionSourceOptions.html +2 -2
- package/docs/html/interfaces/Lens.html +2 -2
- package/docs/html/interfaces/LensCreator.html +2 -2
- package/docs/html/interfaces/LensLaunchData.html +2 -2
- package/docs/html/interfaces/LensSource.html +2 -2
- package/docs/html/interfaces/LensUserData.html +2 -2
- package/docs/html/interfaces/LoadAssetRequest.html +2 -2
- package/docs/html/interfaces/MediaStreamSourceOptions.html +2 -2
- package/docs/html/interfaces/Preview.html +2 -2
- package/docs/html/interfaces/RemoteApiRequest.html +2 -2
- package/docs/html/interfaces/RemoteApiResponse.html +2 -2
- package/docs/html/interfaces/RemoteApiService.html +2 -2
- package/docs/html/interfaces/Snapcode.html +2 -2
- package/docs/html/interfaces/UriCancelRequest.html +2 -2
- package/docs/html/interfaces/UriRequest.html +2 -2
- package/docs/html/interfaces/UriResponse.html +2 -2
- package/docs/html/interfaces/VideoSourceOptions.html +2 -2
- package/docs/html/modules.html +2 -4
- package/docs/html/types/ArgumentValidationError.html +2 -2
- package/docs/html/types/AssetLoader.html +2 -2
- package/docs/html/types/AssetResponse.html +1 -1
- package/docs/html/types/AssetTiming.html +2 -2
- package/docs/html/types/BenchmarkError.html +1 -1
- package/docs/html/types/BootstrapError.html +2 -2
- package/docs/html/types/CacheKeyNotFoundError.html +1 -1
- package/docs/html/types/CameraKitSessionEventListener.html +2 -2
- package/docs/html/types/CameraKitSessionEvents.html +2 -2
- package/docs/html/types/CameraKitSourceError.html +1 -1
- package/docs/html/types/ConfigurationError.html +2 -2
- package/docs/html/types/FetchHandler.html +1 -1
- package/docs/html/types/FilePicker.html +2 -2
- package/docs/html/types/FilePickerOptions.html +2 -2
- package/docs/html/types/FilePickerResult.html +2 -2
- package/docs/html/types/Keyboard.html +2 -2
- package/docs/html/types/KeyboardEvents.html +2 -2
- package/docs/html/types/LegalError.html +1 -1
- package/docs/html/types/LensAbortError.html +2 -2
- package/docs/html/types/LensAssetError.html +2 -2
- package/docs/html/types/LensContentValidationError.html +1 -1
- package/docs/html/types/LensError.html +1 -1
- package/docs/html/types/LensExecutionError.html +2 -2
- package/docs/html/types/LensImagePickerError.html +2 -2
- package/docs/html/types/LensLaunchParams.html +2 -2
- package/docs/html/types/LensMetricsEvents.html +2 -2
- package/docs/html/types/LensPerformanceCluster.html +1 -1
- package/docs/html/types/LensView.html +2 -2
- package/docs/html/types/LensWait.html +2 -2
- package/docs/html/types/Matrix.html +2 -2
- package/docs/html/types/PersistentStoreError.html +2 -2
- package/docs/html/types/PlatformNotSupportedError.html +2 -2
- package/docs/html/types/PublicContainer.html +2 -2
- package/docs/html/types/PublicServices.html +2 -2
- package/docs/html/types/RemoteApiCancelRequestHandler.html +2 -2
- package/docs/html/types/RemoteApiRequestHandler.html +2 -2
- package/docs/html/types/RemoteApiServices.html +1 -1
- package/docs/html/types/RemoteApiStatus.html +2 -2
- package/docs/html/types/RenderTarget.html +2 -2
- package/docs/html/types/Uri.html +1 -1
- package/docs/html/types/WebGLError.html +1 -1
- package/docs/html/types/Zodiac.html +1 -1
- package/docs/html/variables/extensionRequestContext.html +2 -2
- package/docs/md/README.md +1 -1
- package/docs/md/classes/CameraKit.md +1 -1
- package/docs/md/classes/CameraKitSession.md +7 -2
- package/docs/md/classes/CameraKitSource.md +6 -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/Transform2D.md +1 -1
- package/docs/md/classes/TypedCustomEvent.md +1 -1
- package/docs/md/classes/TypedEventTarget.md +1 -1
- package/docs/md/enums/Lens_CameraFacing.md +1 -1
- package/docs/md/interfaces/BitmojiUserInfo.md +1 -1
- package/docs/md/interfaces/CameraKitBootstrapConfiguration.md +1 -1
- package/docs/md/interfaces/CameraKitDeviceOptions.md +1 -1
- package/docs/md/interfaces/CameraKitSourceInfo.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/FriendUserInfo.md +1 -1
- package/docs/md/interfaces/FunctionSourceOptions.md +1 -1
- package/docs/md/interfaces/Lens.md +1 -1
- package/docs/md/interfaces/LensCreator.md +1 -1
- package/docs/md/interfaces/LensLaunchData.md +1 -1
- package/docs/md/interfaces/LensSource.md +1 -1
- package/docs/md/interfaces/LensUserData.md +1 -1
- package/docs/md/interfaces/LoadAssetRequest.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 +5 -166
- package/package.json +5 -5
- package/dist/dependency-injection/Container.d.ts +0 -177
- package/dist/dependency-injection/Container.d.ts.map +0 -1
- package/dist/dependency-injection/Container.js +0 -72
- package/dist/dependency-injection/Container.js.map +0 -1
- package/dist/dependency-injection/Injectable.d.ts +0 -96
- package/dist/dependency-injection/Injectable.d.ts.map +0 -1
- package/dist/dependency-injection/Injectable.js +0 -37
- package/dist/dependency-injection/Injectable.js.map +0 -1
- package/dist/dependency-injection/PartialContainer.d.ts +0 -86
- package/dist/dependency-injection/PartialContainer.d.ts.map +0 -1
- package/dist/dependency-injection/PartialContainer.js +0 -28
- package/dist/dependency-injection/PartialContainer.js.map +0 -1
- package/dist/dependency-injection/RootServices.d.ts +0 -76
- package/dist/dependency-injection/RootServices.d.ts.map +0 -1
- package/dist/dependency-injection/RootServices.js.map +0 -1
- package/dist/dependency-injection/types.d.ts +0 -57
- package/dist/dependency-injection/types.d.ts.map +0 -1
- package/dist/dependency-injection/types.js +0 -2
- package/dist/dependency-injection/types.js.map +0 -1
- package/docs/html/functions/ConcatInjectable.html +0 -19
- package/docs/html/functions/Injectable.html +0 -17
- /package/dist/{dependency-injection/RootServices.js → RootServices.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LensSource.js","sourceRoot":"","sources":["../../src/lens/LensSource.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"LensSource.js","sourceRoot":"","sources":["../../src/lens/LensSource.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,mDAAmD,CAAC;AAkC7E,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC,aAAa,EAAE,GAAiB,EAAE,CAAC,EAAE,CAAC,CAAC;AAQpF,MAAM,UAAgB,qBAAqB,CAAC,OAAqB,EAAE,OAAe,EAAE,MAAe;;QAC/F,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;QACtE,IAAI,CAAC,MAAM,EAAE;YACT,MAAM,IAAI,KAAK,CACX,oBAAoB,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,QAAQ,CAAC,CAAC,CAAC,EAAE,SAAS,OAAO,IAAI;gBACnE,qDAAqD,CAC5D,CAAC;SACL;QACD,MAAM,QAAQ,GACV,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAExG,OAAO,QAAQ,YAAY,WAAW,IAAI,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC;YAClE,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,YAAY,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM;YAC9F,CAAC,CAAC,EAAE,CAAC;IACb,CAAC;CAAA","sourcesContent":["import { Injectable } from \"@snap/ts-inject\";\nimport { Envelope } from \"../generated-proto/pb_schema/camera_kit/v3/export\";\nimport type { Lens } from \"../generated-proto/pb_schema/camera_kit/v3/lens\";\n\n/**\n * Provides Lens metadata for one or more Lens groups.\n *\n * When a Lens or Lens group is requested via the {@link LensRepository}, CameraKit will find the LensSource which\n * claims ownership of that group. The appropriate LensSource method will be called and must return an ArrayBuffer\n * containing the encoded Lens metadata -- this can be obtained from a CameraKit backend API.\n */\nexport interface LensSource {\n isGroupOwner(groupId: string): boolean;\n loadLens(lensId: string, groupId: string): Promise<ArrayBuffer>;\n loadLensGroup(groupId: string): Promise<ArrayBuffer>;\n}\n\n/**\n * By default, no custom {@link LensSource} is provided to CameraKit. But to enable certain advanced use-cases,\n * applications may provide their own {@link LensSource}.\n *\n * Perhaps the most convenient way to do this is with {@link ConcatInjectable}, as shown here:\n *\n * @example\n * ```ts\n * import { bootstrapCameraKit, lensSourcesFactory, LensSource } from '@snap/camera-kit'\n *\n * const cameraKit = bootstrapCameraKit(config, (container) => {\n * return container.provides(ConcatInjectable(\n * lensSourcesFactory.token,\n * (): LensSource => { return ... }\n * ))\n * })\n * ```\n */\nexport const lensSourcesFactory = Injectable(\"lensSources\", (): LensSource[] => []);\n\n/**\n * Given a list of LensSources (like the one provided by CameraKit's DI container under the `'lensSources'` token), and\n * a groupId/lensId, return a list of lenses loaded by the first LensSource claiming ownership of the given groupId.\n *\n * @internal\n */\nexport async function loadLensesFromSources(sources: LensSource[], groupId: string, lensId?: string): Promise<Lens[]> {\n const source = sources.find((source) => source.isGroupOwner(groupId));\n if (!source) {\n throw new Error(\n `Cannot load lens ${lensId ? `${lensId} from ` : \"\"}group ${groupId}. ` +\n `No LensSource claimed ownership of that lens group.`\n );\n }\n const envelope =\n lensId === undefined ? await source.loadLensGroup(groupId) : await source.loadLens(lensId, groupId);\n\n return envelope instanceof ArrayBuffer || ArrayBuffer.isView(envelope)\n ? Envelope.decode(envelope instanceof Uint8Array ? envelope : new Uint8Array(envelope)).lenses\n : [];\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
|
-
import { Injectable } from "
|
|
2
|
+
import { Injectable } from "@snap/ts-inject";
|
|
3
3
|
import { dispatchRequestCompleted, dispatchRequestErrored, dispatchRequestStarted, requestStateEventTargetFactory, } from "../../handlers/requestStateEmittingHandler";
|
|
4
4
|
import { LensAssetManifestItem_RequestTiming, LensAssetManifestItem_Type, } from "../../generated-proto/pb_schema/camera_kit/v3/lens";
|
|
5
5
|
import { assertUnreachable } from "../../common/assertions";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LensAssetRepository.js","sourceRoot":"","sources":["../../../src/lens/assets/LensAssetRepository.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AAGnE,OAAO,EACH,wBAAwB,EACxB,sBAAsB,EACtB,sBAAsB,EACtB,8BAA8B,GACjC,MAAM,4CAA4C,CAAC;AAGpD,OAAO,EACH,mCAAmC,EACnC,0BAA0B,GAC7B,MAAM,oDAAoD,CAAC;AAC5D,OA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C;QACN,CAAC;KAAA;CACJ;AAKD,MAAM,CAAC,MAAM,0BAA0B,GAAG,UAAU,CAChD,qBAAqB,EACrB;IACI,eAAe,CAAC,KAAK;IACrB,iCAAiC,CAAC,KAAK;IACvC,6BAA6B,CAAC,KAAK;IACnC,wBAAwB,CAAC,KAAK;IAC9B,yBAAyB,CAAC,KAAK;IAC/B,8BAA8B,CAAC,KAAK;CAC9B,EACV,CACI,QAAkB,EAClB,0BAAuC,EACvC,sBAAmC,EACnC,iBAA8B,EAC9B,OAA2B,EAC3B,uBAAgD,EAClD,EAAE,CACA,IAAI,mBAAmB,CACnB,QAAQ,EACR,IAAI,GAAG,CAAC;IACJ,CAAC,QAAQ,CAAC,SAAS,CAAC,eAAe,EAAE,CAAC,iBAAiB,EAAE,0BAA0B,CAAC,CAAC;IACrF,CAAC,QAAQ,CAAC,SAAS,CAAC,gBAAgB,EAAE,CAAC,kBAAkB,EAAE,sBAAsB,CAAC,CAAC;IAGnF,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,sBAAsB,CAAC,CAAC;IACzD,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC;CAC7D,CAAC,EACF,OAAO,EACP,uBAAuB,CAC1B,CACR,CAAC","sourcesContent":["import { Injectable } from \"../../dependency-injection/Injectable\";\nimport type { Lens } from \"../Lens\";\nimport type { RequestStateEventTarget } from \"../../handlers/requestStateEmittingHandler\";\nimport {\n dispatchRequestCompleted,\n dispatchRequestErrored,\n dispatchRequestStarted,\n requestStateEventTargetFactory,\n} from \"../../handlers/requestStateEmittingHandler\";\nimport type { AssetDownloadDimensions } from \"../../metrics/reporters/reportLensAndAssetDownload\";\nimport type { LensAssetManifestItem } from \"../../generated-proto/pb_schema/camera_kit/v3/lens\";\nimport {\n LensAssetManifestItem_RequestTiming,\n LensAssetManifestItem_Type,\n} from \"../../generated-proto/pb_schema/camera_kit/v3/lens\";\nimport { assertUnreachable } from \"../../common/assertions\";\nimport { getLogger } from \"../../logger/logger\";\nimport type { MetricsEventTarget } from \"../../metrics/metricsEventTarget\";\nimport { metricsEventTargetFactory } from \"../../metrics/metricsEventTarget\";\nimport { TypedCustomEvent } from \"../../events/TypedCustomEvent\";\nimport type { AssetDescriptor, AssetType } from \"../../lens-core-module/generated-types\";\nimport type { LensCore } from \"../../lens-core-module/lensCore\";\nimport { lensCoreFactory } from \"../../lens-core-module/loader/lensCoreFactory\";\nimport { deviceDependentAssetLoaderFactory } from \"./deviceDependentAssetLoader\";\nimport { remoteMediaAssetLoaderFactory } from \"./remoteMediaAssetLoaderFactory\";\nimport { staticAssetLoaderFactory } from \"./staticAssetLoader\";\n\nconst logger = getLogger(\"LensAssetRepository\");\n\n/**\n * Computes cache key for asset ID and loader type pair.\n * @param asset Asset ID and loader type pair.\n * @returns Cache key.\n */\nfunction getCacheKey(asset: AssetDescriptor) {\n return `${asset.assetId}_${asset.assetType.value}`;\n}\n\nexport function mapManfiestItemToAssetType(lensCore: LensCore, type: LensAssetManifestItem_Type): AssetType {\n switch (type) {\n case LensAssetManifestItem_Type.ASSET:\n return lensCore.AssetType.Static;\n case LensAssetManifestItem_Type.DEVICE_DEPENDENT_ASSET_UNSET:\n case LensAssetManifestItem_Type.UNRECOGNIZED:\n return lensCore.AssetType.DeviceDependent;\n default:\n return assertUnreachable(type);\n }\n}\n\nexport interface Asset {\n assetId: string;\n assetBuffer: ArrayBuffer;\n assetType: AssetType;\n assetChecksum: string | undefined;\n}\n\nexport type AssetResponse =\n | ArrayBuffer\n | {\n data: ArrayBuffer;\n checksum?: string;\n };\n\n/**\n * Represents a request for loading assets through {@link AssetLoader}. This object specifies the asset to be loaded,\n * optionally defines the lens context, includes an asset manifest if available, and indicates the priority of the load.\n *\n * @category Lenses\n */\nexport interface LoadAssetRequest {\n /**\n * Describes the asset to be loaded.\n */\n assetDescriptor: AssetDescriptor;\n\n /**\n * Specifies the lens context for the asset load, if applicable.\n */\n lens: Lens | undefined;\n\n /**\n * Lens asset manifest.\n */\n assetManifest: LensAssetManifestItem[];\n\n /**\n * Indicates whether the asset fetch should be treated with lower priority compared to other\n * network requests on the page. When set to true, this request may be deferred in favor of higher-priority\n * traffic, potentially improving overall page responsiveness and load times for critical assets.\n */\n lowPriority: boolean;\n}\n\n/**\n * An AssetLoader is used to retrieve assets. A separate loader may be defined to retrieve different asset types.\n *\n * @category Lenses\n *\n * @param request The {@link LoadAssetRequest} detailing the asset to be loaded, its context, and loading priority.\n * @returns A promise that resolves to an {@link AssetResponse} for asynchronous loading,\n * or an {@link AssetResponse} directly for synchronous operations.\n */\nexport type AssetLoader = (request: LoadAssetRequest) => Promise<AssetResponse> | AssetResponse;\n\n/**\n * Registers a remote asset provider function with a given instance of LensCore, and uses a provided mapping of asset\n * types to loading functions to acquire remote asset data and pass it to LensCore.\n *\n * *Note:* LensCoreModule.initialize must be called on the desired LensCoreModule instance **prior** to passing it\n * to the LensAssetProvider constructor. If this class is instantiated with a LensCoreModule that has not been\n * initialized, the registry of the asset provider function will fail silently and no remote assets will be loaded.\n */\nexport class LensAssetRepository {\n private readonly cachedAssetKeys = new Set<string>();\n\n constructor(\n private readonly lensCore: LensCore,\n private readonly assetLoaders: Map<AssetType, [keyof LensCore[\"AssetType\"], AssetLoader]>,\n private readonly metrics: MetricsEventTarget,\n private readonly requestStateEventTarget: RequestStateEventTarget\n ) {}\n\n /**\n * Caches lens assets defined in asset manifest.\n *\n * @param assetManifest Lens asset manifest.\n * @param lens Lens to cache assets of.\n * @param assetTimings Optionally specifies what assets to cache. By default, on-demand assets are not cached.\n * @returns Promise rejects if any required assets could not be loaded – if this occurs, it's very likely the Lens\n * with this manifest will not function.\n */\n public async cacheAssets(\n assetManifest: LensAssetManifestItem[],\n lens: Lens,\n assetTimings: LensAssetManifestItem_RequestTiming[] = [LensAssetManifestItem_RequestTiming.REQUIRED],\n lowPriority: boolean = false\n ): Promise<void> {\n const assetTimingsToPreload = new Set([\n // That is a bad naming, but PRELOAD_UNSET actually means\n // that an asset has to be preloaded\n LensAssetManifestItem_RequestTiming.PRELOAD_UNSET,\n ...assetTimings,\n ]);\n const assetDescriptors = assetManifest\n .filter((asset) => {\n return assetTimingsToPreload.has(asset.requestTiming);\n })\n .map(({ id, type }) => ({\n assetId: id,\n assetType: mapManfiestItemToAssetType(this.lensCore, type),\n }));\n\n if (assetDescriptors.length) {\n // When preloading, we *do* want load failures to reject Promise.all (assets listed in the manifest\n // are known to be hard requirements of the lens).\n return this.cacheAssetsByDescriptor(assetDescriptors, lens, assetManifest, lowPriority);\n }\n }\n\n /**\n * Calls the correct asset loader to fetch the asset's data,\n * depending on the requested asset's type and provides that to LensCore.\n */\n public async loadAsset(request: LoadAssetRequest): Promise<void> {\n const {\n assetDescriptor: { assetId, assetType },\n lens,\n } = request;\n const [assetTypeName, assetLoader] = this.assetLoaders.get(assetType) ?? [];\n const safeAssetTypeName = assetTypeName ?? \"unknown\";\n const dimensions: AssetDownloadDimensions = {\n requestType: \"asset\",\n assetId: assetId,\n assetType: safeAssetTypeName,\n lensId: lens?.id ?? \"unknown\",\n };\n\n const { requestId } = dispatchRequestStarted(this.requestStateEventTarget, { dimensions });\n\n try {\n if (!assetLoader) {\n throw new Error(`Cannot get asset ${assetId}. Asset type ${safeAssetTypeName} is not supported.`);\n }\n\n const assetResponse = await assetLoader(request);\n const assetBuffer = \"data\" in assetResponse ? assetResponse.data : assetResponse;\n const assetChecksum = \"checksum\" in assetResponse ? assetResponse.checksum : undefined;\n\n if (assetBuffer.byteLength === 0) {\n throw new Error(`Got empty response for asset ${assetId} from ${safeAssetTypeName} loader.`);\n }\n\n dispatchRequestCompleted(this.requestStateEventTarget, {\n requestId,\n dimensions,\n status: 200,\n sizeByte: assetBuffer.byteLength,\n });\n\n this.lensCore.provideRemoteAssetsResponse({\n assetId,\n assetBuffer,\n assetType,\n assetChecksum,\n onFailure: (lensCoreError) => {\n if (/validation failed/.test(lensCoreError.message)) {\n this.metrics.dispatchEvent(\n new TypedCustomEvent(\"assetValidationFailed\", {\n name: \"assetValidationFailed\",\n assetId,\n })\n );\n }\n logger.warn(`Failed to provide lens asset ${assetId}.`, lensCoreError);\n },\n });\n } catch (error) {\n const wrappedError = new Error(`Failed to load lens asset ${assetId}.`, { cause: error });\n dispatchRequestErrored(this.requestStateEventTarget, { requestId, dimensions, error: wrappedError });\n throw wrappedError;\n }\n }\n\n /**\n * Downloads and caches assets if applicable. Does nothing for assets that are already in cache.\n * @param assetDescriptors Asset ID and type pairs.\n * @param lens Lens to load assets for.\n * @param assetManifest Lens asset manifest.\n */\n private async cacheAssetsByDescriptor(\n assetDescriptors: AssetDescriptor[],\n lens: Lens,\n assetManifest: LensAssetManifestItem[],\n lowPriority: boolean\n ): Promise<void> {\n await Promise.all(\n assetDescriptors\n .filter((assetDescriptors) => !this.cachedAssetKeys.has(getCacheKey(assetDescriptors)))\n .map(async (assetDescriptor) => {\n try {\n // NOTE: we allow concurrent cache request to download the same asset more than once,\n // because that is better than skipping second request when the firs one fails.\n // In future we could improve concurrent logic with observables as part of\n // https://jira.sc-corp.net/browse/CAMKIT-3931\n await this.loadAsset({ assetDescriptor, lens, assetManifest, lowPriority });\n this.cachedAssetKeys.add(getCacheKey(assetDescriptor));\n } catch (error) {\n const { assetId, assetType } = assetDescriptor;\n const [assetTypeName] = this.assetLoaders.get(assetType) ?? [];\n logger.warn(\n `Failed to cache asset ${assetId} of type ${assetTypeName ?? assetType.value}.`,\n error\n );\n }\n })\n );\n }\n}\n\n/**\n * @internal\n */\nexport const lensAssetRepositoryFactory = Injectable(\n \"lensAssetRepository\",\n [\n lensCoreFactory.token,\n deviceDependentAssetLoaderFactory.token,\n remoteMediaAssetLoaderFactory.token,\n staticAssetLoaderFactory.token,\n metricsEventTargetFactory.token,\n requestStateEventTargetFactory.token,\n ] as const,\n (\n lensCore: LensCore,\n deviceDependentAssetLoader: AssetLoader,\n remoteMediaAssetLoader: AssetLoader,\n staticAssetLoader: AssetLoader,\n metrics: MetricsEventTarget,\n requestStateEventTarget: RequestStateEventTarget\n ) =>\n new LensAssetRepository(\n lensCore,\n new Map([\n [lensCore.AssetType.DeviceDependent, [\"DeviceDependent\", deviceDependentAssetLoader]],\n [lensCore.AssetType.RemoteMediaByUrl, [\"RemoteMediaByUrl\", remoteMediaAssetLoader]],\n // URL type is deprecated and was introduced before RemoteMediaByURL\n // however, there are some lenses still using it so we need to support it\n [lensCore.AssetType.URL, [\"URL\", remoteMediaAssetLoader]],\n [lensCore.AssetType.Static, [\"Static\", staticAssetLoader]],\n ]),\n metrics,\n requestStateEventTarget\n )\n);\n"]}
|
|
1
|
+
{"version":3,"file":"LensAssetRepository.js","sourceRoot":"","sources":["../../../src/lens/assets/LensAssetRepository.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C,OAAO,EACH,wBAAwB,EACxB,sBAAsB,EACtB,sBAAsB,EACtB,8BAA8B,GACjC,MAAM,4CAA4C,CAAC;AAGpD,OAAO,EACH,mCAAmC,EACnC,0BAA0B,GAC7B,MAAM,oDAAoD,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAGjE,OAAO,EAAE,eAAe,EAAE,MAAM,+CAA+C,CAAC;AAChF,OAAO,EAAE,iCAAiC,EAAE,MAAM,8BAA8B,CAAC;AACjF,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAE/D,MAAM,MAAM,GAAG,SAAS,CAAC,qBAAqB,CAAC,CAAC;AAOhD,SAAS,WAAW,CAAC,KAAsB;IACvC,OAA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QAAQ,CAAC,SAAS,CAAC,gBAAgB,EAAE,CAAC,kBAAkB,EAAE,sBAAsB,CAAC,CAAC;IAGnF,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,sBAAsB,CAAC,CAAC;IACzD,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC;CAC7D,CAAC,EACF,OAAO,EACP,uBAAuB,CAC1B,CACR,CAAC","sourcesContent":["import { Injectable } from \"@snap/ts-inject\";\nimport type { Lens } from \"../Lens\";\nimport type { RequestStateEventTarget } from \"../../handlers/requestStateEmittingHandler\";\nimport {\n dispatchRequestCompleted,\n dispatchRequestErrored,\n dispatchRequestStarted,\n requestStateEventTargetFactory,\n} from \"../../handlers/requestStateEmittingHandler\";\nimport type { AssetDownloadDimensions } from \"../../metrics/reporters/reportLensAndAssetDownload\";\nimport type { LensAssetManifestItem } from \"../../generated-proto/pb_schema/camera_kit/v3/lens\";\nimport {\n LensAssetManifestItem_RequestTiming,\n LensAssetManifestItem_Type,\n} from \"../../generated-proto/pb_schema/camera_kit/v3/lens\";\nimport { assertUnreachable } from \"../../common/assertions\";\nimport { getLogger } from \"../../logger/logger\";\nimport type { MetricsEventTarget } from \"../../metrics/metricsEventTarget\";\nimport { metricsEventTargetFactory } from \"../../metrics/metricsEventTarget\";\nimport { TypedCustomEvent } from \"../../events/TypedCustomEvent\";\nimport type { AssetDescriptor, AssetType } from \"../../lens-core-module/generated-types\";\nimport type { LensCore } from \"../../lens-core-module/lensCore\";\nimport { lensCoreFactory } from \"../../lens-core-module/loader/lensCoreFactory\";\nimport { deviceDependentAssetLoaderFactory } from \"./deviceDependentAssetLoader\";\nimport { remoteMediaAssetLoaderFactory } from \"./remoteMediaAssetLoaderFactory\";\nimport { staticAssetLoaderFactory } from \"./staticAssetLoader\";\n\nconst logger = getLogger(\"LensAssetRepository\");\n\n/**\n * Computes cache key for asset ID and loader type pair.\n * @param asset Asset ID and loader type pair.\n * @returns Cache key.\n */\nfunction getCacheKey(asset: AssetDescriptor) {\n return `${asset.assetId}_${asset.assetType.value}`;\n}\n\nexport function mapManfiestItemToAssetType(lensCore: LensCore, type: LensAssetManifestItem_Type): AssetType {\n switch (type) {\n case LensAssetManifestItem_Type.ASSET:\n return lensCore.AssetType.Static;\n case LensAssetManifestItem_Type.DEVICE_DEPENDENT_ASSET_UNSET:\n case LensAssetManifestItem_Type.UNRECOGNIZED:\n return lensCore.AssetType.DeviceDependent;\n default:\n return assertUnreachable(type);\n }\n}\n\nexport interface Asset {\n assetId: string;\n assetBuffer: ArrayBuffer;\n assetType: AssetType;\n assetChecksum: string | undefined;\n}\n\nexport type AssetResponse =\n | ArrayBuffer\n | {\n data: ArrayBuffer;\n checksum?: string;\n };\n\n/**\n * Represents a request for loading assets through {@link AssetLoader}. This object specifies the asset to be loaded,\n * optionally defines the lens context, includes an asset manifest if available, and indicates the priority of the load.\n *\n * @category Lenses\n */\nexport interface LoadAssetRequest {\n /**\n * Describes the asset to be loaded.\n */\n assetDescriptor: AssetDescriptor;\n\n /**\n * Specifies the lens context for the asset load, if applicable.\n */\n lens: Lens | undefined;\n\n /**\n * Lens asset manifest.\n */\n assetManifest: LensAssetManifestItem[];\n\n /**\n * Indicates whether the asset fetch should be treated with lower priority compared to other\n * network requests on the page. When set to true, this request may be deferred in favor of higher-priority\n * traffic, potentially improving overall page responsiveness and load times for critical assets.\n */\n lowPriority: boolean;\n}\n\n/**\n * An AssetLoader is used to retrieve assets. A separate loader may be defined to retrieve different asset types.\n *\n * @category Lenses\n *\n * @param request The {@link LoadAssetRequest} detailing the asset to be loaded, its context, and loading priority.\n * @returns A promise that resolves to an {@link AssetResponse} for asynchronous loading,\n * or an {@link AssetResponse} directly for synchronous operations.\n */\nexport type AssetLoader = (request: LoadAssetRequest) => Promise<AssetResponse> | AssetResponse;\n\n/**\n * Registers a remote asset provider function with a given instance of LensCore, and uses a provided mapping of asset\n * types to loading functions to acquire remote asset data and pass it to LensCore.\n *\n * *Note:* LensCoreModule.initialize must be called on the desired LensCoreModule instance **prior** to passing it\n * to the LensAssetProvider constructor. If this class is instantiated with a LensCoreModule that has not been\n * initialized, the registry of the asset provider function will fail silently and no remote assets will be loaded.\n */\nexport class LensAssetRepository {\n private readonly cachedAssetKeys = new Set<string>();\n\n constructor(\n private readonly lensCore: LensCore,\n private readonly assetLoaders: Map<AssetType, [keyof LensCore[\"AssetType\"], AssetLoader]>,\n private readonly metrics: MetricsEventTarget,\n private readonly requestStateEventTarget: RequestStateEventTarget\n ) {}\n\n /**\n * Caches lens assets defined in asset manifest.\n *\n * @param assetManifest Lens asset manifest.\n * @param lens Lens to cache assets of.\n * @param assetTimings Optionally specifies what assets to cache. By default, on-demand assets are not cached.\n * @returns Promise rejects if any required assets could not be loaded – if this occurs, it's very likely the Lens\n * with this manifest will not function.\n */\n public async cacheAssets(\n assetManifest: LensAssetManifestItem[],\n lens: Lens,\n assetTimings: LensAssetManifestItem_RequestTiming[] = [LensAssetManifestItem_RequestTiming.REQUIRED],\n lowPriority: boolean = false\n ): Promise<void> {\n const assetTimingsToPreload = new Set([\n // That is a bad naming, but PRELOAD_UNSET actually means\n // that an asset has to be preloaded\n LensAssetManifestItem_RequestTiming.PRELOAD_UNSET,\n ...assetTimings,\n ]);\n const assetDescriptors = assetManifest\n .filter((asset) => {\n return assetTimingsToPreload.has(asset.requestTiming);\n })\n .map(({ id, type }) => ({\n assetId: id,\n assetType: mapManfiestItemToAssetType(this.lensCore, type),\n }));\n\n if (assetDescriptors.length) {\n // When preloading, we *do* want load failures to reject Promise.all (assets listed in the manifest\n // are known to be hard requirements of the lens).\n return this.cacheAssetsByDescriptor(assetDescriptors, lens, assetManifest, lowPriority);\n }\n }\n\n /**\n * Calls the correct asset loader to fetch the asset's data,\n * depending on the requested asset's type and provides that to LensCore.\n */\n public async loadAsset(request: LoadAssetRequest): Promise<void> {\n const {\n assetDescriptor: { assetId, assetType },\n lens,\n } = request;\n const [assetTypeName, assetLoader] = this.assetLoaders.get(assetType) ?? [];\n const safeAssetTypeName = assetTypeName ?? \"unknown\";\n const dimensions: AssetDownloadDimensions = {\n requestType: \"asset\",\n assetId: assetId,\n assetType: safeAssetTypeName,\n lensId: lens?.id ?? \"unknown\",\n };\n\n const { requestId } = dispatchRequestStarted(this.requestStateEventTarget, { dimensions });\n\n try {\n if (!assetLoader) {\n throw new Error(`Cannot get asset ${assetId}. Asset type ${safeAssetTypeName} is not supported.`);\n }\n\n const assetResponse = await assetLoader(request);\n const assetBuffer = \"data\" in assetResponse ? assetResponse.data : assetResponse;\n const assetChecksum = \"checksum\" in assetResponse ? assetResponse.checksum : undefined;\n\n if (assetBuffer.byteLength === 0) {\n throw new Error(`Got empty response for asset ${assetId} from ${safeAssetTypeName} loader.`);\n }\n\n dispatchRequestCompleted(this.requestStateEventTarget, {\n requestId,\n dimensions,\n status: 200,\n sizeByte: assetBuffer.byteLength,\n });\n\n this.lensCore.provideRemoteAssetsResponse({\n assetId,\n assetBuffer,\n assetType,\n assetChecksum,\n onFailure: (lensCoreError) => {\n if (/validation failed/.test(lensCoreError.message)) {\n this.metrics.dispatchEvent(\n new TypedCustomEvent(\"assetValidationFailed\", {\n name: \"assetValidationFailed\",\n assetId,\n })\n );\n }\n logger.warn(`Failed to provide lens asset ${assetId}.`, lensCoreError);\n },\n });\n } catch (error) {\n const wrappedError = new Error(`Failed to load lens asset ${assetId}.`, { cause: error });\n dispatchRequestErrored(this.requestStateEventTarget, { requestId, dimensions, error: wrappedError });\n throw wrappedError;\n }\n }\n\n /**\n * Downloads and caches assets if applicable. Does nothing for assets that are already in cache.\n * @param assetDescriptors Asset ID and type pairs.\n * @param lens Lens to load assets for.\n * @param assetManifest Lens asset manifest.\n */\n private async cacheAssetsByDescriptor(\n assetDescriptors: AssetDescriptor[],\n lens: Lens,\n assetManifest: LensAssetManifestItem[],\n lowPriority: boolean\n ): Promise<void> {\n await Promise.all(\n assetDescriptors\n .filter((assetDescriptors) => !this.cachedAssetKeys.has(getCacheKey(assetDescriptors)))\n .map(async (assetDescriptor) => {\n try {\n // NOTE: we allow concurrent cache request to download the same asset more than once,\n // because that is better than skipping second request when the firs one fails.\n // In future we could improve concurrent logic with observables as part of\n // https://jira.sc-corp.net/browse/CAMKIT-3931\n await this.loadAsset({ assetDescriptor, lens, assetManifest, lowPriority });\n this.cachedAssetKeys.add(getCacheKey(assetDescriptor));\n } catch (error) {\n const { assetId, assetType } = assetDescriptor;\n const [assetTypeName] = this.assetLoaders.get(assetType) ?? [];\n logger.warn(\n `Failed to cache asset ${assetId} of type ${assetTypeName ?? assetType.value}.`,\n error\n );\n }\n })\n );\n }\n}\n\n/**\n * @internal\n */\nexport const lensAssetRepositoryFactory = Injectable(\n \"lensAssetRepository\",\n [\n lensCoreFactory.token,\n deviceDependentAssetLoaderFactory.token,\n remoteMediaAssetLoaderFactory.token,\n staticAssetLoaderFactory.token,\n metricsEventTargetFactory.token,\n requestStateEventTargetFactory.token,\n ] as const,\n (\n lensCore: LensCore,\n deviceDependentAssetLoader: AssetLoader,\n remoteMediaAssetLoader: AssetLoader,\n staticAssetLoader: AssetLoader,\n metrics: MetricsEventTarget,\n requestStateEventTarget: RequestStateEventTarget\n ) =>\n new LensAssetRepository(\n lensCore,\n new Map([\n [lensCore.AssetType.DeviceDependent, [\"DeviceDependent\", deviceDependentAssetLoader]],\n [lensCore.AssetType.RemoteMediaByUrl, [\"RemoteMediaByUrl\", remoteMediaAssetLoader]],\n // URL type is deprecated and was introduced before RemoteMediaByURL\n // however, there are some lenses still using it so we need to support it\n [lensCore.AssetType.URL, [\"URL\", remoteMediaAssetLoader]],\n [lensCore.AssetType.Static, [\"Static\", staticAssetLoader]],\n ]),\n metrics,\n requestStateEventTarget\n )\n);\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
|
-
import { Injectable } from "
|
|
2
|
+
import { Injectable } from "@snap/ts-inject";
|
|
3
3
|
import { lensAssetError } from "../../namedErrors";
|
|
4
4
|
import { getLogger } from "../../logger/logger";
|
|
5
5
|
import { toPublicLens } from "../Lens";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LensAssetsProvider.js","sourceRoot":"","sources":["../../../src/lens/assets/LensAssetsProvider.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"LensAssetsProvider.js","sourceRoot":"","sources":["../../../src/lens/assets/LensAssetsProvider.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,+CAA+C,CAAC;AAGhF,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAEnE,MAAM,MAAM,GAAG,SAAS,CAAC,mBAAmB,CAAC,CAAC;AAC9C,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAe/B,MAAM,CAAC,MAAM,0BAA0B,GAAG,UAAU,CAChD,4BAA4B,EAC5B;IACI,eAAe,CAAC,KAAK;IACrB,qBAAqB,CAAC,KAAK;IAC3B,0BAA0B,CAAC,KAAK;IAChC,gBAAgB,CAAC,KAAK;CAChB,EACV,CACI,QAAkB,EAClB,cAA8B,EAC9B,mBAAwC,EACxC,SAAoB,EACtB,EAAE;IACA,MAAM,yBAAyB,GAAG,IAAI,GAAG,EAAkB,CAAC;IAE5D,QAAQ,CAAC,uBAAuB,CAAC,CAAO,eAAe,EAAE,EAAE;;QAIvD,MA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ACvG;iBAAM;gBACH,MAAM,CAAC,IAAI,CAAC,2DAA2D,OAAO,EAAE,CAAC,CAAC;aACrF;SACJ;IACL,CAAC,CAAA,CAAC,CAAC;AACP,CAAC,CACJ,CAAC","sourcesContent":["import { Injectable } from \"@snap/ts-inject\";\nimport { lensAssetError } from \"../../namedErrors\";\nimport { getLogger } from \"../../logger/logger\";\nimport type { MakeTaggedBusinessEvent } from \"../../metrics/businessEventsReporter\";\nimport { toPublicLens } from \"../Lens\";\nimport type { LensRepository } from \"../LensRepository\";\nimport { lensRepositoryFactory } from \"../LensRepository\";\nimport type { LensState } from \"../../session/lensState\";\nimport { lensStateFactory } from \"../../session/lensState\";\nimport { lensCoreFactory } from \"../../lens-core-module/loader/lensCoreFactory\";\nimport type { LensCore } from \"../../lens-core-module/lensCore\";\nimport type { LensAssetRepository } from \"./LensAssetRepository\";\nimport { lensAssetRepositoryFactory } from \"./LensAssetRepository\";\n\nconst logger = getLogger(\"LensAssetProvider\");\nconst maxConsecutiveErrors = 3;\n\n/**\n * The AssetValidationFailed metric reports every time we handle an asset checksum validation failure.\n */\nexport type AssetValidationFailed = MakeTaggedBusinessEvent<\"assetValidationFailed\">;\n\n/**\n * Registers a remote asset provider function with a given instance of LensCore.\n *\n * *Note:* LensCoreModule.initialize must be called on the desired LensCoreModule instance **prior** to passing it\n * to the LensAssetsProvider constructor. If this class is instantiated with a LensCoreModule that has not been\n * initialized, the registry of the asset provider function will fail silently and no remote assets will be loaded.\n * @internal\n */\nexport const registerLensAssetsProvider = Injectable(\n \"registerLensAssetsProvider\",\n [\n lensCoreFactory.token,\n lensRepositoryFactory.token,\n lensAssetRepositoryFactory.token,\n lensStateFactory.token,\n ] as const,\n (\n lensCore: LensCore,\n lensRepository: LensRepository,\n lensAssetRepository: LensAssetRepository,\n lensState: LensState\n ) => {\n const consecutiveErrorsPerAsset = new Map<string, number>();\n\n lensCore.setRemoteAssetsProvider(async (assetDescriptor) => {\n // Fetch an asset and provide it to LensCore. If fetching the asset fails we give LensCore\n // an empty response (which it may handle in a variety of ways, e.g. retry, gracefully\n // degrade lens behavior, throw error) and then reject.\n const { assetId, assetType, effectId } = assetDescriptor;\n\n try {\n if ((consecutiveErrorsPerAsset.get(assetId) ?? 0) > maxConsecutiveErrors) {\n throw new Error(`Maximum consecutive asset load errors reached for asset ${assetId}`);\n }\n const lensId = effectId ?? lensState.getState().data?.id;\n const lens = lensId ? lensRepository.getLensMetadata(lensId) : undefined;\n\n await lensAssetRepository.loadAsset({\n assetDescriptor,\n lens: lens && toPublicLens(lens),\n assetManifest: lens?.content?.assetManifest ?? [],\n lowPriority: false,\n });\n consecutiveErrorsPerAsset.set(assetId, 0);\n } catch (error) {\n // if an error occurs, LensCore handles things in different ways\n // depending on the active lens. It might: 1) retry, 2) gracefully degrade lens behavior,\n // 3) lens JS might throw, which will be passed to the exceptionHandler we register with LensCore.\n lensCore.provideRemoteAssetsResponse({\n assetId,\n assetType,\n });\n\n const consecutiveErrors = (consecutiveErrorsPerAsset.get(assetId) ?? 0) + 1;\n consecutiveErrorsPerAsset.set(assetId, consecutiveErrors);\n\n // We've already reported `maxConsecutiveErrors` number of errors for this asset, so we can skip\n // logging additional errors.\n if (consecutiveErrors <= maxConsecutiveErrors) {\n logger.error(lensAssetError(`Error occurred while handling lens asset ${assetId} request.`, error));\n } else {\n logger.warn(`Maximum consecutive asset load errors reached for asset ${assetId}`);\n }\n }\n });\n }\n);\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
2
|
import { catchError, firstValueFrom, map, mergeMap } from "rxjs";
|
|
3
|
+
import { Injectable } from "@snap/ts-inject";
|
|
3
4
|
import { isRecord, isString } from "../../common/typeguards";
|
|
4
|
-
import { Injectable } from "../../dependency-injection/Injectable";
|
|
5
5
|
import { createArrayBufferParsingHandler } from "../../handlers/arrayBufferParsingHandler";
|
|
6
6
|
import { defaultFetchHandlerFactory } from "../../handlers/defaultFetchHandler";
|
|
7
7
|
import { HandlerChainBuilder } from "../../handlers/HandlerChainBuilder";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deviceDependentAssetLoader.js","sourceRoot":"","sources":["../../../src/lens/assets/deviceDependentAssetLoader.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACjE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"deviceDependentAssetLoader.js","sourceRoot":"","sources":["../../../src/lens/assets/deviceDependentAssetLoader.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,+BAA+B,EAAE,MAAM,0CAA0C,CAAC;AAE3F,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAEzE,OAAO,EAAE,0BAA0B,EAAE,MAAM,gDAAgD,CAAC;AAC5F,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAQ3D,MAAM,cAAc,GAAG,CAAC,KAAc,EAAoC,EAAE;IACxE,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;AAC1D,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,CAAC,KAAc,EAAwB,EAAE;IAC3D,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,KAAK,SAAS,IAAI,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,C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CAAC,CAAC;iBAC9E;gBAID,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC;oBAAE,MAAM,aAAa,CAAC,oCAAoC,CAAC,CAAC;gBAE3F,OAAO,WAAW,CAAC;YACvB,CAAC,CAAC,EACF,QAAQ,CAAC,CAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE,EAAE;gBAEjC,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,GAAG,MAAM,YAAY,CACvC,GAAG,EACH,mBAAmB,CAAC,EAAE,KAAK,EAAE,aAAa,EAAE,EAAE,WAAW,CAAC,CAC7D,CAAC;gBACF,IAAI,CAAC,QAAQ,CAAC,EAAE;oBAAE,MAAM,QAAQ,CAAC;gBACjC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;YAC9B,CAAC,CAAA,CAAC,CACL,CACJ,CAAC;QACN,CAAC;KAAA,CAAC;AACN,CAAC,CACJ,CAAC","sourcesContent":["import { catchError, firstValueFrom, map, mergeMap } from \"rxjs\";\nimport { Injectable } from \"@snap/ts-inject\";\nimport { isRecord, isString } from \"../../common/typeguards\";\nimport { createArrayBufferParsingHandler } from \"../../handlers/arrayBufferParsingHandler\";\nimport type { FetchHandler } from \"../../handlers/defaultFetchHandler\";\nimport { defaultFetchHandlerFactory } from \"../../handlers/defaultFetchHandler\";\nimport { HandlerChainBuilder } from \"../../handlers/HandlerChainBuilder\";\nimport type { RemoteConfiguration } from \"../../remote-configuration/remoteConfiguration\";\nimport { remoteConfigurationFactory } from \"../../remote-configuration/remoteConfiguration\";\nimport { withRequestPriority } from \"../../handlers/utils\";\nimport type { AssetLoader, AssetResponse } from \"./LensAssetRepository\";\n\ninterface AssetConfig {\n url: string;\n checksum?: string;\n}\n\nconst hasStringValue = (value: unknown): value is { stringValue: string } => {\n return isRecord(value) && isString(value.stringValue);\n};\n\nconst isAssetConfig = (value: unknown): value is AssetConfig => {\n return isRecord(value) && isString(value.url) && (value.checksum === undefined || isString(value.checksum));\n};\n\n/**\n * @internal\n */\nexport const deviceDependentAssetLoaderFactory = Injectable(\n \"deviceDependentAssetLoader\",\n [defaultFetchHandlerFactory.token, remoteConfigurationFactory.token] as const,\n (fetchHandler: FetchHandler, remoteConfiguration: RemoteConfiguration): AssetLoader => {\n const assetHandler = new HandlerChainBuilder(fetchHandler).map(createArrayBufferParsingHandler()).handler;\n\n return async function deviceDependentAssetLoader({\n assetDescriptor: { assetId },\n lowPriority,\n }): Promise<AssetResponse> {\n const loadingFailed = (reason: string, cause?: unknown) =>\n new Error(`Cannot load device-dependent asset ${assetId}. ${reason}`, { cause });\n\n return firstValueFrom(\n remoteConfiguration.get(assetId).pipe(\n catchError((error) => {\n throw loadingFailed(\"COF config failed to load.\", error);\n }),\n map((configs) => {\n if (configs.length === 0) {\n throw loadingFailed(`No COF config found corresponding to that assetId.`);\n }\n // All of the deviceDependent asset configs will only have one value, so we can safely use the\n // first (i.e. only) element in the configs list.\n const [{ value }] = configs;\n\n // Asset configurations are all JSON-encoded in the `stringValue` property. If it doesn't\n // exists, we can't fetch the asset.\n if (!hasStringValue(value)) throw loadingFailed(\"COF config malformed (missing stringValue)\");\n\n let assetConfig: unknown;\n try {\n assetConfig = JSON.parse(value.stringValue);\n } catch (parseError) {\n throw loadingFailed(\"COF config malformed (JSON parse error)\", parseError);\n }\n\n // Asset configurations have a `url` and `checksum` property. Otherwise we're dealing with some\n // other kind of configuration, and cannot fetch the asset.\n if (!isAssetConfig(assetConfig)) throw loadingFailed(\"COF config malformed (missing URL)\");\n\n return assetConfig;\n }),\n mergeMap(async ({ url, checksum }) => {\n // TODO: remove force-cache once https://jira.sc-corp.net/browse/CAMKIT-3671 is addressed\n const [data, response] = await assetHandler(\n url,\n withRequestPriority({ cache: \"force-cache\" }, lowPriority)\n );\n if (!response.ok) throw response;\n return { data, checksum };\n })\n )\n );\n };\n }\n);\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
|
-
import { Injectable } from "
|
|
2
|
+
import { Injectable } from "@snap/ts-inject";
|
|
3
3
|
import { createArrayBufferParsingHandler } from "../../handlers/arrayBufferParsingHandler";
|
|
4
4
|
import { defaultFetchHandlerFactory } from "../../handlers/defaultFetchHandler";
|
|
5
5
|
import { HandlerChainBuilder } from "../../handlers/HandlerChainBuilder";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remoteMediaAssetLoaderFactory.js","sourceRoot":"","sources":["../../../src/lens/assets/remoteMediaAssetLoaderFactory.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"remoteMediaAssetLoaderFactory.js","sourceRoot":"","sources":["../../../src/lens/assets/remoteMediaAssetLoaderFactory.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,+BAA+B,EAAE,MAAM,0CAA0C,CAAC;AAE3F,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAM3D,MAAM,CAAC,MAAM,6BAA6B,GAAG,UAAU,CACnD,wBAAwB,EACxB,CAAC,0BAA0B,CAAC,KAAK,CAAU,EAC3C,CAAC,YAA0B,EAAe,EAAE;IACxC,MAAM,OAAO,GAAG,IAAI,mBAAmB,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,+BAA+B,EAAE,CAAC,CAAC,OAAO,CAAC;IAErG,OAAO,SAAe,sBAAsB,CAAC,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,EAAE,WAAW,EAAE;;YAOtF,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,MAAM,OAAO,CACpC,OAAO,EACP,mBAAmB,CAAC,EAAE,KAAK,EAAE,aAAa,EAAE,EAAE,WAAW,CAAC,CAC7D,CAAC;YACF,IAAI,CAAC,QAAQ,CAAC,EAAE;gBAAE,MAAM,QAAQ,CAAC;YACjC,OAAO,MAAM,CAAC;QAClB,CAAC;KAAA,CAAC;AACN,CAAC,CACJ,CAAC","sourcesContent":["import { Injectable } from \"@snap/ts-inject\";\nimport { createArrayBufferParsingHandler } from \"../../handlers/arrayBufferParsingHandler\";\nimport type { FetchHandler } from \"../../handlers/defaultFetchHandler\";\nimport { defaultFetchHandlerFactory } from \"../../handlers/defaultFetchHandler\";\nimport { HandlerChainBuilder } from \"../../handlers/HandlerChainBuilder\";\nimport { withRequestPriority } from \"../../handlers/utils\";\nimport type { AssetLoader } from \"./LensAssetRepository\";\n\n/**\n * @internal\n */\nexport const remoteMediaAssetLoaderFactory = Injectable(\n \"remoteMediaAssetLoader\",\n [defaultFetchHandlerFactory.token] as const,\n (fetchHandler: FetchHandler): AssetLoader => {\n const handler = new HandlerChainBuilder(fetchHandler).map(createArrayBufferParsingHandler()).handler;\n\n return async function remoteMediaAssetLoader({ assetDescriptor: { assetId }, lowPriority }) {\n // as a default option assuming that RemoteMedia asset type contains asset url in assetId\n // this behavior could be changed by providing own implementation for RemoteMedia asset loader\n // const cameraKit = bootstrapCameraKit(config, container => {\n // return container.provides(Injectable(\n // remoteMediaAssetLoaderFactory.token, ...\n // TODO: remove force-cache once https://jira.sc-corp.net/browse/CAMKIT-3671 is addressed\n const [buffer, response] = await handler(\n assetId,\n withRequestPriority({ cache: \"force-cache\" }, lowPriority)\n );\n if (!response.ok) throw response;\n return buffer;\n };\n }\n);\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
|
-
import { Injectable } from "
|
|
2
|
+
import { Injectable } from "@snap/ts-inject";
|
|
3
3
|
import { createArrayBufferParsingHandler } from "../../handlers/arrayBufferParsingHandler";
|
|
4
4
|
import { defaultFetchHandlerFactory } from "../../handlers/defaultFetchHandler";
|
|
5
5
|
import { HandlerChainBuilder } from "../../handlers/HandlerChainBuilder";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"staticAssetLoader.js","sourceRoot":"","sources":["../../../src/lens/assets/staticAssetLoader.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"staticAssetLoader.js","sourceRoot":"","sources":["../../../src/lens/assets/staticAssetLoader.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,+BAA+B,EAAE,MAAM,0CAA0C,CAAC;AAE3F,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAM3D,MAAM,CAAC,MAAM,wBAAwB,GAAG,UAAU,CAC9C,mBAAmB,EACnB,CAAC,0BAA0B,CAAC,KAAK,CAAU,EAC3C,CAAC,YAA0B,EAAe,EAAE;IACxC,MAAM,OAAO,GAAG,IAAI,mBAAmB,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,+BAA+B,EAAE,CAAC,CAAC,OAAO,CAAC;IAErG,OAAO,CAAO,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,EAAE,aAAa,EAAE,WAAW,EAAE,EAAE,EAAE;;QAC1E,MAAM,QAAQ,GAAG,MAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,KAAK,OAAO,CAAC,0CAAE,QAAQ,CAAC;QACtF,IAAI,CAAC,QAAQ,EAAE;YACX,MAAM,IAAI,KAAK,CAAC,0BAA0B,OAAO,wCAAwC,CAAC,CAAC;SAC9F;QAED,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,MAAM,OAAO,CACpC,QAAQ,EACR,mBAAmB,CAAC,EAAE,KAAK,EAAE,aAAa,EAAE,EAAE,WAAW,CAAC,CAC7D,CAAC;QACF,IAAI,CAAC,QAAQ,CAAC,EAAE;YAAE,MAAM,QAAQ,CAAC;QACjC,OAAO,MAAM,CAAC;IAClB,CAAC,CAAA,CAAC;AACN,CAAC,CACJ,CAAC","sourcesContent":["import { Injectable } from \"@snap/ts-inject\";\nimport { createArrayBufferParsingHandler } from \"../../handlers/arrayBufferParsingHandler\";\nimport type { FetchHandler } from \"../../handlers/defaultFetchHandler\";\nimport { defaultFetchHandlerFactory } from \"../../handlers/defaultFetchHandler\";\nimport { HandlerChainBuilder } from \"../../handlers/HandlerChainBuilder\";\nimport { withRequestPriority } from \"../../handlers/utils\";\nimport type { AssetLoader } from \"./LensAssetRepository\";\n\n/**\n * @internal\n */\nexport const staticAssetLoaderFactory = Injectable(\n \"staticAssetLoader\",\n [defaultFetchHandlerFactory.token] as const,\n (fetchHandler: FetchHandler): AssetLoader => {\n const handler = new HandlerChainBuilder(fetchHandler).map(createArrayBufferParsingHandler()).handler;\n\n return async ({ assetDescriptor: { assetId }, assetManifest, lowPriority }) => {\n const assetUrl = assetManifest?.find((manifest) => manifest.id === assetId)?.assetUrl;\n if (!assetUrl) {\n throw new Error(`Cannot load lens asset ${assetId}. Static asset URL could not be found.`);\n }\n // TODO: remove force-cache once https://jira.sc-corp.net/browse/CAMKIT-3671 is addressed\n const [buffer, response] = await handler(\n assetUrl,\n withRequestPriority({ cache: \"force-cache\" }, lowPriority)\n );\n if (!response.ok) throw response;\n return buffer;\n };\n }\n);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cameraKitLensSource.d.ts","sourceRoot":"","sources":["../../src/lens/cameraKitLensSource.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cameraKitLensSource.d.ts","sourceRoot":"","sources":["../../src/lens/cameraKitLensSource.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAC;AAIvF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAmB/C;;;;;;;;GAQG;AACH,eAAO,MAAM,0BAA0B;;;;CAgFtC,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
2
|
import { catchError, firstValueFrom, map, of } from "rxjs";
|
|
3
|
-
import {
|
|
3
|
+
import { BinaryWriter } from "@bufbuild/protobuf/wire";
|
|
4
|
+
import { Injectable } from "@snap/ts-inject";
|
|
4
5
|
import { Lens } from "../generated-proto/pb_schema/camera_kit/v3/lens";
|
|
5
6
|
import { lensesClientFactory } from "../clients/lensesClient";
|
|
6
|
-
import { Injectable } from "../dependency-injection/Injectable";
|
|
7
7
|
import { remoteConfigurationFactory } from "../remote-configuration/remoteConfiguration";
|
|
8
8
|
import { getLogger } from "../logger/logger";
|
|
9
9
|
import { lensSourcesFactory } from "./LensSource";
|
|
@@ -38,7 +38,7 @@ export const cameraKitLensSourceFactory = Injectable(lensSourcesFactory.token, [
|
|
|
38
38
|
logger.error(error);
|
|
39
39
|
return of(Lens.encode(Lens.fromPartial(defaultWatermarkLens)).finish());
|
|
40
40
|
})));
|
|
41
|
-
return
|
|
41
|
+
return new BinaryWriter().uint32(10).bytes(lensMessage).finish();
|
|
42
42
|
});
|
|
43
43
|
},
|
|
44
44
|
loadLensGroup() {
|
|
@@ -66,7 +66,7 @@ export const cameraKitLensSourceFactory = Injectable(lensSourcesFactory.token, [
|
|
|
66
66
|
throw new Error(`Cannot load lens ${lensId} from group ${groupId}. The response did not contain ` +
|
|
67
67
|
`a lens.\n\t${JSON.stringify(result)} for requestId ${response.headers.get("x-request-id")}`);
|
|
68
68
|
}
|
|
69
|
-
return Lens.encode(response.message.lens,
|
|
69
|
+
return Lens.encode(response.message.lens, new BinaryWriter().uint32(10).fork()).join().finish();
|
|
70
70
|
});
|
|
71
71
|
},
|
|
72
72
|
loadLensGroup(groupId) {
|
|
@@ -83,8 +83,8 @@ export const cameraKitLensSourceFactory = Injectable(lensSourcesFactory.token, [
|
|
|
83
83
|
throw new Error(`Cannot load lens group ${groupId}. The response contained no lenses ` +
|
|
84
84
|
`\n\t${JSON.stringify(response)} for requestId ${response.headers.get("x-request-id")}`);
|
|
85
85
|
}
|
|
86
|
-
const writer =
|
|
87
|
-
response.message.lenses.forEach((lens) => Lens.encode(lens, writer.uint32(10).fork()).
|
|
86
|
+
const writer = new BinaryWriter();
|
|
87
|
+
response.message.lenses.forEach((lens) => Lens.encode(lens, writer.uint32(10).fork()).join());
|
|
88
88
|
return writer.finish();
|
|
89
89
|
});
|
|
90
90
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cameraKitLensSource.js","sourceRoot":"","sources":["../../src/lens/cameraKitLensSource.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC3D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"cameraKitLensSource.js","sourceRoot":"","sources":["../../src/lens/cameraKitLensSource.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,iDAAiD,CAAC;AAEvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D,OAAO,EAAE,0BAA0B,EAAE,MAAM,6CAA6C,CAAC;AAEzF,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;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/ts-inject\";\nimport { Lens } from \"../generated-proto/pb_schema/camera_kit/v3/lens\";\nimport type { LensesClient } from \"../clients/lensesClient\";\nimport { lensesClientFactory } from \"../clients/lensesClient\";\nimport type { RemoteConfiguration } from \"../remote-configuration/remoteConfiguration\";\nimport { remoteConfigurationFactory } from \"../remote-configuration/remoteConfiguration\";\nimport type { ConfigResult } from \"../generated-proto/pb_schema/cdp/cof/config_result\";\nimport { getLogger } from \"../logger/logger\";\nimport type { LensSource } from \"./LensSource\";\nimport { lensSourcesFactory } from \"./LensSource\";\nimport { watermarksLensGroup } from \"./fetchWatermarkLens\";\n\nconst logger = getLogger(\"CameraKitLensSource\");\n\nconst hasAnyValue = (c: ConfigResult): c is ConfigResult & { value: { anyValue: { value: Uint8Array } } } => {\n return c.value?.anyValue?.value instanceof Uint8Array;\n};\n\nconst defaultWatermarkLens = {\n id: \"60515300902\",\n name: \"Watermark\",\n content: {\n lnsSha256: \"3EDEAEBCD51A547FF4D1F5708FBD6F4D628AD736BEE07AB3844B14E6C69EC510\",\n lnsUrlBolt:\n \"https://bolt-gcdn.sc-cdn.net/3/L6uAe5Fhyg0ZFf3RLsCVZ?bo=EhgaABoAMgF9OgEEQgYIkbHPpgZIAlASYAE%3D&uc=18\",\n },\n};\n/**\n * This LensSource loads lenses from the CameraKit backend service. It is meant to be used as the last LensSource in the\n * LensSource[] array used by LensRepository to load lenses.\n *\n * We ensure this is the case by providing cameraKitLensSourceFactory *after* the DI container has been modified by the\n * application during bootstrap -- this way we're guaranteed to place this LensSource after all other LensSources.\n *\n * @internal\n */\nexport const cameraKitLensSourceFactory = Injectable(\n lensSourcesFactory.token,\n [lensSourcesFactory.token, lensesClientFactory.token, remoteConfigurationFactory.token] as const,\n (lensSources: LensSource[], lensesClient: LensesClient, remoteConfig: RemoteConfiguration): LensSource[] => [\n // Watermark source goes always first not allowing apps to override it\n {\n isGroupOwner(groupId: string) {\n return groupId === watermarksLensGroup;\n },\n async loadLens() {\n const lensMessage = await firstValueFrom(\n remoteConfig.get(\"CAMERA_KIT_WATERMARK_LENS\").pipe(\n map((configResults) => {\n const lensMessage = configResults.find(hasAnyValue)?.value.anyValue.value;\n if (!lensMessage) throw new Error(\"Failed to read watermark Lens from COF response.\");\n return lensMessage;\n }),\n catchError((error) => {\n logger.error(error);\n return of(Lens.encode(Lens.fromPartial(defaultWatermarkLens)).finish());\n })\n )\n );\n\n return new BinaryWriter().uint32(10).bytes(lensMessage).finish();\n },\n async loadLensGroup() {\n throw new Error(\"Not implemented.\");\n },\n },\n // custom lens sources provided by apps\n ...lensSources,\n {\n // This LensSource will claim ownership of all lens groups -- it should be used as the last element in a\n // list of LensSources, as a catch-all to load any lens groups not claimed by other LensSources.\n isGroupOwner(): boolean {\n return true;\n },\n\n async loadLens(lensId: string, groupId: string): Promise<ArrayBuffer> {\n const result = await lensesClient.getGroupLens({ lensId, groupId });\n if (!result.ok) {\n const error = result.unwrapErr();\n throw new Error(\n `Cannot load lens lens ${lensId} from group ${groupId}. An error occured in the ` +\n `gRPC client:\\n\\t[${error.status}] ${error.statusMessage}`\n );\n }\n const response = result.unwrap();\n if (!response.message?.lens) {\n throw new Error(\n `Cannot load lens ${lensId} from group ${groupId}. The response did not contain ` +\n `a lens.\\n\\t${JSON.stringify(result)} for requestId ${response.headers.get(\"x-request-id\")}`\n );\n }\n return Lens.encode(response.message.lens, new BinaryWriter().uint32(10).fork()).join().finish();\n },\n\n async loadLensGroup(groupId: string): Promise<ArrayBuffer> {\n const result = await lensesClient.getGroup({ id: groupId });\n if (!result.ok) {\n const error = result.unwrapErr();\n throw new Error(\n `Cannot load lens group ${groupId}. An error occurred in the gRPC client:\\n` +\n `\\t[${error.status}] ${error.statusMessage}`\n );\n }\n const response = result.unwrap();\n if (!response.message?.lenses) {\n throw new Error(\n `Cannot load lens group ${groupId}. The response contained no lenses ` +\n `\\n\\t${JSON.stringify(response)} for requestId ${response.headers.get(\"x-request-id\")}`\n );\n }\n const writer = new BinaryWriter();\n response.message.lenses.forEach((lens) => Lens.encode(lens, writer.uint32(10).fork()).join());\n return writer.finish();\n },\n },\n ]\n);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchWatermarkLens.d.ts","sourceRoot":"","sources":["../../src/lens/fetchWatermarkLens.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fetchWatermarkLens.d.ts","sourceRoot":"","sources":["../../src/lens/fetchWatermarkLens.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAC;AAGvF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAMvD,eAAO,MAAM,mBAAmB,eAAe,CAAC;AAEhD;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;CAiB9B,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
2
|
import { take } from "rxjs";
|
|
3
|
+
import { Injectable } from "@snap/ts-inject";
|
|
3
4
|
import { remoteConfigurationFactory } from "../remote-configuration/remoteConfiguration";
|
|
4
|
-
import { Injectable } from "../dependency-injection/Injectable";
|
|
5
5
|
import { getLogger } from "../logger/logger";
|
|
6
6
|
import { lensRepositoryFactory } from "./LensRepository";
|
|
7
7
|
const logger = getLogger("fetchWatermarkLens");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchWatermarkLens.js","sourceRoot":"","sources":["../../src/lens/fetchWatermarkLens.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"fetchWatermarkLens.js","sourceRoot":"","sources":["../../src/lens/fetchWatermarkLens.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EAAE,0BAA0B,EAAE,MAAM,6CAA6C,CAAC;AACzF,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,MAAM,MAAM,GAAG,SAAS,CAAC,oBAAoB,CAAC,CAAC;AAG/C,MAAM,CAAC,MAAM,mBAAmB,GAAG,YAAY,CAAC;AAKhD,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CACxC,oBAAoB,EACpB,CAAC,0BAA0B,CAAC,KAAK,EAAE,qBAAqB,CAAC,KAAK,CAAU,EACxE,CAAC,mBAAwC,EAAE,cAA8B,EAAE,EAAE;IACzE,mBAAmB;SACd,uBAAuB,EAAE;SACzB,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACb,SAAS,CAAC;QACP,IAAI,EAAE,CAAO,MAAM,EAAE,EAAE;YACnB,IAAI,MAAM,CAAC,gBAAgB,EAAE;gBACzB,MAAM,IAAI,GAAG,MAAM,cAAc,CAAC,QAAQ,CAAC,EAAE,EAAE,mBAAmB,CAAC,CAAC;gBACpE,MAAM,cAAc,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;aACjD;QACL,CAAC,CAAA;QACD,KAAK,EAAE,MAAM,CAAC,KAAK;KACtB,CAAC,CAAC;AACX,CAAC,CACJ,CAAC","sourcesContent":["import { take } from \"rxjs\";\nimport { Injectable } from \"@snap/ts-inject\";\nimport type { RemoteConfiguration } from \"../remote-configuration/remoteConfiguration\";\nimport { remoteConfigurationFactory } from \"../remote-configuration/remoteConfiguration\";\nimport { getLogger } from \"../logger/logger\";\nimport type { LensRepository } from \"./LensRepository\";\nimport { lensRepositoryFactory } from \"./LensRepository\";\n\nconst logger = getLogger(\"fetchWatermarkLens\");\n\n// Special group for all \"watermark\" lenses that are applied by the Camera Kit internally.\nexport const watermarksLensGroup = \"watermarks\";\n\n/**\n * @internal\n */\nexport const fetchWatermarkLens = Injectable(\n \"fetchWatermarkLens\",\n [remoteConfigurationFactory.token, lensRepositoryFactory.token] as const,\n (remoteConfiguration: RemoteConfiguration, lensRepository: LensRepository) => {\n remoteConfiguration\n .getInitializationConfig()\n .pipe(take(1))\n .subscribe({\n next: async (config) => {\n if (config.watermarkEnabled) {\n const lens = await lensRepository.loadLens(\"\", watermarksLensGroup);\n await lensRepository.cacheLensContent([lens]);\n }\n },\n error: logger.error,\n });\n }\n);\n"]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Lens } from "./Lens";
|
|
2
|
+
/**
|
|
3
|
+
* Callback for determining user data access levels on a per-lens basis.
|
|
4
|
+
*
|
|
5
|
+
* @param lens - The lens for which the data access level is being determined.
|
|
6
|
+
* @returns
|
|
7
|
+
* - `"unrestricted"`: The lens can access sensitive user data if needed.
|
|
8
|
+
* - `"restricted"`: The lens is denied access to sensitive user data, like location.
|
|
9
|
+
* - A `Promise` that resolves to one of these values.
|
|
10
|
+
*
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export type UserDataAccessResolver = (lens: Lens) => "restricted" | "unrestricted" | Promise<"restricted" | "unrestricted">;
|
|
14
|
+
/**
|
|
15
|
+
* Service for determining user data access levels on a per-lens basis.
|
|
16
|
+
* Can be overridden by applications to control access for individual lenses.
|
|
17
|
+
*
|
|
18
|
+
* Some lenses may require access to sensitive user data, such as location, to function properly.
|
|
19
|
+
* APIs marked with the `Exposes User Data` tag (e.g., those in
|
|
20
|
+
* [UserContextSystem](https://developers.snap.com/lens-studio/api/lens-scripting/interfaces/Built_In.UserContextSystem.html))
|
|
21
|
+
* expose this sensitive data, and access to these APIs is managed through this resolver to ensure
|
|
22
|
+
* proper control and privacy.
|
|
23
|
+
*
|
|
24
|
+
* The access level determines whether a lens can access such data:
|
|
25
|
+
* - `"unrestricted"` (default): The lens can access sensitive user data if needed.
|
|
26
|
+
* - `"restricted"`: The lens is denied access to sensitive user data, like location.
|
|
27
|
+
*
|
|
28
|
+
* Example usage:
|
|
29
|
+
*
|
|
30
|
+
* ```ts
|
|
31
|
+
* const cameraKit = bootstrapCameraKit(config, (container) => {
|
|
32
|
+
* container.provides(
|
|
33
|
+
* Injectable(
|
|
34
|
+
* lensUserDataAccessResolverFactory.token,
|
|
35
|
+
* (): LensUserDataAccessResolver => (lens: Lens) => {
|
|
36
|
+
* return doesLensRequireStrictAccess(lens)
|
|
37
|
+
* ? "restricted"
|
|
38
|
+
* : "unrestricted";
|
|
39
|
+
* }
|
|
40
|
+
* )
|
|
41
|
+
* );
|
|
42
|
+
* });
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @internal
|
|
46
|
+
*/
|
|
47
|
+
export declare const userDataAccessResolverFactory: {
|
|
48
|
+
(): UserDataAccessResolver;
|
|
49
|
+
token: "userDataAccessResolver";
|
|
50
|
+
dependencies: [];
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=userDataAccessResolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"userDataAccessResolver.d.ts","sourceRoot":"","sources":["../../src/lens/userDataAccessResolver.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEnC;;;;;;;;;;GAUG;AACH,MAAM,MAAM,sBAAsB,GAAG,CACjC,IAAI,EAAE,IAAI,KACT,YAAY,GAAG,cAAc,GAAG,OAAO,CAAC,YAAY,GAAG,cAAc,CAAC,CAAC;AAG5E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,eAAO,MAAM,6BAA6B;;;;CAGzC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"userDataAccessResolver.js","sourceRoot":"","sources":["../../src/lens/userDataAccessResolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAqD7C,MAAM,CAAC,MAAM,6BAA6B,GAAG,UAAU,CACnD,wBAAwB,EACxB,GAA2B,EAAE,CAAC,GAAG,EAAE,CAAC,cAAc,CACrD,CAAC","sourcesContent":["import { Injectable } from \"@snap/ts-inject\";\nimport type { Lens } from \"./Lens\";\n\n/**\n * Callback for determining user data access levels on a per-lens basis.\n *\n * @param lens - The lens for which the data access level is being determined.\n * @returns\n * - `\"unrestricted\"`: The lens can access sensitive user data if needed.\n * - `\"restricted\"`: The lens is denied access to sensitive user data, like location.\n * - A `Promise` that resolves to one of these values.\n *\n * @internal\n */\nexport type UserDataAccessResolver = (\n lens: Lens\n) => \"restricted\" | \"unrestricted\" | Promise<\"restricted\" | \"unrestricted\">;\n\n/* eslint-disable max-len */\n/**\n * Service for determining user data access levels on a per-lens basis.\n * Can be overridden by applications to control access for individual lenses.\n *\n * Some lenses may require access to sensitive user data, such as location, to function properly.\n * APIs marked with the `Exposes User Data` tag (e.g., those in\n * [UserContextSystem](https://developers.snap.com/lens-studio/api/lens-scripting/interfaces/Built_In.UserContextSystem.html))\n * expose this sensitive data, and access to these APIs is managed through this resolver to ensure\n * proper control and privacy.\n *\n * The access level determines whether a lens can access such data:\n * - `\"unrestricted\"` (default): The lens can access sensitive user data if needed.\n * - `\"restricted\"`: The lens is denied access to sensitive user data, like location.\n *\n * Example usage:\n *\n * ```ts\n * const cameraKit = bootstrapCameraKit(config, (container) => {\n * container.provides(\n * Injectable(\n * lensUserDataAccessResolverFactory.token,\n * (): LensUserDataAccessResolver => (lens: Lens) => {\n * return doesLensRequireStrictAccess(lens)\n * ? \"restricted\"\n * : \"unrestricted\";\n * }\n * )\n * );\n * });\n * ```\n *\n * @internal\n */\n/* eslint-enable max-len */\nexport const userDataAccessResolverFactory = Injectable(\n \"userDataAccessResolver\",\n (): UserDataAccessResolver => () => \"unrestricted\"\n);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filePicker.d.ts","sourceRoot":"","sources":["../../src/lens-client-interface/filePicker.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"filePicker.d.ts","sourceRoot":"","sources":["../../src/lens-client-interface/filePicker.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElE;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,OAAO,QAAQ,CAAC;AAEpD;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC;AAErE;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC,cAAc,GAAG,cAAc,EAAE,CAAC,CAAC;AAE1E;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,qBAAqB,KAAK,gBAAgB,CAAC;AAEpH;;;GAGG;AACH,eAAO,MAAM,iBAAiB;;;;CAG7B,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Injectable } from "
|
|
1
|
+
import { Injectable } from "@snap/ts-inject";
|
|
2
2
|
export const filePickerFactory = Injectable("filePicker", () => (options, openDefaultPicker) => openDefaultPicker(options));
|
|
3
3
|
//# sourceMappingURL=filePicker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filePicker.js","sourceRoot":"","sources":["../../src/lens-client-interface/filePicker.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"filePicker.js","sourceRoot":"","sources":["../../src/lens-client-interface/filePicker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AA+B7C,MAAM,CAAC,MAAM,iBAAiB,GAAG,UAAU,CACvC,YAAY,EACZ,GAAe,EAAE,CAAC,CAAC,OAAO,EAAE,iBAAiB,EAAE,EAAE,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAC/E,CAAC","sourcesContent":["import { Injectable } from \"@snap/ts-inject\";\nimport type { FileWithHandle, fileOpen } from \"browser-fs-access\";\n\n/**\n * Default file picker dialog type.\n */\nexport type OpenDefaultFilePicker = typeof fileOpen;\n\n/**\n * File picker options. For example, it indicates which MIME types of files are expected to be picked.\n */\nexport type FilePickerOptions = Parameters<OpenDefaultFilePicker>[0];\n\n/**\n * File picker dialog result object, which is a Promise that resolves to a file or an array of files with handles.\n */\nexport type FilePickerResult = Promise<FileWithHandle | FileWithHandle[]>;\n\n/**\n * A callback to show a file picker dialog.\n * @param options - Options for the file picker dialog.\n * @param openDefaultPicker - The default file picker function. The client app may choose to use\n * the default file picker.\n * @returns A promise that resolves to the result of the file picker dialog.\n */\nexport type FilePicker = (options: FilePickerOptions, openDefaultPicker: OpenDefaultFilePicker) => FilePickerResult;\n\n/**\n * Default file picker factory function. The file picker is triggered when a lens issues a file request.\n * Client applications can override this factory function to provide their custom file picker.\n */\nexport const filePickerFactory = Injectable(\n \"filePicker\",\n (): FilePicker => (options, openDefaultPicker) => openDefaultPicker(options)\n);\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
|
+
import { Injectable } from "@snap/ts-inject";
|
|
2
3
|
import { lensImagePickerError } from "../namedErrors";
|
|
3
|
-
import { Injectable } from "../dependency-injection/Injectable";
|
|
4
4
|
import { getLogger } from "../logger/logger";
|
|
5
5
|
import { lensCoreFactory } from "../lens-core-module/loader/lensCoreFactory";
|
|
6
6
|
import { pickClientImage } from "./imagePicker";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lensClientInterface.js","sourceRoot":"","sources":["../../src/lens-client-interface/lensClientInterface.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"lensClientInterface.js","sourceRoot":"","sources":["../../src/lens-client-interface/lensClientInterface.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,4CAA4C,CAAC;AAE7E,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,MAAM,MAAM,GAAG,SAAS,CAAC,qBAAqB,CAAC,CAAC;AAShD,MAAM,CAAC,MAAM,kCAAkC,GAAG,UAAU,CACxD,oCAAoC,EACpC,CAAC,eAAe,CAAC,KAAK,EAAE,iBAAiB,CAAC,KAAK,CAAU,EACzD,CAAC,QAAkB,EAAE,UAAsB,EAAE,EAAE;IAE3C,IAAI,CAAC,QAAQ,CAAC,gCAAgC,EAAE;QAC5C,MAAM,CAAC,IAAI,CAAC,yEAAyE,CAAC,CAAC;QACvF,OAAO;KACV;IAED,QAAQ,CAAC,gCAAgC,CAAC,CAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,eAAe,EAAE,EAAE,EAAE;QAC5F,IACI,gBAAgB,KAAK,QAAQ,CAAC,gBAAgB,CAAC,WAAW;YAC1D,eAAe,KAAK,QAAQ,CAAC,eAAe,CAAC,IAAI,EACnD;YACE,MAAM,eAAe,CAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;gBAC9D,MAAM,CAAC,KAAK,CACR,oBAAoB,CAChB,+EAA+E,EAC/E,KAAK,CACR,CACJ,CAAC;YACN,CAAC,CAAC,CAAC;SACN;IACL,CAAC,CAAA,CAAC,CAAC;AACP,CAAC,CACJ,CAAC","sourcesContent":["import { Injectable } from \"@snap/ts-inject\";\nimport { lensImagePickerError } from \"../namedErrors\";\nimport { getLogger } from \"../logger/logger\";\nimport { lensCoreFactory } from \"../lens-core-module/loader/lensCoreFactory\";\nimport type { LensCore } from \"../lens-core-module/lensCore\";\nimport { pickClientImage } from \"./imagePicker\";\nimport type { FilePicker } from \"./filePicker\";\nimport { filePickerFactory } from \"./filePicker\";\n\nconst logger = getLogger(\"lensClientInterface\");\n\n/**\n * Registers client interface handler in LensCore.\n *\n * @internal\n * @param lensCore LensCore instance to register in.\n * @param sessionErrors EventTarget to dispatch errors in.\n */\nexport const registerLensClientInterfaceHandler = Injectable(\n \"registerLensClientInterfaceHandler\",\n [lensCoreFactory.token, filePickerFactory.token] as const,\n (lensCore: LensCore, filePicker: FilePicker) => {\n // Make sure we are compatible with previous LensCore versions\n if (!lensCore.setClientInterfaceRequestHandler) {\n logger.warn(\"Current LensCore version doesn't support lens client interface requests\");\n return;\n }\n\n lensCore.setClientInterfaceRequestHandler(async ({ data, interfaceControl, interfaceAction }) => {\n if (\n interfaceControl === lensCore.InterfaceControl.ImagePicker &&\n interfaceAction === lensCore.InterfaceAction.Show\n ) {\n await pickClientImage(data, lensCore, filePicker).catch((error) => {\n logger.error(\n lensImagePickerError(\n \"Error occurred while attempting to select an image file for the lens request.\",\n error\n )\n );\n });\n }\n });\n }\n);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lensCoreFactory.d.ts","sourceRoot":"","sources":["../../../src/lens-core-module/loader/lensCoreFactory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lensCoreFactory.d.ts","sourceRoot":"","sources":["../../../src/lens-core-module/loader/lensCoreFactory.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAElE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAQvE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4CAA4C,CAAC;AAW1F,eAAO,MAAM,yBAAyB,iBAAiB,CAAC;AACxD,eAAO,MAAM,2BAA2B,mBAAmB,CAAC;AAE5D,MAAM,WAAW,0BAA2B,SAAQ,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IACtE,WAAW,EAAE,OAAO,yBAAyB,GAAG,OAAO,2BAA2B,CAAC;IACnF,WAAW,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe;;;;CAiG3B,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
|
+
import { Injectable } from "@snap/ts-inject";
|
|
2
3
|
import lensCoreWasm from "../../lensCoreWasmVersions";
|
|
3
4
|
import { configurationToken } from "../../configuration";
|
|
4
|
-
import { Injectable } from "../../dependency-injection/Injectable";
|
|
5
5
|
import { defaultFetchHandlerFactory } from "../../handlers/defaultFetchHandler";
|
|
6
6
|
import { getLogger } from "../../logger/logger";
|
|
7
7
|
import { createLensCore } from "../lensCore";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lensCoreFactory.js","sourceRoot":"","sources":["../../../src/lens-core-module/loader/lensCoreFactory.ts"],"names":[],"mappings":";AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"lensCoreFactory.js","sourceRoot":"","sources":["../../../src/lens-core-module/loader/lensCoreFactory.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,YAAY,MAAM,4BAA4B,CAAC;AAEtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAEhF,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AAEnF,OAAO,EACH,iCAAiC,EACjC,8BAA8B,GACjC,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,wBAA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Ac,GAAG,MAAM,CAAC;oBACtC,OAAO,CAAC,UAAU,CAAC,CAAC;gBACxB,CAAC,CAAC;qBACD,KAAK,CAAC,MAAM,CAAC,CAAC;YACvB,CAAC;SACJ,CAAC,CACL,CAAC;IACN,CAAC,CAAC,CAAC;IAGH,aAAa,CAAC,MAAM,EAAE,CAAC;IAGvB,IAAI,YAAY,CAAC,OAAO,IAAI,GAAG,QAAQ,CAAC,cAAc,EAAE,EAAE,EAAE;QACxD,MAAM,CAAC,IAAI,CACP,4BAA4B,QAAQ,CAAC,cAAc,EAAE,gCACjD,YAAY,CAAC,OACjB,GAAG,CACN,CAAC;KACL;IAED,OAAO,cAAc,CAAC,QAAQ,CAAC,CAAC;AACpC,CAAC,CAAA,CACJ,CAAC","sourcesContent":["import { Injectable } from \"@snap/ts-inject\";\nimport lensCoreWasm from \"../../lensCoreWasmVersions\";\nimport type { CameraKitConfiguration } from \"../../configuration\";\nimport { configurationToken } from \"../../configuration\";\nimport type { FetchHandler } from \"../../handlers/defaultFetchHandler\";\nimport { defaultFetchHandlerFactory } from \"../../handlers/defaultFetchHandler\";\nimport type { InitialEmscriptenModule, LensCoreModule } from \"../generated-types\";\nimport { getLogger } from \"../../logger/logger\";\nimport { createLensCore } from \"../lensCore\";\nimport { loadScript } from \"../../common/loadScript\";\nimport { HandlerChainBuilder } from \"../../handlers/HandlerChainBuilder\";\nimport { createCustomLensCoreHandler } from \"../../handlers/customLensCoreHandler\";\nimport type { RequestStateEventTarget } from \"../../handlers/requestStateEmittingHandler\";\nimport {\n createRequestStateEmittingHandler,\n requestStateEventTargetFactory,\n} from \"../../handlers/requestStateEmittingHandler\";\nimport { getRequiredBootstrapURLs } from \"./bootstrapURLs\";\n\nconst logger = getLogger(\"lensCoreFactory\");\n\nconst findMatch = (regex: RegExp, strings: string[]) => strings.find((s) => regex.test(s));\n\nexport const LENS_CORE_JS_REQUEST_TYPE = \"lens_core_js\";\nexport const LENS_CORE_WASM_REQUEST_TYPE = \"lens_core_wasm\";\n\nexport interface LensCoreDownloadDimensions extends Record<string, string> {\n requestType: typeof LENS_CORE_JS_REQUEST_TYPE | typeof LENS_CORE_WASM_REQUEST_TYPE;\n customBuild: string;\n}\n\n/**\n * This component is responsible for:\n * 1) Loading LensCore WebAssembly (WASM) assets\n * 2) Using the WASM assets to initialize the LensCore WASM module\n *\n * By default, WASM assets will be loaded from the Bolt CDN – but if `endpoint` is provided, assets will be loaded\n * using it as a base URL.\n *\n * @internal\n */\nexport const lensCoreFactory = Injectable(\n \"lensCore\",\n [defaultFetchHandlerFactory.token, configurationToken, requestStateEventTargetFactory.token] as const,\n async (\n handler: FetchHandler,\n { lensCoreOverrideUrls, wasmEndpointOverride }: CameraKitConfiguration,\n requestStateEventTarget: RequestStateEventTarget\n ) => {\n let lensCoreJS: string;\n let lensCoreWASM: string;\n\n const customBuild = !!(lensCoreOverrideUrls || wasmEndpointOverride);\n let lensCoreHandlerChainBuilder = new HandlerChainBuilder(handler);\n if (customBuild) {\n // We only use custom handler when LensCore is loaded from a custom location.\n lensCoreHandlerChainBuilder = lensCoreHandlerChainBuilder.map(createCustomLensCoreHandler());\n }\n // add metrics to LC requests\n const lensCoreHandler = lensCoreHandlerChainBuilder.map(\n // TODO: ideally we don't need it here: https://jira.sc-corp.net/browse/CAMKIT-6350\n createRequestStateEmittingHandler<LensCoreDownloadDimensions>(requestStateEventTarget)\n ).handler;\n\n if (lensCoreOverrideUrls) {\n lensCoreJS = lensCoreOverrideUrls.js;\n lensCoreWASM = lensCoreOverrideUrls.wasm;\n } else {\n const endpointOverride = wasmEndpointOverride ?? undefined;\n const assetURLs = await getRequiredBootstrapURLs(endpointOverride);\n\n lensCoreJS = findMatch(/\\.js/, assetURLs) ?? \"\";\n lensCoreWASM = findMatch(/\\.wasm/, assetURLs) ?? \"\";\n\n if (!lensCoreJS || !lensCoreWASM) {\n throw new Error(\n `Cannot fetch required LensCore assets. Either the JS or WASM filename is missing from ` +\n `this list: ${assetURLs}.`\n );\n }\n\n // Fetching here and creating an Object URL lets LensCore optimized loading itself in a WebWorker,\n // otherwise the glue script would need to be downloaded again.\n const glueScript = await lensCoreHandler([\n lensCoreJS,\n { requestType: LENS_CORE_JS_REQUEST_TYPE, customBuild: `${customBuild}` },\n ]).then((r) => r.blob());\n lensCoreJS = URL.createObjectURL(glueScript);\n }\n\n const scriptElement = await loadScript(lensCoreJS);\n\n const lensCore = await new Promise<InitialEmscriptenModule & LensCoreModule>((resolve, reject) => {\n let initialModule: Partial<InitialEmscriptenModule>;\n // will trigger WASM initialization and data loading,\n // after completion it will be safe to call imported WASM functions\n // More about emscripten initialization:\n // eslint-disable-next-line max-len\n // https://emscripten.org/docs/getting_started/FAQ.html?highlight=modularize#how-can-i-tell-when-the-page-is-fully-loaded-and-it-is-safe-to-call-compiled-functions\n const moduleInit = globalThis.createLensesModule(\n (initialModule = {\n // url will be used for loading glue JS during Worker initialization\n mainScriptUrlOrBlob: lensCoreJS,\n // will be triggered by Emscripten during the initialization\n instantiateWasm: (importObject, receiveInstance) => {\n WebAssembly.instantiateStreaming(\n lensCoreHandler([\n lensCoreWASM,\n { requestType: LENS_CORE_WASM_REQUEST_TYPE, customBuild: `${customBuild}` },\n ]),\n importObject\n )\n .then(function ({ instance, module }) {\n receiveInstance(instance, module);\n // compiled module will be reused in Worker\n initialModule.compiledModule = module;\n resolve(moduleInit);\n })\n .catch(reject);\n },\n })\n );\n });\n\n // now when we have LensCore WASM in memory we can release the script element\n scriptElement.remove();\n\n // print warning if loaded version differs from hardcoded one\n if (lensCoreWasm.version != `${lensCore.getCoreVersion()}`) {\n logger.warn(\n `Loaded LensCore version (${lensCore.getCoreVersion()}) differs from expected one (${\n lensCoreWasm.version\n })`\n );\n }\n\n return createLensCore(lensCore);\n }\n);\n"]}
|