ngwr 6.0.0 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (696) hide show
  1. package/LICENSE +1 -3
  2. package/README.md +179 -32
  3. package/affix/styles/_index.scss +12 -0
  4. package/alert/styles/_index.scss +75 -32
  5. package/anchor/styles/_index.scss +59 -0
  6. package/aurora/aurora.scss +1 -0
  7. package/aurora/styles/_index.scss +30 -0
  8. package/avatar/styles/_index.scss +30 -14
  9. package/back-top/styles/_index.scss +42 -0
  10. package/badge/styles/_index.scss +80 -0
  11. package/badge/styles/_tag.scss +81 -0
  12. package/bar-chart/styles/_index.scss +56 -0
  13. package/blur-text/blur-text.scss +1 -0
  14. package/blur-text/styles/_index.scss +14 -0
  15. package/border-glow/border-glow.scss +4 -0
  16. package/border-glow/styles/_index.scss +228 -0
  17. package/breadcrumbs/breadcrumbs.scss +1 -0
  18. package/breadcrumbs/styles/_index.scss +76 -0
  19. package/button/styles/_index.scss +148 -125
  20. package/calendar/styles/_index.scss +252 -0
  21. package/calendar-heatmap/styles/_index.scss +69 -0
  22. package/card/card.scss +1 -0
  23. package/card/styles/_index.scss +96 -0
  24. package/carousel/styles/_index.scss +102 -0
  25. package/cascader/cascader.scss +1 -0
  26. package/cascader/styles/_index.scss +174 -0
  27. package/checkbox/styles/_index.scss +76 -60
  28. package/circular-text/circular-text.scss +1 -0
  29. package/circular-text/styles/_index.scss +45 -0
  30. package/click-spark/click-spark.scss +1 -0
  31. package/click-spark/styles/_index.scss +16 -0
  32. package/collapse/styles/_index.scss +92 -0
  33. package/color-picker/styles/_index.scss +247 -0
  34. package/command-palette/styles/_index.scss +188 -0
  35. package/compare/styles/_index.scss +100 -0
  36. package/context-menu/styles/_index.scss +112 -0
  37. package/counter/styles/_index.scss +44 -0
  38. package/date-picker/styles/_index.scss +204 -0
  39. package/decrypt-text/decrypt-text.scss +1 -0
  40. package/decrypt-text/styles/_index.scss +26 -0
  41. package/density/styles/_index.scss +37 -0
  42. package/descriptions/styles/_index.scss +104 -0
  43. package/dialog/styles/_index.scss +101 -27
  44. package/divider/styles/_index.scss +43 -24
  45. package/donut-chart/styles/_index.scss +76 -0
  46. package/drag-drop/sortable-list.scss +1 -0
  47. package/drag-drop/styles/_index.scss +99 -0
  48. package/drawer/styles/_index.scss +164 -0
  49. package/dropdown/styles/_index.scss +76 -56
  50. package/empty/styles/_index.scss +49 -0
  51. package/falling-text/falling-text.scss +1 -0
  52. package/falling-text/styles/_index.scss +30 -0
  53. package/fesm2022/ngwr-affix.mjs +102 -0
  54. package/fesm2022/ngwr-affix.mjs.map +1 -0
  55. package/fesm2022/ngwr-alert.mjs +70 -52
  56. package/fesm2022/ngwr-alert.mjs.map +1 -1
  57. package/fesm2022/ngwr-anchor.mjs +103 -0
  58. package/fesm2022/ngwr-anchor.mjs.map +1 -0
  59. package/fesm2022/ngwr-aurora.mjs +309 -0
  60. package/fesm2022/ngwr-aurora.mjs.map +1 -0
  61. package/fesm2022/ngwr-avatar.mjs +81 -71
  62. package/fesm2022/ngwr-avatar.mjs.map +1 -1
  63. package/fesm2022/ngwr-back-top.mjs +81 -0
  64. package/fesm2022/ngwr-back-top.mjs.map +1 -0
  65. package/fesm2022/ngwr-badge.mjs +192 -0
  66. package/fesm2022/ngwr-badge.mjs.map +1 -0
  67. package/fesm2022/ngwr-bar-chart.mjs +69 -0
  68. package/fesm2022/ngwr-bar-chart.mjs.map +1 -0
  69. package/fesm2022/ngwr-blur-text.mjs +181 -0
  70. package/fesm2022/ngwr-blur-text.mjs.map +1 -0
  71. package/fesm2022/ngwr-border-glow.mjs +278 -0
  72. package/fesm2022/ngwr-border-glow.mjs.map +1 -0
  73. package/fesm2022/ngwr-breadcrumbs.mjs +101 -0
  74. package/fesm2022/ngwr-breadcrumbs.mjs.map +1 -0
  75. package/fesm2022/ngwr-button.mjs +179 -104
  76. package/fesm2022/ngwr-button.mjs.map +1 -1
  77. package/fesm2022/ngwr-calendar-heatmap.mjs +145 -0
  78. package/fesm2022/ngwr-calendar-heatmap.mjs.map +1 -0
  79. package/fesm2022/ngwr-calendar.mjs +402 -0
  80. package/fesm2022/ngwr-calendar.mjs.map +1 -0
  81. package/fesm2022/ngwr-card.mjs +100 -0
  82. package/fesm2022/ngwr-card.mjs.map +1 -0
  83. package/fesm2022/ngwr-carousel.mjs +128 -0
  84. package/fesm2022/ngwr-carousel.mjs.map +1 -0
  85. package/fesm2022/ngwr-cascader.mjs +280 -0
  86. package/fesm2022/ngwr-cascader.mjs.map +1 -0
  87. package/fesm2022/ngwr-checkbox.mjs +214 -54
  88. package/fesm2022/ngwr-checkbox.mjs.map +1 -1
  89. package/fesm2022/ngwr-circular-text.mjs +168 -0
  90. package/fesm2022/ngwr-circular-text.mjs.map +1 -0
  91. package/fesm2022/ngwr-click-spark.mjs +163 -0
  92. package/fesm2022/ngwr-click-spark.mjs.map +1 -0
  93. package/fesm2022/ngwr-clipboard.mjs +130 -0
  94. package/fesm2022/ngwr-clipboard.mjs.map +1 -0
  95. package/fesm2022/ngwr-collapse.mjs +232 -0
  96. package/fesm2022/ngwr-collapse.mjs.map +1 -0
  97. package/fesm2022/ngwr-color-picker.mjs +646 -0
  98. package/fesm2022/ngwr-color-picker.mjs.map +1 -0
  99. package/fesm2022/ngwr-command-palette.mjs +259 -0
  100. package/fesm2022/ngwr-command-palette.mjs.map +1 -0
  101. package/fesm2022/ngwr-compare.mjs +137 -0
  102. package/fesm2022/ngwr-compare.mjs.map +1 -0
  103. package/fesm2022/ngwr-confetti.mjs +160 -0
  104. package/fesm2022/ngwr-confetti.mjs.map +1 -0
  105. package/fesm2022/ngwr-context-menu.mjs +653 -0
  106. package/fesm2022/ngwr-context-menu.mjs.map +1 -0
  107. package/fesm2022/ngwr-cookie.mjs +127 -0
  108. package/fesm2022/ngwr-cookie.mjs.map +1 -0
  109. package/fesm2022/ngwr-counter.mjs +415 -0
  110. package/fesm2022/ngwr-counter.mjs.map +1 -0
  111. package/fesm2022/ngwr-date-adapter-fns.mjs +180 -0
  112. package/fesm2022/ngwr-date-adapter-fns.mjs.map +1 -0
  113. package/fesm2022/ngwr-date-adapter-luxon.mjs +201 -0
  114. package/fesm2022/ngwr-date-adapter-luxon.mjs.map +1 -0
  115. package/fesm2022/ngwr-date-adapter.mjs +419 -0
  116. package/fesm2022/ngwr-date-adapter.mjs.map +1 -0
  117. package/fesm2022/ngwr-date-picker.mjs +624 -0
  118. package/fesm2022/ngwr-date-picker.mjs.map +1 -0
  119. package/fesm2022/ngwr-decrypt-text.mjs +396 -0
  120. package/fesm2022/ngwr-decrypt-text.mjs.map +1 -0
  121. package/fesm2022/ngwr-density.mjs +157 -0
  122. package/fesm2022/ngwr-density.mjs.map +1 -0
  123. package/fesm2022/ngwr-descriptions.mjs +83 -0
  124. package/fesm2022/ngwr-descriptions.mjs.map +1 -0
  125. package/fesm2022/ngwr-dialog.mjs +249 -383
  126. package/fesm2022/ngwr-dialog.mjs.map +1 -1
  127. package/fesm2022/ngwr-directives.mjs +315 -0
  128. package/fesm2022/ngwr-directives.mjs.map +1 -0
  129. package/fesm2022/ngwr-divider.mjs +74 -59
  130. package/fesm2022/ngwr-divider.mjs.map +1 -1
  131. package/fesm2022/ngwr-donut-chart.mjs +131 -0
  132. package/fesm2022/ngwr-donut-chart.mjs.map +1 -0
  133. package/fesm2022/ngwr-drag-drop.mjs +117 -0
  134. package/fesm2022/ngwr-drag-drop.mjs.map +1 -0
  135. package/fesm2022/ngwr-drawer.mjs +315 -0
  136. package/fesm2022/ngwr-drawer.mjs.map +1 -0
  137. package/fesm2022/ngwr-dropdown.mjs +276 -229
  138. package/fesm2022/ngwr-dropdown.mjs.map +1 -1
  139. package/fesm2022/ngwr-empty.mjs +57 -0
  140. package/fesm2022/ngwr-empty.mjs.map +1 -0
  141. package/fesm2022/ngwr-falling-text.mjs +316 -0
  142. package/fesm2022/ngwr-falling-text.mjs.map +1 -0
  143. package/fesm2022/ngwr-file-upload.mjs +260 -0
  144. package/fesm2022/ngwr-file-upload.mjs.map +1 -0
  145. package/fesm2022/ngwr-form.mjs +133 -48
  146. package/fesm2022/ngwr-form.mjs.map +1 -1
  147. package/fesm2022/ngwr-fuzzy-text.mjs +373 -0
  148. package/fesm2022/ngwr-fuzzy-text.mjs.map +1 -0
  149. package/fesm2022/ngwr-gauge.mjs +83 -0
  150. package/fesm2022/ngwr-gauge.mjs.map +1 -0
  151. package/fesm2022/ngwr-glitch-text.mjs +67 -0
  152. package/fesm2022/ngwr-glitch-text.mjs.map +1 -0
  153. package/fesm2022/ngwr-gradient-text.mjs +109 -0
  154. package/fesm2022/ngwr-gradient-text.mjs.map +1 -0
  155. package/fesm2022/ngwr-hotkey.mjs +263 -0
  156. package/fesm2022/ngwr-hotkey.mjs.map +1 -0
  157. package/fesm2022/ngwr-i18n-en.mjs +168 -0
  158. package/fesm2022/ngwr-i18n-en.mjs.map +1 -0
  159. package/fesm2022/ngwr-i18n-ru.mjs +156 -0
  160. package/fesm2022/ngwr-i18n-ru.mjs.map +1 -0
  161. package/fesm2022/ngwr-i18n.mjs +478 -0
  162. package/fesm2022/ngwr-i18n.mjs.map +1 -0
  163. package/fesm2022/ngwr-icon-adapters-feather.mjs +74 -0
  164. package/fesm2022/ngwr-icon-adapters-feather.mjs.map +1 -0
  165. package/fesm2022/ngwr-icon-adapters-lucide.mjs +88 -0
  166. package/fesm2022/ngwr-icon-adapters-lucide.mjs.map +1 -0
  167. package/fesm2022/ngwr-icon.mjs +189 -650
  168. package/fesm2022/ngwr-icon.mjs.map +1 -1
  169. package/fesm2022/ngwr-image-cropper.mjs +299 -0
  170. package/fesm2022/ngwr-image-cropper.mjs.map +1 -0
  171. package/fesm2022/ngwr-input-number.mjs +239 -0
  172. package/fesm2022/ngwr-input-number.mjs.map +1 -0
  173. package/fesm2022/ngwr-input-otp.mjs +216 -0
  174. package/fesm2022/ngwr-input-otp.mjs.map +1 -0
  175. package/fesm2022/ngwr-input.mjs +183 -104
  176. package/fesm2022/ngwr-input.mjs.map +1 -1
  177. package/fesm2022/ngwr-keyboard.mjs +47 -0
  178. package/fesm2022/ngwr-keyboard.mjs.map +1 -0
  179. package/fesm2022/ngwr-knob.mjs +227 -0
  180. package/fesm2022/ngwr-knob.mjs.map +1 -0
  181. package/fesm2022/ngwr-layout.mjs +197 -0
  182. package/fesm2022/ngwr-layout.mjs.map +1 -0
  183. package/fesm2022/ngwr-lightbox.mjs +131 -0
  184. package/fesm2022/ngwr-lightbox.mjs.map +1 -0
  185. package/fesm2022/ngwr-line-chart.mjs +176 -0
  186. package/fesm2022/ngwr-line-chart.mjs.map +1 -0
  187. package/fesm2022/ngwr-list.mjs +132 -0
  188. package/fesm2022/ngwr-list.mjs.map +1 -0
  189. package/fesm2022/ngwr-loading-bar.mjs +160 -0
  190. package/fesm2022/ngwr-loading-bar.mjs.map +1 -0
  191. package/fesm2022/ngwr-marquee.mjs +224 -0
  192. package/fesm2022/ngwr-marquee.mjs.map +1 -0
  193. package/fesm2022/ngwr-media.mjs +132 -0
  194. package/fesm2022/ngwr-media.mjs.map +1 -0
  195. package/fesm2022/ngwr-mention.mjs +374 -0
  196. package/fesm2022/ngwr-mention.mjs.map +1 -0
  197. package/fesm2022/ngwr-meta.mjs +266 -0
  198. package/fesm2022/ngwr-meta.mjs.map +1 -0
  199. package/fesm2022/ngwr-meter-group.mjs +73 -0
  200. package/fesm2022/ngwr-meter-group.mjs.map +1 -0
  201. package/fesm2022/ngwr-overlay.mjs +145 -0
  202. package/fesm2022/ngwr-overlay.mjs.map +1 -0
  203. package/fesm2022/ngwr-page-header.mjs +53 -0
  204. package/fesm2022/ngwr-page-header.mjs.map +1 -0
  205. package/fesm2022/ngwr-pagination.mjs +152 -96
  206. package/fesm2022/ngwr-pagination.mjs.map +1 -1
  207. package/fesm2022/ngwr-pipes.mjs +290 -11
  208. package/fesm2022/ngwr-pipes.mjs.map +1 -1
  209. package/fesm2022/ngwr-platform.mjs +63 -0
  210. package/fesm2022/ngwr-platform.mjs.map +1 -0
  211. package/fesm2022/ngwr-popconfirm.mjs +188 -0
  212. package/fesm2022/ngwr-popconfirm.mjs.map +1 -0
  213. package/fesm2022/ngwr-popover.mjs +361 -0
  214. package/fesm2022/ngwr-popover.mjs.map +1 -0
  215. package/fesm2022/ngwr-progress.mjs +47 -39
  216. package/fesm2022/ngwr-progress.mjs.map +1 -1
  217. package/fesm2022/ngwr-qr.mjs +168 -190
  218. package/fesm2022/ngwr-qr.mjs.map +1 -1
  219. package/fesm2022/ngwr-radio.mjs +204 -0
  220. package/fesm2022/ngwr-radio.mjs.map +1 -0
  221. package/fesm2022/ngwr-rating.mjs +180 -0
  222. package/fesm2022/ngwr-rating.mjs.map +1 -0
  223. package/fesm2022/ngwr-result.mjs +119 -0
  224. package/fesm2022/ngwr-result.mjs.map +1 -0
  225. package/fesm2022/ngwr-rotating-text.mjs +256 -0
  226. package/fesm2022/ngwr-rotating-text.mjs.map +1 -0
  227. package/fesm2022/ngwr-scramble-text.mjs +165 -0
  228. package/fesm2022/ngwr-scramble-text.mjs.map +1 -0
  229. package/fesm2022/ngwr-scroll.mjs +107 -0
  230. package/fesm2022/ngwr-scroll.mjs.map +1 -0
  231. package/fesm2022/ngwr-segmented.mjs +96 -0
  232. package/fesm2022/ngwr-segmented.mjs.map +1 -0
  233. package/fesm2022/ngwr-select.mjs +842 -307
  234. package/fesm2022/ngwr-select.mjs.map +1 -1
  235. package/fesm2022/ngwr-shiny-text.mjs +127 -0
  236. package/fesm2022/ngwr-shiny-text.mjs.map +1 -0
  237. package/fesm2022/ngwr-sidebar.mjs +134 -0
  238. package/fesm2022/ngwr-sidebar.mjs.map +1 -0
  239. package/fesm2022/ngwr-skeleton.mjs +59 -34
  240. package/fesm2022/ngwr-skeleton.mjs.map +1 -1
  241. package/fesm2022/ngwr-slider.mjs +234 -0
  242. package/fesm2022/ngwr-slider.mjs.map +1 -0
  243. package/fesm2022/ngwr-sparkline.mjs +104 -0
  244. package/fesm2022/ngwr-sparkline.mjs.map +1 -0
  245. package/fesm2022/ngwr-speed-dial.mjs +79 -0
  246. package/fesm2022/ngwr-speed-dial.mjs.map +1 -0
  247. package/fesm2022/ngwr-spinner.mjs +34 -28
  248. package/fesm2022/ngwr-spinner.mjs.map +1 -1
  249. package/fesm2022/ngwr-splash-cursor.mjs +970 -0
  250. package/fesm2022/ngwr-splash-cursor.mjs.map +1 -0
  251. package/fesm2022/ngwr-split-text.mjs +200 -0
  252. package/fesm2022/ngwr-split-text.mjs.map +1 -0
  253. package/fesm2022/ngwr-splitter.mjs +125 -0
  254. package/fesm2022/ngwr-splitter.mjs.map +1 -0
  255. package/fesm2022/ngwr-spotlight-card.mjs +138 -0
  256. package/fesm2022/ngwr-spotlight-card.mjs.map +1 -0
  257. package/fesm2022/ngwr-squircle.mjs +320 -0
  258. package/fesm2022/ngwr-squircle.mjs.map +1 -0
  259. package/fesm2022/ngwr-star-border.mjs +72 -0
  260. package/fesm2022/ngwr-star-border.mjs.map +1 -0
  261. package/fesm2022/ngwr-statistic.mjs +220 -0
  262. package/fesm2022/ngwr-statistic.mjs.map +1 -0
  263. package/fesm2022/ngwr-stepper.mjs +186 -0
  264. package/fesm2022/ngwr-stepper.mjs.map +1 -0
  265. package/fesm2022/ngwr-storage.mjs +317 -0
  266. package/fesm2022/ngwr-storage.mjs.map +1 -0
  267. package/fesm2022/ngwr-switch.mjs +99 -0
  268. package/fesm2022/ngwr-switch.mjs.map +1 -0
  269. package/fesm2022/ngwr-table.mjs +218 -207
  270. package/fesm2022/ngwr-table.mjs.map +1 -1
  271. package/fesm2022/ngwr-tabs.mjs +217 -0
  272. package/fesm2022/ngwr-tabs.mjs.map +1 -0
  273. package/fesm2022/ngwr-textarea.mjs +106 -120
  274. package/fesm2022/ngwr-textarea.mjs.map +1 -1
  275. package/fesm2022/ngwr-theme.mjs +152 -0
  276. package/fesm2022/ngwr-theme.mjs.map +1 -0
  277. package/fesm2022/ngwr-tilt-card.mjs +137 -0
  278. package/fesm2022/ngwr-tilt-card.mjs.map +1 -0
  279. package/fesm2022/ngwr-timeline.mjs +73 -0
  280. package/fesm2022/ngwr-timeline.mjs.map +1 -0
  281. package/fesm2022/ngwr-toast.mjs +446 -0
  282. package/fesm2022/ngwr-toast.mjs.map +1 -0
  283. package/fesm2022/ngwr-toolbar.mjs +46 -0
  284. package/fesm2022/ngwr-toolbar.mjs.map +1 -0
  285. package/fesm2022/ngwr-tree.mjs +483 -0
  286. package/fesm2022/ngwr-tree.mjs.map +1 -0
  287. package/fesm2022/ngwr-typewriter.mjs +229 -0
  288. package/fesm2022/ngwr-typewriter.mjs.map +1 -0
  289. package/fesm2022/ngwr-typography.mjs +79 -0
  290. package/fesm2022/ngwr-typography.mjs.map +1 -0
  291. package/fesm2022/ngwr-utils.mjs +535 -0
  292. package/fesm2022/ngwr-utils.mjs.map +1 -0
  293. package/fesm2022/ngwr-validators.mjs +214 -0
  294. package/fesm2022/ngwr-validators.mjs.map +1 -0
  295. package/fesm2022/ngwr-version.mjs +51 -0
  296. package/fesm2022/ngwr-version.mjs.map +1 -0
  297. package/fesm2022/ngwr-virtual-scroll.mjs +99 -0
  298. package/fesm2022/ngwr-virtual-scroll.mjs.map +1 -0
  299. package/fesm2022/ngwr-waves.mjs +356 -0
  300. package/fesm2022/ngwr-waves.mjs.map +1 -0
  301. package/fesm2022/ngwr-window.mjs +1141 -0
  302. package/fesm2022/ngwr-window.mjs.map +1 -0
  303. package/fesm2022/ngwr.mjs +0 -3
  304. package/fesm2022/ngwr.mjs.map +1 -1
  305. package/file-upload/styles/_index.scss +152 -0
  306. package/form/styles/_index.scss +85 -42
  307. package/gauge/styles/_index.scss +37 -0
  308. package/glitch-text/glitch-text.scss +1 -0
  309. package/glitch-text/styles/_index.scss +144 -0
  310. package/gradient-text/gradient-text.scss +1 -0
  311. package/gradient-text/styles/_index.scss +113 -0
  312. package/icon/styles/_index.scss +21 -15
  313. package/image-cropper/styles/_index.scss +114 -0
  314. package/input/styles/_index.scss +133 -93
  315. package/input-number/styles/_index.scss +75 -0
  316. package/input-otp/styles/_index.scss +53 -0
  317. package/keyboard/styles/_index.scss +55 -0
  318. package/knob/styles/_index.scss +54 -0
  319. package/layout/styles/_index.scss +65 -0
  320. package/lightbox/lightbox.scss +1 -0
  321. package/lightbox/styles/_index.scss +144 -0
  322. package/line-chart/styles/_index.scss +93 -0
  323. package/list/list.scss +1 -0
  324. package/list/styles/_index.scss +101 -0
  325. package/loading-bar/loading-bar.scss +1 -0
  326. package/loading-bar/styles/_index.scss +29 -0
  327. package/marquee/marquee.scss +1 -0
  328. package/marquee/styles/_index.scss +138 -0
  329. package/mention/styles/_index.scss +47 -0
  330. package/meter-group/styles/_index.scss +61 -0
  331. package/package.json +576 -99
  332. package/page-header/styles/_index.scss +78 -0
  333. package/pagination/styles/_index.scss +89 -34
  334. package/popconfirm/styles/_index.scss +32 -0
  335. package/popover/styles/_index.scss +83 -0
  336. package/progress/styles/_index.scss +29 -14
  337. package/qr/styles/_index.scss +6 -3
  338. package/radio/styles/_index.scss +111 -0
  339. package/rating/styles/_index.scss +63 -0
  340. package/result/styles/_index.scss +69 -0
  341. package/rotating-text/rotating-text.scss +1 -0
  342. package/rotating-text/styles/_index.scss +39 -0
  343. package/schematics/collection.json +37 -0
  344. package/schematics/component-style/index.js +49 -0
  345. package/{alert/alert-type.d.ts → schematics/component-style/schema.js} +2 -1
  346. package/schematics/component-style/schema.json +20 -0
  347. package/schematics/icon-set/index.js +96 -0
  348. package/{avatar/public-api.d.ts → schematics/icon-set/schema.js} +2 -1
  349. package/schematics/icon-set/schema.json +39 -0
  350. package/schematics/migrations/v7/index.js +187 -0
  351. package/schematics/migrations.json +10 -0
  352. package/schematics/ng-add/index.js +180 -0
  353. package/{cdk/public-api.d.ts → schematics/ng-add/schema.js} +2 -1
  354. package/schematics/ng-add/schema.json +80 -0
  355. package/schematics/page/index.js +63 -0
  356. package/{alert/public-api.d.ts → schematics/page/schema.js} +2 -2
  357. package/schematics/page/schema.json +39 -0
  358. package/schematics/page/templates.js +198 -0
  359. package/schematics/provider/index.js +126 -0
  360. package/schematics/provider/schema.js +8 -0
  361. package/schematics/provider/schema.json +52 -0
  362. package/schematics/use/index.js +143 -0
  363. package/schematics/use/schema.js +8 -0
  364. package/schematics/use/schema.json +25 -0
  365. package/schematics/use/symbol-map.json +356 -0
  366. package/scramble-text/scramble-text.scss +1 -0
  367. package/scramble-text/styles/_index.scss +8 -0
  368. package/segmented/styles/_index.scss +92 -0
  369. package/select/styles/_index.scss +245 -159
  370. package/shiny-text/shiny-text.scss +1 -0
  371. package/shiny-text/styles/_index.scss +101 -0
  372. package/sidebar/styles/_index.scss +208 -0
  373. package/skeleton/styles/_index.scss +33 -33
  374. package/slider/styles/_index.scss +77 -0
  375. package/sparkline/styles/_index.scss +9 -0
  376. package/speed-dial/styles/_index.scss +158 -0
  377. package/spinner/styles/_index.scss +38 -22
  378. package/splash-cursor/splash-cursor.scss +1 -0
  379. package/splash-cursor/styles/_index.scss +27 -0
  380. package/split-text/split-text.scss +1 -0
  381. package/split-text/styles/_index.scss +22 -0
  382. package/splitter/styles/_index.scss +85 -0
  383. package/spotlight-card/spotlight-card.scss +1 -0
  384. package/spotlight-card/styles/_index.scss +43 -0
  385. package/squircle/styles/_index.scss +34 -0
  386. package/star-border/star-border.scss +1 -0
  387. package/star-border/styles/_index.scss +118 -0
  388. package/statistic/styles/_index.scss +54 -0
  389. package/stepper/styles/_index.scss +162 -0
  390. package/styles/_animations.scss +198 -0
  391. package/styles/_breakpoints.scss +75 -0
  392. package/styles/_grid.scss +71 -0
  393. package/styles/_reset.scss +123 -0
  394. package/styles/_typography.scss +122 -0
  395. package/styles.scss +102 -13
  396. package/switch/styles/_index.scss +82 -0
  397. package/table/styles/_index.scss +255 -4
  398. package/tabs/styles/_index.scss +71 -0
  399. package/textarea/styles/_index.scss +47 -56
  400. package/theme/styles/_colors.scss +83 -0
  401. package/theme/styles/_dark.scss +85 -0
  402. package/theme/styles/_focus.scss +93 -0
  403. package/theme/styles/_index.scss +5 -0
  404. package/theme/styles/_mixins.scss +57 -0
  405. package/theme/styles/_variables.scss +118 -0
  406. package/tilt-card/styles/_index.scss +40 -0
  407. package/tilt-card/tilt-card.scss +1 -0
  408. package/timeline/styles/_index.scss +127 -0
  409. package/toast/styles/_index.scss +263 -0
  410. package/toolbar/styles/_index.scss +65 -0
  411. package/tree/styles/_index.scss +271 -0
  412. package/types/ngwr-affix.d.ts +43 -0
  413. package/types/ngwr-alert.d.ts +68 -0
  414. package/types/ngwr-anchor.d.ts +53 -0
  415. package/types/ngwr-aurora.d.ts +52 -0
  416. package/types/ngwr-avatar.d.ts +90 -0
  417. package/types/ngwr-back-top.d.ts +37 -0
  418. package/types/ngwr-badge.d.ts +158 -0
  419. package/types/ngwr-bar-chart.d.ts +47 -0
  420. package/types/ngwr-blur-text.d.ts +62 -0
  421. package/types/ngwr-border-glow.d.ts +66 -0
  422. package/types/ngwr-breadcrumbs.d.ts +61 -0
  423. package/types/ngwr-button.d.ts +176 -0
  424. package/types/ngwr-calendar-heatmap.d.ts +58 -0
  425. package/types/ngwr-calendar.d.ts +116 -0
  426. package/types/ngwr-card.d.ts +50 -0
  427. package/types/ngwr-carousel.d.ts +57 -0
  428. package/types/ngwr-cascader.d.ts +107 -0
  429. package/types/ngwr-checkbox.d.ts +139 -0
  430. package/types/ngwr-circular-text.d.ts +49 -0
  431. package/types/ngwr-click-spark.d.ts +52 -0
  432. package/types/ngwr-clipboard.d.ts +53 -0
  433. package/types/ngwr-collapse.d.ts +139 -0
  434. package/types/ngwr-color-picker.d.ts +302 -0
  435. package/types/ngwr-command-palette.d.ts +113 -0
  436. package/types/ngwr-compare.d.ts +55 -0
  437. package/types/ngwr-confetti.d.ts +70 -0
  438. package/types/ngwr-context-menu.d.ts +207 -0
  439. package/types/ngwr-cookie.d.ts +60 -0
  440. package/types/ngwr-counter.d.ts +182 -0
  441. package/types/ngwr-date-adapter-fns.d.ts +73 -0
  442. package/types/ngwr-date-adapter-luxon.d.ts +73 -0
  443. package/types/ngwr-date-adapter.d.ts +198 -0
  444. package/types/ngwr-date-picker.d.ts +117 -0
  445. package/types/ngwr-decrypt-text.d.ts +85 -0
  446. package/types/ngwr-density.d.ts +97 -0
  447. package/types/ngwr-descriptions.d.ts +41 -0
  448. package/types/ngwr-dialog.d.ts +210 -0
  449. package/types/ngwr-directives.d.ts +125 -0
  450. package/types/ngwr-divider.d.ts +73 -0
  451. package/types/ngwr-donut-chart.d.ts +53 -0
  452. package/types/ngwr-drag-drop.d.ts +83 -0
  453. package/types/ngwr-drawer.d.ts +155 -0
  454. package/types/ngwr-dropdown.d.ts +124 -0
  455. package/types/ngwr-empty.d.ts +38 -0
  456. package/types/ngwr-falling-text.d.ts +63 -0
  457. package/types/ngwr-file-upload.d.ts +94 -0
  458. package/types/ngwr-form.d.ts +95 -0
  459. package/types/ngwr-fuzzy-text.d.ts +74 -0
  460. package/types/ngwr-gauge.d.ts +39 -0
  461. package/types/ngwr-glitch-text.d.ts +31 -0
  462. package/types/ngwr-gradient-text.d.ts +46 -0
  463. package/types/ngwr-hotkey.d.ts +142 -0
  464. package/types/ngwr-i18n-en.d.ts +18 -0
  465. package/types/ngwr-i18n-ru.d.ts +6 -0
  466. package/types/ngwr-i18n.d.ts +336 -0
  467. package/types/ngwr-icon-adapters-feather.d.ts +44 -0
  468. package/types/ngwr-icon-adapters-lucide.d.ts +54 -0
  469. package/types/ngwr-icon.d.ts +180 -0
  470. package/types/ngwr-image-cropper.d.ts +110 -0
  471. package/types/ngwr-input-number.d.ts +77 -0
  472. package/types/ngwr-input-otp.d.ts +78 -0
  473. package/types/ngwr-input.d.ts +131 -0
  474. package/types/ngwr-keyboard.d.ts +34 -0
  475. package/types/ngwr-knob.d.ts +77 -0
  476. package/types/ngwr-layout.d.ts +89 -0
  477. package/types/ngwr-lightbox.d.ts +50 -0
  478. package/types/ngwr-line-chart.d.ts +90 -0
  479. package/types/ngwr-list.d.ts +71 -0
  480. package/types/ngwr-loading-bar.d.ts +79 -0
  481. package/types/ngwr-marquee.d.ts +95 -0
  482. package/types/ngwr-media.d.ts +74 -0
  483. package/types/ngwr-mention.d.ts +110 -0
  484. package/types/ngwr-meta.d.ts +164 -0
  485. package/types/ngwr-meter-group.d.ts +57 -0
  486. package/types/ngwr-overlay.d.ts +110 -0
  487. package/types/ngwr-page-header.d.ts +35 -0
  488. package/types/ngwr-pagination.d.ts +119 -0
  489. package/types/ngwr-pipes.d.ts +177 -0
  490. package/types/ngwr-platform.d.ts +38 -0
  491. package/types/ngwr-popconfirm.d.ts +79 -0
  492. package/types/ngwr-popover.d.ts +90 -0
  493. package/types/ngwr-progress.d.ts +33 -0
  494. package/types/ngwr-qr.d.ts +56 -0
  495. package/types/ngwr-radio.d.ts +120 -0
  496. package/types/ngwr-rating.d.ts +62 -0
  497. package/types/ngwr-result.d.ts +64 -0
  498. package/types/ngwr-rotating-text.d.ts +72 -0
  499. package/types/ngwr-scramble-text.d.ts +49 -0
  500. package/types/ngwr-scroll.d.ts +65 -0
  501. package/types/ngwr-segmented.d.ts +65 -0
  502. package/types/ngwr-select.d.ts +413 -0
  503. package/types/ngwr-shiny-text.d.ts +70 -0
  504. package/types/ngwr-sidebar.d.ts +83 -0
  505. package/types/ngwr-skeleton.d.ts +41 -0
  506. package/types/ngwr-slider.d.ts +86 -0
  507. package/types/ngwr-sparkline.d.ts +48 -0
  508. package/types/ngwr-speed-dial.d.ts +51 -0
  509. package/types/ngwr-spinner.d.ts +41 -0
  510. package/types/ngwr-splash-cursor.d.ts +94 -0
  511. package/types/ngwr-split-text.d.ts +83 -0
  512. package/types/ngwr-splitter.d.ts +52 -0
  513. package/types/ngwr-spotlight-card.d.ts +71 -0
  514. package/types/ngwr-squircle.d.ts +132 -0
  515. package/types/ngwr-star-border.d.ts +40 -0
  516. package/types/ngwr-statistic.d.ts +88 -0
  517. package/types/ngwr-stepper.d.ts +99 -0
  518. package/types/ngwr-storage.d.ts +178 -0
  519. package/types/ngwr-switch.d.ts +39 -0
  520. package/types/ngwr-table.d.ts +237 -0
  521. package/types/ngwr-tabs.d.ts +125 -0
  522. package/types/ngwr-textarea.d.ts +60 -0
  523. package/types/ngwr-theme.d.ts +124 -0
  524. package/types/ngwr-tilt-card.d.ts +63 -0
  525. package/types/ngwr-timeline.d.ts +40 -0
  526. package/types/ngwr-toast.d.ts +230 -0
  527. package/types/ngwr-toolbar.d.ts +30 -0
  528. package/types/ngwr-tree.d.ts +150 -0
  529. package/types/ngwr-typewriter.d.ts +84 -0
  530. package/types/ngwr-typography.d.ts +56 -0
  531. package/types/ngwr-utils.d.ts +447 -0
  532. package/types/ngwr-validators.d.ts +70 -0
  533. package/types/ngwr-version.d.ts +44 -0
  534. package/types/ngwr-virtual-scroll.d.ts +64 -0
  535. package/types/ngwr-waves.d.ts +71 -0
  536. package/types/ngwr-window.d.ts +437 -0
  537. package/types/ngwr.d.ts +2 -0
  538. package/typewriter/styles/_index.scss +33 -0
  539. package/typewriter/typewriter.scss +1 -0
  540. package/typography/styles/_index.scss +211 -0
  541. package/virtual-scroll/styles/_index.scss +27 -0
  542. package/virtual-scroll/virtual-scroll.scss +1 -0
  543. package/waves/styles/_index.scss +24 -0
  544. package/waves/waves.scss +1 -0
  545. package/window/styles/_index.scss +430 -0
  546. package/alert/alert.component.d.ts +0 -21
  547. package/alert/index.d.ts +0 -5
  548. package/alert/styles/theming.scss +0 -26
  549. package/alert/styles/vars.scss +0 -11
  550. package/avatar/avatar.component.d.ts +0 -27
  551. package/avatar/index.d.ts +0 -5
  552. package/button/button-group.component.d.ts +0 -12
  553. package/button/button.component.d.ts +0 -31
  554. package/button/index.d.ts +0 -5
  555. package/button/public-api.d.ts +0 -8
  556. package/button/styles/vars.scss +0 -13
  557. package/cdk/base.directive.d.ts +0 -20
  558. package/cdk/index.d.ts +0 -5
  559. package/cdk/rxjs/index.d.ts +0 -5
  560. package/cdk/rxjs/is-array.d.ts +0 -8
  561. package/cdk/rxjs/is-defined.d.ts +0 -8
  562. package/cdk/rxjs/is-not-empty-array.d.ts +0 -8
  563. package/cdk/rxjs/is-observable.d.ts +0 -9
  564. package/cdk/rxjs/public-api.d.ts +0 -10
  565. package/cdk/types/index.d.ts +0 -5
  566. package/cdk/types/maybe.d.ts +0 -7
  567. package/cdk/types/public-api.d.ts +0 -9
  568. package/cdk/types/safe-any.d.ts +0 -7
  569. package/cdk/types/theme-color.d.ts +0 -8
  570. package/cdk/utils/generate-random-id.d.ts +0 -12
  571. package/cdk/utils/index.d.ts +0 -5
  572. package/cdk/utils/public-api.d.ts +0 -7
  573. package/checkbox/checkbox.component.d.ts +0 -28
  574. package/checkbox/index.d.ts +0 -5
  575. package/checkbox/public-api.d.ts +0 -7
  576. package/checkbox/styles/vars.scss +0 -16
  577. package/dialog/dialog-animations.d.ts +0 -22
  578. package/dialog/dialog-base.directive.d.ts +0 -40
  579. package/dialog/dialog-close.directive.d.ts +0 -9
  580. package/dialog/dialog-content.directive.d.ts +0 -6
  581. package/dialog/dialog-data.token.d.ts +0 -8
  582. package/dialog/dialog-footer.directive.d.ts +0 -8
  583. package/dialog/dialog-options.d.ts +0 -19
  584. package/dialog/dialog-ref.d.ts +0 -26
  585. package/dialog/dialog-title.directive.d.ts +0 -6
  586. package/dialog/dialog.component.d.ts +0 -28
  587. package/dialog/dialog.module.d.ts +0 -6
  588. package/dialog/dialog.service.d.ts +0 -28
  589. package/dialog/index.d.ts +0 -5
  590. package/dialog/public-api.d.ts +0 -18
  591. package/dialog/styles/vars.scss +0 -7
  592. package/divider/divider.component.d.ts +0 -13
  593. package/divider/index.d.ts +0 -5
  594. package/divider/public-api.d.ts +0 -7
  595. package/dropdown/dropdown-menu-item.component.d.ts +0 -12
  596. package/dropdown/dropdown-menu.component.d.ts +0 -14
  597. package/dropdown/dropdown.directive.d.ts +0 -29
  598. package/dropdown/dropdown.types.d.ts +0 -9
  599. package/dropdown/index.d.ts +0 -5
  600. package/dropdown/public-api.d.ts +0 -10
  601. package/dropdown/styles/vars.scss +0 -18
  602. package/fesm2022/ngwr-cdk-rxjs.mjs +0 -53
  603. package/fesm2022/ngwr-cdk-rxjs.mjs.map +0 -1
  604. package/fesm2022/ngwr-cdk-types.mjs +0 -44
  605. package/fesm2022/ngwr-cdk-types.mjs.map +0 -1
  606. package/fesm2022/ngwr-cdk-utils.mjs +0 -30
  607. package/fesm2022/ngwr-cdk-utils.mjs.map +0 -1
  608. package/fesm2022/ngwr-cdk.mjs +0 -46
  609. package/fesm2022/ngwr-cdk.mjs.map +0 -1
  610. package/fesm2022/ngwr-tag.mjs +0 -87
  611. package/fesm2022/ngwr-tag.mjs.map +0 -1
  612. package/form/form-error.component.d.ts +0 -11
  613. package/form/form-item.component.d.ts +0 -14
  614. package/form/index.d.ts +0 -5
  615. package/form/public-api.d.ts +0 -8
  616. package/icon/icon.component.d.ts +0 -24
  617. package/icon/icon.service.d.ts +0 -23
  618. package/icon/icons.d.ts +0 -770
  619. package/icon/index.d.ts +0 -5
  620. package/icon/provide-wr-icons.d.ts +0 -9
  621. package/icon/public-api.d.ts +0 -10
  622. package/icon/styles/vars.scss +0 -3
  623. package/index.d.ts +0 -5
  624. package/input/index.d.ts +0 -5
  625. package/input/input-types.d.ts +0 -1
  626. package/input/input.component.d.ts +0 -38
  627. package/input/public-api.d.ts +0 -8
  628. package/input/styles/vars.scss +0 -17
  629. package/pagination/index.d.ts +0 -5
  630. package/pagination/pagination.component.d.ts +0 -23
  631. package/pagination/pagination.types.d.ts +0 -7
  632. package/pagination/public-api.d.ts +0 -8
  633. package/pagination/styles/vars.scss +0 -14
  634. package/pipes/index.d.ts +0 -5
  635. package/pipes/new-array.pipe.d.ts +0 -13
  636. package/pipes/public-api.d.ts +0 -7
  637. package/progress/index.d.ts +0 -5
  638. package/progress/progress.component.d.ts +0 -10
  639. package/progress/public-api.d.ts +0 -7
  640. package/progress/styles/theming.scss +0 -8
  641. package/progress/styles/vars.scss +0 -6
  642. package/public-api.d.ts +0 -2
  643. package/qr/generator.d.ts +0 -7
  644. package/qr/index.d.ts +0 -5
  645. package/qr/public-api.d.ts +0 -7
  646. package/qr/qr.component.d.ts +0 -31
  647. package/qr/qrcodegen.d.ts +0 -94
  648. package/select/index.d.ts +0 -5
  649. package/select/public-api.d.ts +0 -10
  650. package/select/select-option-group.component.d.ts +0 -19
  651. package/select/select-option.component.d.ts +0 -22
  652. package/select/select.component.d.ts +0 -63
  653. package/select/select.types.d.ts +0 -17
  654. package/select/styles/vars.scss +0 -32
  655. package/skeleton/index.d.ts +0 -1
  656. package/skeleton/skeleton.component.d.ts +0 -10
  657. package/spinner/index.d.ts +0 -1
  658. package/spinner/spinner.component.d.ts +0 -13
  659. package/spinner/spinner.types.d.ts +0 -7
  660. package/styles/animations.scss +0 -92
  661. package/styles/cdk.scss +0 -5
  662. package/styles/colors.scss +0 -72
  663. package/styles/grid.scss +0 -99
  664. package/styles/maps.scss +0 -31
  665. package/styles/reset.scss +0 -112
  666. package/styles/variables.scss +0 -72
  667. package/table/index.d.ts +0 -5
  668. package/table/public-api.d.ts +0 -11
  669. package/table/styles/table-filter.scss +0 -202
  670. package/table/styles/table-sort.scss +0 -47
  671. package/table/styles/table.scss +0 -232
  672. package/table/styles/vars.scss +0 -21
  673. package/table/table-cell/index.d.ts +0 -7
  674. package/table/table-cell/table-cell.directive.d.ts +0 -8
  675. package/table/table-filter/index.d.ts +0 -7
  676. package/table/table-filter/table-filter.component.d.ts +0 -18
  677. package/table/table-sort/index.d.ts +0 -7
  678. package/table/table-sort/table-sort.component.d.ts +0 -8
  679. package/table/table.component.d.ts +0 -33
  680. package/table/types/index.d.ts +0 -6
  681. package/table/types/table-cell-context.d.ts +0 -6
  682. package/table/types/table-columns.d.ts +0 -7
  683. package/table/types/table-filter-emit.d.ts +0 -5
  684. package/table/types/table-filter-item.d.ts +0 -6
  685. package/table/types/table-order-item.d.ts +0 -5
  686. package/table/types/table-order.enum.d.ts +0 -5
  687. package/tag/index.d.ts +0 -5
  688. package/tag/public-api.d.ts +0 -7
  689. package/tag/styles/_index.scss +0 -32
  690. package/tag/styles/theming.scss +0 -21
  691. package/tag/styles/vars.scss +0 -12
  692. package/tag/tag.component.d.ts +0 -21
  693. package/textarea/index.d.ts +0 -7
  694. package/textarea/public-api.d.ts +0 -7
  695. package/textarea/styles/vars.scss +0 -17
  696. package/textarea/textarea.component.d.ts +0 -44
