@splendidlabz/utils 1.11.3 → 1.11.4

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 (408) hide show
  1. package/dist/cjs/dom/accessibility.cjs +53 -0
  2. package/dist/cjs/dom/actions/index.cjs +410 -0
  3. package/dist/cjs/dom/actions/masonry.cjs +152 -0
  4. package/dist/cjs/dom/actions/prefer-horizontal-scroll.cjs +157 -0
  5. package/dist/cjs/dom/actions/sticky.cjs +213 -0
  6. package/dist/cjs/dom/bounding-box.cjs +70 -0
  7. package/dist/cjs/dom/clipboard.cjs +37 -0
  8. package/dist/cjs/dom/cookie.cjs +57 -0
  9. package/dist/cjs/dom/css-vars.cjs +57 -0
  10. package/dist/cjs/dom/events.cjs +59 -0
  11. package/{src/dom/focusable.js → dist/cjs/dom/focusable.cjs} +51 -73
  12. package/dist/cjs/dom/font-size.cjs +80 -0
  13. package/dist/cjs/dom/get-element.cjs +98 -0
  14. package/dist/cjs/dom/hash.cjs +35 -0
  15. package/dist/cjs/dom/index.cjs +1267 -0
  16. package/dist/cjs/dom/keyboard.cjs +51 -0
  17. package/dist/cjs/dom/local-store.cjs +79 -0
  18. package/dist/cjs/dom/media.cjs +59 -0
  19. package/dist/cjs/dom/observers/index.cjs +253 -0
  20. package/dist/cjs/dom/observers/intersection-observer.cjs +91 -0
  21. package/dist/cjs/dom/observers/mutation-observer.cjs +95 -0
  22. package/dist/cjs/dom/observers/observer.cjs +48 -0
  23. package/dist/cjs/dom/observers/resize-observer.cjs +84 -0
  24. package/dist/cjs/dom/observers/scroll-observer.cjs +177 -0
  25. package/dist/cjs/dom/pkce.cjs +53 -0
  26. package/dist/cjs/dom/query-params.cjs +38 -0
  27. package/dist/cjs/dom/random-string.cjs +38 -0
  28. package/dist/cjs/dom/sanitize.cjs +65 -0
  29. package/dist/cjs/dom/session-store.cjs +49 -0
  30. package/dist/cjs/dom/spam-prevention.cjs +50 -0
  31. package/dist/cjs/dom/trap-focus.cjs +197 -0
  32. package/dist/cjs/dom/ui/aria-current.cjs +43 -0
  33. package/dist/cjs/dom/ui/inconsistent-button-fix.cjs +35 -0
  34. package/dist/cjs/dom/ui/index.cjs +105 -0
  35. package/dist/cjs/dom/ui/scroll-container.cjs +47 -0
  36. package/dist/cjs/dom/ui/traverse-and-scramble.cjs +50 -0
  37. package/dist/cjs/lib/arrays/index.cjs +139 -0
  38. package/dist/cjs/lib/arrays/item-position.cjs +42 -0
  39. package/dist/cjs/lib/arrays/join.cjs +43 -0
  40. package/dist/cjs/lib/arrays/shuffle.cjs +42 -0
  41. package/dist/cjs/lib/arrays/sort.cjs +67 -0
  42. package/dist/cjs/lib/arrays/split-array.cjs +41 -0
  43. package/dist/cjs/lib/arrays/unique.cjs +31 -0
  44. package/dist/cjs/lib/auth/index.cjs +53 -0
  45. package/dist/cjs/lib/auth/route-manager.cjs +51 -0
  46. package/dist/cjs/lib/checks.cjs +63 -0
  47. package/dist/cjs/lib/date/days.cjs +37 -0
  48. package/dist/cjs/lib/date/index.cjs +208 -0
  49. package/dist/cjs/lib/date/months.cjs +102 -0
  50. package/dist/cjs/lib/date/time.cjs +117 -0
  51. package/dist/cjs/lib/form/form-data.cjs +83 -0
  52. package/dist/cjs/lib/form/index.cjs +122 -0
  53. package/dist/cjs/lib/form/sanitize.cjs +61 -0
  54. package/dist/cjs/lib/functions/callback.cjs +31 -0
  55. package/dist/cjs/lib/functions/debounce.cjs +43 -0
  56. package/dist/cjs/lib/functions/env.cjs +32 -0
  57. package/dist/cjs/lib/functions/functional.cjs +82 -0
  58. package/dist/cjs/lib/functions/index.cjs +142 -0
  59. package/dist/cjs/lib/functions/throttle.cjs +38 -0
  60. package/dist/cjs/lib/functions/timeout.cjs +41 -0
  61. package/dist/cjs/lib/hash.cjs +43 -0
  62. package/dist/cjs/lib/index.cjs +1178 -0
  63. package/dist/cjs/lib/numbers/index.cjs +49 -0
  64. package/dist/cjs/lib/numbers/math.cjs +36 -0
  65. package/dist/cjs/lib/objects/camelcase-keys.cjs +80 -0
  66. package/dist/cjs/lib/objects/empty.cjs +39 -0
  67. package/dist/cjs/lib/objects/equal.cjs +47 -0
  68. package/dist/cjs/lib/objects/extend.cjs +147 -0
  69. package/dist/cjs/lib/objects/flatten.cjs +48 -0
  70. package/dist/cjs/lib/objects/index.cjs +378 -0
  71. package/dist/cjs/lib/objects/json.cjs +35 -0
  72. package/dist/cjs/lib/objects/loop.cjs +40 -0
  73. package/dist/cjs/lib/objects/mix/mix.cjs +115 -0
  74. package/dist/cjs/lib/objects/nested-property.cjs +45 -0
  75. package/dist/cjs/lib/objects/normalize-object.cjs +106 -0
  76. package/dist/cjs/lib/objects/omit-empty.cjs +40 -0
  77. package/dist/cjs/lib/objects/size.cjs +63 -0
  78. package/dist/cjs/lib/objects/split.cjs +39 -0
  79. package/dist/cjs/lib/promises/index.cjs +69 -0
  80. package/dist/cjs/lib/promises/reject.cjs +67 -0
  81. package/dist/cjs/lib/sse.cjs +99 -0
  82. package/dist/cjs/lib/strings/convert-case/convert-case.cjs +96 -0
  83. package/dist/cjs/lib/strings/index.cjs +197 -0
  84. package/dist/cjs/lib/strings/markdown.cjs +76 -0
  85. package/dist/cjs/lib/strings/name.cjs +46 -0
  86. package/dist/cjs/lib/strings/pluralize.cjs +40 -0
  87. package/dist/cjs/lib/strings/query-string.cjs +43 -0
  88. package/dist/cjs/lib/style/index.cjs +64 -0
  89. package/dist/cjs/lib/symbols/index.cjs +40 -0
  90. package/dist/cjs/lib/symbols/symbols.cjs +38 -0
  91. package/dist/cjs/node/dirname.cjs +49 -0
  92. package/dist/cjs/node/file-cache.cjs +200 -0
  93. package/dist/cjs/node/file.cjs +50 -0
  94. package/dist/cjs/node/hash.cjs +42 -0
  95. package/dist/cjs/node/index.cjs +296 -0
  96. package/dist/cjs/node/pkce.cjs +64 -0
  97. package/dist/cjs/node/random-string.cjs +43 -0
  98. package/dist/cjs/node/sanitize.cjs +65 -0
  99. package/dist/cjs/node/uuid.cjs +42 -0
  100. package/dist/esm/dom/accessibility.js +26 -0
  101. package/dist/esm/dom/actions/index.js +3 -0
  102. package/dist/esm/dom/actions/masonry.js +38 -0
  103. package/dist/esm/dom/actions/prefer-horizontal-scroll.js +90 -0
  104. package/dist/esm/dom/actions/sticky.js +70 -0
  105. package/dist/esm/dom/bounding-box.js +44 -0
  106. package/dist/esm/dom/clipboard.js +12 -0
  107. package/dist/esm/dom/cookie.js +31 -0
  108. package/dist/esm/dom/css-vars.js +21 -0
  109. package/dist/esm/dom/events.js +31 -0
  110. package/dist/esm/dom/focusable.js +117 -0
  111. package/dist/esm/dom/font-size.js +40 -0
  112. package/dist/esm/dom/get-element.js +66 -0
  113. package/dist/esm/dom/hash.js +10 -0
  114. package/dist/esm/dom/index.js +23 -0
  115. package/dist/esm/dom/keyboard.js +22 -0
  116. package/{src → dist/esm}/dom/local-store.js +16 -28
  117. package/dist/esm/dom/media.js +32 -0
  118. package/dist/esm/dom/observers/index.js +4 -0
  119. package/dist/esm/dom/observers/intersection-observer.js +36 -0
  120. package/dist/esm/dom/observers/mutation-observer.js +40 -0
  121. package/dist/esm/dom/observers/observer.js +15 -0
  122. package/dist/esm/dom/observers/resize-observer.js +29 -0
  123. package/dist/esm/dom/observers/scroll-observer.js +95 -0
  124. package/dist/esm/dom/pkce.js +20 -0
  125. package/dist/esm/dom/query-params.js +13 -0
  126. package/dist/esm/dom/random-string.js +12 -0
  127. package/dist/esm/dom/sanitize.js +8 -0
  128. package/dist/esm/dom/session-store.js +24 -0
  129. package/dist/esm/dom/spam-prevention.js +25 -0
  130. package/dist/esm/dom/trap-focus.js +51 -0
  131. package/dist/esm/dom/ui/aria-current.js +17 -0
  132. package/dist/esm/dom/ui/inconsistent-button-fix.js +10 -0
  133. package/dist/esm/dom/ui/index.js +4 -0
  134. package/dist/esm/dom/ui/scroll-container.js +22 -0
  135. package/dist/esm/dom/ui/traverse-and-scramble.js +25 -0
  136. package/dist/esm/lib/arrays/index.js +6 -0
  137. package/dist/esm/lib/arrays/item-position.js +15 -0
  138. package/dist/esm/lib/arrays/join.js +12 -0
  139. package/dist/esm/lib/arrays/shuffle.js +17 -0
  140. package/dist/esm/lib/arrays/sort.js +36 -0
  141. package/dist/esm/lib/arrays/split-array.js +16 -0
  142. package/dist/esm/lib/arrays/unique.js +6 -0
  143. package/dist/esm/lib/auth/index.js +1 -0
  144. package/dist/esm/lib/auth/route-manager.js +25 -0
  145. package/dist/esm/lib/checks.js +34 -0
  146. package/dist/esm/lib/date/days.js +12 -0
  147. package/dist/esm/lib/date/index.js +3 -0
  148. package/dist/esm/lib/date/months.js +77 -0
  149. package/dist/esm/lib/date/time.js +75 -0
  150. package/dist/esm/lib/form/form-data.js +57 -0
  151. package/dist/esm/lib/form/index.js +2 -0
  152. package/dist/esm/lib/form/sanitize.js +34 -0
  153. package/dist/esm/lib/functions/callback.js +6 -0
  154. package/dist/esm/lib/functions/debounce.js +18 -0
  155. package/dist/esm/lib/functions/env.js +7 -0
  156. package/dist/esm/lib/functions/functional.js +52 -0
  157. package/dist/esm/lib/functions/index.js +5 -0
  158. package/dist/esm/lib/functions/throttle.js +13 -0
  159. package/dist/esm/lib/functions/timeout.js +14 -0
  160. package/dist/esm/lib/hash.js +18 -0
  161. package/dist/esm/lib/index.js +14 -0
  162. package/dist/esm/lib/numbers/index.js +11 -0
  163. package/dist/esm/lib/numbers/math.js +10 -0
  164. package/dist/esm/lib/objects/camelcase-keys.js +16 -0
  165. package/dist/esm/lib/objects/empty.js +13 -0
  166. package/dist/esm/lib/objects/equal.js +11 -0
  167. package/dist/esm/lib/objects/extend.js +13 -0
  168. package/dist/esm/lib/objects/flatten.js +17 -0
  169. package/dist/esm/lib/objects/index.js +13 -0
  170. package/dist/esm/lib/objects/json.js +10 -0
  171. package/dist/esm/lib/objects/loop.js +14 -0
  172. package/dist/esm/lib/objects/mix/mix.js +88 -0
  173. package/dist/esm/lib/objects/nested-property.js +18 -0
  174. package/dist/esm/lib/objects/normalize-object.js +9 -0
  175. package/dist/esm/lib/objects/omit-empty.js +15 -0
  176. package/dist/esm/lib/objects/size.js +38 -0
  177. package/dist/esm/lib/objects/split.js +14 -0
  178. package/dist/esm/lib/promises/index.js +1 -0
  179. package/dist/esm/lib/promises/reject.js +17 -0
  180. package/dist/esm/lib/sse.js +50 -0
  181. package/dist/esm/lib/strings/convert-case/convert-case.js +64 -0
  182. package/dist/esm/lib/strings/index.js +5 -0
  183. package/dist/esm/lib/strings/markdown.js +40 -0
  184. package/dist/esm/lib/strings/name.js +21 -0
  185. package/dist/esm/lib/strings/pluralize.js +5 -0
  186. package/dist/esm/lib/strings/query-string.js +16 -0
  187. package/dist/esm/lib/style/index.js +12 -0
  188. package/dist/esm/lib/symbols/index.js +1 -0
  189. package/dist/esm/lib/symbols/symbols.js +12 -0
  190. package/dist/esm/node/context.js +0 -0
  191. package/dist/esm/node/dirname.js +13 -0
  192. package/dist/esm/node/file-cache.js +121 -0
  193. package/dist/esm/node/file.js +14 -0
  194. package/dist/esm/node/hash.js +7 -0
  195. package/dist/esm/node/index.js +7 -0
  196. package/dist/esm/node/pkce.js +20 -0
  197. package/dist/esm/node/random-string.js +8 -0
  198. package/dist/esm/node/sanitize.js +8 -0
  199. package/dist/esm/node/uuid.js +7 -0
  200. package/dist/types/dom/accessibility.d.cts +30 -0
  201. package/dist/types/dom/actions/index.d.cts +3 -0
  202. package/dist/types/dom/actions/masonry.d.cts +5 -0
  203. package/dist/types/dom/actions/prefer-horizontal-scroll.d.cts +5 -0
  204. package/dist/types/dom/actions/sticky.d.cts +5 -0
  205. package/{src/dom/bounding-box.js → dist/types/dom/bounding-box.d.cts} +8 -49
  206. package/dist/types/dom/clipboard.d.cts +7 -0
  207. package/dist/types/dom/cookie.d.cts +7 -0
  208. package/dist/types/dom/css-vars.d.cts +6 -0
  209. package/{src/dom/events.js → dist/types/dom/events.d.cts} +52 -31
  210. package/dist/types/dom/focusable.d.cts +78 -0
  211. package/dist/types/dom/font-size.d.cts +8 -0
  212. package/{src/dom/get-element.js → dist/types/dom/get-element.d.cts} +25 -99
  213. package/dist/types/dom/hash.d.cts +3 -0
  214. package/dist/types/dom/index.d.cts +31 -0
  215. package/{src/dom/keyboard.js → dist/types/dom/keyboard.d.cts} +7 -19
  216. package/dist/types/dom/local-store.d.cts +31 -0
  217. package/dist/types/dom/media.d.cts +5 -0
  218. package/dist/types/dom/observers/index.d.cts +4 -0
  219. package/dist/types/dom/observers/intersection-observer.d.cts +10 -0
  220. package/dist/types/dom/observers/mutation-observer.d.cts +9 -0
  221. package/dist/types/dom/observers/observer.d.cts +3 -0
  222. package/{src/dom/observers/resize-observer.js → dist/types/dom/observers/resize-observer.d.cts} +6 -32
  223. package/dist/types/dom/observers/scroll-observer.d.cts +40 -0
  224. package/dist/types/dom/pkce.d.cts +8 -0
  225. package/dist/types/dom/query-params.d.cts +6 -0
  226. package/dist/types/dom/random-string.d.cts +9 -0
  227. package/dist/types/dom/sanitize.d.cts +10 -0
  228. package/dist/types/dom/session-store.d.cts +7 -0
  229. package/dist/types/dom/spam-prevention.d.cts +14 -0
  230. package/dist/types/dom/trap-focus.d.cts +32 -0
  231. package/dist/types/dom/ui/aria-current.d.cts +7 -0
  232. package/{src/dom/ui/inconsistent-button-fix.js → dist/types/dom/ui/inconsistent-button-fix.d.cts} +5 -11
  233. package/dist/types/dom/ui/index.d.cts +4 -0
  234. package/dist/types/dom/ui/scroll-container.d.cts +3 -0
  235. package/dist/types/dom/ui/traverse-and-scramble.d.cts +21 -0
  236. package/dist/types/lib/arrays/index.d.cts +6 -0
  237. package/{src/lib/arrays/item-position.js → dist/types/lib/arrays/item-position.d.cts} +5 -12
  238. package/{src/lib/arrays/join.js → dist/types/lib/arrays/join.d.cts} +4 -9
  239. package/dist/types/lib/arrays/shuffle.d.cts +3 -0
  240. package/dist/types/lib/arrays/sort.d.cts +32 -0
  241. package/dist/types/lib/arrays/split-array.d.cts +6 -0
  242. package/dist/types/lib/arrays/unique.d.cts +3 -0
  243. package/dist/types/lib/auth/index.d.cts +1 -0
  244. package/dist/types/lib/auth/route-manager.d.cts +28 -0
  245. package/dist/types/lib/checks.d.cts +33 -0
  246. package/dist/types/lib/date/days.d.cts +7 -0
  247. package/dist/types/lib/date/index.d.cts +3 -0
  248. package/dist/types/lib/date/months.d.cts +11 -0
  249. package/dist/types/lib/date/time.d.cts +21 -0
  250. package/dist/types/lib/form/form-data.d.cts +9 -0
  251. package/dist/types/lib/form/index.d.cts +2 -0
  252. package/{src/lib/form/sanitize.js → dist/types/lib/form/sanitize.d.cts} +19 -39
  253. package/{src/lib/functions/callback.js → dist/types/lib/functions/callback.d.cts} +3 -3
  254. package/dist/types/lib/functions/debounce.d.cts +3 -0
  255. package/dist/types/lib/functions/env.d.cts +3 -0
  256. package/{src/lib/functions/functional.js → dist/types/lib/functions/functional.d.cts} +8 -49
  257. package/dist/types/lib/functions/index.d.cts +5 -0
  258. package/dist/types/lib/functions/throttle.d.cts +3 -0
  259. package/dist/types/lib/functions/timeout.d.cts +5 -0
  260. package/dist/types/lib/hash.d.cts +3 -0
  261. package/dist/types/lib/index.d.cts +43 -0
  262. package/dist/types/lib/numbers/index.d.cts +5 -0
  263. package/dist/types/lib/numbers/math.d.cts +4 -0
  264. package/dist/types/lib/objects/camelcase-keys.d.cts +3 -0
  265. package/dist/types/lib/objects/empty.d.cts +4 -0
  266. package/dist/types/lib/objects/equal.d.cts +4 -0
  267. package/dist/types/lib/objects/extend.d.cts +6 -0
  268. package/dist/types/lib/objects/flatten.d.cts +6 -0
  269. package/dist/types/lib/objects/index.d.cts +13 -0
  270. package/dist/types/lib/objects/json.d.cts +3 -0
  271. package/dist/types/lib/objects/loop.d.cts +4 -0
  272. package/dist/types/lib/objects/mix/mix.d.cts +44 -0
  273. package/{src/lib/objects/nested-property.js → dist/types/lib/objects/nested-property.d.cts} +4 -21
  274. package/dist/types/lib/objects/normalize-object.d.cts +3 -0
  275. package/dist/types/lib/objects/omit-empty.d.cts +3 -0
  276. package/dist/types/lib/objects/size.d.cts +3 -0
  277. package/dist/types/lib/objects/split.d.cts +14 -0
  278. package/dist/types/lib/promises/index.d.cts +1 -0
  279. package/dist/types/lib/promises/reject.d.cts +5 -0
  280. package/dist/types/lib/sse.d.cts +18 -0
  281. package/dist/types/lib/strings/convert-case/convert-case.d.cts +10 -0
  282. package/dist/types/lib/strings/index.d.cts +5 -0
  283. package/dist/types/lib/strings/markdown.d.cts +25 -0
  284. package/dist/types/lib/strings/name.d.cts +7 -0
  285. package/dist/types/lib/strings/pluralize.d.cts +3 -0
  286. package/dist/types/lib/strings/query-string.d.cts +10 -0
  287. package/dist/types/lib/style/index.d.cts +3 -0
  288. package/dist/types/lib/symbols/index.d.cts +1 -0
  289. package/dist/types/lib/symbols/symbols.d.cts +4 -0
  290. package/dist/types/node/context.d.cts +2 -0
  291. package/dist/types/node/dirname.d.cts +9 -0
  292. package/dist/types/node/file-cache.d.cts +56 -0
  293. package/dist/types/node/file.d.cts +4 -0
  294. package/dist/types/node/hash.d.cts +3 -0
  295. package/dist/types/node/index.d.cts +7 -0
  296. package/dist/types/node/pkce.d.cts +14 -0
  297. package/dist/types/node/random-string.d.cts +3 -0
  298. package/{src/node/sanitize.js → dist/types/node/sanitize.d.cts} +3 -6
  299. package/dist/types/node/uuid.d.cts +3 -0
  300. package/package.json +4 -1
  301. package/CHANGELOG.md +0 -237
  302. package/eslint.config.js +0 -2
  303. package/src/dom/accessibility.js +0 -58
  304. package/src/dom/actions/index.js +0 -3
  305. package/src/dom/actions/masonry.js +0 -43
  306. package/src/dom/actions/prefer-horizontal-scroll.js +0 -121
  307. package/src/dom/actions/sticky.js +0 -85
  308. package/src/dom/clipboard.js +0 -14
  309. package/src/dom/cookie.js +0 -32
  310. package/src/dom/css-vars.js +0 -19
  311. package/src/dom/font-size.js +0 -40
  312. package/src/dom/hash.js +0 -9
  313. package/src/dom/index.js +0 -23
  314. package/src/dom/media.js +0 -30
  315. package/src/dom/observers/index.js +0 -4
  316. package/src/dom/observers/intersection-observer.js +0 -43
  317. package/src/dom/observers/mutation-observer.js +0 -51
  318. package/src/dom/observers/observer.js +0 -18
  319. package/src/dom/observers/scroll-observer.js +0 -146
  320. package/src/dom/pkce.js +0 -34
  321. package/src/dom/query-params.js +0 -14
  322. package/src/dom/random-string.js +0 -18
  323. package/src/dom/random-string.test.js +0 -13
  324. package/src/dom/sanitize.js +0 -16
  325. package/src/dom/session-store.js +0 -29
  326. package/src/dom/spam-prevention.js +0 -40
  327. package/src/dom/trap-focus.js +0 -70
  328. package/src/dom/ui/aria-current.js +0 -20
  329. package/src/dom/ui/index.js +0 -4
  330. package/src/dom/ui/scroll-container.js +0 -25
  331. package/src/dom/ui/traverse-and-scramble.js +0 -61
  332. package/src/lib/arrays/index.js +0 -6
  333. package/src/lib/arrays/shuffle.js +0 -21
  334. package/src/lib/arrays/sort.js +0 -88
  335. package/src/lib/arrays/sort.spec.js +0 -123
  336. package/src/lib/arrays/split-array.js +0 -15
  337. package/src/lib/arrays/unique.js +0 -3
  338. package/src/lib/auth/index.js +0 -1
  339. package/src/lib/auth/route-manager.js +0 -45
  340. package/src/lib/checks.js +0 -57
  341. package/src/lib/date/days.js +0 -9
  342. package/src/lib/date/index.js +0 -3
  343. package/src/lib/date/months.js +0 -74
  344. package/src/lib/date/time.js +0 -83
  345. package/src/lib/form/form-data.js +0 -73
  346. package/src/lib/form/index.js +0 -2
  347. package/src/lib/form/sanitize.spec.js +0 -126
  348. package/src/lib/functions/debounce.js +0 -18
  349. package/src/lib/functions/env.js +0 -5
  350. package/src/lib/functions/functional.test.js +0 -196
  351. package/src/lib/functions/index.js +0 -5
  352. package/src/lib/functions/throttle.js +0 -11
  353. package/src/lib/functions/timeout.js +0 -15
  354. package/src/lib/hash.js +0 -18
  355. package/src/lib/hash.spec.js +0 -163
  356. package/src/lib/index.js +0 -14
  357. package/src/lib/numbers/index.js +0 -12
  358. package/src/lib/numbers/math.js +0 -9
  359. package/src/lib/numbers/split-unit.test.js +0 -45
  360. package/src/lib/objects/camelcase-keys.js +0 -17
  361. package/src/lib/objects/camelcase-keys.test.js +0 -72
  362. package/src/lib/objects/empty.js +0 -10
  363. package/src/lib/objects/equal.js +0 -9
  364. package/src/lib/objects/extend.js +0 -16
  365. package/src/lib/objects/extend.test.js +0 -35
  366. package/src/lib/objects/flatten.js +0 -19
  367. package/src/lib/objects/index.js +0 -13
  368. package/src/lib/objects/json.js +0 -7
  369. package/src/lib/objects/loop.js +0 -11
  370. package/src/lib/objects/loop.test.js +0 -31
  371. package/src/lib/objects/mix/mix.js +0 -191
  372. package/src/lib/objects/mix/mix.md +0 -78
  373. package/src/lib/objects/mix/mix.test.js +0 -445
  374. package/src/lib/objects/normalize-object.js +0 -10
  375. package/src/lib/objects/omit-empty.js +0 -23
  376. package/src/lib/objects/omit-empty.test.js +0 -85
  377. package/src/lib/objects/size.js +0 -41
  378. package/src/lib/objects/split.js +0 -19
  379. package/src/lib/promises/index.js +0 -1
  380. package/src/lib/promises/reject.js +0 -17
  381. package/src/lib/sse.js +0 -61
  382. package/src/lib/strings/convert-case/convert-case.js +0 -86
  383. package/src/lib/strings/convert-case/convert-case.md +0 -44
  384. package/src/lib/strings/convert-case/convert-case.test.js +0 -50
  385. package/src/lib/strings/index.js +0 -5
  386. package/src/lib/strings/markdown.js +0 -71
  387. package/src/lib/strings/markdown.spec.js +0 -73
  388. package/src/lib/strings/name.js +0 -24
  389. package/src/lib/strings/name.test.js +0 -67
  390. package/src/lib/strings/pluralize.js +0 -2
  391. package/src/lib/strings/query-string.js +0 -18
  392. package/src/lib/style/index.js +0 -13
  393. package/src/lib/symbols/index.js +0 -1
  394. package/src/lib/symbols/symbols.js +0 -9
  395. package/src/node/dirname.js +0 -17
  396. package/src/node/file-cache.js +0 -184
  397. package/src/node/file.js +0 -13
  398. package/src/node/hash.js +0 -5
  399. package/src/node/index.js +0 -7
  400. package/src/node/pkce.js +0 -33
  401. package/src/node/random-string.js +0 -10
  402. package/src/node/random-string.test.js +0 -15
  403. package/src/node/sanitize.spec.js +0 -142
  404. package/src/node/uuid.js +0 -5
  405. package/tsconfig.json +0 -23
  406. package/tsup.config.js +0 -38
  407. package/tsup.config.mjs +0 -63
  408. /package/{src/node/context.js → dist/cjs/node/context.cjs} +0 -0
