@rzl-zone/utils-js 3.12.0 → 3.12.1-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (286) hide show
  1. package/{LICENSE.md → LICENSE} +3 -3
  2. package/README.md +69 -96
  3. package/dist/.references/index.d.cts +25 -0
  4. package/dist/.references/index.d.ts +25 -0
  5. package/dist/assertIsArray-DJXkjHZs.cjs +26 -0
  6. package/dist/assertIsArray-DJXkjHZs.cjs.map +1 -0
  7. package/dist/assertIsArray-bTA3XLjq.js +20 -0
  8. package/dist/assertIsArray-bTA3XLjq.js.map +1 -0
  9. package/dist/assertIsBoolean-C8WEXVr2.cjs +1283 -0
  10. package/dist/assertIsBoolean-C8WEXVr2.cjs.map +1 -0
  11. package/dist/assertIsBoolean-DR1SaXPD.js +1073 -0
  12. package/dist/assertIsBoolean-DR1SaXPD.js.map +1 -0
  13. package/dist/assertIsString-BiHQSrB2.cjs +26 -0
  14. package/dist/assertIsString-BiHQSrB2.cjs.map +1 -0
  15. package/dist/assertIsString-CEB07_83.js +20 -0
  16. package/dist/assertIsString-CEB07_83.js.map +1 -0
  17. package/dist/assertions/index.cjs +37 -40
  18. package/dist/assertions/index.cjs.map +1 -0
  19. package/dist/assertions/index.d.cts +12 -0
  20. package/dist/assertions/index.d.ts +10 -824
  21. package/dist/assertions/index.js +30 -13
  22. package/dist/assertions/index.js.map +1 -0
  23. package/dist/conversions/index.cjs +34 -103
  24. package/dist/conversions/index.d.cts +12 -0
  25. package/dist/conversions/index.d.ts +10 -1791
  26. package/dist/conversions/index.js +14 -24
  27. package/dist/conversions-BNIh_tCH.js +380 -0
  28. package/dist/conversions-BNIh_tCH.js.map +1 -0
  29. package/dist/conversions-D_Kh0a_C.cjs +446 -0
  30. package/dist/conversions-D_Kh0a_C.cjs.map +1 -0
  31. package/dist/events/index.cjs +55 -31
  32. package/dist/events/index.cjs.map +1 -0
  33. package/dist/events/index.d.cts +176 -0
  34. package/dist/events/index.d.ts +164 -166
  35. package/dist/events/index.js +50 -12
  36. package/dist/events/index.js.map +1 -0
  37. package/dist/formatEnvPort-B3OLxQk9.cjs +171 -0
  38. package/dist/formatEnvPort-B3OLxQk9.cjs.map +1 -0
  39. package/dist/formatEnvPort-ByFVLjSV.js +159 -0
  40. package/dist/formatEnvPort-ByFVLjSV.js.map +1 -0
  41. package/dist/formatters/index.cjs +21 -61
  42. package/dist/formatters/index.d.cts +12 -0
  43. package/dist/formatters/index.d.ts +10 -2152
  44. package/dist/formatters/index.js +10 -18
  45. package/dist/formatters--1m_vpE8.js +369 -0
  46. package/dist/formatters--1m_vpE8.js.map +1 -0
  47. package/dist/formatters-Cbij0XLU.cjs +429 -0
  48. package/dist/formatters-Cbij0XLU.cjs.map +1 -0
  49. package/dist/generators/index.cjs +165 -41
  50. package/dist/generators/index.cjs.map +1 -0
  51. package/dist/generators/index.d.cts +12 -0
  52. package/dist/generators/index.d.ts +10 -338
  53. package/dist/generators/index.js +158 -14
  54. package/dist/generators/index.js.map +1 -0
  55. package/dist/index-59zbLcPr.d.ts +340 -0
  56. package/dist/index-B6tawc8L.d.cts +1716 -0
  57. package/dist/index-C267akkJ.d.ts +2158 -0
  58. package/dist/index-CeBC2Vvl.d.cts +2361 -0
  59. package/dist/index-CgRDTI6f.d.ts +822 -0
  60. package/dist/index-CoiUBVmr.d.ts +720 -0
  61. package/dist/index-D4fcasfZ.d.cts +720 -0
  62. package/dist/index-DDrSQKIc.d.ts +1716 -0
  63. package/dist/index-DsGxO31H.d.cts +765 -0
  64. package/dist/index-Hg1qJkjl.d.ts +765 -0
  65. package/dist/index-Qm3iFwd0.d.cts +2158 -0
  66. package/dist/index-UPp94Agr.d.ts +2361 -0
  67. package/dist/index-gBA_8SuF.d.cts +340 -0
  68. package/dist/index-jyDqzicx.d.cts +822 -0
  69. package/dist/isBigInt-C4krUeAw.cjs +20 -0
  70. package/dist/isBigInt-C4krUeAw.cjs.map +1 -0
  71. package/dist/isBigInt-DKe0M6hp.js +14 -0
  72. package/dist/isBigInt-DKe0M6hp.js.map +1 -0
  73. package/dist/isEmptyObject-DCipFwxJ.js +25 -0
  74. package/dist/isEmptyObject-DCipFwxJ.js.map +1 -0
  75. package/dist/isEmptyObject-ZkSwRC_D.cjs +37 -0
  76. package/dist/isEmptyObject-ZkSwRC_D.cjs.map +1 -0
  77. package/dist/isEmptyString-BXzKAC2j.js +15 -0
  78. package/dist/isEmptyString-BXzKAC2j.js.map +1 -0
  79. package/dist/isEmptyString-UiiUsSQj.cjs +21 -0
  80. package/dist/isEmptyString-UiiUsSQj.cjs.map +1 -0
  81. package/dist/isEmptyValue-BQzcjVaL.cjs +30 -0
  82. package/dist/isEmptyValue-BQzcjVaL.cjs.map +1 -0
  83. package/dist/isEmptyValue-jqOr7OHD.js +24 -0
  84. package/dist/isEmptyValue-jqOr7OHD.js.map +1 -0
  85. package/dist/isEqual-BX49cF9m.js +87 -0
  86. package/dist/isEqual-BX49cF9m.js.map +1 -0
  87. package/dist/isEqual-BvumA3RA.cjs +111 -0
  88. package/dist/isEqual-BvumA3RA.cjs.map +1 -0
  89. package/dist/isFinite-BCnaDpod.js +15 -0
  90. package/dist/isFinite-BCnaDpod.js.map +1 -0
  91. package/dist/isFinite-D24ZaE6c.cjs +21 -0
  92. package/dist/isFinite-D24ZaE6c.cjs.map +1 -0
  93. package/dist/isInteger-Caeuz0rB.cjs +20 -0
  94. package/dist/isInteger-Caeuz0rB.cjs.map +1 -0
  95. package/dist/isInteger-naMbJsxJ.js +14 -0
  96. package/dist/isInteger-naMbJsxJ.js.map +1 -0
  97. package/dist/isPlainObject-BF-2-phb.d.cts +339 -0
  98. package/dist/isPlainObject-DxNDL8XU.d.ts +339 -0
  99. package/dist/isServer-BJHVnixd.cjs +20 -0
  100. package/dist/isServer-BJHVnixd.cjs.map +1 -0
  101. package/dist/isServer-Da3o3XSs.js +14 -0
  102. package/dist/isServer-Da3o3XSs.js.map +1 -0
  103. package/dist/isTypedArray-DuNA8tK6.js +31 -0
  104. package/dist/isTypedArray-DuNA8tK6.js.map +1 -0
  105. package/dist/isTypedArray-TJptiw2b.cjs +43 -0
  106. package/dist/isTypedArray-TJptiw2b.cjs.map +1 -0
  107. package/dist/isURL-C-kSk6KJ.js +14 -0
  108. package/dist/isURL-C-kSk6KJ.js.map +1 -0
  109. package/dist/isURL-DeUPO_oR.cjs +20 -0
  110. package/dist/isURL-DeUPO_oR.cjs.map +1 -0
  111. package/dist/isValidDomain-BB9IGhJs.cjs +1845 -0
  112. package/dist/isValidDomain-BB9IGhJs.cjs.map +1 -0
  113. package/dist/isValidDomain-DoE98yhJ.js +1827 -0
  114. package/dist/isValidDomain-DoE98yhJ.js.map +1 -0
  115. package/dist/next/index.cjs +119 -214
  116. package/dist/next/index.cjs.map +1 -0
  117. package/dist/next/index.d.cts +220 -0
  118. package/dist/next/index.d.ts +203 -214
  119. package/dist/next/index.js +117 -212
  120. package/dist/next/index.js.map +1 -0
  121. package/dist/next/server/index.cjs +25 -40
  122. package/dist/next/server/index.cjs.map +1 -0
  123. package/dist/next/server/index.d.cts +39 -0
  124. package/dist/next/server/index.d.ts +34 -35
  125. package/dist/next/server/index.js +23 -38
  126. package/dist/next/server/index.js.map +1 -0
  127. package/dist/noop-B13_ii35.cjs +18 -0
  128. package/dist/noop-B13_ii35.cjs.map +1 -0
  129. package/dist/noop-ubqAIbHD.js +12 -0
  130. package/dist/noop-ubqAIbHD.js.map +1 -0
  131. package/dist/normalizeSpaces-Bg2IZW7W.js +23 -0
  132. package/dist/normalizeSpaces-Bg2IZW7W.js.map +1 -0
  133. package/dist/normalizeSpaces-ZXnR4Qzp.cjs +29 -0
  134. package/dist/normalizeSpaces-ZXnR4Qzp.cjs.map +1 -0
  135. package/dist/normalizeString-BDdkaXui.js +15 -0
  136. package/dist/normalizeString-BDdkaXui.js.map +1 -0
  137. package/dist/normalizeString-BE6ELqEb.cjs +21 -0
  138. package/dist/normalizeString-BE6ELqEb.cjs.map +1 -0
  139. package/dist/operations/index.cjs +65 -32
  140. package/dist/operations/index.cjs.map +1 -0
  141. package/dist/operations/index.d.cts +139 -0
  142. package/dist/operations/index.d.ts +129 -134
  143. package/dist/operations/index.js +61 -17
  144. package/dist/operations/index.js.map +1 -0
  145. package/dist/parsers/index.cjs +12 -19
  146. package/dist/parsers/index.d.cts +239 -0
  147. package/dist/parsers/index.d.ts +234 -235
  148. package/dist/parsers/index.js +10 -12
  149. package/dist/parsers-BSBPgvsq.js +643 -0
  150. package/dist/parsers-BSBPgvsq.js.map +1 -0
  151. package/dist/parsers-OqDeffqc.cjs +649 -0
  152. package/dist/parsers-OqDeffqc.cjs.map +1 -0
  153. package/dist/parsing-Cao8b358.js +50 -0
  154. package/dist/parsing-Cao8b358.js.map +1 -0
  155. package/dist/parsing-DOGSCH6N.cjs +56 -0
  156. package/dist/parsing-DOGSCH6N.cjs.map +1 -0
  157. package/dist/predicates/index.cjs +91 -296
  158. package/dist/predicates/index.d.cts +13 -0
  159. package/dist/predicates/index.d.ts +12 -2482
  160. package/dist/predicates/index.js +23 -25
  161. package/dist/predicates-Bj6meyXV.js +256 -0
  162. package/dist/predicates-Bj6meyXV.js.map +1 -0
  163. package/dist/predicates-D0ubqgqy.cjs +412 -0
  164. package/dist/predicates-D0ubqgqy.cjs.map +1 -0
  165. package/dist/promises/index.cjs +76 -24
  166. package/dist/promises/index.cjs.map +1 -0
  167. package/dist/promises/index.d.cts +123 -0
  168. package/dist/promises/index.d.ts +116 -119
  169. package/dist/promises/index.js +73 -13
  170. package/dist/promises/index.js.map +1 -0
  171. package/dist/punyCode-8SrbMWfM.js +179 -0
  172. package/dist/punyCode-8SrbMWfM.js.map +1 -0
  173. package/dist/punyCode-D-Qu6nj6.cjs +185 -0
  174. package/dist/punyCode-D-Qu6nj6.cjs.map +1 -0
  175. package/dist/removeSpaces-Bmc5DX4F.js +19 -0
  176. package/dist/removeSpaces-Bmc5DX4F.js.map +1 -0
  177. package/dist/removeSpaces-CWIvhZHg.cjs +25 -0
  178. package/dist/removeSpaces-CWIvhZHg.cjs.map +1 -0
  179. package/dist/rzl-utils.global.js +20 -9
  180. package/dist/safeJsonParse-BP38mwlj.js +184 -0
  181. package/dist/safeJsonParse-BP38mwlj.js.map +1 -0
  182. package/dist/safeJsonParse-Sms2CJf4.cjs +208 -0
  183. package/dist/safeJsonParse-Sms2CJf4.cjs.map +1 -0
  184. package/dist/safeStableStringify-CJtP89qn.cjs +106 -0
  185. package/dist/safeStableStringify-CJtP89qn.cjs.map +1 -0
  186. package/dist/safeStableStringify-CXOZ9Ub8.js +88 -0
  187. package/dist/safeStableStringify-CXOZ9Ub8.js.map +1 -0
  188. package/dist/strings/index.cjs +79 -81
  189. package/dist/strings/index.cjs.map +1 -0
  190. package/dist/strings/index.d.cts +12 -0
  191. package/dist/strings/index.d.ts +10 -775
  192. package/dist/strings/index.js +62 -14
  193. package/dist/strings/index.js.map +1 -0
  194. package/dist/tailwind/index.cjs +19 -47
  195. package/dist/tailwind/index.d.cts +12 -0
  196. package/dist/tailwind/index.d.ts +11 -712
  197. package/dist/tailwind/index.js +10 -12
  198. package/dist/tailwind-B2ssevxq.js +199 -0
  199. package/dist/tailwind-B2ssevxq.js.map +1 -0
  200. package/dist/tailwind-CHIx9uxu.cjs +247 -0
  201. package/dist/tailwind-CHIx9uxu.cjs.map +1 -0
  202. package/dist/toStringArrayUnRecursive-C4zYCja7.cjs +51 -0
  203. package/dist/toStringArrayUnRecursive-C4zYCja7.cjs.map +1 -0
  204. package/dist/toStringArrayUnRecursive-DJGtPsFb.js +39 -0
  205. package/dist/toStringArrayUnRecursive-DJGtPsFb.js.map +1 -0
  206. package/dist/urls/index.cjs +130 -57
  207. package/dist/urls/index.cjs.map +1 -0
  208. package/dist/urls/index.d.cts +737 -0
  209. package/dist/urls/index.d.ts +699 -708
  210. package/dist/urls/index.js +122 -26
  211. package/dist/urls/index.js.map +1 -0
  212. package/package.json +203 -194
  213. package/dist/chunk-2AFQ33D3.cjs +0 -64
  214. package/dist/chunk-2CYDJVGM.js +0 -246
  215. package/dist/chunk-2MW4JDQ2.cjs +0 -598
  216. package/dist/chunk-2VTDXC3N.cjs +0 -1825
  217. package/dist/chunk-44XX2P34.js +0 -209
  218. package/dist/chunk-4YLBKLGS.cjs +0 -18
  219. package/dist/chunk-566CXQW7.cjs +0 -560
  220. package/dist/chunk-57EPKYID.cjs +0 -397
  221. package/dist/chunk-5MGEC3YG.js +0 -63
  222. package/dist/chunk-6EF52423.cjs +0 -249
  223. package/dist/chunk-6SCOKU3S.js +0 -109
  224. package/dist/chunk-6VUXD3CF.js +0 -119
  225. package/dist/chunk-7B76BSNK.cjs +0 -118
  226. package/dist/chunk-7Y6I2DSU.cjs +0 -101
  227. package/dist/chunk-A7S7E2EE.cjs +0 -308
  228. package/dist/chunk-AJZ6PMMZ.js +0 -16
  229. package/dist/chunk-AXGBL2IO.cjs +0 -251
  230. package/dist/chunk-B4TC6FBV.cjs +0 -678
  231. package/dist/chunk-BAV5T2E3.cjs +0 -15
  232. package/dist/chunk-BKIJBNIE.js +0 -21
  233. package/dist/chunk-BNIMTFK5.js +0 -59
  234. package/dist/chunk-BXW7YXB7.js +0 -1823
  235. package/dist/chunk-CFYZC4S6.js +0 -53
  236. package/dist/chunk-CSG4SCL3.js +0 -1587
  237. package/dist/chunk-CWQW7AKK.js +0 -676
  238. package/dist/chunk-DVMHRLKP.cjs +0 -16
  239. package/dist/chunk-EN7LVZBZ.js +0 -548
  240. package/dist/chunk-EV4Y7HCY.cjs +0 -26
  241. package/dist/chunk-F66VDYIZ.cjs +0 -18
  242. package/dist/chunk-FLJX37EL.cjs +0 -30
  243. package/dist/chunk-GKC3UDMC.cjs +0 -1623
  244. package/dist/chunk-H65I3GRZ.cjs +0 -106
  245. package/dist/chunk-HHYWB7VZ.js +0 -24
  246. package/dist/chunk-HNGGISFL.cjs +0 -65
  247. package/dist/chunk-HNSQAVSZ.cjs +0 -35
  248. package/dist/chunk-HSP6IWZK.js +0 -17
  249. package/dist/chunk-IDZS7J6T.js +0 -242
  250. package/dist/chunk-JS6R55VL.js +0 -302
  251. package/dist/chunk-JZVT5FK7.js +0 -232
  252. package/dist/chunk-KHO2SBNA.cjs +0 -16
  253. package/dist/chunk-KIDJCMNJ.js +0 -33
  254. package/dist/chunk-KOLEURVT.cjs +0 -38
  255. package/dist/chunk-L4V53MQK.cjs +0 -269
  256. package/dist/chunk-L5RDAVVH.js +0 -14
  257. package/dist/chunk-NODTV4F3.js +0 -16
  258. package/dist/chunk-NYK5K3V2.cjs +0 -211
  259. package/dist/chunk-ODUO3RTL.cjs +0 -113
  260. package/dist/chunk-ONZFBJVW.js +0 -14
  261. package/dist/chunk-PFXCTE37.js +0 -28
  262. package/dist/chunk-PPST7QAQ.js +0 -587
  263. package/dist/chunk-Q5IMYDFL.cjs +0 -33
  264. package/dist/chunk-QFFBIOJ4.js +0 -31
  265. package/dist/chunk-QNKGP5DY.js +0 -14
  266. package/dist/chunk-RRQHMOPE.cjs +0 -19
  267. package/dist/chunk-RU5OSRBU.js +0 -95
  268. package/dist/chunk-SDMPEJ4F.js +0 -35
  269. package/dist/chunk-SYNL5IKP.js +0 -115
  270. package/dist/chunk-TCDOWZQE.js +0 -16
  271. package/dist/chunk-TQPGXGKB.cjs +0 -123
  272. package/dist/chunk-TULOI4GL.js +0 -370
  273. package/dist/chunk-UBHCP4N5.cjs +0 -36
  274. package/dist/chunk-UCHF3M34.cjs +0 -56
  275. package/dist/chunk-UDA26MCU.cjs +0 -16
  276. package/dist/chunk-V3C4FYZL.cjs +0 -18
  277. package/dist/chunk-VAAHZFBF.js +0 -32
  278. package/dist/chunk-VJDDGRIK.cjs +0 -16
  279. package/dist/chunk-WVSPXFTY.js +0 -14
  280. package/dist/chunk-WYP76WXB.js +0 -101
  281. package/dist/chunk-YDE4ZBB7.cjs +0 -237
  282. package/dist/chunk-YKQEOO7C.cjs +0 -23
  283. package/dist/chunk-YSZC56SZ.js +0 -264
  284. package/dist/chunk-YWHHVDT4.js +0 -13
  285. package/dist/index.d.ts +0 -24
  286. package/dist/isPlainObject-DTJVV2Kf.d.ts +0 -536
