@splendidlabz/utils 1.11.2 → 1.11.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (228) hide show
  1. package/dist/cjs/dom/accessibility.cjs +2 -0
  2. package/dist/cjs/dom/actions/index.cjs +392 -7
  3. package/dist/cjs/dom/actions/masonry.cjs +97 -6
  4. package/dist/cjs/dom/actions/prefer-horizontal-scroll.cjs +58 -14
  5. package/dist/cjs/dom/actions/sticky.cjs +126 -6
  6. package/dist/cjs/dom/bounding-box.cjs +2 -0
  7. package/dist/cjs/dom/clipboard.cjs +2 -0
  8. package/dist/cjs/dom/cookie.cjs +3 -1
  9. package/dist/cjs/dom/css-vars.cjs +13 -3
  10. package/dist/cjs/dom/events.cjs +2 -0
  11. package/dist/cjs/dom/focusable.cjs +2 -0
  12. package/dist/cjs/dom/font-size.cjs +15 -3
  13. package/dist/cjs/dom/get-element.cjs +3 -1
  14. package/dist/cjs/dom/hash.cjs +2 -0
  15. package/dist/cjs/dom/index.cjs +1249 -47
  16. package/dist/cjs/dom/keyboard.cjs +2 -0
  17. package/dist/cjs/dom/local-store.cjs +3 -1
  18. package/dist/cjs/dom/media.cjs +2 -0
  19. package/dist/cjs/dom/observers/index.cjs +235 -9
  20. package/dist/cjs/dom/observers/intersection-observer.cjs +38 -6
  21. package/dist/cjs/dom/observers/mutation-observer.cjs +38 -6
  22. package/dist/cjs/dom/observers/observer.cjs +12 -2
  23. package/dist/cjs/dom/observers/resize-observer.cjs +38 -6
  24. package/dist/cjs/dom/observers/scroll-observer.cjs +62 -3
  25. package/dist/cjs/dom/pkce.cjs +13 -3
  26. package/dist/cjs/dom/query-params.cjs +3 -1
  27. package/dist/cjs/dom/random-string.cjs +2 -0
  28. package/dist/cjs/dom/sanitize.cjs +27 -3
  29. package/dist/cjs/dom/session-store.cjs +3 -1
  30. package/dist/cjs/dom/spam-prevention.cjs +2 -0
  31. package/dist/cjs/dom/trap-focus.cjs +131 -9
  32. package/dist/cjs/dom/ui/aria-current.cjs +2 -0
  33. package/dist/cjs/dom/ui/inconsistent-button-fix.cjs +2 -0
  34. package/dist/cjs/dom/ui/index.cjs +87 -9
  35. package/dist/cjs/dom/ui/scroll-container.cjs +2 -0
  36. package/dist/cjs/dom/ui/traverse-and-scramble.cjs +2 -0
  37. package/dist/cjs/lib/arrays/index.cjs +121 -13
  38. package/dist/cjs/lib/arrays/item-position.cjs +2 -0
  39. package/dist/cjs/lib/arrays/join.cjs +10 -2
  40. package/dist/cjs/lib/arrays/shuffle.cjs +2 -0
  41. package/dist/cjs/lib/arrays/sort.cjs +11 -3
  42. package/dist/cjs/lib/arrays/split-array.cjs +2 -0
  43. package/dist/cjs/lib/arrays/unique.cjs +2 -0
  44. package/dist/cjs/lib/auth/index.cjs +35 -3
  45. package/dist/cjs/lib/auth/route-manager.cjs +2 -0
  46. package/dist/cjs/lib/checks.cjs +2 -0
  47. package/dist/cjs/lib/date/days.cjs +3 -1
  48. package/dist/cjs/lib/date/index.cjs +190 -7
  49. package/dist/cjs/lib/date/months.cjs +3 -1
  50. package/dist/cjs/lib/date/time.cjs +14 -2
  51. package/dist/cjs/lib/form/form-data.cjs +2 -0
  52. package/dist/cjs/lib/form/index.cjs +104 -5
  53. package/dist/cjs/lib/form/sanitize.cjs +2 -0
  54. package/dist/cjs/lib/functions/callback.cjs +2 -0
  55. package/dist/cjs/lib/functions/debounce.cjs +2 -0
  56. package/dist/cjs/lib/functions/env.cjs +2 -0
  57. package/dist/cjs/lib/functions/functional.cjs +2 -0
  58. package/dist/cjs/lib/functions/index.cjs +124 -11
  59. package/dist/cjs/lib/functions/throttle.cjs +2 -0
  60. package/dist/cjs/lib/functions/timeout.cjs +2 -0
  61. package/dist/cjs/lib/hash.cjs +2 -0
  62. package/dist/cjs/lib/index.cjs +1160 -29
  63. package/dist/cjs/lib/numbers/index.cjs +17 -4
  64. package/dist/cjs/lib/numbers/math.cjs +2 -0
  65. package/dist/cjs/lib/objects/camelcase-keys.cjs +45 -4
  66. package/dist/cjs/lib/objects/empty.cjs +2 -0
  67. package/dist/cjs/lib/objects/equal.cjs +2 -0
  68. package/dist/cjs/lib/objects/extend.cjs +117 -6
  69. package/dist/cjs/lib/objects/flatten.cjs +11 -3
  70. package/dist/cjs/lib/objects/index.cjs +360 -27
  71. package/dist/cjs/lib/objects/json.cjs +2 -0
  72. package/dist/cjs/lib/objects/loop.cjs +2 -0
  73. package/dist/cjs/lib/objects/mix/mix.cjs +5 -3
  74. package/dist/cjs/lib/objects/nested-property.cjs +2 -0
  75. package/dist/cjs/lib/objects/normalize-object.cjs +78 -4
  76. package/dist/cjs/lib/objects/omit-empty.cjs +2 -0
  77. package/dist/cjs/lib/objects/size.cjs +2 -0
  78. package/dist/cjs/lib/objects/split.cjs +2 -0
  79. package/dist/cjs/lib/promises/index.cjs +51 -3
  80. package/dist/cjs/lib/promises/reject.cjs +19 -2
  81. package/dist/cjs/lib/sse.cjs +29 -4
  82. package/dist/cjs/lib/strings/convert-case/convert-case.cjs +2 -0
  83. package/dist/cjs/lib/strings/index.cjs +179 -11
  84. package/dist/cjs/lib/strings/markdown.cjs +3 -1
  85. package/dist/cjs/lib/strings/name.cjs +2 -0
  86. package/dist/cjs/lib/strings/pluralize.cjs +3 -1
  87. package/dist/cjs/lib/strings/query-string.cjs +2 -0
  88. package/dist/cjs/lib/style/index.cjs +31 -2
  89. package/dist/cjs/lib/symbols/index.cjs +22 -3
  90. package/dist/cjs/lib/symbols/symbols.cjs +2 -0
  91. package/dist/cjs/node/context.cjs +0 -0
  92. package/dist/cjs/node/dirname.cjs +4 -2
  93. package/dist/cjs/node/file-cache.cjs +45 -3
  94. package/dist/cjs/node/file.cjs +4 -2
  95. package/dist/cjs/node/hash.cjs +3 -1
  96. package/dist/cjs/node/index.cjs +278 -15
  97. package/dist/cjs/node/pkce.cjs +20 -8
  98. package/dist/cjs/node/random-string.cjs +3 -1
  99. package/dist/cjs/node/sanitize.cjs +27 -3
  100. package/dist/cjs/node/uuid.cjs +2 -0
  101. package/dist/esm/node/context.js +0 -0
  102. package/dist/esm/node/file-cache.js +1 -1
  103. package/dist/esm/node/pkce.js +3 -2
  104. package/dist/types/node/context.d.cts +2 -0
  105. package/dist/types/node/index.d.cts +1 -1
  106. package/dist/types/node/pkce.d.cts +7 -1
  107. package/package.json +5 -2
  108. package/CHANGELOG.md +0 -231
  109. package/eslint.config.js +0 -2
  110. package/src/dom/accessibility.js +0 -58
  111. package/src/dom/actions/index.js +0 -3
  112. package/src/dom/actions/masonry.js +0 -43
  113. package/src/dom/actions/prefer-horizontal-scroll.js +0 -121
  114. package/src/dom/actions/sticky.js +0 -85
  115. package/src/dom/bounding-box.js +0 -82
  116. package/src/dom/clipboard.js +0 -14
  117. package/src/dom/cookie.js +0 -32
  118. package/src/dom/css-vars.js +0 -19
  119. package/src/dom/events.js +0 -71
  120. package/src/dom/focusable.js +0 -165
  121. package/src/dom/font-size.js +0 -40
  122. package/src/dom/get-element.js +0 -176
  123. package/src/dom/hash.js +0 -9
  124. package/src/dom/index.js +0 -23
  125. package/src/dom/keyboard.js +0 -44
  126. package/src/dom/local-store.js +0 -66
  127. package/src/dom/media.js +0 -30
  128. package/src/dom/observers/index.js +0 -4
  129. package/src/dom/observers/intersection-observer.js +0 -43
  130. package/src/dom/observers/mutation-observer.js +0 -51
  131. package/src/dom/observers/observer.js +0 -18
  132. package/src/dom/observers/resize-observer.js +0 -66
  133. package/src/dom/observers/scroll-observer.js +0 -146
  134. package/src/dom/pkce.js +0 -34
  135. package/src/dom/query-params.js +0 -14
  136. package/src/dom/random-string.js +0 -18
  137. package/src/dom/random-string.test.js +0 -13
  138. package/src/dom/sanitize.js +0 -16
  139. package/src/dom/session-store.js +0 -29
  140. package/src/dom/spam-prevention.js +0 -40
  141. package/src/dom/trap-focus.js +0 -70
  142. package/src/dom/ui/aria-current.js +0 -20
  143. package/src/dom/ui/inconsistent-button-fix.js +0 -20
  144. package/src/dom/ui/index.js +0 -4
  145. package/src/dom/ui/scroll-container.js +0 -25
  146. package/src/dom/ui/traverse-and-scramble.js +0 -61
  147. package/src/lib/arrays/index.js +0 -6
  148. package/src/lib/arrays/item-position.js +0 -23
  149. package/src/lib/arrays/join.js +0 -20
  150. package/src/lib/arrays/shuffle.js +0 -21
  151. package/src/lib/arrays/sort.js +0 -88
  152. package/src/lib/arrays/sort.spec.js +0 -123
  153. package/src/lib/arrays/split-array.js +0 -15
  154. package/src/lib/arrays/unique.js +0 -3
  155. package/src/lib/auth/index.js +0 -1
  156. package/src/lib/auth/route-manager.js +0 -45
  157. package/src/lib/checks.js +0 -57
  158. package/src/lib/date/days.js +0 -9
  159. package/src/lib/date/index.js +0 -3
  160. package/src/lib/date/months.js +0 -74
  161. package/src/lib/date/time.js +0 -83
  162. package/src/lib/form/form-data.js +0 -73
  163. package/src/lib/form/index.js +0 -2
  164. package/src/lib/form/sanitize.js +0 -80
  165. package/src/lib/form/sanitize.spec.js +0 -126
  166. package/src/lib/functions/callback.js +0 -8
  167. package/src/lib/functions/debounce.js +0 -18
  168. package/src/lib/functions/env.js +0 -5
  169. package/src/lib/functions/functional.js +0 -113
  170. package/src/lib/functions/functional.test.js +0 -196
  171. package/src/lib/functions/index.js +0 -5
  172. package/src/lib/functions/throttle.js +0 -11
  173. package/src/lib/functions/timeout.js +0 -15
  174. package/src/lib/hash.js +0 -18
  175. package/src/lib/hash.spec.js +0 -163
  176. package/src/lib/index.js +0 -14
  177. package/src/lib/numbers/index.js +0 -12
  178. package/src/lib/numbers/math.js +0 -9
  179. package/src/lib/numbers/split-unit.test.js +0 -45
  180. package/src/lib/objects/camelcase-keys.js +0 -17
  181. package/src/lib/objects/camelcase-keys.test.js +0 -72
  182. package/src/lib/objects/empty.js +0 -10
  183. package/src/lib/objects/equal.js +0 -9
  184. package/src/lib/objects/extend.js +0 -16
  185. package/src/lib/objects/extend.test.js +0 -35
  186. package/src/lib/objects/flatten.js +0 -19
  187. package/src/lib/objects/index.js +0 -13
  188. package/src/lib/objects/json.js +0 -7
  189. package/src/lib/objects/loop.js +0 -11
  190. package/src/lib/objects/loop.test.js +0 -31
  191. package/src/lib/objects/mix/mix.js +0 -191
  192. package/src/lib/objects/mix/mix.md +0 -78
  193. package/src/lib/objects/mix/mix.test.js +0 -445
  194. package/src/lib/objects/nested-property.js +0 -41
  195. package/src/lib/objects/normalize-object.js +0 -10
  196. package/src/lib/objects/omit-empty.js +0 -23
  197. package/src/lib/objects/omit-empty.test.js +0 -85
  198. package/src/lib/objects/size.js +0 -41
  199. package/src/lib/objects/split.js +0 -19
  200. package/src/lib/promises/index.js +0 -1
  201. package/src/lib/promises/reject.js +0 -17
  202. package/src/lib/sse.js +0 -61
  203. package/src/lib/strings/convert-case/convert-case.js +0 -86
  204. package/src/lib/strings/convert-case/convert-case.md +0 -44
  205. package/src/lib/strings/convert-case/convert-case.test.js +0 -50
  206. package/src/lib/strings/index.js +0 -5
  207. package/src/lib/strings/markdown.js +0 -71
  208. package/src/lib/strings/name.js +0 -24
  209. package/src/lib/strings/name.test.js +0 -67
  210. package/src/lib/strings/pluralize.js +0 -2
  211. package/src/lib/strings/query-string.js +0 -18
  212. package/src/lib/style/index.js +0 -13
  213. package/src/lib/symbols/index.js +0 -1
  214. package/src/lib/symbols/symbols.js +0 -9
  215. package/src/node/dirname.js +0 -17
  216. package/src/node/file-cache.js +0 -184
  217. package/src/node/file.js +0 -13
  218. package/src/node/hash.js +0 -5
  219. package/src/node/index.js +0 -7
  220. package/src/node/pkce.js +0 -33
  221. package/src/node/random-string.js +0 -10
  222. package/src/node/random-string.test.js +0 -15
  223. package/src/node/sanitize.js +0 -13
  224. package/src/node/sanitize.spec.js +0 -142
  225. package/src/node/uuid.js +0 -5
  226. package/tsconfig.json +0 -23
  227. package/tsup.config.js +0 -38
  228. package/tsup.config.mjs +0 -45
