@luckylca/react-native-liquid-glass 0.0.0-stage → 0.2.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.
Files changed (674) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +307 -2
  3. package/README.zh-CN.md +310 -0
  4. package/THIRD_PARTY_NOTICES.md +98 -0
  5. package/android/build.gradle +19 -0
  6. package/android/src/main/AndroidManifest.xml +1 -0
  7. package/android/src/main/java/expo/modules/localglass/ExpoLocalGlassEngineModule.kt +141 -0
  8. package/android/src/main/java/expo/modules/localglass/ExpoLocalGlassModule.kt +341 -0
  9. package/android/src/main/java/expo/modules/localglass/LocalGlassShader.kt +59 -0
  10. package/android/src/main/java/expo/modules/newhuliquidglass/CoreLiquidGlassRegistry.kt +75 -0
  11. package/android/src/main/java/expo/modules/newhuliquidglass/EffectiveScrollInputBridge.kt +47 -0
  12. package/android/src/main/java/expo/modules/newhuliquidglass/ExpoGlassCoreModule.kt +226 -0
  13. package/android/src/main/java/expo/modules/newhuliquidglass/ExpoGlassProviderCoreView.kt +1125 -0
  14. package/android/src/main/java/expo/modules/newhuliquidglass/ExpoGlassSurfaceCoreView.kt +571 -0
  15. package/android/src/main/java/expo/modules/newhuliquidglass/PassSurfaceSuppression.kt +39 -0
  16. package/android/src/main/java/expo/modules/newhuliquidglass/SharedGlassPassProbeLog.kt +23 -0
  17. package/android/src/main/java/expo/modules/newhuliquidglass/SharedGlassPassWiring.kt +59 -0
  18. package/android-core/build.gradle +36 -0
  19. package/android-core/src/main/java/com/newhu/liquidglass/backdrop/BackdropRecorder.kt +930 -0
  20. package/android-core/src/main/java/com/newhu/liquidglass/backdrop/FrozenBackdrop.kt +66 -0
  21. package/android-core/src/main/java/com/newhu/liquidglass/backdrop/GlassBackdropCoordinator.kt +624 -0
  22. package/android-core/src/main/java/com/newhu/liquidglass/backdrop/GlassBackdropSourceHandle.kt +8 -0
  23. package/android-core/src/main/java/com/newhu/liquidglass/backdrop/GlassScrollSource.kt +13 -0
  24. package/android-core/src/main/java/com/newhu/liquidglass/backdrop/GlassViewController.kt +1605 -0
  25. package/android-core/src/main/java/com/newhu/liquidglass/backdrop/LiquidGlassProviderLayout.kt +340 -0
  26. package/android-core/src/main/java/com/newhu/liquidglass/backdrop/LiquidGlassView.kt +103 -0
  27. package/android-core/src/main/java/com/newhu/liquidglass/backdrop/ReferenceSourceWindowPolicy.kt +13 -0
  28. package/android-core/src/main/java/com/newhu/liquidglass/backdrop/StableSceneTexturePolicy.kt +43 -0
  29. package/android-core/src/main/java/com/newhu/liquidglass/backdrop/internal/GlassViewRenderer.kt +1459 -0
  30. package/android-core/src/main/java/com/newhu/liquidglass/backdrop/internal/ReferenceTabSampling.kt +15 -0
  31. package/android-core/src/main/java/com/newhu/liquidglass/backdrop/internal/SharedSceneCapture.kt +163 -0
  32. package/android-core/src/main/java/com/newhu/liquidglass/core/GlassCapabilities.kt +21 -0
  33. package/android-core/src/main/java/com/newhu/liquidglass/core/GlassEngine.kt +131 -0
  34. package/android-core/src/main/java/com/newhu/liquidglass/core/GlassMaterial.kt +89 -0
  35. package/android-core/src/main/java/com/newhu/liquidglass/core/GlassMath.kt +131 -0
  36. package/android-core/src/main/java/com/newhu/liquidglass/core/GlassOpticalInsets.kt +8 -0
  37. package/android-core/src/main/java/com/newhu/liquidglass/core/GlassRenderTier.kt +54 -0
  38. package/android-core/src/main/java/com/newhu/liquidglass/core/GlassShapePacker.kt +77 -0
  39. package/android-core/src/main/java/com/newhu/liquidglass/core/GlassSurfaceState.kt +11 -0
  40. package/android-core/src/main/java/com/newhu/liquidglass/core/GlassUniforms.kt +113 -0
  41. package/android-core/src/main/java/com/newhu/liquidglass/core/LiquidGlassShaders.kt +234 -0
  42. package/android-core/src/main/java/com/newhu/liquidglass/core/SharedGlassPass.kt +456 -0
  43. package/android-core/src/main/java/com/newhu/liquidglass/core/geometry/G2RoundedRectangle.kt +207 -0
  44. package/android-core/src/main/java/com/newhu/liquidglass/core/geometry/ReferenceG2MaskTexture.kt +334 -0
  45. package/android-core/src/main/java/com/newhu/liquidglass/core/shader/HeightFieldGlassShader.kt +7 -0
  46. package/android-core/src/main/java/com/newhu/liquidglass/core/shader/ReferenceBackdropBlurShader.kt +58 -0
  47. package/android-core/src/main/java/com/newhu/liquidglass/core/shader/ReferenceGaussianDiscBackdropBlur.kt +42 -0
  48. package/android-core/src/main/java/com/newhu/liquidglass/core/shader/ReferenceGlassUniforms.kt +111 -0
  49. package/android-core/src/main/java/com/newhu/liquidglass/core/shader/ReferenceParityGlassShader.kt +613 -0
  50. package/android-core/src/main/java/com/newhu/liquidglass/core/shader/ReferenceParityMultiShapeShader.kt +128 -0
  51. package/android-core/src/main/java/com/newhu/liquidglass/core/shader/SdfScaleLensShader.kt +144 -0
  52. package/android-core/src/main/java/com/newhu/liquidglass/local/LocalGlassHardwareLayerExperiment.kt +29 -0
  53. package/android-core/src/main/java/com/newhu/liquidglass/local/LocalGlassMaterial.kt +14 -0
  54. package/android-core/src/main/java/com/newhu/liquidglass/local/LocalGlassRenderer.kt +126 -0
  55. package/android-core/src/main/java/com/newhu/liquidglass/local/LocalGlassRuntimeShader.kt +50 -0
  56. package/android-core/src/main/java/com/newhu/liquidglass/local/LocalGlassShader.kt +59 -0
  57. package/android-core/src/main/java/com/newhu/liquidglass/local/LocalGlassView.kt +47 -0
  58. package/android-core/src/main/java/com/newhu/liquidglass/motion/GlassMotionDriver.kt +824 -0
  59. package/android-core/src/main/java/com/newhu/liquidglass/motion/GlassMotionState.kt +359 -0
  60. package/android-core/src/main/java/com/newhu/liquidglass/motion/PointerVelocityTracker.kt +109 -0
  61. package/android-core/src/main/java/com/newhu/liquidglass/motion/SpringSpec.kt +209 -0
  62. package/android-core/src/main/java/com/newhu/liquidglass/optics/G2Corner.kt +194 -0
  63. package/android-core/src/main/java/com/newhu/liquidglass/optics/GlassMaterial.kt +250 -0
  64. package/android-core/src/main/java/com/newhu/liquidglass/optics/GlassOpticsShader.kt +696 -0
  65. package/android-core/src/main/java/com/newhu/liquidglass/optics/GlassParityProbe.kt +342 -0
  66. package/android-core/src/main/java/com/newhu/liquidglass/optics/GlassShapeGeometry.kt +317 -0
  67. package/android-core/src/main/java/com/newhu/liquidglass/optics/GlassUniformBinder.kt +308 -0
  68. package/android-core/src/main/java/com/newhu/liquidglass/optics/PixelDiff.kt +363 -0
  69. package/android-core/src/main/java/com/newhu/liquidglass/optics/ReferenceOptics.kt +568 -0
  70. package/android-core/src/main/java/com/newhu/liquidglass/rendering/GlassEngineSelection.kt +30 -0
  71. package/android-core/src/main/java/com/newhu/liquidglass/rendering/GlassSurfaceHost.kt +317 -0
  72. package/android-core/src/main/java/com/newhu/liquidglass/rendering/GlassSurfaceRenderer.kt +847 -0
  73. package/android-core/src/main/java/com/newhu/liquidglass/rendering/RetainedBackdropLayer.kt +83 -0
  74. package/android-core/src/main/java/com/newhu/liquidglass/scheduler/GlassFrameScheduler.kt +27 -0
  75. package/android-core/src/main/java/com/newhu/liquidglass/telemetry/EffectiveScrollFpsProbe.kt +965 -0
  76. package/android-core/src/main/java/com/newhu/liquidglass/telemetry/GlassTelemetry.kt +16 -0
  77. package/android-core/src/main/java/com/newhu/liquidglass/telemetry/LiquidGlassPerfTelemetry.kt +676 -0
  78. package/android-core/src/main/java/com/newhu/liquidglass/telemetry/LiquidGlassTrace.kt +30 -0
  79. package/android-core/src/main/java/com/newhu/liquidglass/telemetry/LocalGlassTelemetry.kt +55 -0
  80. package/app.plugin.js +25 -0
  81. package/docs/images/buttons.webp +0 -0
  82. package/docs/images/controls.webp +0 -0
  83. package/docs/images/tabs.webp +0 -0
  84. package/docs/publishing.md +84 -0
  85. package/expo-module.config.json +10 -0
  86. package/lib/commonjs/GlassSurface.js +832 -0
  87. package/lib/commonjs/GlassSurface.js.map +1 -0
  88. package/lib/commonjs/GlassTabBar.js +976 -0
  89. package/lib/commonjs/GlassTabBar.js.map +1 -0
  90. package/lib/commonjs/GlassTabLens.js +67 -0
  91. package/lib/commonjs/GlassTabLens.js.map +1 -0
  92. package/lib/commonjs/LiquidGlassProvider.js +40 -0
  93. package/lib/commonjs/LiquidGlassProvider.js.map +1 -0
  94. package/lib/commonjs/LocalGlassMaterial.js +194 -0
  95. package/lib/commonjs/LocalGlassMaterial.js.map +1 -0
  96. package/lib/commonjs/adaptiveLuminance.js +14 -0
  97. package/lib/commonjs/adaptiveLuminance.js.map +1 -0
  98. package/lib/commonjs/badgePalette.js +46 -0
  99. package/lib/commonjs/badgePalette.js.map +1 -0
  100. package/lib/commonjs/buttonGesturePolicy.js +22 -0
  101. package/lib/commonjs/buttonGesturePolicy.js.map +1 -0
  102. package/lib/commonjs/components/AdaptiveLuminance.js +20 -0
  103. package/lib/commonjs/components/AdaptiveLuminance.js.map +1 -0
  104. package/lib/commonjs/components/BottomSheet.js +222 -0
  105. package/lib/commonjs/components/BottomSheet.js.map +1 -0
  106. package/lib/commonjs/components/Button.js +20 -0
  107. package/lib/commonjs/components/Button.js.map +1 -0
  108. package/lib/commonjs/components/Card.js +206 -0
  109. package/lib/commonjs/components/Card.js.map +1 -0
  110. package/lib/commonjs/components/Checkbox.js +123 -0
  111. package/lib/commonjs/components/Checkbox.js.map +1 -0
  112. package/lib/commonjs/components/ControlPressContext.js +8 -0
  113. package/lib/commonjs/components/ControlPressContext.js.map +1 -0
  114. package/lib/commonjs/components/Dialog.js +122 -0
  115. package/lib/commonjs/components/Dialog.js.map +1 -0
  116. package/lib/commonjs/components/DialogAction.js +124 -0
  117. package/lib/commonjs/components/DialogAction.js.map +1 -0
  118. package/lib/commonjs/components/DialogContent.js +23 -0
  119. package/lib/commonjs/components/DialogContent.js.map +1 -0
  120. package/lib/commonjs/components/GlassButton.js +96 -0
  121. package/lib/commonjs/components/GlassButton.js.map +1 -0
  122. package/lib/commonjs/components/GlassFab.js +43 -0
  123. package/lib/commonjs/components/GlassFab.js.map +1 -0
  124. package/lib/commonjs/components/GlassMagnifier.js +135 -0
  125. package/lib/commonjs/components/GlassMagnifier.js.map +1 -0
  126. package/lib/commonjs/components/GlassPlayground.js +158 -0
  127. package/lib/commonjs/components/GlassPlayground.js.map +1 -0
  128. package/lib/commonjs/components/GlassSlider.js +364 -0
  129. package/lib/commonjs/components/GlassSlider.js.map +1 -0
  130. package/lib/commonjs/components/GlassSwitch.js +334 -0
  131. package/lib/commonjs/components/GlassSwitch.js.map +1 -0
  132. package/lib/commonjs/components/GlassTabBar.js +387 -0
  133. package/lib/commonjs/components/GlassTabBar.js.map +1 -0
  134. package/lib/commonjs/components/Input.js +180 -0
  135. package/lib/commonjs/components/Input.js.map +1 -0
  136. package/lib/commonjs/components/ListRow.js +64 -0
  137. package/lib/commonjs/components/ListRow.js.map +1 -0
  138. package/lib/commonjs/components/Menu.js +214 -0
  139. package/lib/commonjs/components/Menu.js.map +1 -0
  140. package/lib/commonjs/components/NavigationBar.js +20 -0
  141. package/lib/commonjs/components/NavigationBar.js.map +1 -0
  142. package/lib/commonjs/components/NumberWheel.js +273 -0
  143. package/lib/commonjs/components/NumberWheel.js.map +1 -0
  144. package/lib/commonjs/components/PageFeedList.js +25 -0
  145. package/lib/commonjs/components/PageFeedList.js.map +1 -0
  146. package/lib/commonjs/components/PageScaffold.js +161 -0
  147. package/lib/commonjs/components/PageScaffold.js.map +1 -0
  148. package/lib/commonjs/components/PreferenceGroup.js +34 -0
  149. package/lib/commonjs/components/PreferenceGroup.js.map +1 -0
  150. package/lib/commonjs/components/ProgressIndicator.js +79 -0
  151. package/lib/commonjs/components/ProgressIndicator.js.map +1 -0
  152. package/lib/commonjs/components/ProgressiveBlur.js +29 -0
  153. package/lib/commonjs/components/ProgressiveBlur.js.map +1 -0
  154. package/lib/commonjs/components/ReferenceSlider.js +304 -0
  155. package/lib/commonjs/components/ReferenceSlider.js.map +1 -0
  156. package/lib/commonjs/components/ReferenceTabBar.js +381 -0
  157. package/lib/commonjs/components/ReferenceTabBar.js.map +1 -0
  158. package/lib/commonjs/components/SearchBar.js +200 -0
  159. package/lib/commonjs/components/SearchBar.js.map +1 -0
  160. package/lib/commonjs/components/SegmentedControl.js +62 -0
  161. package/lib/commonjs/components/SegmentedControl.js.map +1 -0
  162. package/lib/commonjs/components/Slider.js +12 -0
  163. package/lib/commonjs/components/Slider.js.map +1 -0
  164. package/lib/commonjs/components/Snackbar.js +11 -0
  165. package/lib/commonjs/components/Snackbar.js.map +1 -0
  166. package/lib/commonjs/components/SurfaceEnvironmentContext.js +35 -0
  167. package/lib/commonjs/components/SurfaceEnvironmentContext.js.map +1 -0
  168. package/lib/commonjs/components/SurfaceGroup.js +39 -0
  169. package/lib/commonjs/components/SurfaceGroup.js.map +1 -0
  170. package/lib/commonjs/components/Switch.js +11 -0
  171. package/lib/commonjs/components/Switch.js.map +1 -0
  172. package/lib/commonjs/components/Toast.js +110 -0
  173. package/lib/commonjs/components/Toast.js.map +1 -0
  174. package/lib/commonjs/components/TopAppBar.js +107 -0
  175. package/lib/commonjs/components/TopAppBar.js.map +1 -0
  176. package/lib/commonjs/components/bottomSheetMotion.js +14 -0
  177. package/lib/commonjs/components/bottomSheetMotion.js.map +1 -0
  178. package/lib/commonjs/components/glassControlMaterial.js +22 -0
  179. package/lib/commonjs/components/glassControlMaterial.js.map +1 -0
  180. package/lib/commonjs/components/menuPosition.js +42 -0
  181. package/lib/commonjs/components/menuPosition.js.map +1 -0
  182. package/lib/commonjs/components/pages/FeedPage.js +15 -0
  183. package/lib/commonjs/components/pages/FeedPage.js.map +1 -0
  184. package/lib/commonjs/components/pages/PageBenchmarkContext.js +123 -0
  185. package/lib/commonjs/components/pages/PageBenchmarkContext.js.map +1 -0
  186. package/lib/commonjs/components/pages/SettingsPage.js +47 -0
  187. package/lib/commonjs/components/pages/SettingsPage.js.map +1 -0
  188. package/lib/commonjs/components/pages/SettingsSection.js +14 -0
  189. package/lib/commonjs/components/pages/SettingsSection.js.map +1 -0
  190. package/lib/commonjs/components/pages/StaticSettingsPage.js +16 -0
  191. package/lib/commonjs/components/pages/StaticSettingsPage.js.map +1 -0
  192. package/lib/commonjs/fallbackKnobGeometry.js +19 -0
  193. package/lib/commonjs/fallbackKnobGeometry.js.map +1 -0
  194. package/lib/commonjs/glassController.js +65 -0
  195. package/lib/commonjs/glassController.js.map +1 -0
  196. package/lib/commonjs/glassNativeEngine.js +16 -0
  197. package/lib/commonjs/glassNativeEngine.js.map +1 -0
  198. package/lib/commonjs/glassRuntime.js +27 -0
  199. package/lib/commonjs/glassRuntime.js.map +1 -0
  200. package/lib/commonjs/index.js +218 -0
  201. package/lib/commonjs/index.js.map +1 -0
  202. package/lib/commonjs/inputPresentation.js +17 -0
  203. package/lib/commonjs/inputPresentation.js.map +1 -0
  204. package/lib/commonjs/localGlassTelemetry.js +113 -0
  205. package/lib/commonjs/localGlassTelemetry.js.map +1 -0
  206. package/lib/commonjs/motion/MotionProvider.js +15 -0
  207. package/lib/commonjs/motion/MotionProvider.js.map +1 -0
  208. package/lib/commonjs/motion/easings.js +71 -0
  209. package/lib/commonjs/motion/easings.js.map +1 -0
  210. package/lib/commonjs/motion/folmeSpring.js +24 -0
  211. package/lib/commonjs/motion/folmeSpring.js.map +1 -0
  212. package/lib/commonjs/motion/folmeSpringByResponse.js +22 -0
  213. package/lib/commonjs/motion/folmeSpringByResponse.js.map +1 -0
  214. package/lib/commonjs/motion/index.js +57 -0
  215. package/lib/commonjs/motion/index.js.map +1 -0
  216. package/lib/commonjs/motion/presets.js +101 -0
  217. package/lib/commonjs/motion/presets.js.map +1 -0
  218. package/lib/commonjs/nativeGlassViews.js +33 -0
  219. package/lib/commonjs/nativeGlassViews.js.map +1 -0
  220. package/lib/commonjs/performanceTelemetry.js +28 -0
  221. package/lib/commonjs/performanceTelemetry.js.map +1 -0
  222. package/lib/commonjs/pointerEventBridge.js +17 -0
  223. package/lib/commonjs/pointerEventBridge.js.map +1 -0
  224. package/lib/commonjs/pointerGeometry.js +12 -0
  225. package/lib/commonjs/pointerGeometry.js.map +1 -0
  226. package/lib/commonjs/pressVelocity.js +34 -0
  227. package/lib/commonjs/pressVelocity.js.map +1 -0
  228. package/lib/commonjs/primitives/Divider.js +32 -0
  229. package/lib/commonjs/primitives/Divider.js.map +1 -0
  230. package/lib/commonjs/primitives/Icon.js +22 -0
  231. package/lib/commonjs/primitives/Icon.js.map +1 -0
  232. package/lib/commonjs/primitives/PressIndication.js +58 -0
  233. package/lib/commonjs/primitives/PressIndication.js.map +1 -0
  234. package/lib/commonjs/primitives/Pressable.js +28 -0
  235. package/lib/commonjs/primitives/Pressable.js.map +1 -0
  236. package/lib/commonjs/primitives/PressableScale.js +64 -0
  237. package/lib/commonjs/primitives/PressableScale.js.map +1 -0
  238. package/lib/commonjs/primitives/Surface.js +122 -0
  239. package/lib/commonjs/primitives/Surface.js.map +1 -0
  240. package/lib/commonjs/primitives/Text.js +43 -0
  241. package/lib/commonjs/primitives/Text.js.map +1 -0
  242. package/lib/commonjs/primitives/index.js +18 -0
  243. package/lib/commonjs/primitives/index.js.map +1 -0
  244. package/lib/commonjs/renderer.js +58 -0
  245. package/lib/commonjs/renderer.js.map +1 -0
  246. package/lib/commonjs/sliderValue.js +28 -0
  247. package/lib/commonjs/sliderValue.js.map +1 -0
  248. package/lib/commonjs/surfaceRendererPolicy.js +32 -0
  249. package/lib/commonjs/surfaceRendererPolicy.js.map +1 -0
  250. package/lib/commonjs/theme/ThemeProvider.js +37 -0
  251. package/lib/commonjs/theme/ThemeProvider.js.map +1 -0
  252. package/lib/commonjs/theme/buildTheme.js +157 -0
  253. package/lib/commonjs/theme/buildTheme.js.map +1 -0
  254. package/lib/commonjs/theme/glassColors.js +17 -0
  255. package/lib/commonjs/theme/glassColors.js.map +1 -0
  256. package/lib/commonjs/theme/index.js +38 -0
  257. package/lib/commonjs/theme/index.js.map +1 -0
  258. package/lib/commonjs/theme/liquidGlass.js +24 -0
  259. package/lib/commonjs/theme/liquidGlass.js.map +1 -0
  260. package/lib/commonjs/theme/presentation.js +14 -0
  261. package/lib/commonjs/theme/presentation.js.map +1 -0
  262. package/lib/commonjs/theme/registry.js +17 -0
  263. package/lib/commonjs/theme/registry.js.map +1 -0
  264. package/lib/commonjs/theme/selectVariant.js +13 -0
  265. package/lib/commonjs/theme/selectVariant.js.map +1 -0
  266. package/lib/commonjs/theme/tokens.js +266 -0
  267. package/lib/commonjs/theme/tokens.js.map +1 -0
  268. package/lib/commonjs/theme/types.js +3 -0
  269. package/lib/commonjs/theme/types.js.map +1 -0
  270. package/lib/commonjs/theme/wallpaper.js +91 -0
  271. package/lib/commonjs/theme/wallpaper.js.map +1 -0
  272. package/lib/commonjs/types.js +3 -0
  273. package/lib/commonjs/types.js.map +1 -0
  274. package/lib/commonjs/useButtonGesture.js +135 -0
  275. package/lib/commonjs/useButtonGesture.js.map +1 -0
  276. package/lib/commonjs/useGlassKnobMotion.js +115 -0
  277. package/lib/commonjs/useGlassKnobMotion.js.map +1 -0
  278. package/lib/commonjs/useGlassPressMotion.js +147 -0
  279. package/lib/commonjs/useGlassPressMotion.js.map +1 -0
  280. package/lib/module/GlassSurface.js +782 -0
  281. package/lib/module/GlassSurface.js.map +1 -0
  282. package/lib/module/GlassTabBar.js +939 -0
  283. package/lib/module/GlassTabBar.js.map +1 -0
  284. package/lib/module/GlassTabLens.js +64 -0
  285. package/lib/module/GlassTabLens.js.map +1 -0
  286. package/lib/module/LiquidGlassProvider.js +37 -0
  287. package/lib/module/LiquidGlassProvider.js.map +1 -0
  288. package/lib/module/LocalGlassMaterial.js +191 -0
  289. package/lib/module/LocalGlassMaterial.js.map +1 -0
  290. package/lib/module/adaptiveLuminance.js +11 -0
  291. package/lib/module/adaptiveLuminance.js.map +1 -0
  292. package/lib/module/badgePalette.js +40 -0
  293. package/lib/module/badgePalette.js.map +1 -0
  294. package/lib/module/buttonGesturePolicy.js +17 -0
  295. package/lib/module/buttonGesturePolicy.js.map +1 -0
  296. package/lib/module/components/AdaptiveLuminance.js +16 -0
  297. package/lib/module/components/AdaptiveLuminance.js.map +1 -0
  298. package/lib/module/components/BottomSheet.js +186 -0
  299. package/lib/module/components/BottomSheet.js.map +1 -0
  300. package/lib/module/components/Button.js +17 -0
  301. package/lib/module/components/Button.js.map +1 -0
  302. package/lib/module/components/Card.js +170 -0
  303. package/lib/module/components/Card.js.map +1 -0
  304. package/lib/module/components/Checkbox.js +84 -0
  305. package/lib/module/components/Checkbox.js.map +1 -0
  306. package/lib/module/components/ControlPressContext.js +4 -0
  307. package/lib/module/components/ControlPressContext.js.map +1 -0
  308. package/lib/module/components/Dialog.js +86 -0
  309. package/lib/module/components/Dialog.js.map +1 -0
  310. package/lib/module/components/DialogAction.js +88 -0
  311. package/lib/module/components/DialogAction.js.map +1 -0
  312. package/lib/module/components/DialogContent.js +20 -0
  313. package/lib/module/components/DialogContent.js.map +1 -0
  314. package/lib/module/components/GlassButton.js +93 -0
  315. package/lib/module/components/GlassButton.js.map +1 -0
  316. package/lib/module/components/GlassFab.js +37 -0
  317. package/lib/module/components/GlassFab.js.map +1 -0
  318. package/lib/module/components/GlassMagnifier.js +99 -0
  319. package/lib/module/components/GlassMagnifier.js.map +1 -0
  320. package/lib/module/components/GlassPlayground.js +122 -0
  321. package/lib/module/components/GlassPlayground.js.map +1 -0
  322. package/lib/module/components/GlassSlider.js +328 -0
  323. package/lib/module/components/GlassSlider.js.map +1 -0
  324. package/lib/module/components/GlassSwitch.js +298 -0
  325. package/lib/module/components/GlassSwitch.js.map +1 -0
  326. package/lib/module/components/GlassTabBar.js +351 -0
  327. package/lib/module/components/GlassTabBar.js.map +1 -0
  328. package/lib/module/components/Input.js +144 -0
  329. package/lib/module/components/Input.js.map +1 -0
  330. package/lib/module/components/ListRow.js +61 -0
  331. package/lib/module/components/ListRow.js.map +1 -0
  332. package/lib/module/components/Menu.js +178 -0
  333. package/lib/module/components/Menu.js.map +1 -0
  334. package/lib/module/components/NavigationBar.js +14 -0
  335. package/lib/module/components/NavigationBar.js.map +1 -0
  336. package/lib/module/components/NumberWheel.js +238 -0
  337. package/lib/module/components/NumberWheel.js.map +1 -0
  338. package/lib/module/components/PageFeedList.js +19 -0
  339. package/lib/module/components/PageFeedList.js.map +1 -0
  340. package/lib/module/components/PageScaffold.js +114 -0
  341. package/lib/module/components/PageScaffold.js.map +1 -0
  342. package/lib/module/components/PreferenceGroup.js +28 -0
  343. package/lib/module/components/PreferenceGroup.js.map +1 -0
  344. package/lib/module/components/ProgressIndicator.js +44 -0
  345. package/lib/module/components/ProgressIndicator.js.map +1 -0
  346. package/lib/module/components/ProgressiveBlur.js +26 -0
  347. package/lib/module/components/ProgressiveBlur.js.map +1 -0
  348. package/lib/module/components/ReferenceSlider.js +268 -0
  349. package/lib/module/components/ReferenceSlider.js.map +1 -0
  350. package/lib/module/components/ReferenceTabBar.js +344 -0
  351. package/lib/module/components/ReferenceTabBar.js.map +1 -0
  352. package/lib/module/components/SearchBar.js +164 -0
  353. package/lib/module/components/SearchBar.js.map +1 -0
  354. package/lib/module/components/SegmentedControl.js +26 -0
  355. package/lib/module/components/SegmentedControl.js.map +1 -0
  356. package/lib/module/components/Slider.js +9 -0
  357. package/lib/module/components/Slider.js.map +1 -0
  358. package/lib/module/components/Snackbar.js +8 -0
  359. package/lib/module/components/Snackbar.js.map +1 -0
  360. package/lib/module/components/SurfaceEnvironmentContext.js +27 -0
  361. package/lib/module/components/SurfaceEnvironmentContext.js.map +1 -0
  362. package/lib/module/components/SurfaceGroup.js +33 -0
  363. package/lib/module/components/SurfaceGroup.js.map +1 -0
  364. package/lib/module/components/Switch.js +8 -0
  365. package/lib/module/components/Switch.js.map +1 -0
  366. package/lib/module/components/Toast.js +74 -0
  367. package/lib/module/components/Toast.js.map +1 -0
  368. package/lib/module/components/TopAppBar.js +68 -0
  369. package/lib/module/components/TopAppBar.js.map +1 -0
  370. package/lib/module/components/bottomSheetMotion.js +11 -0
  371. package/lib/module/components/bottomSheetMotion.js.map +1 -0
  372. package/lib/module/components/glassControlMaterial.js +19 -0
  373. package/lib/module/components/glassControlMaterial.js.map +1 -0
  374. package/lib/module/components/menuPosition.js +37 -0
  375. package/lib/module/components/menuPosition.js.map +1 -0
  376. package/lib/module/components/pages/FeedPage.js +12 -0
  377. package/lib/module/components/pages/FeedPage.js.map +1 -0
  378. package/lib/module/components/pages/PageBenchmarkContext.js +84 -0
  379. package/lib/module/components/pages/PageBenchmarkContext.js.map +1 -0
  380. package/lib/module/components/pages/SettingsPage.js +11 -0
  381. package/lib/module/components/pages/SettingsPage.js.map +1 -0
  382. package/lib/module/components/pages/SettingsSection.js +8 -0
  383. package/lib/module/components/pages/SettingsSection.js.map +1 -0
  384. package/lib/module/components/pages/StaticSettingsPage.js +10 -0
  385. package/lib/module/components/pages/StaticSettingsPage.js.map +1 -0
  386. package/lib/module/fallbackKnobGeometry.js +16 -0
  387. package/lib/module/fallbackKnobGeometry.js.map +1 -0
  388. package/lib/module/glassController.js +58 -0
  389. package/lib/module/glassController.js.map +1 -0
  390. package/lib/module/glassNativeEngine.js +11 -0
  391. package/lib/module/glassNativeEngine.js.map +1 -0
  392. package/lib/module/glassRuntime.js +22 -0
  393. package/lib/module/glassRuntime.js.map +1 -0
  394. package/lib/module/index.js +80 -0
  395. package/lib/module/index.js.map +1 -0
  396. package/lib/module/inputPresentation.js +14 -0
  397. package/lib/module/inputPresentation.js.map +1 -0
  398. package/lib/module/localGlassTelemetry.js +103 -0
  399. package/lib/module/localGlassTelemetry.js.map +1 -0
  400. package/lib/module/motion/MotionProvider.js +11 -0
  401. package/lib/module/motion/MotionProvider.js.map +1 -0
  402. package/lib/module/motion/easings.js +64 -0
  403. package/lib/module/motion/easings.js.map +1 -0
  404. package/lib/module/motion/folmeSpring.js +21 -0
  405. package/lib/module/motion/folmeSpring.js.map +1 -0
  406. package/lib/module/motion/folmeSpringByResponse.js +19 -0
  407. package/lib/module/motion/folmeSpringByResponse.js.map +1 -0
  408. package/lib/module/motion/index.js +6 -0
  409. package/lib/module/motion/index.js.map +1 -0
  410. package/lib/module/motion/presets.js +98 -0
  411. package/lib/module/motion/presets.js.map +1 -0
  412. package/lib/module/nativeGlassViews.js +27 -0
  413. package/lib/module/nativeGlassViews.js.map +1 -0
  414. package/lib/module/package.json +1 -0
  415. package/lib/module/performanceTelemetry.js +23 -0
  416. package/lib/module/performanceTelemetry.js.map +1 -0
  417. package/lib/module/pointerEventBridge.js +14 -0
  418. package/lib/module/pointerEventBridge.js.map +1 -0
  419. package/lib/module/pointerGeometry.js +9 -0
  420. package/lib/module/pointerGeometry.js.map +1 -0
  421. package/lib/module/pressVelocity.js +31 -0
  422. package/lib/module/pressVelocity.js.map +1 -0
  423. package/lib/module/primitives/Divider.js +29 -0
  424. package/lib/module/primitives/Divider.js.map +1 -0
  425. package/lib/module/primitives/Icon.js +19 -0
  426. package/lib/module/primitives/Icon.js.map +1 -0
  427. package/lib/module/primitives/PressIndication.js +22 -0
  428. package/lib/module/primitives/PressIndication.js.map +1 -0
  429. package/lib/module/primitives/Pressable.js +25 -0
  430. package/lib/module/primitives/Pressable.js.map +1 -0
  431. package/lib/module/primitives/PressableScale.js +28 -0
  432. package/lib/module/primitives/PressableScale.js.map +1 -0
  433. package/lib/module/primitives/Surface.js +83 -0
  434. package/lib/module/primitives/Surface.js.map +1 -0
  435. package/lib/module/primitives/Text.js +40 -0
  436. package/lib/module/primitives/Text.js.map +1 -0
  437. package/lib/module/primitives/index.js +8 -0
  438. package/lib/module/primitives/index.js.map +1 -0
  439. package/lib/module/renderer.js +22 -0
  440. package/lib/module/renderer.js.map +1 -0
  441. package/lib/module/sliderValue.js +25 -0
  442. package/lib/module/sliderValue.js.map +1 -0
  443. package/lib/module/surfaceRendererPolicy.js +27 -0
  444. package/lib/module/surfaceRendererPolicy.js.map +1 -0
  445. package/lib/module/theme/ThemeProvider.js +32 -0
  446. package/lib/module/theme/ThemeProvider.js.map +1 -0
  447. package/lib/module/theme/buildTheme.js +153 -0
  448. package/lib/module/theme/buildTheme.js.map +1 -0
  449. package/lib/module/theme/glassColors.js +14 -0
  450. package/lib/module/theme/glassColors.js.map +1 -0
  451. package/lib/module/theme/index.js +9 -0
  452. package/lib/module/theme/index.js.map +1 -0
  453. package/lib/module/theme/liquidGlass.js +21 -0
  454. package/lib/module/theme/liquidGlass.js.map +1 -0
  455. package/lib/module/theme/presentation.js +11 -0
  456. package/lib/module/theme/presentation.js.map +1 -0
  457. package/lib/module/theme/registry.js +13 -0
  458. package/lib/module/theme/registry.js.map +1 -0
  459. package/lib/module/theme/selectVariant.js +10 -0
  460. package/lib/module/theme/selectVariant.js.map +1 -0
  461. package/lib/module/theme/tokens.js +262 -0
  462. package/lib/module/theme/tokens.js.map +1 -0
  463. package/lib/module/theme/types.js +2 -0
  464. package/lib/module/theme/types.js.map +1 -0
  465. package/lib/module/theme/wallpaper.js +83 -0
  466. package/lib/module/theme/wallpaper.js.map +1 -0
  467. package/lib/module/types.js +2 -0
  468. package/lib/module/types.js.map +1 -0
  469. package/lib/module/useButtonGesture.js +132 -0
  470. package/lib/module/useButtonGesture.js.map +1 -0
  471. package/lib/module/useGlassKnobMotion.js +112 -0
  472. package/lib/module/useGlassKnobMotion.js.map +1 -0
  473. package/lib/module/useGlassPressMotion.js +143 -0
  474. package/lib/module/useGlassPressMotion.js.map +1 -0
  475. package/lib/types/GlassSurface.d.ts +216 -0
  476. package/lib/types/GlassTabBar.d.ts +35 -0
  477. package/lib/types/GlassTabLens.d.ts +11 -0
  478. package/lib/types/LiquidGlassProvider.d.ts +47 -0
  479. package/lib/types/LocalGlassMaterial.d.ts +21 -0
  480. package/lib/types/adaptiveLuminance.d.ts +2 -0
  481. package/lib/types/badgePalette.d.ts +9 -0
  482. package/lib/types/buttonGesturePolicy.d.ts +4 -0
  483. package/lib/types/components/AdaptiveLuminance.d.ts +23 -0
  484. package/lib/types/components/BottomSheet.d.ts +33 -0
  485. package/lib/types/components/Button.d.ts +16 -0
  486. package/lib/types/components/Card.d.ts +25 -0
  487. package/lib/types/components/Checkbox.d.ts +11 -0
  488. package/lib/types/components/ControlPressContext.d.ts +9 -0
  489. package/lib/types/components/Dialog.d.ts +12 -0
  490. package/lib/types/components/DialogAction.d.ts +4 -0
  491. package/lib/types/components/DialogContent.d.ts +12 -0
  492. package/lib/types/components/GlassButton.d.ts +38 -0
  493. package/lib/types/components/GlassFab.d.ts +15 -0
  494. package/lib/types/components/GlassMagnifier.d.ts +41 -0
  495. package/lib/types/components/GlassPlayground.d.ts +12 -0
  496. package/lib/types/components/GlassSlider.d.ts +48 -0
  497. package/lib/types/components/GlassSwitch.d.ts +46 -0
  498. package/lib/types/components/GlassTabBar.d.ts +44 -0
  499. package/lib/types/components/Input.d.ts +47 -0
  500. package/lib/types/components/ListRow.d.ts +17 -0
  501. package/lib/types/components/Menu.d.ts +41 -0
  502. package/lib/types/components/NavigationBar.d.ts +14 -0
  503. package/lib/types/components/NumberWheel.d.ts +11 -0
  504. package/lib/types/components/PageFeedList.d.ts +6 -0
  505. package/lib/types/components/PageScaffold.d.ts +64 -0
  506. package/lib/types/components/PreferenceGroup.d.ts +12 -0
  507. package/lib/types/components/ProgressIndicator.d.ts +9 -0
  508. package/lib/types/components/ProgressiveBlur.d.ts +12 -0
  509. package/lib/types/components/ReferenceSlider.d.ts +31 -0
  510. package/lib/types/components/ReferenceTabBar.d.ts +61 -0
  511. package/lib/types/components/SearchBar.d.ts +52 -0
  512. package/lib/types/components/SegmentedControl.d.ts +10 -0
  513. package/lib/types/components/Slider.d.ts +19 -0
  514. package/lib/types/components/Snackbar.d.ts +5 -0
  515. package/lib/types/components/SurfaceEnvironmentContext.d.ts +17 -0
  516. package/lib/types/components/SurfaceGroup.d.ts +17 -0
  517. package/lib/types/components/Switch.d.ts +12 -0
  518. package/lib/types/components/Toast.d.ts +14 -0
  519. package/lib/types/components/TopAppBar.d.ts +49 -0
  520. package/lib/types/components/bottomSheetMotion.d.ts +2 -0
  521. package/lib/types/components/glassControlMaterial.d.ts +3 -0
  522. package/lib/types/components/menuPosition.d.ts +22 -0
  523. package/lib/types/components/pages/FeedPage.d.ts +31 -0
  524. package/lib/types/components/pages/PageBenchmarkContext.d.ts +30 -0
  525. package/lib/types/components/pages/SettingsPage.d.ts +20 -0
  526. package/lib/types/components/pages/SettingsSection.d.ts +9 -0
  527. package/lib/types/components/pages/StaticSettingsPage.d.ts +18 -0
  528. package/lib/types/fallbackKnobGeometry.d.ts +7 -0
  529. package/lib/types/glassController.d.ts +20 -0
  530. package/lib/types/glassNativeEngine.d.ts +5 -0
  531. package/lib/types/glassRuntime.d.ts +7 -0
  532. package/lib/types/index.d.ts +124 -0
  533. package/lib/types/inputPresentation.d.ts +12 -0
  534. package/lib/types/localGlassTelemetry.d.ts +28 -0
  535. package/lib/types/motion/MotionProvider.d.ts +7 -0
  536. package/lib/types/motion/easings.d.ts +33 -0
  537. package/lib/types/motion/folmeSpring.d.ts +15 -0
  538. package/lib/types/motion/folmeSpringByResponse.d.ts +14 -0
  539. package/lib/types/motion/index.d.ts +7 -0
  540. package/lib/types/motion/presets.d.ts +103 -0
  541. package/lib/types/nativeGlassViews.d.ts +114 -0
  542. package/lib/types/performanceTelemetry.d.ts +65 -0
  543. package/lib/types/pointerEventBridge.d.ts +17 -0
  544. package/lib/types/pointerGeometry.d.ts +2 -0
  545. package/lib/types/pressVelocity.d.ts +11 -0
  546. package/lib/types/primitives/Divider.d.ts +19 -0
  547. package/lib/types/primitives/Icon.d.ts +29 -0
  548. package/lib/types/primitives/PressIndication.d.ts +26 -0
  549. package/lib/types/primitives/Pressable.d.ts +9 -0
  550. package/lib/types/primitives/PressableScale.d.ts +19 -0
  551. package/lib/types/primitives/Surface.d.ts +63 -0
  552. package/lib/types/primitives/Text.d.ts +35 -0
  553. package/lib/types/primitives/index.d.ts +14 -0
  554. package/lib/types/renderer.d.ts +32 -0
  555. package/lib/types/sliderValue.d.ts +2 -0
  556. package/lib/types/surfaceRendererPolicy.d.ts +14 -0
  557. package/lib/types/theme/ThemeProvider.d.ts +26 -0
  558. package/lib/types/theme/buildTheme.d.ts +6 -0
  559. package/lib/types/theme/glassColors.d.ts +13 -0
  560. package/lib/types/theme/index.d.ts +11 -0
  561. package/lib/types/theme/liquidGlass.d.ts +5 -0
  562. package/lib/types/theme/presentation.d.ts +3 -0
  563. package/lib/types/theme/registry.d.ts +7 -0
  564. package/lib/types/theme/selectVariant.d.ts +10 -0
  565. package/lib/types/theme/tokens.d.ts +18 -0
  566. package/lib/types/theme/types.d.ts +305 -0
  567. package/lib/types/theme/wallpaper.d.ts +32 -0
  568. package/lib/types/types.d.ts +127 -0
  569. package/lib/types/useButtonGesture.d.ts +30 -0
  570. package/lib/types/useGlassKnobMotion.d.ts +40 -0
  571. package/lib/types/useGlassPressMotion.d.ts +61 -0
  572. package/licenses/Apache-2.0-Kyant0-Shapes.txt +191 -0
  573. package/package.json +139 -4
  574. package/patches/liquid-glass-kit+1.0.0.patch +2015 -0
  575. package/patches/liquid-glass-kit-invalidation-coalescing.diff +249 -0
  576. package/patches/liquid-glass-kit-native-infra.diff +624 -0
  577. package/scripts/apply-legacy-patches.mjs +116 -0
  578. package/src/GlassSurface.tsx +1786 -0
  579. package/src/GlassTabBar.tsx +1304 -0
  580. package/src/GlassTabLens.tsx +92 -0
  581. package/src/LiquidGlassProvider.tsx +135 -0
  582. package/src/LocalGlassMaterial.tsx +262 -0
  583. package/src/adaptiveLuminance.ts +15 -0
  584. package/src/badgePalette.ts +54 -0
  585. package/src/buttonGesturePolicy.ts +15 -0
  586. package/src/components/AdaptiveLuminance.tsx +40 -0
  587. package/src/components/BottomSheet.tsx +291 -0
  588. package/src/components/Button.tsx +30 -0
  589. package/src/components/Card.tsx +343 -0
  590. package/src/components/Checkbox.tsx +141 -0
  591. package/src/components/ControlPressContext.ts +11 -0
  592. package/src/components/Dialog.tsx +129 -0
  593. package/src/components/DialogAction.tsx +109 -0
  594. package/src/components/DialogContent.tsx +52 -0
  595. package/src/components/GlassButton.tsx +225 -0
  596. package/src/components/GlassFab.tsx +98 -0
  597. package/src/components/GlassMagnifier.tsx +178 -0
  598. package/src/components/GlassPlayground.tsx +190 -0
  599. package/src/components/GlassSlider.tsx +448 -0
  600. package/src/components/GlassSwitch.tsx +391 -0
  601. package/src/components/GlassTabBar.tsx +522 -0
  602. package/src/components/Input.tsx +277 -0
  603. package/src/components/ListRow.tsx +124 -0
  604. package/src/components/Menu.tsx +322 -0
  605. package/src/components/NavigationBar.tsx +27 -0
  606. package/src/components/NumberWheel.tsx +344 -0
  607. package/src/components/PageFeedList.tsx +37 -0
  608. package/src/components/PageScaffold.tsx +266 -0
  609. package/src/components/PreferenceGroup.tsx +65 -0
  610. package/src/components/ProgressIndicator.tsx +63 -0
  611. package/src/components/ProgressiveBlur.tsx +56 -0
  612. package/src/components/ReferenceSlider.tsx +364 -0
  613. package/src/components/ReferenceTabBar.tsx +564 -0
  614. package/src/components/SearchBar.tsx +340 -0
  615. package/src/components/SegmentedControl.tsx +45 -0
  616. package/src/components/Slider.tsx +25 -0
  617. package/src/components/Snackbar.tsx +10 -0
  618. package/src/components/SurfaceEnvironmentContext.tsx +46 -0
  619. package/src/components/SurfaceGroup.tsx +60 -0
  620. package/src/components/Switch.tsx +18 -0
  621. package/src/components/Toast.tsx +110 -0
  622. package/src/components/TopAppBar.tsx +272 -0
  623. package/src/components/bottomSheetMotion.ts +10 -0
  624. package/src/components/glassControlMaterial.ts +20 -0
  625. package/src/components/menuPosition.ts +58 -0
  626. package/src/components/pages/FeedPage.tsx +96 -0
  627. package/src/components/pages/PageBenchmarkContext.tsx +105 -0
  628. package/src/components/pages/SettingsPage.tsx +55 -0
  629. package/src/components/pages/SettingsSection.tsx +20 -0
  630. package/src/components/pages/StaticSettingsPage.tsx +50 -0
  631. package/src/fallbackKnobGeometry.ts +15 -0
  632. package/src/glassController.ts +74 -0
  633. package/src/glassNativeEngine.ts +16 -0
  634. package/src/glassRuntime.ts +28 -0
  635. package/src/index.ts +199 -0
  636. package/src/inputPresentation.ts +32 -0
  637. package/src/localGlassTelemetry.ts +138 -0
  638. package/src/motion/MotionProvider.tsx +12 -0
  639. package/src/motion/easings.ts +71 -0
  640. package/src/motion/folmeSpring.ts +22 -0
  641. package/src/motion/folmeSpringByResponse.ts +19 -0
  642. package/src/motion/index.ts +47 -0
  643. package/src/motion/presets.ts +128 -0
  644. package/src/nativeGlassViews.ts +147 -0
  645. package/src/performanceTelemetry.ts +95 -0
  646. package/src/pointerEventBridge.ts +27 -0
  647. package/src/pointerGeometry.ts +8 -0
  648. package/src/pressVelocity.ts +36 -0
  649. package/src/primitives/Divider.tsx +42 -0
  650. package/src/primitives/Icon.tsx +44 -0
  651. package/src/primitives/PressIndication.tsx +43 -0
  652. package/src/primitives/Pressable.tsx +75 -0
  653. package/src/primitives/PressableScale.tsx +50 -0
  654. package/src/primitives/Surface.tsx +171 -0
  655. package/src/primitives/Text.tsx +80 -0
  656. package/src/primitives/index.ts +14 -0
  657. package/src/renderer.ts +70 -0
  658. package/src/sliderValue.ts +19 -0
  659. package/src/surfaceRendererPolicy.ts +32 -0
  660. package/src/theme/ThemeProvider.tsx +52 -0
  661. package/src/theme/buildTheme.ts +160 -0
  662. package/src/theme/glassColors.ts +13 -0
  663. package/src/theme/index.ts +34 -0
  664. package/src/theme/liquidGlass.ts +25 -0
  665. package/src/theme/presentation.ts +12 -0
  666. package/src/theme/registry.ts +16 -0
  667. package/src/theme/selectVariant.ts +12 -0
  668. package/src/theme/tokens.ts +309 -0
  669. package/src/theme/types.ts +345 -0
  670. package/src/theme/wallpaper.ts +94 -0
  671. package/src/types.ts +95 -0
  672. package/src/useButtonGesture.ts +134 -0
  673. package/src/useGlassKnobMotion.ts +155 -0
  674. package/src/useGlassPressMotion.ts +209 -0