@@ -1,178 +1,176 @@
1
1
  /*!
2
- * ====================================================
3
- * Rzl Utils-JS.
4
- * ----------------------------------------------------
5
- * Version: 3.12.0.
6
- * Author: Rizalvin Dwiky.
7
- * Repository: https://github.com/rzl-zone/utils-js.
8
- * ====================================================
9
- */
2
+ * ========================================================================
3
+ * @rzl-zone/utils-js
4
+ * ------------------------------------------------------------------------
5
+ * Version: `3.12.1-beta.1`
6
+ * Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
7
+ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
8
+ * ========================================================================
9
+ */
10
10
  /** ----------------------------------------------------------
11
- * * ***Utility: `disableUserInteraction`.***
12
- * ----------------------------------------------------------
13
- * **Disables user interaction by adding a CSS class to the `<html>` element.**
14
- * - **Key points**:
15
- * - Works **only in browser environments**.
16
- * - Safely adds the specified CSS class to `<html>`.
17
- * - Prevents multiple additions of the same class.
18
- * - Useful to indicate that a process is ongoing
19
- * (e.g., loading or processing state).
20
- * - **Using custom CSS classes:**
21
- * - You can pass any class name that exists in your CSS.
22
- * - Example: if you have `.loading` in your styles, passing `"loading"`
23
- * will add it and disable interactions accordingly.
24
- * - **Validation:**
25
- * - Throws `TypeError` if the `className` parameter is not a string.
26
- * @defaultValue `"on_processing"`
27
- * @param {string} [className="on_processing"] - The CSS class to add, defaults to `"on_processing"`.
28
- * @returns {void} Does not return anything (void).
29
- * @throws **{@link TypeError | `TypeError`}** if `className` is not a string.
30
- * @example
31
- * * ***Example in your code:***
32
- * ```ts
33
- * disableUserInteraction(); // ➔ Adds "on_processing" class
34
- * disableUserInteraction("loading"); // ➔ Adds "loading" class
35
- * // ❌ Invalid value:
36
- * disableUserInteraction(123); // ➔ Throws TypeError
37
- * ```
38
- * * ***Example in your css file (with defaultValue `className` props [on_processing]):***
39
- * ```css
40
- * .on_processing {
41
- * cursor: wait;
42
- * touch-action: none;
43
- * user-select: none;
44
- * }
45
- *
46
- * .on_processing > * {
47
- * pointer-events: none;
48
- * touch-action: none;
49
- * user-select: none;
50
- * }
51
- * ```
52
- */
11
+ * * ***Utility: `disableUserInteraction`.***
12
+ * ----------------------------------------------------------
13
+ * **Disables user interaction by adding a CSS class to the `<html>` element.**
14
+ * - **Key points**:
15
+ * - Works **only in browser environments**.
16
+ * - Safely adds the specified CSS class to `<html>`.
17
+ * - Prevents multiple additions of the same class.
18
+ * - Useful to indicate that a process is ongoing
19
+ * (e.g., loading or processing state).
20
+ * - **Using custom CSS classes:**
21
+ * - You can pass any class name that exists in your CSS.
22
+ * - Example: if you have `.loading` in your styles, passing `"loading"`
23
+ * will add it and disable interactions accordingly.
24
+ * - **Validation:**
25
+ * - Throws `TypeError` if the `className` parameter is not a string.
26
+ * @defaultValue `"on_processing"`
27
+ * @param {string} [className="on_processing"] - The CSS class to add, defaults to `"on_processing"`.
28
+ * @returns {void} Does not return anything (void).
29
+ * @throws **{@link TypeError | `TypeError`}** if `className` is not a string.
30
+ * @example
31
+ * * ***Example in your code:***
32
+ * ```ts
33
+ * disableUserInteraction(); // ➔ Adds "on_processing" class
34
+ * disableUserInteraction("loading"); // ➔ Adds "loading" class
35
+ * // ❌ Invalid value:
36
+ * disableUserInteraction(123); // ➔ Throws TypeError
37
+ * ```
38
+ * * ***Example in your css file (with defaultValue `className` props [on_processing]):***
39
+ * ```css
40
+ * .on_processing {
41
+ * cursor: wait;
42
+ * touch-action: none;
43
+ * user-select: none;
44
+ * }
45
+ *
46
+ * .on_processing > * {
47
+ * pointer-events: none;
48
+ * touch-action: none;
49
+ * user-select: none;
50
+ * }
51
+ * ```
52
+ */
53
53
  declare const disableUserInteraction: (className?: string) => void;
