@luckylca/react-native-liquid-glass 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -33
- package/README.zh-CN.md +20 -33
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/android/build.gradle +4 -4
- package/android/src/main/java/expo/modules/{newhuliquidglass → liquidglass}/EffectiveScrollInputBridge.kt +2 -2
- package/android/src/main/java/expo/modules/{newhuliquidglass/ExpoGlassProviderCoreView.kt → liquidglass/GlassCaptureView.kt} +39 -39
- package/android/src/main/java/expo/modules/{newhuliquidglass/CoreLiquidGlassRegistry.kt → liquidglass/GlassRegistry.kt} +7 -7
- package/android/src/main/java/expo/modules/{newhuliquidglass/ExpoGlassSurfaceCoreView.kt → liquidglass/GlassSurfaceView.kt} +17 -17
- package/android/src/main/java/expo/modules/liquidglass/LiquidGlassModule.kt +205 -0
- package/android/src/main/java/expo/modules/{localglass/ExpoLocalGlassEngineModule.kt → liquidglass/LocalMaterialView.kt} +24 -27
- package/android/src/main/java/expo/modules/{newhuliquidglass → liquidglass}/PassSurfaceSuppression.kt +1 -1
- package/android/src/main/java/expo/modules/{newhuliquidglass → liquidglass}/SharedGlassPassProbeLog.kt +1 -1
- package/android/src/main/java/expo/modules/{newhuliquidglass → liquidglass}/SharedGlassPassWiring.kt +3 -3
- package/android-core/build.gradle +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/BackdropRecorder.kt +4 -4
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/FrozenBackdrop.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/GlassBackdropCoordinator.kt +5 -5
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/GlassBackdropSourceHandle.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/GlassScrollSource.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/GlassViewController.kt +119 -722
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/LiquidGlassProviderLayout.kt +2 -2
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/LiquidGlassView.kt +2 -2
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/ReferenceSourceWindowPolicy.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/StableSceneTexturePolicy.kt +1 -1
- package/android-core/src/main/java/io/github/luckylca/liquidglass/backdrop/SurfaceFrameBuilder.kt +278 -0
- package/android-core/src/main/java/io/github/luckylca/liquidglass/backdrop/SurfaceInteraction.kt +359 -0
- package/android-core/src/main/java/io/github/luckylca/liquidglass/backdrop/internal/GlassFrame.kt +110 -0
- package/android-core/src/main/java/io/github/luckylca/liquidglass/backdrop/internal/GlassViewRenderer.kt +728 -0
- package/android-core/src/main/java/io/github/luckylca/liquidglass/backdrop/internal/ReferenceParityPasses.kt +705 -0
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/internal/ReferenceTabSampling.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/internal/SharedSceneCapture.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/GlassCapabilities.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/GlassEngine.kt +7 -7
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/GlassMaterial.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/GlassMath.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/GlassOpticalInsets.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/GlassRenderTier.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/GlassShapePacker.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/GlassSurfaceState.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/GlassUniforms.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/LiquidGlassShaders.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/SharedGlassPass.kt +6 -6
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/geometry/G2RoundedRectangle.kt +2 -2
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/geometry/ReferenceG2MaskTexture.kt +1 -1
- package/android-core/src/main/java/io/github/luckylca/liquidglass/core/shader/HeightFieldGlassShader.kt +7 -0
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/shader/ReferenceBackdropBlurShader.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/shader/ReferenceGaussianDiscBackdropBlur.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/shader/ReferenceGlassUniforms.kt +4 -4
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/shader/ReferenceParityGlassShader.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/shader/ReferenceParityMultiShapeShader.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/shader/SdfScaleLensShader.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/local/LocalGlassHardwareLayerExperiment.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/local/LocalGlassMaterial.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/local/LocalGlassRenderer.kt +2 -2
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/local/LocalGlassRuntimeShader.kt +2 -2
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/local/LocalGlassShader.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/local/LocalGlassView.kt +2 -2
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/motion/GlassMotionDriver.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/motion/GlassMotionState.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/motion/PointerVelocityTracker.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/motion/SpringSpec.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/optics/G2Corner.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/optics/GlassMaterial.kt +3 -3
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/optics/GlassOpticsShader.kt +3 -3
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/optics/GlassParityProbe.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/optics/GlassShapeGeometry.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/optics/GlassUniformBinder.kt +2 -2
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/optics/PixelDiff.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/optics/ReferenceOptics.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/rendering/GlassSurfaceHost.kt +17 -17
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/rendering/GlassSurfaceRenderer.kt +9 -9
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/rendering/RetainedBackdropLayer.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/scheduler/GlassFrameScheduler.kt +2 -2
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/telemetry/EffectiveScrollFpsProbe.kt +13 -13
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/telemetry/GlassTelemetry.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/telemetry/LiquidGlassPerfTelemetry.kt +13 -13
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/telemetry/LiquidGlassTrace.kt +3 -3
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/telemetry/LocalGlassTelemetry.kt +1 -1
- package/docs/architecture.md +61 -0
- package/docs/migration-0.3.md +19 -0
- package/docs/publishing.md +29 -7
- package/expo-module.config.json +4 -4
- package/lib/commonjs/GlassSurface.js +157 -585
- package/lib/commonjs/GlassSurface.js.map +1 -1
- package/lib/commonjs/GlassTabBar.js +18 -957
- package/lib/commonjs/GlassTabBar.js.map +1 -1
- package/lib/commonjs/LocalGlassMaterial.js +3 -9
- package/lib/commonjs/LocalGlassMaterial.js.map +1 -1
- package/lib/commonjs/glassController.js +3 -7
- package/lib/commonjs/glassController.js.map +1 -1
- package/lib/commonjs/glassRuntime.js +7 -19
- package/lib/commonjs/glassRuntime.js.map +1 -1
- package/lib/commonjs/localGlassTelemetry.js +4 -13
- package/lib/commonjs/localGlassTelemetry.js.map +1 -1
- package/lib/commonjs/nativeGlassViews.js +8 -11
- package/lib/commonjs/nativeGlassViews.js.map +1 -1
- package/lib/commonjs/performanceTelemetry.js +2 -6
- package/lib/commonjs/performanceTelemetry.js.map +1 -1
- package/lib/commonjs/surface/InlineSurface.js +134 -0
- package/lib/commonjs/surface/InlineSurface.js.map +1 -0
- package/lib/commonjs/surface/MaterialProvider.js +78 -0
- package/lib/commonjs/surface/MaterialProvider.js.map +1 -0
- package/lib/commonjs/surface/NativeSurface.js +55 -0
- package/lib/commonjs/surface/NativeSurface.js.map +1 -0
- package/lib/commonjs/surface/PortalLayers.js +331 -0
- package/lib/commonjs/surface/PortalLayers.js.map +1 -0
- package/lib/commonjs/surface/contexts.js +108 -0
- package/lib/commonjs/surface/contexts.js.map +1 -0
- package/lib/commonjs/surface/registry.js +113 -0
- package/lib/commonjs/surface/registry.js.map +1 -0
- package/lib/commonjs/surface/styles.js +34 -0
- package/lib/commonjs/surface/styles.js.map +1 -0
- package/lib/commonjs/surface/types.js +3 -0
- package/lib/commonjs/surface/types.js.map +1 -0
- package/lib/commonjs/tabs/GlassTabItem.js +66 -0
- package/lib/commonjs/tabs/GlassTabItem.js.map +1 -0
- package/lib/commonjs/tabs/InlineTabBar.js +867 -0
- package/lib/commonjs/tabs/InlineTabBar.js.map +1 -0
- package/lib/commonjs/tabs/tabConstants.js +22 -0
- package/lib/commonjs/tabs/tabConstants.js.map +1 -0
- package/lib/commonjs/tabs/tabDebug.js +50 -0
- package/lib/commonjs/tabs/tabDebug.js.map +1 -0
- package/lib/commonjs/tabs/tabStyles.js +107 -0
- package/lib/commonjs/tabs/tabStyles.js.map +1 -0
- package/lib/commonjs/tabs/useInlineTabGesture.js +227 -0
- package/lib/commonjs/tabs/useInlineTabGesture.js.map +1 -0
- package/lib/commonjs/theme/buildTheme.js +1 -1
- package/lib/commonjs/theme/buildTheme.js.map +1 -1
- package/lib/module/GlassSurface.js +135 -563
- package/lib/module/GlassSurface.js.map +1 -1
- package/lib/module/GlassTabBar.js +18 -925
- package/lib/module/GlassTabBar.js.map +1 -1
- package/lib/module/LocalGlassMaterial.js +5 -11
- package/lib/module/LocalGlassMaterial.js.map +1 -1
- package/lib/module/glassController.js +3 -7
- package/lib/module/glassController.js.map +1 -1
- package/lib/module/glassRuntime.js +7 -19
- package/lib/module/glassRuntime.js.map +1 -1
- package/lib/module/localGlassTelemetry.js +4 -13
- package/lib/module/localGlassTelemetry.js.map +1 -1
- package/lib/module/nativeGlassViews.js +7 -10
- package/lib/module/nativeGlassViews.js.map +1 -1
- package/lib/module/performanceTelemetry.js +2 -6
- package/lib/module/performanceTelemetry.js.map +1 -1
- package/lib/module/surface/InlineSurface.js +97 -0
- package/lib/module/surface/InlineSurface.js.map +1 -0
- package/lib/module/surface/MaterialProvider.js +74 -0
- package/lib/module/surface/MaterialProvider.js.map +1 -0
- package/lib/module/surface/NativeSurface.js +47 -0
- package/lib/module/surface/NativeSurface.js.map +1 -0
- package/lib/module/surface/PortalLayers.js +292 -0
- package/lib/module/surface/PortalLayers.js.map +1 -0
- package/lib/module/surface/contexts.js +96 -0
- package/lib/module/surface/contexts.js.map +1 -0
- package/lib/module/surface/registry.js +103 -0
- package/lib/module/surface/registry.js.map +1 -0
- package/lib/module/surface/styles.js +31 -0
- package/lib/module/surface/styles.js.map +1 -0
- package/lib/module/surface/types.js +2 -0
- package/lib/module/surface/types.js.map +1 -0
- package/lib/module/tabs/GlassTabItem.js +30 -0
- package/lib/module/tabs/GlassTabItem.js.map +1 -0
- package/lib/module/tabs/InlineTabBar.js +829 -0
- package/lib/module/tabs/InlineTabBar.js.map +1 -0
- package/lib/module/tabs/tabConstants.js +19 -0
- package/lib/module/tabs/tabConstants.js.map +1 -0
- package/lib/module/tabs/tabDebug.js +13 -0
- package/lib/module/tabs/tabDebug.js.map +1 -0
- package/lib/module/tabs/tabStyles.js +104 -0
- package/lib/module/tabs/tabStyles.js.map +1 -0
- package/lib/module/tabs/useInlineTabGesture.js +221 -0
- package/lib/module/tabs/useInlineTabGesture.js.map +1 -0
- package/lib/module/theme/buildTheme.js +1 -1
- package/lib/module/theme/buildTheme.js.map +1 -1
- package/lib/types/GlassSurface.d.ts +17 -86
- package/lib/types/GlassTabBar.d.ts +1 -0
- package/lib/types/glassNativeEngine.d.ts +1 -1
- package/lib/types/glassRuntime.d.ts +5 -2
- package/lib/types/localGlassTelemetry.d.ts +2 -2
- package/lib/types/nativeGlassViews.d.ts +2 -4
- package/lib/types/surface/InlineSurface.d.ts +42 -0
- package/lib/types/surface/MaterialProvider.d.ts +46 -0
- package/lib/types/surface/NativeSurface.d.ts +11 -0
- package/lib/types/surface/PortalLayers.d.ts +33 -0
- package/lib/types/surface/contexts.d.ts +66 -0
- package/lib/types/surface/registry.d.ts +6 -0
- package/lib/types/surface/styles.d.ts +74 -0
- package/lib/types/surface/types.d.ts +118 -0
- package/lib/types/tabs/GlassTabItem.d.ts +20 -0
- package/lib/types/tabs/InlineTabBar.d.ts +5 -0
- package/lib/types/tabs/tabConstants.d.ts +34 -0
- package/lib/types/tabs/tabDebug.d.ts +15 -0
- package/lib/types/tabs/tabStyles.d.ts +119 -0
- package/lib/types/tabs/useInlineTabGesture.d.ts +34 -0
- package/package.json +6 -14
- package/src/GlassSurface.tsx +227 -1337
- package/src/GlassTabBar.tsx +43 -1241
- package/src/LocalGlassMaterial.tsx +5 -11
- package/src/glassController.ts +3 -7
- package/src/glassRuntime.ts +9 -26
- package/src/localGlassTelemetry.ts +6 -15
- package/src/nativeGlassViews.ts +7 -10
- package/src/performanceTelemetry.ts +2 -6
- package/src/surface/InlineSurface.tsx +299 -0
- package/src/surface/MaterialProvider.tsx +235 -0
- package/src/surface/NativeSurface.tsx +115 -0
- package/src/surface/PortalLayers.tsx +574 -0
- package/src/surface/contexts.tsx +188 -0
- package/src/surface/registry.ts +109 -0
- package/src/surface/styles.ts +31 -0
- package/src/surface/types.ts +139 -0
- package/src/tabs/GlassTabItem.tsx +100 -0
- package/src/tabs/InlineTabBar.tsx +1193 -0
- package/src/tabs/tabConstants.ts +35 -0
- package/src/tabs/tabDebug.ts +29 -0
- package/src/tabs/tabStyles.ts +104 -0
- package/src/tabs/useInlineTabGesture.ts +306 -0
- package/src/theme/buildTheme.ts +1 -1
- package/android/src/main/java/expo/modules/localglass/ExpoLocalGlassModule.kt +0 -341
- package/android/src/main/java/expo/modules/localglass/LocalGlassShader.kt +0 -59
- package/android/src/main/java/expo/modules/newhuliquidglass/ExpoGlassCoreModule.kt +0 -226
- package/android-core/src/main/java/com/newhu/liquidglass/backdrop/internal/GlassViewRenderer.kt +0 -1459
- package/android-core/src/main/java/com/newhu/liquidglass/core/shader/HeightFieldGlassShader.kt +0 -7
- package/android-core/src/main/java/com/newhu/liquidglass/rendering/GlassEngineSelection.kt +0 -30
- package/patches/liquid-glass-kit+1.0.0.patch +0 -2015
- package/patches/liquid-glass-kit-invalidation-coalescing.diff +0 -249
- package/patches/liquid-glass-kit-native-infra.diff +0 -624
- package/scripts/apply-legacy-patches.mjs +0 -116
package/src/GlassSurface.tsx
CHANGED
|
@@ -1,1074 +1,24 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useCallback, useContext, useEffect, useId, useRef, useState } from 'react';
|
|
2
2
|
import { findNodeHandle, Platform, StyleSheet, View } from 'react-native';
|
|
3
3
|
import type { ColorValue, LayoutChangeEvent, StyleProp, ViewProps, ViewStyle } from 'react-native';
|
|
4
|
-
import Animated, {
|
|
4
|
+
import Animated, { useAnimatedStyle } from 'react-native-reanimated';
|
|
5
5
|
import type { AnimatedStyle, SharedValue } from 'react-native-reanimated';
|
|
6
|
-
import { LocalGlassMaterial } from './LocalGlassMaterial';
|
|
7
6
|
import type { GlassSurfaceRole } from './surfaceRendererPolicy';
|
|
8
|
-
import {
|
|
9
|
-
import type { GlassNativeEngine } from './glassNativeEngine';
|
|
10
|
-
import { forwardPointerToSurface, forwardValueToSurface } from './glassController';
|
|
11
|
-
import { CoreGlassCaptureSource, CoreGlassSurfaceView, LegacyGlassCaptureSource, LegacyGlassSurfaceView } from './nativeGlassViews';
|
|
12
|
-
import type { GlassCaptureSourceProps, NativeGlassSurfaceProps } from './nativeGlassViews';
|
|
13
|
-
import type { GlassMaterialTokens, GlassTokens, GlassVariant } from './types';
|
|
7
|
+
import type { GlassMaterialTokens, GlassVariant } from './types';
|
|
14
8
|
import type { GlassPointerEventSink, GlassValueEventSink } from './pointerEventBridge';
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
export interface GlassRuntime {
|
|
30
|
-
tokens: GlassTokens;
|
|
31
|
-
dark: boolean;
|
|
32
|
-
reducedMotion: boolean;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const GlassRuntimeContext = createContext<GlassRuntime | null>(null);
|
|
36
|
-
const GlassCaptureSourceContext = createContext<string | null>(null);
|
|
37
|
-
const GlassNativeEngineContext = createContext<GlassNativeEngine>('legacy');
|
|
38
|
-
const GlassRouteTransitionContext = createContext<SharedValue<number> | null>(null);
|
|
39
|
-
const GlassPortalScrollContext = createContext<{
|
|
40
|
-
offsets: readonly SharedValue<number>[];
|
|
41
|
-
layoutRevision: number;
|
|
42
|
-
groupKey: string;
|
|
43
|
-
}>({ offsets: [], layoutRevision: 0, groupKey: '' });
|
|
44
|
-
const GlassMeasureOnlyContext = createContext<boolean>(false);
|
|
45
|
-
|
|
46
|
-
/** Keeps backdrop surfaces aligned with content inside a scroll container. */
|
|
47
|
-
export function GlassPortalScrollScope({
|
|
48
|
-
scrollOffset,
|
|
49
|
-
layoutRevision = 0,
|
|
50
|
-
children,
|
|
51
|
-
}: {
|
|
52
|
-
scrollOffset: SharedValue<number>;
|
|
53
|
-
/** Increment after content reflow so surfaces can refresh their window frames. */
|
|
54
|
-
layoutRevision?: number;
|
|
55
|
-
children: React.ReactNode;
|
|
56
|
-
}) {
|
|
57
|
-
const scopeId = useId();
|
|
58
|
-
const parent = useContext(GlassPortalScrollContext);
|
|
59
|
-
const value = useMemo(() => ({
|
|
60
|
-
offsets: [...parent.offsets, scrollOffset],
|
|
61
|
-
layoutRevision: parent.layoutRevision + layoutRevision,
|
|
62
|
-
groupKey: parent.groupKey ? `${parent.groupKey}|${scopeId}` : scopeId,
|
|
63
|
-
}), [layoutRevision, parent, scopeId, scrollOffset]);
|
|
64
|
-
return <GlassPortalScrollContext.Provider value={value}>{children}</GlassPortalScrollContext.Provider>;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Shares a route's horizontal transition with portaled glass surfaces.
|
|
69
|
-
* Backdrop surfaces live in a host-level overlay, so an ancestor transform is
|
|
70
|
-
* not inherited automatically. This scope keeps their window frames and the
|
|
71
|
-
* visible React Native content on the same animation value.
|
|
72
|
-
*/
|
|
73
|
-
export function GlassRouteTransitionScope({
|
|
74
|
-
translateX,
|
|
75
|
-
children,
|
|
76
|
-
}: {
|
|
77
|
-
translateX: SharedValue<number>;
|
|
78
|
-
children: React.ReactNode;
|
|
79
|
-
}) {
|
|
80
|
-
return <GlassRouteTransitionContext.Provider value={translateX}>{children}</GlassRouteTransitionContext.Provider>;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export function useGlassReducedMotion() {
|
|
84
|
-
return useContext(GlassRuntimeContext)?.reducedMotion ?? false;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export function useGlassInsideScroll() {
|
|
88
|
-
return useContext(GlassPortalScrollContext).offsets.length > 0;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export function useGlassInsideCaptureScope() {
|
|
92
|
-
return useContext(GlassCaptureSourceContext) !== null;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export function useGlassAppearance() {
|
|
96
|
-
return useContext(GlassRuntimeContext);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/** Resolve the provider that represents the visible scene for a glass consumer. */
|
|
100
|
-
export function useGlassSamplingProviderId(source: GlassSamplingSource = 'routeScene') {
|
|
101
|
-
const host = useContext(GlassHostContext);
|
|
102
|
-
const captureSourceProviderId = useContext(GlassCaptureSourceContext);
|
|
103
|
-
if (!host) return null;
|
|
104
|
-
return source === 'themeBackdrop'
|
|
105
|
-
? host.themeBackdropProviderId
|
|
106
|
-
: captureSourceProviderId ?? host.routeSceneProviderId ?? host.themeBackdropProviderId;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
interface SurfaceFrame {
|
|
110
|
-
x: number;
|
|
111
|
-
y: number;
|
|
112
|
-
width: number;
|
|
113
|
-
height: number;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export type GlassSamplingSource = 'routeScene' | 'themeBackdrop';
|
|
117
|
-
|
|
118
|
-
interface SurfaceEntry {
|
|
119
|
-
frame: SurfaceFrame;
|
|
120
|
-
positioning: 'inFlow' | 'floating';
|
|
121
|
-
variant: GlassVariant;
|
|
122
|
-
samplingSource: GlassSamplingSource;
|
|
123
|
-
/** Native provider selected when the source-tree surface was registered. */
|
|
124
|
-
samplingProviderId: string;
|
|
125
|
-
tintColor?: ColorValue;
|
|
126
|
-
portalContent?: React.ReactNode;
|
|
127
|
-
/** Paint the surface's own children above the glass instead of into the scene it samples. */
|
|
128
|
-
contentAboveGlass: boolean;
|
|
129
|
-
content?: React.ReactNode;
|
|
130
|
-
/** Layout applied to the visible copy when content is portaled above the glass. */
|
|
131
|
-
contentStyle?: StyleProp<ViewStyle>;
|
|
132
|
-
interactive: boolean;
|
|
133
|
-
continuous: boolean;
|
|
134
|
-
sharedSource: boolean;
|
|
135
|
-
captureProbe: boolean;
|
|
136
|
-
opticalProgress?: SharedValue<number>;
|
|
137
|
-
scrollGroupKey: string;
|
|
138
|
-
scrollOffsets: readonly SharedValue<number>[];
|
|
139
|
-
routeTransitionX?: SharedValue<number> | null;
|
|
140
|
-
portalOffsetStyle?: AnimatedStyle<ViewStyle>;
|
|
141
|
-
portalTranslateX?: SharedValue<number>;
|
|
142
|
-
portalTranslateY?: SharedValue<number>;
|
|
143
|
-
portalScaleX?: SharedValue<number>;
|
|
144
|
-
portalScaleY?: SharedValue<number>;
|
|
145
|
-
/** Pointer event stream for the native motion driver; it owns the spring. */
|
|
146
|
-
pointerEvent?: SharedValue<string>;
|
|
147
|
-
/** The same stream as plain state; this is what the native prop receives. */
|
|
148
|
-
pointerEventValue?: string;
|
|
149
|
-
/** Direct native path for pointer samples that should not rerender portal surfaces. */
|
|
150
|
-
pointerEventSink?: GlassPointerEventSink;
|
|
151
|
-
/** Knob value stream for value-driven lenses; see useGlassKnobMotion. */
|
|
152
|
-
valueEvent?: string;
|
|
153
|
-
/** Direct native path for knob values that should not rerender portal surfaces. */
|
|
154
|
-
valueEventSink?: GlassValueEventSink;
|
|
155
|
-
opticalToggleFraction?: SharedValue<number>;
|
|
156
|
-
/** Deterministic progress used by reference-capture fixtures. */
|
|
157
|
-
opticalProgressValue?: number;
|
|
158
|
-
opticalPointX?: SharedValue<number>;
|
|
159
|
-
opticalPointY?: SharedValue<number>;
|
|
160
|
-
/** UI-thread pointer velocity in local dp/s for the reference release spring. */
|
|
161
|
-
opticalVelocityX?: SharedValue<number>;
|
|
162
|
-
opticalVelocityY?: SharedValue<number>;
|
|
163
|
-
opticalMotionX?: SharedValue<number>;
|
|
164
|
-
opticalMotionY?: SharedValue<number>;
|
|
165
|
-
materialOverrides?: Partial<GlassMaterialTokens>;
|
|
166
|
-
shapeMaskText?: string;
|
|
167
|
-
shapeMaskFontSize?: number;
|
|
168
|
-
shapeMaskFontWeight?: number;
|
|
169
|
-
progressiveBlurIntensity?: number;
|
|
170
|
-
displacementOnlyDebug: boolean;
|
|
171
|
-
syncContentTransform?: boolean;
|
|
172
|
-
animatedStyle?: AnimatedStyle<ViewStyle>;
|
|
173
|
-
placement?: 'layout' | 'bottom' | 'center';
|
|
174
|
-
bottomInset?: number;
|
|
175
|
-
zIndex: number;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
interface OverlayEntry {
|
|
179
|
-
children: React.ReactNode;
|
|
180
|
-
style?: AnimatedStyle<ViewStyle>;
|
|
181
|
-
frame?: SurfaceFrame;
|
|
182
|
-
scrollOffsets?: readonly SharedValue<number>[];
|
|
183
|
-
routeTransitionX?: SharedValue<number> | null;
|
|
184
|
-
portalOffsetStyle?: AnimatedStyle<ViewStyle>;
|
|
185
|
-
zIndex: number;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
interface EntryRegistry<Entry> {
|
|
189
|
-
getSnapshot: () => [string, Entry][];
|
|
190
|
-
subscribe: (listener: () => void) => () => void;
|
|
191
|
-
update: (id: string, entry: Entry, equals: (previous: Entry, next: Entry) => boolean) => void;
|
|
192
|
-
remove: (id: string) => void;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
function createEntryRegistry<Entry>(): EntryRegistry<Entry> {
|
|
196
|
-
const entries = new Map<string, Entry>();
|
|
197
|
-
const listeners = new Set<() => void>();
|
|
198
|
-
let snapshot: [string, Entry][] = [];
|
|
199
|
-
const publish = () => {
|
|
200
|
-
snapshot = Array.from(entries.entries());
|
|
201
|
-
for (const listener of listeners) listener();
|
|
202
|
-
};
|
|
203
|
-
return {
|
|
204
|
-
getSnapshot: () => snapshot,
|
|
205
|
-
subscribe: (listener) => {
|
|
206
|
-
listeners.add(listener);
|
|
207
|
-
return () => listeners.delete(listener);
|
|
208
|
-
},
|
|
209
|
-
update: (id, entry, equals) => {
|
|
210
|
-
const previous = entries.get(id);
|
|
211
|
-
if (previous !== undefined && equals(previous, entry)) return;
|
|
212
|
-
entries.set(id, entry);
|
|
213
|
-
publish();
|
|
214
|
-
},
|
|
215
|
-
remove: (id) => {
|
|
216
|
-
if (!entries.delete(id)) return;
|
|
217
|
-
publish();
|
|
218
|
-
},
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
function useRegistrySnapshot<Entry>(registry: EntryRegistry<Entry>) {
|
|
223
|
-
return React.useSyncExternalStore(registry.subscribe, registry.getSnapshot, registry.getSnapshot);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
function sameSurface(previous: SurfaceEntry, next: SurfaceEntry) {
|
|
227
|
-
return previous.frame.x === next.frame.x && previous.frame.y === next.frame.y &&
|
|
228
|
-
previous.frame.width === next.frame.width && previous.frame.height === next.frame.height &&
|
|
229
|
-
previous.positioning === next.positioning && previous.samplingSource === next.samplingSource &&
|
|
230
|
-
previous.samplingProviderId === next.samplingProviderId &&
|
|
231
|
-
previous.tintColor === next.tintColor && previous.portalContent === next.portalContent &&
|
|
232
|
-
previous.contentAboveGlass === next.contentAboveGlass && previous.content === next.content && previous.contentStyle === next.contentStyle &&
|
|
233
|
-
previous.variant === next.variant && previous.interactive === next.interactive && previous.continuous === next.continuous &&
|
|
234
|
-
previous.sharedSource === next.sharedSource && previous.captureProbe === next.captureProbe &&
|
|
235
|
-
previous.opticalProgress === next.opticalProgress && previous.scrollGroupKey === next.scrollGroupKey && previous.scrollOffsets === next.scrollOffsets && previous.routeTransitionX === next.routeTransitionX && previous.portalOffsetStyle === next.portalOffsetStyle && previous.portalTranslateX === next.portalTranslateX && previous.portalTranslateY === next.portalTranslateY && previous.portalScaleX === next.portalScaleX && previous.portalScaleY === next.portalScaleY && previous.pointerEvent === next.pointerEvent && previous.pointerEventValue === next.pointerEventValue && previous.pointerEventSink === next.pointerEventSink && previous.valueEvent === next.valueEvent && previous.valueEventSink === next.valueEventSink && previous.opticalToggleFraction === next.opticalToggleFraction && previous.opticalProgressValue === next.opticalProgressValue && previous.opticalPointX === next.opticalPointX && previous.opticalPointY === next.opticalPointY && previous.opticalMotionX === next.opticalMotionX && previous.opticalMotionY === next.opticalMotionY &&
|
|
236
|
-
previous.opticalVelocityX === next.opticalVelocityX && previous.opticalVelocityY === next.opticalVelocityY &&
|
|
237
|
-
previous.materialOverrides === next.materialOverrides && previous.displacementOnlyDebug === next.displacementOnlyDebug &&
|
|
238
|
-
previous.syncContentTransform === next.syncContentTransform &&
|
|
239
|
-
previous.shapeMaskText === next.shapeMaskText && previous.shapeMaskFontSize === next.shapeMaskFontSize && previous.shapeMaskFontWeight === next.shapeMaskFontWeight &&
|
|
240
|
-
previous.progressiveBlurIntensity === next.progressiveBlurIntensity &&
|
|
241
|
-
previous.animatedStyle === next.animatedStyle && previous.placement === next.placement &&
|
|
242
|
-
previous.bottomInset === next.bottomInset && previous.zIndex === next.zIndex;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
function sameOverlay(previous: OverlayEntry, next: OverlayEntry) {
|
|
246
|
-
return previous.children === next.children && previous.style === next.style &&
|
|
247
|
-
previous.frame?.x === next.frame?.x && previous.frame?.y === next.frame?.y &&
|
|
248
|
-
previous.frame?.width === next.frame?.width && previous.frame?.height === next.frame?.height &&
|
|
249
|
-
previous.scrollOffsets === next.scrollOffsets && previous.routeTransitionX === next.routeTransitionX &&
|
|
250
|
-
previous.portalOffsetStyle === next.portalOffsetStyle && previous.zIndex === next.zIndex;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
function selectBalancedShaderSurfaces(entries: [string, SurfaceEntry][]) {
|
|
254
|
-
// Every mounted backdrop surface keeps the same renderer regardless of
|
|
255
|
-
// quality preset; display cadence is selected by the native provider.
|
|
256
|
-
return new Set(entries.map(([id]) => id));
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
interface GlassHostContextValue {
|
|
260
|
-
providerId: string;
|
|
261
|
-
routeSceneProviderId: string | null;
|
|
262
|
-
themeBackdropProviderId: string;
|
|
263
|
-
inlineBackdropByDefault: boolean;
|
|
264
|
-
hasSeparateBackdrop: boolean;
|
|
265
|
-
defaultSamplingSource: GlassSamplingSource;
|
|
266
|
-
hostRef: React.RefObject<View | null>;
|
|
267
|
-
updateSurface: (id: string, entry: SurfaceEntry) => void;
|
|
268
|
-
updateOverlay: (id: string, entry: OverlayEntry) => void;
|
|
269
|
-
removeOverlay: (id: string) => void;
|
|
270
|
-
remove: (id: string) => void;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
const GlassHostContext = createContext<GlassHostContextValue | null>(null);
|
|
274
|
-
|
|
275
|
-
export function RouteGlassCaptureScope({ children, active = true, scopeId = 'page-content' }: { children: React.ReactNode; active?: boolean; scopeId?: string }) {
|
|
276
|
-
const host = useContext(GlassHostContext);
|
|
277
|
-
const parentActive = useContext(GlassScopeActiveContext);
|
|
278
|
-
const parentProviderId = useContext(GlassCaptureSourceContext);
|
|
279
|
-
const baseId = parentProviderId ?? host?.providerId ?? null;
|
|
280
|
-
const providerId = baseId ? `${baseId}:${scopeId}` : null;
|
|
281
|
-
return (
|
|
282
|
-
<GlassScopeActiveContext.Provider value={active && parentActive}>
|
|
283
|
-
<GlassCaptureSourceContext.Provider value={providerId}>{children}</GlassCaptureSourceContext.Provider>
|
|
284
|
-
</GlassScopeActiveContext.Provider>
|
|
285
|
-
);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
export function RouteGlassCaptureSource({
|
|
289
|
-
children,
|
|
290
|
-
captureMode,
|
|
291
|
-
captureOnly = false,
|
|
292
|
-
sourceRevision,
|
|
293
|
-
underlayProviderId,
|
|
294
|
-
style,
|
|
295
|
-
}: {
|
|
296
|
-
children: React.ReactNode;
|
|
297
|
-
captureMode?: 'live' | 'oneShotPassThrough' | 'livePassThrough' | 'oneShot' | 'static';
|
|
298
|
-
/** A private pass-through scene used only by other glass consumers. */
|
|
299
|
-
captureOnly?: boolean;
|
|
300
|
-
sourceRevision?: string;
|
|
301
|
-
underlayProviderId?: string | null;
|
|
302
|
-
style?: StyleProp<ViewStyle>;
|
|
303
|
-
}) {
|
|
304
|
-
const host = useContext(GlassHostContext);
|
|
305
|
-
const runtime = useContext(GlassRuntimeContext);
|
|
306
|
-
const scopedProviderId = useContext(GlassCaptureSourceContext);
|
|
307
|
-
const scopeActive = useContext(GlassScopeActiveContext);
|
|
308
|
-
const inactiveId = useId();
|
|
309
|
-
// Pager siblings share a route-scene alias. A hidden page must retain its
|
|
310
|
-
// native tree without replacing the visible page in the provider registry.
|
|
311
|
-
const providerId = !scopeActive && scopedProviderId
|
|
312
|
-
? `${scopedProviderId}:inactive:${inactiveId}`
|
|
313
|
-
: scopedProviderId;
|
|
314
|
-
if (!host || !providerId || !runtime?.tokens.enabled) return <>{children}</>;
|
|
315
|
-
const resolvedCaptureMode = !scopeActive ? 'frozen'
|
|
316
|
-
: captureMode ?? (Platform.OS === 'android' && getGlassNativeEngine() === 'core' ? 'oneShotPassThrough' : 'live');
|
|
317
|
-
const resolvedUnderlay = underlayProviderId === null
|
|
318
|
-
? undefined
|
|
319
|
-
: underlayProviderId ?? host.routeSceneProviderId ?? host.themeBackdropProviderId;
|
|
320
|
-
return (
|
|
321
|
-
<GlassCaptureSourceView
|
|
322
|
-
providerId={providerId}
|
|
323
|
-
underlayProviderId={resolvedUnderlay}
|
|
324
|
-
captureMode={resolvedCaptureMode as GlassCaptureSourceProps['captureMode']}
|
|
325
|
-
captureOnly={getGlassNativeEngine() === 'core' ? captureOnly : undefined}
|
|
326
|
-
sourceRevision={sourceRevision}
|
|
327
|
-
pointerEvents="box-none"
|
|
328
|
-
style={[styles.captureSource, style]}
|
|
329
|
-
>
|
|
330
|
-
{children}
|
|
331
|
-
</GlassCaptureSourceView>
|
|
332
|
-
);
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
function NativeBackdropSurface({
|
|
336
|
-
opticsModel,
|
|
337
|
-
sdfDisplacementMapDebug,
|
|
338
|
-
sdfContrast,
|
|
339
|
-
sdfBrightness,
|
|
340
|
-
sdfSaturation,
|
|
341
|
-
sdfOuterShadowAlpha,
|
|
342
|
-
sdfOuterShadowBlurRadius,
|
|
343
|
-
sdfOuterShadowOffsetY,
|
|
344
|
-
sdfInnerShadowAlpha,
|
|
345
|
-
sdfInnerShadowExtent,
|
|
346
|
-
shapeMaskText,
|
|
347
|
-
shapeMaskFontSize,
|
|
348
|
-
shapeMaskFontWeight,
|
|
349
|
-
sharedPassOrder,
|
|
350
|
-
sharedPassZIndex,
|
|
351
|
-
pointerEventSink,
|
|
352
|
-
valueEventSink,
|
|
353
|
-
syncContentTransform,
|
|
354
|
-
renderingEnabled = true,
|
|
355
|
-
...props
|
|
356
|
-
}: NativeBackdropSurfaceProps) {
|
|
357
|
-
const nativeEngine = useContext(GlassNativeEngineContext);
|
|
358
|
-
const nativeViewRef = useRef<View>(null);
|
|
359
|
-
useEffect(() => {
|
|
360
|
-
const viewTag = nativeEngine === 'core' && nativeViewRef.current
|
|
361
|
-
? findNodeHandle(nativeViewRef.current)
|
|
362
|
-
: null;
|
|
363
|
-
if (pointerEventSink) {
|
|
364
|
-
pointerEventSink.current = viewTag == null
|
|
365
|
-
? null
|
|
366
|
-
: (payload) => forwardPointerToSurface(viewTag, payload);
|
|
367
|
-
}
|
|
368
|
-
if (valueEventSink) {
|
|
369
|
-
valueEventSink.current = viewTag == null
|
|
370
|
-
? null
|
|
371
|
-
: (payload) => forwardValueToSurface(viewTag, payload);
|
|
372
|
-
}
|
|
373
|
-
return () => {
|
|
374
|
-
if (pointerEventSink) pointerEventSink.current = null;
|
|
375
|
-
if (valueEventSink) valueEventSink.current = null;
|
|
376
|
-
};
|
|
377
|
-
}, [nativeEngine, pointerEventSink, valueEventSink]);
|
|
378
|
-
// 'core' is the default, but the core view only exists on Android. Falling back
|
|
379
|
-
// to the legacy view there keeps iOS and any missing registration drawing
|
|
380
|
-
// something instead of nothing.
|
|
381
|
-
if (nativeEngine === 'core') {
|
|
382
|
-
if (props.animatedProps == null && CoreGlassSurfaceView) {
|
|
383
|
-
const { animatedProps: _unused, ...staticProps } = props;
|
|
384
|
-
return (
|
|
385
|
-
<CoreGlassSurfaceView
|
|
386
|
-
ref={nativeViewRef}
|
|
387
|
-
renderingEnabled={renderingEnabled}
|
|
388
|
-
{...staticProps}
|
|
389
|
-
sharedPassOrder={sharedPassOrder}
|
|
390
|
-
sharedPassZIndex={sharedPassZIndex}
|
|
391
|
-
opticsModel={opticsModel}
|
|
392
|
-
sdfDisplacementMapDebug={sdfDisplacementMapDebug}
|
|
393
|
-
sdfContrast={sdfContrast}
|
|
394
|
-
sdfBrightness={sdfBrightness}
|
|
395
|
-
sdfSaturation={sdfSaturation}
|
|
396
|
-
sdfOuterShadowAlpha={sdfOuterShadowAlpha}
|
|
397
|
-
sdfOuterShadowBlurRadius={sdfOuterShadowBlurRadius}
|
|
398
|
-
sdfOuterShadowOffsetY={sdfOuterShadowOffsetY}
|
|
399
|
-
sdfInnerShadowAlpha={sdfInnerShadowAlpha}
|
|
400
|
-
sdfInnerShadowExtent={sdfInnerShadowExtent}
|
|
401
|
-
shapeMaskText={shapeMaskText}
|
|
402
|
-
shapeMaskFontSize={shapeMaskFontSize}
|
|
403
|
-
shapeMaskFontWeight={shapeMaskFontWeight}
|
|
404
|
-
syncContentTransform={syncContentTransform}
|
|
405
|
-
/>
|
|
406
|
-
);
|
|
407
|
-
}
|
|
408
|
-
if (AnimatedCoreGlassSurfaceView) {
|
|
409
|
-
return (
|
|
410
|
-
<AnimatedCoreGlassSurfaceView
|
|
411
|
-
ref={nativeViewRef}
|
|
412
|
-
renderingEnabled={renderingEnabled}
|
|
413
|
-
{...props}
|
|
414
|
-
sharedPassOrder={sharedPassOrder}
|
|
415
|
-
sharedPassZIndex={sharedPassZIndex}
|
|
416
|
-
opticsModel={opticsModel}
|
|
417
|
-
sdfDisplacementMapDebug={sdfDisplacementMapDebug}
|
|
418
|
-
sdfContrast={sdfContrast}
|
|
419
|
-
sdfBrightness={sdfBrightness}
|
|
420
|
-
sdfSaturation={sdfSaturation}
|
|
421
|
-
sdfOuterShadowAlpha={sdfOuterShadowAlpha}
|
|
422
|
-
sdfOuterShadowBlurRadius={sdfOuterShadowBlurRadius}
|
|
423
|
-
sdfOuterShadowOffsetY={sdfOuterShadowOffsetY}
|
|
424
|
-
sdfInnerShadowAlpha={sdfInnerShadowAlpha}
|
|
425
|
-
sdfInnerShadowExtent={sdfInnerShadowExtent}
|
|
426
|
-
shapeMaskText={shapeMaskText}
|
|
427
|
-
shapeMaskFontSize={shapeMaskFontSize}
|
|
428
|
-
shapeMaskFontWeight={shapeMaskFontWeight}
|
|
429
|
-
syncContentTransform={syncContentTransform}
|
|
430
|
-
/>
|
|
431
|
-
);
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
return <AnimatedLegacyGlassSurfaceView {...props} style={[props.style, !renderingEnabled ? { opacity: 0 } : undefined]} />;
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
function GlassCaptureSourceView({ children, ...props }: GlassCaptureSourceProps) {
|
|
438
|
-
const nativeEngine = useContext(GlassNativeEngineContext);
|
|
439
|
-
if (nativeEngine === 'core' && CoreGlassCaptureSource) {
|
|
440
|
-
return <CoreGlassCaptureSource {...props}>{children}</CoreGlassCaptureSource>;
|
|
441
|
-
}
|
|
442
|
-
return <LegacyGlassCaptureSource {...props}>{children}</LegacyGlassCaptureSource>;
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
interface GlassOverlayHostContextValue {
|
|
446
|
-
providerId: string;
|
|
447
|
-
updateOverlay: (id: string, entry: OverlayEntry) => void;
|
|
448
|
-
remove: (id: string) => void;
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
const GlassOverlayHostContext = createContext<GlassOverlayHostContextValue | null>(null);
|
|
452
|
-
|
|
453
|
-
/**
|
|
454
|
-
* Page-level scope for glass surfaces.
|
|
455
|
-
*
|
|
456
|
-
* Every page under a PagerView shares one provider id (`host.providerId +
|
|
457
|
-
* ':page-content'`) and one registry, and GlassSurfacePortalLayer draws every
|
|
458
|
-
* registered entry in a provider-level layer above page content. So a kept-alive
|
|
459
|
-
* page's surfaces paint on top of whichever page is actually visible: on Home
|
|
460
|
-
* that showed up as an empty 344x55dp panel under the search bar, which turned
|
|
461
|
-
* out to be the User page's segmented control.
|
|
462
|
-
*
|
|
463
|
-
* A surface whose scope is inactive stops publishing. Layout is untouched; only
|
|
464
|
-
* the registry entry goes away, so nothing is drawn for it.
|
|
465
|
-
*/
|
|
466
|
-
const GlassScopeActiveContext = createContext<boolean>(true);
|
|
467
|
-
|
|
468
|
-
/**
|
|
469
|
-
* A route-scoped host for backdrop-mode surfaces. Theme capability controls
|
|
470
|
-
* whether Glass surfaces exist; capture mode is controlled imperatively by
|
|
471
|
-
* the native provider without changing the React surface tree.
|
|
472
|
-
*/
|
|
473
|
-
export interface GlassMaterialProviderProps {
|
|
474
|
-
children: React.ReactNode;
|
|
475
|
-
/** Scene layer recorded behind route content. When supplied, route views render as normal siblings. */
|
|
476
|
-
backdrop?: React.ReactNode;
|
|
477
|
-
/** Separate visible backdrop/source used by sheets and other stable overlays. */
|
|
478
|
-
themeBackdrop?: React.ReactNode;
|
|
479
|
-
/** Changes only when the theme backdrop image or palette itself changes. */
|
|
480
|
-
themeBackdropRevision?: string;
|
|
481
|
-
/** Render descendant surfaces in place by default. Useful for fixed-scene preview galleries. */
|
|
482
|
-
inlineBackdropByDefault?: boolean;
|
|
483
|
-
/** Default sampling scene for descendants that do not select one explicitly. */
|
|
484
|
-
defaultSamplingSource?: GlassSamplingSource;
|
|
485
|
-
providerId?: string;
|
|
486
|
-
style?: StyleProp<ViewStyle>;
|
|
487
|
-
tokens: GlassTokens;
|
|
488
|
-
dark: boolean;
|
|
489
|
-
reducedMotion?: boolean;
|
|
490
|
-
/**
|
|
491
|
-
* Whether this provider's family is the one the host resolved.
|
|
492
|
-
*
|
|
493
|
-
* A host that keeps several material scopes mounted must pass `false` for the
|
|
494
|
-
* inactive ones. An inactive provider publishes the same contexts and renders
|
|
495
|
-
* the same tree, but records nothing: capture sources attach no native
|
|
496
|
-
* provider and the surface layers stay empty, so there is exactly one
|
|
497
|
-
* recorder in the window.
|
|
498
|
-
*/
|
|
499
|
-
active?: boolean;
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
/** Supplies preview optics without mounting another native backdrop recorder. */
|
|
503
|
-
export interface GlassAppearanceProviderProps {
|
|
504
|
-
children: React.ReactNode;
|
|
505
|
-
tokens: GlassTokens;
|
|
506
|
-
dark: boolean;
|
|
507
|
-
reducedMotion?: boolean;
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
export function GlassAppearanceProvider({ children, tokens, dark, reducedMotion = false }: GlassAppearanceProviderProps) {
|
|
511
|
-
const runtime = useMemo(() => ({ tokens, dark, reducedMotion }), [tokens, dark, reducedMotion]);
|
|
512
|
-
return <GlassRuntimeContext.Provider value={runtime}>{children}</GlassRuntimeContext.Provider>;
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
export function GlassMaterialProvider({ children, backdrop, themeBackdrop, themeBackdropRevision, inlineBackdropByDefault = false, defaultSamplingSource = 'routeScene', providerId: providerIdProp, style, tokens, dark, reducedMotion = false, active = true }: GlassMaterialProviderProps) {
|
|
516
|
-
const hostRef = useRef<View>(null);
|
|
517
|
-
const generatedProviderId = useId();
|
|
518
|
-
const providerId = providerIdProp ?? generatedProviderId;
|
|
519
|
-
const routeSceneProviderId = backdrop !== undefined ? providerId : null;
|
|
520
|
-
const generatedThemeBackdropProviderId = useId();
|
|
521
|
-
// When a separate stable theme backdrop was not supplied, the provider's
|
|
522
|
-
// base backdrop is the stable scene. Aliasing its id avoids recording that
|
|
523
|
-
// exact scene into a second native source just to support inline lenses.
|
|
524
|
-
const themeBackdropProviderId = themeBackdrop !== undefined ? generatedThemeBackdropProviderId : providerId;
|
|
525
|
-
const surfaceRegistryRef = useRef<EntryRegistry<SurfaceEntry> | null>(null);
|
|
526
|
-
const overlayRegistryRef = useRef<EntryRegistry<OverlayEntry> | null>(null);
|
|
527
|
-
if (!surfaceRegistryRef.current) surfaceRegistryRef.current = createEntryRegistry();
|
|
528
|
-
if (!overlayRegistryRef.current) overlayRegistryRef.current = createEntryRegistry();
|
|
529
|
-
const surfaceRegistry = surfaceRegistryRef.current;
|
|
530
|
-
const overlayRegistry = overlayRegistryRef.current;
|
|
531
|
-
const runtime = useMemo(() => ({ tokens, dark, reducedMotion }), [tokens, dark, reducedMotion]);
|
|
532
|
-
const nativeEngine = useSyncExternalStore(subscribeGlassNativeEngine, getGlassNativeEngine, getGlassNativeEngine);
|
|
533
|
-
|
|
534
|
-
const updateSurface = useCallback((id: string, entry: SurfaceEntry) => {
|
|
535
|
-
surfaceRegistry.update(id, entry, sameSurface);
|
|
536
|
-
}, [surfaceRegistry]);
|
|
537
|
-
|
|
538
|
-
const updateOverlay = useCallback((id: string, entry: OverlayEntry) => {
|
|
539
|
-
overlayRegistry.update(id, entry, sameOverlay);
|
|
540
|
-
}, [overlayRegistry]);
|
|
541
|
-
|
|
542
|
-
const removeOverlay = useCallback((id: string) => {
|
|
543
|
-
overlayRegistry.remove(id);
|
|
544
|
-
}, [overlayRegistry]);
|
|
545
|
-
|
|
546
|
-
const remove = useCallback((id: string) => {
|
|
547
|
-
surfaceRegistry.remove(id);
|
|
548
|
-
overlayRegistry.remove(id);
|
|
549
|
-
}, [surfaceRegistry, overlayRegistry]);
|
|
550
|
-
|
|
551
|
-
const hasSeparateBackdrop = backdrop !== undefined;
|
|
552
|
-
const context = useMemo(() => ({ providerId, routeSceneProviderId, themeBackdropProviderId, inlineBackdropByDefault, hasSeparateBackdrop, defaultSamplingSource, hostRef, updateSurface, updateOverlay, removeOverlay, remove }), [providerId, routeSceneProviderId, themeBackdropProviderId, inlineBackdropByDefault, hasSeparateBackdrop, defaultSamplingSource, updateSurface, updateOverlay, removeOverlay, remove]);
|
|
553
|
-
const overlayContext = useMemo(() => ({ providerId, updateOverlay, remove }), [providerId, updateOverlay, remove]);
|
|
554
|
-
const recording = active && tokens.enabled;
|
|
555
|
-
|
|
556
|
-
return (
|
|
557
|
-
<GlassNativeEngineContext.Provider value={nativeEngine}>
|
|
558
|
-
<GlassRuntimeContext.Provider value={runtime}>
|
|
559
|
-
<GlassHostContext.Provider value={context}>
|
|
560
|
-
<GlassOverlayHostContext.Provider value={overlayContext}>
|
|
561
|
-
<View ref={hostRef} collapsable={false} style={[styles.root, style]}>
|
|
562
|
-
<GlassScopeActiveContext.Provider value={recording}>
|
|
563
|
-
{recording && themeBackdrop !== undefined ? (
|
|
564
|
-
<GlassCaptureSourceView
|
|
565
|
-
providerId={themeBackdropProviderId}
|
|
566
|
-
captureMode="static"
|
|
567
|
-
sourceRevision={themeBackdropRevision}
|
|
568
|
-
pointerEvents="none"
|
|
569
|
-
style={StyleSheet.absoluteFill}
|
|
570
|
-
>
|
|
571
|
-
{themeBackdrop}
|
|
572
|
-
</GlassCaptureSourceView>
|
|
573
|
-
) : null}
|
|
574
|
-
{/*
|
|
575
|
-
Exactly one parent for the route tree, always of the same
|
|
576
|
-
element type. Choosing between a capture source and a plain
|
|
577
|
-
View here would change the element type at the children
|
|
578
|
-
position, and React unmounts a subtree whose parent type
|
|
579
|
-
changes — the route rebuilt itself on every switch even
|
|
580
|
-
though the host above was stable.
|
|
581
|
-
|
|
582
|
-
Inactive or disabled, the capture source stays mounted in
|
|
583
|
-
`frozen` mode: the native recorder stops capturing and the
|
|
584
|
-
page renders through it untouched.
|
|
585
|
-
*/}
|
|
586
|
-
{hasSeparateBackdrop ? (
|
|
587
|
-
<>
|
|
588
|
-
{/*
|
|
589
|
-
Separate-backdrop mode: the capture source records
|
|
590
|
-
the supplied scene only. `children` appears exactly
|
|
591
|
-
once, in the layer below — previously it was passed
|
|
592
|
-
here as well and the route tree mounted twice.
|
|
593
|
-
*/}
|
|
594
|
-
<GlassCaptureSourceView
|
|
595
|
-
providerId={providerId}
|
|
596
|
-
underlayProviderId={themeBackdrop !== undefined ? themeBackdropProviderId : undefined}
|
|
597
|
-
captureMode={recording ? 'live' : 'frozen'}
|
|
598
|
-
style={StyleSheet.absoluteFill}
|
|
599
|
-
>
|
|
600
|
-
{backdrop}
|
|
601
|
-
</GlassCaptureSourceView>
|
|
602
|
-
<View pointerEvents="box-none" style={StyleSheet.absoluteFill}>
|
|
603
|
-
{children}
|
|
604
|
-
</View>
|
|
605
|
-
</>
|
|
606
|
-
) : (
|
|
607
|
-
<GlassCaptureSourceView
|
|
608
|
-
providerId={providerId}
|
|
609
|
-
underlayProviderId={themeBackdrop !== undefined ? themeBackdropProviderId : undefined}
|
|
610
|
-
captureMode={recording ? 'live' : 'frozen'}
|
|
611
|
-
style={StyleSheet.absoluteFill}
|
|
612
|
-
>
|
|
613
|
-
{children}
|
|
614
|
-
</GlassCaptureSourceView>
|
|
615
|
-
)}
|
|
616
|
-
<GlassSurfacePortalLayer registry={surfaceRegistry} tokens={tokens} />
|
|
617
|
-
<GlassRouteOverlayLayer registry={overlayRegistry} enabled={recording} />
|
|
618
|
-
</GlassScopeActiveContext.Provider>
|
|
619
|
-
</View>
|
|
620
|
-
</GlassOverlayHostContext.Provider>
|
|
621
|
-
</GlassHostContext.Provider>
|
|
622
|
-
</GlassRuntimeContext.Provider>
|
|
623
|
-
</GlassNativeEngineContext.Provider>
|
|
624
|
-
);
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
function GlassSurfacePortalLayer({ registry, tokens }: { registry: EntryRegistry<SurfaceEntry>; tokens: GlassTokens }) {
|
|
628
|
-
const entries = useRegistrySnapshot(registry);
|
|
629
|
-
const balancedShaderSurfaces = useMemo(() => selectBalancedShaderSurfaces(entries), [entries]);
|
|
630
|
-
const groups = useMemo(() => {
|
|
631
|
-
const list: {
|
|
632
|
-
key: string;
|
|
633
|
-
zIndex: number;
|
|
634
|
-
offsets: readonly SharedValue<number>[];
|
|
635
|
-
routeTransitionX?: SharedValue<number> | null;
|
|
636
|
-
items: [string, SurfaceEntry][];
|
|
637
|
-
}[] = [];
|
|
638
|
-
const byKey = new Map<string, (typeof list)[number]>();
|
|
639
|
-
for (let i = 0; i < entries.length; i += 1) {
|
|
640
|
-
const pair = entries[i];
|
|
641
|
-
const entry = pair[1];
|
|
642
|
-
const routeId = getSharedValueId(entry.routeTransitionX);
|
|
643
|
-
const key = `${entry.zIndex}::${entry.scrollGroupKey}::${routeId}`;
|
|
644
|
-
let group = byKey.get(key);
|
|
645
|
-
if (!group) {
|
|
646
|
-
group = {
|
|
647
|
-
key,
|
|
648
|
-
zIndex: entry.zIndex,
|
|
649
|
-
offsets: entry.scrollOffsets,
|
|
650
|
-
routeTransitionX: entry.routeTransitionX,
|
|
651
|
-
items: [],
|
|
652
|
-
};
|
|
653
|
-
byKey.set(key, group);
|
|
654
|
-
list.push(group);
|
|
655
|
-
}
|
|
656
|
-
group.items.push(pair);
|
|
657
|
-
}
|
|
658
|
-
return list;
|
|
659
|
-
}, [entries]);
|
|
660
|
-
if (!tokens.enabled) return null;
|
|
661
|
-
return (
|
|
662
|
-
<View pointerEvents="box-none" style={StyleSheet.absoluteFill}>
|
|
663
|
-
{/* The layer itself must not claim the screen, but its portaled
|
|
664
|
-
above-glass content and explicitly interactive native surfaces
|
|
665
|
-
still need to receive touches. Grouping by scroll scope drives
|
|
666
|
-
every scrolled card in lockstep via one Reanimated worklet instead
|
|
667
|
-
of N per-item worklets on every frame. */}
|
|
668
|
-
{groups.map((group) => {
|
|
669
|
-
const content = group.items.map(([id, entry]) => (
|
|
670
|
-
<PortalGlassSurface
|
|
671
|
-
key={id}
|
|
672
|
-
providerId={entry.samplingProviderId}
|
|
673
|
-
entry={entry}
|
|
674
|
-
drawOrder={0}
|
|
675
|
-
shaderEnabled={tokens.quality === 'high' || (tokens.quality === 'balanced' && balancedShaderSurfaces.has(id))}
|
|
676
|
-
/>
|
|
677
|
-
));
|
|
678
|
-
if (group.offsets.length === 0 && !group.routeTransitionX) {
|
|
679
|
-
return (
|
|
680
|
-
<View key={group.key} pointerEvents="box-none" style={[StyleSheet.absoluteFill, { zIndex: group.zIndex }]}>
|
|
681
|
-
{content}
|
|
682
|
-
</View>
|
|
683
|
-
);
|
|
684
|
-
}
|
|
685
|
-
return (
|
|
686
|
-
<PortalScrollGroupContainer
|
|
687
|
-
key={group.key}
|
|
688
|
-
offsets={group.offsets}
|
|
689
|
-
routeTransitionX={group.routeTransitionX}
|
|
690
|
-
zIndex={group.zIndex}
|
|
691
|
-
>
|
|
692
|
-
{content}
|
|
693
|
-
</PortalScrollGroupContainer>
|
|
694
|
-
);
|
|
695
|
-
})}
|
|
696
|
-
</View>
|
|
697
|
-
);
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
const sharedValueGroupIds = new WeakMap<object, number>();
|
|
701
|
-
let nextSharedValueGroupId = 1;
|
|
702
|
-
|
|
703
|
-
function getSharedValueId(value: SharedValue<number> | null | undefined): number {
|
|
704
|
-
if (!value) return 0;
|
|
705
|
-
let id = sharedValueGroupIds.get(value);
|
|
706
|
-
if (id == null) {
|
|
707
|
-
id = nextSharedValueGroupId++;
|
|
708
|
-
sharedValueGroupIds.set(value, id);
|
|
709
|
-
}
|
|
710
|
-
return id;
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
const PortalScrollGroupContainer = React.memo(function PortalScrollGroupContainer({
|
|
714
|
-
offsets,
|
|
715
|
-
routeTransitionX,
|
|
716
|
-
zIndex,
|
|
717
|
-
children,
|
|
718
|
-
}: {
|
|
719
|
-
offsets: readonly SharedValue<number>[];
|
|
720
|
-
routeTransitionX?: SharedValue<number> | null;
|
|
721
|
-
zIndex: number;
|
|
722
|
-
children: React.ReactNode;
|
|
723
|
-
}) {
|
|
724
|
-
const groupTransformStyle = useAnimatedStyle(() => {
|
|
725
|
-
let scrollY = 0;
|
|
726
|
-
for (let index = 0; index < offsets.length; index += 1) {
|
|
727
|
-
scrollY += offsets[index].value;
|
|
728
|
-
}
|
|
729
|
-
return {
|
|
730
|
-
transform: [
|
|
731
|
-
{ translateX: routeTransitionX?.value ?? 0 },
|
|
732
|
-
{ translateY: -scrollY },
|
|
733
|
-
],
|
|
734
|
-
};
|
|
735
|
-
}, [offsets, routeTransitionX]);
|
|
736
|
-
|
|
737
|
-
return (
|
|
738
|
-
<Animated.View pointerEvents="box-none" style={[StyleSheet.absoluteFill, groupTransformStyle, { zIndex }]}>
|
|
739
|
-
{children}
|
|
740
|
-
</Animated.View>
|
|
741
|
-
);
|
|
742
|
-
});
|
|
743
|
-
|
|
744
|
-
function GlassRouteOverlayLayer({ registry, enabled }: { registry: EntryRegistry<OverlayEntry>; enabled: boolean }) {
|
|
745
|
-
const entries = useRegistrySnapshot(registry);
|
|
746
|
-
if (!enabled) return null;
|
|
747
|
-
return (
|
|
748
|
-
<View pointerEvents="box-none" style={StyleSheet.absoluteFill}>
|
|
749
|
-
{entries.map(([id, entry]) => <RouteOverlayView key={id} entry={entry} />)}
|
|
750
|
-
</View>
|
|
751
|
-
);
|
|
752
|
-
}
|
|
753
|
-
|
|
754
|
-
const RouteOverlayView = React.memo(function RouteOverlayView({ entry }: { entry: OverlayEntry }) {
|
|
755
|
-
const offsets = entry.scrollOffsets;
|
|
756
|
-
const routeTransitionX = entry.routeTransitionX;
|
|
757
|
-
const scrollTransformStyle = useAnimatedStyle(() => {
|
|
758
|
-
let scrollY = 0;
|
|
759
|
-
if (offsets) {
|
|
760
|
-
for (let index = 0; index < offsets.length; index += 1) {
|
|
761
|
-
scrollY += offsets[index].value;
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
|
-
return {
|
|
765
|
-
transform: [
|
|
766
|
-
{ translateX: routeTransitionX?.value ?? 0 },
|
|
767
|
-
{ translateY: -scrollY },
|
|
768
|
-
],
|
|
769
|
-
};
|
|
770
|
-
}, [offsets, routeTransitionX]);
|
|
771
|
-
const hasScrollOrRoute = (offsets != null && offsets.length > 0) || routeTransitionX != null;
|
|
772
|
-
return (
|
|
773
|
-
<Animated.View pointerEvents="box-none" style={[StyleSheet.absoluteFill, entry.style, { zIndex: entry.zIndex }]}>
|
|
774
|
-
{entry.frame ? (
|
|
775
|
-
<Animated.View
|
|
776
|
-
pointerEvents="box-none"
|
|
777
|
-
style={[
|
|
778
|
-
{ position: 'absolute', left: entry.frame.x, top: entry.frame.y, width: entry.frame.width, height: entry.frame.height },
|
|
779
|
-
hasScrollOrRoute ? scrollTransformStyle : undefined,
|
|
780
|
-
entry.portalOffsetStyle,
|
|
781
|
-
]}
|
|
782
|
-
>
|
|
783
|
-
{entry.children}
|
|
784
|
-
</Animated.View>
|
|
785
|
-
) : entry.children}
|
|
786
|
-
</Animated.View>
|
|
787
|
-
);
|
|
788
|
-
});
|
|
789
|
-
|
|
790
|
-
const PortalGlassSurface = React.memo(function PortalGlassSurface({ providerId, entry, drawOrder, shaderEnabled }: { providerId: string; entry: SurfaceEntry; drawOrder: number; shaderEnabled: boolean }) {
|
|
791
|
-
const runtime = useContext(GlassRuntimeContext);
|
|
792
|
-
const opticalProgress = entry.opticalProgress;
|
|
793
|
-
const pointerEvent = entry.pointerEvent;
|
|
794
|
-
const pointerEventValue = entry.pointerEventValue;
|
|
795
|
-
const pointerEventSink = entry.pointerEventSink;
|
|
796
|
-
const valueEvent = entry.valueEvent;
|
|
797
|
-
const valueEventSink = entry.valueEventSink;
|
|
798
|
-
const opticalToggleFraction = entry.opticalToggleFraction;
|
|
799
|
-
const opticalProgressValue = entry.opticalProgressValue;
|
|
800
|
-
const opticalPointX = entry.opticalPointX;
|
|
801
|
-
const opticalPointY = entry.opticalPointY;
|
|
802
|
-
const opticalVelocityX = entry.opticalVelocityX;
|
|
803
|
-
const opticalVelocityY = entry.opticalVelocityY;
|
|
804
|
-
const opticalMotionX = entry.opticalMotionX;
|
|
805
|
-
const opticalMotionY = entry.opticalMotionY;
|
|
806
|
-
const hasAnimatedOptics = Boolean(
|
|
807
|
-
opticalPointX || opticalPointY || opticalVelocityX || opticalVelocityY ||
|
|
808
|
-
opticalProgressValue != null || opticalProgress || opticalToggleFraction ||
|
|
809
|
-
opticalMotionX || opticalMotionY,
|
|
810
|
-
);
|
|
811
|
-
const animatedOptics = useAnimatedProps(() => ({
|
|
812
|
-
interactionVelocityX: opticalVelocityX?.value,
|
|
813
|
-
interactionVelocityY: opticalVelocityY?.value,
|
|
814
|
-
interactionPointX: opticalPointX?.value,
|
|
815
|
-
interactionPointY: opticalPointY?.value,
|
|
816
|
-
interactionProgress: opticalProgressValue ?? opticalProgress?.value ?? 0,
|
|
817
|
-
toggleFraction: opticalToggleFraction?.value ?? 0,
|
|
818
|
-
motionX: opticalMotionX ? Math.max(-1, Math.min(1, opticalMotionX.value / 1800)) : undefined,
|
|
819
|
-
motionY: opticalMotionY ? Math.max(-1, Math.min(1, opticalMotionY.value / 1800)) : undefined,
|
|
820
|
-
}), [opticalPointX, opticalPointY, opticalVelocityX, opticalVelocityY, opticalProgress, pointerEventValue, valueEvent, opticalToggleFraction, opticalProgressValue, opticalMotionX, opticalMotionY]);
|
|
821
|
-
if (!runtime) return null;
|
|
822
|
-
const { tokens, dark, reducedMotion } = runtime;
|
|
823
|
-
// Backdrop glass is drawn in a sibling overlay, above the actual control.
|
|
824
|
-
// Some native render backends still participate in Android hit testing even
|
|
825
|
-
// with pointerEvents="none" on the native view itself, so make the whole
|
|
826
|
-
// portal subtree untargetable for passive lenses. Keep box-none where its
|
|
827
|
-
// React content or an explicitly interactive surface needs to receive input.
|
|
828
|
-
const portalPointerEvents = entry.interactive || entry.portalContent || entry.contentAboveGlass
|
|
829
|
-
? 'box-none'
|
|
830
|
-
: 'none';
|
|
831
|
-
const material = entry.materialOverrides
|
|
832
|
-
? { ...tokens.materials[entry.variant], ...entry.materialOverrides }
|
|
833
|
-
: tokens.materials[entry.variant];
|
|
834
|
-
const qualityScale = material.opticsModel === 'referenceParity'
|
|
835
|
-
? 1
|
|
836
|
-
: tokens.quality === 'high' ? 1.2 : tokens.quality === 'fallback' ? 0.45 : 1;
|
|
837
|
-
|
|
838
|
-
if (!shaderEnabled) return <PortalFallbackSurface entry={entry} />;
|
|
839
|
-
|
|
840
|
-
const nativeSurface = (
|
|
841
|
-
<NativeBackdropSurface
|
|
842
|
-
providerId={providerId}
|
|
843
|
-
sharedPassZIndex={entry.zIndex}
|
|
844
|
-
sharedPassOrder={drawOrder}
|
|
845
|
-
opticsModel={material.opticsModel}
|
|
846
|
-
shapeMaskText={entry.shapeMaskText}
|
|
847
|
-
shapeMaskFontSize={entry.shapeMaskFontSize}
|
|
848
|
-
shapeMaskFontWeight={entry.shapeMaskFontWeight}
|
|
849
|
-
progressiveBlurIntensity={entry.progressiveBlurIntensity}
|
|
850
|
-
depthEffect={material.referenceDepthEffect ?? false}
|
|
851
|
-
highlightStyle={material.referenceHighlightStyle}
|
|
852
|
-
interactionProfile={material.referenceInteractionProfile}
|
|
853
|
-
contentScaleX={material.referenceContentScaleX}
|
|
854
|
-
contentScaleY={material.referenceContentScaleY}
|
|
855
|
-
sampleOffsetX={material.referenceSampleOffsetX}
|
|
856
|
-
sampleOffsetY={material.referenceSampleOffsetY}
|
|
857
|
-
toggleTrackColorOff={material.referenceToggleTrackColorOff}
|
|
858
|
-
toggleTrackColorOn={material.referenceToggleTrackColorOn}
|
|
859
|
-
toggleTrackWidth={material.referenceToggleTrackWidth}
|
|
860
|
-
toggleTrackHeight={material.referenceToggleTrackHeight}
|
|
861
|
-
toggleSolidBackdropColor={material.referenceToggleSolidBackdropColor}
|
|
862
|
-
brightness={material.brightness ?? 0}
|
|
863
|
-
contrast={material.contrast ?? 1}
|
|
864
|
-
highlightFalloff={material.highlightFalloff ?? 1}
|
|
865
|
-
sdfContrast={material.sdfScaleLens?.contrast}
|
|
866
|
-
sdfBrightness={material.sdfScaleLens?.brightness}
|
|
867
|
-
sdfSaturation={material.sdfScaleLens?.saturation}
|
|
868
|
-
sdfOuterShadowAlpha={material.sdfScaleLens?.outerShadowAlpha}
|
|
869
|
-
sdfOuterShadowBlurRadius={material.sdfScaleLens?.outerShadowBlurRadius}
|
|
870
|
-
sdfOuterShadowOffsetY={material.sdfScaleLens?.outerShadowOffsetY}
|
|
871
|
-
sdfInnerShadowAlpha={material.sdfScaleLens?.innerShadowAlpha}
|
|
872
|
-
sdfInnerShadowExtent={material.sdfScaleLens?.innerShadowExtent}
|
|
873
|
-
cornerRadius={material.radius}
|
|
874
|
-
blurRadius={material.blurRadius * qualityScale}
|
|
875
|
-
refractionHeight={material.refractionHeight * qualityScale}
|
|
876
|
-
refractionAmount={material.refractionAmount * qualityScale}
|
|
877
|
-
bodyRefractionAmount={(material.refractionBodyAmount ?? 2.5) * qualityScale}
|
|
878
|
-
interactionProgress={opticalProgressValue ?? 0}
|
|
879
|
-
// The pointer stream must be a real prop, not only an animated one:
|
|
880
|
-
// Reanimated's animatedProps path does not reach an Expo Modules view's
|
|
881
|
-
// prop setter, so a gesture sent only there is silently dropped and the
|
|
882
|
-
// native driver never sees a single event.
|
|
883
|
-
pointerEvent={entry.pointerEventValue}
|
|
884
|
-
pointerEventSink={pointerEventSink}
|
|
885
|
-
valueEvent={entry.valueEvent}
|
|
886
|
-
valueEventSink={valueEventSink}
|
|
887
|
-
saturation={material.saturation}
|
|
888
|
-
chromaticAberration={material.opticsModel === 'referenceParity' || tokens.quality === 'high' || entry.variant === 'tabSelectionLens'
|
|
889
|
-
? material.chromaticAberration
|
|
890
|
-
: 0}
|
|
891
|
-
highlightAlpha={material.highlightAlpha}
|
|
892
|
-
highlightWidth={material.highlightWidth}
|
|
893
|
-
lightAngle={material.highlightAngle ?? 45}
|
|
894
|
-
highlightColor={material.highlightColor ? (dark ? material.highlightColor.dark : material.highlightColor.light) : undefined}
|
|
895
|
-
tintAlpha={material.tintAlpha ?? 1}
|
|
896
|
-
specularStrength={material.specularStrength ?? 1}
|
|
897
|
-
fresnelStrength={material.fresnelStrength ?? 0.85}
|
|
898
|
-
innerShadowStrength={material.innerShadowStrength ?? (material.opticsModel === 'referenceParity' ? 0 : 0.18)}
|
|
899
|
-
shadowOpacity={material.shadowOpacity ?? (material.opticsModel === 'referenceParity' ? 0 : 0.1)}
|
|
900
|
-
shadowRadius={material.shadowRadius ?? (material.opticsModel === 'referenceParity' ? 0 : 24)}
|
|
901
|
-
shadowOffsetY={material.shadowOffsetY ?? (material.opticsModel === 'referenceParity' ? 0 : 4)}
|
|
902
|
-
tint={entry.tintColor ?? (dark ? tokens.tint.dark : tokens.tint.light)}
|
|
903
|
-
surfaceColor={material.surfaceColor ? (dark ? material.surfaceColor.dark : material.surfaceColor.light) : undefined}
|
|
904
|
-
interactive={entry.interactive && tokens.interaction.enabled && !reducedMotion}
|
|
905
|
-
pointerEvents={entry.interactive && tokens.interaction.enabled && !reducedMotion ? 'auto' : 'none'}
|
|
906
|
-
continuous={entry.continuous}
|
|
907
|
-
sharedSource={entry.sharedSource}
|
|
908
|
-
captureProbe={entry.captureProbe}
|
|
909
|
-
motionX={undefined}
|
|
910
|
-
motionY={undefined}
|
|
911
|
-
displacementOnlyDebug={entry.displacementOnlyDebug}
|
|
912
|
-
syncContentTransform={entry.syncContentTransform}
|
|
913
|
-
animatedProps={hasAnimatedOptics ? animatedOptics : undefined}
|
|
914
|
-
style={[
|
|
915
|
-
styles.nativeSurface,
|
|
916
|
-
entry.placement === 'layout'
|
|
917
|
-
? StyleSheet.absoluteFill
|
|
918
|
-
: { width: entry.frame.width > 0 ? entry.frame.width : undefined },
|
|
919
|
-
{ borderRadius: material.radius },
|
|
920
|
-
]}
|
|
921
|
-
/>
|
|
922
|
-
);
|
|
923
|
-
|
|
924
|
-
if (entry.placement === 'bottom' || entry.placement === 'center') {
|
|
925
|
-
const hasMotion = entry.animatedStyle != null || entry.portalOffsetStyle != null;
|
|
926
|
-
if (!hasMotion) {
|
|
927
|
-
return (
|
|
928
|
-
<View
|
|
929
|
-
pointerEvents={portalPointerEvents}
|
|
930
|
-
style={[
|
|
931
|
-
StyleSheet.absoluteFill,
|
|
932
|
-
entry.placement === 'center' ? styles.centerPlacement : styles.bottomPlacement,
|
|
933
|
-
entry.placement === 'bottom' && entry.bottomInset != null ? { paddingBottom: entry.bottomInset } : undefined,
|
|
934
|
-
]}
|
|
935
|
-
>
|
|
936
|
-
{nativeSurface}
|
|
937
|
-
</View>
|
|
938
|
-
);
|
|
939
|
-
}
|
|
940
|
-
return (
|
|
941
|
-
<Animated.View
|
|
942
|
-
pointerEvents={portalPointerEvents}
|
|
943
|
-
style={[
|
|
944
|
-
StyleSheet.absoluteFill,
|
|
945
|
-
entry.placement === 'center' ? styles.centerPlacement : styles.bottomPlacement,
|
|
946
|
-
entry.placement === 'bottom' && entry.bottomInset != null ? { paddingBottom: entry.bottomInset } : undefined,
|
|
947
|
-
entry.animatedStyle,
|
|
948
|
-
entry.portalOffsetStyle,
|
|
949
|
-
]}
|
|
950
|
-
>
|
|
951
|
-
{nativeSurface}
|
|
952
|
-
</Animated.View>
|
|
953
|
-
);
|
|
954
|
-
}
|
|
955
|
-
|
|
956
|
-
const portalContent = entry.portalContent && entry.placement === 'layout' ? (
|
|
957
|
-
<View
|
|
958
|
-
pointerEvents="box-none"
|
|
959
|
-
accessible={false}
|
|
960
|
-
accessibilityElementsHidden
|
|
961
|
-
importantForAccessibility="no-hide-descendants"
|
|
962
|
-
style={[StyleSheet.absoluteFill, styles.portalContentOverlay, { borderRadius: material.radius }]}
|
|
963
|
-
>
|
|
964
|
-
{entry.portalContent}
|
|
965
|
-
</View>
|
|
966
|
-
) : null;
|
|
967
|
-
|
|
968
|
-
const innerContent = (
|
|
969
|
-
<>
|
|
970
|
-
{nativeSurface}
|
|
971
|
-
{entry.contentAboveGlass && entry.content ? (
|
|
972
|
-
<View
|
|
973
|
-
pointerEvents="box-none"
|
|
974
|
-
style={[StyleSheet.absoluteFill, { borderRadius: material.radius }, styles.contentAboveGlass]}
|
|
975
|
-
>
|
|
976
|
-
<View style={entry.contentStyle}>{entry.content}</View>
|
|
977
|
-
</View>
|
|
978
|
-
) : null}
|
|
979
|
-
{portalContent}
|
|
980
|
-
</>
|
|
981
|
-
);
|
|
982
|
-
|
|
983
|
-
const hasMotion = (entry.positioning === 'floating' && entry.animatedStyle != null) || entry.portalOffsetStyle != null;
|
|
984
|
-
if (!hasMotion) {
|
|
985
|
-
return (
|
|
986
|
-
<View
|
|
987
|
-
pointerEvents={portalPointerEvents}
|
|
988
|
-
collapsable={!entry.syncContentTransform}
|
|
989
|
-
style={[
|
|
990
|
-
styles.portalSurface,
|
|
991
|
-
{ left: entry.frame.x, top: entry.frame.y, width: entry.frame.width, height: entry.frame.height },
|
|
992
|
-
]}
|
|
993
|
-
>
|
|
994
|
-
{innerContent}
|
|
995
|
-
</View>
|
|
996
|
-
);
|
|
997
|
-
}
|
|
998
|
-
|
|
999
|
-
return (
|
|
1000
|
-
<Animated.View
|
|
1001
|
-
pointerEvents={portalPointerEvents}
|
|
1002
|
-
collapsable={!entry.syncContentTransform}
|
|
1003
|
-
style={[
|
|
1004
|
-
styles.portalSurface,
|
|
1005
|
-
{ left: entry.frame.x, top: entry.frame.y, width: entry.frame.width, height: entry.frame.height },
|
|
1006
|
-
entry.positioning === 'floating' ? entry.animatedStyle : undefined,
|
|
1007
|
-
entry.portalOffsetStyle,
|
|
1008
|
-
]}
|
|
1009
|
-
>
|
|
1010
|
-
{innerContent}
|
|
1011
|
-
</Animated.View>
|
|
1012
|
-
);
|
|
1013
|
-
});
|
|
1014
|
-
|
|
1015
|
-
const PortalFallbackSurface = React.memo(function PortalFallbackSurface({ entry }: { entry: SurfaceEntry }) {
|
|
1016
|
-
const runtime = useContext(GlassRuntimeContext);
|
|
1017
|
-
if (!runtime) return null;
|
|
1018
|
-
const { tokens, dark } = runtime;
|
|
1019
|
-
const portalPointerEvents = entry.interactive || entry.portalContent || entry.contentAboveGlass
|
|
1020
|
-
? 'box-none'
|
|
1021
|
-
: 'none';
|
|
1022
|
-
const material = tokens.materials[entry.variant];
|
|
1023
|
-
const fallbackSurface = (
|
|
1024
|
-
<View
|
|
1025
|
-
pointerEvents="none"
|
|
1026
|
-
style={[
|
|
1027
|
-
styles.fallbackSurface,
|
|
1028
|
-
entry.placement === 'layout'
|
|
1029
|
-
? StyleSheet.absoluteFill
|
|
1030
|
-
: { width: entry.frame.width > 0 ? entry.frame.width : undefined },
|
|
1031
|
-
{
|
|
1032
|
-
backgroundColor: dark ? tokens.fallbackTint.dark : tokens.fallbackTint.light,
|
|
1033
|
-
borderColor: dark ? tokens.fallbackBorder.dark : tokens.fallbackBorder.light,
|
|
1034
|
-
borderRadius: material.radius,
|
|
1035
|
-
},
|
|
1036
|
-
]}
|
|
1037
|
-
>
|
|
1038
|
-
</View>
|
|
1039
|
-
);
|
|
1040
|
-
|
|
1041
|
-
if (entry.placement === 'bottom' || entry.placement === 'center') {
|
|
1042
|
-
return (
|
|
1043
|
-
<Animated.View
|
|
1044
|
-
pointerEvents={portalPointerEvents}
|
|
1045
|
-
style={[
|
|
1046
|
-
StyleSheet.absoluteFill,
|
|
1047
|
-
entry.placement === 'center' ? styles.centerPlacement : styles.bottomPlacement,
|
|
1048
|
-
entry.placement === 'bottom' && entry.bottomInset != null ? { paddingBottom: entry.bottomInset } : undefined,
|
|
1049
|
-
entry.animatedStyle,
|
|
1050
|
-
entry.portalOffsetStyle,
|
|
1051
|
-
]}
|
|
1052
|
-
>
|
|
1053
|
-
{fallbackSurface}
|
|
1054
|
-
</Animated.View>
|
|
1055
|
-
);
|
|
1056
|
-
}
|
|
1057
|
-
|
|
1058
|
-
return (
|
|
1059
|
-
<Animated.View
|
|
1060
|
-
pointerEvents={portalPointerEvents}
|
|
1061
|
-
style={[
|
|
1062
|
-
styles.portalSurface,
|
|
1063
|
-
{ left: entry.frame.x, top: entry.frame.y, width: entry.frame.width, height: entry.frame.height },
|
|
1064
|
-
entry.animatedStyle,
|
|
1065
|
-
entry.portalOffsetStyle,
|
|
1066
|
-
]}
|
|
1067
|
-
>
|
|
1068
|
-
{fallbackSurface}
|
|
1069
|
-
</Animated.View>
|
|
1070
|
-
);
|
|
1071
|
-
});
|
|
9
|
+
import {
|
|
10
|
+
GlassRuntimeContext,
|
|
11
|
+
GlassCaptureSourceContext,
|
|
12
|
+
GlassRouteTransitionContext,
|
|
13
|
+
GlassPortalScrollContext,
|
|
14
|
+
GlassMeasureOnlyContext,
|
|
15
|
+
GlassHostContext,
|
|
16
|
+
GlassOverlayHostContext,
|
|
17
|
+
GlassScopeActiveContext,
|
|
18
|
+
} from './surface/contexts';
|
|
19
|
+
import type { SurfaceFrame, GlassSamplingSource } from './surface/types';
|
|
20
|
+
import { InlineBackdropSurface, LocalGlassSurface } from './surface/InlineSurface';
|
|
21
|
+
import { styles } from './surface/styles';
|
|
1072
22
|
|
|
1073
23
|
export interface GlassSurfaceProps {
|
|
1074
24
|
variant?: GlassVariant;
|
|
@@ -1244,15 +194,19 @@ export const GlassSurface = React.memo(function GlassSurface({
|
|
|
1244
194
|
const routeTransitionX = useContext(GlassRouteTransitionContext);
|
|
1245
195
|
const portalScroll = useContext(GlassPortalScrollContext);
|
|
1246
196
|
const measureOnly = useContext(GlassMeasureOnlyContext);
|
|
1247
|
-
const hasPortalMotion =
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
197
|
+
const hasPortalMotion =
|
|
198
|
+
portalTranslateX != null || portalTranslateY != null || portalScaleX != null || portalScaleY != null;
|
|
199
|
+
const portalOffsetStyle = useAnimatedStyle(
|
|
200
|
+
() => ({
|
|
201
|
+
transform: [
|
|
202
|
+
...(portalTranslateX ? [{ translateX: portalTranslateX.value }] : []),
|
|
203
|
+
...(portalTranslateY ? [{ translateY: portalTranslateY.value }] : []),
|
|
204
|
+
...(portalScaleX ? [{ scaleX: portalScaleX.value }] : []),
|
|
205
|
+
...(portalScaleY ? [{ scaleY: portalScaleY.value }] : []),
|
|
206
|
+
],
|
|
207
|
+
}),
|
|
208
|
+
[portalTranslateX, portalTranslateY, portalScaleX, portalScaleY],
|
|
209
|
+
);
|
|
1256
210
|
const resolvedPositioning = positioning ?? (renderMode === 'backdrop' ? 'floating' : 'inFlow');
|
|
1257
211
|
const themeMaterial = runtime?.tokens.materials[variant];
|
|
1258
212
|
const referenceParity = themeMaterial?.opticsModel === 'referenceParity';
|
|
@@ -1261,31 +215,34 @@ export const GlassSurface = React.memo(function GlassSurface({
|
|
|
1261
215
|
// preference. Before 2026-11-15 a referenceParity material silently promoted
|
|
1262
216
|
// every local surface into a real backdrop consumer, which overrode Hyper UI's
|
|
1263
217
|
// `sampling="local"` cards and made the local strategy unreachable.
|
|
1264
|
-
const resolvedSampling =
|
|
1265
|
-
|
|
1266
|
-
|
|
218
|
+
const resolvedSampling =
|
|
219
|
+
sampling ??
|
|
220
|
+
renderMode ??
|
|
221
|
+
(referenceParity ? 'backdrop' : resolvedPositioning === 'floating' ? 'backdrop' : 'local');
|
|
1267
222
|
const resolvedSamplingSource = samplingSource ?? host?.defaultSamplingSource ?? 'routeScene';
|
|
1268
|
-
const resolvedSamplingProviderId =
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
223
|
+
const resolvedSamplingProviderId =
|
|
224
|
+
providerIdOverride != null
|
|
225
|
+
? providerIdOverride
|
|
226
|
+
: resolvedSamplingSource === 'themeBackdrop'
|
|
227
|
+
? host?.themeBackdropProviderId
|
|
228
|
+
: (captureSourceProviderId ?? host?.routeSceneProviderId ?? host?.themeBackdropProviderId);
|
|
1273
229
|
// A routeScene provider records route content. Keep its consumers outside
|
|
1274
230
|
// that source tree or the RenderNode can sample itself recursively.
|
|
1275
231
|
// Inline rendering remains valid when it samples the separate theme
|
|
1276
232
|
// backdrop provider (including the routeScene fallback without a scope)
|
|
1277
233
|
// or an explicit parent/underlay providerIdOverride outside the inner capture scope.
|
|
1278
|
-
const samplesOwnCaptureSource =
|
|
1279
|
-
|
|
234
|
+
const samplesOwnCaptureSource =
|
|
235
|
+
captureSourceProviderId !== null &&
|
|
236
|
+
(providerIdOverride != null
|
|
1280
237
|
? providerIdOverride === captureSourceProviderId
|
|
1281
|
-
: resolvedSamplingSource === 'routeScene'
|
|
1282
|
-
);
|
|
238
|
+
: resolvedSamplingSource === 'routeScene');
|
|
1283
239
|
// With a separate `backdrop` the route tree is already a sibling above the
|
|
1284
240
|
// capture source, so an in-flow surface can sample it directly through the
|
|
1285
241
|
// inline path. That removes the per-surface measureInWindow bridge round
|
|
1286
242
|
// trips, the portal re-render and the duplicate hidden measure tree.
|
|
1287
243
|
const flatSurfaceStyle = StyleSheet.flatten(style) as { height?: unknown } | undefined;
|
|
1288
|
-
const autoInlineBackdrop =
|
|
244
|
+
const autoInlineBackdrop =
|
|
245
|
+
inlineBackdrop === undefined &&
|
|
1289
246
|
host?.hasSeparateBackdrop === true &&
|
|
1290
247
|
!samplesOwnCaptureSource &&
|
|
1291
248
|
resolvedPositioning === 'inFlow' &&
|
|
@@ -1295,14 +252,20 @@ export const GlassSurface = React.memo(function GlassSurface({
|
|
|
1295
252
|
frameOverride == null &&
|
|
1296
253
|
zIndex <= 1 &&
|
|
1297
254
|
!hasPortalMotion;
|
|
1298
|
-
const resolvedInlineBackdrop =
|
|
255
|
+
const resolvedInlineBackdrop =
|
|
256
|
+
(inlineBackdrop ?? (autoInlineBackdrop || host?.inlineBackdropByDefault === true)) &&
|
|
1299
257
|
!samplesOwnCaptureSource;
|
|
1300
|
-
const resolvedIntrinsicInlineBackdrop =
|
|
1301
|
-
(autoInlineBackdrop && typeof flatSurfaceStyle?.height !== 'number');
|
|
258
|
+
const resolvedIntrinsicInlineBackdrop =
|
|
259
|
+
intrinsicInlineBackdrop || (autoInlineBackdrop && typeof flatSurfaceStyle?.height !== 'number');
|
|
1302
260
|
const contentAboveGlass = contentPlacement === 'aboveGlass' && resolvedSampling === 'backdrop';
|
|
1303
|
-
const resolvedRenderMode =
|
|
1304
|
-
|
|
1305
|
-
|
|
261
|
+
const resolvedRenderMode =
|
|
262
|
+
runtime?.tokens.enabled &&
|
|
263
|
+
resolvedSampling === 'backdrop' &&
|
|
264
|
+
Platform.OS === 'android' &&
|
|
265
|
+
host &&
|
|
266
|
+
runtime.tokens.quality !== 'fallback'
|
|
267
|
+
? 'backdrop'
|
|
268
|
+
: 'local';
|
|
1306
269
|
const id = useId();
|
|
1307
270
|
const viewRef = useRef<View>(null);
|
|
1308
271
|
const [frame, setFrame] = useState<SurfaceFrame | null>(null);
|
|
@@ -1331,17 +294,26 @@ export const GlassSurface = React.memo(function GlassSurface({
|
|
|
1331
294
|
width,
|
|
1332
295
|
height,
|
|
1333
296
|
};
|
|
1334
|
-
setFrame((current) =>
|
|
1335
|
-
|
|
1336
|
-
|
|
297
|
+
setFrame((current) =>
|
|
298
|
+
current &&
|
|
299
|
+
current.x === next.x &&
|
|
300
|
+
current.y === next.y &&
|
|
301
|
+
current.width === width &&
|
|
302
|
+
current.height === height
|
|
303
|
+
? current
|
|
304
|
+
: next,
|
|
305
|
+
);
|
|
1337
306
|
});
|
|
1338
307
|
});
|
|
1339
308
|
}, [host, portalScroll.offsets, routeTransitionX, resolvedInlineBackdrop]);
|
|
1340
309
|
|
|
1341
|
-
const onLayout = useCallback(
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
310
|
+
const onLayout = useCallback(
|
|
311
|
+
(event: LayoutChangeEvent) => {
|
|
312
|
+
measure();
|
|
313
|
+
onLayoutProp?.(event);
|
|
314
|
+
},
|
|
315
|
+
[measure, onLayoutProp],
|
|
316
|
+
);
|
|
1345
317
|
|
|
1346
318
|
useEffect(() => {
|
|
1347
319
|
measure();
|
|
@@ -1351,12 +323,26 @@ export const GlassSurface = React.memo(function GlassSurface({
|
|
|
1351
323
|
|
|
1352
324
|
useEffect(() => {
|
|
1353
325
|
if (!host) return;
|
|
1354
|
-
if (
|
|
326
|
+
if (
|
|
327
|
+
measureOnly ||
|
|
328
|
+
!scopeActive ||
|
|
329
|
+
!runtime?.tokens.enabled ||
|
|
330
|
+
resolvedRenderMode !== 'backdrop' ||
|
|
331
|
+
resolvedInlineBackdrop ||
|
|
332
|
+
!frame ||
|
|
333
|
+
frame.width <= 0 ||
|
|
334
|
+
frame.height <= 0
|
|
335
|
+
) {
|
|
1355
336
|
host.remove(id);
|
|
1356
337
|
return;
|
|
1357
338
|
}
|
|
1358
339
|
const publishedFrame = frameOverride
|
|
1359
|
-
? {
|
|
340
|
+
? {
|
|
341
|
+
x: frameOverride.x,
|
|
342
|
+
y: frameOverride.y,
|
|
343
|
+
width: frameOverride.width,
|
|
344
|
+
height: frameOverride.height,
|
|
345
|
+
}
|
|
1360
346
|
: frame;
|
|
1361
347
|
host.updateSurface(id, {
|
|
1362
348
|
frame: publishedFrame,
|
|
@@ -1366,7 +352,8 @@ export const GlassSurface = React.memo(function GlassSurface({
|
|
|
1366
352
|
samplingProviderId: resolvedSamplingProviderId ?? host.themeBackdropProviderId,
|
|
1367
353
|
tintColor,
|
|
1368
354
|
portalContent,
|
|
1369
|
-
contentAboveGlass:
|
|
355
|
+
contentAboveGlass:
|
|
356
|
+
contentAboveGlass && resolvedRenderMode === 'backdrop' && !resolvedInlineBackdrop,
|
|
1370
357
|
sharedSource,
|
|
1371
358
|
content: contentAboveGlass ? children : undefined,
|
|
1372
359
|
contentStyle: contentAboveGlass ? contentStyle : undefined,
|
|
@@ -1419,13 +406,87 @@ export const GlassSurface = React.memo(function GlassSurface({
|
|
|
1419
406
|
} else {
|
|
1420
407
|
host.removeOverlay(id);
|
|
1421
408
|
}
|
|
1422
|
-
}, [
|
|
409
|
+
}, [
|
|
410
|
+
measureOnly,
|
|
411
|
+
scopeActive,
|
|
412
|
+
runtime?.tokens.enabled,
|
|
413
|
+
resolvedRenderMode,
|
|
414
|
+
resolvedInlineBackdrop,
|
|
415
|
+
host,
|
|
416
|
+
id,
|
|
417
|
+
frame,
|
|
418
|
+
frameOverride,
|
|
419
|
+
resolvedPositioning,
|
|
420
|
+
resolvedSamplingSource,
|
|
421
|
+
resolvedSamplingProviderId,
|
|
422
|
+
tintColor,
|
|
423
|
+
portalContent,
|
|
424
|
+
portalInteractionContent,
|
|
425
|
+
contentAboveGlass,
|
|
426
|
+
children,
|
|
427
|
+
variant,
|
|
428
|
+
interactive,
|
|
429
|
+
continuous,
|
|
430
|
+
sharedSource,
|
|
431
|
+
captureProbe,
|
|
432
|
+
opticalProgress,
|
|
433
|
+
routeTransitionX,
|
|
434
|
+
portalScroll.offsets,
|
|
435
|
+
portalScroll.groupKey,
|
|
436
|
+
hasPortalMotion,
|
|
437
|
+
portalOffsetStyle,
|
|
438
|
+
portalTranslateX,
|
|
439
|
+
portalTranslateY,
|
|
440
|
+
portalScaleX,
|
|
441
|
+
portalScaleY,
|
|
442
|
+
pointerEvent,
|
|
443
|
+
pointerEventValue,
|
|
444
|
+
pointerEventSink,
|
|
445
|
+
valueEvent,
|
|
446
|
+
valueEventSink,
|
|
447
|
+
opticalToggleFraction,
|
|
448
|
+
opticalProgressValue,
|
|
449
|
+
opticalPointX,
|
|
450
|
+
opticalPointY,
|
|
451
|
+
opticalVelocityX,
|
|
452
|
+
opticalVelocityY,
|
|
453
|
+
opticalMotionX,
|
|
454
|
+
opticalMotionY,
|
|
455
|
+
materialOverrides,
|
|
456
|
+
shapeMaskText,
|
|
457
|
+
shapeMaskFontSize,
|
|
458
|
+
shapeMaskFontWeight,
|
|
459
|
+
progressiveBlurIntensity,
|
|
460
|
+
displacementOnlyDebug,
|
|
461
|
+
syncContentTransform,
|
|
462
|
+
animatedStyle,
|
|
463
|
+
placement,
|
|
464
|
+
bottomInset,
|
|
465
|
+
zIndex,
|
|
466
|
+
]);
|
|
1423
467
|
|
|
1424
468
|
if (measureOnly) {
|
|
1425
469
|
return (
|
|
1426
470
|
<View pointerEvents="none" style={style}>
|
|
1427
|
-
<View
|
|
1428
|
-
|
|
471
|
+
<View
|
|
472
|
+
style={
|
|
473
|
+
resolvedInlineBackdrop
|
|
474
|
+
? resolvedIntrinsicInlineBackdrop
|
|
475
|
+
? styles.inlineBackdropIntrinsicSurface
|
|
476
|
+
: styles.inlineBackdropSurface
|
|
477
|
+
: undefined
|
|
478
|
+
}
|
|
479
|
+
>
|
|
480
|
+
<View
|
|
481
|
+
style={[
|
|
482
|
+
contentAboveGlass || resolvedIntrinsicInlineBackdrop
|
|
483
|
+
? styles.portalContentIntrinsic
|
|
484
|
+
: placement === 'layout'
|
|
485
|
+
? styles.portalContentLayout
|
|
486
|
+
: styles.portalContentWrap,
|
|
487
|
+
contentStyle,
|
|
488
|
+
]}
|
|
489
|
+
>
|
|
1429
490
|
{children}
|
|
1430
491
|
</View>
|
|
1431
492
|
</View>
|
|
@@ -1434,7 +495,18 @@ export const GlassSurface = React.memo(function GlassSurface({
|
|
|
1434
495
|
}
|
|
1435
496
|
|
|
1436
497
|
if (!runtime?.tokens.enabled) {
|
|
1437
|
-
return
|
|
498
|
+
return (
|
|
499
|
+
<Animated.View
|
|
500
|
+
style={[
|
|
501
|
+
style,
|
|
502
|
+
animatedStyle,
|
|
503
|
+
hasPortalMotion ? portalOffsetStyle : undefined,
|
|
504
|
+
fallbackAnimatedStyle,
|
|
505
|
+
]}
|
|
506
|
+
>
|
|
507
|
+
<View style={contentStyle}>{children}</View>
|
|
508
|
+
</Animated.View>
|
|
509
|
+
);
|
|
1438
510
|
}
|
|
1439
511
|
|
|
1440
512
|
// Keep inline renderers and their foreground subtrees mounted across page
|
|
@@ -1449,7 +521,11 @@ export const GlassSurface = React.memo(function GlassSurface({
|
|
|
1449
521
|
// motion driver and no press animation was ever created.
|
|
1450
522
|
if (resolvedInlineBackdrop) {
|
|
1451
523
|
return (
|
|
1452
|
-
<Animated.View
|
|
524
|
+
<Animated.View
|
|
525
|
+
pointerEvents={pointerEvents}
|
|
526
|
+
onLayout={onLayoutProp}
|
|
527
|
+
style={[style, animatedStyle, hasPortalMotion ? portalOffsetStyle : undefined]}
|
|
528
|
+
>
|
|
1453
529
|
<InlineBackdropSurface
|
|
1454
530
|
renderingEnabled={scopeActive}
|
|
1455
531
|
providerId={resolvedSamplingProviderId ?? ''}
|
|
@@ -1510,7 +586,16 @@ export const GlassSurface = React.memo(function GlassSurface({
|
|
|
1510
586
|
onLayout={onLayout}
|
|
1511
587
|
style={[style, animatedStyle, styles.measureOnly]}
|
|
1512
588
|
>
|
|
1513
|
-
<View
|
|
589
|
+
<View
|
|
590
|
+
style={[
|
|
591
|
+
contentAboveGlass
|
|
592
|
+
? styles.portalContentIntrinsic
|
|
593
|
+
: placement === 'layout'
|
|
594
|
+
? styles.portalContentLayout
|
|
595
|
+
: styles.portalContentWrap,
|
|
596
|
+
contentStyle,
|
|
597
|
+
]}
|
|
598
|
+
>
|
|
1514
599
|
{contentAboveGlass ? (
|
|
1515
600
|
// The visible copy lives in the overlay; this one only exists
|
|
1516
601
|
// so a content-sized surface still measures. alpha 0 keeps it
|
|
@@ -1526,213 +611,14 @@ export const GlassSurface = React.memo(function GlassSurface({
|
|
|
1526
611
|
{measurementContent ?? children}
|
|
1527
612
|
</GlassMeasureOnlyContext.Provider>
|
|
1528
613
|
</View>
|
|
1529
|
-
) :
|
|
614
|
+
) : (
|
|
615
|
+
children
|
|
616
|
+
)}
|
|
1530
617
|
</View>
|
|
1531
618
|
</Animated.View>
|
|
1532
619
|
);
|
|
1533
620
|
});
|
|
1534
621
|
|
|
1535
|
-
const InlineBackdropSurface = React.memo(function InlineBackdropSurface({
|
|
1536
|
-
renderingEnabled,
|
|
1537
|
-
providerId,
|
|
1538
|
-
variant,
|
|
1539
|
-
tintColor,
|
|
1540
|
-
interactive,
|
|
1541
|
-
continuous,
|
|
1542
|
-
sharedSource,
|
|
1543
|
-
captureProbe,
|
|
1544
|
-
opticalProgress,
|
|
1545
|
-
pointerEvent,
|
|
1546
|
-
pointerEventValue,
|
|
1547
|
-
pointerEventSink,
|
|
1548
|
-
valueEventSink,
|
|
1549
|
-
valueEvent,
|
|
1550
|
-
opticalToggleFraction,
|
|
1551
|
-
opticalPointX,
|
|
1552
|
-
opticalPointY,
|
|
1553
|
-
opticalVelocityX,
|
|
1554
|
-
opticalVelocityY,
|
|
1555
|
-
opticalMotionX,
|
|
1556
|
-
opticalMotionY,
|
|
1557
|
-
materialOverrides,
|
|
1558
|
-
displacementOnlyDebug,
|
|
1559
|
-
syncContentTransform,
|
|
1560
|
-
intrinsicLayout,
|
|
1561
|
-
contentStyle,
|
|
1562
|
-
placement,
|
|
1563
|
-
children,
|
|
1564
|
-
}: {
|
|
1565
|
-
renderingEnabled: boolean;
|
|
1566
|
-
providerId: string;
|
|
1567
|
-
variant: GlassVariant;
|
|
1568
|
-
tintColor?: ColorValue;
|
|
1569
|
-
interactive: boolean;
|
|
1570
|
-
continuous: boolean;
|
|
1571
|
-
opticalProgress?: SharedValue<number>;
|
|
1572
|
-
/** Pointer event stream for the native motion driver; it owns the spring. */
|
|
1573
|
-
pointerEvent?: SharedValue<string>;
|
|
1574
|
-
/** The same stream as plain state; this is what the native prop receives. */
|
|
1575
|
-
pointerEventValue?: string;
|
|
1576
|
-
/** Direct native path for pointer samples that should not rerender inline surfaces. */
|
|
1577
|
-
pointerEventSink?: GlassPointerEventSink;
|
|
1578
|
-
/** Knob value stream for value-driven lenses; see useGlassKnobMotion. */
|
|
1579
|
-
valueEvent?: string;
|
|
1580
|
-
/** Direct native path for knob values that should not rerender portal surfaces. */
|
|
1581
|
-
valueEventSink?: GlassValueEventSink;
|
|
1582
|
-
opticalToggleFraction?: SharedValue<number>;
|
|
1583
|
-
opticalPointX?: SharedValue<number>;
|
|
1584
|
-
opticalPointY?: SharedValue<number>;
|
|
1585
|
-
opticalVelocityX?: SharedValue<number>;
|
|
1586
|
-
opticalVelocityY?: SharedValue<number>;
|
|
1587
|
-
opticalMotionX?: SharedValue<number>;
|
|
1588
|
-
opticalMotionY?: SharedValue<number>;
|
|
1589
|
-
materialOverrides?: Partial<GlassMaterialTokens>;
|
|
1590
|
-
displacementOnlyDebug: boolean;
|
|
1591
|
-
syncContentTransform?: boolean;
|
|
1592
|
-
intrinsicLayout: boolean;
|
|
1593
|
-
sharedSource?: boolean;
|
|
1594
|
-
captureProbe?: boolean;
|
|
1595
|
-
contentStyle?: StyleProp<ViewStyle>;
|
|
1596
|
-
placement: 'layout' | 'bottom' | 'center';
|
|
1597
|
-
children?: React.ReactNode;
|
|
1598
|
-
}) {
|
|
1599
|
-
const runtime = useContext(GlassRuntimeContext);
|
|
1600
|
-
const hasAnimatedOptics = Boolean(
|
|
1601
|
-
opticalPointX || opticalPointY || opticalVelocityX || opticalVelocityY ||
|
|
1602
|
-
opticalProgress || opticalToggleFraction || opticalMotionX || opticalMotionY,
|
|
1603
|
-
);
|
|
1604
|
-
const animatedOptics = useAnimatedProps(() => ({
|
|
1605
|
-
interactionVelocityX: opticalVelocityX?.value,
|
|
1606
|
-
interactionVelocityY: opticalVelocityY?.value,
|
|
1607
|
-
interactionPointX: opticalPointX?.value,
|
|
1608
|
-
interactionPointY: opticalPointY?.value,
|
|
1609
|
-
interactionProgress: opticalProgress?.value ?? 0,
|
|
1610
|
-
toggleFraction: opticalToggleFraction?.value ?? 0,
|
|
1611
|
-
motionX: opticalMotionX ? Math.max(-1, Math.min(1, opticalMotionX.value / 1800)) : undefined,
|
|
1612
|
-
motionY: opticalMotionY ? Math.max(-1, Math.min(1, opticalMotionY.value / 1800)) : undefined,
|
|
1613
|
-
}), [opticalPointX, opticalPointY, opticalVelocityX, opticalVelocityY, opticalProgress, pointerEventValue, valueEvent, opticalToggleFraction, opticalMotionX, opticalMotionY]);
|
|
1614
|
-
if (!runtime) return <>{children}</>;
|
|
1615
|
-
const { tokens, dark, reducedMotion } = runtime;
|
|
1616
|
-
const material = materialOverrides
|
|
1617
|
-
? { ...tokens.materials[variant], ...materialOverrides }
|
|
1618
|
-
: tokens.materials[variant];
|
|
1619
|
-
const qualityScale = material.opticsModel === 'referenceParity'
|
|
1620
|
-
? 1
|
|
1621
|
-
: tokens.quality === 'high' ? 1.2 : tokens.quality === 'fallback' ? 0.45 : 1;
|
|
1622
|
-
return (
|
|
1623
|
-
<View collapsable={!syncContentTransform} style={intrinsicLayout ? styles.inlineBackdropIntrinsicSurface : styles.inlineBackdropSurface}>
|
|
1624
|
-
<NativeBackdropSurface
|
|
1625
|
-
renderingEnabled={renderingEnabled}
|
|
1626
|
-
providerId={providerId}
|
|
1627
|
-
opticsModel={material.opticsModel}
|
|
1628
|
-
depthEffect={material.referenceDepthEffect ?? false}
|
|
1629
|
-
highlightStyle={material.referenceHighlightStyle}
|
|
1630
|
-
interactionProfile={material.referenceInteractionProfile}
|
|
1631
|
-
contentScaleX={material.referenceContentScaleX}
|
|
1632
|
-
contentScaleY={material.referenceContentScaleY}
|
|
1633
|
-
sampleOffsetX={material.referenceSampleOffsetX}
|
|
1634
|
-
sampleOffsetY={material.referenceSampleOffsetY}
|
|
1635
|
-
toggleTrackColorOff={material.referenceToggleTrackColorOff}
|
|
1636
|
-
toggleTrackColorOn={material.referenceToggleTrackColorOn}
|
|
1637
|
-
toggleTrackWidth={material.referenceToggleTrackWidth}
|
|
1638
|
-
toggleTrackHeight={material.referenceToggleTrackHeight}
|
|
1639
|
-
toggleSolidBackdropColor={material.referenceToggleSolidBackdropColor}
|
|
1640
|
-
brightness={material.brightness ?? 0}
|
|
1641
|
-
contrast={material.contrast ?? 1}
|
|
1642
|
-
highlightFalloff={material.highlightFalloff ?? 1}
|
|
1643
|
-
sdfContrast={material.sdfScaleLens?.contrast}
|
|
1644
|
-
sdfBrightness={material.sdfScaleLens?.brightness}
|
|
1645
|
-
sdfSaturation={material.sdfScaleLens?.saturation}
|
|
1646
|
-
sdfOuterShadowAlpha={material.sdfScaleLens?.outerShadowAlpha}
|
|
1647
|
-
sdfOuterShadowBlurRadius={material.sdfScaleLens?.outerShadowBlurRadius}
|
|
1648
|
-
sdfOuterShadowOffsetY={material.sdfScaleLens?.outerShadowOffsetY}
|
|
1649
|
-
sdfInnerShadowAlpha={material.sdfScaleLens?.innerShadowAlpha}
|
|
1650
|
-
sdfInnerShadowExtent={material.sdfScaleLens?.innerShadowExtent}
|
|
1651
|
-
cornerRadius={material.radius}
|
|
1652
|
-
blurRadius={material.blurRadius * qualityScale}
|
|
1653
|
-
refractionHeight={material.refractionHeight * qualityScale}
|
|
1654
|
-
refractionAmount={material.refractionAmount * qualityScale}
|
|
1655
|
-
bodyRefractionAmount={(material.refractionBodyAmount ?? 2.5) * qualityScale}
|
|
1656
|
-
interactionProgress={0}
|
|
1657
|
-
pointerEvent={pointerEventValue}
|
|
1658
|
-
pointerEventSink={pointerEventSink}
|
|
1659
|
-
valueEventSink={valueEventSink}
|
|
1660
|
-
valueEvent={valueEvent}
|
|
1661
|
-
saturation={material.saturation}
|
|
1662
|
-
chromaticAberration={material.opticsModel === 'referenceParity' || tokens.quality === 'high' || variant === 'tabSelectionLens' ? material.chromaticAberration : 0}
|
|
1663
|
-
highlightAlpha={material.highlightAlpha}
|
|
1664
|
-
highlightWidth={material.highlightWidth}
|
|
1665
|
-
lightAngle={material.highlightAngle ?? 45}
|
|
1666
|
-
highlightColor={material.highlightColor ? (dark ? material.highlightColor.dark : material.highlightColor.light) : undefined}
|
|
1667
|
-
tintAlpha={material.tintAlpha ?? 1}
|
|
1668
|
-
specularStrength={material.specularStrength ?? 1}
|
|
1669
|
-
fresnelStrength={material.fresnelStrength ?? 0.85}
|
|
1670
|
-
innerShadowStrength={material.innerShadowStrength ?? (material.opticsModel === 'referenceParity' ? 0 : 0.18)}
|
|
1671
|
-
shadowOpacity={material.shadowOpacity ?? (material.opticsModel === 'referenceParity' ? 0 : 0.1)}
|
|
1672
|
-
shadowRadius={material.shadowRadius ?? (material.opticsModel === 'referenceParity' ? 0 : 24)}
|
|
1673
|
-
shadowOffsetY={material.shadowOffsetY ?? (material.opticsModel === 'referenceParity' ? 0 : 4)}
|
|
1674
|
-
tint={tintColor ?? (dark ? tokens.tint.dark : tokens.tint.light)}
|
|
1675
|
-
surfaceColor={material.surfaceColor ? (dark ? material.surfaceColor.dark : material.surfaceColor.light) : undefined}
|
|
1676
|
-
interactive={interactive && tokens.interaction.enabled && !reducedMotion}
|
|
1677
|
-
continuous={continuous}
|
|
1678
|
-
sharedSource={sharedSource}
|
|
1679
|
-
captureProbe={captureProbe}
|
|
1680
|
-
displacementOnlyDebug={displacementOnlyDebug}
|
|
1681
|
-
syncContentTransform={syncContentTransform}
|
|
1682
|
-
animatedProps={hasAnimatedOptics ? animatedOptics : undefined}
|
|
1683
|
-
pointerEvents={interactive ? undefined : 'none'}
|
|
1684
|
-
style={[StyleSheet.absoluteFill, { borderRadius: material.radius }]}
|
|
1685
|
-
/>
|
|
1686
|
-
<View style={[intrinsicLayout ? styles.portalContentIntrinsic : placement === 'layout' ? styles.portalContentLayout : styles.portalContentWrap, contentStyle]}>
|
|
1687
|
-
{children}
|
|
1688
|
-
</View>
|
|
1689
|
-
</View>
|
|
1690
|
-
);
|
|
1691
|
-
});
|
|
1692
|
-
|
|
1693
|
-
function LocalGlassSurface({
|
|
1694
|
-
variant,
|
|
1695
|
-
surfaceRole,
|
|
1696
|
-
style,
|
|
1697
|
-
contentStyle,
|
|
1698
|
-
animatedStyle,
|
|
1699
|
-
fallbackAnimatedStyle,
|
|
1700
|
-
pointerEvents,
|
|
1701
|
-
onLayout,
|
|
1702
|
-
children,
|
|
1703
|
-
}: Pick<GlassSurfaceProps, 'variant' | 'surfaceRole' | 'style' | 'contentStyle' | 'animatedStyle' | 'fallbackAnimatedStyle' | 'pointerEvents' | 'onLayout' | 'children'>) {
|
|
1704
|
-
const runtime = useContext(GlassRuntimeContext);
|
|
1705
|
-
if (!runtime?.tokens.enabled) return <Animated.View onLayout={onLayout} style={[style, animatedStyle, fallbackAnimatedStyle]}><View style={contentStyle}>{children}</View></Animated.View>;
|
|
1706
|
-
const { tokens, dark } = runtime;
|
|
1707
|
-
const material: GlassMaterialTokens = tokens.materials[variant ?? 'surface'];
|
|
1708
|
-
const fallback = tokens.quality === 'fallback';
|
|
1709
|
-
return (
|
|
1710
|
-
<Animated.View
|
|
1711
|
-
pointerEvents={pointerEvents}
|
|
1712
|
-
onLayout={onLayout}
|
|
1713
|
-
style={[styles.localSurface, { borderRadius: material.radius, backgroundColor: 'transparent' }, style, animatedStyle, fallbackAnimatedStyle]}
|
|
1714
|
-
>
|
|
1715
|
-
{fallback ? (
|
|
1716
|
-
<View
|
|
1717
|
-
pointerEvents="none"
|
|
1718
|
-
style={[
|
|
1719
|
-
StyleSheet.absoluteFill,
|
|
1720
|
-
{
|
|
1721
|
-
backgroundColor: dark ? tokens.fallbackTint.dark : tokens.fallbackTint.light,
|
|
1722
|
-
borderColor: dark ? tokens.fallbackBorder.dark : tokens.fallbackBorder.light,
|
|
1723
|
-
borderWidth: StyleSheet.hairlineWidth,
|
|
1724
|
-
borderRadius: material.radius,
|
|
1725
|
-
},
|
|
1726
|
-
]}
|
|
1727
|
-
/>
|
|
1728
|
-
) : (
|
|
1729
|
-
<LocalGlassMaterial tokens={tokens} material={material} dark={dark} surfaceRole={surfaceRole} />
|
|
1730
|
-
)}
|
|
1731
|
-
<View style={[styles.localContent, contentStyle]}>{children}</View>
|
|
1732
|
-
</Animated.View>
|
|
1733
|
-
);
|
|
1734
|
-
}
|
|
1735
|
-
|
|
1736
622
|
export function useGlassProviderId() {
|
|
1737
623
|
return useContext(GlassHostContext)?.providerId ?? null;
|
|
1738
624
|
}
|
|
@@ -1759,28 +645,32 @@ export function GlassOverlay({ children, zIndex = 100 }: { children: React.React
|
|
|
1759
645
|
return null;
|
|
1760
646
|
}
|
|
1761
647
|
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
}
|
|
648
|
+
export type { GlassRuntime } from './surface/types';
|
|
649
|
+
|
|
650
|
+
export { GlassPortalScrollScope } from './surface/contexts';
|
|
651
|
+
|
|
652
|
+
export { GlassRouteTransitionScope } from './surface/contexts';
|
|
653
|
+
|
|
654
|
+
export { useGlassReducedMotion } from './surface/contexts';
|
|
655
|
+
|
|
656
|
+
export { useGlassInsideScroll } from './surface/contexts';
|
|
657
|
+
|
|
658
|
+
export { useGlassInsideCaptureScope } from './surface/contexts';
|
|
659
|
+
|
|
660
|
+
export { useGlassAppearance } from './surface/contexts';
|
|
661
|
+
|
|
662
|
+
export { useGlassSamplingProviderId } from './surface/contexts';
|
|
663
|
+
|
|
664
|
+
export type { GlassSamplingSource } from './surface/types';
|
|
665
|
+
|
|
666
|
+
export { RouteGlassCaptureScope } from './surface/contexts';
|
|
667
|
+
|
|
668
|
+
export { RouteGlassCaptureSource } from './surface/contexts';
|
|
669
|
+
|
|
670
|
+
export type { GlassMaterialProviderProps } from './surface/MaterialProvider';
|
|
671
|
+
|
|
672
|
+
export type { GlassAppearanceProviderProps } from './surface/MaterialProvider';
|
|
673
|
+
|
|
674
|
+
export { GlassAppearanceProvider } from './surface/MaterialProvider';
|
|
675
|
+
|
|
676
|
+
export { GlassMaterialProvider } from './surface/MaterialProvider';
|