@@ -0,0 +1,1786 @@
1
+ import React, { createContext, useCallback, useContext, useEffect, useId, useMemo, useRef, useState, useSyncExternalStore } from 'react';
2
+ import { findNodeHandle, Platform, StyleSheet, View } from 'react-native';
3
+ import type { ColorValue, LayoutChangeEvent, StyleProp, ViewProps, ViewStyle } from 'react-native';
4
+ import Animated, { useAnimatedProps, useAnimatedStyle } from 'react-native-reanimated';
5
+ import type { AnimatedStyle, SharedValue } from 'react-native-reanimated';
6
+ import { LocalGlassMaterial } from './LocalGlassMaterial';
7
+ import type { GlassSurfaceRole } from './surfaceRendererPolicy';
8
+ import { getGlassNativeEngine, subscribeGlassNativeEngine } from './glassNativeEngine';
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';
14
+ import type { GlassPointerEventSink, GlassValueEventSink } from './pointerEventBridge';
15
+
16
+ type NativeBackdropSurfaceProps = NativeGlassSurfaceProps & {
17
+ /** Direct high-frequency event channel; consumed here and never sent as a native prop. */
18
+ pointerEventSink?: GlassPointerEventSink;
19
+ /** Direct high-frequency knob channel; consumed here and never sent as a native prop. */
20
+ valueEventSink?: GlassValueEventSink;
21
+ animatedProps?: Partial<Pick<NativeGlassSurfaceProps, 'interactionProgress' | 'interactionPointX' | 'interactionPointY' | 'interactionVelocityX' | 'interactionVelocityY' | 'motionX' | 'motionY' | 'toggleFraction'>>;
22
+ };
23
+
24
+ const AnimatedLegacyGlassSurfaceView = Animated.createAnimatedComponent(LegacyGlassSurfaceView) as unknown as React.ComponentType<NativeBackdropSurfaceProps>;
25
+ const AnimatedCoreGlassSurfaceView = CoreGlassSurfaceView
26
+ ? Animated.createAnimatedComponent(CoreGlassSurfaceView) as unknown as React.ComponentType<NativeBackdropSurfaceProps & React.RefAttributes<View>>
27
+ : null;
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
+ });
1072
+
1073
+ export interface GlassSurfaceProps {
1074
+ variant?: GlassVariant;
1075
+ /** Surface purpose used by the shared local renderer policy. */
1076
+ surfaceRole?: GlassSurfaceRole;
1077
+ /** Semantic placement role. The parent owns actual layout and coordinates. */
1078
+ positioning?: 'inFlow' | 'floating';
1079
+ /** Optical sampling source. Backdrop sampling is explicitly opt-in. */
1080
+ sampling?: 'local' | 'backdrop';
1081
+ /** Select live route content for bars or the stable ThemeBackdrop for sheets. */
1082
+ samplingSource?: GlassSamplingSource;
1083
+ /** Optional per-surface hue tint, separate from the material surface-color overlay. */
1084
+ tintColor?: ColorValue;
1085
+ /** Content drawn above a portaled glass body, such as a control label. */
1086
+ portalContent?: React.ReactNode;
1087
+ /** Touch/accessibility content hosted above the glass portal's native view. */
1088
+ portalInteractionContent?: React.ReactNode;
1089
+ /**
1090
+ * `aboveGlass` keeps the children out of the scene the glass samples, so a
1091
+ * content-bearing surface refracts what is behind it instead of its own text.
1092
+ * The surface must then size itself; children no longer drive its height.
1093
+ */
1094
+ contentPlacement?: 'inFlow' | 'aboveGlass';
1095
+ /** Passive layout placeholder for stateful content mounted above the glass. */
1096
+ measurementContent?: React.ReactNode;
1097
+ /** Draw the optical backing in place beneath its ordinary route children. */
1098
+ inlineBackdrop?: boolean;
1099
+ /** Keep intrinsic content height for inline backdrops with no fixed parent height. */
1100
+ intrinsicInlineBackdrop?: boolean;
1101
+ /** @deprecated Use sampling; kept for source compatibility. */
1102
+ renderMode?: 'local' | 'backdrop';
1103
+ pointerEvents?: ViewProps['pointerEvents'];
1104
+ interactive?: boolean;
1105
+ /** Request fresh backdrop frames while this surface is mounted. */
1106
+ continuous?: boolean;
1107
+ /** Sample the provider's shared recording instead of a per-consumer crop. */
1108
+ sharedSource?: boolean;
1109
+ /** Experimental: capture the provider scene to a texture once per frame. */
1110
+ captureProbe?: boolean;
1111
+ /** UI-thread optical morph shared with native AGSL uniforms. */
1112
+ opticalProgress?: SharedValue<number>;
1113
+ /** Pointer event stream for the native motion driver; it owns the spring. */
1114
+ pointerEvent?: SharedValue<string>;
1115
+ /** The same stream as plain state; this is what the native prop receives. */
1116
+ pointerEventValue?: string;
1117
+ /** Direct native path for pointer samples that should not rerender portal surfaces. */
1118
+ pointerEventSink?: GlassPointerEventSink;
1119
+ /** Knob value stream for value-driven lenses; see useGlassKnobMotion. */
1120
+ valueEvent?: string;
1121
+ /** Direct native path for knob values that should not rerender portal surfaces. */
1122
+ valueEventSink?: GlassValueEventSink;
1123
+ /** Live thumb fraction for CombinedBackdrop controls such as Toggle. */
1124
+ opticalToggleFraction?: SharedValue<number>;
1125
+ /** Controlled static progress for deterministic reference snapshots. */
1126
+ opticalProgressValue?: number;
1127
+ /** UI-thread pointer location in local dp for the reference press highlight. */
1128
+ opticalPointX?: SharedValue<number>;
1129
+ opticalPointY?: SharedValue<number>;
1130
+ /** UI-thread pointer velocity in local dp/s for the reference release spring. */
1131
+ opticalVelocityX?: SharedValue<number>;
1132
+ opticalVelocityY?: SharedValue<number>;
1133
+ /** UI-thread horizontal velocity in dp/s, forwarded without React renders. */
1134
+ opticalMotionX?: SharedValue<number>;
1135
+ /** UI-thread vertical velocity in dp/s, forwarded without React renders. */
1136
+ opticalMotionY?: SharedValue<number>;
1137
+ /** UI-thread motion applied only when the procedural local renderer is used. */
1138
+ fallbackAnimatedStyle?: AnimatedStyle<ViewStyle>;
1139
+ /** Native material overrides, primarily used by the optical debug screen. */
1140
+ materialOverrides?: Partial<GlassMaterialTokens>;
1141
+ /** Text silhouette sampled as an SDF mask for custom glass lettering (Android core). */
1142
+ shapeMaskText?: string;
1143
+ shapeMaskFontSize?: number;
1144
+ shapeMaskFontWeight?: number;
1145
+ /** Alpha-mask reference blur from opaque at the top to clear at the bottom. */
1146
+ progressiveBlurIntensity?: number;
1147
+ /** Show only the re-sampled backdrop, with tint and lighting removed. */
1148
+ displacementOnlyDebug?: boolean;
1149
+ /** Mirror native interaction transforms onto non-glass sibling foreground content. */
1150
+ syncContentTransform?: boolean;
1151
+ /** Explicitly sample a specific native backdrop provider (e.g. a parent underlay behind a nested capture source). */
1152
+ providerIdOverride?: string | null;
1153
+ style?: StyleProp<ViewStyle>;
1154
+ contentStyle?: StyleProp<ViewStyle>;
1155
+ /** Observe the measured surface bounds without replacing portal measurement. */
1156
+ onLayout?: ViewProps['onLayout'];
1157
+ animatedStyle?: AnimatedStyle<ViewStyle>;
1158
+ /** UI-thread translation for the portaled backing, independent of its measured frame. */
1159
+ portalTranslateX?: SharedValue<number>;
1160
+ /** UI-thread vertical translation for both the portaled lens and its hit target. */
1161
+ portalTranslateY?: SharedValue<number>;
1162
+ /** UI-thread horizontal scale for the portaled backing, independent of layout measurement. */
1163
+ portalScaleX?: SharedValue<number>;
1164
+ /** UI-thread vertical scale for the portaled backing, independent of layout measurement. */
1165
+ portalScaleY?: SharedValue<number>;
1166
+ placement?: 'layout' | 'bottom' | 'center';
1167
+ bottomInset?: number;
1168
+ zIndex?: number;
1169
+ /**
1170
+ * Explicit surface rect in window coordinates.
1171
+ *
1172
+ * `measureInWindow` is not reliable for a view that lives inside the
1173
+ * floating glass overlay on Fabric: the tab bar shell measured itself at
1174
+ * (16,169)dp while the bar sat at the bottom of the screen, which put an
1175
+ * empty 344x55dp glass panel under the search bar and robbed the bar of its
1176
+ * own shell. Callers that already know their geometry pass it here instead.
1177
+ */
1178
+ frameOverride?: { x: number; y: number; width: number; height: number } | null;
1179
+ placeholderChildren?: React.ReactNode;
1180
+ children?: React.ReactNode;
1181
+ }
1182
+
1183
+ /** Theme-driven glass material. Callers select a role; all optical settings live in AppTheme. */
1184
+ export const GlassSurface = React.memo(function GlassSurface({
1185
+ variant = 'surface',
1186
+ surfaceRole = 'staticGroup',
1187
+ positioning,
1188
+ sampling,
1189
+ samplingSource,
1190
+ tintColor,
1191
+ portalContent,
1192
+ portalInteractionContent,
1193
+ contentPlacement = 'inFlow',
1194
+ measurementContent,
1195
+ inlineBackdrop,
1196
+ intrinsicInlineBackdrop = false,
1197
+ renderMode,
1198
+ pointerEvents,
1199
+ interactive = false,
1200
+ continuous = false,
1201
+ sharedSource = false,
1202
+ captureProbe = false,
1203
+ opticalProgress,
1204
+ pointerEvent,
1205
+ pointerEventValue,
1206
+ pointerEventSink,
1207
+ valueEvent,
1208
+ valueEventSink,
1209
+ opticalToggleFraction,
1210
+ opticalProgressValue,
1211
+ opticalPointX,
1212
+ opticalPointY,
1213
+ opticalVelocityX,
1214
+ opticalVelocityY,
1215
+ opticalMotionX,
1216
+ opticalMotionY,
1217
+ fallbackAnimatedStyle,
1218
+ materialOverrides,
1219
+ shapeMaskText,
1220
+ shapeMaskFontSize = 0,
1221
+ shapeMaskFontWeight = 700,
1222
+ progressiveBlurIntensity = 0,
1223
+ displacementOnlyDebug = false,
1224
+ syncContentTransform = false,
1225
+ providerIdOverride = null,
1226
+ style,
1227
+ contentStyle,
1228
+ onLayout: onLayoutProp,
1229
+ animatedStyle,
1230
+ portalTranslateX,
1231
+ portalTranslateY,
1232
+ portalScaleX,
1233
+ portalScaleY,
1234
+ placement = 'layout',
1235
+ bottomInset,
1236
+ zIndex = 1,
1237
+ children,
1238
+ frameOverride,
1239
+ }: GlassSurfaceProps) {
1240
+ const runtime = useContext(GlassRuntimeContext);
1241
+ const host = useContext(GlassHostContext);
1242
+ const captureSourceProviderId = useContext(GlassCaptureSourceContext);
1243
+ const scopeActive = useContext(GlassScopeActiveContext);
1244
+ const routeTransitionX = useContext(GlassRouteTransitionContext);
1245
+ const portalScroll = useContext(GlassPortalScrollContext);
1246
+ const measureOnly = useContext(GlassMeasureOnlyContext);
1247
+ const hasPortalMotion = portalTranslateX != null || portalTranslateY != null || portalScaleX != null || portalScaleY != null;
1248
+ const portalOffsetStyle = useAnimatedStyle(() => ({
1249
+ transform: [
1250
+ ...(portalTranslateX ? [{ translateX: portalTranslateX.value }] : []),
1251
+ ...(portalTranslateY ? [{ translateY: portalTranslateY.value }] : []),
1252
+ ...(portalScaleX ? [{ scaleX: portalScaleX.value }] : []),
1253
+ ...(portalScaleY ? [{ scaleY: portalScaleY.value }] : []),
1254
+ ],
1255
+ }), [portalTranslateX, portalTranslateY, portalScaleX, portalScaleY]);
1256
+ const resolvedPositioning = positioning ?? (renderMode === 'backdrop' ? 'floating' : 'inFlow');
1257
+ const themeMaterial = runtime?.tokens.materials[variant];
1258
+ const referenceParity = themeMaterial?.opticsModel === 'referenceParity';
1259
+ // Sampling and optics are independent. An explicit `sampling` prop always wins;
1260
+ // opticsModel only supplies the default for surfaces that never expressed a
1261
+ // preference. Before 2026-11-15 a referenceParity material silently promoted
1262
+ // every local surface into a real backdrop consumer, which overrode Hyper UI's
1263
+ // `sampling="local"` cards and made the local strategy unreachable.
1264
+ const resolvedSampling = sampling ?? (renderMode ?? (referenceParity
1265
+ ? 'backdrop'
1266
+ : resolvedPositioning === 'floating' ? 'backdrop' : 'local'));
1267
+ const resolvedSamplingSource = samplingSource ?? host?.defaultSamplingSource ?? 'routeScene';
1268
+ const resolvedSamplingProviderId = providerIdOverride != null
1269
+ ? providerIdOverride
1270
+ : resolvedSamplingSource === 'themeBackdrop'
1271
+ ? host?.themeBackdropProviderId
1272
+ : captureSourceProviderId ?? host?.routeSceneProviderId ?? host?.themeBackdropProviderId;
1273
+ // A routeScene provider records route content. Keep its consumers outside
1274
+ // that source tree or the RenderNode can sample itself recursively.
1275
+ // Inline rendering remains valid when it samples the separate theme
1276
+ // backdrop provider (including the routeScene fallback without a scope)
1277
+ // or an explicit parent/underlay providerIdOverride outside the inner capture scope.
1278
+ const samplesOwnCaptureSource = captureSourceProviderId !== null && (
1279
+ providerIdOverride != null
1280
+ ? providerIdOverride === captureSourceProviderId
1281
+ : resolvedSamplingSource === 'routeScene'
1282
+ );
1283
+ // With a separate `backdrop` the route tree is already a sibling above the
1284
+ // capture source, so an in-flow surface can sample it directly through the
1285
+ // inline path. That removes the per-surface measureInWindow bridge round
1286
+ // trips, the portal re-render and the duplicate hidden measure tree.
1287
+ const flatSurfaceStyle = StyleSheet.flatten(style) as { height?: unknown } | undefined;
1288
+ const autoInlineBackdrop = inlineBackdrop === undefined &&
1289
+ host?.hasSeparateBackdrop === true &&
1290
+ !samplesOwnCaptureSource &&
1291
+ resolvedPositioning === 'inFlow' &&
1292
+ placement === 'layout' &&
1293
+ portalContent == null &&
1294
+ portalInteractionContent == null &&
1295
+ frameOverride == null &&
1296
+ zIndex <= 1 &&
1297
+ !hasPortalMotion;
1298
+ const resolvedInlineBackdrop = (inlineBackdrop ?? (autoInlineBackdrop || host?.inlineBackdropByDefault === true)) &&
1299
+ !samplesOwnCaptureSource;
1300
+ const resolvedIntrinsicInlineBackdrop = intrinsicInlineBackdrop ||
1301
+ (autoInlineBackdrop && typeof flatSurfaceStyle?.height !== 'number');
1302
+ const contentAboveGlass = contentPlacement === 'aboveGlass' && resolvedSampling === 'backdrop';
1303
+ const resolvedRenderMode = runtime?.tokens.enabled && resolvedSampling === 'backdrop' && Platform.OS === 'android' && host && runtime.tokens.quality !== 'fallback'
1304
+ ? 'backdrop'
1305
+ : 'local';
1306
+ const id = useId();
1307
+ const viewRef = useRef<View>(null);
1308
+ const [frame, setFrame] = useState<SurfaceFrame | null>(null);
1309
+
1310
+ const measure = useCallback(() => {
1311
+ if (resolvedInlineBackdrop) return;
1312
+ const view = viewRef.current;
1313
+ const hostNode = host?.hostRef.current;
1314
+ if (!view || !hostNode) return;
1315
+ if (findNodeHandle(view) == null || findNodeHandle(hostNode) == null) return;
1316
+
1317
+ // Native-stack/Fabric can place a route view in a different native
1318
+ // branch from the app-level glass host. measureLayout requires a true
1319
+ // native ancestor and silently loses the surface when that is false.
1320
+ // Same-window coordinates work across those branches and map directly
1321
+ // to the full-screen sibling overlay.
1322
+ view.measureInWindow((viewX, viewY, width, height) => {
1323
+ hostNode.measureInWindow((hostX, hostY) => {
1324
+ // measureInWindow includes the route container's transform.
1325
+ // Keep the registered base frame untransformed, then apply that
1326
+ // same shared value to the host-level glass overlay below.
1327
+ const scrollOffsetY = portalScroll.offsets.reduce((offset, value) => offset + value.value, 0);
1328
+ const next = {
1329
+ x: viewX - hostX - (routeTransitionX?.value ?? 0),
1330
+ y: viewY - hostY + scrollOffsetY,
1331
+ width,
1332
+ height,
1333
+ };
1334
+ setFrame((current) => current && current.x === next.x && current.y === next.y && current.width === width && current.height === height
1335
+ ? current
1336
+ : next);
1337
+ });
1338
+ });
1339
+ }, [host, portalScroll.offsets, routeTransitionX, resolvedInlineBackdrop]);
1340
+
1341
+ const onLayout = useCallback((event: LayoutChangeEvent) => {
1342
+ measure();
1343
+ onLayoutProp?.(event);
1344
+ }, [measure, onLayoutProp]);
1345
+
1346
+ useEffect(() => {
1347
+ measure();
1348
+ }, [measure, portalScroll.layoutRevision]);
1349
+
1350
+ useEffect(() => () => host?.remove(id), [host, id]);
1351
+
1352
+ useEffect(() => {
1353
+ if (!host) return;
1354
+ if (measureOnly || !scopeActive || !runtime?.tokens.enabled || resolvedRenderMode !== 'backdrop' || resolvedInlineBackdrop || !frame || frame.width <= 0 || frame.height <= 0) {
1355
+ host.remove(id);
1356
+ return;
1357
+ }
1358
+ const publishedFrame = frameOverride
1359
+ ? { x: frameOverride.x, y: frameOverride.y, width: frameOverride.width, height: frameOverride.height }
1360
+ : frame;
1361
+ host.updateSurface(id, {
1362
+ frame: publishedFrame,
1363
+ positioning: resolvedPositioning,
1364
+ samplingSource: resolvedSamplingSource,
1365
+ captureProbe,
1366
+ samplingProviderId: resolvedSamplingProviderId ?? host.themeBackdropProviderId,
1367
+ tintColor,
1368
+ portalContent,
1369
+ contentAboveGlass: contentAboveGlass && resolvedRenderMode === 'backdrop' && !resolvedInlineBackdrop,
1370
+ sharedSource,
1371
+ content: contentAboveGlass ? children : undefined,
1372
+ contentStyle: contentAboveGlass ? contentStyle : undefined,
1373
+ variant,
1374
+ interactive,
1375
+ continuous,
1376
+ opticalProgress,
1377
+ scrollGroupKey: portalScroll.offsets.length > 0 ? portalScroll.groupKey : '',
1378
+ scrollOffsets: portalScroll.offsets,
1379
+ routeTransitionX,
1380
+ portalOffsetStyle: hasPortalMotion ? portalOffsetStyle : undefined,
1381
+ portalTranslateX,
1382
+ portalTranslateY,
1383
+ portalScaleX,
1384
+ portalScaleY,
1385
+ pointerEvent,
1386
+ pointerEventValue,
1387
+ pointerEventSink,
1388
+ valueEvent,
1389
+ valueEventSink,
1390
+ opticalToggleFraction,
1391
+ opticalProgressValue,
1392
+ opticalPointX,
1393
+ opticalPointY,
1394
+ opticalVelocityX,
1395
+ opticalVelocityY,
1396
+ opticalMotionX,
1397
+ opticalMotionY,
1398
+ materialOverrides,
1399
+ shapeMaskText,
1400
+ shapeMaskFontSize,
1401
+ shapeMaskFontWeight,
1402
+ progressiveBlurIntensity,
1403
+ displacementOnlyDebug,
1404
+ syncContentTransform,
1405
+ animatedStyle,
1406
+ placement,
1407
+ bottomInset,
1408
+ zIndex,
1409
+ });
1410
+ if (portalInteractionContent) {
1411
+ host.updateOverlay(id, {
1412
+ children: portalInteractionContent,
1413
+ frame: publishedFrame,
1414
+ scrollOffsets: portalScroll.offsets.length > 0 ? portalScroll.offsets : undefined,
1415
+ routeTransitionX,
1416
+ portalOffsetStyle: hasPortalMotion ? portalOffsetStyle : undefined,
1417
+ zIndex: 10000 + zIndex,
1418
+ });
1419
+ } else {
1420
+ host.removeOverlay(id);
1421
+ }
1422
+ }, [measureOnly, scopeActive, runtime?.tokens.enabled, resolvedRenderMode, resolvedInlineBackdrop, host, id, frame, frameOverride, resolvedPositioning, resolvedSamplingSource, resolvedSamplingProviderId, tintColor, portalContent, portalInteractionContent, contentAboveGlass, children, variant, interactive, continuous, sharedSource, captureProbe, opticalProgress, routeTransitionX, portalScroll.offsets, portalScroll.groupKey, hasPortalMotion, portalOffsetStyle, portalTranslateX, portalTranslateY, portalScaleX, portalScaleY, pointerEvent, pointerEventValue, pointerEventSink, valueEvent, valueEventSink, opticalToggleFraction, opticalProgressValue, opticalPointX, opticalPointY, opticalVelocityX, opticalVelocityY, opticalMotionX, opticalMotionY, materialOverrides, shapeMaskText, shapeMaskFontSize, shapeMaskFontWeight, progressiveBlurIntensity, displacementOnlyDebug, syncContentTransform, animatedStyle, placement, bottomInset, zIndex]);
1423
+
1424
+ if (measureOnly) {
1425
+ return (
1426
+ <View pointerEvents="none" style={style}>
1427
+ <View style={resolvedInlineBackdrop ? (resolvedIntrinsicInlineBackdrop ? styles.inlineBackdropIntrinsicSurface : styles.inlineBackdropSurface) : undefined}>
1428
+ <View style={[contentAboveGlass || resolvedIntrinsicInlineBackdrop ? styles.portalContentIntrinsic : placement === 'layout' ? styles.portalContentLayout : styles.portalContentWrap, contentStyle]}>
1429
+ {children}
1430
+ </View>
1431
+ </View>
1432
+ </View>
1433
+ );
1434
+ }
1435
+
1436
+ if (!runtime?.tokens.enabled) {
1437
+ return <Animated.View style={[style, animatedStyle, hasPortalMotion ? portalOffsetStyle : undefined, fallbackAnimatedStyle]}><View style={contentStyle}>{children}</View></Animated.View>;
1438
+ }
1439
+
1440
+ // Keep inline renderers and their foreground subtrees mounted across page
1441
+ // activation. Replacing this branch with LocalGlassSurface rebuilt text,
1442
+ // gestures and native renderers on every tab selection. Hidden native
1443
+ // lenses are INVISIBLE; portaled surfaces still unpublish below so another
1444
+ // page can never paint a hidden page's pill.
1445
+ // The inline path samples a provider id directly and needs no host, so it must
1446
+ // be checked before the host guard. Ordered the other way, a provider that
1447
+ // supplies no backdrop recorder could never reach its own inline material:
1448
+ // every surface fell through to the local renderer and no native view, no
1449
+ // motion driver and no press animation was ever created.
1450
+ if (resolvedInlineBackdrop) {
1451
+ return (
1452
+ <Animated.View pointerEvents={pointerEvents} onLayout={onLayoutProp} style={[style, animatedStyle, hasPortalMotion ? portalOffsetStyle : undefined]}>
1453
+ <InlineBackdropSurface
1454
+ renderingEnabled={scopeActive}
1455
+ providerId={resolvedSamplingProviderId ?? ''}
1456
+ variant={variant}
1457
+ tintColor={tintColor}
1458
+ interactive={interactive}
1459
+ continuous={continuous}
1460
+ sharedSource={sharedSource}
1461
+ captureProbe={captureProbe}
1462
+ opticalProgress={opticalProgress}
1463
+ pointerEvent={pointerEvent}
1464
+ pointerEventValue={pointerEventValue}
1465
+ pointerEventSink={pointerEventSink}
1466
+ valueEventSink={valueEventSink}
1467
+ valueEvent={valueEvent}
1468
+ opticalToggleFraction={opticalToggleFraction}
1469
+ opticalPointX={opticalPointX}
1470
+ opticalPointY={opticalPointY}
1471
+ opticalVelocityX={opticalVelocityX}
1472
+ opticalVelocityY={opticalVelocityY}
1473
+ opticalMotionX={opticalMotionX}
1474
+ opticalMotionY={opticalMotionY}
1475
+ materialOverrides={materialOverrides}
1476
+ displacementOnlyDebug={displacementOnlyDebug}
1477
+ syncContentTransform={syncContentTransform}
1478
+ intrinsicLayout={resolvedIntrinsicInlineBackdrop}
1479
+ contentStyle={contentStyle}
1480
+ placement={placement}
1481
+ >
1482
+ {children}
1483
+ </InlineBackdropSurface>
1484
+ </Animated.View>
1485
+ );
1486
+ }
1487
+
1488
+ if (resolvedRenderMode === 'local' || !host || !scopeActive) {
1489
+ return (
1490
+ <LocalGlassSurface
1491
+ variant={variant}
1492
+ surfaceRole={surfaceRole}
1493
+ style={style}
1494
+ contentStyle={contentStyle}
1495
+ animatedStyle={hasPortalMotion ? portalOffsetStyle : animatedStyle}
1496
+ fallbackAnimatedStyle={fallbackAnimatedStyle}
1497
+ pointerEvents={pointerEvents}
1498
+ onLayout={onLayout}
1499
+ >
1500
+ {children}
1501
+ </LocalGlassSurface>
1502
+ );
1503
+ }
1504
+
1505
+ return (
1506
+ <Animated.View
1507
+ ref={viewRef}
1508
+ collapsable={false}
1509
+ pointerEvents={pointerEvents}
1510
+ onLayout={onLayout}
1511
+ style={[style, animatedStyle, styles.measureOnly]}
1512
+ >
1513
+ <View style={[contentAboveGlass ? styles.portalContentIntrinsic : placement === 'layout' ? styles.portalContentLayout : styles.portalContentWrap, contentStyle]}>
1514
+ {contentAboveGlass ? (
1515
+ // The visible copy lives in the overlay; this one only exists
1516
+ // so a content-sized surface still measures. alpha 0 keeps it
1517
+ // out of the recorded scene, which is the whole point.
1518
+ <View
1519
+ pointerEvents="none"
1520
+ accessible={false}
1521
+ accessibilityElementsHidden
1522
+ importantForAccessibility="no-hide-descendants"
1523
+ style={[styles.contentAboveGlassMeasure, { opacity: 0 }]}
1524
+ >
1525
+ <GlassMeasureOnlyContext.Provider value={true}>
1526
+ {measurementContent ?? children}
1527
+ </GlassMeasureOnlyContext.Provider>
1528
+ </View>
1529
+ ) : children}
1530
+ </View>
1531
+ </Animated.View>
1532
+ );
1533
+ });
1534
+
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
+ export function useGlassProviderId() {
1737
+ return useContext(GlassHostContext)?.providerId ?? null;
1738
+ }
1739
+
1740
+ /** Ref for converting window-measured anchors into the route overlay's local coordinates. */
1741
+ export function useGlassOverlayHostRef() {
1742
+ return useContext(GlassHostContext)?.hostRef ?? null;
1743
+ }
1744
+
1745
+ /** Route-level view overlay for sheets/dialogs; its children remain ordinary native views. */
1746
+ export function GlassOverlay({ children, zIndex = 100 }: { children: React.ReactNode; zIndex?: number }) {
1747
+ const runtime = useContext(GlassRuntimeContext);
1748
+ const host = useContext(GlassOverlayHostContext);
1749
+ const id = useId();
1750
+
1751
+ useEffect(() => () => host?.remove(id), [host, id]);
1752
+ useEffect(() => {
1753
+ if (!host) return;
1754
+ if (runtime?.tokens.enabled) host.updateOverlay(id, { children, zIndex });
1755
+ else host.remove(id);
1756
+ }, [runtime?.tokens.enabled, host, id, children, zIndex]);
1757
+
1758
+ if (!runtime?.tokens.enabled || !host) return <>{children}</>;
1759
+ return null;
1760
+ }
1761
+
1762
+ const styles = StyleSheet.create({
1763
+ root: { flex: 1 },
1764
+ routeContent: { ...StyleSheet.flatten(StyleSheet.absoluteFill) },
1765
+ measureOnly: {},
1766
+ localSurface: { position: 'relative', overflow: 'hidden' },
1767
+ // In-flow local surfaces wrap their content by default. A default flex:1
1768
+ // makes controls inside a virtualized list header consume the viewport,
1769
+ // pushing the actual feed cells below the visible area. Callers that need
1770
+ // a filling surface opt into flex through contentStyle.
1771
+ localContent: { overflow: 'hidden' },
1772
+ portalSurface: { position: 'absolute', overflow: 'visible' },
1773
+ portalContentOverlay: { alignItems: 'center', justifyContent: 'center', overflow: 'hidden' },
1774
+ contentAboveGlass: { overflow: 'hidden' },
1775
+ contentAboveGlassMeasure: { alignSelf: 'stretch' },
1776
+ nativeSurface: { backgroundColor: 'transparent', overflow: 'hidden' },
1777
+ fallbackSurface: { backgroundColor: 'transparent', borderWidth: StyleSheet.hairlineWidth, overflow: 'hidden' },
1778
+ portalContentLayout: { flex: 1, overflow: 'hidden' },
1779
+ portalContentWrap: { flexGrow: 1, flexShrink: 1, overflow: 'hidden' },
1780
+ portalContentIntrinsic: { alignSelf: 'stretch', overflow: 'hidden' },
1781
+ captureSource: { flex: 1 },
1782
+ inlineBackdropSurface: { flex: 1 },
1783
+ inlineBackdropIntrinsicSurface: { flexGrow: 1 },
1784
+ bottomPlacement: { alignItems: 'center', justifyContent: 'flex-end' },
1785
+ centerPlacement: { alignItems: 'center', justifyContent: 'center' },
1786
+ });