54
-
55
54
  /** ----------------------------------------------------------
56
- * * ***Utility: `enableUserInteraction`.***
57
- * ----------------------------------------------------------
58
- * **Enables user interaction by removing a CSS class from the `<html>` element.**
59
- * - **Key points**:
60
- * - Works **only in browser environments**.
61
- * - Safely removes the specified CSS class from `<html>`.
62
- * - Does nothing if the class is not present.
63
- * - Useful to re-enable user interactions after a process
64
- * (e.g., loading or processing) completes.
65
- * - **Using custom CSS classes:**
66
- * - You can pass any class name that exists in your CSS.
67
- * - Example: if you have `.loading` in your styles, passing `"loading"`
68
- * will remove it and re-enable interactions.
69
- * - **Validation:**
70
- * - Throws `TypeError` if the `className` parameter is not a string.
71
- * @defaultValue `"on_processing"`
72
- * @param {string} [className="on_processing"] - The CSS class to remove, defaults to `"on_processing"`.
73
- * @returns {void} Does not return anything (void).
74
- * @throws **{@link TypeError | `TypeError`}** if `className` is not a string.
75
- * @example
76
- * * ***Example in your code:***
77
- * ```ts
78
- * enableUserInteraction(); // ➔ Removes "on_processing" class
79
- * enableUserInteraction("loading"); // ➔ Removes "loading" class
80
- * // ❌ Invalid value:
81
- * enableUserInteraction(123); // ➔ Throws TypeError
82
- * ```
83
- * * ***Example in your css file (with defaultValue `className` props [on_processing]):***
84
- * ```css
85
- * .on_processing {
86
- * cursor: wait;
87
- * touch-action: none;
88
- * user-select: none;
89
- * }
90
- *
91
- * .on_processing > * {
92
- * pointer-events: none;
93
- * touch-action: none;
94
- * user-select: none;
95
- * }
96
- * ```
97
- */
55
+ * * ***Utility: `enableUserInteraction`.***
56
+ * ----------------------------------------------------------
57
+ * **Enables user interaction by removing a CSS class from the `<html>` element.**
58
+ * - **Key points**:
59
+ * - Works **only in browser environments**.
60
+ * - Safely removes the specified CSS class from `<html>`.
61
+ * - Does nothing if the class is not present.
62
+ * - Useful to re-enable user interactions after a process
63
+ * (e.g., loading or processing) completes.
64
+ * - **Using custom CSS classes:**
65
+ * - You can pass any class name that exists in your CSS.
66
+ * - Example: if you have `.loading` in your styles, passing `"loading"`
67
+ * will remove it and re-enable interactions.
68
+ * - **Validation:**
69
+ * - Throws `TypeError` if the `className` parameter is not a string.
70
+ * @defaultValue `"on_processing"`
71
+ * @param {string} [className="on_processing"] - The CSS class to remove, defaults to `"on_processing"`.
72
+ * @returns {void} Does not return anything (void).
73
+ * @throws **{@link TypeError | `TypeError`}** if `className` is not a string.
74
+ * @example
75
+ * * ***Example in your code:***
76
+ * ```ts
77
+ * enableUserInteraction(); // ➔ Removes "on_processing" class
78
+ * enableUserInteraction("loading"); // ➔ Removes "loading" class
79
+ * // ❌ Invalid value:
80
+ * enableUserInteraction(123); // ➔ Throws TypeError
81
+ * ```
82
+ * * ***Example in your css file (with defaultValue `className` props [on_processing]):***
83
+ * ```css
84
+ * .on_processing {
85
+ * cursor: wait;
86
+ * touch-action: none;
87
+ * user-select: none;
88
+ * }
89
+ *
90
+ * .on_processing > * {
91
+ * pointer-events: none;
92
+ * touch-action: none;
93
+ * user-select: none;
94
+ * }
95
+ * ```
96
+ */
98
97
  declare const enableUserInteraction: (className?: string) => void;