@@ -1,121 +0,0 @@
1
- import { omitEmpty } from '../../lib/objects/omit-empty.js'
2
- import { getCSSVar, setCSSVar } from '../css-vars.js'
3
- import { addListeners, removeListeners } from '../events.js'
4
-
5
- const DEFAULT_OPTIONS = {
6
- scrollSnapDelay: 1000,
7
- }
8
-
9
- export function preferHorizontalScroll(node, props = {}) {
10
- if (!node.classList.contains('scrollable-prefer-horizontal')) return
11
-
12
- const state = {
13
- origSnapType: null,
14
- currentSnapType: null,
15
- snapTimeoutID: null,
16
- }
17
-
18
- const options = {
19
- ...DEFAULT_OPTIONS,
20
- ...omitEmpty({
21
- scrollSnapDelay: getCSSVar(node, '--scroll-snap-delay'),
22
- }),
23
- ...omitEmpty(props),
24
- }
25
-
26
- const listeners = [
27
- {
28
- event: 'wheel',
29
- node,
30
- handler: handleWheel,
31
- },
32
-
33
- {
34
- event: 'pointerenter',
35
- node,
36
- handler: handlePointerEnter,
37
- },
38
-
39
- {
40
- event: 'pointerleave',
41
- node,
42
- handler: handlePointerLeave,
43
- },
44
- ]
45
-
46
- addListeners(listeners)
47
-
48
- function handleWheel(event) {
49
- const direction = event.deltaY > 0 ? 'down' : 'up'
50
- const updatedDelta = event.deltaY
51
-
52
- // Only handle mouse wheel
53
- // Trackpad users can scroll horizontally themselves
54
- if (isTrackpad(event)) return false
55
-
56
- setCSSVar(node, '--snap-type', 'none')
57
-
58
- const scrolledAmount = node.scrollLeft
59
- const scrollWidth = node.scrollWidth
60
- const clientWidth = node.clientWidth
61
- const scrollableAmount = scrollWidth - clientWidth // Maximum scrollable width to the right
62
-
63
- // Hijack downwards scroll
64
- if (direction === 'down' && scrolledAmount < scrollableAmount) {
65
- node.scrollLeft += updatedDelta
66
- event.preventDefault()
67
- }
68
-
69
- // Hijack upwards scroll
70
- if (direction === 'up' && scrolledAmount > 0) {
71
- node.scrollLeft += updatedDelta
72
- event.preventDefault()
73
- }
74
-
75
- // Restore snap type after a delay
76
- const { snapTimeoutID } = state
77
- if (snapTimeoutID) clearTimeout(snapTimeoutID)
78
- state.snapTimeoutID = setTimeout(_ => {
79
- restoreHijackedState(node, state)
80
- }, options.scrollSnapDelay)
81
- }
82
-
83
- function handlePointerEnter(event) {
84
- state.origSnapType = getCSSVar(node, '--snap-type') || 'proximity'
85
- }
86
-
87
- function handlePointerLeave(event) {
88
- restoreHijackedState(node, state)
89
- }
90
-
91
- return {
92
- destroy() {
93
- removeListeners(listeners)
94
- },
95
- }
96
- }
97
-
98
- function restoreHijackedState(node, state) {
99
- const scrollLeft = node.scrollLeft
100
-
101
- // Get the final scroll position
102
- setCSSVar(node, '--snap-type', state.origSnapType)
103
- const finalScrollLeft = node.scrollLeft
104
-
105
- // Scroll back to original position before replacing snap
106
- setCSSVar(node, '--snap-type', 'none')
107
- node.scrollTo({ left: scrollLeft, behavior: 'instant' })
108
-
109
- // Scroll back to the final position smoothly
110
- node.scrollTo({ left: finalScrollLeft, behavior: 'smooth' })
111
-
112
- setTimeout(_ => {
113
- setCSSVar(node, '--snap-type', state.origSnapType)
114
- }, 250)
115
- }
116
-
117
- // https://stackoverflow.com/questions/10744645/detect-touchpad-vs-mouse-in-javascript/62415754#62415754
118
- function isTrackpad(event) {
119
- // if (event.deltaMode === 0) return true // Deltamode no longer works in Chrome
120
- if (event.wheelDeltaY === event.deltaY * -3) return true
121
- }
@@ -1,85 +0,0 @@
1
- import { boundingBoxRelativeToAncestor } from '../bounding-box.js'
2
- import { resizeObserver } from '../observers/resize-observer.js'
3
- import { findScrollContainer } from '../ui/scroll-container.js'
4
-
5
- export function sticky(node, props = {}) {
6
- const scrollContainer = findScrollContainer(node)
7
- let stickyTBLR = getComputedTBLR(node)
8
-
9
- const obs = resizeObserver(node, {
10
- callback: ({ entry }) => {
11
- stickyTBLR = getComputedTBLR(node)
12
- isSticking()
13
-
14
- // Arguably, one can use a single container to check for all Sticky elements, but that is unnecessarily complicated to code. This adds more listeners to the scroll containers (assuming many), but it shouldn't be have enough listeners to break performance in any way.
15
- scrollContainer === document.documentElement
16
- ? window.addEventListener('scroll', scrollEventListener)
17
- : scrollContainer.addEventListener('scroll', scrollEventListener)
18
- },
19
- })
20
-
21
- function scrollEventListener(event) {
22
- isSticking()
23
- }
24
-
25
- function isSticking() {
26
- const { top, bottom, left, right } = stickyTBLR
27
- const relativeRect = boundingBoxRelativeToAncestor({
28
- element: node,
29
- ancestorElement: scrollContainer,
30
- })
31
-
32
- // Sticky Top
33
- if (!isNaN(top)) {
34
- if (relativeRect.top - top <= 1) {
35
- node.classList.add('sticking')
36
- } else {
37
- node.classList.remove('sticking')
38
- }
39
- }
40
-
41
- // Sticky Bottom
42
- if (!isNaN(bottom)) {
43
- if (relativeRect.bottom + bottom >= -1) {
44
- node.classList.add('sticking')
45
- } else {
46
- node.classList.remove('sticking')
47
- }
48
- }
49
-
50
- // Sticky Left
51
- if (!isNaN(left)) {
52
- if (relativeRect.left - left <= 1) {
53
- node.classList.add('sticking')
54
- } else {
55
- node.classList.remove('sticking')
56
- }
57
- }
58
-
59
- // Sticky Right
60
- if (!isNaN(right)) {
61
- if (relativeRect.right + right >= -1) {
62
- node.classList.add('sticking')
63
- } else {
64
- node.classList.remove('sticking')
65
- }
66
- }
67
- }
68
-
69
- return {
70
- destroy() {
71
- obs.disconnect()
72
- scrollContainer.removeEventListener('scroll', scrollEventListener)
73
- },
74
- }
75
- }
76
-
77
- function getComputedTBLR(element) {
78
- const style = getComputedStyle(element)
79
- return {
80
- top: parseFloat(style.top),
81
- bottom: parseFloat(style.bottom),
82
- left: parseFloat(style.left),
83
- right: parseFloat(style.right),
84
- }
85
- }
@@ -1,14 +0,0 @@
1
- /**
2
- * Copies rich text from an element to the clipboard
3
- * @param HTMLElement element - Element to copy
4
- */
5
- export function copyRichText(element) {
6
- const range = document.createRange()
7
- range.selectNode(element)
8
-
9
- const selection = window.getSelection()
10
- selection.removeAllRanges()
11
- selection.addRange(range)
12
- document.execCommand('copy')
13
- selection.removeAllRanges()
14
- }
package/src/dom/cookie.js DELETED
@@ -1,32 +0,0 @@
1
- export const cookies = {
2
- get(name) {
3
- return getCookie(name)
4
- },
5
-
6
- set(name, value, days) {
7
- setCookie(name, value, days)
8
- },
9
- }
10
-
11
- export function getCookie(name) {
12
- const match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'))
13
- if (!match) return null
14
- const decoded = decodeURIComponent(match[2])
15
-
16
- try {
17
- return JSON.parse(decoded)
18
- } catch (e) {
19
- return decoded
20
- }
21
- }
22
-
23
- // By Copilot. Needs testing before confirmation.
24
- function setCookie(name, value, days) {
25
- let expires = ''
26
- if (days) {
27
- const date = new Date()
28
- date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000)
29
- expires = '; expires=' + date.toUTCString()
30
- }
31
- document.cookie = name + '=' + (value || '') + expires + '; path=/'
32
- }
@@ -1,19 +0,0 @@
1
- import { getElement } from './get-element.js'
2
-
3
- export function getCSSValue(element, prop) {
4
- return getCSSVar(element, prop)
5
- }
6
-
7
- export function setCSSValue(element, prop, value) {
8
- setCSSVar(element, prop, value)
9
- }
10
-
11
- export function getCSSVar(element, prop) {
12
- element = getElement(element)
13
- return getComputedStyle(element).getPropertyValue(prop)
14
- }
15
-
16
- export function setCSSVar(element, prop, value) {
17
- element = getElement(element)
18
- element.style.setProperty(prop, value)
19
- }
@@ -1,40 +0,0 @@
1
- import { splitUnit } from '../lib/numbers/index.js'
2
-
3
- export function getUnit(value) {
4
- const [, unit] = splitUnit(value)
5
- return unit
6
- }
7
-
8
- export function rem(multiple = 1) {
9
- const value = parseFloat(getComputedStyle(document.body)['font-size'])
10
- return Math.round(value * multiple)
11
- }
12
-
13
- export function em(element = document.body, multiple = 1) {
14
- const value = parseFloat(getComputedStyle(element)['font-size'])
15
- return Math.round(value * multiple)
16
- }
17
-
18
- export function rlh(multiple = 1) {
19
- const lineHeight = parseFloat(getComputedStyle(document.body)['line-height'])
20
- return Math.round(lineHeight * multiple)
21
- }
22
-
23
- export function lh(element = document.body, multiple = 1) {
24
- const lineHeight = getComputedStyle(element)['line-height']
25
- const value = parseFloat(lineHeight)
26
- return Math.round(value * multiple)
27
- }
28
-
29
- export function toPx(value, element = null) {
30
- const [numeric, unit] = splitUnit(value)
31
- let finalValue = 0
32
-
33
- if (unit === 'rem') finalValue = rem(numeric)
34
- if (unit === 'em') finalValue = em(element, numeric)
35
- if (unit === 'lh') finalValue = lh(element, numeric)
36
- if (unit === 'px') finalValue = numeric
37
- if (!unit) finalValue = numeric // Default to px offsets
38
-
39
- return finalValue
40
- }
package/src/dom/hash.js DELETED
@@ -1,9 +0,0 @@
1
- export async function sha256Hash(string) {
2
- const utf8 = new TextEncoder().encode(string)
3
- const hashBuffer = await crypto.subtle.digest('SHA-256', utf8)
4
- const hashArray = Array.from(new Uint8Array(hashBuffer))
5
- const hashHex = hashArray
6
- .map(bytes => bytes.toString(16).padStart(2, '0'))
7
- .join('')
8
- return hashHex
9
- }
package/src/dom/index.js DELETED
@@ -1,23 +0,0 @@
1
- export * from './accessibility.js'
2
- export * from './actions/index.js'
3
- export * from './bounding-box.js'
4
- export * from './clipboard.js'
5
- export * from './cookie.js'
6
- export * from './css-vars.js'
7
- export * from './events.js'
8
- export * from './focusable.js'
9
- export * from './font-size.js'
10
- export * from './get-element.js'
11
- export * from './hash.js'
12
- export * from './keyboard.js'
13
- export * from './local-store.js'
14
- export * from './media.js'
15
- export * from './observers/index.js'
16
- export * from './pkce.js'
17
- export * from './query-params.js'
18
- export * from './random-string.js'
19
- export * from './sanitize.js'
20
- export * from './session-store.js'
21
- export * from './spam-prevention.js'
22
- export * from './trap-focus.js'
23
- export * from './ui/index.js'
package/src/dom/media.js DELETED
@@ -1,30 +0,0 @@
1
- export async function imagesLoaded(node) {
2
- const images = Array.from(node.querySelectorAll('img'))
3
- const promises = images.map(img => {
4
- return new Promise((resolve, reject) => {
5
- if (img.complete) return resolve()
6
- img.onload = resolve
7
- img.onerror = e => {
8
- // eslint-disable-next-line prefer-promise-reject-errors
9
- reject('Image failed to load')
10
- }
11
- })
12
- })
13
- return Promise.all(promises)
14
- }
15
-
16
- export async function videosLoaded(node) {
17
- const videos = Array.from(node.querySelectorAll('video'))
18
- const promises = videos.map(video => {
19
- return new Promise((resolve, reject) => {
20
- if (video.readyState === 4) return resolve() // HAVE_ENOUGH_DATA
21
- video.onloadedmetadata = resolve
22
- video.onerror = reject
23
- })
24
- })
25
- return Promise.all(promises)
26
- }
27
-
28
- export async function mediaLoaded(node) {
29
- return Promise.all([imagesLoaded(node), videosLoaded(node)])
30
- }
@@ -1,4 +0,0 @@
1
- export * from './intersection-observer.js'
2
- export * from './mutation-observer.js'
3
- export * from './resize-observer.js'
4
- export * from './scroll-observer.js'
@@ -1,43 +0,0 @@
1
- import { dispatchEvent } from '../events.js'
2
- import { useObserverMethodOnTarget } from './observer.js'
3
-
4
- // See https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/IntersectionObserver#options for options
5
- export function intersectionObserver(target, options = {}) {
6
- const { callback, ...opts } = options
7
- const observer = new IntersectionObserver(observerFn, opts)
8
-
9
- useObserverMethodOnTarget(target, observer, 'observe')
10
-
11
- function observerFn(entries) {
12
- for (const entry of entries) {
13
- if (callback) callback({ entry, entries, observer })
14
- else dispatchEvent(target, 'intersect', { entry, entries, observer })
15
- }
16
- }
17
-
18
- return {
19
- observer,
20
- observe(target) {
21
- useObserverMethodOnTarget(target, observer, 'observe', options)
22
- },
23
-
24
- unobserve(target) {
25
- useObserverMethodOnTarget(target, observer, 'unobserve')
26
- },
27
-
28
- takeRecords() {
29
- return observer.takeRecords()
30
- },
31
-
32
- disconnect() {
33
- // Take records before disconnecting.
34
- const records = observer.takeRecords()
35
- observer.disconnect()
36
- if (records.length > 0) observerFn(records)
37
- },
38
-
39
- destroy() {
40
- observer.disconnect()
41
- },
42
- }
43
- }
@@ -1,51 +0,0 @@
1
- /* eslint-env browser */
2
- import { dispatchEvent } from '../events.js'
3
- import { useObserverMethodOnTarget } from './observer.js'
4
-
5
- // https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver/observe
6
-
7
- // These are simply options that will often be used. Check the docs for other options. Adding them here simply because it's easier to refer them here than reading the docs.
8
- const defaultOptions = {
9
- attributes: false,
10
- childList: false,
11
- subtree: false,
12
- }
13
-
14
- export function mutationObserver(target, options) {
15
- options = { ...defaultOptions, ...options }
16
- const { callback, ...opts } = options
17
- const observer = new MutationObserver(observerFn)
18
-
19
- if (target === window) target = document.body
20
- useObserverMethodOnTarget(target, observer, 'observe', opts)
21
-
22
- function observerFn(entries) {
23
- for (const entry of entries) {
24
- if (callback) callback({ entry, entries, observer })
25
- else dispatchEvent(target, 'mutate', { entry, entries, observer })
26
- }
27
- }
28
-
29
- return {
30
- observer,
31
- observe(target) {
32
- useObserverMethodOnTarget(target, observer, 'observe', options)
33
- },
34
-
35
- takeRecords() {
36
- return observer.takeRecords()
37
- },
38
-
39
- disconnect() {
40
- // Take records before disconnecting.
41
- // https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver/takeRecords
42
- const records = observer.takeRecords()
43
- observer.disconnect()
44
- if (records.length > 0) observerFn(records)
45
- },
46
-
47
- destroy() {
48
- observer.disconnect()
49
- },
50
- }
51
- }
@@ -1,18 +0,0 @@
1
- import { getNodeType } from '../get-element.js'
2
-
3
- export function useObserverMethodOnTarget(
4
- target,
5
- observer,
6
- method = 'observe',
7
- options = undefined
8
- ) {
9
- const targetType = getNodeType(target)
10
- if (targetType === 'element') observer[method](target, options)
11
- if (targetType === 'nodelist') {
12
- const elements = Array.from(target)
13
- elements.forEach(element => observer[method](element, options))
14
- }
15
- if (targetType === 'array') {
16
- target.forEach(element => observer[method](element, options))
17
- }
18
- }
@@ -1,146 +0,0 @@
1
- /* eslint-env browser */
2
- import { resizeObserver } from './resize-observer.js'
3
-
4
- const defaultOptions = {
5
- threshold: 0, // Float between 0 to 1.
6
- tolerance: 0.1, // Float between 0 to 1. Tolerance for event firing
7
- once: false, // Only fire threshold callback once
8
- }
9
-
10
- /**
11
- * @typedef {Object} ScrollObserverOptions
12
- * @property {number} [threshold] - Float between 0 to 1. When to trigger callback (0.75 = 75% down page)
13
- * @property {number} [tolerance] - Float between 0 to 1. Tolerance zone around threshold
14
- * @property {boolean} [once] - Only fire threshold callback once (default: false)
15
- * @property {Function} [callback] - Called on every scroll with scrollPercent
16
- * @property {Function} [onScrollDown] - Called when scrolling down
17
- * @property {Function} [onScrollUp] - Called when scrolling up
18
- * @property {Function} [onEnterThreshold] - Called when entering threshold zone
19
- */
20
-
21
- /**
22
- * @param {Element | Document | Window} node
23
- * @returns {Element}
24
- */
25
- function getScrollElement(node) {
26
- if (
27
- node === document ||
28
- node === window ||
29
- node === document.documentElement
30
- ) {
31
- return document.documentElement
32
- }
33
- return /** @type {Element} */ (node)
34
- }
35
-
36
- /**
37
- * Scroll Observer - Optimized for performance
38
- * @param {Element | Document | Window} node - The element to observe scroll events on
39
- * @param {ScrollObserverOptions} [options] - Configuration options
40
- */
41
- export function scrollObserver(node, options = {}) {
42
- const { callback, onScrollDown, onScrollUp, onEnterThreshold, ...userOpts } =
43
- options
44
- const opts = { ...defaultOptions, ...userOpts }
45
- const { threshold, tolerance, once } = opts
46
-
47
- let prevScrollDirection = null
48
- let prevScrollTop = 0
49
- let prevScrollPercent = 0
50
- let thresholdFired = false
51
- let rafId = null
52
-
53
- // Determine scroll context once at initialization
54
- const isDocumentScroll =
55
- node === document || node === window || node === document.documentElement
56
- const scrollElement = getScrollElement(node)
57
- const eventTarget = isDocumentScroll ? window : node
58
-
59
- // Cache DOM references and expensive calculations
60
- let cachedScrollHeight = 0
61
- let cachedClientHeight = 0
62
-
63
- // Initialize cache and start observing for changes
64
- updateCache()
65
- const cacheObserver = resizeObserver(scrollElement, {
66
- callback: updateCache,
67
- })
68
-
69
- eventTarget.addEventListener('scroll', throttledObserve, { passive: true })
70
-
71
- function throttledObserve() {
72
- rafId = requestAnimationFrame(observe)
73
- }
74
-
75
- function updateCache() {
76
- cachedScrollHeight = scrollElement.scrollHeight
77
- cachedClientHeight = scrollElement.clientHeight
78
- }
79
-
80
- function observe() {
81
- const scrollTop = scrollElement.scrollTop
82
-
83
- // Skip if scroll position hasn't changed meaningfully
84
- if (Math.abs(scrollTop - prevScrollTop) < 1) return
85
-
86
- const scrollDirection = scrollTop > prevScrollTop ? 'down' : 'up'
87
- const maxScroll = Math.max(1, cachedScrollHeight - cachedClientHeight)
88
- const scrollPercent = Math.min(1, Math.max(0, scrollTop / maxScroll))
89
-
90
- // Check threshold crossing (e.g., 75% ± tolerance)
91
- const thresholdMin = threshold - tolerance / 2
92
- const thresholdMax = threshold + tolerance / 2
93
- const wasInThreshold =
94
- prevScrollPercent >= thresholdMin && prevScrollPercent <= thresholdMax
95
- const isInThreshold =
96
- scrollPercent >= thresholdMin && scrollPercent <= thresholdMax
97
- const hasEnteredThreshold =
98
- !wasInThreshold && isInThreshold && (!once || !thresholdFired)
99
-
100
- if (hasEnteredThreshold && once) {
101
- thresholdFired = true
102
- }
103
-
104
- // Prepare common data for all callbacks
105
- const callbackData = {
106
- scrollTop,
107
- scrollDirection,
108
- scrollPercent,
109
- directionChanged: scrollDirection !== prevScrollDirection,
110
- hasEnteredThreshold,
111
- isInThreshold,
112
- }
113
-
114
- // Call specific callbacks
115
- if (typeof callback === 'function') {
116
- callback(callbackData)
117
- }
118
-
119
- // Only fire direction callbacks when direction actually changes
120
- if (scrollDirection !== prevScrollDirection) {
121
- if (scrollDirection === 'down' && typeof onScrollDown === 'function') {
122
- onScrollDown(callbackData)
123
- }
124
- if (scrollDirection === 'up' && typeof onScrollUp === 'function') {
125
- onScrollUp(callbackData)
126
- }
127
- }
128
-
129
- // Fire threshold callback when entering threshold zone
130
- if (hasEnteredThreshold && typeof onEnterThreshold === 'function') {
131
- onEnterThreshold(callbackData)
132
- }
133
-
134
- prevScrollTop = scrollTop
135
- prevScrollPercent = scrollPercent
136
- prevScrollDirection = scrollDirection
137
- }
138
-
139
- return {
140
- destroy() {
141
- eventTarget.removeEventListener('scroll', throttledObserve)
142
- if (rafId) cancelAnimationFrame(rafId)
143
- cacheObserver.destroy()
144
- },
145
- }
146
- }
package/src/dom/pkce.js DELETED
@@ -1,34 +0,0 @@
1
- // Browser only
2
- // Check the node version for usage in servers
3
- import { randomString } from './random-string.js'
4
-
5
- export async function PKCE() {
6
- const codeVerifier = await randomString()
7
- const codeChallenge = await getCodeChallenge(codeVerifier)
8
-
9
- return {
10
- state: await randomString(),
11
- code_verifier: codeVerifier,
12
- code_challenge: codeChallenge,
13
- code_challenge_method: 'S256',
14
- }
15
- }
16
-
17
- /**
18
- * Generates code challenge in browser
19
- * @param {string} verifier
20
- * @returns promise
21
- */
22
- async function getCodeChallenge(verifier) {
23
- // Hash the code verifier with SHA-256
24
- const encoder = new TextEncoder()
25
- const data = encoder.encode(verifier)
26
- const hashed = await window.crypto.subtle.digest('SHA-256', data)
27
-
28
- // Base64url encode the hash
29
- return window
30
- .btoa(String.fromCharCode.apply(null, new Uint8Array(hashed)))
31
- .replace(/\+/g, '-')
32
- .replace(/\//g, '_')
33
- .replace(/=+$/, '')
34
- }