umaki 0.12.0 → 0.13.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 (147) hide show
  1. package/README.md +58 -0
  2. package/dist/LICENSE.txt +1 -32
  3. package/dist/{index.cjs.js → index.cjs} +64 -62
  4. package/dist/index.es.js +3 -1
  5. package/dist/libs/callback/{index.cjs.js → index.cjs} +2 -2
  6. package/dist/libs/config/{_internal.cjs.js → _internal.cjs} +1 -1
  7. package/dist/libs/config/{get-config.cjs.js → get-config.cjs} +1 -1
  8. package/dist/libs/config/{index.cjs.js → index.cjs} +3 -3
  9. package/dist/libs/config/set-config.cjs +12 -0
  10. package/dist/libs/config/set-config.d.ts +1 -0
  11. package/dist/libs/config/set-config.es.js +5 -1
  12. package/dist/libs/control/{bg-scroll-stop.cjs.js → bg-scroll-stop.cjs} +2 -1
  13. package/dist/libs/control/bg-scroll-stop.d.ts +1 -0
  14. package/dist/libs/control/bg-scroll-stop.es.js +1 -0
  15. package/dist/libs/control/{index.cjs.js → index.cjs} +5 -5
  16. package/dist/libs/control/{scroll-to-hash.cjs.js → scroll-to-hash.cjs} +1 -0
  17. package/dist/libs/control/scroll-to-hash.d.ts +1 -0
  18. package/dist/libs/control/scroll-to-hash.es.js +1 -0
  19. package/dist/libs/control/{video-play-control.cjs.js → video-play-control.cjs} +1 -1
  20. package/dist/libs/convert/{change-date-string-to-specific-format.cjs.js → change-date-string-to-specific-format.cjs} +4 -4
  21. package/dist/libs/convert/change-date-string-to-specific-format.es.js +2 -2
  22. package/dist/libs/convert/{index.cjs.js → index.cjs} +4 -4
  23. package/dist/libs/eventControl/{index.cjs.js → index.cjs} +2 -2
  24. package/dist/libs/get/{get-aspect-ratio.cjs.js → get-aspect-ratio.cjs} +1 -1
  25. package/dist/libs/get/get-document-height.cjs +7 -0
  26. package/dist/libs/get/get-document-height.d.ts +1 -0
  27. package/dist/libs/get/get-document-height.es.js +4 -1
  28. package/dist/libs/get/{get-gcd.cjs.js → get-gcd.cjs} +4 -1
  29. package/dist/libs/get/get-gcd.d.ts +1 -0
  30. package/dist/libs/get/get-gcd.es.js +3 -0
  31. package/dist/libs/get/{get-gravatar-url.cjs.js → get-gravatar-url.cjs} +3 -0
  32. package/dist/libs/get/get-gravatar-url.d.ts +4 -0
  33. package/dist/libs/get/get-gravatar-url.es.js +3 -0
  34. package/dist/libs/get/{get-query-params.cjs.js → get-query-params.cjs} +4 -1
  35. package/dist/libs/get/get-query-params.d.ts +1 -0
  36. package/dist/libs/get/get-query-params.es.js +4 -1
  37. package/dist/libs/get/{get-random-int.cjs.js → get-random-int.cjs} +6 -0
  38. package/dist/libs/get/get-random-int.d.ts +5 -1
  39. package/dist/libs/get/get-random-int.es.js +6 -0
  40. package/dist/libs/get/{get-rem.cjs.js → get-rem.cjs} +1 -0
  41. package/dist/libs/get/get-rem.d.ts +1 -0
  42. package/dist/libs/get/get-rem.es.js +1 -0
  43. package/dist/libs/get/get-rendered-line-height.cjs +57 -0
  44. package/dist/libs/get/get-rendered-line-height.d.ts +37 -0
  45. package/dist/libs/get/get-rendered-line-height.es.js +57 -0
  46. package/dist/libs/get/get-rendered-line-height.test.d.ts +1 -0
  47. package/dist/libs/get/get-scrollbar-width.cjs +7 -0
  48. package/dist/libs/get/get-scrollbar-width.d.ts +1 -0
  49. package/dist/libs/get/get-scrollbar-width.es.js +4 -1
  50. package/dist/libs/get/{get-style-property-value-to-number.cjs.js → get-style-property-value-to-number.cjs} +1 -1
  51. package/dist/libs/get/get-style-property-value.cjs +7 -0
  52. package/dist/libs/get/get-style-property-value.d.ts +1 -0
  53. package/dist/libs/get/get-style-property-value.es.js +4 -1
  54. package/dist/libs/get/{get-ua-data.cjs.js → get-ua-data.cjs} +1 -1
  55. package/dist/libs/get/{index.cjs.js → index.cjs} +21 -19
  56. package/dist/libs/get/index.d.ts +2 -1
  57. package/dist/libs/get/index.es.js +3 -1
  58. package/dist/libs/is/{check-device-size.cjs.js → check-device-size.cjs} +1 -1
  59. package/dist/libs/is/{index.cjs.js → index.cjs} +11 -11
  60. package/dist/libs/is/{is-between-date-time.cjs.js → is-between-date-time.cjs} +2 -2
  61. package/dist/libs/is/is-between-date-time.es.js +1 -1
  62. package/dist/libs/is/{is-ipad.cjs.js → is-ipad.cjs} +2 -2
  63. package/dist/libs/is/{is-safari.cjs.js → is-safari.cjs} +1 -1
  64. package/dist/libs/remove/{index.cjs.js → index.cjs} +4 -4
  65. package/dist/libs/remove/remove-all-html-tags.d.ts +7 -1
  66. package/dist/libs/remove/{remove-style-property-value.cjs.js → remove-style-property-value.cjs} +1 -0
  67. package/dist/libs/remove/remove-style-property-value.d.ts +1 -0
  68. package/dist/libs/remove/remove-style-property-value.es.js +1 -0
  69. package/dist/libs/security/{html-sanitize.cjs.js → html-sanitize.cjs} +7 -1
  70. package/dist/libs/security/html-sanitize.d.ts +8 -0
  71. package/dist/libs/security/html-sanitize.es.js +7 -1
  72. package/dist/libs/security/{index.cjs.js → index.cjs} +1 -1
  73. package/dist/libs/set/{index.cjs.js → index.cjs} +6 -6
  74. package/dist/libs/set/{set-100vh.cjs.js → set-100vh.cjs} +1 -0
  75. package/dist/libs/set/set-100vh.d.ts +1 -0
  76. package/dist/libs/set/set-100vh.es.js +1 -0
  77. package/dist/libs/set/{set-100vw.cjs.js → set-100vw.cjs} +1 -0
  78. package/dist/libs/set/set-100vw.d.ts +1 -0
  79. package/dist/libs/set/set-100vw.es.js +1 -0
  80. package/dist/libs/set/{set-style-property-value.cjs.js → set-style-property-value.cjs} +1 -0
  81. package/dist/libs/set/set-style-property-value.d.ts +1 -0
  82. package/dist/libs/set/set-style-property-value.es.js +1 -0
  83. package/dist/libs/to/{index.cjs.js → index.cjs} +2 -2
  84. package/dist/libs/transform/{index.cjs.js → index.cjs} +1 -1
  85. package/dist/libs/wait/{index.cjs.js → index.cjs} +2 -2
  86. package/dist/libs/wait/{wait-for-all-media-loaded.cjs.js → wait-for-all-media-loaded.cjs} +2 -3
  87. package/dist/libs/wait/wait-for-all-media-loaded.d.ts +1 -0
  88. package/dist/libs/wait/wait-for-all-media-loaded.es.js +2 -3
  89. package/package.json +30 -31
  90. package/dist/_virtual/_commonjsHelpers.cjs.js +0 -6
  91. package/dist/_virtual/_commonjsHelpers.es.js +0 -6
  92. package/dist/_virtual/isBetween.cjs.js +0 -7
  93. package/dist/_virtual/isBetween.cjs2.js +0 -4
  94. package/dist/_virtual/isBetween.es.js +0 -7
  95. package/dist/_virtual/isBetween.es2.js +0 -4
  96. package/dist/_virtual/timezone.cjs.js +0 -7
  97. package/dist/_virtual/timezone.cjs2.js +0 -4
  98. package/dist/_virtual/timezone.es.js +0 -7
  99. package/dist/_virtual/timezone.es2.js +0 -4
  100. package/dist/_virtual/utc.cjs.js +0 -7
  101. package/dist/_virtual/utc.cjs2.js +0 -4
  102. package/dist/_virtual/utc.es.js +0 -7
  103. package/dist/_virtual/utc.es2.js +0 -4
  104. package/dist/libs/config/set-config.cjs.js +0 -8
  105. package/dist/libs/get/get-document-height.cjs.js +0 -4
  106. package/dist/libs/get/get-scrollbar-width.cjs.js +0 -4
  107. package/dist/libs/get/get-style-property-value.cjs.js +0 -4
  108. package/dist/node_modules/.pnpm/dayjs@1.11.19/node_modules/dayjs/plugin/isBetween.cjs.js +0 -23
  109. package/dist/node_modules/.pnpm/dayjs@1.11.19/node_modules/dayjs/plugin/isBetween.es.js +0 -23
  110. package/dist/node_modules/.pnpm/dayjs@1.11.19/node_modules/dayjs/plugin/timezone.cjs.js +0 -71
  111. package/dist/node_modules/.pnpm/dayjs@1.11.19/node_modules/dayjs/plugin/timezone.es.js +0 -71
  112. package/dist/node_modules/.pnpm/dayjs@1.11.19/node_modules/dayjs/plugin/utc.cjs.js +0 -83
  113. package/dist/node_modules/.pnpm/dayjs@1.11.19/node_modules/dayjs/plugin/utc.es.js +0 -83
  114. /package/dist/libs/callback/{tap-async.cjs.js → tap-async.cjs} +0 -0
  115. /package/dist/libs/callback/{tap.cjs.js → tap.cjs} +0 -0
  116. /package/dist/libs/config/{default-config.cjs.js → default-config.cjs} +0 -0
  117. /package/dist/libs/control/{copy-to-clipboard.cjs.js → copy-to-clipboard.cjs} +0 -0
  118. /package/dist/libs/control/{pd.cjs.js → pd.cjs} +0 -0
  119. /package/dist/libs/convert/{hex-to-rgb.cjs.js → hex-to-rgb.cjs} +0 -0
  120. /package/dist/libs/convert/{json-string-to-json-object.cjs.js → json-string-to-json-object.cjs} +0 -0
  121. /package/dist/libs/convert/{rgb-to-hex.cjs.js → rgb-to-hex.cjs} +0 -0
  122. /package/dist/libs/eventControl/{debounce.cjs.js → debounce.cjs} +0 -0
  123. /package/dist/libs/eventControl/{throttle.cjs.js → throttle.cjs} +0 -0
  124. /package/dist/libs/get/{get-class-names.cjs.js → get-class-names.cjs} +0 -0
  125. /package/dist/libs/get/{get-event-paths.cjs.js → get-event-paths.cjs} +0 -0
  126. /package/dist/libs/get/{get-orientation.cjs.js → get-orientation.cjs} +0 -0
  127. /package/dist/libs/get/{get-parent-list.cjs.js → get-parent-list.cjs} +0 -0
  128. /package/dist/libs/get/{get-relative-time.cjs.js → get-relative-time.cjs} +0 -0
  129. /package/dist/libs/get/{get-session-storage.cjs.js → get-session-storage.cjs} +0 -0
  130. /package/dist/libs/get/{get-string-length.cjs.js → get-string-length.cjs} +0 -0
  131. /package/dist/libs/is/{is-after-date-time.cjs.js → is-after-date-time.cjs} +0 -0
  132. /package/dist/libs/is/{is-exist-all-elements.cjs.js → is-exist-all-elements.cjs} +0 -0
  133. /package/dist/libs/is/{is-in-viewport.cjs.js → is-in-viewport.cjs} +0 -0
  134. /package/dist/libs/is/{is-key-exists.cjs.js → is-key-exists.cjs} +0 -0
  135. /package/dist/libs/is/{is-online.cjs.js → is-online.cjs} +0 -0
  136. /package/dist/libs/is/{is-scrollable.cjs.js → is-scrollable.cjs} +0 -0
  137. /package/dist/libs/is/{is-touch-support.cjs.js → is-touch-support.cjs} +0 -0
  138. /package/dist/libs/remove/{remove-all-html-tags.cjs.js → remove-all-html-tags.cjs} +0 -0
  139. /package/dist/libs/remove/{remove-attribute.cjs.js → remove-attribute.cjs} +0 -0
  140. /package/dist/libs/remove/{remove-session-storage.cjs.js → remove-session-storage.cjs} +0 -0
  141. /package/dist/libs/set/{set-attribute.cjs.js → set-attribute.cjs} +0 -0
  142. /package/dist/libs/set/{set-scroll-position-to-center.cjs.js → set-scroll-position-to-center.cjs} +0 -0
  143. /package/dist/libs/set/{set-session-storage.cjs.js → set-session-storage.cjs} +0 -0
  144. /package/dist/libs/to/{to-boolean.cjs.js → to-boolean.cjs} +0 -0
  145. /package/dist/libs/to/{to-positive-number.cjs.js → to-positive-number.cjs} +0 -0
  146. /package/dist/libs/transform/{wrap-text-with-spans.cjs.js → wrap-text-with-spans.cjs} +0 -0
  147. /package/dist/libs/wait/{sleep.cjs.js → sleep.cjs} +0 -0