99
-
100
98
  /** ----------------------------------------------------------
101
- * * ***Utility: `removeElementFocus`.***
102
- * ----------------------------------------------------------
103
- * **Removes focus from the currently active element in the document.**
104
- * - **Features**:
105
- * - This function works **only in browser environments** ***(safely no-ops in server environments)***.
106
- * - If an element is focused, it will lose focus by calling `HTMLElement.blur()`.
107
- * - If no element is focused or the active element is not an `HTMLElement`, nothing happens.
108
- * @returns {void} Does not return anything (void).
109
- * @example
110
- * removeElementFocus(); // ➔ Removes focus from the currently active element
111
- */
99
+ * * ***Utility: `removeElementFocus`.***
100
+ * ----------------------------------------------------------
101
+ * **Removes focus from the currently active element in the document.**
102
+ * - **Features**:
103
+ * - This function works **only in browser environments** ***(safely no-ops in server environments)***.
104
+ * - If an element is focused, it will lose focus by calling `HTMLElement.blur()`.
105
+ * - If no element is focused or the active element is not an `HTMLElement`, nothing happens.
106
+ * @returns {void} Does not return anything (void).
107
+ * @example
108
+ * removeElementFocus(); // ➔ Removes focus from the currently active element
109
+ */
112
110
  declare const removeElementFocus: () => void;
113
-
114
- /** @private ***Types options for {@link scrollToTop | `scrollToTop`}.*** */
111
+ /**
112
+ * ***Types options for {@link scrollToTop | `scrollToTop`}.***
113
+ */
115
114
  type ScrollToTopOptions = {
116
- /** ----------------------------------------------------------
117
- * * ***Scroll animation type.***
118
- * ----------------------------------------------------------
119
- * - ***Behavior:***
120
- * - Valid values: `"auto"`, `"instant"`, `"smooth"`.
121
- * - Default force to `"smooth"` if missing or invalid.
122
- *
123
- * @default "smooth"
124
- */
125
- behavior?: ScrollBehavior | undefined;
126
- /** ----------------------------------------------------------
127
- * * ***Delay before scrolling (in milliseconds).***
128
- * ----------------------------------------------------------
129
- * - ***Behavior:***
130
- * - Default value is `1`.
131
- * - Valid values: any number `≥` `1`.
132
- * - Non-integer number are truncated to an integer.
133
- * - Force to `2147483647` if number is larger than `2147483647`.
134
- * - Default force to `1` if `missing`, `NaN`, `invalid-type`, or `less-than` `1`.
135
- *
136
- * @default 1
137
- */
138
- timeout?: number | undefined;
115
+ /** ----------------------------------------------------------
116
+ * * ***Scroll animation type.***
117
+ * ----------------------------------------------------------
118
+ * - ***Behavior:***
119
+ * - Valid values: `"auto"`, `"instant"`, `"smooth"`.
120
+ * - Default force to `"smooth"` if missing or invalid.
121
+ *
122
+ * @default "smooth"
123
+ */
124
+ behavior?: ScrollBehavior | undefined;
125
+ /** ----------------------------------------------------------
126
+ * * ***Delay before scrolling (in milliseconds).***
127
+ * ----------------------------------------------------------
128
+ * - ***Behavior:***
129
+ * - Default value is `1`.
130
+ * - Valid values: any number `≥` `1`.
131
+ * - Non-integer number are truncated to an integer.
132
+ * - Force to `2147483647` if number is larger than `2147483647`.
133
+ * - Default force to `1` if `missing`, `NaN`, `invalid-type`, or `less-than` `1`.
134
+ *
135
+ * @default 1
136
+ */
137
+ timeout?: number | undefined;
139
138
  };
