glacia-native 0.5.2 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (381) hide show
  1. package/README.md +84 -17
  2. package/lib/module/Accordion.js +58 -0
  3. package/lib/module/ActionSheet.js +38 -0
  4. package/lib/module/Alert.js +23 -0
  5. package/lib/module/AlertDialog.js +47 -0
  6. package/lib/module/Avatar.js +48 -0
  7. package/lib/module/Badge.js +36 -0
  8. package/lib/module/Bars.js +13 -268
  9. package/lib/module/Button.js +57 -39
  10. package/lib/module/Card.js +31 -19
  11. package/lib/module/Checkbox.js +42 -0
  12. package/lib/module/Chip.js +80 -0
  13. package/lib/module/Collapsible.js +26 -0
  14. package/lib/module/ContextMenu.js +33 -0
  15. package/lib/module/Dialog.js +39 -123
  16. package/lib/module/DropdownMenu.js +33 -0
  17. package/lib/module/Field.js +22 -0
  18. package/lib/module/Glass.js +10 -3
  19. package/lib/module/Group.js +36 -0
  20. package/lib/module/IconButton.js +40 -0
  21. package/lib/module/Input.js +43 -38
  22. package/lib/module/Label.js +17 -0
  23. package/lib/module/MorphGroup.js +47 -0
  24. package/lib/module/Popover.js +29 -0
  25. package/lib/module/Progress.js +32 -0
  26. package/lib/module/RadioGroup.js +51 -0
  27. package/lib/module/Scrim.js +44 -0
  28. package/lib/module/SegmentedControl.js +70 -63
  29. package/lib/module/Select.js +51 -0
  30. package/lib/module/Separator.js +25 -0
  31. package/lib/module/Sheet.js +51 -0
  32. package/lib/module/Skeleton.js +48 -0
  33. package/lib/module/Slider.js +45 -34
  34. package/lib/module/Stepper.js +167 -0
  35. package/lib/module/Switch.js +45 -55
  36. package/lib/module/TabBar.js +50 -44
  37. package/lib/module/Textarea.js +18 -0
  38. package/lib/module/Toast.js +55 -0
  39. package/lib/module/Toggle.js +47 -0
  40. package/lib/module/ToggleGroup.js +56 -0
  41. package/lib/module/Toolbar.js +37 -0
  42. package/lib/module/Tooltip.js +31 -0
  43. package/lib/module/glass-provider.js +28 -0
  44. package/lib/module/glass-stack.js +61 -0
  45. package/lib/module/index.js +78 -109
  46. package/lib/module/internal/GlassBackdrop.js +36 -0
  47. package/lib/module/internal/GlassView.js +43 -11
  48. package/lib/module/internal/blur-community.js +20 -0
  49. package/lib/module/internal/blur-community.web.js +9 -0
  50. package/lib/module/internal/blur.js +6 -9
  51. package/lib/module/internal/glass-routing.js +156 -30
  52. package/lib/module/internal/initials.js +12 -0
  53. package/lib/module/internal/overlay.js +147 -0
  54. package/lib/module/internal/primitives.js +16 -0
  55. package/lib/typescript/Accordion.d.ts +22 -0
  56. package/lib/typescript/ActionSheet.d.ts +24 -0
  57. package/lib/typescript/Alert.d.ts +15 -0
  58. package/lib/typescript/AlertDialog.d.ts +17 -0
  59. package/lib/typescript/Avatar.d.ts +22 -0
  60. package/lib/typescript/Badge.d.ts +12 -0
  61. package/lib/typescript/Bars.d.ts +3 -188
  62. package/lib/typescript/Button.d.ts +44 -10
  63. package/lib/typescript/Card.d.ts +30 -3
  64. package/lib/typescript/Checkbox.d.ts +14 -0
  65. package/lib/typescript/Chip.d.ts +19 -0
  66. package/lib/typescript/Collapsible.d.ts +17 -0
  67. package/lib/typescript/ContextMenu.d.ts +23 -0
  68. package/lib/typescript/Dialog.d.ts +8 -68
  69. package/lib/typescript/DropdownMenu.d.ts +23 -0
  70. package/lib/typescript/Field.d.ts +19 -0
  71. package/lib/typescript/Glass.d.ts +11 -2
  72. package/lib/typescript/Group.d.ts +35 -0
  73. package/lib/typescript/IconButton.d.ts +21 -0
  74. package/lib/typescript/Input.d.ts +17 -18
  75. package/lib/typescript/Label.d.ts +14 -0
  76. package/lib/typescript/MorphGroup.d.ts +46 -0
  77. package/lib/typescript/Popover.d.ts +17 -0
  78. package/lib/typescript/Progress.d.ts +13 -0
  79. package/lib/typescript/RadioGroup.d.ts +21 -0
  80. package/lib/typescript/Scrim.d.ts +33 -0
  81. package/lib/typescript/SegmentedControl.d.ts +24 -13
  82. package/lib/typescript/Select.d.ts +19 -0
  83. package/lib/typescript/Separator.d.ts +10 -0
  84. package/lib/typescript/Sheet.d.ts +45 -0
  85. package/lib/typescript/Skeleton.d.ts +10 -0
  86. package/lib/typescript/Slider.d.ts +15 -7
  87. package/lib/typescript/Stepper.d.ts +49 -0
  88. package/lib/typescript/Switch.d.ts +19 -12
  89. package/lib/typescript/TabBar.d.ts +18 -6
  90. package/lib/typescript/Textarea.d.ts +6 -0
  91. package/lib/typescript/Toast.d.ts +40 -0
  92. package/lib/typescript/Toggle.d.ts +21 -0
  93. package/lib/typescript/ToggleGroup.d.ts +22 -0
  94. package/lib/typescript/Toolbar.d.ts +35 -0
  95. package/lib/typescript/Tooltip.d.ts +16 -0
  96. package/lib/typescript/glass-provider.d.ts +34 -0
  97. package/lib/typescript/glass-stack.d.ts +54 -0
  98. package/lib/typescript/index.d.ts +38 -17
  99. package/lib/typescript/internal/GlassBackdrop.d.ts +33 -0
  100. package/lib/typescript/internal/GlassView.d.ts +18 -2
  101. package/lib/typescript/internal/blur-community.d.ts +2 -0
  102. package/lib/typescript/internal/blur-community.web.d.ts +2 -0
  103. package/lib/typescript/internal/glass-routing.d.ts +83 -15
  104. package/lib/typescript/internal/initials.d.ts +2 -0
  105. package/lib/typescript/internal/overlay.d.ts +74 -0
  106. package/lib/typescript/internal/primitives.d.ts +11 -0
  107. package/package.json +12 -10
  108. package/src/Accordion.tsx +165 -0
  109. package/src/ActionSheet.tsx +149 -0
  110. package/src/Alert.tsx +85 -0
  111. package/src/AlertDialog.tsx +124 -0
  112. package/src/Avatar.tsx +102 -0
  113. package/src/Badge.tsx +80 -0
  114. package/src/Bars.tsx +10 -807
  115. package/src/Button.tsx +196 -67
  116. package/src/Card.tsx +105 -32
  117. package/src/Checkbox.tsx +98 -0
  118. package/src/Chip.tsx +149 -0
  119. package/src/Collapsible.tsx +66 -0
  120. package/src/ContextMenu.tsx +103 -0
  121. package/src/Dialog.tsx +85 -335
  122. package/src/DropdownMenu.tsx +103 -0
  123. package/src/Field.tsx +65 -0
  124. package/src/Glass.tsx +15 -5
  125. package/src/Group.tsx +98 -0
  126. package/src/IconButton.tsx +110 -0
  127. package/src/Input.tsx +139 -87
  128. package/src/Label.tsx +56 -0
  129. package/src/MorphGroup.tsx +134 -0
  130. package/src/Popover.tsx +81 -0
  131. package/src/Progress.tsx +83 -0
  132. package/src/RadioGroup.tsx +122 -0
  133. package/src/Scrim.tsx +94 -0
  134. package/src/SegmentedControl.tsx +132 -99
  135. package/src/Select.tsx +136 -0
  136. package/src/Separator.tsx +52 -0
  137. package/src/Sheet.tsx +139 -0
  138. package/src/Skeleton.tsx +77 -0
  139. package/src/Slider.tsx +84 -47
  140. package/src/Stepper.tsx +315 -0
  141. package/src/Switch.tsx +81 -73
  142. package/src/TabBar.tsx +106 -93
  143. package/src/Textarea.tsx +34 -0
  144. package/src/Toast.tsx +131 -0
  145. package/src/Toggle.tsx +113 -0
  146. package/src/ToggleGroup.tsx +129 -0
  147. package/src/Toolbar.tsx +111 -0
  148. package/src/Tooltip.tsx +79 -0
  149. package/src/engine/CHANGELOG.md +430 -0
  150. package/src/engine/NOTICE +54 -0
  151. package/src/engine/README.md +975 -0
  152. package/src/engine/android/build.gradle +18 -0
  153. package/src/engine/android/src/main/AndroidManifest.xml +2 -0
  154. package/src/engine/android/src/main/java/expo/modules/liquidglass/ExpoLiquidGlassModule.kt +174 -0
  155. package/src/engine/android/src/main/java/expo/modules/liquidglass/GlassConstants.kt +7 -0
  156. package/src/engine/android/src/main/java/expo/modules/liquidglass/LiquidGlassContainerView.kt +16 -0
  157. package/src/engine/android/src/main/java/expo/modules/liquidglass/LiquidGlassProviderView.kt +165 -0
  158. package/src/engine/android/src/main/java/expo/modules/liquidglass/LiquidGlassView.kt +1731 -0
  159. package/src/engine/android/src/main/java/expo/modules/liquidglass/enums/GlassEnums.kt +171 -0
  160. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/BackdropGraph.kt +146 -0
  161. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/BackdropSource.kt +53 -0
  162. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/ContinuousCorners.kt +188 -0
  163. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/CornerRadii.kt +62 -0
  164. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassAppearance.kt +352 -0
  165. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassDebug.kt +109 -0
  166. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassEnvironment.kt +139 -0
  167. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassHdr.kt +85 -0
  168. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassLuminanceProbe.kt +189 -0
  169. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassPressAnimator.kt +264 -0
  170. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassProgressiveBlur.kt +249 -0
  171. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassShaderCache.kt +256 -0
  172. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassShaderSource.kt +845 -0
  173. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassTier.kt +63 -0
  174. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/ProviderRegistry.kt +71 -0
  175. package/src/engine/android/src/main/java/expo/modules/liquidglass/records/GlassRecords.kt +288 -0
  176. package/src/engine/index.ts +24 -0
  177. package/src/engine/ios/Enums/GlassBlurDirection.swift +21 -0
  178. package/src/engine/ios/Enums/GlassVariant.swift +86 -0
  179. package/src/engine/ios/ExpoLiquidGlass.podspec +93 -0
  180. package/src/engine/ios/ExpoLiquidGlassModule.swift +77 -0
  181. package/src/engine/ios/Glass/BackdropCapturer.swift +811 -0
  182. package/src/engine/ios/Glass/ContinuousCorners.swift +165 -0
  183. package/src/engine/ios/Glass/GlassBackdrop.swift +176 -0
  184. package/src/engine/ios/Glass/GlassFramePhase.swift +126 -0
  185. package/src/engine/ios/Glass/GlassFrameScheduler.swift +261 -0
  186. package/src/engine/ios/Glass/GlassPressAnimator.swift +250 -0
  187. package/src/engine/ios/Glass/GlassRenderContext.swift +168 -0
  188. package/src/engine/ios/Glass/GlassRenderer.swift +186 -0
  189. package/src/engine/ios/Glass/GlassSurfaceView.swift +452 -0
  190. package/src/engine/ios/Glass/NonRenderableView.swift +54 -0
  191. package/src/engine/ios/Glass/StripCache.swift +545 -0
  192. package/src/engine/ios/Records/GlassCornerRadii.swift +79 -0
  193. package/src/engine/ios/Records/GlassMetalOptions.swift +180 -0
  194. package/src/engine/ios/Records/GlassRefractionCurve.swift +14 -0
  195. package/src/engine/ios/Shaders/LiquidGlass.metal +480 -0
  196. package/src/engine/ios/Shaders/bundle-marker.txt +6 -0
  197. package/src/engine/ios/Views/LiquidGlassContainerView.swift +99 -0
  198. package/src/engine/ios/Views/LiquidGlassView.swift +859 -0
  199. package/src/engine/package.json +70 -0
  200. package/src/engine/src/components/LiquidGlassButton/LiquidGlassButton.tsx +424 -0
  201. package/src/engine/src/components/LiquidGlassCard/LiquidGlassCard.tsx +98 -0
  202. package/src/engine/src/components/LiquidGlassChip/LiquidGlassChip.tsx +65 -0
  203. package/src/engine/src/components/LiquidGlassGroup/LiquidGlassGroup.tsx +350 -0
  204. package/src/engine/src/components/LiquidGlassIconButton/LiquidGlassIconButton.tsx +24 -0
  205. package/src/engine/src/components/LiquidGlassMorphGroup/LiquidGlassMorphGroup.tsx +434 -0
  206. package/src/engine/src/components/LiquidGlassScrim/LiquidGlassScrim.tsx +100 -0
  207. package/src/engine/src/components/LiquidGlassSegmentedControl/LiquidGlassSegmentedControl.tsx +213 -0
  208. package/src/engine/src/components/LiquidGlassSheet/LiquidGlassSheet.tsx +218 -0
  209. package/src/engine/src/components/LiquidGlassSlider/LiquidGlassSlider.tsx +327 -0
  210. package/src/engine/src/components/LiquidGlassStepper/LiquidGlassStepper.tsx +321 -0
  211. package/src/engine/src/components/LiquidGlassSwitch/LiquidGlassSwitch.tsx +296 -0
  212. package/src/engine/src/components/LiquidGlassTabBar/LiquidGlassTabBar.tsx +952 -0
  213. package/src/engine/src/components/LiquidGlassTextInput/LiquidGlassTextInput.tsx +151 -0
  214. package/src/engine/src/components/LiquidGlassToast/LiquidGlassToast.tsx +169 -0
  215. package/src/engine/src/components/LiquidGlassToolbar/LiquidGlassToolbar.tsx +124 -0
  216. package/src/engine/src/components/index.ts +16 -0
  217. package/src/engine/src/constants/index.ts +4 -0
  218. package/src/engine/src/constants/metal.constants.ts +327 -0
  219. package/src/engine/src/constants/metrics.constants.ts +325 -0
  220. package/src/engine/src/constants/springs.constants.ts +107 -0
  221. package/src/engine/src/constants/styles.constants.ts +12 -0
  222. package/src/engine/src/context/glass-group.context.ts +65 -0
  223. package/src/engine/src/context/index.ts +6 -0
  224. package/src/engine/src/core/components/LiquidGlassContainer/LiquidGlassContainer.tsx +32 -0
  225. package/src/engine/src/core/components/LiquidGlassContainer/index.ts +1 -0
  226. package/src/engine/src/core/components/LiquidGlassProvider/LiquidGlassProvider.tsx +66 -0
  227. package/src/engine/src/core/components/LiquidGlassProvider/index.ts +1 -0
  228. package/src/engine/src/core/components/LiquidGlassStack/LiquidGlassStack.tsx +184 -0
  229. package/src/engine/src/core/components/LiquidGlassStack/index.ts +1 -0
  230. package/src/engine/src/core/components/LiquidGlassView/LiquidGlassView.tsx +126 -0
  231. package/src/engine/src/core/components/LiquidGlassView/index.ts +1 -0
  232. package/src/engine/src/core/components/index.ts +4 -0
  233. package/src/engine/src/core/constants/glass.constants.ts +57 -0
  234. package/src/engine/src/core/constants/index.ts +20 -0
  235. package/src/engine/src/core/constants/native.constants.ts +16 -0
  236. package/src/engine/src/core/context/glass-stack.context.ts +30 -0
  237. package/src/engine/src/core/context/index.ts +4 -0
  238. package/src/engine/src/core/enum/index.ts +12 -0
  239. package/src/engine/src/core/index.ts +1 -0
  240. package/src/engine/src/core/interfaces/glass-hdr.interface.ts +15 -0
  241. package/src/engine/src/core/interfaces/glass-metal.interface.ts +248 -0
  242. package/src/engine/src/core/interfaces/glass-surface.interface.ts +9 -0
  243. package/src/engine/src/core/interfaces/index.ts +31 -0
  244. package/src/engine/src/core/interfaces/liquid-glass-container.interface.ts +6 -0
  245. package/src/engine/src/core/interfaces/liquid-glass-provider.interface.ts +14 -0
  246. package/src/engine/src/core/interfaces/liquid-glass-stack.interface.ts +21 -0
  247. package/src/engine/src/core/interfaces/liquid-glass-view.interface.ts +129 -0
  248. package/src/engine/src/core/interfaces/native-liquid-glass-view.interface.ts +19 -0
  249. package/src/engine/src/core/modules/ExpoLiquidGlassModule.ts +26 -0
  250. package/src/engine/src/core/modules/index.ts +2 -0
  251. package/src/engine/src/core/root/index.ts +51 -0
  252. package/src/engine/src/core/types/glass.types.ts +25 -0
  253. package/src/engine/src/core/types/index.ts +8 -0
  254. package/src/engine/src/core/utils/debug.utils.ts +17 -0
  255. package/src/engine/src/core/utils/dev-warn.utils.ts +17 -0
  256. package/src/engine/src/core/utils/hdr.utils.ts +37 -0
  257. package/src/engine/src/core/utils/index.ts +5 -0
  258. package/src/engine/src/core/utils/native-view.utils.ts +33 -0
  259. package/src/engine/src/core/utils/platform.utils.ts +34 -0
  260. package/src/engine/src/core/views/NativeGlassBackdropView.ts +24 -0
  261. package/src/engine/src/core/views/NativeLiquidGlassContainerView.ts +13 -0
  262. package/src/engine/src/core/views/NativeLiquidGlassContainerView.web.ts +10 -0
  263. package/src/engine/src/core/views/NativeLiquidGlassProviderView.ts +13 -0
  264. package/src/engine/src/core/views/NativeLiquidGlassProviderView.web.ts +10 -0
  265. package/src/engine/src/core/views/NativeLiquidGlassView.ts +19 -0
  266. package/src/engine/src/core/views/NativeLiquidGlassView.web.ts +14 -0
  267. package/src/engine/src/core/views/index.ts +4 -0
  268. package/src/engine/src/hooks/index.ts +18 -0
  269. package/src/engine/src/hooks/use-adaptive-glass.ts +91 -0
  270. package/src/engine/src/hooks/use-damped-drag.ts +332 -0
  271. package/src/engine/src/hooks/use-echo-filter.ts +55 -0
  272. package/src/engine/src/hooks/use-glass-group-member.ts +169 -0
  273. package/src/engine/src/hooks/use-gravity-highlight.ts +79 -0
  274. package/src/engine/src/hooks/use-press-progress.ts +44 -0
  275. package/src/engine/src/index.ts +120 -0
  276. package/src/engine/src/interfaces/index.ts +28 -0
  277. package/src/engine/src/interfaces/liquid-glass-button.interface.ts +94 -0
  278. package/src/engine/src/interfaces/liquid-glass-card.interface.ts +40 -0
  279. package/src/engine/src/interfaces/liquid-glass-chip.interface.ts +29 -0
  280. package/src/engine/src/interfaces/liquid-glass-group.interface.ts +32 -0
  281. package/src/engine/src/interfaces/liquid-glass-icon-button.interface.ts +19 -0
  282. package/src/engine/src/interfaces/liquid-glass-morph-group.interface.ts +59 -0
  283. package/src/engine/src/interfaces/liquid-glass-scrim.interface.ts +36 -0
  284. package/src/engine/src/interfaces/liquid-glass-segmented-control.interface.ts +32 -0
  285. package/src/engine/src/interfaces/liquid-glass-sheet.interface.ts +38 -0
  286. package/src/engine/src/interfaces/liquid-glass-slider.interface.ts +37 -0
  287. package/src/engine/src/interfaces/liquid-glass-stepper.interface.ts +35 -0
  288. package/src/engine/src/interfaces/liquid-glass-switch.interface.ts +27 -0
  289. package/src/engine/src/interfaces/liquid-glass-tab-bar.interface.ts +116 -0
  290. package/src/engine/src/interfaces/liquid-glass-text-input.interface.ts +42 -0
  291. package/src/engine/src/interfaces/liquid-glass-toast.interface.ts +36 -0
  292. package/src/engine/src/interfaces/liquid-glass-toolbar.interface.ts +33 -0
  293. package/src/engine/src/theme/glass-ui-theme.ts +100 -0
  294. package/src/engine/src/theme/index.ts +2 -0
  295. package/src/engine/src/utils/button-press.utils.ts +63 -0
  296. package/src/engine/src/utils/index.ts +3 -0
  297. package/src/engine/src/utils/metal.utils.ts +164 -0
  298. package/src/glass-provider.tsx +60 -0
  299. package/src/glass-stack.tsx +115 -0
  300. package/src/index.ts +47 -190
  301. package/src/internal/GlassBackdrop.tsx +60 -0
  302. package/src/internal/GlassView.tsx +53 -18
  303. package/src/internal/blur-community.ts +19 -0
  304. package/src/internal/blur-community.web.ts +7 -0
  305. package/src/internal/blur.ts +7 -8
  306. package/src/internal/glass-routing.ts +212 -34
  307. package/src/internal/initials.ts +7 -0
  308. package/src/internal/overlay.tsx +258 -0
  309. package/src/internal/primitives.ts +23 -0
  310. package/lib/module/Carousel.js +0 -103
  311. package/lib/module/Display.js +0 -318
  312. package/lib/module/Feedback.js +0 -395
  313. package/lib/module/Form.js +0 -160
  314. package/lib/module/Forms2.js +0 -471
  315. package/lib/module/Message.js +0 -84
  316. package/lib/module/Overlays.js +0 -344
  317. package/lib/module/Pickers.js +0 -243
  318. package/lib/module/Table.js +0 -100
  319. package/lib/module/ai.js +0 -283
  320. package/lib/module/charts/AreaChart.js +0 -32
  321. package/lib/module/charts/BarChart.js +0 -75
  322. package/lib/module/charts/FunnelChart.js +0 -50
  323. package/lib/module/charts/HeatmapChart.js +0 -71
  324. package/lib/module/charts/LineChart.js +0 -81
  325. package/lib/module/charts/PlotChart.js +0 -52
  326. package/lib/module/charts/RadarChart.js +0 -78
  327. package/lib/module/charts/RingChart.js +0 -52
  328. package/lib/module/charts/ScatterChart.js +0 -95
  329. package/lib/module/charts/WaterfallChart.js +0 -85
  330. package/lib/module/charts/advanced.js +0 -313
  331. package/lib/module/charts/extra.js +0 -108
  332. package/lib/module/charts/index.js +0 -50
  333. package/lib/module/charts/scales.js +0 -140
  334. package/lib/typescript/Carousel.d.ts +0 -47
  335. package/lib/typescript/Display.d.ts +0 -178
  336. package/lib/typescript/Feedback.d.ts +0 -196
  337. package/lib/typescript/Form.d.ts +0 -97
  338. package/lib/typescript/Forms2.d.ts +0 -209
  339. package/lib/typescript/Message.d.ts +0 -67
  340. package/lib/typescript/Overlays.d.ts +0 -146
  341. package/lib/typescript/Pickers.d.ts +0 -105
  342. package/lib/typescript/Table.d.ts +0 -64
  343. package/lib/typescript/ai.d.ts +0 -166
  344. package/lib/typescript/charts/AreaChart.d.ts +0 -44
  345. package/lib/typescript/charts/BarChart.d.ts +0 -19
  346. package/lib/typescript/charts/FunnelChart.d.ts +0 -25
  347. package/lib/typescript/charts/HeatmapChart.d.ts +0 -23
  348. package/lib/typescript/charts/LineChart.d.ts +0 -30
  349. package/lib/typescript/charts/PlotChart.d.ts +0 -31
  350. package/lib/typescript/charts/RadarChart.d.ts +0 -27
  351. package/lib/typescript/charts/RingChart.d.ts +0 -28
  352. package/lib/typescript/charts/ScatterChart.d.ts +0 -34
  353. package/lib/typescript/charts/WaterfallChart.d.ts +0 -22
  354. package/lib/typescript/charts/advanced.d.ts +0 -107
  355. package/lib/typescript/charts/extra.d.ts +0 -63
  356. package/lib/typescript/charts/index.d.ts +0 -13
  357. package/lib/typescript/charts/scales.d.ts +0 -35
  358. package/src/Carousel.tsx +0 -233
  359. package/src/Display.tsx +0 -781
  360. package/src/Feedback.tsx +0 -992
  361. package/src/Form.tsx +0 -445
  362. package/src/Forms2.tsx +0 -1055
  363. package/src/Message.tsx +0 -218
  364. package/src/Overlays.tsx +0 -704
  365. package/src/Pickers.tsx +0 -595
  366. package/src/Table.tsx +0 -232
  367. package/src/ai.tsx +0 -715
  368. package/src/charts/AreaChart.tsx +0 -73
  369. package/src/charts/BarChart.tsx +0 -221
  370. package/src/charts/FunnelChart.tsx +0 -125
  371. package/src/charts/HeatmapChart.tsx +0 -155
  372. package/src/charts/LineChart.tsx +0 -247
  373. package/src/charts/PlotChart.tsx +0 -168
  374. package/src/charts/RadarChart.tsx +0 -208
  375. package/src/charts/RingChart.tsx +0 -133
  376. package/src/charts/ScatterChart.tsx +0 -223
  377. package/src/charts/WaterfallChart.tsx +0 -201
  378. package/src/charts/advanced.tsx +0 -676
  379. package/src/charts/extra.tsx +0 -242
  380. package/src/charts/index.ts +0 -86
  381. package/src/charts/scales.ts +0 -163