@@ -25,13 +25,30 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
25
  mod
26
26
  ));
27
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/lib/promises/reject.js
28
30
  var reject_exports = {};
29
31
  __export(reject_exports, {
30
32
  reject: () => reject
31
33
  });
32
34
  module.exports = __toCommonJS(reject_exports);
33
35
  var import_statuses = __toESM(require("statuses"), 1);
34
- var import_omit_empty = require("../objects/omit-empty.js");
36
+
37
+ // src/lib/objects/omit-empty.js
38
+ function omitEmpty(obj, shallow = false) {
39
+ if (typeof obj !== "object" || obj === null) return obj;
40
+ if (obj instanceof Date) return obj;
41
+ const result = Array.isArray(obj) ? [] : {};
42
+ for (const [key, value] of Object.entries(obj)) {
43
+ if (value === null || value === void 0 || value === "" || typeof value === "object" && !(value instanceof Date) && Object.keys(value).length === 0) {
44
+ continue;
45
+ }
46
+ result[key] = shallow ? value : omitEmpty(value);
47
+ }
48
+ return result;
49
+ }
50
+
51
+ // src/lib/promises/reject.js
35
52
  function reject(props, { includeStack = true } = {}) {
36
53
  const { status, statusText, body, message } = props;
37
54
  const e = new Error();
@@ -42,7 +59,7 @@ function reject(props, { includeStack = true } = {}) {
42
59
  message,
43
60
  stack: includeStack && e.stack
44
61
  };
45
- return Promise.reject((0, import_omit_empty.omitEmpty)(err));
62
+ return Promise.reject(omitEmpty(err));
46
63
  }