140
139
  /** ----------------------------------------------------------
141
- * * ***Utility: `scrollToTop`.***
142
- * ----------------------------------------------------------
143
- * **Scrolls the page to the top with optional smooth animation and delay.**
144
- * - **Features**:
145
- * - This function works **only in browser environments** (no effect on server-side).
146
- * - It leverages the native `window.scrollTo()` API with support for smooth scrolling
147
- * and an optional timeout delay before executing the scroll.
148
- * - Each option has strict valid values.
149
- * - If an invalid value is provided, the function **automatically falls back to its default**.
150
- * @param {ScrollToTopOptions} [options] - Optional settings for scroll behavior.
151
- * @param {ScrollToTopOptions["behavior"]} [options.behavior="smooth"] - Scroll animation type.
152
- * - Valid values: `"auto"`, `"instant"`, `"smooth"`.
153
- * - Default force to `"smooth"` if missing or invalid.
154
- * @param {ScrollToTopOptions["timeout"]} [options.timeout=1] - Delay before scrolling (in milliseconds).
155
- * - Default value is `1`.
156
- * - Valid values: any number `≥` `1`.
157
- * - Non-integer number are truncated to an integer.
158
- * - Force to `2147483647` if number is larger than `2147483647`.
159
- * - Default force to `1` if `missing`, `NaN`, `invalid`, or `less-than` `1`.
160
- * @returns {void} Does not return anything, only scrolling to top (void).
161
- * @example
162
- * // ✅ Valid options value:
163
- * scrollToTop();
164
- * // ➔ Scroll smoothly to the top after 1ms delay
165
- * scrollToTop({ behavior: "instant" });
166
- * // ➔ Jump instantly to the top
167
- * scrollToTop({ timeout: 500 });
168
- * // ➔ Scroll smoothly to the top after 500ms
169
- *
170
- * // ❌ Invalid options value:
171
- * scrollToTop({ behavior: "fly", timeout: -100 });
172
- * // ➔ Fallback: behavior="smooth", timeout=1
173
- * scrollToTop({ behavior: "fly", timeout: 123.55 });
174
- * // ➔ Fallback: behavior="smooth", timeout=123
175
- */
140
+ * * ***Utility: `scrollToTop`.***
141
+ * ----------------------------------------------------------
142
+ * **Scrolls the page to the top with optional smooth animation and delay.**
143
+ * - **Features**:
144
+ * - This function works **only in browser environments** (no effect on server-side).
145
+ * - It leverages the native `window.scrollTo()` API with support for smooth scrolling
146
+ * and an optional timeout delay before executing the scroll.
147
+ * - Each option has strict valid values.
148
+ * - If an invalid value is provided, the function **automatically falls back to its default**.
149
+ * @param {ScrollToTopOptions} [options] - Optional settings for scroll behavior.
150
+ * @param {ScrollToTopOptions["behavior"]} [options.behavior="smooth"] - Scroll animation type.
151
+ * - Valid values: `"auto"`, `"instant"`, `"smooth"`.
152
+ * - Default force to `"smooth"` if missing or invalid.
153
+ * @param {ScrollToTopOptions["timeout"]} [options.timeout=1] - Delay before scrolling (in milliseconds).
154
+ * - Default value is `1`.
155
+ * - Valid values: any number `≥` `1`.
156
+ * - Non-integer number are truncated to an integer.
157
+ * - Force to `2147483647` if number is larger than `2147483647`.
158
+ * - Default force to `1` if `missing`, `NaN`, `invalid`, or `less-than` `1`.
159
+ * @returns {void} Does not return anything, only scrolling to top (void).
160
+ * @example
161
+ * // ✅ Valid options value:
162
+ * scrollToTop();
163
+ * // ➔ Scroll smoothly to the top after 1ms delay
164
+ * scrollToTop({ behavior: "instant" });
165
+ * // ➔ Jump instantly to the top
166
+ * scrollToTop({ timeout: 500 });
167
+ * // ➔ Scroll smoothly to the top after 500ms
168
+ *
169
+ * // ❌ Invalid options value:
170
+ * scrollToTop({ behavior: "fly", timeout: -100 });
171
+ * // ➔ Fallback: behavior="smooth", timeout=1
172
+ * scrollToTop({ behavior: "fly", timeout: 123.55 });
173
+ * // ➔ Fallback: behavior="smooth", timeout=123
174
+ */
176
175
  declare const scrollToTop: (options?: ScrollToTopOptions) => void;
177
-
178
176
  export { disableUserInteraction, enableUserInteraction, removeElementFocus, scrollToTop };