@@ -0,0 +1,970 @@
1
+ import { coerceBooleanProperty } from '@angular/cdk/coercion';
2
+ import { isPlatformBrowser } from '@angular/common';
3
+ import * as i0 from '@angular/core';
4
+ import { input, viewChild, inject, NgZone, PLATFORM_ID, effect, ViewEncapsulation, Component } from '@angular/core';
5
+ import { WrPlatform } from 'ngwr/platform';
6
+ import { numAttr } from 'ngwr/utils';
7
+
8
+ /**
9
+ * @license
10
+ *
11
+ * Use of this source code is governed by an MIT-style license that can be
12
+ * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
13
+ *
14
+ * WebGL fluid simulation behind `<wr-splash-cursor>`. Port of the engine
15
+ * used by reactbits.dev's SplashCursor (itself based on Pavel Dobryakov's
16
+ * WebGL-Fluid-Simulation, MIT).
17
+ *
18
+ * Framework-free on purpose: `createFluidSimulation(canvas, config)` boots
19
+ * the sim and returns a teardown, or `null` when WebGL isn't available.
20
+ */
21
+ function createFluidSimulation(canvas, config) {
22
+ const ctx = getWebGLContext(canvas);
23
+ if (!ctx)
24
+ return null;
25
+ const { gl, ext } = ctx;
26
+ let dyeResolution = config.dyeResolution;
27
+ let shading = config.shading;
28
+ if (!ext.supportLinearFiltering) {
29
+ dyeResolution = 256;
30
+ shading = false;
31
+ }
32
+ let active = true;
33
+ let rafId = 0;
34
+ const pointer = {
35
+ texcoordX: 0,
36
+ texcoordY: 0,
37
+ prevTexcoordX: 0,
38
+ prevTexcoordY: 0,
39
+ deltaX: 0,
40
+ deltaY: 0,
41
+ moved: false,
42
+ color: { r: 0, g: 0, b: 0 },
43
+ };
44
+ // Shader plumbing
45
+ function compile(type, source, keywords) {
46
+ const prefixed = keywords ? keywords.map(k => `#define ${k}\n`).join('') + source : source;
47
+ const shader = gl.createShader(type);
48
+ gl.shaderSource(shader, prefixed);
49
+ gl.compileShader(shader);
50
+ if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
51
+ // eslint-disable-next-line no-console -- GPU shader failures are otherwise invisible
52
+ console.error('wr-splash-cursor shader error:', gl.getShaderInfoLog(shader));
53
+ }
54
+ return shader;
55
+ }
56
+ function link(vertex, fragment) {
57
+ const program = gl.createProgram();
58
+ gl.attachShader(program, vertex);
59
+ gl.attachShader(program, fragment);
60
+ gl.linkProgram(program);
61
+ if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
62
+ // eslint-disable-next-line no-console -- GPU link failures are otherwise invisible
63
+ console.error('wr-splash-cursor program error:', gl.getProgramInfoLog(program));
64
+ }
65
+ return program;
66
+ }
67
+ function uniformsOf(program) {
68
+ const out = {};
69
+ const count = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS);
70
+ for (let i = 0; i < count; i++) {
71
+ const name = gl.getActiveUniform(program, i).name;
72
+ out[name] = gl.getUniformLocation(program, name);
73
+ }
74
+ return out;
75
+ }
76
+ class ShaderProgram {
77
+ program;
78
+ uniforms;
79
+ constructor(vertex, fragment) {
80
+ this.program = link(vertex, fragment);
81
+ this.uniforms = uniformsOf(this.program);
82
+ }
83
+ bind() {
84
+ gl.useProgram(this.program);
85
+ }
86
+ }
87
+ /** Display shader with `#define`-keyword program variants. */
88
+ class DisplayMaterial {
89
+ vertex;
90
+ fragmentSource;
91
+ programs = new Map();
92
+ activeProgram = null;
93
+ uniforms = {};
94
+ constructor(vertex, fragmentSource) {
95
+ this.vertex = vertex;
96
+ this.fragmentSource = fragmentSource;
97
+ }
98
+ setKeywords(keywords) {
99
+ let hash = 0;
100
+ for (const k of keywords)
101
+ hash += hashCode(k);
102
+ let program = this.programs.get(hash);
103
+ if (!program) {
104
+ program = link(this.vertex, compile(gl.FRAGMENT_SHADER, this.fragmentSource, keywords));
105
+ this.programs.set(hash, program);
106
+ }
107
+ if (program === this.activeProgram)
108
+ return;
109
+ this.uniforms = uniformsOf(program);
110
+ this.activeProgram = program;
111
+ }
112
+ bind() {
113
+ gl.useProgram(this.activeProgram);
114
+ }
115
+ }
116
+ // Shaders
117
+ const baseVertexShader = compile(gl.VERTEX_SHADER, `
118
+ precision highp float;
119
+ attribute vec2 aPosition;
120
+ varying vec2 vUv;
121
+ varying vec2 vL;
122
+ varying vec2 vR;
123
+ varying vec2 vT;
124
+ varying vec2 vB;
125
+ uniform vec2 texelSize;
126
+
127
+ void main () {
128
+ vUv = aPosition * 0.5 + 0.5;
129
+ vL = vUv - vec2(texelSize.x, 0.0);
130
+ vR = vUv + vec2(texelSize.x, 0.0);
131
+ vT = vUv + vec2(0.0, texelSize.y);
132
+ vB = vUv - vec2(0.0, texelSize.y);
133
+ gl_Position = vec4(aPosition, 0.0, 1.0);
134
+ }
135
+ `);
136
+ const copyShader = compile(gl.FRAGMENT_SHADER, `
137
+ precision mediump float;
138
+ precision mediump sampler2D;
139
+ varying highp vec2 vUv;
140
+ uniform sampler2D uTexture;
141
+
142
+ void main () {
143
+ gl_FragColor = texture2D(uTexture, vUv);
144
+ }
145
+ `);
146
+ const clearShader = compile(gl.FRAGMENT_SHADER, `
147
+ precision mediump float;
148
+ precision mediump sampler2D;
149
+ varying highp vec2 vUv;
150
+ uniform sampler2D uTexture;
151
+ uniform float value;
152
+
153
+ void main () {
154
+ gl_FragColor = value * texture2D(uTexture, vUv);
155
+ }
156
+ `);
157
+ const displayShaderSource = `
158
+ precision highp float;
159
+ precision highp sampler2D;
160
+ varying vec2 vUv;
161
+ varying vec2 vL;
162
+ varying vec2 vR;
163
+ varying vec2 vT;
164
+ varying vec2 vB;
165
+ uniform sampler2D uTexture;
166
+ uniform vec2 texelSize;
167
+
168
+ void main () {
169
+ vec3 c = texture2D(uTexture, vUv).rgb;
170
+ #ifdef SHADING
171
+ vec3 lc = texture2D(uTexture, vL).rgb;
172
+ vec3 rc = texture2D(uTexture, vR).rgb;
173
+ vec3 tc = texture2D(uTexture, vT).rgb;
174
+ vec3 bc = texture2D(uTexture, vB).rgb;
175
+
176
+ float dx = length(rc) - length(lc);
177
+ float dy = length(tc) - length(bc);
178
+
179
+ vec3 n = normalize(vec3(dx, dy, length(texelSize)));
180
+ vec3 l = vec3(0.0, 0.0, 1.0);
181
+
182
+ float diffuse = clamp(dot(n, l) + 0.7, 0.7, 1.0);
183
+ c *= diffuse;
184
+ #endif
185
+
186
+ float a = max(c.r, max(c.g, c.b));
187
+ gl_FragColor = vec4(c, a);
188
+ }
189
+ `;
190
+ const splatShader = compile(gl.FRAGMENT_SHADER, `
191
+ precision highp float;
192
+ precision highp sampler2D;
193
+ varying vec2 vUv;
194
+ uniform sampler2D uTarget;
195
+ uniform float aspectRatio;
196
+ uniform vec3 color;
197
+ uniform vec2 point;
198
+ uniform float radius;
199
+
200
+ void main () {
201
+ vec2 p = vUv - point.xy;
202
+ p.x *= aspectRatio;
203
+ vec3 splat = exp(-dot(p, p) / radius) * color;
204
+ vec3 base = texture2D(uTarget, vUv).xyz;
205
+ gl_FragColor = vec4(base + splat, 1.0);
206
+ }
207
+ `);
208
+ const advectionShader = compile(gl.FRAGMENT_SHADER, `
209
+ precision highp float;
210
+ precision highp sampler2D;
211
+ varying vec2 vUv;
212
+ uniform sampler2D uVelocity;
213
+ uniform sampler2D uSource;
214
+ uniform vec2 texelSize;
215
+ uniform vec2 dyeTexelSize;
216
+ uniform float dt;
217
+ uniform float dissipation;
218
+
219
+ vec4 bilerp (sampler2D sam, vec2 uv, vec2 tsize) {
220
+ vec2 st = uv / tsize - 0.5;
221
+ vec2 iuv = floor(st);
222
+ vec2 fuv = fract(st);
223
+
224
+ vec4 a = texture2D(sam, (iuv + vec2(0.5, 0.5)) * tsize);
225
+ vec4 b = texture2D(sam, (iuv + vec2(1.5, 0.5)) * tsize);
226
+ vec4 c = texture2D(sam, (iuv + vec2(0.5, 1.5)) * tsize);
227
+ vec4 d = texture2D(sam, (iuv + vec2(1.5, 1.5)) * tsize);
228
+
229
+ return mix(mix(a, b, fuv.x), mix(c, d, fuv.x), fuv.y);
230
+ }
231
+
232
+ void main () {
233
+ #ifdef MANUAL_FILTERING
234
+ vec2 coord = vUv - dt * bilerp(uVelocity, vUv, texelSize).xy * texelSize;
235
+ vec4 result = bilerp(uSource, coord, dyeTexelSize);
236
+ #else
237
+ vec2 coord = vUv - dt * texture2D(uVelocity, vUv).xy * texelSize;
238
+ vec4 result = texture2D(uSource, coord);
239
+ #endif
240
+ float decay = 1.0 + dissipation * dt;
241
+ gl_FragColor = result / decay;
242
+ }
243
+ `, ext.supportLinearFiltering ? undefined : ['MANUAL_FILTERING']);
244
+ const divergenceShader = compile(gl.FRAGMENT_SHADER, `
245
+ precision mediump float;
246
+ precision mediump sampler2D;
247
+ varying highp vec2 vUv;
248
+ varying highp vec2 vL;
249
+ varying highp vec2 vR;
250
+ varying highp vec2 vT;
251
+ varying highp vec2 vB;
252
+ uniform sampler2D uVelocity;
253
+
254
+ void main () {
255
+ float L = texture2D(uVelocity, vL).x;
256
+ float R = texture2D(uVelocity, vR).x;
257
+ float T = texture2D(uVelocity, vT).y;
258
+ float B = texture2D(uVelocity, vB).y;
259
+
260
+ vec2 C = texture2D(uVelocity, vUv).xy;
261
+ if (vL.x < 0.0) { L = -C.x; }
262
+ if (vR.x > 1.0) { R = -C.x; }
263
+ if (vT.y > 1.0) { T = -C.y; }
264
+ if (vB.y < 0.0) { B = -C.y; }
265
+
266
+ float div = 0.5 * (R - L + T - B);
267
+ gl_FragColor = vec4(div, 0.0, 0.0, 1.0);
268
+ }
269
+ `);
270
+ const curlShader = compile(gl.FRAGMENT_SHADER, `
271
+ precision mediump float;
272
+ precision mediump sampler2D;
273
+ varying highp vec2 vUv;
274
+ varying highp vec2 vL;
275
+ varying highp vec2 vR;
276
+ varying highp vec2 vT;
277
+ varying highp vec2 vB;
278
+ uniform sampler2D uVelocity;
279
+
280
+ void main () {
281
+ float L = texture2D(uVelocity, vL).y;
282
+ float R = texture2D(uVelocity, vR).y;
283
+ float T = texture2D(uVelocity, vT).x;
284
+ float B = texture2D(uVelocity, vB).x;
285
+ float vorticity = R - L - T + B;
286
+ gl_FragColor = vec4(0.5 * vorticity, 0.0, 0.0, 1.0);
287
+ }
288
+ `);
289
+ const vorticityShader = compile(gl.FRAGMENT_SHADER, `
290
+ precision highp float;
291
+ precision highp sampler2D;
292
+ varying vec2 vUv;
293
+ varying vec2 vL;
294
+ varying vec2 vR;
295
+ varying vec2 vT;
296
+ varying vec2 vB;
297
+ uniform sampler2D uVelocity;
298
+ uniform sampler2D uCurl;
299
+ uniform float curl;
300
+ uniform float dt;
301
+
302
+ void main () {
303
+ float L = texture2D(uCurl, vL).x;
304
+ float R = texture2D(uCurl, vR).x;
305
+ float T = texture2D(uCurl, vT).x;
306
+ float B = texture2D(uCurl, vB).x;
307
+ float C = texture2D(uCurl, vUv).x;
308
+
309
+ vec2 force = 0.5 * vec2(abs(T) - abs(B), abs(R) - abs(L));
310
+ force /= length(force) + 0.0001;
311
+ force *= curl * C;
312
+ force.y *= -1.0;
313
+
314
+ vec2 velocity = texture2D(uVelocity, vUv).xy;
315
+ velocity += force * dt;
316
+ velocity = min(max(velocity, -1000.0), 1000.0);
317
+ gl_FragColor = vec4(velocity, 0.0, 1.0);
318
+ }
319
+ `);
320
+ const pressureShader = compile(gl.FRAGMENT_SHADER, `
321
+ precision mediump float;
322
+ precision mediump sampler2D;
323
+ varying highp vec2 vUv;
324
+ varying highp vec2 vL;
325
+ varying highp vec2 vR;
326
+ varying highp vec2 vT;
327
+ varying highp vec2 vB;
328
+ uniform sampler2D uPressure;
329
+ uniform sampler2D uDivergence;
330
+
331
+ void main () {
332
+ float L = texture2D(uPressure, vL).x;
333
+ float R = texture2D(uPressure, vR).x;
334
+ float T = texture2D(uPressure, vT).x;
335
+ float B = texture2D(uPressure, vB).x;
336
+ float C = texture2D(uPressure, vUv).x;
337
+ float divergence = texture2D(uDivergence, vUv).x;
338
+ float pressure = (L + R + B + T - divergence) * 0.25;
339
+ gl_FragColor = vec4(pressure, 0.0, 0.0, 1.0);
340
+ }
341
+ `);
342
+ const gradientSubtractShader = compile(gl.FRAGMENT_SHADER, `
343
+ precision mediump float;
344
+ precision mediump sampler2D;
345
+ varying highp vec2 vUv;
346
+ varying highp vec2 vL;
347
+ varying highp vec2 vR;
348
+ varying highp vec2 vT;
349
+ varying highp vec2 vB;
350
+ uniform sampler2D uPressure;
351
+ uniform sampler2D uVelocity;
352
+
353
+ void main () {
354
+ float L = texture2D(uPressure, vL).x;
355
+ float R = texture2D(uPressure, vR).x;
356
+ float T = texture2D(uPressure, vT).x;
357
+ float B = texture2D(uPressure, vB).x;
358
+ vec2 velocity = texture2D(uVelocity, vUv).xy;
359
+ velocity.xy -= vec2(R - L, T - B);
360
+ gl_FragColor = vec4(velocity, 0.0, 1.0);
361
+ }
362
+ `);
363
+ // Fullscreen blit
364
+ gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer());
365
+ gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, -1, 1, 1, 1, 1, -1]), gl.STATIC_DRAW);
366
+ gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, gl.createBuffer());
367
+ gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array([0, 1, 2, 0, 2, 3]), gl.STATIC_DRAW);
368
+ gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);
369
+ gl.enableVertexAttribArray(0);
370
+ function blit(target, clear = false) {
371
+ if (target === null) {
372
+ gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
373
+ gl.bindFramebuffer(gl.FRAMEBUFFER, null);
374
+ }
375
+ else {
376
+ gl.viewport(0, 0, target.width, target.height);
377
+ gl.bindFramebuffer(gl.FRAMEBUFFER, target.fbo);
378
+ }
379
+ if (clear) {
380
+ gl.clearColor(0.0, 0.0, 0.0, 1.0);
381
+ gl.clear(gl.COLOR_BUFFER_BIT);
382
+ }
383
+ gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0);
384
+ }
385
+ // Framebuffers
386
+ function createFBO(w, h, internalFormat, format, type, param) {
387
+ gl.activeTexture(gl.TEXTURE0);
388
+ const texture = gl.createTexture();
389
+ gl.bindTexture(gl.TEXTURE_2D, texture);
390
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, param);
391
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, param);
392
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
393
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
394
+ gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, w, h, 0, format, type, null);
395
+ const fbo = gl.createFramebuffer();
396
+ gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
397
+ gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
398
+ gl.viewport(0, 0, w, h);
399
+ gl.clear(gl.COLOR_BUFFER_BIT);
400
+ return {
401
+ texture,
402
+ fbo,
403
+ width: w,
404
+ height: h,
405
+ texelSizeX: 1 / w,
406
+ texelSizeY: 1 / h,
407
+ attach(id) {
408
+ gl.activeTexture(gl.TEXTURE0 + id);
409
+ gl.bindTexture(gl.TEXTURE_2D, texture);
410
+ return id;
411
+ },
412
+ };
413
+ }
414
+ function createDoubleFBO(w, h, internalFormat, format, type, param) {
415
+ let fbo1 = createFBO(w, h, internalFormat, format, type, param);
416
+ let fbo2 = createFBO(w, h, internalFormat, format, type, param);
417
+ return {
418
+ width: w,
419
+ height: h,
420
+ texelSizeX: fbo1.texelSizeX,
421
+ texelSizeY: fbo1.texelSizeY,
422
+ get read() {
423
+ return fbo1;
424
+ },
425
+ set read(value) {
426
+ fbo1 = value;
427
+ },
428
+ get write() {
429
+ return fbo2;
430
+ },
431
+ set write(value) {
432
+ fbo2 = value;
433
+ },
434
+ swap() {
435
+ const temp = fbo1;
436
+ fbo1 = fbo2;
437
+ fbo2 = temp;
438
+ },
439
+ };
440
+ }
441
+ function resizeFBO(target, w, h, internalFormat, format, type, param) {
442
+ const newFBO = createFBO(w, h, internalFormat, format, type, param);
443
+ copyProgram.bind();
444
+ gl.uniform1i(copyProgram.uniforms['uTexture'], target.attach(0));
445
+ blit(newFBO);
446
+ return newFBO;
447
+ }
448
+ function resizeDoubleFBO(target, w, h, internalFormat, format, type, param) {
449
+ if (target.width === w && target.height === h)
450
+ return target;
451
+ target.read = resizeFBO(target.read, w, h, internalFormat, format, type, param);
452
+ target.write = createFBO(w, h, internalFormat, format, type, param);
453
+ target.width = w;
454
+ target.height = h;
455
+ target.texelSizeX = 1 / w;
456
+ target.texelSizeY = 1 / h;
457
+ return target;
458
+ }
459
+ // Programs + state
460
+ const copyProgram = new ShaderProgram(baseVertexShader, copyShader);
461
+ const clearProgram = new ShaderProgram(baseVertexShader, clearShader);
462
+ const splatProgram = new ShaderProgram(baseVertexShader, splatShader);
463
+ const advectionProgram = new ShaderProgram(baseVertexShader, advectionShader);
464
+ const divergenceProgram = new ShaderProgram(baseVertexShader, divergenceShader);
465
+ const curlProgram = new ShaderProgram(baseVertexShader, curlShader);
466
+ const vorticityProgram = new ShaderProgram(baseVertexShader, vorticityShader);
467
+ const pressureProgram = new ShaderProgram(baseVertexShader, pressureShader);
468
+ const gradientSubtractProgram = new ShaderProgram(baseVertexShader, gradientSubtractShader);
469
+ const displayMaterial = new DisplayMaterial(baseVertexShader, displayShaderSource);
470
+ let dye;
471
+ let velocity;
472
+ let divergence;
473
+ let curl;
474
+ let pressure;
475
+ function initFramebuffers() {
476
+ const simRes = getResolution(config.simResolution);
477
+ const dyeRes = getResolution(dyeResolution);
478
+ const texType = ext.halfFloatTexType;
479
+ const rgba = ext.formatRGBA;
480
+ const rg = ext.formatRG;
481
+ const r = ext.formatR;
482
+ const filtering = ext.supportLinearFiltering ? gl.LINEAR : gl.NEAREST;
483
+ gl.disable(gl.BLEND);
484
+ dye = dye
485
+ ? resizeDoubleFBO(dye, dyeRes.width, dyeRes.height, rgba.internalFormat, rgba.format, texType, filtering)
486
+ : createDoubleFBO(dyeRes.width, dyeRes.height, rgba.internalFormat, rgba.format, texType, filtering);
487
+ velocity = velocity
488
+ ? resizeDoubleFBO(velocity, simRes.width, simRes.height, rg.internalFormat, rg.format, texType, filtering)
489
+ : createDoubleFBO(simRes.width, simRes.height, rg.internalFormat, rg.format, texType, filtering);
490
+ divergence = createFBO(simRes.width, simRes.height, r.internalFormat, r.format, texType, gl.NEAREST);
491
+ curl = createFBO(simRes.width, simRes.height, r.internalFormat, r.format, texType, gl.NEAREST);
492
+ pressure = createDoubleFBO(simRes.width, simRes.height, r.internalFormat, r.format, texType, gl.NEAREST);
493
+ }
494
+ displayMaterial.setKeywords(shading ? ['SHADING'] : []);
495
+ initFramebuffers();
496
+ let lastUpdateTime = Date.now();
497
+ let colorUpdateTimer = 0;
498
+ // Frame loop
499
+ function updateFrame() {
500
+ if (!active)
501
+ return;
502
+ const dt = calcDeltaTime();
503
+ if (resizeCanvas())
504
+ initFramebuffers();
505
+ updateColors(dt);
506
+ applyInputs();
507
+ step(dt);
508
+ render();
509
+ rafId = requestAnimationFrame(updateFrame);
510
+ }
511
+ function calcDeltaTime() {
512
+ const now = Date.now();
513
+ const dt = Math.min((now - lastUpdateTime) / 1000, 0.016666);
514
+ lastUpdateTime = now;
515
+ return dt;
516
+ }
517
+ function resizeCanvas() {
518
+ const width = scaleByPixelRatio(canvas.clientWidth);
519
+ const height = scaleByPixelRatio(canvas.clientHeight);
520
+ if (canvas.width !== width || canvas.height !== height) {
521
+ canvas.width = width;
522
+ canvas.height = height;
523
+ return true;
524
+ }
525
+ return false;
526
+ }
527
+ function updateColors(dt) {
528
+ colorUpdateTimer += dt * config.colorUpdateSpeed;
529
+ if (colorUpdateTimer >= 1) {
530
+ colorUpdateTimer = wrap(colorUpdateTimer, 0, 1);
531
+ pointer.color = generateColor();
532
+ }
533
+ }
534
+ function applyInputs() {
535
+ if (pointer.moved) {
536
+ pointer.moved = false;
537
+ splatPointer();
538
+ }
539
+ }
540
+ function step(dt) {
541
+ gl.disable(gl.BLEND);
542
+ curlProgram.bind();
543
+ gl.uniform2f(curlProgram.uniforms['texelSize'], velocity.texelSizeX, velocity.texelSizeY);
544
+ gl.uniform1i(curlProgram.uniforms['uVelocity'], velocity.read.attach(0));
545
+ blit(curl);
546
+ vorticityProgram.bind();
547
+ gl.uniform2f(vorticityProgram.uniforms['texelSize'], velocity.texelSizeX, velocity.texelSizeY);
548
+ gl.uniform1i(vorticityProgram.uniforms['uVelocity'], velocity.read.attach(0));
549
+ gl.uniform1i(vorticityProgram.uniforms['uCurl'], curl.attach(1));
550
+ gl.uniform1f(vorticityProgram.uniforms['curl'], config.curl);
551
+ gl.uniform1f(vorticityProgram.uniforms['dt'], dt);
552
+ blit(velocity.write);
553
+ velocity.swap();
554
+ divergenceProgram.bind();
555
+ gl.uniform2f(divergenceProgram.uniforms['texelSize'], velocity.texelSizeX, velocity.texelSizeY);
556
+ gl.uniform1i(divergenceProgram.uniforms['uVelocity'], velocity.read.attach(0));
557
+ blit(divergence);
558
+ clearProgram.bind();
559
+ gl.uniform1i(clearProgram.uniforms['uTexture'], pressure.read.attach(0));
560
+ gl.uniform1f(clearProgram.uniforms['value'], config.pressure);
561
+ blit(pressure.write);
562
+ pressure.swap();
563
+ pressureProgram.bind();
564
+ gl.uniform2f(pressureProgram.uniforms['texelSize'], velocity.texelSizeX, velocity.texelSizeY);
565
+ gl.uniform1i(pressureProgram.uniforms['uDivergence'], divergence.attach(0));
566
+ for (let i = 0; i < config.pressureIterations; i++) {
567
+ gl.uniform1i(pressureProgram.uniforms['uPressure'], pressure.read.attach(1));
568
+ blit(pressure.write);
569
+ pressure.swap();
570
+ }
571
+ gradientSubtractProgram.bind();
572
+ gl.uniform2f(gradientSubtractProgram.uniforms['texelSize'], velocity.texelSizeX, velocity.texelSizeY);
573
+ gl.uniform1i(gradientSubtractProgram.uniforms['uPressure'], pressure.read.attach(0));
574
+ gl.uniform1i(gradientSubtractProgram.uniforms['uVelocity'], velocity.read.attach(1));
575
+ blit(velocity.write);
576
+ velocity.swap();
577
+ advectionProgram.bind();
578
+ gl.uniform2f(advectionProgram.uniforms['texelSize'], velocity.texelSizeX, velocity.texelSizeY);
579
+ if (!ext.supportLinearFiltering) {
580
+ gl.uniform2f(advectionProgram.uniforms['dyeTexelSize'], velocity.texelSizeX, velocity.texelSizeY);
581
+ }
582
+ const velocityId = velocity.read.attach(0);
583
+ gl.uniform1i(advectionProgram.uniforms['uVelocity'], velocityId);
584
+ gl.uniform1i(advectionProgram.uniforms['uSource'], velocityId);
585
+ gl.uniform1f(advectionProgram.uniforms['dt'], dt);
586
+ gl.uniform1f(advectionProgram.uniforms['dissipation'], config.velocityDissipation);
587
+ blit(velocity.write);
588
+ velocity.swap();
589
+ if (!ext.supportLinearFiltering) {
590
+ gl.uniform2f(advectionProgram.uniforms['dyeTexelSize'], dye.texelSizeX, dye.texelSizeY);
591
+ }
592
+ gl.uniform1i(advectionProgram.uniforms['uVelocity'], velocity.read.attach(0));
593
+ gl.uniform1i(advectionProgram.uniforms['uSource'], dye.read.attach(1));
594
+ gl.uniform1f(advectionProgram.uniforms['dissipation'], config.densityDissipation);
595
+ blit(dye.write);
596
+ dye.swap();
597
+ }
598
+ function render() {
599
+ gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
600
+ gl.enable(gl.BLEND);
601
+ displayMaterial.bind();
602
+ if (shading) {
603
+ gl.uniform2f(displayMaterial.uniforms['texelSize'], 1 / gl.drawingBufferWidth, 1 / gl.drawingBufferHeight);
604
+ }
605
+ gl.uniform1i(displayMaterial.uniforms['uTexture'], dye.read.attach(0));
606
+ blit(null);
607
+ }
608
+ // Splats
609
+ function splatPointer() {
610
+ const dx = pointer.deltaX * config.splatForce;
611
+ const dy = pointer.deltaY * config.splatForce;
612
+ splat(pointer.texcoordX, pointer.texcoordY, dx, dy, pointer.color);
613
+ }
614
+ function clickSplat() {
615
+ const color = generateColor();
616
+ color.r *= 10;
617
+ color.g *= 10;
618
+ color.b *= 10;
619
+ const dx = 10 * (Math.random() - 0.5);
620
+ const dy = 30 * (Math.random() - 0.5);
621
+ splat(pointer.texcoordX, pointer.texcoordY, dx, dy, color);
622
+ }
623
+ function splat(x, y, dx, dy, color) {
624
+ splatProgram.bind();
625
+ gl.uniform1i(splatProgram.uniforms['uTarget'], velocity.read.attach(0));
626
+ gl.uniform1f(splatProgram.uniforms['aspectRatio'], canvas.width / canvas.height);
627
+ gl.uniform2f(splatProgram.uniforms['point'], x, y);
628
+ gl.uniform3f(splatProgram.uniforms['color'], dx, dy, 0);
629
+ gl.uniform1f(splatProgram.uniforms['radius'], correctRadius(config.splatRadius / 100));
630
+ blit(velocity.write);
631
+ velocity.swap();
632
+ gl.uniform1i(splatProgram.uniforms['uTarget'], dye.read.attach(0));
633
+ gl.uniform3f(splatProgram.uniforms['color'], color.r, color.g, color.b);
634
+ blit(dye.write);
635
+ dye.swap();
636
+ }
637
+ function correctRadius(radius) {
638
+ const aspectRatio = canvas.width / canvas.height;
639
+ return aspectRatio > 1 ? radius * aspectRatio : radius;
640
+ }
641
+ // Pointer
642
+ function pointerDown(posX, posY) {
643
+ pointer.moved = false;
644
+ pointer.texcoordX = posX / canvas.width;
645
+ pointer.texcoordY = 1 - posY / canvas.height;
646
+ pointer.prevTexcoordX = pointer.texcoordX;
647
+ pointer.prevTexcoordY = pointer.texcoordY;
648
+ pointer.deltaX = 0;
649
+ pointer.deltaY = 0;
650
+ pointer.color = generateColor();
651
+ }
652
+ function pointerMove(posX, posY, color) {
653
+ pointer.prevTexcoordX = pointer.texcoordX;
654
+ pointer.prevTexcoordY = pointer.texcoordY;
655
+ pointer.texcoordX = posX / canvas.width;
656
+ pointer.texcoordY = 1 - posY / canvas.height;
657
+ pointer.deltaX = correctDeltaX(pointer.texcoordX - pointer.prevTexcoordX);
658
+ pointer.deltaY = correctDeltaY(pointer.texcoordY - pointer.prevTexcoordY);
659
+ pointer.moved = Math.abs(pointer.deltaX) > 0 || Math.abs(pointer.deltaY) > 0;
660
+ pointer.color = color;
661
+ }
662
+ function correctDeltaX(delta) {
663
+ const aspectRatio = canvas.width / canvas.height;
664
+ return aspectRatio < 1 ? delta * aspectRatio : delta;
665
+ }
666
+ function correctDeltaY(delta) {
667
+ const aspectRatio = canvas.width / canvas.height;
668
+ return aspectRatio > 1 ? delta / aspectRatio : delta;
669
+ }
670
+ // Colours
671
+ function hexToRGB(hex) {
672
+ let val = hex.replace('#', '');
673
+ if (val.length === 3)
674
+ val = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
675
+ return {
676
+ r: (Number.parseInt(val.slice(0, 2), 16) / 255) * 0.15,
677
+ g: (Number.parseInt(val.slice(2, 4), 16) / 255) * 0.15,
678
+ b: (Number.parseInt(val.slice(4, 6), 16) / 255) * 0.15,
679
+ };
680
+ }
681
+ function generateColor() {
682
+ if (!config.rainbow)
683
+ return hexToRGB(config.color);
684
+ const c = hsvToRgb(Math.random(), 1, 1);
685
+ c.r *= 0.15;
686
+ c.g *= 0.15;
687
+ c.b *= 0.15;
688
+ return c;
689
+ }
690
+ function hsvToRgb(h, s, v) {
691
+ const i = Math.floor(h * 6);
692
+ const f = h * 6 - i;
693
+ const p = v * (1 - s);
694
+ const q = v * (1 - f * s);
695
+ const t = v * (1 - (1 - f) * s);
696
+ switch (i % 6) {
697
+ case 0:
698
+ return { r: v, g: t, b: p };
699
+ case 1:
700
+ return { r: q, g: v, b: p };
701
+ case 2:
702
+ return { r: p, g: v, b: t };
703
+ case 3:
704
+ return { r: p, g: q, b: v };
705
+ case 4:
706
+ return { r: t, g: p, b: v };
707
+ default:
708
+ return { r: v, g: p, b: q };
709
+ }
710
+ }
711
+ function wrap(value, min, max) {
712
+ const range = max - min;
713
+ if (range === 0)
714
+ return min;
715
+ return ((value - min) % range) + min;
716
+ }
717
+ function getResolution(resolution) {
718
+ let aspectRatio = gl.drawingBufferWidth / gl.drawingBufferHeight;
719
+ if (aspectRatio < 1)
720
+ aspectRatio = 1 / aspectRatio;
721
+ const min = Math.round(resolution);
722
+ const max = Math.round(resolution * aspectRatio);
723
+ return gl.drawingBufferWidth > gl.drawingBufferHeight ? { width: max, height: min } : { width: min, height: max };
724
+ }
725
+ function scaleByPixelRatio(input) {
726
+ return Math.floor(input * (window.devicePixelRatio || 1));
727
+ }
728
+ function hashCode(s) {
729
+ let hash = 0;
730
+ for (let i = 0; i < s.length; i++) {
731
+ hash = (hash << 5) - hash + s.charCodeAt(i);
732
+ hash |= 0;
733
+ }
734
+ return hash;
735
+ }
736
+ // Events + boot
737
+ let firstMoveHandled = false;
738
+ // Coordinates are taken relative to the canvas box: identical to the
739
+ // raw client position for the fullscreen overlay, and it makes a
740
+ // contained canvas track the pointer correctly too.
741
+ const toLocal = (clientX, clientY) => {
742
+ const rect = canvas.getBoundingClientRect();
743
+ return { x: scaleByPixelRatio(clientX - rect.left), y: scaleByPixelRatio(clientY - rect.top) };
744
+ };
745
+ const onMouseDown = (e) => {
746
+ const pos = toLocal(e.clientX, e.clientY);
747
+ pointerDown(pos.x, pos.y);
748
+ clickSplat();
749
+ };
750
+ const onMouseMove = (e) => {
751
+ const pos = toLocal(e.clientX, e.clientY);
752
+ const color = firstMoveHandled ? pointer.color : generateColor();
753
+ firstMoveHandled = true;
754
+ pointerMove(pos.x, pos.y, color);
755
+ };
756
+ const onTouchStart = (e) => {
757
+ const t = e.targetTouches[0];
758
+ if (!t)
759
+ return;
760
+ const pos = toLocal(t.clientX, t.clientY);
761
+ pointerDown(pos.x, pos.y);
762
+ };
763
+ const onTouchMove = (e) => {
764
+ const t = e.targetTouches[0];
765
+ if (!t)
766
+ return;
767
+ const pos = toLocal(t.clientX, t.clientY);
768
+ pointerMove(pos.x, pos.y, pointer.color);
769
+ };
770
+ window.addEventListener('mousedown', onMouseDown);
771
+ window.addEventListener('mousemove', onMouseMove);
772
+ window.addEventListener('touchstart', onTouchStart, { passive: true });
773
+ window.addEventListener('touchmove', onTouchMove, { passive: true });
774
+ updateFrame();
775
+ return () => {
776
+ active = false;
777
+ cancelAnimationFrame(rafId);
778
+ window.removeEventListener('mousedown', onMouseDown);
779
+ window.removeEventListener('mousemove', onMouseMove);
780
+ window.removeEventListener('touchstart', onTouchStart);
781
+ window.removeEventListener('touchmove', onTouchMove);
782
+ // The context is NOT lost here on purpose — input changes reboot the
783
+ // sim on the same canvas, and a lost context can't be re-acquired.
784
+ };
785
+ }
786
+ // WebGL context bootstrap
787
+ function getWebGLContext(canvas) {
788
+ const params = {
789
+ alpha: true,
790
+ depth: false,
791
+ stencil: false,
792
+ antialias: false,
793
+ preserveDrawingBuffer: false,
794
+ };
795
+ const gl2 = canvas.getContext('webgl2', params);
796
+ const gl = gl2 ?? canvas.getContext('webgl', params);
797
+ if (!gl)
798
+ return null;
799
+ const isWebGL2 = !!gl2;
800
+ let halfFloat = null;
801
+ let supportLinearFiltering;
802
+ if (isWebGL2) {
803
+ gl.getExtension('EXT_color_buffer_float');
804
+ supportLinearFiltering = !!gl.getExtension('OES_texture_float_linear');
805
+ }
806
+ else {
807
+ halfFloat = gl.getExtension('OES_texture_half_float');
808
+ supportLinearFiltering = !!gl.getExtension('OES_texture_half_float_linear');
809
+ }
810
+ gl.clearColor(0, 0, 0, 1);
811
+ const halfFloatTexType = isWebGL2
812
+ ? gl.HALF_FLOAT
813
+ : (halfFloat?.HALF_FLOAT_OES ?? gl.UNSIGNED_BYTE);
814
+ let formatRGBA;
815
+ let formatRG;
816
+ let formatR;
817
+ if (isWebGL2) {
818
+ const g2 = gl;
819
+ formatRGBA = getSupportedFormat(g2, g2.RGBA16F, g2.RGBA, halfFloatTexType);
820
+ formatRG = getSupportedFormat(g2, g2.RG16F, g2.RG, halfFloatTexType);
821
+ formatR = getSupportedFormat(g2, g2.R16F, g2.RED, halfFloatTexType);
822
+ }
823
+ else {
824
+ formatRGBA = getSupportedFormat(gl, gl.RGBA, gl.RGBA, halfFloatTexType);
825
+ formatRG = formatRGBA;
826
+ formatR = formatRGBA;
827
+ }
828
+ if (!formatRGBA || !formatRG || !formatR)
829
+ return null;
830
+ return { gl, ext: { formatRGBA, formatRG, formatR, halfFloatTexType, supportLinearFiltering } };
831
+ }
832
+ function getSupportedFormat(gl, internalFormat, format, type) {
833
+ if (!supportRenderTextureFormat(gl, internalFormat, format, type)) {
834
+ const g2 = gl;
835
+ switch (internalFormat) {
836
+ case g2.R16F:
837
+ return getSupportedFormat(gl, g2.RG16F, g2.RG, type);
838
+ case g2.RG16F:
839
+ return getSupportedFormat(gl, g2.RGBA16F, g2.RGBA, type);
840
+ default:
841
+ return null;
842
+ }
843
+ }
844
+ return { internalFormat, format };
845
+ }
846
+ function supportRenderTextureFormat(gl, internalFormat, format, type) {
847
+ const texture = gl.createTexture();
848
+ gl.bindTexture(gl.TEXTURE_2D, texture);
849
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
850
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
851
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
852
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
853
+ gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, 4, 4, 0, format, type, null);
854
+ const fbo = gl.createFramebuffer();
855
+ gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
856
+ gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
857
+ return gl.checkFramebufferStatus(gl.FRAMEBUFFER) === gl.FRAMEBUFFER_COMPLETE;
858
+ }
859
+
860
+ /**
861
+ * @license
862
+ *
863
+ * Use of this source code is governed by an MIT-style license that can be
864
+ * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
865
+ *
866
+ * Angular adaptation of the SplashCursor effect by David Haz / reactbits.dev.
867
+ * Original: https://www.reactbits.dev/animations/splash-cursor
868
+ */
869
+ /**
870
+ * Splash cursor — a WebGL fluid simulation that splashes colourful dye
871
+ * wherever the pointer moves or clicks. Renders as a fixed, full-viewport,
872
+ * click-through overlay; mount it once on a page (it follows the pointer
873
+ * everywhere) and it tears down with the component.
874
+ *
875
+ * Renders nothing under `prefers-reduced-motion` or when WebGL is
876
+ * unavailable.
877
+ *
878
+ * @example
879
+ * ```html
880
+ * <wr-splash-cursor />
881
+ * <wr-splash-cursor [rainbow]="false" color="#5227ff" />
882
+ * ```
883
+ *
884
+ * @see https://ngwr.dev/animations/splash-cursor
885
+ */
886
+ class WrSplashCursor {
887
+ /**
888
+ * `true` overlays the whole viewport (reactbits behaviour); `false`
889
+ * fills the nearest positioned ancestor instead — handy for demo boxes,
890
+ * and the dye collides with the box walls. @default true
891
+ */
892
+ fullscreen = input(true, { ...(ngDevMode ? { debugName: "fullscreen" } : /* istanbul ignore next */ {}), transform: coerceBooleanProperty });
893
+ /** Velocity / pressure grid resolution. @default 128 */
894
+ simResolution = input(128, { ...(ngDevMode ? { debugName: "simResolution" } : /* istanbul ignore next */ {}), transform: numAttr(128) });
895
+ /** Dye texture resolution — the visible detail. @default 1440 */
896
+ dyeResolution = input(1440, { ...(ngDevMode ? { debugName: "dyeResolution" } : /* istanbul ignore next */ {}), transform: numAttr(1440) });
897
+ /** How fast the dye fades, higher = shorter trails. @default 3.5 */
898
+ densityDissipation = input(3.5, { ...(ngDevMode ? { debugName: "densityDissipation" } : /* istanbul ignore next */ {}), transform: numAttr(3.5) });
899
+ /** How fast motion settles. @default 2 */
900
+ velocityDissipation = input(2, { ...(ngDevMode ? { debugName: "velocityDissipation" } : /* istanbul ignore next */ {}), transform: numAttr(2) });
901
+ /** Pressure retained between frames, 0..1. @default 0.1 */
902
+ pressure = input(0.1, { ...(ngDevMode ? { debugName: "pressure" } : /* istanbul ignore next */ {}), transform: numAttr(0.1) });
903
+ /** Jacobi iterations for the pressure solve. @default 20 */
904
+ pressureIterations = input(20, { ...(ngDevMode ? { debugName: "pressureIterations" } : /* istanbul ignore next */ {}), transform: numAttr(20) });
905
+ /** Vorticity confinement — swirliness. @default 3 */
906
+ curl = input(3, { ...(ngDevMode ? { debugName: "curl" } : /* istanbul ignore next */ {}), transform: numAttr(3) });
907
+ /** Splat size. @default 0.2 */
908
+ splatRadius = input(0.2, { ...(ngDevMode ? { debugName: "splatRadius" } : /* istanbul ignore next */ {}), transform: numAttr(0.2) });
909
+ /** Velocity a pointer move injects. @default 6000 */
910
+ splatForce = input(6000, { ...(ngDevMode ? { debugName: "splatForce" } : /* istanbul ignore next */ {}), transform: numAttr(6000) });
911
+ /** Pseudo-3D shading on the dye. @default true */
912
+ shading = input(true, { ...(ngDevMode ? { debugName: "shading" } : /* istanbul ignore next */ {}), transform: coerceBooleanProperty });
913
+ /** How fast the splat colour cycles. @default 10 */
914
+ colorUpdateSpeed = input(10, { ...(ngDevMode ? { debugName: "colorUpdateSpeed" } : /* istanbul ignore next */ {}), transform: numAttr(10) });
915
+ /** Cycle splat colours through the rainbow. @default true */
916
+ rainbow = input(true, { ...(ngDevMode ? { debugName: "rainbow" } : /* istanbul ignore next */ {}), transform: coerceBooleanProperty });
917
+ /** Fixed splat colour when `rainbow` is off. @default '#ff0000' */
918
+ color = input('#ff0000', /* @ts-ignore */
919
+ ...(ngDevMode ? [{ debugName: "color" }] : /* istanbul ignore next */ []));
920
+ canvasRef = viewChild('canvas', /* @ts-ignore */
921
+ ...(ngDevMode ? [{ debugName: "canvasRef" }] : /* istanbul ignore next */ []));
922
+ zone = inject(NgZone);
923
+ platform = inject(WrPlatform);
924
+ isBrowser = isPlatformBrowser(inject(PLATFORM_ID));
925
+ constructor() {
926
+ if (!this.isBrowser)
927
+ return;
928
+ // (Re)boot whenever the canvas appears, any input changes, or the OS
929
+ // reduced-motion preference flips. `onCleanup` tears the old sim down.
930
+ effect(onCleanup => {
931
+ const canvas = this.canvasRef()?.nativeElement;
932
+ const config = {
933
+ simResolution: this.simResolution(),
934
+ dyeResolution: this.dyeResolution(),
935
+ densityDissipation: this.densityDissipation(),
936
+ velocityDissipation: this.velocityDissipation(),
937
+ pressure: this.pressure(),
938
+ pressureIterations: this.pressureIterations(),
939
+ curl: this.curl(),
940
+ splatRadius: this.splatRadius(),
941
+ splatForce: this.splatForce(),
942
+ shading: this.shading(),
943
+ colorUpdateSpeed: this.colorUpdateSpeed(),
944
+ rainbow: this.rainbow(),
945
+ color: this.color(),
946
+ };
947
+ if (!canvas || this.platform.prefersReducedMotion())
948
+ return;
949
+ const teardown = this.zone.runOutsideAngular(() => createFluidSimulation(canvas, config));
950
+ if (teardown)
951
+ onCleanup(teardown);
952
+ });
953
+ }
954
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: WrSplashCursor, deps: [], target: i0.ɵɵFactoryTarget.Component });
955
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.0.1", type: WrSplashCursor, isStandalone: true, selector: "wr-splash-cursor", inputs: { fullscreen: { classPropertyName: "fullscreen", publicName: "fullscreen", isSignal: true, isRequired: false, transformFunction: null }, simResolution: { classPropertyName: "simResolution", publicName: "simResolution", isSignal: true, isRequired: false, transformFunction: null }, dyeResolution: { classPropertyName: "dyeResolution", publicName: "dyeResolution", isSignal: true, isRequired: false, transformFunction: null }, densityDissipation: { classPropertyName: "densityDissipation", publicName: "densityDissipation", isSignal: true, isRequired: false, transformFunction: null }, velocityDissipation: { classPropertyName: "velocityDissipation", publicName: "velocityDissipation", isSignal: true, isRequired: false, transformFunction: null }, pressure: { classPropertyName: "pressure", publicName: "pressure", isSignal: true, isRequired: false, transformFunction: null }, pressureIterations: { classPropertyName: "pressureIterations", publicName: "pressureIterations", isSignal: true, isRequired: false, transformFunction: null }, curl: { classPropertyName: "curl", publicName: "curl", isSignal: true, isRequired: false, transformFunction: null }, splatRadius: { classPropertyName: "splatRadius", publicName: "splatRadius", isSignal: true, isRequired: false, transformFunction: null }, splatForce: { classPropertyName: "splatForce", publicName: "splatForce", isSignal: true, isRequired: false, transformFunction: null }, shading: { classPropertyName: "shading", publicName: "shading", isSignal: true, isRequired: false, transformFunction: null }, colorUpdateSpeed: { classPropertyName: "colorUpdateSpeed", publicName: "colorUpdateSpeed", isSignal: true, isRequired: false, transformFunction: null }, rainbow: { classPropertyName: "rainbow", publicName: "rainbow", isSignal: true, isRequired: false, transformFunction: null }, color: { classPropertyName: "color", publicName: "color", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.wr-splash-cursor--contained": "!fullscreen()" }, classAttribute: "wr-splash-cursor" }, viewQueries: [{ propertyName: "canvasRef", first: true, predicate: ["canvas"], descendants: true, isSignal: true }], ngImport: i0, template: '<canvas #canvas class="wr-splash-cursor__canvas"></canvas>', isInline: true, styles: [".wr-splash-cursor{position:fixed;inset:0;z-index:50;display:block;pointer-events:none}.wr-splash-cursor__canvas{display:block;width:100vw;height:100vh}.wr-splash-cursor--contained{position:absolute;z-index:0}.wr-splash-cursor--contained .wr-splash-cursor__canvas{width:100%;height:100%}\n"], encapsulation: i0.ViewEncapsulation.None });
956
+ }
957
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: WrSplashCursor, decorators: [{
958
+ type: Component,
959
+ args: [{ selector: 'wr-splash-cursor', template: '<canvas #canvas class="wr-splash-cursor__canvas"></canvas>', encapsulation: ViewEncapsulation.None, host: {
960
+ class: 'wr-splash-cursor',
961
+ '[class.wr-splash-cursor--contained]': '!fullscreen()',
962
+ }, styles: [".wr-splash-cursor{position:fixed;inset:0;z-index:50;display:block;pointer-events:none}.wr-splash-cursor__canvas{display:block;width:100vw;height:100vh}.wr-splash-cursor--contained{position:absolute;z-index:0}.wr-splash-cursor--contained .wr-splash-cursor__canvas{width:100%;height:100%}\n"] }]
963
+ }], ctorParameters: () => [], propDecorators: { fullscreen: [{ type: i0.Input, args: [{ isSignal: true, alias: "fullscreen", required: false }] }], simResolution: [{ type: i0.Input, args: [{ isSignal: true, alias: "simResolution", required: false }] }], dyeResolution: [{ type: i0.Input, args: [{ isSignal: true, alias: "dyeResolution", required: false }] }], densityDissipation: [{ type: i0.Input, args: [{ isSignal: true, alias: "densityDissipation", required: false }] }], velocityDissipation: [{ type: i0.Input, args: [{ isSignal: true, alias: "velocityDissipation", required: false }] }], pressure: [{ type: i0.Input, args: [{ isSignal: true, alias: "pressure", required: false }] }], pressureIterations: [{ type: i0.Input, args: [{ isSignal: true, alias: "pressureIterations", required: false }] }], curl: [{ type: i0.Input, args: [{ isSignal: true, alias: "curl", required: false }] }], splatRadius: [{ type: i0.Input, args: [{ isSignal: true, alias: "splatRadius", required: false }] }], splatForce: [{ type: i0.Input, args: [{ isSignal: true, alias: "splatForce", required: false }] }], shading: [{ type: i0.Input, args: [{ isSignal: true, alias: "shading", required: false }] }], colorUpdateSpeed: [{ type: i0.Input, args: [{ isSignal: true, alias: "colorUpdateSpeed", required: false }] }], rainbow: [{ type: i0.Input, args: [{ isSignal: true, alias: "rainbow", required: false }] }], color: [{ type: i0.Input, args: [{ isSignal: true, alias: "color", required: false }] }], canvasRef: [{ type: i0.ViewChild, args: ['canvas', { isSignal: true }] }] } });
964
+
965
+ /**
966
+ * Generated bundle index. Do not edit.
967
+ */
968
+
969
+ export { WrSplashCursor };
970
+ //# sourceMappingURL=ngwr-splash-cursor.mjs.map