package/README.md CHANGED
@@ -36,6 +36,14 @@ Umaki is your one-stop solution for web development utilities, bringing together
36
36
  import { foo } from "umaki";
37
37
  ```
38
38
 
39
+ Category subpaths are also available to keep bundles small:
40
+
41
+ ```ts
42
+ import { debounce } from "umaki/eventControl";
43
+ ```
44
+
45
+ CommonJS (`require("umaki")`) is supported as well. Some dependencies are ESM-only, so loading umaki with `require` from Node.js needs a version that supports `require(esm)` (Node.js 20.19+ or 22.12+).
46
+
39
47
  ## Configuration
40
48
 
41
49
  ### setConfig
@@ -106,6 +114,7 @@ console.log(breakpoint); // e.g. 768 (default) or custom value if set
106
114
  - [getRandomInt](#getrandomint)
107
115
  - [getRelativeTime](#getrelativetime)
108
116
  - [getRem](#getrem)
117
+ - [getRenderedLineHeight](#getrenderedlineheight)
109
118
  - [getScrollbarWidth](#getscrollbarwidth)
110
119
  - [getSessionStorage](#getsessionstorage)
111
120
  - [getStringLength](#getstringlength)
@@ -619,6 +628,48 @@ console.log(remValue); // '1rem'
619
628
 
620
629
  [View file →](src/libs/get/get-rem.ts)
621
630
 
631
+ ### getRenderedLineHeight
632
+
633
+ Measures the line-height **as it is actually rendered** (in CSS pixels) for a target element by inserting a hidden probe element with the same font-related styles and dividing its multi-line height by the sample line count.
634
+
635
+ This works around an iOS Safari quirk ([WebKit Bug #225695](https://bugs.webkit.org/show_bug.cgi?id=225695)) where fractional `line-height` values are floored to integer pixels at paint time. Stacking-line UIs that rely on `1lh` (e.g. `mask-image: repeating-linear-gradient` rules) drift on iOS Safari but match `getRenderedLineHeight` output. Returns `NaN` in SSR environments or when the probe cannot be measured.
636
+
637
+ The caller is responsible for awaiting `document.fonts.ready` before measuring when font-loaded accuracy matters.
638
+
639
+ ```ts
640
+ import { getRenderedLineHeight } from "umaki";
641
+
642
+ const textEl = document.querySelector<HTMLElement>(".text");
643
+ if (!textEl) return;
644
+
645
+ await document.fonts.ready;
646
+
647
+ const lh = getRenderedLineHeight(textEl);
648
+ if (Number.isFinite(lh)) {
649
+ textEl.style.setProperty("--text-line-height", `${lh}px`);
650
+ }
651
+ ```
652
+
653
+ ```css
654
+ .text {
655
+ mask-image: repeating-linear-gradient(
656
+ to bottom,
657
+ transparent 0,
658
+ transparent calc(var(--text-line-height, 1lh) - 0.5px),
659
+ #000 calc(var(--text-line-height, 1lh) - 0.5px),
660
+ #000 var(--text-line-height, 1lh)
661
+ );
662
+ }
663
+ ```
664
+
665
+ You can adjust the sampling resolution via `sampleLines` (default `20`, minimum `2`):
666
+
667
+ ```ts
668
+ const lh = getRenderedLineHeight(textEl, { sampleLines: 40 });
669
+ ```
670
+
671
+ [View file →](src/libs/get/get-rendered-line-height.ts)
672
+
622
673
  ### getScrollbarWidth
623
674
 
624
675
  A function that retrieves the width of the scrollbar.
@@ -912,6 +963,9 @@ const output = removeAllHtmlTags(input);
912
963
  console.log(output); // 'Hello World!'
913
964
  ```