@@ -1,13 +1,51 @@
1
1
  /*!
2
- * ====================================================
3
- * Rzl Utils-JS.
4
- * ----------------------------------------------------
5
- * Version: 3.12.0.
6
- * Author: Rizalvin Dwiky.
7
- * Repository: https://github.com/rzl-zone/utils-js.
8
- * ====================================================
9
- */
10
- export { disableUserInteraction, enableUserInteraction, removeElementFocus, scrollToTop } from '../chunk-BNIMTFK5.js';
11
- import '../chunk-L5RDAVVH.js';
12
- import '../chunk-BKIJBNIE.js';
13
- import '../chunk-CSG4SCL3.js';
2
+ * ========================================================================
3
+ * @rzl-zone/utils-js
4
+ * ------------------------------------------------------------------------
5
+ * Version: `3.12.1-beta.1`
6
+ * Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
7
+ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
8
+ * ========================================================================
9
+ */
10
+ import { A as isPlainObject, b as hasOwnProp, w as isNumber, y as isNonEmptyString } from "../assertIsBoolean-DR1SaXPD.js";
11
+ import { t as assertIsString } from "../assertIsString-CEB07_83.js";
12
+ import { t as isServer } from "../isServer-Da3o3XSs.js";
13
+ const disableUserInteraction = (className = "on_processing") => {
14
+ if (isServer()) return;
15
+ assertIsString(className, { message({ validType, currentType }) {
16
+ return `First parameter \`className\` must be of type \`${validType}\`, but received: \`${currentType}\`.`;
17
+ } });
18
+ const { documentElement } = document;
19
+ if (documentElement && !documentElement.classList.contains(className)) documentElement.classList.add(className);
20
+ };
21
+ const enableUserInteraction = (className = "on_processing") => {
22
+ if (isServer()) return;
23
+ assertIsString(className, { message({ validType, currentType }) {
24
+ return `First parameter \`className\` must be of type \`${validType}\`, but received: \`${currentType}\`.`;
25
+ } });
26
+ const { documentElement } = document;
27
+ if (documentElement && documentElement.classList.contains(className)) documentElement.classList.remove(className);
28
+ };
29
+ const removeElementFocus = () => {
30
+ if (isServer()) return;
31
+ const activeElement = document.activeElement;
32
+ if (activeElement instanceof HTMLElement) activeElement.blur();
33
+ };
34
+ const scrollToTop = (options) => {
35
+ if (isServer()) return;
36
+ if (!isPlainObject(options)) options = {};
37
+ const behavior = hasOwnProp(options, "behavior") && isNonEmptyString(options.behavior) && [
38
+ "auto",
39
+ "instant",
40
+ "smooth"
41
+ ].includes(options.behavior) ? options.behavior : "smooth";
42
+ let timeout = hasOwnProp(options, "timeout") && isNumber(options.timeout) && options.timeout >= 1 ? options.timeout : 1;
43
+ timeout = timeout > 2147483647 ? 2147483647 : timeout;
44
+ setTimeout(() => window.scrollTo({
45
+ top: 0,
46
+ left: 0,
47
+ behavior
48
+ }), timeout);
49
+ };
50
+ export { disableUserInteraction, enableUserInteraction, removeElementFocus, scrollToTop };
51
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/events/actions/disableUserInteraction.ts","../../src/events/actions/enableUserInteraction.ts","../../src/events/actions/removeElementFocus.ts","../../src/events/actions/scrollToTop.ts"],"sourcesContent":["import { isServer } from \"@/predicates/is/isServer\";\nimport { assertIsString } from \"@/assertions/strings/assertIsString\";\n\n/** ----------------------------------------------------------\n * * ***Utility: `disableUserInteraction`.***\n * ----------------------------------------------------------\n * **Disables user interaction by adding a CSS class to the `<html>` element.**\n * - **Key points**:\n * - Works **only in browser environments**.\n * - Safely adds the specified CSS class to `<html>`.\n * - Prevents multiple additions of the same class.\n * - Useful to indicate that a process is ongoing\n * (e.g., loading or processing state).\n * - **Using custom CSS classes:**\n * - You can pass any class name that exists in your CSS.\n * - Example: if you have `.loading` in your styles, passing `\"loading\"`\n * will add it and disable interactions accordingly.\n * - **Validation:**\n * - Throws `TypeError` if the `className` parameter is not a string.\n * @defaultValue `\"on_processing\"`\n * @param {string} [className=\"on_processing\"] - The CSS class to add, defaults to `\"on_processing\"`.\n * @returns {void} Does not return anything (void).\n * @throws **{@link TypeError | `TypeError`}** if `className` is not a string.\n * @example\n * * ***Example in your code:***\n * ```ts\n * disableUserInteraction(); // ➔ Adds \"on_processing\" class\n * disableUserInteraction(\"loading\"); // ➔ Adds \"loading\" class\n * // ❌ Invalid value:\n * disableUserInteraction(123); // ➔ Throws TypeError\n * ```\n * * ***Example in your css file (with defaultValue `className` props [on_processing]):***\n * ```css\n * .on_processing {\n * cursor: wait;\n * touch-action: none;\n * user-select: none;\n * }\n *\n * .on_processing > * {\n * pointer-events: none;\n * touch-action: none;\n * user-select: none;\n * }\n * ```\n */\nexport const disableUserInteraction = (\n className: string = \"on_processing\"\n): void => {\n // Ensure function runs only in the browser\n if (isServer()) return;\n\n assertIsString(className, {\n message({ validType, currentType }) {\n return `First parameter \\`className\\` must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`;\n }\n });\n\n const { documentElement } = document;\n\n if (documentElement && !documentElement.classList.contains(className)) {\n documentElement.classList.add(className);\n }\n};\n","import { isServer } from \"@/predicates/is/isServer\";\nimport { assertIsString } from \"@/assertions/strings/assertIsString\";\n\n/** ----------------------------------------------------------\n * * ***Utility: `enableUserInteraction`.***\n * ----------------------------------------------------------\n * **Enables user interaction by removing a CSS class from the `<html>` element.**\n * - **Key points**:\n * - Works **only in browser environments**.\n * - Safely removes the specified CSS class from `<html>`.\n * - Does nothing if the class is not present.\n * - Useful to re-enable user interactions after a process\n * (e.g., loading or processing) completes.\n * - **Using custom CSS classes:**\n * - You can pass any class name that exists in your CSS.\n * - Example: if you have `.loading` in your styles, passing `\"loading\"`\n * will remove it and re-enable interactions.\n * - **Validation:**\n * - Throws `TypeError` if the `className` parameter is not a string.\n * @defaultValue `\"on_processing\"`\n * @param {string} [className=\"on_processing\"] - The CSS class to remove, defaults to `\"on_processing\"`.\n * @returns {void} Does not return anything (void).\n * @throws **{@link TypeError | `TypeError`}** if `className` is not a string.\n * @example\n * * ***Example in your code:***\n * ```ts\n * enableUserInteraction(); // ➔ Removes \"on_processing\" class\n * enableUserInteraction(\"loading\"); // ➔ Removes \"loading\" class\n * // ❌ Invalid value:\n * enableUserInteraction(123); // ➔ Throws TypeError\n * ```\n * * ***Example in your css file (with defaultValue `className` props [on_processing]):***\n * ```css\n * .on_processing {\n * cursor: wait;\n * touch-action: none;\n * user-select: none;\n * }\n *\n * .on_processing > * {\n * pointer-events: none;\n * touch-action: none;\n * user-select: none;\n * }\n * ```\n */\nexport const enableUserInteraction = (\n className: string = \"on_processing\"\n): void => {\n // Ensure function runs only in the browser\n if (isServer()) return;\n\n assertIsString(className, {\n message({ validType, currentType }) {\n return `First parameter \\`className\\` must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`;\n }\n });\n\n const { documentElement } = document;\n\n if (documentElement && documentElement.classList.contains(className)) {\n documentElement.classList.remove(className);\n }\n};\n","import { isServer } from \"@/predicates/is/isServer\";\n\n/** ----------------------------------------------------------\n * * ***Utility: `removeElementFocus`.***\n * ----------------------------------------------------------\n * **Removes focus from the currently active element in the document.**\n * - **Features**:\n * - This function works **only in browser environments** ***(safely no-ops in server environments)***.\n * - If an element is focused, it will lose focus by calling `HTMLElement.blur()`.\n * - If no element is focused or the active element is not an `HTMLElement`, nothing happens.\n * @returns {void} Does not return anything (void).\n * @example\n * removeElementFocus(); // ➔ Removes focus from the currently active element\n */\nexport const removeElementFocus = (): void => {\n // Ensure function runs only in the browser\n if (isServer()) return;\n\n const activeElement = document.activeElement;\n\n if (activeElement instanceof HTMLElement) {\n activeElement.blur();\n } else {\n // not-support, currently we nothing to do...\n // console.warn(\"removeElementFocus: No active element to blur or unsupported element type.\");\n }\n};\n","import { isNumber } from \"@/predicates/is/isNumber\";\nimport { hasOwnProp } from \"@/predicates/has/hasOwnProp\";\nimport { isServer } from \"@/predicates/is/isServer\";\nimport { isPlainObject } from \"@/predicates/is/isPlainObject\";\nimport { isNonEmptyString } from \"@/predicates/is/isNonEmptyString\";\n\n/**\n * ***Types options for {@link scrollToTop | `scrollToTop`}.***\n */\ntype ScrollToTopOptions = {\n /** ----------------------------------------------------------\n * * ***Scroll animation type.***\n * ----------------------------------------------------------\n * - ***Behavior:***\n * - Valid values: `\"auto\"`, `\"instant\"`, `\"smooth\"`.\n * - Default force to `\"smooth\"` if missing or invalid.\n *\n * @default \"smooth\"\n */\n behavior?: ScrollBehavior | undefined;\n /** ----------------------------------------------------------\n * * ***Delay before scrolling (in milliseconds).***\n * ----------------------------------------------------------\n * - ***Behavior:***\n * - Default value is `1`.\n * - Valid values: any number `≥` `1`.\n * - Non-integer number are truncated to an integer.\n * - Force to `2147483647` if number is larger than `2147483647`.\n * - Default force to `1` if `missing`, `NaN`, `invalid-type`, or `less-than` `1`.\n *\n * @default 1\n */\n timeout?: number | undefined;\n};\n\n/** ----------------------------------------------------------\n * * ***Utility: `scrollToTop`.***\n * ----------------------------------------------------------\n * **Scrolls the page to the top with optional smooth animation and delay.**\n * - **Features**:\n * - This function works **only in browser environments** (no effect on server-side).\n * - It leverages the native `window.scrollTo()` API with support for smooth scrolling\n * and an optional timeout delay before executing the scroll.\n * - Each option has strict valid values.\n * - If an invalid value is provided, the function **automatically falls back to its default**.\n * @param {ScrollToTopOptions} [options] - Optional settings for scroll behavior.\n * @param {ScrollToTopOptions[\"behavior\"]} [options.behavior=\"smooth\"] - Scroll animation type.\n * - Valid values: `\"auto\"`, `\"instant\"`, `\"smooth\"`.\n * - Default force to `\"smooth\"` if missing or invalid.\n * @param {ScrollToTopOptions[\"timeout\"]} [options.timeout=1] - Delay before scrolling (in milliseconds).\n * - Default value is `1`.\n * - Valid values: any number `≥` `1`.\n * - Non-integer number are truncated to an integer.\n * - Force to `2147483647` if number is larger than `2147483647`.\n * - Default force to `1` if `missing`, `NaN`, `invalid`, or `less-than` `1`.\n * @returns {void} Does not return anything, only scrolling to top (void).\n * @example\n * // ✅ Valid options value:\n * scrollToTop();\n * // ➔ Scroll smoothly to the top after 1ms delay\n * scrollToTop({ behavior: \"instant\" });\n * // ➔ Jump instantly to the top\n * scrollToTop({ timeout: 500 });\n * // ➔ Scroll smoothly to the top after 500ms\n *\n * // ❌ Invalid options value:\n * scrollToTop({ behavior: \"fly\", timeout: -100 });\n * // ➔ Fallback: behavior=\"smooth\", timeout=1\n * scrollToTop({ behavior: \"fly\", timeout: 123.55 });\n * // ➔ Fallback: behavior=\"smooth\", timeout=123\n */\nexport const scrollToTop = (options?: ScrollToTopOptions): void => {\n // Ensure function runs only in the browser\n if (isServer()) return;\n\n // Ensure options is an object and Defensive options check\n if (!isPlainObject(options)) {\n options = {};\n }\n\n const behavior: ScrollBehavior =\n hasOwnProp(options, \"behavior\") &&\n isNonEmptyString(options.behavior) &&\n [\"auto\", \"instant\", \"smooth\"].includes(options.behavior)\n ? options.behavior\n : \"smooth\";\n let timeout =\n hasOwnProp(options, \"timeout\") &&\n isNumber(options.timeout) &&\n options.timeout >= 1\n ? options.timeout\n : 1;\n\n timeout = timeout > 2147483647 ? 2147483647 : timeout;\n\n setTimeout(() => window.scrollTo({ top: 0, left: 0, behavior }), timeout);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,MAAa,0BACX,YAAoB,oBACX;CAET,IAAI,UAAU,EAAE;CAEhB,eAAe,WAAW,EACxB,QAAQ,EAAE,WAAW,eAAe;EAClC,OAAO,mDAAmD,UAAU,sBAAsB,YAAY;IAEzG,CAAC;CAEF,MAAM,EAAE,oBAAoB;CAE5B,IAAI,mBAAmB,CAAC,gBAAgB,UAAU,SAAS,UAAU,EACnE,gBAAgB,UAAU,IAAI,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACf5C,MAAa,yBACX,YAAoB,oBACX;CAET,IAAI,UAAU,EAAE;CAEhB,eAAe,WAAW,EACxB,QAAQ,EAAE,WAAW,eAAe;EAClC,OAAO,mDAAmD,UAAU,sBAAsB,YAAY;IAEzG,CAAC;CAEF,MAAM,EAAE,oBAAoB;CAE5B,IAAI,mBAAmB,gBAAgB,UAAU,SAAS,UAAU,EAClE,gBAAgB,UAAU,OAAO,UAAU;;;;;;;;;;;;;;;;;AC/C/C,MAAa,2BAAiC;CAE5C,IAAI,UAAU,EAAE;CAEhB,MAAM,gBAAgB,SAAS;CAE/B,IAAI,yBAAyB,aAC3B,cAAc,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACkDxB,MAAa,eAAe,YAAuC;CAEjE,IAAI,UAAU,EAAE;CAGhB,IAAI,CAAC,cAAc,QAAQ,EACzB,UAAU,EAAE;CAGd,MAAM,WACJ,WAAW,SAAS,WAAW,IAC/B,iBAAiB,QAAQ,SAAS,IAClC;EAAC;EAAQ;EAAW;EAAS,CAAC,SAAS,QAAQ,SAAS,GACpD,QAAQ,WACR;CACN,IAAI,UACF,WAAW,SAAS,UAAU,IAC9B,SAAS,QAAQ,QAAQ,IACzB,QAAQ,WAAW,IACf,QAAQ,UACR;CAEN,UAAU,UAAU,aAAa,aAAa;CAE9C,iBAAiB,OAAO,SAAS;EAAE,KAAK;EAAG,MAAM;EAAG;EAAU,CAAC,EAAE,QAAQ"}
@@ -0,0 +1,171 @@
1
+ /*!
2
+ * ========================================================================
3
+ * @rzl-zone/utils-js
4
+ * ------------------------------------------------------------------------
5
+ * Version: `3.12.1-beta.1`
6
+ * Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
7
+ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
8
+ * ========================================================================
9
+ */
10
+ "use strict";
11
+ const require_assertIsBoolean = require('./assertIsBoolean-C8WEXVr2.cjs');
12
+ const require_safeStableStringify = require('./safeStableStringify-CJtP89qn.cjs');
13
+ const require_isEmptyString = require('./isEmptyString-UiiUsSQj.cjs');
14
+ const require_isValidDomain = require('./isValidDomain-BB9IGhJs.cjs');
15
+ const require_removeSpaces = require('./removeSpaces-CWIvhZHg.cjs');
16
+ var NormalizePathnameError = class NormalizePathnameError extends Error {
17
+ originalError;
18
+ constructor(message, originalError) {
19
+ super(message, require_assertIsBoolean.isFunction(Error) ? { cause: originalError } : void 0);
20
+ this.name = "NormalizePathnameError";
21
+ this.originalError = originalError;
22
+ if (require_assertIsBoolean.isFunction(Error.captureStackTrace)) Error.captureStackTrace(this, NormalizePathnameError);
23
+ else this.stack = new Error(message).stack;
24
+ }
25
+ toJSON() {
26
+ return {
27
+ name: this.name,
28
+ message: this.message,
29
+ stack: this.stack,
30
+ originalError: {
31
+ name: this.originalError.name,
32
+ message: this.originalError.message,
33
+ stack: this.originalError.stack
34
+ }
35
+ };
36
+ }
37
+ };
38
+ function normalizePathname(pathname, options = {
39
+ defaultPath: "/",
40
+ keepNullable: false
41
+ }) {
42
+ require_assertIsBoolean.assertIsPlainObject(options, { message({ currentType, validType }) {
43
+ return `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`;
44
+ } });
45
+ const { defaultPath = "/", keepNullable = false, keepTrailingSlash = false, localhostDomain = false, ignoreDomainExtensions = void 0 } = options;
46
+ if (!require_assertIsBoolean.isNonEmptyString(defaultPath)) throw new TypeError(`Parameter \`defaultPath\` property of the \`options\` (second parameter) must be of type \`string\` and not empty-string, but received: \`${require_assertIsBoolean.getPreciseType(defaultPath)}\`, with value: \`${require_safeStableStringify.safeStableStringify(defaultPath, { keepUndefined: true })}\`.`);
47
+ require_assertIsBoolean.assertIsBoolean(keepNullable, { message({ currentType, validType }) {
48
+ return `Parameter \`keepNullable\` property of the \`options\` (second parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.`;
49
+ } });
50
+ require_assertIsBoolean.assertIsBoolean(keepTrailingSlash, { message({ currentType, validType }) {
51
+ return `Parameter \`keepTrailingSlash\` property of the \`options\` (second parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.`;
52
+ } });
53
+ require_assertIsBoolean.assertIsBoolean(localhostDomain, { message({ currentType, validType }) {
54
+ return `Parameter \`localhostDomain\` property of the \`options\` (second parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.`;
55
+ } });
56
+ let ignoreDomainExtsSet;
57
+ if (!require_assertIsBoolean.isUndefined(ignoreDomainExtensions)) {
58
+ if (!require_assertIsBoolean.isSet(ignoreDomainExtensions) && !require_assertIsBoolean.isArray(ignoreDomainExtensions)) throw new TypeError(`Parameter \`ignoreDomainExtensions\` must be of type a \`Set<string>\` or \`string[]\`, but received: \`${require_assertIsBoolean.getPreciseType(ignoreDomainExtensions)}\`.`);
59
+ ignoreDomainExtsSet = require_assertIsBoolean.isSet(ignoreDomainExtensions) ? ignoreDomainExtensions : new Set(ignoreDomainExtensions);
60
+ let idx = 0;
61
+ for (const ext of ignoreDomainExtsSet) {
62
+ if (!require_assertIsBoolean.isNonEmptyString(ext)) throw new TypeError(`Parameter \`ignoreDomainExtensions[${idx}]\` must be a \`string\` and \`non-empty string\`, but received: \`${require_safeStableStringify.safeStableStringify(ext, { keepUndefined: true })}\`.`);
63
+ if (!ext.startsWith(".")) throw new TypeError(`Parameter \`ignoreDomainExtensions[${idx}]\` must start with a dot (.), but received: ${require_safeStableStringify.safeStableStringify(ext, { keepUndefined: true })}`);
64
+ idx++;
65
+ }
66
+ }
67
+ try {
68
+ if (keepNullable && (require_assertIsBoolean.isNil(pathname) || !require_assertIsBoolean.isString(pathname))) {
69
+ if (require_assertIsBoolean.isNull(pathname)) return null;
70
+ return;
71
+ }
72
+ let currentPathName = require_assertIsBoolean.isNonEmptyString(pathname) ? pathname : defaultPath;
73
+ currentPathName = require_removeSpaces.removeSpaces(currentPathName, { trimOnly: true }).replace(/\s+/g, "");
74
+ currentPathName = stripLeadingDomain(currentPathName, {
75
+ keepTrailingSlash,
76
+ localhostDomain,
77
+ ignoreDomainExtensions: ignoreDomainExtsSet
78
+ });
79
+ let _pathName = currentPathName;
80
+ let search = "";
81
+ let hash = "";
82
+ const searchIndex = currentPathName.indexOf("?");
83
+ const hashIndex = currentPathName.indexOf("#");
84
+ if (searchIndex !== -1) search = currentPathName.slice(searchIndex, hashIndex !== -1 ? hashIndex : void 0);
85
+ if (hashIndex !== -1) hash = currentPathName.slice(hashIndex);
86
+ const endIndex = Math.min(searchIndex !== -1 ? searchIndex : currentPathName.length, hashIndex !== -1 ? hashIndex : currentPathName.length);
87
+ _pathName = currentPathName.slice(0, endIndex);
88
+ _pathName = "/" + _pathName.replace(/^\/+/, "").replace(/\/{2,}/g, "/");
89
+ if (!keepTrailingSlash && _pathName !== "/") _pathName = _pathName.replace(/\/+$/, "");
90
+ _pathName = decodeUnicodeSequences(_pathName);
91
+ search = decodeUnicodeSequences(search);
92
+ hash = decodeUnicodeSequences(hash);
93
+ return _pathName + search + hash;
94
+ } catch (error) {
95
+ throwError(error);
96
+ }
97
+ }
98
+ const decodeUnicodeSequences = (str) => {
99
+ return str.replace(/(?:%(?:[0-9A-F]{2})){2,}/gi, (match) => {
100
+ try {
101
+ const decoded = decodeURIComponent(match);
102
+ if (/^[\u0000-\u007F]+$/.test(decoded)) return match;
103
+ return decoded;
104
+ } catch {
105
+ return match;
106
+ }
107
+ });
108
+ };
109
+ const stripLeadingDomain = (path, options) => {
110
+ let currentPath = path;
111
+ const { ignoreDomainExtensions, localhostDomain } = options;
112
+ if (/^https?:\/\//i.test(currentPath)) try {
113
+ const url = new URL(currentPath);
114
+ currentPath = url.pathname.replace(/^\/+/, "").replace(/\/{2,}/g, "/") + url.search + url.hash;
115
+ return ensureLeadingSlash(currentPath);
116
+ } catch (error) {
117
+ throwError(error);
118
+ }
119
+ if (currentPath.startsWith("/")) currentPath = currentPath.replace(/\/{2,}/g, "/").slice(1);
120
+ const segments = currentPath.split("/");
121
+ const firstPart = segments[0];
122
+ const domainPart = firstPart?.split(":")[0];
123
+ const isDomain = require_isValidDomain.isValidDomain(domainPart, {
124
+ subdomain: true,
125
+ allowUnicode: true,
126
+ wildcard: true,
127
+ allowLocalhost: localhostDomain,
128
+ allowPort: true,
129
+ allowProtocol: true,
130
+ topLevel: false
131
+ });
132
+ let hasIgnoredExtension = false;
133
+ if (ignoreDomainExtensions) {
134
+ for (const ext of ignoreDomainExtensions) if (firstPart?.endsWith(ext)) {
135
+ hasIgnoredExtension = true;
136
+ break;
137
+ }
138
+ }
139
+ if (isDomain && !hasIgnoredExtension) segments.shift();
140
+ return ensureLeadingSlash(segments.join("/"));
141
+ };
142
+ const ensureLeadingSlash = (path) => {
143
+ if (!path.startsWith("/")) path = "/" + path;
144
+ return path;
145
+ };
146
+ const throwError = (error) => {
147
+ const err = require_assertIsBoolean.isError(error) ? error : /* @__PURE__ */ new Error("Unknown error from function `normalizePathname()`.");
148
+ throw new NormalizePathnameError(`Failed to normalize pathname in function \`normalizePathname()\`: ${err.message}`, err);
149
+ };
150
+ const formatEnvPort = (envVar, options = {}) => {
151
+ if (!require_assertIsBoolean.isNonEmptyString(envVar)) return "";
152
+ require_assertIsBoolean.assertIsPlainObject(options, { message: ({ currentType, validType }) => `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.` });
153
+ const prefixColon = require_assertIsBoolean.hasOwnProp(options, "prefixColon") ? options.prefixColon : false;
154
+ if (!require_assertIsBoolean.isBoolean(prefixColon)) throw new TypeError(`Parameter \`prefixColon\` property of the \`options\` (second parameter) must be of type \`boolean\`, but received: \`${require_assertIsBoolean.getPreciseType(prefixColon)}\`.`);
155
+ const digitsOnly = envVar.replace(/\D+/g, "");
156
+ if (require_isEmptyString.isEmptyString(digitsOnly)) return "";
157
+ return prefixColon ? `:${digitsOnly}` : digitsOnly;
158
+ };
159
+ Object.defineProperty(exports, 'formatEnvPort', {
160
+ enumerable: true,
161
+ get: function () {
162
+ return formatEnvPort;
163
+ }
164
+ });
165
+ Object.defineProperty(exports, 'normalizePathname', {
166
+ enumerable: true,
167
+ get: function () {
168
+ return normalizePathname;
169
+ }
170
+ });
171
+ //# sourceMappingURL=formatEnvPort-B3OLxQk9.cjs.map