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,545 @@
1
+ import Metal
2
+ import QuartzCore
3
+ import UIKit
4
+ import os
5
+
6
+ // =============================================================================================
7
+ // StripCache — the Metal tier photographs scroll content in CONTENT coordinates.
8
+ //
9
+ // The window capture answers "what is at window (x, y) right now?". For scrolling content that
10
+ // question is only true for one frame, and the capture governor deliberately skips frames while
11
+ // the region moves, so a dragged pane refracts a still photograph of where the list used to be.
12
+ // This cache replaces the content band with a ring buffer in the scroll view's own coordinate
13
+ // space: rows are rasterised once as they come into view and re-composited every frame at the
14
+ // presented content offset. Cost scales with how many NEW rows a frame exposes, not with the
15
+ // size of the glass or the length of the content.
16
+ //
17
+ // What the cache is not: it cannot see sticky headers that move in window space at a different
18
+ // rate, parallax layers driven by their own transforms, nested scrollers, video or Lottie frames
19
+ // that redraw without changing geometry, or images that arrive asynchronously. Those are the
20
+ // honest degradations. `fingerprint` catches the cheap ones (a subtree whose shape or transform
21
+ // changed since its rows were drawn) and reports the cache untrustworthy; the scheduler then
22
+ // falls back to the improved governor — low-resolution band captures during motion, one sharp
23
+ // capture on settle — and takes the cache back only once the fingerprint settles again.
24
+ //
25
+ // Ring addressing: row y in content space lives at pixel row `(y * scale) mod ringPixelHeight`,
26
+ // which is `fract(contentY / stripHeight)` in the shader's language. The cache does the wrap in
27
+ // the blit instead: up to two source rectangles per frame, so the lens shader is untouched and
28
+ // the backdrop texture keeps its window-space `uvRect` contract.
29
+ // =============================================================================================
30
+
31
+ final class StripCache {
32
+
33
+ private enum Tuning {
34
+
35
+ /// The band the cache keeps beyond the viewport on each side: the largest blur radius
36
+ /// the glass can ask for plus the largest refraction/dispersion displacement, so a lens
37
+ /// near the edge never reads a row that has scrolled out of the ring.
38
+ static let refractionHeadroom: CGFloat = 48
39
+
40
+ /// Velocity lookahead, seconds. At 1,500 pt/s this is 25 pt — one 60 Hz frame — of rows
41
+ /// the cache keeps ahead of the presented offset, so a fling never outruns it.
42
+ static let lookahead: CFTimeInterval = 1.0 / 60.0
43
+
44
+ /// The ring never shrinks below this many points of content, and never exceeds the
45
+ /// cap: past it the band is too tall to keep coherent and the window capture is honest.
46
+ static let minimumStripHeight: CGFloat = 512
47
+ static let maximumStripHeight: CGFloat = 4096
48
+
49
+ /// Rows allowed in one frame before the cache gives up and re-rasterises the visible
50
+ /// band only. This is the "cost scales with scroll speed" ceiling: a fast fling past a
51
+ /// gap does not get to rerasterise the whole ring in one frame.
52
+ static let maximumRowsPerFrame = 1_200
53
+
54
+ /// A fingerprint mismatch inside this window keeps the cache distrusted; after it the
55
+ /// cache is re-seeded from the render tree.
56
+ static let distrustDuration: CFTimeInterval = 1.0
57
+
58
+ /// Luminance cells per axis for the validator. Matches the capturer's grid so the two
59
+ /// compare like for like.
60
+ static let validationGrid = 12
61
+
62
+ /// Mean luminance difference (0...1) above which the strip and a fresh window capture
63
+ /// disagree about the same band, and the cache is no longer trusted.
64
+ static let validationTolerance: Double = 0.12
65
+ }
66
+
67
+ private let device: MTLDevice
68
+ private let queue: MTLCommandQueue?
69
+
70
+ private(set) var texture: MTLTexture?
71
+
72
+ /// Scale at which the ring is rasterised. The window capture must run at the same scale
73
+ /// while a strip is active, or the composite cannot be a blit.
74
+ private(set) var scale: CGFloat = 2
75
+
76
+ /// Height of the ring in points. `fract(contentY / stripHeight)` must use this number.
77
+ private(set) var stripHeight: CGFloat = Tuning.minimumStripHeight
78
+
79
+ private var ringHeightPixels = 0
80
+ private var widthPixels = 0
81
+
82
+ /// The content-Y range currently valid in the ring. Not wrapped for the caller: these are
83
+ /// content coordinates, and the modulo happens at upload and composite time.
84
+ private var validMin: CGFloat = 0
85
+ private var validMax: CGFloat = 0
86
+ private var hasContent = false
87
+
88
+ /// Fingerprint of the render tree at the time the valid rows were drawn.
89
+ private var fingerprint: UInt64 = 0
90
+ private var distrustUntil: CFTimeInterval = 0
91
+
92
+ /// Diagnostics for the report: rows rasterised this frame and total, and the ring's
93
+ /// occupancy. Read only under `EXPO_LIQUID_GLASS_DEBUG`.
94
+ private(set) var lastRasterisedRows = 0
95
+ private(set) var lastCompositeWasBlit = false
96
+
97
+ private static let log = OSLog(subsystem: "com.glacia.glass", category: "StripCache")
98
+
99
+ init?(device: MTLDevice) {
100
+ guard let queue = device.makeCommandQueue() else { return nil }
101
+ queue.label = "GlaciaStripComposite"
102
+ self.device = device
103
+ self.queue = queue
104
+ }
105
+
106
+ // ----------------------------------------------------------------------------------- layout
107
+
108
+ /// Sizes the ring to the scroll view and its viewport.
109
+ ///
110
+ /// Returns false when the content is too short to need a ring (the window capture is
111
+ /// already exact for a list that does not move), and marks itself unusable when the band
112
+ /// would exceed the cap — an extremely tall glass over a short viewport.
113
+ @discardableResult
114
+ func layout(scrollView: UIScrollView, scale: CGFloat) -> Bool {
115
+ let viewport = scrollView.bounds.height
116
+ guard viewport > 1, scrollView.contentSize.height > 1 else { return false }
117
+
118
+ let headroom = Tuning.refractionHeadroom + viewport * CGFloat(Tuning.lookahead)
119
+ let wanted = min(
120
+ max(viewport + headroom * 2, Tuning.minimumStripHeight),
121
+ Tuning.maximumStripHeight
122
+ )
123
+ let height = min(wanted, scrollView.contentSize.height)
124
+ let width = scrollView.bounds.width
125
+
126
+ guard width > 1, height > 1 else { return false }
127
+
128
+ let widthPixels = Int((width * scale).rounded(.up))
129
+ let ringPixels = Int((height * scale).rounded(.up))
130
+ if widthPixels == self.widthPixels,
131
+ ringPixels == ringHeightPixels,
132
+ abs(scale - self.scale) < 0.01,
133
+ texture != nil {
134
+ return true
135
+ }
136
+
137
+ guard widthPixels > 0, ringPixels > 0,
138
+ widthPixels * ringPixels <= 8_192 * 8_192
139
+ else {
140
+ invalidateAll()
141
+ return false
142
+ }
143
+
144
+ let descriptor = MTLTextureDescriptor.texture2DDescriptor(
145
+ pixelFormat: .bgra8Unorm,
146
+ width: widthPixels,
147
+ height: ringPixels,
148
+ mipmapped: false
149
+ )
150
+ descriptor.usage = [.shaderRead]
151
+ // Shared storage: the rows arrive from CGContext on the CPU and are uploaded with
152
+ // replace(region:). Private storage would need a staging buffer per upload for no gain
153
+ // at these sizes (≤ 8 MB).
154
+ descriptor.storageMode = .shared
155
+
156
+ guard let texture = device.makeTexture(descriptor: descriptor) else {
157
+ invalidateAll()
158
+ return false
159
+ }
160
+ texture.label = "GlaciaStrip"
161
+
162
+ self.texture = texture
163
+ self.scale = scale
164
+ self.stripHeight = height
165
+ self.ringHeightPixels = ringPixels
166
+ self.widthPixels = widthPixels
167
+ invalidateAll()
168
+ return true
169
+ }
170
+
171
+ /// True when the ring holds rows that a lens at `contentY` can read.
172
+ func covers(_ contentY: CGFloat, height: CGFloat) -> Bool {
173
+ guard hasContent, texture != nil else { return false }
174
+ let top = contentY
175
+ let bottom = contentY + height
176
+ return top >= validMin - 0.5 && bottom <= validMax + 0.5
177
+ }
178
+
179
+ /// True while a fingerprint mismatch has forced the cache out of service.
180
+ var isDistrusted: Bool { CACurrentMediaTime() < distrustUntil }
181
+
182
+ func distrust() {
183
+ distrustUntil = CACurrentMediaTime() + Tuning.distrustDuration
184
+ hasContent = false
185
+ }
186
+
187
+ // ---------------------------------------------------------------------------------- capture
188
+
189
+ /// Brings the ring up to the rows this frame needs, in content coordinates.
190
+ ///
191
+ /// Rasterises only the newly exposed intervals. Returns the presented content offset the
192
+ /// composite should use, or nil when the caller must fall back to the window capture.
193
+ func sync(
194
+ scrollView: UIScrollView,
195
+ content: UIView,
196
+ offsetY: CGFloat,
197
+ contentHeight: CGFloat,
198
+ scale: CGFloat
199
+ ) -> CGFloat? {
200
+ os_signpost(.begin, log: Self.log, name: "stripSync")
201
+
202
+ defer { os_signpost(.end, log: Self.log, name: "stripSync") }
203
+
204
+ guard layout(scrollView: scrollView, scale: scale) else { return nil }
205
+ guard let texture else { return nil }
206
+
207
+ let viewport = scrollView.bounds.height
208
+ let wantedMin = max(0, offsetY - Tuning.refractionHeadroom)
209
+ let wantedMax = min(contentHeight, offsetY + viewport + Tuning.refractionHeadroom)
210
+
211
+ // A jump larger than the ring, or a content size change, leaves the ring describing a
212
+ // document that no longer exists. Re-seed rather than splice.
213
+ if hasContent, wantedMin > validMax || wantedMax < validMin {
214
+ hasContent = false
215
+ }
216
+
217
+ let nextFingerprint = Self.fingerprint(of: content)
218
+ if hasContent, nextFingerprint != fingerprint { distrust() }
219
+ fingerprint = nextFingerprint
220
+
221
+ guard !isDistrusted else { return nil }
222
+
223
+ if !hasContent {
224
+ hasContent = true
225
+ validMin = wantedMin
226
+ validMax = wantedMin
227
+ }
228
+
229
+ let advanceFrom = min(validMax, wantedMax)
230
+ if wantedMax > advanceFrom {
231
+ let height = wantedMax - advanceFrom
232
+ guard height * scale <= CGFloat(Tuning.maximumRowsPerFrame) else {
233
+ // Too much new content in one frame: draw the visible band, leave the rest to
234
+ // the next frames. The lens only reads the band it covers, so this is a cost
235
+ // ceiling, not a correctness hole.
236
+ let bandMin = max(0, offsetY)
237
+ let bandMax = min(contentHeight, offsetY + viewport)
238
+ guard rasterise(
239
+ content: content,
240
+ from: bandMin,
241
+ to: bandMax,
242
+ texture: texture,
243
+ scrollView: scrollView
244
+ ) else {
245
+ distrust()
246
+ return nil
247
+ }
248
+ validMin = bandMin
249
+ validMax = bandMax
250
+ lastRasterisedRows = Int((bandMax - bandMin) * scale)
251
+ return offsetY
252
+ }
253
+
254
+ guard rasterise(
255
+ content: content,
256
+ from: advanceFrom,
257
+ to: wantedMax,
258
+ texture: texture,
259
+ scrollView: scrollView
260
+ ) else {
261
+ distrust()
262
+ return nil
263
+ }
264
+ validMax = wantedMax
265
+ lastRasterisedRows = Int(height * scale)
266
+ } else {
267
+ lastRasterisedRows = 0
268
+ }
269
+
270
+ // The band must cover everything the glass can read; if the content is shorter than the
271
+ // viewport plus headroom the ring holds all of it and the check is trivially true.
272
+ guard covers(offsetY - Tuning.refractionHeadroom,
273
+ height: viewport + Tuning.refractionHeadroom * 2)
274
+ else {
275
+ return nil
276
+ }
277
+
278
+ return offsetY
279
+ }
280
+
281
+ /// Rasterises one content-space range into the ring.
282
+ ///
283
+ /// The content container is drawn directly, not the scroll view: drawing the scroll view
284
+ /// would apply its clip and photograph exactly the window band the cache exists to replace.
285
+ private func rasterise(
286
+ content: UIView,
287
+ from: CGFloat,
288
+ to: CGFloat,
289
+ texture: MTLTexture,
290
+ scrollView: UIScrollView
291
+ ) -> Bool {
292
+ let rows = to - from
293
+ guard rows > 0.5 else { return true }
294
+
295
+ let widthPoints = scrollView.bounds.width
296
+ let widthPixels = Int((widthPoints * scale).rounded(.up))
297
+ let rowsPixels = Int((rows * scale).rounded(.up))
298
+ guard widthPixels > 0, rowsPixels > 0,
299
+ let bitmap = CGContext(
300
+ data: nil,
301
+ width: widthPixels,
302
+ height: rowsPixels,
303
+ bitsPerComponent: 8,
304
+ bytesPerRow: widthPixels * 4,
305
+ space: CGColorSpaceCreateDeviceRGB(),
306
+ bitmapInfo: CGImageAlphaInfo.premultipliedFirst.rawValue
307
+ | CGBitmapInfo.byteOrder32Little.rawValue
308
+ )
309
+ else { return false }
310
+
311
+ bitmap.interpolationQuality = .none
312
+ bitmap.setShouldSmoothFonts(false)
313
+ bitmap.scaleBy(x: scale, y: scale)
314
+ // Content-space y = from lands on bitmap row 0. The content view's own origin is
315
+ // irrelevant: it draws its full document in content coordinates either way.
316
+ bitmap.translateBy(x: 0, y: -from)
317
+
318
+ let drawn = content.layer
319
+ drawn.render(in: bitmap)
320
+
321
+ guard let data = bitmap.data else { return false }
322
+ let bytesPerRow = bitmap.bytesPerRow
323
+
324
+ // Wrap at the ring seam: at most two regions.
325
+ let startPixel = Self.pixelRow(for: from, scale: scale, ringHeight: ringHeightPixels)
326
+ let firstRows = min(rowsPixels, ringHeightPixels - startPixel)
327
+ texture.replace(
328
+ region: MTLRegionMake2D(0, startPixel, widthPixels, firstRows),
329
+ mipmapLevel: 0,
330
+ withBytes: data,
331
+ bytesPerRow: bytesPerRow
332
+ )
333
+ if firstRows < rowsPixels {
334
+ texture.replace(
335
+ region: MTLRegionMake2D(0, 0, widthPixels, rowsPixels - firstRows),
336
+ mipmapLevel: 0,
337
+ withBytes: data.advanced(by: firstRows * bytesPerRow),
338
+ bytesPerRow: bytesPerRow
339
+ )
340
+ }
341
+ return true
342
+ }
343
+
344
+ // ------------------------------------------------------------------------------ composite
345
+
346
+ /// Copies the content band of `scrollFrame` from the ring into the window-space backdrop.
347
+ ///
348
+ /// The backdrop texture belongs to `BackdropCapturer` and already holds the static bands
349
+ /// above and below the scroller; this overwrites only the band the scroller occupies, so the
350
+ /// lens keeps its single window-space `uvRect` and the shader never learns about content
351
+ /// coordinates. Returns false when the ring cannot serve the band and the caller should
352
+ /// capture the window instead.
353
+ @discardableResult
354
+ func composite(
355
+ into backdrop: MTLTexture,
356
+ scrollFrame: CGRect,
357
+ capturedOrigin: CGPoint,
358
+ contentOffsetY: CGFloat
359
+ ) -> Bool {
360
+ lastCompositeWasBlit = false
361
+ guard let strip = texture, let queue else { return false }
362
+ guard backdrop.width == widthPixels, backdrop.height > 0 else { return false }
363
+
364
+ let viewport = scrollFrame.height
365
+ guard covers(contentOffsetY, height: viewport) else { return false }
366
+
367
+ // Destination: the band in backdrop pixels.
368
+ let x = (scrollFrame.minX - capturedOrigin.x) * scale
369
+ let y = (scrollFrame.minY - capturedOrigin.y) * scale
370
+ let w = scrollFrame.width * scale
371
+ let h = viewport * scale
372
+ let destX = max(0, Int(x.rounded()))
373
+ let destY = max(0, Int(y.rounded()))
374
+ let destW = min(Int(w.rounded()), backdrop.width - destX)
375
+ let destH = min(Int(h.rounded()), backdrop.height - destY)
376
+ guard destW > 0, destH > 0, destX + destW <= backdrop.width,
377
+ destY + destH <= backdrop.height
378
+ else { return false }
379
+
380
+ // Source: the same rows in the ring, split at the seam.
381
+ let sourceTop = contentOffsetY + CGFloat(destY - Int(y.rounded())) / scale
382
+ let startPixel = Self.pixelRow(
383
+ for: sourceTop,
384
+ scale: scale,
385
+ ringHeight: ringHeightPixels
386
+ )
387
+
388
+ guard let command = queue.makeCommandBuffer(),
389
+ let blit = command.makeBlitCommandEncoder()
390
+ else { return false }
391
+ command.label = "StripComposite"
392
+ blit.label = "StripCompositeBlit"
393
+
394
+ var copied = 0
395
+
396
+ func copyRows(_ rows: Int, from ringPixel: Int, to destPixel: Int) {
397
+ guard rows > 0 else { return }
398
+ blit.copy(
399
+ from: strip,
400
+ sourceSlice: 0,
401
+ sourceLevel: 0,
402
+ sourceOrigin: MTLOrigin(x: 0, y: ringPixel, z: 0),
403
+ sourceSize: MTLSize(width: destW, height: rows, depth: 1),
404
+ to: backdrop,
405
+ destinationSlice: 0,
406
+ destinationLevel: 0,
407
+ destinationOrigin: MTLOrigin(x: destX, y: destPixel, z: 0)
408
+ )
409
+ copied += rows
410
+ }
411
+
412
+ let firstRows = min(destH, ringHeightPixels - startPixel)
413
+ copyRows(firstRows, from: startPixel, to: destY)
414
+ if firstRows < destH {
415
+ copyRows(destH - firstRows, from: 0, to: destY + firstRows)
416
+ }
417
+
418
+ blit.endEncoding()
419
+ command.commit()
420
+ lastCompositeWasBlit = copied == destH
421
+ return lastCompositeWasBlit
422
+ }
423
+
424
+ // ------------------------------------------------------------------------------ validator
425
+
426
+ /// Compares the strip's band against a fresh window capture of the same band.
427
+ ///
428
+ /// Called on a settle capture, never during motion. A mean luminance difference past the
429
+ /// tolerance means the content moved in a way the strip did not model — a per-frame redraw,
430
+ /// an image that arrived, a transformed layer — and the cache is distrusted until the
431
+ /// fingerprint settles again. This is the §2 validator, reduced to what the ring can answer
432
+ /// from bytes it already has.
433
+ func validate(
434
+ against capture: MTLTexture,
435
+ scrollFrame: CGRect,
436
+ capturedOrigin: CGPoint,
437
+ contentOffsetY: CGFloat
438
+ ) {
439
+ guard let strip = texture else { return }
440
+ let bandY = (scrollFrame.minY - capturedOrigin.y) * scale
441
+ let bandX = (scrollFrame.minX - capturedOrigin.x) * scale
442
+ let bandH = min(scrollFrame.height * scale, CGFloat(capture.height) - bandY)
443
+ guard bandH > 8, bandX >= 0, bandX < CGFloat(capture.width) else { return }
444
+
445
+ let cells = Tuning.validationGrid
446
+ var stripMean: Double = 0
447
+ var captureMean: Double = 0
448
+ var samples = 0
449
+
450
+ // Window pixel y -> content y: the band starts at scrollFrame.minY in the window, which
451
+ // is contentY = contentOffsetY at that row, so every other row maps by the pixel delta.
452
+ let bandTopContentY = contentOffsetY
453
+
454
+ for cell in 0..<cells {
455
+ let destRow = Int(bandY + bandH * (CGFloat(cell) + 0.5) / CGFloat(cells))
456
+ guard destRow >= 0, destRow < capture.height else { continue }
457
+
458
+ let contentY = bandTopContentY + (CGFloat(destRow) - bandY) / scale
459
+ let sourceRow = Self.pixelRow(
460
+ for: contentY,
461
+ scale: scale,
462
+ ringHeight: ringHeightPixels
463
+ )
464
+ let x = max(0, min(Int(bandX), strip.width - 1))
465
+ stripMean += Self.luminance(strip, x: x, y: sourceRow)
466
+ captureMean += Self.luminance(capture, x: x, y: destRow)
467
+ samples += 1
468
+ }
469
+
470
+ guard samples > 0 else { return }
471
+ let delta = abs(stripMean - captureMean) / Double(samples)
472
+ if delta > Tuning.validationTolerance {
473
+ distrust()
474
+ }
475
+ }
476
+
477
+ // ------------------------------------------------------------------------------ lifecycle
478
+
479
+ func invalidateAll() {
480
+ hasContent = false
481
+ validMin = 0
482
+ validMax = 0
483
+ }
484
+
485
+ func releaseResources() {
486
+ texture = nil
487
+ ringHeightPixels = 0
488
+ widthPixels = 0
489
+ invalidateAll()
490
+ }
491
+
492
+ // -------------------------------------------------------------------------------- helpers
493
+
494
+ private static func pixelRow(for contentY: CGFloat, scale: CGFloat, ringHeight: Int) -> Int {
495
+ guard ringHeight > 0 else { return 0 }
496
+ let row = Int((contentY * scale).rounded(.down))
497
+ return ((row % ringHeight) + ringHeight) % ringHeight
498
+ }
499
+
500
+ /// A cheap structural digest of the content subtree.
501
+ ///
502
+ /// Geometry and membership only: it costs one walk of the scroll content per frame and
503
+ /// catches the failures a strip cannot model (a row inserted, a layer transformed). It
504
+ /// cannot see a pixel change inside an otherwise identical subtree — that is what the
505
+ /// settle validator is for.
506
+ static func fingerprint(of content: UIView) -> UInt64 {
507
+ var hash: UInt64 = 1469598103934665603
508
+ var stack: [UIView] = [content]
509
+ var visited = 0
510
+ while let view = stack.popLast(), visited < 512 {
511
+ visited += 1
512
+ func mix(_ value: UInt64) {
513
+ hash = (hash ^ value) &* 1099511628211
514
+ }
515
+ mix(UInt64(view.subviews.count))
516
+ mix(UInt64(bitPattern: Int64(view.frame.origin.y.rounded())))
517
+ mix(UInt64(bitPattern: Int64(view.frame.height.rounded())))
518
+ mix(UInt64(bitPattern: Int64(view.alpha * 1000)))
519
+ mix(UInt64(view.isHidden ? 1 : 0))
520
+ if let presented = view.layer.presentation() {
521
+ mix(UInt64(bitPattern: Int64(presented.transform.m11 * 10_000)))
522
+ mix(UInt64(bitPattern: Int64(presented.opacity * 1000)))
523
+ }
524
+ stack.append(contentsOf: view.subviews)
525
+ }
526
+ return hash
527
+ }
528
+
529
+ private static func luminance(_ texture: MTLTexture, x: Int, y: Int) -> Double {
530
+ var pixel = [UInt8](repeating: 0, count: 4)
531
+ pixel.withUnsafeMutableBytes { buffer in
532
+ texture.getBytes(
533
+ buffer.baseAddress!,
534
+ bytesPerRow: 4,
535
+ from: MTLRegionMake2D(x, y, 1, 1),
536
+ mipmapLevel: 0
537
+ )
538
+ }
539
+ // bgra8Unorm
540
+ let b = Double(pixel[0]) / 255
541
+ let g = Double(pixel[1]) / 255
542
+ let r = Double(pixel[2]) / 255
543
+ return 0.2126 * r + 0.7152 * g + 0.0722 * b
544
+ }
545
+ }
@@ -0,0 +1,79 @@
1
+ import ExpoModulesCore
2
+ import CoreGraphics
3
+
4
+ public struct GlassCornerRadii: Record {
5
+ @Field public var topLeft: Double = 0
6
+ @Field public var topRight: Double = 0
7
+ @Field public var bottomRight: Double = 0
8
+ @Field public var bottomLeft: Double = 0
9
+
10
+ public init() {}
11
+ }
12
+
13
+ struct CornerRadiiValues: Equatable {
14
+ var topLeft: CGFloat = 0
15
+ var topRight: CGFloat = 0
16
+ var bottomRight: CGFloat = 0
17
+ var bottomLeft: CGFloat = 0
18
+
19
+ static func uniform(_ radius: CGFloat) -> CornerRadiiValues {
20
+ CornerRadiiValues(topLeft: radius, topRight: radius, bottomRight: radius, bottomLeft: radius)
21
+ }
22
+
23
+ var isUniform: Bool {
24
+ topLeft == topRight && topRight == bottomRight && bottomRight == bottomLeft
25
+ }
26
+
27
+ var isZero: Bool {
28
+ topLeft <= 0 && topRight <= 0 && bottomRight <= 0 && bottomLeft <= 0
29
+ }
30
+
31
+ func clamped(to size: CGSize) -> CornerRadiiValues {
32
+ let limit = min(size.width, size.height) / 2
33
+ return CornerRadiiValues(
34
+ topLeft: min(max(0, topLeft), limit),
35
+ topRight: min(max(0, topRight), limit),
36
+ bottomRight: min(max(0, bottomRight), limit),
37
+ bottomLeft: min(max(0, bottomLeft), limit)
38
+ )
39
+ }
40
+
41
+ func simd(for size: CGSize) -> SIMD4<Float> {
42
+ let c = clamped(to: size)
43
+ return SIMD4<Float>(
44
+ Float(c.bottomLeft),
45
+ Float(c.bottomRight),
46
+ Float(c.topRight),
47
+ Float(c.topLeft)
48
+ )
49
+ }
50
+ }
51
+
52
+ extension CornerRadiiValues {
53
+
54
+ init(_ prop: Either<Double, GlassCornerRadii>?) {
55
+ guard let prop else {
56
+ self = .uniform(0)
57
+ return
58
+ }
59
+
60
+ let radius: Double? = prop.get()
61
+ if let radius {
62
+ self = .uniform(CGFloat(radius))
63
+ return
64
+ }
65
+
66
+ let radii: GlassCornerRadii? = prop.get()
67
+ guard let radii else {
68
+ self = .uniform(0)
69
+ return
70
+ }
71
+
72
+ self = CornerRadiiValues(
73
+ topLeft: CGFloat(radii.topLeft),
74
+ topRight: CGFloat(radii.topRight),
75
+ bottomRight: CGFloat(radii.bottomRight),
76
+ bottomLeft: CGFloat(radii.bottomLeft)
77
+ )
78
+ }
79
+ }