914
965
 
966
+ > [!NOTE]
967
+ > The result is an HTML string, not plain text. When the input contains `<`, special characters are escaped (e.g. `removeAllHtmlTags("Tom & Jerry <b>!</b>")` returns `'Tom &amp; Jerry !'`). It is safe to insert as HTML, but do not decode it and insert it as HTML. To keep safe markup instead, use [`sanitizeHtml`](#sanitizehtml).
968
+
915
969
  [View file →](src/libs/remove/remove-all-html-tags.ts)
916
970
 
917
971
  ### removeAttribute
@@ -1151,6 +1205,10 @@ This function uses `isomorphic-dompurify` and has the following features:
1151
1205
  - Removes dangerous HTML tags and attributes by default
1152
1206
  - Allows flexible control through custom configuration
1153
1207
  - Can be used on both server-side and client-side
1208
+ - Always returns a string (`RETURN_DOM`, `RETURN_DOM_FRAGMENT`, `RETURN_TRUSTED_TYPE` and `IN_PLACE` are ignored)
1209
+
1210
+ > [!WARNING]
1211
+ > The result is safe only as HTML element content (e.g. `innerHTML`). Do not use it for attribute values, URLs, `<script>` or CSS. Options such as `ALLOWED_URI_REGEXP`, `ADD_TAGS` and `ALLOW_UNKNOWN_PROTOCOLS` can weaken the protection.
1154
1212
 
1155
1213
  [View file →](src/libs/security/html-sanitize.ts)
1156
1214
 
package/dist/LICENSE.txt CHANGED
@@ -1,32 +1 @@
1
- Name: dayjs
2
- Version: 1.11.19
3
- License: MIT
4
- Private: false
5
- Description: 2KB immutable date time library alternative to Moment.js with the same modern API
6
- Repository: https://github.com/iamkun/dayjs.git
7
- Homepage: https://day.js.org
8
- Author: iamkun
9
- License Copyright:
10
- ===
11
-
12
- MIT License
13
-
14
- Copyright (c) 2018-present, iamkun
15
-
16
- Permission is hereby granted, free of charge, to any person obtaining a copy
17
- of this software and associated documentation files (the "Software"), to deal
18
- in the Software without restriction, including without limitation the rights
19
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20
- copies of the Software, and to permit persons to whom the Software is
21
- furnished to do so, subject to the following conditions:
22
-
23
- The above copyright notice and this permission notice shall be included in all
24
- copies or substantial portions of the Software.
25
-
26
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32
- SOFTWARE.
1
+ No third parties dependencies
@@ -1,66 +1,67 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const tap = require("./libs/callback/tap.cjs.js");
4
- const tapAsync = require("./libs/callback/tap-async.cjs.js");
5
- const defaultConfig = require("./libs/config/default-config.cjs.js");
6
- const getConfig = require("./libs/config/get-config.cjs.js");
7
- const setConfig = require("./libs/config/set-config.cjs.js");
8
- const bgScrollStop = require("./libs/control/bg-scroll-stop.cjs.js");
9
- const copyToClipboard = require("./libs/control/copy-to-clipboard.cjs.js");
10
- const pd = require("./libs/control/pd.cjs.js");
11
- const scrollToHash = require("./libs/control/scroll-to-hash.cjs.js");
12
- const videoPlayControl = require("./libs/control/video-play-control.cjs.js");
13
- const changeDateStringToSpecificFormat = require("./libs/convert/change-date-string-to-specific-format.cjs.js");
14
- const hexToRgb = require("./libs/convert/hex-to-rgb.cjs.js");
15
- const jsonStringToJsonObject = require("./libs/convert/json-string-to-json-object.cjs.js");
16
- const rgbToHex = require("./libs/convert/rgb-to-hex.cjs.js");
17
- const debounce = require("./libs/eventControl/debounce.cjs.js");
18
- const throttle = require("./libs/eventControl/throttle.cjs.js");
19
- const getAspectRatio = require("./libs/get/get-aspect-ratio.cjs.js");
20
- const getClassNames = require("./libs/get/get-class-names.cjs.js");
21
- const getDocumentHeight = require("./libs/get/get-document-height.cjs.js");
22
- const getEventPaths = require("./libs/get/get-event-paths.cjs.js");
23
- const getGcd = require("./libs/get/get-gcd.cjs.js");
24
- const getGravatarUrl = require("./libs/get/get-gravatar-url.cjs.js");
25
- const getOrientation = require("./libs/get/get-orientation.cjs.js");
26
- const getParentList = require("./libs/get/get-parent-list.cjs.js");
27
- const getQueryParams = require("./libs/get/get-query-params.cjs.js");
28
- const getRelativeTime = require("./libs/get/get-relative-time.cjs.js");
29
- const getRandomInt = require("./libs/get/get-random-int.cjs.js");
30
- const getRem = require("./libs/get/get-rem.cjs.js");
31
- const getScrollbarWidth = require("./libs/get/get-scrollbar-width.cjs.js");
32
- const getSessionStorage = require("./libs/get/get-session-storage.cjs.js");
33
- const getStringLength = require("./libs/get/get-string-length.cjs.js");
34
- const getStylePropertyValue = require("./libs/get/get-style-property-value.cjs.js");
35
- const getStylePropertyValueToNumber = require("./libs/get/get-style-property-value-to-number.cjs.js");
36
- const getUaData = require("./libs/get/get-ua-data.cjs.js");
37
- const checkDeviceSize = require("./libs/is/check-device-size.cjs.js");
38
- const isAfterDateTime = require("./libs/is/is-after-date-time.cjs.js");
39
- const isBetweenDateTime = require("./libs/is/is-between-date-time.cjs.js");
40
- const isExistAllElements = require("./libs/is/is-exist-all-elements.cjs.js");
41
- const isInViewport = require("./libs/is/is-in-viewport.cjs.js");
42
- const isIpad = require("./libs/is/is-ipad.cjs.js");
43
- const isKeyExists = require("./libs/is/is-key-exists.cjs.js");
44
- const isOnline = require("./libs/is/is-online.cjs.js");
45
- const isSafari = require("./libs/is/is-safari.cjs.js");
46
- const isScrollable = require("./libs/is/is-scrollable.cjs.js");
47
- const isTouchSupport = require("./libs/is/is-touch-support.cjs.js");
48
- const removeAllHtmlTags = require("./libs/remove/remove-all-html-tags.cjs.js");
49
- const removeAttribute = require("./libs/remove/remove-attribute.cjs.js");
50
- const removeSessionStorage = require("./libs/remove/remove-session-storage.cjs.js");
51
- const removeStylePropertyValue = require("./libs/remove/remove-style-property-value.cjs.js");
52
- const htmlSanitize = require("./libs/security/html-sanitize.cjs.js");
53
- const set100vh = require("./libs/set/set-100vh.cjs.js");
54
- const set100vw = require("./libs/set/set-100vw.cjs.js");
55
- const setAttribute = require("./libs/set/set-attribute.cjs.js");
56
- const setScrollPositionToCenter = require("./libs/set/set-scroll-position-to-center.cjs.js");
57
- const setSessionStorage = require("./libs/set/set-session-storage.cjs.js");
58
- const setStylePropertyValue = require("./libs/set/set-style-property-value.cjs.js");
59
- const toBoolean = require("./libs/to/to-boolean.cjs.js");
60
- const toPositiveNumber = require("./libs/to/to-positive-number.cjs.js");
61
- const wrapTextWithSpans = require("./libs/transform/wrap-text-with-spans.cjs.js");
62
- const sleep = require("./libs/wait/sleep.cjs.js");
63
- const waitForAllMediaLoaded = require("./libs/wait/wait-for-all-media-loaded.cjs.js");
3
+ const tap = require("./libs/callback/tap.cjs");
4
+ const tapAsync = require("./libs/callback/tap-async.cjs");
5
+ const defaultConfig = require("./libs/config/default-config.cjs");
6
+ const getConfig = require("./libs/config/get-config.cjs");
7
+ const setConfig = require("./libs/config/set-config.cjs");
8
+ const bgScrollStop = require("./libs/control/bg-scroll-stop.cjs");
9
+ const copyToClipboard = require("./libs/control/copy-to-clipboard.cjs");
10
+ const pd = require("./libs/control/pd.cjs");
11
+ const scrollToHash = require("./libs/control/scroll-to-hash.cjs");
12
+ const videoPlayControl = require("./libs/control/video-play-control.cjs");
13
+ const changeDateStringToSpecificFormat = require("./libs/convert/change-date-string-to-specific-format.cjs");
14
+ const hexToRgb = require("./libs/convert/hex-to-rgb.cjs");
15
+ const jsonStringToJsonObject = require("./libs/convert/json-string-to-json-object.cjs");
16
+ const rgbToHex = require("./libs/convert/rgb-to-hex.cjs");
17
+ const debounce = require("./libs/eventControl/debounce.cjs");
18
+ const throttle = require("./libs/eventControl/throttle.cjs");
19
+ const getAspectRatio = require("./libs/get/get-aspect-ratio.cjs");
20
+ const getClassNames = require("./libs/get/get-class-names.cjs");
21
+ const getDocumentHeight = require("./libs/get/get-document-height.cjs");
22
+ const getEventPaths = require("./libs/get/get-event-paths.cjs");
23
+ const getGcd = require("./libs/get/get-gcd.cjs");
24
+ const getGravatarUrl = require("./libs/get/get-gravatar-url.cjs");
25
+ const getOrientation = require("./libs/get/get-orientation.cjs");
26
+ const getParentList = require("./libs/get/get-parent-list.cjs");
27
+ const getQueryParams = require("./libs/get/get-query-params.cjs");
28
+ const getRandomInt = require("./libs/get/get-random-int.cjs");
29
+ const getRelativeTime = require("./libs/get/get-relative-time.cjs");
30
+ const getRem = require("./libs/get/get-rem.cjs");
31
+ const getRenderedLineHeight = require("./libs/get/get-rendered-line-height.cjs");
32
+ const getScrollbarWidth = require("./libs/get/get-scrollbar-width.cjs");
33
+ const getSessionStorage = require("./libs/get/get-session-storage.cjs");
34
+ const getStringLength = require("./libs/get/get-string-length.cjs");
35
+ const getStylePropertyValue = require("./libs/get/get-style-property-value.cjs");
36
+ const getStylePropertyValueToNumber = require("./libs/get/get-style-property-value-to-number.cjs");
37
+ const getUaData = require("./libs/get/get-ua-data.cjs");
38
+ const checkDeviceSize = require("./libs/is/check-device-size.cjs");
39
+ const isAfterDateTime = require("./libs/is/is-after-date-time.cjs");
40
+ const isBetweenDateTime = require("./libs/is/is-between-date-time.cjs");
41
+ const isExistAllElements = require("./libs/is/is-exist-all-elements.cjs");
42
+ const isInViewport = require("./libs/is/is-in-viewport.cjs");
43
+ const isIpad = require("./libs/is/is-ipad.cjs");
44
+ const isKeyExists = require("./libs/is/is-key-exists.cjs");
45
+ const isOnline = require("./libs/is/is-online.cjs");
46
+ const isSafari = require("./libs/is/is-safari.cjs");
47
+ const isScrollable = require("./libs/is/is-scrollable.cjs");
48
+ const isTouchSupport = require("./libs/is/is-touch-support.cjs");
49
+ const removeAllHtmlTags = require("./libs/remove/remove-all-html-tags.cjs");
50
+ const removeAttribute = require("./libs/remove/remove-attribute.cjs");
51
+ const removeSessionStorage = require("./libs/remove/remove-session-storage.cjs");
52
+ const removeStylePropertyValue = require("./libs/remove/remove-style-property-value.cjs");
53
+ const htmlSanitize = require("./libs/security/html-sanitize.cjs");
54
+ const set100vh = require("./libs/set/set-100vh.cjs");
55
+ const set100vw = require("./libs/set/set-100vw.cjs");
56
+ const setAttribute = require("./libs/set/set-attribute.cjs");
57
+ const setScrollPositionToCenter = require("./libs/set/set-scroll-position-to-center.cjs");
58
+ const setSessionStorage = require("./libs/set/set-session-storage.cjs");
59
+ const setStylePropertyValue = require("./libs/set/set-style-property-value.cjs");
60
+ const toBoolean = require("./libs/to/to-boolean.cjs");
61
+ const toPositiveNumber = require("./libs/to/to-positive-number.cjs");
62
+ const wrapTextWithSpans = require("./libs/transform/wrap-text-with-spans.cjs");
63
+ const sleep = require("./libs/wait/sleep.cjs");
64
+ const waitForAllMediaLoaded = require("./libs/wait/wait-for-all-media-loaded.cjs");
64
65
  exports.tap = tap.tap;
65
66
  exports.tapAsync = tapAsync.tapAsync;
66
67
  exports.defaultConfig = defaultConfig.defaultConfig;
@@ -87,9 +88,10 @@ exports.getGravatarUrl = getGravatarUrl.getGravatarUrl;
87
88
  exports.getOrientation = getOrientation.getOrientation;
88
89
  exports.getParentList = getParentList.getParentList;
89
90
  exports.getQueryParams = getQueryParams.getQueryParams;
90
- exports.getRelativeTime = getRelativeTime.getRelativeTime;
91
91
  exports.getRandomInt = getRandomInt.getRandomInt;
92
+ exports.getRelativeTime = getRelativeTime.getRelativeTime;
92
93
  exports.getRem = getRem.getRem;
94
+ exports.getRenderedLineHeight = getRenderedLineHeight.getRenderedLineHeight;
93
95
  exports.getScrollbarWidth = getScrollbarWidth.getScrollbarWidth;
94
96
  exports.getSessionStorage = getSessionStorage.getSessionStorage;
95
97
  exports.getStringLength = getStringLength.getStringLength;
package/dist/index.es.js CHANGED
@@ -23,9 +23,10 @@ import { getGravatarUrl } from "./libs/get/get-gravatar-url.es.js";
23
23
  import { getOrientation } from "./libs/get/get-orientation.es.js";
24
24
  import { getParentList } from "./libs/get/get-parent-list.es.js";
25
25
  import { getQueryParams } from "./libs/get/get-query-params.es.js";
26
- import { getRelativeTime } from "./libs/get/get-relative-time.es.js";
27
26
  import { getRandomInt } from "./libs/get/get-random-int.es.js";
27
+ import { getRelativeTime } from "./libs/get/get-relative-time.es.js";
28
28
  import { getRem } from "./libs/get/get-rem.es.js";
29
+ import { getRenderedLineHeight } from "./libs/get/get-rendered-line-height.es.js";
29
30
  import { getScrollbarWidth } from "./libs/get/get-scrollbar-width.es.js";
30
31
  import { getSessionStorage } from "./libs/get/get-session-storage.es.js";
31
32
  import { getStringLength } from "./libs/get/get-string-length.es.js";
@@ -80,6 +81,7 @@ export {
80
81
  getRandomInt,
81
82
  getRelativeTime,
82
83
  getRem,
84
+ getRenderedLineHeight,
83
85
  getScrollbarWidth,
84
86
  getSessionStorage,
85
87
  getStringLength,
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const tap = require("./tap.cjs.js");
4
- const tapAsync = require("./tap-async.cjs.js");
3
+ const tap = require("./tap.cjs");
4
+ const tapAsync = require("./tap-async.cjs");
5
5
  exports.tap = tap.tap;
6
6
  exports.tapAsync = tapAsync.tapAsync;
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const defaultConfig = require("./default-config.cjs.js");
3
+ const defaultConfig = require("./default-config.cjs");
4
4
  const currentConfig = { ...defaultConfig.defaultConfig };
5
5
  exports.currentConfig = currentConfig;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const _internal = require("./_internal.cjs.js");
3
+ const _internal = require("./_internal.cjs");
4
4
  const getConfig = () => {
5
5
  return { ..._internal.currentConfig };
6
6
  };
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const defaultConfig = require("./default-config.cjs.js");
4
- const getConfig = require("./get-config.cjs.js");
5
- const setConfig = require("./set-config.cjs.js");
3
+ const defaultConfig = require("./default-config.cjs");
4
+ const getConfig = require("./get-config.cjs");
5
+ const setConfig = require("./set-config.cjs");
6
6
  exports.defaultConfig = defaultConfig.defaultConfig;
7
7
  exports.getConfig = getConfig.getConfig;
8
8
  exports.getConfigValue = getConfig.getConfigValue;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const _internal = require("./_internal.cjs");
4
+ const UNSAFE_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
5
+ const setConfig = (config) => {
6
+ for (const [key, value] of Object.entries(config)) {
7
+ if (UNSAFE_KEYS.has(key)) continue;
8
+ _internal.currentConfig[key] = value;
9
+ }
10
+ return { ..._internal.currentConfig };
11
+ };
12
+ exports.setConfig = setConfig;
@@ -3,5 +3,6 @@ import { UmakiConfig } from './types';
3
3
  * Set or update the configuration
4
4
  * @param config - Configuration object with values to update
5
5
  * @returns The updated configuration object
6
+ * `__proto__`, `constructor` and `prototype` keys are ignored.
6
7
  */
7
8
  export declare const setConfig: (config: Partial<UmakiConfig>) => UmakiConfig;
@@ -1,6 +1,10 @@
1
1
  import { currentConfig } from "./_internal.es.js";
2
+ const UNSAFE_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
2
3
  const setConfig = (config) => {
3
- Object.assign(currentConfig, config);
4
+ for (const [key, value] of Object.entries(config)) {
5
+ if (UNSAFE_KEYS.has(key)) continue;
6
+ currentConfig[key] = value;
7
+ }
4
8
  return { ...currentConfig };
5
9
  };
6
10
  export {
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const getScrollbarWidth = require("../get/get-scrollbar-width.cjs.js");
3
+ const getScrollbarWidth = require("../get/get-scrollbar-width.cjs");
4
4
  const bgScrollStop = (isStop = true) => {
5
+ if (typeof window === "undefined") return;
5
6
  document.body.style.paddingRight = isStop ? `${getScrollbarWidth.getScrollbarWidth()}px` : "";
6
7
  document.body.style.overflow = isStop ? "hidden" : "";
7
8
  };
@@ -11,5 +11,6 @@
11
11
  * When `isStop` is false, the function:
12
12
  * - Resets the body's `paddingRight` style.
13
13
  * - Resets the body's `overflow` style to allow background scrolling.
14
+ * Does nothing in SSR environments where window is undefined.
14
15
  */
15
16
  export declare const bgScrollStop: (isStop?: boolean) => void;
@@ -1,5 +1,6 @@
1
1
  import { getScrollbarWidth } from "../get/get-scrollbar-width.es.js";
2
2
  const bgScrollStop = (isStop = true) => {
3
+ if (typeof window === "undefined") return;
3
4
  document.body.style.paddingRight = isStop ? `${getScrollbarWidth()}px` : "";
4
5
  document.body.style.overflow = isStop ? "hidden" : "";
5
6
  };
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const bgScrollStop = require("./bg-scroll-stop.cjs.js");
4
- const copyToClipboard = require("./copy-to-clipboard.cjs.js");
5
- const pd = require("./pd.cjs.js");
6
- const scrollToHash = require("./scroll-to-hash.cjs.js");
7
- const videoPlayControl = require("./video-play-control.cjs.js");
3
+ const bgScrollStop = require("./bg-scroll-stop.cjs");
4
+ const copyToClipboard = require("./copy-to-clipboard.cjs");
5
+ const pd = require("./pd.cjs");
6
+ const scrollToHash = require("./scroll-to-hash.cjs");
7
+ const videoPlayControl = require("./video-play-control.cjs");
8
8
  exports.bgScrollStop = bgScrollStop.bgScrollStop;
9
9
  exports.copyToClipboard = copyToClipboard.copyToClipboard;
10
10
  exports.pd = pd.pd;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const scrollToHash = async (hash, isSmooth = true, manualOffset) => {
4
+ if (typeof window === "undefined") return false;
4
5
  const hashWithoutSharp = hash.replace("#", "");
5
6
  const targetElement = document.getElementById(hashWithoutSharp);
6
7
  if (!targetElement) return false;
@@ -5,5 +5,6 @@
5
5
  * @param isSmooth - Determines if the scroll behavior should be smooth. Defaults to true.
6
6
  * @param manualOffset - An optional manual offset to adjust the scroll position.
7
7
  * @returns A Promise that resolves to true if the scroll was successful, or false if the target element was not found or the scroll did not complete within the timeout.
8
+ * Resolves to false in SSR environments where window is undefined.
8
9
  */
9
10
  export declare const scrollToHash: (hash: string, isSmooth?: boolean, manualOffset?: number) => Promise<boolean>;
@@ -1,4 +1,5 @@
1
1
  const scrollToHash = async (hash, isSmooth = true, manualOffset) => {
2
+ if (typeof window === "undefined") return false;
2
3
  const hashWithoutSharp = hash.replace("#", "");
3
4
  const targetElement = document.getElementById(hashWithoutSharp);
4
5
  if (!targetElement) return false;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const toBoolean = require("../to/to-boolean.cjs.js");
3
+ const toBoolean = require("../to/to-boolean.cjs");
4
4
  const videoPlayControl = async (videoElement, state, currentTime) => {
5
5
  if (state && videoElement.paused) {
6
6
  const isPlaying = toBoolean.toBoolean(videoElement.dataset.playing ?? "");
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const dayjs = require("dayjs");
4
- const timezone = require("../../_virtual/timezone.cjs.js");
5
- const utc = require("../../_virtual/utc.cjs.js");
6
- dayjs.extend(utc.default);
7
- dayjs.extend(timezone.default);
4
+ const timezone = require("dayjs/plugin/timezone.js");
5
+ const utc = require("dayjs/plugin/utc.js");
6
+ dayjs.extend(utc);
7
+ dayjs.extend(timezone);
8
8
  const changeDateStringToSpecificFormat = (date, format = "YYYY年MM月DD日", tz) => {
9
9
  if (tz) {
10
10
  return dayjs(date).tz(tz).format(format);
@@ -1,6 +1,6 @@
1
1
  import dayjs from "dayjs";
2
- import timezone from "../../_virtual/timezone.es.js";
3
- import utc from "../../_virtual/utc.es.js";
2
+ import timezone from "dayjs/plugin/timezone.js";
3
+ import utc from "dayjs/plugin/utc.js";
4
4
  dayjs.extend(utc);
5
5
  dayjs.extend(timezone);
6
6
  const changeDateStringToSpecificFormat = (date, format = "YYYY年MM月DD日", tz) => {
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const changeDateStringToSpecificFormat = require("./change-date-string-to-specific-format.cjs.js");
4
- const hexToRgb = require("./hex-to-rgb.cjs.js");
5
- const jsonStringToJsonObject = require("./json-string-to-json-object.cjs.js");
6
- const rgbToHex = require("./rgb-to-hex.cjs.js");
3
+ const changeDateStringToSpecificFormat = require("./change-date-string-to-specific-format.cjs");
4
+ const hexToRgb = require("./hex-to-rgb.cjs");
5
+ const jsonStringToJsonObject = require("./json-string-to-json-object.cjs");
6
+ const rgbToHex = require("./rgb-to-hex.cjs");
7
7
  exports.changeDateStringToSpecificFormat = changeDateStringToSpecificFormat.changeDateStringToSpecificFormat;
8
8
  exports.hexToRgb = hexToRgb.hexToRgb;
9
9
  exports.jsonStringToJsonObject = jsonStringToJsonObject.jsonStringToJsonObject;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const debounce = require("./debounce.cjs.js");
4
- const throttle = require("./throttle.cjs.js");
3
+ const debounce = require("./debounce.cjs");
4
+ const throttle = require("./throttle.cjs");
5
5
  exports.debounce = debounce.debounce;
6
6
  exports.throttle = throttle.throttle;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const getGcd = require("./get-gcd.cjs.js");
3
+ const getGcd = require("./get-gcd.cjs");
4
4
  const getAspectRatio = (w, h) => {
5
5
  if (w <= 0 || h <= 0 || !Number.isFinite(w) || !Number.isFinite(h)) {
6
6
  throw new Error("Width and height must be positive finite numbers");
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const getDocumentHeight = () => {
4
+ if (typeof window === "undefined") return 0;
5
+ return document.body.clientHeight - window.innerHeight;
6
+ };
7
+ exports.getDocumentHeight = getDocumentHeight;
@@ -2,5 +2,6 @@
2
2
  * Retrieves the height of the document.
3
3
  *
4
4
  * @returns {number} The height of the document, calculated as the difference between the body's client height and the window's inner height.
5
+ * Returns 0 in SSR environments where window is undefined.
5
6
  */
6
7
  export declare const getDocumentHeight: () => number;
@@ -1,4 +1,7 @@
1
- const getDocumentHeight = () => document.body.clientHeight - window.innerHeight;
1
+ const getDocumentHeight = () => {
2
+ if (typeof window === "undefined") return 0;
3
+ return document.body.clientHeight - window.innerHeight;
4
+ };
2
5
  export {
3
6
  getDocumentHeight
4
7
  };
@@ -1,7 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const toPositiveNumber = require("../to/to-positive-number.cjs.js");
3
+ const toPositiveNumber = require("../to/to-positive-number.cjs");
4
4
  const getGcd = (a, b) => {
5
+ if (!Number.isFinite(a) || !Number.isFinite(b)) {
6
+ throw new Error("Arguments must be finite numbers");
7
+ }
5
8
  const positiveA = toPositiveNumber.toPositiveNumber(a);
6
9
  const positiveB = toPositiveNumber.toPositiveNumber(b);
7
10
  if (positiveB === 0) return positiveA;
@@ -7,5 +7,6 @@
7
7
  * @param a - The first number.
8
8
  * @param b - The second number.
9
9
  * @returns The greatest common divisor of the two numbers.
10
+ * @throws {Error} If a or b is not a finite number.
10
11
  */
11
12
  export declare const getGcd: (a: number, b: number) => number;
@@ -1,5 +1,8 @@
1
1
  import { toPositiveNumber } from "../to/to-positive-number.es.js";
2
2
  const getGcd = (a, b) => {
3
+ if (!Number.isFinite(a) || !Number.isFinite(b)) {
4
+ throw new Error("Arguments must be finite numbers");
5
+ }
3
6
  const positiveA = toPositiveNumber(a);
4
7
  const positiveB = toPositiveNumber(b);
5
8
  if (positiveB === 0) return positiveA;
@@ -2,6 +2,9 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const md5 = require("md5");
4
4
  const getGravatarUrl = (email, size) => {
5
+ if (!Number.isInteger(size) || size <= 0) {
6
+ throw new Error("size must be a positive integer");
7
+ }
5
8
  const normalizedEmail = email.trim().toLowerCase();
6
9
  const gravatarUrl = `https://www.gravatar.com/avatar/${md5(normalizedEmail)}?s=${size}&d=404`;
7
10
  return gravatarUrl;
@@ -5,8 +5,12 @@
5
5
  * and converting to lowercase), generating an MD5 hash, and appending the size
6
6
  * parameter with a 404 fallback.
7
7
  *
8
+ * MD5 is used only because Gravatar requires it; do not use it for security purposes.
9
+ * Note that the hash in the URL can be used to look up or enumerate email addresses.
10
+ *
8
11
  * @param email - The email address to generate the Gravatar URL for.
9
12
  * @param size - The size of the avatar image in pixels.
10
13
  * @returns The Gravatar avatar image URL.
14
+ * @throws {Error} If size is not a positive integer.
11
15
  */
12
16
  export declare const getGravatarUrl: (email: string, size: number) => string;
@@ -1,5 +1,8 @@
1
1
  import md5 from "md5";
2
2
  const getGravatarUrl = (email, size) => {
3
+ if (!Number.isInteger(size) || size <= 0) {
4
+ throw new Error("size must be a positive integer");
5
+ }
3
6
  const normalizedEmail = email.trim().toLowerCase();
4
7
  const gravatarUrl = `https://www.gravatar.com/avatar/${md5(normalizedEmail)}?s=${size}&d=404`;
5
8
  return gravatarUrl;
@@ -6,7 +6,10 @@ const queryStringOptions = {
6
6
  parseNumbers: true
7
7
  };
8
8
  const getQueryParams = (query, options = {}) => {
9
- const { searchString = window.location.search, parseOptions } = options;
9
+ const {
10
+ searchString = typeof window === "undefined" ? "" : window.location.search,
11
+ parseOptions
12
+ } = options;
10
13
  const queryOptions = {
11
14
  ...queryStringOptions,
12
15
  ...parseOptions
@@ -10,5 +10,6 @@ export type GetQueryParamsOptions = {
10
10
  * @param query - The name of the query parameter to retrieve.
11
11
  * @param options - Optional. An object containing searchString and parseOptions.
12
12
  * @returns The value of the query parameter, which can be a string, number, array of strings or numbers, or null if the parameter is not found.
13
+ * In SSR environments where window is undefined, `searchString` defaults to an empty string.
13
14
  */
14
15
  export declare const getQueryParams: (query: string, options?: GetQueryParamsOptions) => GetQueryParamsReturnType;