@@ -0,0 +1,845 @@
1
+ package expo.modules.liquidglass.glass
2
+
3
+ /**
4
+ * Quality tiers for the AGSL glass shader.
5
+ *
6
+ * The dispersion tap count **cannot** be a uniform: AGSL follows GLSL ES 1.00 Appendix A, so a
7
+ * `for` loop must have a compile-time-constant bound to be statically unrollable. So each tier is a
8
+ * separate source string with its own compiled [android.graphics.RuntimeShader].
9
+ */
10
+ internal enum class ShaderQuality {
11
+ /** No dispersion, no film grain. ~0.18x the cost of [HIGH]. */
12
+ LOW,
13
+
14
+ /** 8 taps at one-per-point spacing — exactly what iOS resolves to at `regular` defaults. */
15
+ MEDIUM,
16
+
17
+ /** 16 taps at one-per-*pixel* spacing. Finer than iOS. */
18
+ HIGH;
19
+
20
+ val dispersionTaps: Int
21
+ get() = when (this) {
22
+ LOW -> 0
23
+ MEDIUM -> 8
24
+ HIGH -> 16
25
+ }
26
+ }
27
+
28
+ /**
29
+ * A compiled-ready shader source plus the set of uniforms that survive compilation.
30
+ *
31
+ * [liveUniforms] is not documentation — it is load-bearing. `setFloatUniform` throws
32
+ * `IllegalArgumentException: unable to find uniform named …` for a uniform the compiler optimised
33
+ * away, and Skia throws at *draw* time for a declared uniform that was never set. Both directions
34
+ * throw, and the `LOW` tier deletes five uniforms, so the uploader consults this set.
35
+ */
36
+ internal data class GlassShaderVariant(
37
+ val quality: ShaderQuality,
38
+ val source: String,
39
+ val liveUniforms: Set<String>
40
+ )
41
+
42
+ /**
43
+ * Builds the AGSL translation of `ios/Shaders/LiquidGlass.metal:180-256` (`glassFragment`).
44
+ *
45
+ * **Coordinate space is device pixels, origin at the top-left of the padded backdrop RenderNode.**
46
+ * Verified empirically on device during Phase 1: `main`'s `coord` is node-local, and `content.eval`
47
+ * is identity-aligned with it. Every length-valued uniform is therefore in px, not dp.
48
+ *
49
+ * **Precision policy: there is no `half` declaration anywhere in the generated source.** The only
50
+ * two `half` touchpoints are imposed by the language — `main` must return `half4`, and
51
+ * `content.eval()` returns `half4` — and both are converted explicitly at the boundary. fp16
52
+ * overflow has been observed on Samsung/Mali hardware, and emulators run `mediump` at fp32, so this
53
+ * class of bug passes CI and fails only on real devices.
54
+ *
55
+ * ---
56
+ * The rounded-rect SDF decomposition (`cornerParam` / `sdGlassRect` / `gradGlassRect` selected by
57
+ * a packed `float4`; named `radiusAt` / `sdRoundedRect` / `gradSdRoundedRect` before the
58
+ * continuous-corner generalization), the `size` + `offset` device-pixel framing, and the padding
59
+ * budget threaded
60
+ * through the effect chain follow **AndroidLiquidGlass, Apache License 2.0, Copyright 2025 Kyant**
61
+ * (`backdrop/src/commonMain/kotlin/com/kyant/backdrop/internal/Shaders.kt:22-48`, `:54-55`, `:69`;
62
+ * `effects/Lens.kt:25-27`, `:35-46`; `effects/Blur.kt:16-20`). See NOTICE.
63
+ *
64
+ * All refraction, dispersion, tone and noise **maths** is a translation of this project's own
65
+ * Metal shader, with two blocks **deliberately remodeled** against actual iOS 26 glass rather
66
+ * than the Metal fallback — eye-tested against a real iOS 26 button over UI content:
67
+ *
68
+ * 1. **The refraction direction can lean toward the light — as a knob.** Metal (and Kyant — its
69
+ * `coord + d * grad` looks outward but `Lens.kt:49` uploads the amount *negated*, so both
70
+ * sample inward) displaces purely along `normal + depthEffect * radial`, and per-edge pixel
71
+ * solves of real iOS 26 screenshots say Apple does too: the "swirl" the eye reads is the
72
+ * radial term sweeping through the corners with an edge-hugging profile, not a light-steered
73
+ * lean (research/04-ios26-edge-evidence, C4/C8). `refractionSwirl` mixes the highlight's
74
+ * light axis into the displacement direction before normalization for anyone who wants the
75
+ * stylised twist; it defaults to 0, which is Metal/Kyant/Apple exactly. See MAIN_PROLOGUE.
76
+ *
77
+ * 2. **The highlight is the glass border light, nothing else.** Metal's term (`:243-250`) is a
78
+ * signed multiplicative wash as wide as `refractionScale` (20 dp at `regular`): it darkens the
79
+ * whole quadrant opposite the light by up to 25% — a fake inset shadow real glass simply does
80
+ * not have — vanishes over dark backdrops, and lights one lobe. The replacement is a thin
81
+ * **additive** two-lobe rim on the light axis and nothing anywhere else; its
82
+ * `pow(abs(dot(normal, lightDir)), falloff)` model follows Kyant's
83
+ * `DefaultHighlightShaderString` (`internal/Shaders.kt:170-181`, same license as above). The
84
+ * Metal contour line and the signed wash are both gone — see the HIGHLIGHT fragment.
85
+ *
86
+ * Two Kyant behaviours are deliberately not copied: its un-centered `radiusAt(coord, …)` call,
87
+ * which makes the quadrant test always take the `x >= 0` branch so only the right-hand radii are
88
+ * ever selected; and its unguarded `circleMap`, which returns NaN for `|x| > 1`.
89
+ */
90
+ internal object GlassShaderSource {
91
+
92
+ // Uniform names. Referenced by GlassShaderVariant.liveUniforms and by the uploader.
93
+ const val SIZE = "size"
94
+ const val OFFSET = "offset"
95
+ const val CROP = "crop"
96
+ const val CORNER_EXTENTS = "cornerExtents"
97
+ const val CORNER_SHAPES = "cornerShapes"
98
+ const val UNIT_SCALE = "unitScale"
99
+ const val REFRACTION_SCALE = "refractionScale"
100
+ const val REFRACTION_AMOUNT = "refractionAmount"
101
+ const val REFRACTION_SWIRL = "refractionSwirl"
102
+ const val DEPTH_EFFECT = "depthEffect"
103
+ const val PROFILE_POWER = "profilePower"
104
+ const val PROFILE_BIAS = "profileBias"
105
+ const val DISPERSION_HEIGHT = "dispersionHeight"
106
+ const val DISPERSION_AMOUNT = "dispersionAmount"
107
+ const val DISPERSION_TAP_SPACING = "dispersionTapSpacing"
108
+ const val DISPERSION_QUADRANT = "dispersionQuadrant"
109
+ const val TINT_COLOR = "tintColor"
110
+ const val FROST_COLOR = "frostColor"
111
+ const val HIGHLIGHT_INTENSITY = "highlightIntensity"
112
+ const val HIGHLIGHT_DIR = "highlightDir"
113
+ const val HIGHLIGHT_WIDTH = "highlightWidth"
114
+ const val HIGHLIGHT_FALLOFF = "highlightFalloff"
115
+ const val LIGHT_INTENSITY = "lightIntensity"
116
+ const val GLASS_OPACITY = "glassOpacity"
117
+ const val SATURATION = "saturation"
118
+ const val HDR_HEADROOM = "hdrHeadroom"
119
+ const val NOISE_AMOUNT = "noiseAmount"
120
+ const val TOUCH_POS = "touchPos"
121
+ const val TOUCH_GLOW = "touchGlow"
122
+ const val TOUCH_LENS = "touchLens"
123
+ const val SHAPE_RECT = "shapeRect"
124
+ const val MORPH_RECT = "morphRect"
125
+ const val MORPH_SHAPE = "morphShape"
126
+ const val INNER_SHADOW_COLOR = "innerShadowColor"
127
+ const val INNER_SHADOW_GEOM = "innerShadowGeom"
128
+ const val MAGNIFICATION = "magnification"
129
+
130
+ private val cache = HashMap<ShaderQuality, GlassShaderVariant>()
131
+
132
+ @Synchronized
133
+ fun variant(quality: ShaderQuality): GlassShaderVariant =
134
+ cache.getOrPut(quality) { build(quality) }
135
+
136
+ private fun build(quality: ShaderQuality): GlassShaderVariant {
137
+ val taps = quality.dispersionTaps
138
+ // LOW drops the dispersion loop and the film grain. `unitScale` is in every tier: the
139
+ // HIGHLIGHT fragment's sheen band is point-valued.
140
+ val disperses = taps > 0
141
+ val grain = quality != ShaderQuality.LOW
142
+
143
+ val live = linkedSetOf(
144
+ SIZE, OFFSET, CROP, CORNER_EXTENTS, CORNER_SHAPES, UNIT_SCALE,
145
+ REFRACTION_SCALE, REFRACTION_AMOUNT, REFRACTION_SWIRL, DEPTH_EFFECT,
146
+ PROFILE_POWER, PROFILE_BIAS,
147
+ TINT_COLOR, FROST_COLOR,
148
+ HIGHLIGHT_INTENSITY, HIGHLIGHT_DIR, HIGHLIGHT_WIDTH, HIGHLIGHT_FALLOFF,
149
+ LIGHT_INTENSITY, GLASS_OPACITY, SATURATION, HDR_HEADROOM,
150
+ TOUCH_POS, TOUCH_GLOW, TOUCH_LENS, SHAPE_RECT, MORPH_RECT, MORPH_SHAPE,
151
+ INNER_SHADOW_COLOR, INNER_SHADOW_GEOM, MAGNIFICATION
152
+ )
153
+ if (disperses) {
154
+ live += setOf(
155
+ DISPERSION_HEIGHT, DISPERSION_AMOUNT, DISPERSION_TAP_SPACING, DISPERSION_QUADRANT
156
+ )
157
+ }
158
+ if (grain) live += NOISE_AMOUNT
159
+
160
+ val src = buildString {
161
+ append(HEADER)
162
+
163
+ append(
164
+ """
165
+ uniform shader content; // chain input: the padded backdrop, blurred or sharp.
166
+ // Metal: texture2d<float> source [[texture(0)]] (:181)
167
+
168
+ uniform float2 size; // view size, px. Metal: viewSize == shapeSize (:24, :25)
169
+ uniform float2 offset; // (-P, -P), px — node-local to view-local.
170
+ uniform float4 crop; // node-space clamp rect (minX, minY, maxX, maxY), px.
171
+ // Replaces address::clamp_to_edge + clamp(texUV,0,1)
172
+ uniform float4 cornerExtents; // px, packed (BL, BR, TR, TL) like the old cornerRadii.
173
+ // Corner-cell size: E = r for circular, up to 1.5287*r
174
+ // for continuous (ContinuousCorners.resolve).
175
+ uniform float4 cornerShapes; // superellipse exponent per corner, same packing.
176
+ // 2 = circular corner exactly; 3.3418 = Apple continuous
177
+ // (research/05-continuous-corner-calibration).
178
+
179
+ uniform float2 refractionScale; // px. Metal: refractionScale (:27)
180
+ uniform float refractionAmount; // px. Metal: refractionAmount (:29)
181
+ uniform float refractionSwirl; // How far the displacement leans toward the highlight's
182
+ // light axis. 0 = Metal/Kyant. No Metal counterpart.
183
+ uniform float depthEffect; // Metal: depthEffect (:31)
184
+ uniform float profilePower; // Metal: profilePower (:33)
185
+ uniform float profileBias; // Metal: profileBias (:34)
186
+
187
+ uniform float4 tintColor; // straight (non-premultiplied) RGBA. Metal: tintColor (:20)
188
+ uniform float4 frostColor; // rgb = system background, a = frostAmount (:21)
189
+ uniform float highlightIntensity;
190
+ uniform float2 highlightDir; // (cos angle, sin angle) — precomputed on the CPU so the
191
+ // per-pixel sin/cos pair disappears entirely.
192
+ uniform float highlightWidth; // px. Depth of the glass border light. No Metal
193
+ // counterpart — see the HIGHLIGHT fragment.
194
+ uniform float highlightFalloff; // Angular falloff exponent of the two lobes. Kyant's
195
+ // `falloff`, default 1. Guarded >= 0.01 on the CPU.
196
+ uniform float lightIntensity;
197
+ uniform float glassOpacity;
198
+ uniform float saturation;
199
+
200
+ uniform float hdrHeadroom; // display HDR/SDR ratio, >= 1. Exactly 1.0 = SDR, and
201
+ // the shader is bit-identical to the pre-HDR build.
202
+ // > 1 only when the app opted the window into
203
+ // COLOR_MODE_HDR (GlassHdr) on an HDR panel: then the
204
+ // glass border light may exceed SDR white, while the
205
+ // backdrop seen through the glass stays SDR (HIGHLIGHT).
206
+
207
+ uniform float2 touchPos; // view-local px, same space as `pixels`. No Metal
208
+ // counterpart — the `interactive` press glow.
209
+ uniform float touchGlow; // 0..1 press progress; 0 turns the branch off.
210
+ uniform float touchLens; // 0..1 gate on the press's *optical* half — the backdrop
211
+ // dent and the refraction boost. 1 for a press on this
212
+ // view (`interactive`). 0 for a press being reported from
213
+ // elsewhere (`glow`), where only the light belongs here:
214
+ // a bar hosting a grabbed pill lights up, it does not
215
+ // start refracting harder. See GlassGlowOptions.
216
+
217
+ uniform float4 shapeRect; // The primary shape: xy = its center's offset from the
218
+ // view center, zw = its half extents — px. The uploader
219
+ // defaults it to (0, 0, size * 0.5), the view-filling
220
+ // shape, unless `metal.shape` insets it. Metal:
221
+ // shapeSize + shapeOffset.
222
+ uniform float4 morphRect; // The morph partner: xy = its center's offset from the
223
+ // SHAPE center, zw = its half extents — px. Metal:
224
+ // morphRect, identically.
225
+ uniform float2 morphShape; // (corner radius, smoothing), px. smoothing <= 0 turns
226
+ // the merge branch off and the field is bit-identical
227
+ // to the single-shape build. Metal: morphShape.
228
+
229
+ uniform float4 innerShadowColor; // straight RGBA of the inner shadow's colour; a <= 0
230
+ // turns the band off. Metal: innerShadow.
231
+ uniform float3 innerShadowGeom; // (blur radius, cast offset x, cast offset y), px.
232
+ // Metal: innerShadowRadius + innerShadowOffset.
233
+ uniform float magnification; // >= 1; 1 = none. Backdrop sampling contracts toward
234
+ // the shape center by this. Metal: magnification.
235
+
236
+ """.trimIndent()
237
+ )
238
+ appendLine()
239
+
240
+ append(
241
+ """
242
+ // Device px per iOS point. Used ONLY where a point value is hard-coded (the dispersion
243
+ // cutoff, the sheen band).
244
+ uniform float unitScale;
245
+
246
+ """.trimIndent()
247
+ )
248
+ appendLine()
249
+ if (disperses) {
250
+ append(
251
+ """
252
+ uniform float dispersionHeight; // px. Metal: dispersionHeight (:36)
253
+ uniform float dispersionAmount; // px. Metal: dispersionAmount (:37)
254
+ uniform float dispersionTapSpacing; // px between taps. MUST be <= unitScale, or the
255
+ // spread >= 2 invariant breaks and every glass edge
256
+ // gets a blue fringe.
257
+ uniform float dispersionQuadrant; // 0 = the rim fringes evenly all the way round
258
+ // (iOS/Metal). 1 = Kyant's quadrant weighting; see
259
+ // the REFRACTION_WITH_DISPERSION fragment.
260
+
261
+ const int kDispersionTaps = $taps; // Metal: constant int kDispersionTaps = 16 (:96)
262
+
263
+ """.trimIndent()
264
+ )
265
+ appendLine()
266
+ }
267
+ if (grain) {
268
+ append(
269
+ """
270
+ uniform float noiseAmount;
271
+
272
+ """.trimIndent()
273
+ )
274
+ appendLine()
275
+ }
276
+
277
+ append(FUNCTIONS)
278
+ if (grain) append(HASH_NOISE)
279
+ append(SAMPLE_BACKDROP)
280
+
281
+ append(MAIN_PROLOGUE)
282
+ append(if (disperses) REFRACTION_WITH_DISPERSION else REFRACTION_ONLY)
283
+ append(TONE_CHAIN)
284
+ if (grain) append(GRAIN)
285
+ append(HIGHLIGHT)
286
+ append(INNER_SHADOW)
287
+ append(TOUCH_GLOW_FRAGMENT)
288
+ append(MAIN_EPILOGUE)
289
+ }
290
+
291
+ return GlassShaderVariant(quality, src, live)
292
+ }
293
+
294
+ // ---------------------------------------------------------------------------- source fragments
295
+
296
+ private val HEADER = """
297
+ // =========================================================================
298
+ // LiquidGlass.agsl — generated by GlassShaderSource.
299
+ // AGSL port of ios/Shaders/LiquidGlass.metal:180-256 (glassFragment),
300
+ // with two deliberate visual divergences: the refraction direction can
301
+ // lean toward the light (refractionSwirl), and the highlight is the
302
+ // glass border light (see MAIN_PROLOGUE and the HIGHLIGHT fragment).
303
+ // Requires API 33 (android.graphics.RuntimeShader).
304
+ //
305
+ // Coordinate space: DEVICE PIXELS, origin = top-left of the padded backdrop
306
+ // RenderNode. Every length-valued uniform is px.
307
+ //
308
+ // Portions derived from AndroidLiquidGlass (Apache-2.0, (c) 2025 Kyant).
309
+ // See the KDoc on GlassShaderSource and the NOTICE file.
310
+ // =========================================================================
311
+
312
+ const float kNormEps = 1e-6;
313
+
314
+
315
+ """.trimIndent() + "\n"
316
+
317
+ private val FUNCTIONS = """
318
+ // NaN-free normalize. Metal guards each normalize with a length test (:79, :150, :152, :154).
319
+ // A ternary is NOT safe: if SkSL lowers `cond ? normalize(v) : fb` to an arithmetic select then
320
+ // normalize(0) = NaN is still multiplied by 0, and NaN * 0 = NaN. The division form cannot
321
+ // produce NaN for any finite v, because the denominator is floored.
322
+ float2 safeNormalize(float2 v, float2 fallback) {
323
+ float len = length(v);
324
+ float ok = step(kNormEps, len);
325
+ return mix(fallback, v / max(len, kNormEps), ok);
326
+ }
327
+
328
+ // Metal :55-60, generalized: quadrant-select any per-corner packed float4 (extents, shapes).
329
+ // The argument MUST be the CENTERED coordinate, y-down. NB: `packed` is a reserved word in
330
+ // SkSL — hence `corners`.
331
+ float cornerParam(float2 c, float4 corners) {
332
+ if (c.x >= 0.0) {
333
+ return (c.y <= 0.0) ? corners.z : corners.y; // right-top : right-bottom
334
+ }
335
+ return (c.y <= 0.0) ? corners.w : corners.x; // left-top : left-bottom
336
+ }
337
+
338
+ // Metal :62-69, extended to the continuous-corner family (research/05): a corner is a
339
+ // superellipse quadrant in an E x E cell, and (E = r, n = 2) IS the circular corner — the
340
+ // else-branch below is the original Euclidean SDF verbatim, with E in place of r. The edge
341
+ // and interior algebra cancels E exactly as it cancelled r, so straight edges stay exact for
342
+ // any extent.
343
+ //
344
+ // The corner branch is the n-norm field with a first-order Euclidean correction,
345
+ // sd ~ (g - E) / |grad g|. Measured against the true curve: error <= 0.11 px at 20 px depth,
346
+ // growing only where the refraction profile has already decayed to ~0 (research/05 tables).
347
+ // pow() is only ever called with a strictly positive base (the qp > 0 guards), so the
348
+ // GLSL-undefined pow(x<0) and pow(0, 0) cases are unreachable.
349
+ float sdGlassRect(float2 c, float2 halfSize, float4 extents, float4 shapes) {
350
+ // The host resolves the view's own extents; the min() is for rects it cannot see — a
351
+ // `metal.shape` smaller than the radii resolved against it. innerHalf < 0 breaks the SDF.
352
+ float E = min(cornerParam(c, extents), min(halfSize.x, halfSize.y));
353
+ float n = cornerParam(c, shapes);
354
+ float2 innerHalf = halfSize - float2(E);
355
+ float2 q = abs(c) - innerHalf;
356
+ float2 qp = max(q, float2(0.0));
357
+ float outside;
358
+ if (n > 2.001 && qp.x > 0.0 && qp.y > 0.0) {
359
+ float g = max(pow(pow(qp.x, n) + pow(qp.y, n), 1.0 / n), kNormEps);
360
+ float2 dg = pow(qp / g, float2(n - 1.0));
361
+ outside = (g - E) / max(length(dg), kNormEps);
362
+ } else {
363
+ outside = length(qp) - E;
364
+ }
365
+ float inside = min(max(q.x, q.y), 0.0);
366
+ return outside + inside;
367
+ }
368
+
369
+ // Metal :71-81, same extension. In the corner cell the outward direction is the n-norm
370
+ // field's gradient (qp/g)^(n-1), which at n = 2 is qp itself — the original normalize
371
+ // direction. pow(0, n-1) with n > 2 is defined (0), so a cell-boundary qp component is safe.
372
+ float2 gradGlassRect(float2 c, float2 halfSize, float4 extents, float4 shapes) {
373
+ float E = min(cornerParam(c, extents), min(halfSize.x, halfSize.y));
374
+ float n = cornerParam(c, shapes);
375
+ float2 innerHalf = halfSize - float2(E);
376
+ float2 q = abs(c) - innerHalf;
377
+
378
+ float insideCorner = step(0.0, min(q.x, q.y));
379
+ float xMajor = step(q.y, q.x);
380
+ float2 gradEdge = float2(xMajor, 1.0 - xMajor);
381
+ float2 qp = max(q, float2(0.0));
382
+ float2 dir = qp;
383
+ if (n > 2.001) {
384
+ float g = max(pow(pow(qp.x, n) + pow(qp.y, n), 1.0 / n), kNormEps);
385
+ dir = pow(qp / g, float2(n - 1.0));
386
+ }
387
+ float2 gradCorner = safeNormalize(dir, float2(0.0));
388
+ return sign(c) * mix(gradEdge, gradCorner, insideCorner);
389
+ }
390
+
391
+ // Metal :83-85. KEEP the max(0.0, …): without it this returns NaN for |x| > 1.
392
+ float circleMap(float x) {
393
+ return 1.0 - sqrt(max(0.0, 1.0 - x * x));
394
+ }
395
+
396
+ // The merged field at an arbitrary centered coordinate — the primary shape with the morph
397
+ // partner folded in exactly as MAIN_PROLOGUE does it inline (that copy also needs the blend
398
+ // weight for the gradient; this one does not). Used wherever the field is needed at a point
399
+ // other than the fragment's own: the inner shadow's shifted evaluation. Metal: mergedSd.
400
+ float mergedSd(float2 c) {
401
+ float2 halfSize = shapeRect.zw;
402
+ float sd = sdGlassRect(c, halfSize, cornerExtents, cornerShapes);
403
+ float2 morphHalf = morphRect.zw;
404
+ if (morphShape.y > 0.0 && morphHalf.x > 0.0 && morphHalf.y > 0.0) {
405
+ float morphR = min(morphShape.x, min(morphHalf.x, morphHalf.y));
406
+ float sdB = sdGlassRect(c - morphRect.xy, morphHalf, float4(morphR), float4(2.0));
407
+ float k = morphShape.y;
408
+ float h = clamp(0.5 + 0.5 * (sdB - sd) / k, 0.0, 1.0);
409
+ sd = mix(sdB, sd, h) - k * h * (1.0 - h);
410
+ }
411
+ return sd;
412
+ }
413
+
414
+ """.trimIndent() + "\n"
415
+
416
+ // Metal :87-89. MUST stay float: 43758.5453 has no useful fp16 mantissa left after the multiply,
417
+ // and sin() of a large half-precision argument is pure noise on Mali.
418
+ private val HASH_NOISE = """
419
+ float hashNoise(float2 co) {
420
+ return fract(sin(dot(co, float2(12.9898, 78.233))) * 43758.5453);
421
+ }
422
+
423
+ """.trimIndent() + "\n"
424
+
425
+ // Metal :171-178. The whole sourceRect / UV indirection collapses to a translate plus a clamp,
426
+ // because on Android the node IS the sampled region.
427
+ //
428
+ // The clamp is mandatory, not defensive: out-of-bounds `content.eval` returns transparent black,
429
+ // not the clamped edge texel — measured on device in Phase 1. Reading `.rgb` of premultiplied
430
+ // transparent black gives *black*, so an unclamped tap paints a black rim and black corner blobs
431
+ // hugging the SDF boundary.
432
+ private val SAMPLE_BACKDROP = """
433
+ float4 sampleBackdrop(float2 viewPx) {
434
+ // The `interactive` dent: samples near the finger are pulled toward it, which reads as a
435
+ // magnifying bulge travelling with the touch — the glass flexing, not just lighting up.
436
+ // Living here means every read warps coherently (interior, rim band, all dispersion taps)
437
+ // for the cost of a length() per sample, and geometry (sd, normals, t) stays un-warped.
438
+ // d == 0 at the touch point, so there is no normalize() and no NaN to guard.
439
+ if (touchGlow * touchLens > 0.0) {
440
+ float2 d = viewPx - touchPos;
441
+ float f = 1.0 - smoothstep(0.0, 0.6 * min(size.x, size.y), length(d));
442
+ viewPx -= d * (f * f * 0.22 * touchGlow * touchLens);
443
+ }
444
+ float2 nodePx = clamp(viewPx - offset, crop.xy, crop.zw);
445
+ // content.eval() returns half4 by language definition; widen at once so no half-precision
446
+ // value ever enters the arithmetic. The node is PREMULTIPLIED: un-premultiply and carry
447
+ // the alpha out, so a partially-covered texel — a capsule layer's anti-aliased corner,
448
+ // anything a small provider never drew — keeps its true hue instead of reading as black.
449
+ // The epilogue folds this coverage into the output alpha: glass over nothing recorded
450
+ // passes the real content behind it through rather than painting black.
451
+ float4 c = float4(content.eval(nodePx));
452
+ return float4(c.rgb / max(c.a, 1e-4), c.a);
453
+ }
454
+
455
+ """.trimIndent() + "\n"
456
+
457
+ private val MAIN_PROLOGUE = """
458
+ half4 main(float2 fragCoord) {
459
+ // Metal :183-185
460
+ float2 pixels = fragCoord + offset; // view-local px, top-left origin, y-down
461
+ // Shape-centered, not view-centered: with `metal.shape` absent the uploader sends
462
+ // shapeRect = (0, 0, size * 0.5) and both lines are the historical ones exactly.
463
+ // Sampling positions stay `pixels` — only geometry moves.
464
+ float2 halfSize = shapeRect.zw;
465
+ float2 centered = pixels - size * 0.5 - shapeRect.xy;
466
+
467
+ // Reordered relative to Metal, which builds the whole GlassGeometry at :187 before testing
468
+ // at :191. The SDF alone decides the early-out, so the gradient / direction / scale work is
469
+ // skipped for every pixel in the padded margin — which is most of them.
470
+ float sd = sdGlassRect(centered, halfSize, cornerExtents, cornerShapes);
471
+
472
+ // The morph partner (Metal: glassGeometry's morph fold), BEFORE the early-out: the
473
+ // smooth-min neck lies outside both source shapes, so a coverage test on the primary SDF
474
+ // alone would discard exactly the pixels the merge exists to draw. The fold is the
475
+ // polynomial smooth-min — I. Quilez's smin, published mid-2000s and folklore since — and
476
+ // everything downstream reads the merged field, which is what fuses the two shapes into
477
+ // one pane of liquid instead of two panes overlapping. The partner's corners are
478
+ // circular (n = 2): its radius is a single scalar, and the continuous-corner family
479
+ // stays a primary-shape refinement.
480
+ float2 morphHalf = morphRect.zw;
481
+ float2 morphCoord = centered - morphRect.xy;
482
+ float morphR = min(morphShape.x, min(morphHalf.x, morphHalf.y));
483
+ float morphH = 1.0;
484
+ if (morphShape.y > 0.0 && morphHalf.x > 0.0 && morphHalf.y > 0.0) {
485
+ float sdB = sdGlassRect(morphCoord, morphHalf, float4(morphR), float4(2.0));
486
+ float k = morphShape.y;
487
+ morphH = clamp(0.5 + 0.5 * (sdB - sd) / k, 0.0, 1.0);
488
+ sd = mix(sdB, sd, morphH) - k * morphH * (1.0 - morphH);
489
+ }
490
+
491
+ // fwidth() does not exist in AGSL. |grad(sd)| == 1 for an exact SDF and we are in device
492
+ // pixels, so fwidth(sd) == 1.0 — a 2 px feather, which is exactly what iOS produces
493
+ // (fwidth(sd_points) = 1/contentsScale points). The smooth-min field is not exact in the
494
+ // blend zone (|grad| dips below 1), which only widens the feather there — the seam is
495
+ // softer, never harder.
496
+ float aa = 1.0;
497
+ float shapeAlpha = 1.0 - smoothstep(-aa, aa, sd);
498
+ if (shapeAlpha <= 0.001) {
499
+ return half4(0.0); // Metal :192
500
+ }
501
+
502
+ // Metal :141-163 (glassGeometry). The 1.5x inflation applies to the corner-cell extents
503
+ // now — for circular corners that is exactly Metal's radius inflation, and for continuous
504
+ // ones it widens the same look-tuning band around the softer corner.
505
+ float4 maxGradExtent = float4(min(halfSize.x, halfSize.y)); // :147
506
+ float4 gradExtents = min(cornerExtents * 1.5, maxGradExtent); // :148
507
+ float2 normal = safeNormalize(
508
+ gradGlassRect(centered, halfSize, gradExtents, cornerShapes),
509
+ float2(0.0, 1.0)); // :149-150
510
+
511
+ // The merged field's gradient: the two shapes' gradients blended by the same hermite
512
+ // weight — standard SDF practice (the exact derivative's dh terms are dropped), smooth
513
+ // everywhere the weight is. morphH == 1.0 covers both "no partner" and "far on the
514
+ // primary's side", so the extra gradient is only ever computed near the partner.
515
+ if (morphH < 1.0) {
516
+ float4 maxGradB = float4(min(morphHalf.x, morphHalf.y));
517
+ float4 gradExtentsB = min(float4(morphR) * 1.5, maxGradB);
518
+ float2 normalB = safeNormalize(
519
+ gradGlassRect(morphCoord, morphHalf, gradExtentsB, float4(2.0)),
520
+ float2(0.0, 1.0));
521
+ normal = safeNormalize(mix(normalB, normal, morphH), normal);
522
+ }
523
+
524
+ float2 radial = safeNormalize(centered, float2(0.0)); // :152
525
+
526
+ // The light axis: highlightDir rotated +90 degrees — the same axis the HIGHLIGHT lobes
527
+ // sit on, so `highlight.angle` steers both. Mixing it into the displacement direction
528
+ // before normalizing leans the edge refraction toward the light — a stylisation knob,
529
+ // OFF by default: measured real iOS 26 glass carries no such lean (research/04, C8);
530
+ // its perceived twist is the radial term below sweeping through the corners. At swirl 0
531
+ // the sum is exactly Metal :153-154, which is also Kyant's `grad`.
532
+ float2 lobeDir = float2(-highlightDir.y, highlightDir.x);
533
+ float2 direction = safeNormalize(
534
+ normal + depthEffect * radial + refractionSwirl * lobeDir, normal);
535
+
536
+ // Anisotropic refraction height: n^2 . refractionScale yields refractionScale.x on a
537
+ // vertical edge and .y on a horizontal one.
538
+ float2 limit = max(halfSize, float2(1e-3)); // :156
539
+ float2 scale2 = clamp(refractionScale, float2(1e-3), limit); // :157
540
+ float scale = max(dot(normal * normal, scale2), 1e-3); // :158
541
+
542
+ float t = clamp(-min(sd, 0.0) / scale, 0.0, 1.0); // :160
543
+ float inside = -min(sd, 0.0); // :196
544
+
545
+ // The `interactive` press deepens the lens — Kyant's components animate their lens amount
546
+ // with press progress; this is that, riding the existing uniform. 1.0 at rest, and 1.0 for
547
+ // a press reported from another view, which lights this glass without bending it further.
548
+ float touchBoost = 1.0 + 0.35 * touchGlow * touchLens;
549
+
550
+ // The whole-surface lens (research/04, C16 — the interior magnification our shader
551
+ // lacked): sampling contracts toward the shape center by the magnification, so the
552
+ // backdrop reads enlarged through the pane. Geometry is untouched — the edge band still
553
+ // bends off the true silhouette — and magnification >= 1 only ever samples INWARD, so the
554
+ // padding budget needs nothing for it. Metal: samplePx.
555
+ float2 samplePx = pixels;
556
+ if (magnification > 1.0001) {
557
+ samplePx = pixels - centered * (1.0 - 1.0 / magnification);
558
+ }
559
+
560
+ float3 color;
561
+ // Backdrop coverage under this pixel's sample(s); the epilogue multiplies it into the
562
+ // output alpha, so glass over un-recorded regions transmits reality instead of black.
563
+ float bdAlpha = 1.0;
564
+
565
+ """.trimIndent() + "\n"
566
+
567
+ /**
568
+ * The `spreadMag < 2 * unitScale` guard is what keeps `maxI >= 2`, so `u` takes at least 0, 0.5
569
+ * and 1.0 and every channel mask fires. If only `u = 0` were active the mask would be (0,0,1) and
570
+ * the divide would force red and green to black — a solid blue rim on every glass edge. The guard
571
+ * tests the *magnitude*, which is what makes the quadrant weighting safe: it drives the spread
572
+ * through zero along the centre lines, and the untested signed value would sail straight past a
573
+ * `< 2` test on the negative side and into a two-tap walk.
574
+ */
575
+ private val REFRACTION_WITH_DISPERSION = """
576
+ if (inside >= scale) {
577
+ float4 sIn = sampleBackdrop(samplePx); // Metal :198-199
578
+ color = sIn.rgb;
579
+ bdAlpha = sIn.a;
580
+ } else {
581
+ // Metal :165-169 (refractedPixels), hoisted: Metal recomputes it identically at :205
582
+ // and :207. The pow() base is 1-t with t clamped to [0,1] so it is never negative, and
583
+ // the exponent is floored so pow(0, 0) is unreachable.
584
+ float profile = circleMap(pow(1.0 - t, max(profilePower, 1e-3)));
585
+ float amount = (profile + profileBias * (1.0 - t)) * refractionAmount * touchBoost;
586
+ float2 base = samplePx - amount * direction; // NOTE the minus (:168)
587
+
588
+ float dispersionT = clamp(inside / max(dispersionHeight, 1e-3), 0.0, 1.0);
589
+ float spread = circleMap(1.0 - dispersionT) * dispersionAmount * touchBoost;
590
+
591
+ // Kyant's quadrant weighting, blended in by `dispersionQuadrant`
592
+ // (internal/Shaders.kt:`dispersionIntensity`, Apache-2.0 — see NOTICE). The product of
593
+ // the normalized centered coordinates is 0 along BOTH centre lines and +/-1 at the
594
+ // corners, so the fringe lives where the eye already reads the shape bending — the
595
+ // capsule's ends — and dies out along its flanks. Left signed on purpose: the sign
596
+ // flips between adjacent quadrants, which walks the taps the other way and so reverses
597
+ // the hue order. That alternation is the effect's whole signature, and abs() would
598
+ // quietly delete it.
599
+ //
600
+ // |weight| <= 1 always, so this only ever SHRINKS the spread — the padding budget
601
+ // (GlassAppearance.dispersionOutwardReachPx) stays a valid bound and needs no change.
602
+ float2 quadrant = centered / max(halfSize, float2(1e-3));
603
+ spread *= mix(1.0, quadrant.x * quadrant.y, dispersionQuadrant);
604
+
605
+ // Magnitude from here down: a negative spread is a direction, not a smaller one.
606
+ float spreadMag = abs(spread);
607
+
608
+ // The literal 2.0 is POINTS in the Metal source (:204).
609
+ if (spreadMag < 2.0 * unitScale) {
610
+ float4 sBase = sampleBackdrop(base); // :205
611
+ color = sBase.rgb;
612
+ bdAlpha = sBase.a;
613
+ } else {
614
+ // LONGITUDINAL aberration: taps walk along the displacement axis itself — R
615
+ // sampled deepest, B shallowest, G centred. Metal walks the tangent (:208) and
616
+ // the first port copied it; per-channel phase solves of real iOS 26 measured the
617
+ // spread along the displacement direction with blue as the outermost fringe
618
+ // (research/04, C26). `base - direction * s` deepens the sample for positive s,
619
+ // so the R half of the mask (u > 0.5) lands deepest.
620
+ float3 accumulated = float3(0.0);
621
+ float3 weight = float3(0.0);
622
+ float aAccum = 0.0;
623
+ float aTaps = 0.0;
624
+
625
+ // Metal: maxI = min(spread, 16) with `pixels` in POINTS — one tap per point.
626
+ // dispersionTapSpacing == unitScale reproduces that exactly.
627
+ float maxI = min(spreadMag / max(dispersionTapSpacing, 1e-3),
628
+ float(kDispersionTaps)); // :212
629
+
630
+ for (int i = 0; i < kDispersionTaps; ++i) {
631
+ float u = float(i) / maxI; // :215
632
+ // Metal writes `if (u > 1.0) break;` (:216). A dynamic `if` is used instead: it
633
+ // stays statically unrollable across the whole API 33-36 Skia range, and the GPU
634
+ // still skips the eval when the wave agrees. The accumulator and weight are
635
+ // untouched when the test fails, so the result is identical.
636
+ if (u <= 1.0) {
637
+ float4 tap = sampleBackdrop(base - direction * (u - 0.5) * spread);
638
+ float3 mask = float3(step(0.5, u), // R: upper half
639
+ step(0.25, u) * step(u, 0.75), // G: middle band
640
+ step(u, 0.5)); // B: lower half
641
+ accumulated += tap.rgb * mask;
642
+ weight += mask;
643
+ aAccum += tap.a;
644
+ aTaps += 1.0;
645
+ }
646
+ }
647
+ color = accumulated / max(weight, float3(1e-6)); // :227
648
+ bdAlpha = aAccum / max(aTaps, 1.0);
649
+ }
650
+ }
651
+
652
+ """.trimIndent().prependIndent(" ") + "\n"
653
+
654
+ private val REFRACTION_ONLY = """
655
+ {
656
+ float4 s;
657
+ if (inside >= scale) {
658
+ s = sampleBackdrop(samplePx); // Metal :198-199
659
+ } else {
660
+ // Metal :165-169 (refractedPixels). The LOW tier stops here: no chromatic
661
+ // dispersion.
662
+ float profile = circleMap(pow(1.0 - t, max(profilePower, 1e-3)));
663
+ float amount = (profile + profileBias * (1.0 - t)) * refractionAmount * touchBoost;
664
+ s = sampleBackdrop(samplePx - amount * direction); // NOTE the minus (:168)
665
+ }
666
+ color = s.rgb;
667
+ bdAlpha = s.a;
668
+ }
669
+
670
+ """.trimIndent().prependIndent(" ") + "\n"
671
+
672
+ // Metal :231-236. Rec.709 luma, computed in gamma space exactly as Metal does.
673
+ //
674
+ // The frost/tint pair used to be two `mix`es straight onto the transmitted colour, and the
675
+ // epilogue then multiplied the whole output alpha by `bdAlpha`. That is wrong wherever the
676
+ // provider recorded nothing: a glass card overhanging the gap between two cards lost its frost,
677
+ // its tint and its shape alpha all at once and punched a hard-edged hole to the window
678
+ // background. Glass over nothing is still glass — you lose what it transmits, not the pane.
679
+ //
680
+ // So the two are separated and composited by their real coverage. Expanding the original pair,
681
+ //
682
+ // mix(mix(t, F, fa), T, ta) = t*(1-fa)*(1-ta) + F*fa*(1-ta) + T*ta
683
+ //
684
+ // the transmitted term carries weight `(1-fa)(1-ta)`, which is exactly `1 - surfaceAlpha`, and
685
+ // the rest is the surface's own premultiplied colour. Weighting the transmitted term by
686
+ // `bdAlpha` and dividing by the resulting coverage is ordinary source-over — and at `bdAlpha
687
+ // == 1` every line below algebraically collapses back to the two `mix`es, so fully-covered
688
+ // glass is bit-for-bit what it always was.
689
+ private val TONE_CHAIN = """
690
+ color = clamp(color, 0.0, 1.0);
691
+
692
+ float luma = dot(color, float3(0.2126, 0.7152, 0.0722));
693
+ color = mix(float3(luma), color, saturation);
694
+
695
+ float surfaceAlpha = frostColor.a + tintColor.a * (1.0 - frostColor.a);
696
+ float3 surfacePremul =
697
+ frostColor.rgb * (frostColor.a * (1.0 - tintColor.a)) + tintColor.rgb * tintColor.a;
698
+ float transmitWeight = (1.0 - surfaceAlpha) * bdAlpha;
699
+ // Coverage of the finished pane: its own surface, plus whatever it actually transmits.
700
+ // With no surface at all this is just `bdAlpha` — clear glass over nothing IS nothing.
701
+ float cover = surfaceAlpha + transmitWeight;
702
+ color = (color * transmitWeight + surfacePremul) / max(cover, 1e-4);
703
+
704
+ """.trimIndent().prependIndent(" ") + "\n"
705
+
706
+ // Metal :238-241. Metal keys off in.position.xy — drawable device px, which are view-local because
707
+ // the CAMetalLayer *is* the view. `fragCoord` is padded-node-local, so its origin shifts by P
708
+ // whenever refractionAmount / dispersionAmount / blurRadius changes and the grain field would jump
709
+ // on every prop animation. `pixels` is view-local and stable.
710
+ private val GRAIN = """
711
+ if (noiseAmount > 0.0) {
712
+ color += (hashNoise(pixels * 1e-3) - 0.5) * noiseAmount;
713
+ }
714
+
715
+ """.trimIndent().prependIndent(" ") + "\n"
716
+
717
+ // Metal :243-250, deliberately remodeled — the KDoc up top owns the why; the constraints live
718
+ // here.
719
+ //
720
+ // Metal's signed multiplicative wash — `sin(pos_angle - highlightAngle)` over the whole
721
+ // refraction band — is GONE, not reweighted. It darkened the quadrant opposite the light by up
722
+ // to 25%, and real iOS 26 glass has no inset shadow: away from the border light the interior is
723
+ // flat. The highlight itself is 180-degree periodic by construction now; only the swirl lean
724
+ // (MAIN_PROLOGUE, lobeDir flips sign at angle + 180) still tells the two apart. Metal's contour
725
+ // line (:249-250) is folded in too: at a 1.5 dp band the rim IS the crisp line, and a separate
726
+ // contour on top is exactly the over-thick edge this remodel removes.
727
+ //
728
+ // What remains is the glass border light. Falloff model per Kyant's DefaultHighlightShaderString
729
+ // (pow(abs(dot(normal, lightDir)), falloff)): `normal` — not the position angle — is what holds
730
+ // a long edge at constant intensity, and abs() is what lights BOTH light-axis lobes. `lobeDir`
731
+ // (MAIN_PROLOGUE, shared with the swirl) is `highlightDir` rotated +90 degrees, which is what
732
+ // lets `highlight.angle` keep its established meaning: the default 135 lights the top-left and
733
+ // bottom-right lobes. `highlightFalloff` reaches the GPU already floored at 0.01, so pow(0, 0)
734
+ // is unreachable.
735
+ //
736
+ // The rim is ADDED, not multiplied — that is what makes it read over a black backdrop — and it
737
+ // fades over its own `highlightWidth` (default 0.75 dp) rather than borrowing the 20 dp
738
+ // `refractionScale`. Kyant draws the same idea as a ~0.5 dp stroked layer at 0.38 alpha; this
739
+ // SDF band is the single-pass equivalent.
740
+ //
741
+ // Two companions, both measured off real iOS 26 screenshots (research/04-ios26-edge-evidence):
742
+ //
743
+ // `sheen` — the faint broad glow under the lit edges: same lobes, ~7 pt deep, ~0.18x the rim's
744
+ // weight (measured +13/255 over ~25 px at intensity-comparable defaults). This is what lets the
745
+ // crisp line drop to hairline width without the edge going dead.
746
+ //
747
+ // There is deliberately NO drawn dark line. One shipped for a single round as a multiplicative
748
+ // "flank contour" after a dark 1-2 px line was measured on a real icon's edges — then
749
+ // per-channel solves showed that line is the refraction FOLD imaging a dark stripe (achromatic,
750
+ // exactly backdrop-under-transfer where the true stripe is green: content, not ink;
751
+ // research/04, C21). Our profile folds the same way (|dD/dd| > 1 near the edge), so the look
752
+ // emerges from refraction alone; inking it on top double-darkens every strong edge.
753
+ // HDR: only the border light glints past SDR white. The interior is min()'d to 1.0 first —
754
+ // glass does not amplify what is behind it — and the rim's additive term scales by 75% of the
755
+ // available headroom (full headroom reads as a torch, not a glint; eye-tuned on the Nothing
756
+ // Phone (2)). The sheen stays SDR: it is a broad wash, and boosting it lifts whole quadrants.
757
+ // At hdrHeadroom == 1 every line below reduces to the pre-HDR build bit-for-bit: min(x, 1.0)
758
+ // followed by the epilogue clamp is the old single clamp, and the glint factor is 1.
759
+ private val HIGHLIGHT = """
760
+ float rim = pow(abs(dot(normal, lobeDir)), highlightFalloff);
761
+ float rimT = clamp(inside / max(highlightWidth, 1e-3), 0.0, 1.0);
762
+ float rimBand = 1.0 - smoothstep(0.0, 1.0, rimT);
763
+
764
+ float sheenT = clamp(inside / (7.0 * unitScale), 0.0, 1.0);
765
+ float sheen = 1.0 - smoothstep(0.0, 1.0, sheenT);
766
+
767
+ float glint = 1.0 + (hdrHeadroom - 1.0) * 0.75;
768
+
769
+ // The body of the glass may exceed SDR only through its own light: `lightIntensity`
770
+ // scales into the headroom, so LIT glass over a white backdrop genuinely brightens,
771
+ // while light = 0 keeps the interior pinned at SDR no matter the backdrop — glass does
772
+ // not amplify what it merely transmits.
773
+ color = min(color * (1.0 + lightIntensity * glint), hdrHeadroom);
774
+ color += rim * rimBand * highlightIntensity * glint;
775
+ color += rim * sheen * highlightIntensity * 0.18;
776
+
777
+ """.trimIndent().prependIndent(" ") + "\n"
778
+
779
+ // The inner shadow — Kyant's `InnerShadow` (Apache-2.0, see NOTICE), as an SDF band rather
780
+ // than a blurred layer: the shape minus itself translated by the cast offset, `S \ (S + o)`,
781
+ // blurred by the radius. Blur is linear and the blurred coverage of a set is a smoothstep of
782
+ // its SDF, so the band is ss(sd of S ∩ (S + o)) − ss(sd of S), with the intersection's field
783
+ // the max of the two. Offset (0, +r) shades the top inner edge: light from above, the pane's
784
+ // top lip casts inward. Evaluated on the MERGED field, so a morph partner shades as one piece.
785
+ // Applied after the border light, like Kyant's modifier order, and before the press glow.
786
+ // Metal: the innerShadow block.
787
+ private val INNER_SHADOW = """
788
+ if (innerShadowColor.a > 0.0 && innerShadowGeom.x > 0.0) {
789
+ float shadowR = innerShadowGeom.x;
790
+ float sdShifted = mergedSd(centered - innerShadowGeom.yz);
791
+ float shade = smoothstep(-shadowR, shadowR, max(sd, sdShifted))
792
+ - smoothstep(-shadowR, shadowR, sd);
793
+ color = mix(color, innerShadowColor.rgb, clamp(shade, 0.0, 1.0) * innerShadowColor.a);
794
+ }
795
+
796
+ """.trimIndent().prependIndent(" ") + "\n"
797
+
798
+ // The `interactive` press glow, per Kyant's InteractiveHighlight (Apache-2.0, see NOTICE): a
799
+ // flat 0.08 wash plus a 0.15 radial lobe, additive, radius 1.5x the view's min dimension, full
800
+ // strength inside half that radius. `pixels`, not fragCoord — same reasoning as GRAIN: the glow
801
+ // must not jump when the padding P changes mid-press (refraction props animating).
802
+ //
803
+ // The falloff is written `1.0 - smoothstep(lo, hi, d)`, NOT Kyant's `smoothstep(hi, lo, d)` —
804
+ // reversed edges are undefined in GLSL ES, and Mali is where "undefined" stops meaning
805
+ // "works anyway". The branch is uniform-coherent (GRAIN's pattern): free while idle, and it
806
+ // cannot be optimised out, which is what keeps both uniforms live in every tier.
807
+ //
808
+ // HDR: the SDR shimmer (flat 0.08 wash + Kyant's broad 0.15 lobe) is untouched — that lobe
809
+ // spans 1.5x the view at full strength across half of it, and scaling THAT by headroom washes
810
+ // the whole surface to white (shipped for one build; the user's finger found it in minutes).
811
+ // The headroom goes instead into a separate TIGHT core: ~90 dp reach, squared falloff — a
812
+ // fingertip-sized light igniting under the glass, absolute-sized because a finger is the same
813
+ // size on every view. At headroom 1 the core term is exactly zero: pre-HDR build, bit for bit.
814
+ private val TOUCH_GLOW_FRAGMENT = """
815
+ if (touchGlow > 0.0) {
816
+ float touchRadius = 1.5 * min(size.x, size.y);
817
+ float touchDist = distance(pixels, touchPos);
818
+ float touchFalloff = 1.0 - smoothstep(touchRadius * 0.5, touchRadius, touchDist);
819
+ color += (0.08 + 0.15 * touchFalloff) * touchGlow;
820
+
821
+ float hotFalloff = 1.0 - smoothstep(0.0, 90.0 * unitScale, touchDist);
822
+ color += 0.35 * (hdrHeadroom - 1.0) * hotFalloff * hotFalloff * touchGlow;
823
+ }
824
+
825
+ """.trimIndent().prependIndent(" ") + "\n"
826
+
827
+ // Metal :252-255. The narrowing to half is the last statement of the shader and is written as an
828
+ // explicit constructor — float -> half is not an implicit conversion in SkSL.
829
+ //
830
+ // The upper clamp is the HDR ceiling: 1.0 on an SDR window (identical to the Metal source), up
831
+ // to the display's live ratio on an opted-in HDR window. Values above 1 survive premultiply on
832
+ // the FP16 surface; on an SDR surface the uniform is pinned to 1 by the uploader, so nothing
833
+ // out of range is ever emitted there.
834
+ private val MAIN_EPILOGUE = """
835
+ color = clamp(color, 0.0, hdrHeadroom);
836
+
837
+ // `cover` (TONE_CHAIN) folds the backdrop's coverage in: where the provider recorded
838
+ // nothing — a small layer's margins, a capsule layer's corners, the gap between two cards
839
+ // an overhanging pane crosses — the glass stops *transmitting* and thins to its own frost
840
+ // and tint, instead of shading premultiplied black or vanishing outright.
841
+ float alpha = shapeAlpha * glassOpacity * cover;
842
+ return half4(color * alpha, alpha);
843
+ }
844
+ """.trimIndent() + "\n"
845
+ }