47
64
  // Annotate the CommonJS export names for ESM import in node:
48
65
  0 && (module.exports = {
@@ -15,14 +15,39 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/lib/sse.js
18
20
  var sse_exports = {};
19
21
  __export(sse_exports, {
20
22
  createSSE: () => createSSE,
21
23
  parseSSE: () => parseSSE
22
24
  });
23
25
  module.exports = __toCommonJS(sse_exports);
24
- var import_json = require("./objects/json.js");
25
- var import_omit_empty = require("./objects/omit-empty.js");
26
+
27
+ // src/lib/objects/json.js
28
+ function parseJSON(value, defaultValue = {}) {
29
+ try {
30
+ return JSON.parse(value);
31
+ } catch (e) {
32
+ return defaultValue;
33
+ }
34
+ }
35
+
36
+ // src/lib/objects/omit-empty.js
37
+ function omitEmpty(obj, shallow = false) {
38
+ if (typeof obj !== "object" || obj === null) return obj;
39
+ if (obj instanceof Date) return obj;
40
+ const result = Array.isArray(obj) ? [] : {};
41
+ for (const [key, value] of Object.entries(obj)) {
42
+ if (value === null || value === void 0 || value === "" || typeof value === "object" && !(value instanceof Date) && Object.keys(value).length === 0) {
43
+ continue;
44
+ }
45
+ result[key] = shallow ? value : omitEmpty(value);
46
+ }
47
+ return result;
48
+ }
49
+
50
+ // src/lib/sse.js
26
51
  function createSSE({ event, data, id, retry }) {
27
52
  const eventString = event ? `event: ${event}
28
53
  ` : "";
@@ -48,7 +73,7 @@ function parseSSE(message) {
48
73
  for (const line of lines) {
49
74
  if (line.startsWith("data:")) {
50
75
  const data = line.slice(5).trim();
51
- result.data = (0, import_json.parseJSON)(data);
76
+ result.data = parseJSON(data);
52
77
  continue;
53
78
  }
54
79
  if (line.startsWith("event:")) {
@@ -64,7 +89,7 @@ function parseSSE(message) {
64
89
  continue;
65
90
  }
66
91
  }
67
- const ret = (0, import_omit_empty.omitEmpty)(result);
92
+ const ret = omitEmpty(result);
68
93
  return ret.data ? ret : null;
69
94
  }
70
95
  // Annotate the CommonJS export names for ESM import in node:
@@ -15,6 +15,8 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/lib/strings/convert-case/convert-case.js
18
20
  var convert_case_exports = {};
19
21
  __export(convert_case_exports, {
20
22
  toCamel: () => toCamel,
@@ -1,7 +1,13 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
4
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
5
11
  var __copyProps = (to, from, except, desc) => {
6
12
  if (from && typeof from === "object" || typeof from === "function") {
7
13
  for (let key of __getOwnPropNames(from))
@@ -10,20 +16,182 @@ var __copyProps = (to, from, except, desc) => {
10
16
  }
11
17
  return to;
12
18
  };
13
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
14
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/lib/strings/index.js
15
30
  var strings_exports = {};
31
+ __export(strings_exports, {
32
+ markdown: () => markdown,
33
+ parseFullName: () => parseFullName,
34
+ plural: () => plural,
35
+ pluralize: () => pluralize,
36
+ stripNumbers: () => stripNumbers,
37
+ toCamel: () => toCamel,
38
+ toKebab: () => toKebab,
39
+ toLower: () => toLower,
40
+ toPascal: () => toPascal,
41
+ toQueryString: () => toQueryString,
42
+ toSentence: () => toSentence,
43
+ toSlug: () => toSlug,
44
+ toTitle: () => toTitle,
45
+ toUpper: () => toUpper,
46
+ treatMarkdownWhitespace: () => treatMarkdownWhitespace
47
+ });
16
48
  module.exports = __toCommonJS(strings_exports);
17
- __reExport(strings_exports, require("./convert-case/convert-case.js"), module.exports);
18
- __reExport(strings_exports, require("./markdown.js"), module.exports);
19
- __reExport(strings_exports, require("./name.js"), module.exports);
20
- __reExport(strings_exports, require("./pluralize.js"), module.exports);
21
- __reExport(strings_exports, require("./query-string.js"), module.exports);
49
+
50
+ // src/lib/strings/convert-case/convert-case.js
51
+ function toKebab(string) {
52
+ if (!string) return "";
53
+ return string.split("").map((letter, index) => {
54
+ const previousLetter = string[index - 1] || "";
55
+ const currentLetter = letter;
56
+ if (isDigit(currentLetter) && !isDigit(previousLetter)) {
57
+ return `-${currentLetter}`;
58
+ }
59
+ if (!isCaps(currentLetter)) return currentLetter;
60
+ if (previousLetter === "") {
61
+ return `${currentLetter.toLowerCase()}`;
62
+ }
63
+ if (isCaps(previousLetter)) {
64
+ return `${currentLetter.toLowerCase()}`;
65
+ }
66
+ return `-${currentLetter.toLowerCase()}`;
67
+ }).join("").trim().replace(/[-_\s]+/g, "-");
68
+ }
69
+ function toCamel(string) {
70
+ return toKebab(string).split("-").map((word, index) => {
71
+ if (index === 0) return word;
72
+ return word.slice(0, 1).toUpperCase() + word.slice(1).toLowerCase();
73
+ }).join("");
74
+ }
75
+ function toPascal(string) {
76
+ const camel = toCamel(string);
77
+ return camel.slice(0, 1).toUpperCase() + camel.slice(1);
78
+ }
79
+ function toTitle(string) {
80
+ return toKebab(string).split("-").map((word) => {
81
+ return word.slice(0, 1).toUpperCase() + word.slice(1);
82
+ }).join(" ");
83
+ }
84
+ function toSlug(string) {
85
+ return toKebab(string);
86
+ }
87
+ function toSentence(string) {
88
+ const interim = toKebab(string).replace(/-/g, " ");
89
+ return interim.slice(0, 1).toUpperCase() + interim.slice(1);
90
+ }
91
+ function toUpper(string) {
92
+ const interim = toKebab(string).replace(/-/g, " ");
93
+ return interim.toUpperCase();
94
+ }
95
+ function toLower(string) {
96
+ const interim = toKebab(string).replace(/-/g, " ");
97
+ return interim.toLowerCase();
98
+ }
99
+ function isCaps(char) {
100
+ return /\p{Lu}/u.test(char);
101
+ }
102
+ function isDigit(char) {
103
+ return /[0-9]/.test(char);
104
+ }
105
+
106
+ // src/lib/strings/markdown.js
107
+ var import_markdown_it = __toESM(require("markdown-it"), 1);
108
+ var import_markdown_it_anchor = __toESM(require("markdown-it-anchor"), 1);
109
+ var md = (0, import_markdown_it.default)({
110
+ html: true,
111
+ linkify: true,
112
+ typographer: true
113
+ });
114
+ md.use(import_markdown_it_anchor.default, {
115
+ permalink: false,
116
+ slugify: (s) => s.toLowerCase().replace(/\s+/g, "-").replace(/[^\w-]/g, "")
117
+ });
118
+ function markdown(content, options = {}) {
119
+ const defaultOptions = { inline: false };
120
+ const opts = { ...defaultOptions, ...options };
121
+ const { content: treated } = treatMarkdownWhitespace(content, opts);
122
+ if (opts.inline) return md.renderInline(treated);
123
+ return md.render(treated);
124
+ }
125
+ function treatMarkdownWhitespace(content, { inline } = {}) {
126
+ if (!content) return { content: "", inline };
127
+ const lines = content.split("\n");
128
+ if (lines[0] !== "" && inline) return { content, inline: true };
129
+ const firstLineWithLeadingSpacesIndex = lines.findIndex(
130
+ (line) => line.match(/^\s+/)
131
+ );
132
+ const firstLineWithLeadingSpaces = lines[firstLineWithLeadingSpacesIndex];
133
+ const indentation = firstLineWithLeadingSpaces?.match(/^\s+/)?.[0]?.length ?? 0;
134
+ const retContent = lines.map((line, index) => {
135
+ if (index < firstLineWithLeadingSpacesIndex) return line + "\n";
136
+ return line.slice(indentation) + "\n";
137
+ }).join("");
138
+ return {
139
+ content: retContent,
140
+ inline
141
+ };
142
+ }
143
+
144
+ // src/lib/strings/name.js
145
+ function parseFullName(name) {
146
+ const parts = name.trim().split(/\s+/);
147
+ if (parts.length === 1) {
148
+ return { firstName: parts[0], middleName: "", lastName: "" };
149
+ }
150
+ if (parts.length === 2) {
151
+ return { firstName: parts[0], middleName: "", lastName: parts[1] };
152
+ }
153
+ if (parts.length === 3) {
154
+ const firstName2 = parts.slice(0, 2).join(" ");
155
+ const lastName2 = parts[2];
156
+ return { firstName: firstName2, middleName: "", lastName: lastName2 };
157
+ }
158
+ const firstName = parts.slice(0, 2).join(" ");
159
+ const lastName = parts[parts.length - 1];
160
+ const middleName = parts.slice(2, -1).join(" ");
161
+ return { firstName, middleName, lastName };
162
+ }
163
+
164
+ // src/lib/strings/pluralize.js
165
+ var import_pluralize = __toESM(require("pluralize"), 1);
166
+ var pluralize = import_pluralize.default;
167
+
168
+ // src/lib/strings/query-string.js
169
+ function toQueryString(object) {
170
+ const searchParams = new URLSearchParams(object);
171
+ return searchParams.toString();
172
+ }
173
+ function plural(count, noun, suffix = "s") {
174
+ console.warn("plural is deprecated. Use pluralize instead");
175
+ return `${count} ${noun}${count !== 1 ? suffix : ""}`;
176
+ }
177
+ function stripNumbers(string) {
178
+ return string.replace(/\d*/, "");
179
+ }
22
180
  // Annotate the CommonJS export names for ESM import in node:
23
181
  0 && (module.exports = {
24
- ...require("./convert-case/convert-case.js"),
25
- ...require("./markdown.js"),
26
- ...require("./name.js"),
27
- ...require("./pluralize.js"),
28
- ...require("./query-string.js")
182
+ markdown,
183
+ parseFullName,
184
+ plural,
185
+ pluralize,
186
+ stripNumbers,
187
+ toCamel,
188
+ toKebab,
189
+ toLower,
190
+ toPascal,
191
+ toQueryString,
192
+ toSentence,
193
+ toSlug,
194
+ toTitle,
195
+ toUpper,
196
+ treatMarkdownWhitespace
29
197
  });
@@ -25,6 +25,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
25
  mod
26
26
  ));
27
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/lib/strings/markdown.js
28
30
  var markdown_exports = {};
29
31
  __export(markdown_exports, {
30
32
  markdown: () => markdown,
@@ -33,7 +35,7 @@ __export(markdown_exports, {
33
35
  module.exports = __toCommonJS(markdown_exports);
34
36
  var import_markdown_it = __toESM(require("markdown-it"), 1);
35
37
  var import_markdown_it_anchor = __toESM(require("markdown-it-anchor"), 1);
36
- const md = (0, import_markdown_it.default)({
38
+ var md = (0, import_markdown_it.default)({
37
39
  html: true,
38
40
  linkify: true,
39
41
  typographer: true
@@ -15,6 +15,8 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/lib/strings/name.js
18
20
  var name_exports = {};
19
21
  __export(name_exports, {
20
22
  parseFullName: () => parseFullName
@@ -25,13 +25,15 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
25
  mod
26
26
  ));
27
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/lib/strings/pluralize.js
28
30
  var pluralize_exports = {};
29
31
  __export(pluralize_exports, {
30
32
  pluralize: () => pluralize
31
33
  });
32
34
  module.exports = __toCommonJS(pluralize_exports);
33
35
  var import_pluralize = __toESM(require("pluralize"), 1);
34
- const pluralize = import_pluralize.default;
36
+ var pluralize = import_pluralize.default;
35
37
  // Annotate the CommonJS export names for ESM import in node:
36
38
  0 && (module.exports = {
37
39
  pluralize
@@ -15,6 +15,8 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/lib/strings/query-string.js
18
20
  var query_string_exports = {};
19
21
  __export(query_string_exports, {
20
22
  plural: () => plural,
@@ -15,18 +15,47 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/lib/style/index.js
18
20
  var style_exports = {};
19
21
  __export(style_exports, {
20
22
  toStyleString: () => toStyleString
21
23
  });
22
24
  module.exports = __toCommonJS(style_exports);
23
- var import_convert_case = require("../strings/convert-case/convert-case.js");
25
+
26
+ // src/lib/strings/convert-case/convert-case.js
27
+ function toKebab(string) {
28
+ if (!string) return "";
29
+ return string.split("").map((letter, index) => {
30
+ const previousLetter = string[index - 1] || "";
31
+ const currentLetter = letter;
32
+ if (isDigit(currentLetter) && !isDigit(previousLetter)) {
33
+ return `-${currentLetter}`;
34
+ }
35
+ if (!isCaps(currentLetter)) return currentLetter;
36
+ if (previousLetter === "") {
37
+ return `${currentLetter.toLowerCase()}`;
38
+ }
39
+ if (isCaps(previousLetter)) {
40
+ return `${currentLetter.toLowerCase()}`;
41
+ }
42
+ return `-${currentLetter.toLowerCase()}`;
43
+ }).join("").trim().replace(/[-_\s]+/g, "-");
44
+ }
45
+ function isCaps(char) {
46
+ return /\p{Lu}/u.test(char);
47
+ }
48
+ function isDigit(char) {
49
+ return /[0-9]/.test(char);
50
+ }
51
+
52
+ // src/lib/style/index.js
24
53
  function toStyleString(style) {
25
54
  if (!style) return null;
26
55
  if (typeof style === "string") return style;
27
56
  return Object.entries(style).map(([k, v]) => {
28
57
  if (k.startsWith("--")) return `${k}:${v}`;
29
- else return `${(0, import_convert_case.toKebab)(k)}:${v}`;
58
+ else return `${toKebab(k)}:${v}`;
30
59
  }).join("; ").concat(";");
31
60
  }
32
61
  // Annotate the CommonJS export names for ESM import in node:
@@ -2,6 +2,10 @@ var __defProp = Object.defineProperty;
2
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
5
9
  var __copyProps = (to, from, except, desc) => {
6
10
  if (from && typeof from === "object" || typeof from === "function") {
7
11
  for (let key of __getOwnPropNames(from))
@@ -10,12 +14,27 @@ var __copyProps = (to, from, except, desc) => {
10
14
  }
11
15
  return to;
12
16
  };
13
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/lib/symbols/index.js
15
20
  var symbols_exports = {};
21
+ __export(symbols_exports, {
22
+ getSymbol: () => getSymbol,
23
+ getSymbolValue: () => getSymbolValue
24
+ });
16
25
  module.exports = __toCommonJS(symbols_exports);
17
- __reExport(symbols_exports, require("./symbols.js"), module.exports);
26
+
27
+ // src/lib/symbols/symbols.js
28
+ function getSymbol(object, description) {
29
+ return Object.getOwnPropertySymbols(object).find(
30
+ (s) => s.description === description
31
+ );
32
+ }
33
+ function getSymbolValue(object, description) {
34
+ return object[getSymbol(object, description)];
35
+ }
18
36
  // Annotate the CommonJS export names for ESM import in node:
19
37
  0 && (module.exports = {
20
- ...require("./symbols.js")
38
+ getSymbol,
39
+ getSymbolValue
21
40
  });
@@ -15,6 +15,8 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/lib/symbols/symbols.js
18
20
  var symbols_exports = {};
19
21
  __export(symbols_exports, {
20
22
  getSymbol: () => getSymbol,
File without changes
@@ -25,14 +25,16 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
25
  mod
26
26
  ));
27
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/node/dirname.js
28
30
  var dirname_exports = {};
29
31
  __export(dirname_exports, {
30
32
  __dirname: () => __dirname,
31
33
  dirname: () => dirname
32
34
  });
33
35
  module.exports = __toCommonJS(dirname_exports);
34
- var import_node_path = __toESM(require("node:path"), 1);
35
- var import_node_url = require("node:url");
36
+ var import_node_path = __toESM(require("path"), 1);
37
+ var import_node_url = require("url");
36
38
  function __dirname(url) {
37
39
  if (!url) throw Error("Please provide 'import.meta.url' to dirname");
38
40
  return import_node_path.default.dirname((0, import_node_url.fileURLToPath)(url));
@@ -25,6 +25,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
25
  mod
26
26
  ));
27
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/node/file-cache.js
28
30
  var file_cache_exports = {};
29
31
  __export(file_cache_exports, {
30
32
  createCache: () => createCache,
@@ -36,8 +38,48 @@ __export(file_cache_exports, {
36
38
  module.exports = __toCommonJS(file_cache_exports);
37
39
  var import_promises = __toESM(require("fs/promises"), 1);
38
40
  var import_glob = require("glob");
39
- var import_node_path = __toESM(require("node:path"), 1);
40
- var import_arrays = require("../lib/arrays/index.js");
41
+ var import_node_path = __toESM(require("path"), 1);
42
+
43
+ // src/lib/objects/nested-property.js
44
+ function getNestedValue(object, path2) {
45
+ return path2.split(".").reduce((acc, part) => acc?.[part], object);
46
+ }
47
+
48
+ // src/lib/arrays/sort.js
49
+ function sort(array, { props = null, reverse = false } = {}) {
50
+ const clone = array.slice();
51
+ if (props === null) {
52
+ return clone.sort((a, b) => {
53
+ const comparison = compareValues(a, b);
54
+ return reverse ? -comparison : comparison;
55
+ });
56
+ }
57
+ const properties = Array.isArray(props) ? props : [props];
58
+ return clone.sort((a, b) => {
59
+ for (const property of properties) {
60
+ const aValue = getNestedValue(a, property);
61
+ const bValue = getNestedValue(b, property);
62
+ if (aValue === bValue) continue;
63
+ if (aValue == null) return 1;
64
+ if (bValue == null) return -1;
65
+ const comparison = compareValues(aValue, bValue);
66
+ return reverse ? -comparison : comparison;
67
+ }
68
+ return 0;
69
+ });
70
+ }
71
+ function compareValues(a, b) {
72
+ if (typeof a === "number" && typeof b === "number") return a - b;
73
+ if (typeof a === "string" && typeof b === "string") return a.localeCompare(b);
74
+ const aDate = new Date(a);
75
+ const bDate = new Date(b);
76
+ const aTime = aDate.getTime();
77
+ const bTime = bDate.getTime();
78
+ if (!isNaN(aTime) && !isNaN(bTime)) return aTime - bTime;
79
+ return String(a).localeCompare(String(b));
80
+ }
81
+
82
+ // src/node/file-cache.js
41
83
  function resolveDirPath(dirPath) {
42
84
  return import_node_path.default.isAbsolute(dirPath) ? dirPath : import_node_path.default.join(process.cwd(), dirPath);
43
85
  }
@@ -136,7 +178,7 @@ async function getLastModifiedTime(globPath) {
136
178
  }
137
179
  const stats = await Promise.all(files.map((file) => import_promises.default.stat(file)));
138
180
  const timestamps = stats.map((stat) => Number(stat.mtimeMs));
139
- const sorted = (0, import_arrays.sort)(timestamps, { props: "mtimeMs", reverse: true });
181
+ const sorted = sort(timestamps, { props: "mtimeMs", reverse: true });
140
182
  return sorted[0] || 0;
141
183
  }
142
184
  async function getLatestModifiedTime(globPath) {
@@ -25,14 +25,16 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
25
  mod
26
26
  ));
27
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/node/file.js
28
30
  var file_exports = {};
29
31
  __export(file_exports, {
30
32
  copyFile: () => copyFile,
31
33
  mkdir: () => mkdir
32
34
  });
33
35
  module.exports = __toCommonJS(file_exports);
34
- var import_promises = __toESM(require("node:fs/promises"), 1);
35
- var import_node_path = __toESM(require("node:path"), 1);
36
+ var import_promises = __toESM(require("fs/promises"), 1);
37
+ var import_node_path = __toESM(require("path"), 1);
36
38
  async function mkdir(path2) {
37
39
  return import_promises.default.mkdir(path2, { recursive: true });
38
40
  }
@@ -25,12 +25,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
25
  mod
26
26
  ));
27
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/node/hash.js
28
30
  var hash_exports = {};
29
31
  __export(hash_exports, {
30
32
  sha256Hash: () => sha256Hash
31
33
  });
32
34
  module.exports = __toCommonJS(hash_exports);
33
- var import_node_crypto = __toESM(require("node:crypto"), 1);
35
+ var import_node_crypto = __toESM(require("crypto"), 1);
34
36
  function sha256Hash(string) {
35
37
  return import_node_crypto.default.createHash("sha256").update(string).digest("hex");
36
38
  }