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,261 @@
1
+ import Metal
2
+ import UIKit
3
+
4
+ protocol GlassFrameParticipant: AnyObject {
5
+
6
+ var glassWindow: UIWindow? { get }
7
+
8
+ var glassRegionInWindow: CGRect? { get }
9
+
10
+ var glassBackdropPadding: CGFloat { get }
11
+
12
+ var glassCaptureScale: CGFloat { get }
13
+
14
+ func glassDrawRequest(backdrop: MTLTexture, captureScale: CGFloat, backdropDidChange: Bool)
15
+ -> GlassDrawRequest?
16
+ }
17
+
18
+ final class GlassFrameScheduler {
19
+
20
+ static let shared = GlassFrameScheduler()
21
+
22
+ private final class Weak {
23
+ weak var value: GlassFrameParticipant?
24
+ init(_ value: GlassFrameParticipant) { self.value = value }
25
+ }
26
+
27
+ private var participants: [Weak] = []
28
+ private var displayLink: CADisplayLink?
29
+ private var observer: CFRunLoopObserver?
30
+
31
+ private var batch: [GlassDrawRequest] = []
32
+
33
+ private var frameIsPending = false
34
+
35
+ private var backdropDidChange = false
36
+
37
+ private var lastSubmissionDropped = false
38
+
39
+ private var frameDuration: CFTimeInterval = 1.0 / 60.0
40
+
41
+ private var lastFrameTimestamp: CFTimeInterval = 0
42
+ private var isUnderLoad = false
43
+
44
+ private init() {}
45
+
46
+ func add(_ participant: GlassFrameParticipant) {
47
+ prune()
48
+ guard !participants.contains(where: { $0.value === participant }) else { return }
49
+ participants.append(Weak(participant))
50
+ start()
51
+ }
52
+
53
+ func remove(_ participant: GlassFrameParticipant) {
54
+ participants.removeAll { $0.value === participant || $0.value == nil }
55
+ stopIfIdle()
56
+ }
57
+
58
+ private func prune() {
59
+ participants.removeAll { $0.value == nil }
60
+ }
61
+
62
+ private func start() {
63
+ guard displayLink == nil else { return }
64
+
65
+ let link = CADisplayLink(target: self, selector: #selector(tick))
66
+ link.add(to: .main, forMode: .common)
67
+ displayLink = link
68
+
69
+ let observer = CFRunLoopObserverCreateWithHandler(
70
+ kCFAllocatorDefault,
71
+ CFRunLoopActivity.beforeWaiting.rawValue,
72
+ true,
73
+ 0
74
+ ) { [weak self] _, _ in
75
+ self?.gatherIfPending()
76
+ }
77
+
78
+ if let observer {
79
+ CFRunLoopAddObserver(CFRunLoopGetMain(), observer, .commonModes)
80
+ self.observer = observer
81
+ }
82
+ }
83
+
84
+ private func stopIfIdle() {
85
+ guard participants.isEmpty else { return }
86
+
87
+ displayLink?.invalidate()
88
+ displayLink = nil
89
+
90
+ if let observer {
91
+ CFRunLoopRemoveObserver(CFRunLoopGetMain(), observer, .commonModes)
92
+ }
93
+ observer = nil
94
+ frameIsPending = false
95
+ batch.removeAll(keepingCapacity: false)
96
+
97
+ BackdropCapturer.shared.releaseResources()
98
+ }
99
+
100
+ @objc private func tick(_ link: CADisplayLink) {
101
+ frameDuration = max(link.targetTimestamp - link.timestamp, 1.0 / 120.0)
102
+
103
+ let elapsed = link.timestamp - lastFrameTimestamp
104
+ isUnderLoad = lastFrameTimestamp > 0 && elapsed > frameDuration * 1.5
105
+ lastFrameTimestamp = link.timestamp
106
+
107
+ if frameIsPending { gather() }
108
+
109
+ prune()
110
+ guard !participants.isEmpty else { return }
111
+
112
+ backdropDidChange = captureBackdrop()
113
+ frameIsPending = true
114
+ }
115
+
116
+ /// Photographs the backdrop for this frame, in whichever scope the participants use.
117
+ ///
118
+ /// A participant inside a `GlassBackdrop` photographs the scroll content in content
119
+ /// coordinates and the static bands in window coordinates; everyone else keeps the
120
+ /// whole-window capture. When a strip is in service its scale owns the capture, because the
121
+ /// content band is composited into the capturer's texture with a blit and a blit cannot
122
+ /// resize.
123
+ private func captureBackdrop() -> Bool {
124
+
125
+ var region: CGRect = .null
126
+ var window: UIWindow?
127
+ var scale: CGFloat = 1
128
+ var stripScope: StripScope?
129
+
130
+ for entry in participants {
131
+ guard let participant = entry.value,
132
+ let frame = participant.glassRegionInWindow
133
+ else { continue }
134
+ window = window ?? participant.glassWindow
135
+ let padding = participant.glassBackdropPadding
136
+ let padded = frame.insetBy(dx: -padding, dy: -padding)
137
+ region = region.isNull ? padded : region.union(padded)
138
+ scale = max(scale, participant.glassCaptureScale)
139
+
140
+ if stripScope == nil,
141
+ let view = participant as? UIView,
142
+ let provider = GlassBackdropRegistry.shared.nearestProvider(for: view),
143
+ let scroll = provider.resolveScrollView(),
144
+ let content = provider.resolveContentContainer(),
145
+ let cache = provider.stripCache(for: scroll) {
146
+ let offset = GlassFramePhase.presentedOffsetY(of: scroll)
147
+ if let served = cache.sync(
148
+ scrollView: scroll,
149
+ content: content,
150
+ offsetY: offset,
151
+ contentHeight: scroll.contentSize.height,
152
+ scale: provider.stripScale
153
+ ) {
154
+ stripScope = StripScope(
155
+ cache: cache,
156
+ provider: provider,
157
+ scrollView: scroll,
158
+ servedOffsetY: served
159
+ )
160
+ scale = cache.scale
161
+ } else {
162
+ provider.reportUnusable(true)
163
+ }
164
+ }
165
+ }
166
+
167
+ guard !region.isNull, let window else { return false }
168
+
169
+ let stripActive = stripScope != nil
170
+ if stripActive {
171
+ GlassFramePhase.beginTransactionalPresentation(in: window)
172
+ } else {
173
+ GlassFramePhase.endTransactionalPresentation(in: window)
174
+ }
175
+
176
+ let didCapture = GlassFramePhase.signpostResult("captureBackdrop") {
177
+ BackdropCapturer.shared.capture(
178
+ window: window,
179
+ region: region,
180
+ scale: scale,
181
+ frameDuration: frameDuration,
182
+ isUnderLoad: isUnderLoad,
183
+ // A strip only replaces the content band; the static bands above and below it
184
+ // must still be fresh, so their capture is not gated by the movement margin.
185
+ ignoreMovementGate: stripActive
186
+ )
187
+ }
188
+
189
+ guard let scope = stripScope, let texture = BackdropCapturer.shared.texture else {
190
+ return didCapture
191
+ }
192
+
193
+ let presented = GlassFramePhase.presentedFrame(of: scope.scrollView, in: window)
194
+ let composited = scope.cache.composite(
195
+ into: texture,
196
+ scrollFrame: presented,
197
+ capturedOrigin: BackdropCapturer.shared.capturedOrigin,
198
+ contentOffsetY: scope.servedOffsetY
199
+ )
200
+
201
+ if composited {
202
+ scope.provider.reportUnusable(false)
203
+ } else {
204
+ // The ring could not serve the band. The capture that just ran holds the true band
205
+ // for this frame, so nothing is stale yet — but the next frame needs rows, so the
206
+ // cache re-seeds rather than continuing to composite a hole.
207
+ scope.cache.invalidateAll()
208
+ }
209
+
210
+ if didCapture {
211
+ scope.cache.validate(
212
+ against: texture,
213
+ scrollFrame: presented,
214
+ capturedOrigin: BackdropCapturer.shared.capturedOrigin,
215
+ contentOffsetY: scope.servedOffsetY
216
+ )
217
+ }
218
+
219
+ return didCapture
220
+ }
221
+
222
+ /// The one strip scope this frame serves. Only the first is tracked: two independently
223
+ /// scrolling documents under one glass is a nested-scroller case the strip model does not
224
+ /// claim, and the second scope keeps the window capture.
225
+ private struct StripScope {
226
+ let cache: StripCache
227
+ let provider: GlassBackdropView
228
+ let scrollView: UIScrollView
229
+ let servedOffsetY: CGFloat
230
+ }
231
+
232
+ private func gatherIfPending() {
233
+ guard frameIsPending else { return }
234
+ frameIsPending = false
235
+ gather()
236
+ }
237
+
238
+ private func gather() {
239
+ let capturer = BackdropCapturer.shared
240
+ guard let backdrop = capturer.texture else { return }
241
+
242
+ let changed = backdropDidChange || lastSubmissionDropped
243
+ backdropDidChange = false
244
+
245
+ let scale = capturer.textureScale
246
+ batch.removeAll(keepingCapacity: true)
247
+
248
+ for entry in participants {
249
+ guard let participant = entry.value,
250
+ let request = participant.glassDrawRequest(
251
+ backdrop: backdrop,
252
+ captureScale: scale,
253
+ backdropDidChange: changed
254
+ )
255
+ else { continue }
256
+ batch.append(request)
257
+ }
258
+
259
+ lastSubmissionDropped = !GlassRenderer.shared.submit(batch)
260
+ }
261
+ }
@@ -0,0 +1,250 @@
1
+ import QuartzCore
2
+ import UIKit
3
+
4
+ /// The spring choreography behind `interactive` on the Metal path — the Swift twin of the Android
5
+ /// `GlassPressAnimator.kt`, same model and constants: a glow that rises on press and chases the
6
+ /// finger, a subtle whole-view inflation, and the jelly — a rubber-band translation and an
7
+ /// anisotropic stretch, both pure functions of one spring-smoothed drag displacement. Values are
8
+ /// read back by the host on every animation frame; this class never touches uniforms or
9
+ /// transforms itself.
10
+ ///
11
+ /// Model and constants are Kyant's (InteractiveHighlight / LiquidButton / DampedDragAnimation,
12
+ /// Apache-2.0 — see NOTICE): glow ζ 0.5 / k 300; position ζ 1.0 / k 1000 while tracking the
13
+ /// finger and ζ 0.5 / k 300 for the release return; scale ζ 0.65 / k 250. Tracking is critically
14
+ /// damped (lag, never ring); only the way home is bouncy — running the release spec during the
15
+ /// drag made X and Y ring independently on every direction change and read as a wobble.
16
+ ///
17
+ /// The jelly is displacement-based, not velocity-based: translation saturates through tanh
18
+ /// (linear for small pulls, asymptoting at the view's min dimension), and stretch grows along
19
+ /// the displacement's dominant axis, axis-projected so it turns continuously with the drag and
20
+ /// never compresses. Deriving follow, stretch and hotspot from the single smoothed displacement
21
+ /// is what keeps the release coherent — one spring decays and everything settles together.
22
+ ///
23
+ /// Integration is semi-implicit Euler with the dt clamp below (the stiff tracking spring has
24
+ /// ω₀ ≈ 31.6/s; a 32 ms step puts ω₀·dt ≈ 1.0, inside the method's stability bound of 2, with
25
+ /// critical damping on top). The driver is a `CADisplayLink` that exists only while a spring is
26
+ /// unsettled — nothing is scheduled once everything has settled, and a drag held at a fixed
27
+ /// displacement costs no frames. The link retains this object (its target), so a press that is
28
+ /// mid-flight when the host goes away finishes on a dead host and tears itself down.
29
+ /// An `NSObject` because `CADisplayLink` dispatches its selector through the Objective-C runtime.
30
+ final class GlassPressAnimator: NSObject {
31
+
32
+ /// 0 at rest — which is what keeps the shader's uniform-coherent glow branch switched off.
33
+ var glow: CGFloat { min(max(glowSpring.value, 0), 1) }
34
+
35
+ /// Touch position, view-local points — the same space the shader's `pixels` lives in.
36
+ var posX: CGFloat { xSpring.value }
37
+ var posY: CGFloat { ySpring.value }
38
+
39
+ /// Relative scale for the host to apply; floored away from singularity.
40
+ var scale: CGFloat { max(scaleSpring.value, Tuning.scaleFloor) }
41
+
42
+ /// The magnetic follow: the drag displacement through a saturating tanh — an initial
43
+ /// `followSlope` fraction of the pull that asymptotes at the view's min dimension, so a
44
+ /// cross-screen drag meets growing rubber-band resistance instead of a hard stop. Springs
45
+ /// back to zero on release because `releasePress` retargets the position springs at the
46
+ /// origin.
47
+ var followX: CGFloat { follow(xSpring.value - originX) }
48
+ var followY: CGFloat { follow(ySpring.value - originY) }
49
+
50
+ /// The jelly stretch, ≥ 1 per axis: `stretchMax` scaled by the displacement's projection
51
+ /// onto the axis (|d·cos θ| = dx²/r — continuous through every drag direction), normalized by
52
+ /// the view's max dimension, with the aspect correction so a wide view does not stretch
53
+ /// further along its long side. The across axis is left alone — the stretch never
54
+ /// compresses.
55
+ var stretchX: CGFloat {
56
+ 1 + stretchGain(along: xSpring.value - originX, across: ySpring.value - originY,
57
+ alongSize: hostSize.width, acrossSize: hostSize.height)
58
+ }
59
+ var stretchY: CGFloat {
60
+ 1 + stretchGain(along: ySpring.value - originY, across: xSpring.value - originX,
61
+ alongSize: hostSize.height, acrossSize: hostSize.width)
62
+ }
63
+
64
+ private weak var host: UIView?
65
+ private let onFrame: () -> Void
66
+
67
+ private var glowSpring = Spring(0, stiffness: 300, dampingRatio: 0.5, eps: 0.001, epsV: 0.01)
68
+ private var xSpring = Spring(0, stiffness: Tuning.trackStiffness, dampingRatio: Tuning.trackDamping, eps: 0.25, epsV: 2.5)
69
+ private var ySpring = Spring(0, stiffness: Tuning.trackStiffness, dampingRatio: Tuning.trackDamping, eps: 0.25, epsV: 2.5)
70
+ private var scaleSpring = Spring(1, stiffness: 250, dampingRatio: 0.65, eps: 0.001, epsV: 0.01)
71
+
72
+ private var originX: CGFloat = 0
73
+ private var originY: CGFloat = 0
74
+
75
+ private var displayLink: CADisplayLink?
76
+ private var lastTimestamp: CFTimeInterval = 0
77
+
78
+ init(host: UIView, onFrame: @escaping () -> Void) {
79
+ self.host = host
80
+ self.onFrame = onFrame
81
+ super.init()
82
+ }
83
+
84
+ deinit {
85
+ displayLink?.invalidate()
86
+ }
87
+
88
+ private var hostSize: CGSize { host?.bounds.size ?? .zero }
89
+
90
+ private func follow(_ offset: CGFloat) -> CGFloat {
91
+ let maxOffset = min(hostSize.width, hostSize.height)
92
+ if maxOffset < 1 { return 0 }
93
+ return maxOffset * tanh(Tuning.followSlope * offset / maxOffset)
94
+ }
95
+
96
+ private func stretchGain(along: CGFloat, across: CGFloat, alongSize: CGFloat, acrossSize: CGFloat) -> CGFloat {
97
+ if alongSize < 1 || acrossSize < 1 { return 0 }
98
+ let r = (along * along + across * across).squareRoot()
99
+ if r < 1 { return 0 }
100
+ let maxDim = max(alongSize, acrossSize)
101
+ let aspect = min(alongSize / acrossSize, 1)
102
+ return Tuning.stretchMax * min((along * along / r) / maxDim, 1) * aspect
103
+ }
104
+
105
+ /// Position snaps to the touch — the glow must bloom under the finger, not glide in.
106
+ func pressDown(x: CGFloat, y: CGFloat) {
107
+ originX = x
108
+ originY = y
109
+ xSpring.retune(stiffness: Tuning.trackStiffness, dampingRatio: Tuning.trackDamping)
110
+ ySpring.retune(stiffness: Tuning.trackStiffness, dampingRatio: Tuning.trackDamping)
111
+ xSpring.snap(to: x)
112
+ ySpring.snap(to: y)
113
+ glowSpring.target = 1
114
+ scaleSpring.target = Tuning.pressScale
115
+ start()
116
+ }
117
+
118
+ func follow(x: CGFloat, y: CGFloat) {
119
+ xSpring.target = x
120
+ ySpring.target = y
121
+ start()
122
+ }
123
+
124
+ /// Ended and cancelled both land here. The position springs retune to the underdamped
125
+ /// return spec and retarget the press origin — the one deliberate bounce, coherent because
126
+ /// follow, stretch and hotspot all read this same decaying displacement.
127
+ func releasePress() {
128
+ glowSpring.target = 0
129
+ scaleSpring.target = 1
130
+ xSpring.retune(stiffness: Tuning.homeStiffness, dampingRatio: Tuning.homeDamping)
131
+ ySpring.retune(stiffness: Tuning.homeStiffness, dampingRatio: Tuning.homeDamping)
132
+ xSpring.target = originX
133
+ ySpring.target = originY
134
+ start()
135
+ }
136
+
137
+ /// Hard stop: everything to rest instantly, and no frame left scheduled.
138
+ func reset() {
139
+ stop()
140
+ glowSpring.snap(to: 0)
141
+ scaleSpring.snap(to: 1)
142
+ xSpring.snap(to: xSpring.value)
143
+ ySpring.snap(to: ySpring.value)
144
+ // Follow and stretch read (pos - origin): collapsing the origin onto the position zeroes both.
145
+ originX = xSpring.value
146
+ originY = ySpring.value
147
+ }
148
+
149
+ private func start() {
150
+ guard displayLink == nil else { return }
151
+ let link = CADisplayLink(target: self, selector: #selector(step(_:)))
152
+ link.add(to: .main, forMode: .common)
153
+ displayLink = link
154
+ lastTimestamp = CACurrentMediaTime()
155
+ }
156
+
157
+ private func stop() {
158
+ displayLink?.invalidate()
159
+ displayLink = nil
160
+ }
161
+
162
+ @objc private func step(_ link: CADisplayLink) {
163
+ guard host != nil, host?.window != nil else {
164
+ stop()
165
+ return
166
+ }
167
+ let now = link.timestamp
168
+ // Clamped so a stalled window (app switch, expensive frame) cannot integrate a huge step.
169
+ let dt = CGFloat(min(max(now - lastTimestamp, 0), Tuning.maxStepSeconds))
170
+ lastTimestamp = now
171
+
172
+ glowSpring.step(dt)
173
+ xSpring.step(dt)
174
+ ySpring.step(dt)
175
+ scaleSpring.step(dt)
176
+
177
+ let done = glowSpring.settled && xSpring.settled && ySpring.settled && scaleSpring.settled
178
+ if done {
179
+ // Snap and push one final frame so the glow lands at exactly 0 and the branch turns off.
180
+ glowSpring.snap()
181
+ xSpring.snap()
182
+ ySpring.snap()
183
+ scaleSpring.snap()
184
+ stop()
185
+ }
186
+ onFrame()
187
+ }
188
+
189
+ private struct Spring {
190
+ var value: CGFloat
191
+ var target: CGFloat
192
+ var velocity: CGFloat = 0
193
+ private var stiffness: CGFloat = 0
194
+ private var damping: CGFloat = 0
195
+ private let eps: CGFloat
196
+ private let epsV: CGFloat
197
+
198
+ init(_ initial: CGFloat, stiffness: CGFloat, dampingRatio: CGFloat, eps: CGFloat, epsV: CGFloat) {
199
+ value = initial
200
+ target = initial
201
+ self.eps = eps
202
+ self.epsV = epsV
203
+ retune(stiffness: stiffness, dampingRatio: dampingRatio)
204
+ }
205
+
206
+ mutating func retune(stiffness: CGFloat, dampingRatio: CGFloat) {
207
+ self.stiffness = stiffness
208
+ damping = 2 * dampingRatio * stiffness.squareRoot()
209
+ }
210
+
211
+ mutating func step(_ dt: CGFloat) {
212
+ velocity += (-stiffness * (value - target) - damping * velocity) * dt
213
+ value += velocity * dt
214
+ }
215
+
216
+ var settled: Bool { abs(value - target) < eps && abs(velocity) < epsV }
217
+
218
+ mutating func snap() {
219
+ value = target
220
+ velocity = 0
221
+ }
222
+
223
+ mutating func snap(to v: CGFloat) {
224
+ value = v
225
+ target = v
226
+ velocity = 0
227
+ }
228
+ }
229
+
230
+ private enum Tuning {
231
+ /// iOS's press inflation is subtle; the kit layers bigger scales on top.
232
+ static let pressScale: CGFloat = 1.035
233
+ static let scaleFloor: CGFloat = 0.9
234
+ static let maxStepSeconds: CFTimeInterval = 0.032
235
+
236
+ /// Tracking the finger: critically damped and stiff — liquid lag, never a ring.
237
+ static let trackStiffness: CGFloat = 1000
238
+ static let trackDamping: CGFloat = 1
239
+
240
+ /// The way home after release: Kyant's return spec — underdamped, the one deliberate bounce.
241
+ static let homeStiffness: CGFloat = 300
242
+ static let homeDamping: CGFloat = 0.5
243
+
244
+ /// Initial fraction of the pull the view follows; tanh saturates it at the view's min dimension.
245
+ static let followSlope: CGFloat = 0.12
246
+
247
+ /// Stretch gain at a full-max-dimension displacement along an axis, before aspect correction.
248
+ static let stretchMax: CGFloat = 0.12
249
+ }
250
+ }
@@ -0,0 +1,168 @@
1
+ import Metal
2
+ import simd
3
+
4
+ // Mirrors the Metal struct exactly (float4, float4, 3 x float2, 2 x float = 64 bytes, naturally
5
+ // aligned on both sides). Reorder one side and the blur reads garbage.
6
+ struct BlurParams {
7
+ var uvRect: SIMD4<Float>
8
+ var rampLine: SIMD4<Float>
9
+ var rampRadii: SIMD2<Float>
10
+ var paddedSize: SIMD2<Float>
11
+ var texelStep: SIMD2<Float>
12
+ var radius: Float
13
+ var padding: Float
14
+ }
15
+
16
+ // Field order and types mirror the Metal struct exactly — eight float4s, then seven float2s,
17
+ // then seventeen floats. Every member is naturally aligned in both layouts, so neither compiler
18
+ // inserts interior padding and every offset agrees; both pad the tail to 256 bytes. Reorder one
19
+ // side and the shader reads garbage. `docs/inspiration-port/tools/check-params-layout.py`
20
+ // computes both layouts from the two source files and fails on any disagreement — run it after
21
+ // touching either struct.
22
+ struct GlassParams {
23
+ var cornerExtents: SIMD4<Float>
24
+ var cornerShapes: SIMD4<Float>
25
+ var tintColor: SIMD4<Float>
26
+ var frostColor: SIMD4<Float>
27
+ var sourceRect: SIMD4<Float>
28
+ var morphRect: SIMD4<Float>
29
+ var innerShadow: SIMD4<Float>
30
+ var touch: SIMD4<Float>
31
+ var morphShape: SIMD2<Float>
32
+ var viewSize: SIMD2<Float>
33
+ var shapeSize: SIMD2<Float>
34
+ var shapeOffset: SIMD2<Float>
35
+ var refractionScale: SIMD2<Float>
36
+ var highlightDir: SIMD2<Float>
37
+ var innerShadowOffset: SIMD2<Float>
38
+ var refractionAmount: Float
39
+ var refractionSwirl: Float
40
+ var depthEffect: Float
41
+ var profilePower: Float
42
+ var profileBias: Float
43
+ var dispersionHeight: Float
44
+ var dispersionAmount: Float
45
+ var dispersionQuadrant: Float
46
+ var highlightIntensity: Float
47
+ var highlightWidth: Float
48
+ var highlightFalloff: Float
49
+ var lightIntensity: Float
50
+ var glassOpacity: Float
51
+ var saturation: Float
52
+ var noiseAmount: Float
53
+ var innerShadowRadius: Float
54
+ var magnification: Float
55
+ }
56
+
57
+ final class GlassRenderContext {
58
+
59
+ static let shared: GlassRenderContext? = GlassRenderContext()
60
+
61
+ let device: MTLDevice
62
+ let commandQueue: MTLCommandQueue
63
+ let blurPipeline: MTLRenderPipelineState
64
+ let glassPipeline: MTLRenderPipelineState
65
+
66
+ let quadBuffer: MTLBuffer
67
+
68
+ let linearTextureAlignment: Int
69
+
70
+ private init?() {
71
+ guard let device = MTLCreateSystemDefaultDevice(),
72
+ let commandQueue = device.makeCommandQueue(),
73
+ let library = Self.loadShaderLibrary(device: device)
74
+ else { return nil }
75
+
76
+ let quad: [SIMD4<Float>] = [
77
+ SIMD4(-1, -1, 0, 1),
78
+ SIMD4( 1, -1, 1, 1),
79
+ SIMD4(-1, 1, 0, 0),
80
+ SIMD4( 1, 1, 1, 0),
81
+ ]
82
+ guard let quadBuffer = device.makeBuffer(
83
+ bytes: quad,
84
+ length: MemoryLayout<SIMD4<Float>>.stride * quad.count,
85
+ options: .storageModeShared
86
+ ) else { return nil }
87
+
88
+ func pipeline(fragment: String) -> MTLRenderPipelineState? {
89
+ let descriptor = MTLRenderPipelineDescriptor()
90
+ descriptor.label = fragment
91
+ descriptor.vertexFunction = library.makeFunction(name: "liquid_glass_vertex")
92
+ descriptor.fragmentFunction = library.makeFunction(name: fragment)
93
+ descriptor.colorAttachments[0].pixelFormat = .bgra8Unorm
94
+
95
+ return try? device.makeRenderPipelineState(descriptor: descriptor)
96
+ }
97
+
98
+ guard let blurPipeline = pipeline(fragment: "blurFragment"),
99
+ let glassPipeline = pipeline(fragment: "glassFragment")
100
+ else { return nil }
101
+
102
+ self.device = device
103
+ self.commandQueue = commandQueue
104
+ self.blurPipeline = blurPipeline
105
+ self.glassPipeline = glassPipeline
106
+ self.quadBuffer = quadBuffer
107
+ self.linearTextureAlignment = max(
108
+ device.minimumLinearTextureAlignment(for: .bgra8Unorm),
109
+ MemoryLayout<UInt32>.alignment
110
+ )
111
+
112
+ commandQueue.label = "ExpoLiquidGlass"
113
+ }
114
+
115
+ private static func loadShaderLibrary(device: MTLDevice) -> MTLLibrary? {
116
+ let base = Bundle(for: GlassRenderContext.self)
117
+
118
+ if let url = base.url(forResource: "ExpoLiquidGlassShaders", withExtension: "bundle"),
119
+ let nested = Bundle(url: url),
120
+ let library = try? device.makeDefaultLibrary(bundle: nested) {
121
+ return library
122
+ }
123
+
124
+ return try? device.makeDefaultLibrary(bundle: base)
125
+ }
126
+
127
+ func makeRenderTarget(width: Int, height: Int, label: String) -> MTLTexture? {
128
+ let descriptor = MTLTextureDescriptor.texture2DDescriptor(
129
+ pixelFormat: .bgra8Unorm,
130
+ width: max(width, 1),
131
+ height: max(height, 1),
132
+ mipmapped: false
133
+ )
134
+ descriptor.usage = [.renderTarget, .shaderRead]
135
+ descriptor.storageMode = .private
136
+ let texture = device.makeTexture(descriptor: descriptor)
137
+ texture?.label = label
138
+ return texture
139
+ }
140
+
141
+ func encodeQuad(
142
+ into commandBuffer: MTLCommandBuffer,
143
+ descriptor: MTLRenderPassDescriptor,
144
+ pipeline: MTLRenderPipelineState,
145
+ source: MTLTexture,
146
+ params: UnsafeRawPointer,
147
+ length: Int,
148
+ label: String
149
+ ) {
150
+ guard let encoder = commandBuffer.makeRenderCommandEncoder(descriptor: descriptor) else { return }
151
+ encoder.label = label
152
+ encoder.setRenderPipelineState(pipeline)
153
+ encoder.setVertexBuffer(quadBuffer, offset: 0, index: 0)
154
+ encoder.setFragmentTexture(source, index: 0)
155
+ encoder.setFragmentBytes(params, length: length, index: 1)
156
+ encoder.drawPrimitives(type: .triangleStrip, vertexStart: 0, vertexCount: 4)
157
+ encoder.endEncoding()
158
+ }
159
+
160
+ static func offscreenPass(target: MTLTexture) -> MTLRenderPassDescriptor {
161
+ let descriptor = MTLRenderPassDescriptor()
162
+ descriptor.colorAttachments[0].texture = target
163
+ descriptor.colorAttachments[0].loadAction = .clear
164
+ descriptor.colorAttachments[0].storeAction = .store
165
+ descriptor.colorAttachments[0].clearColor = MTLClearColorMake(0, 0, 0, 0)
166
+ return descriptor
167
+ }
168
+ }