@react-fabric/utilities 1.0.0-beta.9 → 1.0.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 (168) hide show
  1. package/dist/cjs/css/boundingBox.js +72 -0
  2. package/dist/cjs/css/cn.js +39 -0
  3. package/dist/cjs/css/imageColorset.js +96 -0
  4. package/dist/cjs/data/countries.js +98 -0
  5. package/dist/cjs/{_fileType.js → data/fileType.js} +37 -19
  6. package/dist/cjs/data/format.js +136 -0
  7. package/dist/cjs/helpers/debounce.js +63 -0
  8. package/dist/cjs/{useLogger.js → helpers/getLogger.js} +96 -96
  9. package/dist/cjs/helpers/lonlat.js +99 -0
  10. package/dist/cjs/index.js +99 -76
  11. package/dist/cjs/lists/dedupe.js +54 -0
  12. package/dist/cjs/lists/flatten.js +66 -0
  13. package/dist/cjs/{_getByPath.js → lists/getByPath.js} +58 -37
  14. package/dist/cjs/lists/groupBy.js +49 -0
  15. package/dist/cjs/matchers/compare.js +70 -0
  16. package/dist/cjs/matchers/isEmpty.js +34 -0
  17. package/dist/cjs/matchers/isEqual.js +82 -0
  18. package/dist/cjs/matchers/nullChecks.js +61 -0
  19. package/dist/cjs/matchers/typeChecks.js +127 -0
  20. package/dist/cjs/strings/ascii.js +105 -0
  21. package/dist/cjs/strings/hash.js +75 -0
  22. package/dist/cjs/strings/interpolate.js +47 -0
  23. package/dist/cjs/strings/matchString.js +54 -0
  24. package/dist/cjs/strings/template.js +48 -0
  25. package/dist/cjs/strings/tokenize.js +83 -0
  26. package/dist/cjs/utils/mergeRefs.js +56 -0
  27. package/dist/esm/css/boundingBox.js +71 -0
  28. package/dist/esm/css/cn.js +39 -0
  29. package/dist/esm/css/imageColorset.js +96 -0
  30. package/dist/esm/data/countries.js +98 -0
  31. package/dist/esm/{_fileType.js → data/fileType.js} +37 -19
  32. package/dist/esm/data/format.js +138 -0
  33. package/dist/esm/helpers/debounce.js +63 -0
  34. package/dist/esm/{useLogger.js → helpers/getLogger.js} +96 -96
  35. package/dist/esm/helpers/lonlat.js +97 -0
  36. package/dist/esm/index.js +54 -36
  37. package/dist/esm/lists/dedupe.js +54 -0
  38. package/dist/esm/lists/flatten.js +65 -0
  39. package/dist/esm/{_getByPath.js → lists/getByPath.js} +50 -29
  40. package/dist/esm/lists/groupBy.js +49 -0
  41. package/dist/esm/matchers/compare.js +70 -0
  42. package/dist/esm/matchers/isEmpty.js +34 -0
  43. package/dist/esm/matchers/isEqual.js +82 -0
  44. package/dist/esm/matchers/nullChecks.js +58 -0
  45. package/dist/esm/matchers/typeChecks.js +119 -0
  46. package/dist/esm/strings/ascii.js +105 -0
  47. package/dist/esm/strings/hash.js +73 -0
  48. package/dist/esm/strings/interpolate.js +47 -0
  49. package/dist/esm/strings/matchString.js +54 -0
  50. package/dist/esm/strings/template.js +48 -0
  51. package/dist/esm/strings/tokenize.js +82 -0
  52. package/dist/esm/utils/mergeRefs.js +56 -0
  53. package/dist/types/css/boundingBox.d.ts +46 -0
  54. package/dist/types/css/cn.d.ts +26 -0
  55. package/dist/types/css/imageColorset.d.ts +37 -0
  56. package/dist/types/data/countries.d.ts +136 -0
  57. package/dist/types/{_fileType.d.ts → data/fileType.d.ts} +41 -1
  58. package/dist/types/data/format.d.ts +122 -0
  59. package/dist/types/helpers/debounce.d.ts +38 -0
  60. package/dist/types/helpers/getLogger.d.ts +49 -0
  61. package/dist/types/helpers/lonlat.d.ts +48 -0
  62. package/dist/types/index.d.ts +54 -20
  63. package/dist/types/lists/dedupe.d.ts +36 -0
  64. package/dist/types/lists/flatten.d.ts +47 -0
  65. package/dist/types/lists/getByPath.d.ts +45 -0
  66. package/dist/types/lists/groupBy.d.ts +36 -0
  67. package/dist/types/matchers/compare.d.ts +38 -0
  68. package/dist/types/matchers/isEmpty.d.ts +38 -0
  69. package/dist/types/matchers/isEqual.d.ts +39 -0
  70. package/dist/types/matchers/nullChecks.d.ts +43 -0
  71. package/dist/types/matchers/typeChecks.d.ts +107 -0
  72. package/dist/types/strings/ascii.d.ts +34 -0
  73. package/dist/types/strings/hash.d.ts +46 -0
  74. package/dist/types/strings/interpolate.d.ts +34 -0
  75. package/dist/types/strings/matchString.d.ts +41 -0
  76. package/dist/types/strings/template.d.ts +35 -0
  77. package/dist/types/strings/tokenize.d.ts +44 -0
  78. package/dist/types/utils/mergeRefs.d.ts +36 -0
  79. package/package.json +13 -11
  80. package/src/css/boundingBox.ts +80 -0
  81. package/src/css/cn.ts +32 -0
  82. package/src/css/imageColorset.ts +97 -0
  83. package/src/data/countries.ts +126 -0
  84. package/src/{_fileType.ts → data/fileType.ts} +72 -89
  85. package/src/data/format.ts +192 -0
  86. package/src/helpers/debounce.ts +49 -0
  87. package/src/{useLogger.ts → helpers/getLogger.ts} +52 -101
  88. package/src/helpers/lonlat.ts +124 -0
  89. package/src/index.ts +57 -37
  90. package/src/lists/dedupe.ts +46 -0
  91. package/src/lists/flatten.ts +56 -0
  92. package/src/lists/getByPath.ts +122 -0
  93. package/src/lists/groupBy.ts +47 -0
  94. package/src/matchers/compare.ts +64 -0
  95. package/src/matchers/isEmpty.ts +54 -0
  96. package/src/matchers/isEqual.ts +71 -0
  97. package/src/matchers/nullChecks.ts +55 -0
  98. package/src/matchers/typeChecks.ts +146 -0
  99. package/src/strings/ascii.ts +100 -0
  100. package/src/strings/hash.ts +68 -0
  101. package/src/strings/interpolate.ts +42 -0
  102. package/src/strings/matchString.ts +49 -0
  103. package/src/strings/template.ts +43 -0
  104. package/src/strings/tokenize.ts +77 -0
  105. package/src/utils/mergeRefs.ts +47 -0
  106. package/src/{yup.ts → utils/yup.ts} +3 -3
  107. package/dist/cjs/_ascii.js +0 -76
  108. package/dist/cjs/_boundingBox.js +0 -59
  109. package/dist/cjs/_countries.js +0 -2805
  110. package/dist/cjs/_debounce.js +0 -53
  111. package/dist/cjs/_dedupe.js +0 -63
  112. package/dist/cjs/_fetch.js +0 -128
  113. package/dist/cjs/_format.js +0 -118
  114. package/dist/cjs/_hash.js +0 -67
  115. package/dist/cjs/_interpolate.js +0 -47
  116. package/dist/cjs/_isEqual.js +0 -108
  117. package/dist/cjs/_isType.js +0 -98
  118. package/dist/cjs/_mergeRefs.js +0 -40
  119. package/dist/cjs/_tokenize.js +0 -67
  120. package/dist/cjs/getImageColorset.js +0 -70
  121. package/dist/esm/_ascii.js +0 -76
  122. package/dist/esm/_boundingBox.js +0 -58
  123. package/dist/esm/_countries.js +0 -2805
  124. package/dist/esm/_debounce.js +0 -53
  125. package/dist/esm/_dedupe.js +0 -60
  126. package/dist/esm/_fetch.js +0 -128
  127. package/dist/esm/_format.js +0 -120
  128. package/dist/esm/_hash.js +0 -65
  129. package/dist/esm/_interpolate.js +0 -46
  130. package/dist/esm/_isEqual.js +0 -106
  131. package/dist/esm/_isType.js +0 -85
  132. package/dist/esm/_mergeRefs.js +0 -40
  133. package/dist/esm/_tokenize.js +0 -66
  134. package/dist/esm/getImageColorset.js +0 -70
  135. package/dist/types/_ascii.d.ts +0 -5
  136. package/dist/types/_boundingBox.d.ts +0 -10
  137. package/dist/types/_countries.d.ts +0 -85
  138. package/dist/types/_debounce.d.ts +0 -8
  139. package/dist/types/_dedupe.d.ts +0 -4
  140. package/dist/types/_fetch.d.ts +0 -23
  141. package/dist/types/_format.d.ts +0 -27
  142. package/dist/types/_getByPath.d.ts +0 -10
  143. package/dist/types/_hash.d.ts +0 -16
  144. package/dist/types/_interpolate.d.ts +0 -6
  145. package/dist/types/_isEqual.d.ts +0 -15
  146. package/dist/types/_isType.d.ts +0 -14
  147. package/dist/types/_mergeRefs.d.ts +0 -1
  148. package/dist/types/_tokenize.d.ts +0 -8
  149. package/dist/types/getImageColorset.d.ts +0 -1
  150. package/dist/types/useLogger.d.ts +0 -25
  151. package/src/_ascii.ts +0 -93
  152. package/src/_boundingBox.ts +0 -72
  153. package/src/_countries.ts +0 -3046
  154. package/src/_debounce.ts +0 -42
  155. package/src/_dedupe.ts +0 -56
  156. package/src/_fetch.ts +0 -109
  157. package/src/_format.ts +0 -141
  158. package/src/_getByPath.ts +0 -108
  159. package/src/_hash.ts +0 -62
  160. package/src/_interpolate.ts +0 -42
  161. package/src/_isEqual.ts +0 -102
  162. package/src/_isType.ts +0 -105
  163. package/src/_mergeRefs.ts +0 -33
  164. package/src/_tokenize.ts +0 -69
  165. package/src/getImageColorset.ts +0 -81
  166. /package/dist/cjs/{yup.js → utils/yup.js} +0 -0
  167. /package/dist/esm/{yup.js → utils/yup.js} +0 -0
  168. /package/dist/types/{yup.d.ts → utils/yup.d.ts} +0 -0
@@ -1,44 +1,44 @@
1
1
  'use client';
2
2
 
3
- import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
3
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
4
4
  import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
5
5
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
6
6
 
7
- var _excluded = ["module"],
8
- _excluded2 = ["module"],
9
- _excluded3 = ["module"],
10
- _excluded4 = ["module"],
11
- _excluded5 = ["module"];
12
- /*
7
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
8
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
9
+ /**
13
10
  * React Fabric
14
- * @version: 1.0.0
15
- *
16
- *
17
- * The MIT License (MIT)
18
- * Copyright (c) 2024 Adarsh Pastakia
11
+ * @version 1.0.0
12
+ * @license MIT
13
+ * @copyright 2024 Adarsh Pastakia
19
14
  *
20
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
21
- * and associated documentation files (the "Software"), to deal in the Software without restriction,
22
- * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
23
- * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
24
- * subject to the following conditions:
15
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
16
+ * of this software and associated documentation files (the "Software"), to deal
17
+ * in the Software without restriction, including without limitation the rights
18
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19
+ * copies of the Software, and to permit persons to whom the Software is
20
+ * furnished to do so, subject to the following conditions:
25
21
  *
26
- * The above copyright notice and this permission notice shall be included in all copies or substantial
27
- * portions of the Software.
22
+ * The above copyright notice and this permission notice shall be included in all
23
+ * copies or substantial portions of the Software.
28
24
  *
29
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
30
- * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
31
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
32
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31
+ * SOFTWARE.
33
32
  */
34
- var LOG_LEVEL = /*#__PURE__*/function (LOG_LEVEL) {
35
- LOG_LEVEL[LOG_LEVEL["OFF"] = 0] = "OFF";
36
- LOG_LEVEL[LOG_LEVEL["WARNING"] = 1] = "WARNING";
37
- LOG_LEVEL[LOG_LEVEL["INFO"] = 2] = "INFO";
38
- LOG_LEVEL[LOG_LEVEL["DEBUG"] = 3] = "DEBUG";
39
- return LOG_LEVEL;
40
- }(LOG_LEVEL || {});
33
+
34
+ var LOG_LEVEL = {
35
+ WARNING: 1,
36
+ INFO: 2,
37
+ DEBUG: 3
38
+ };
39
+
41
40
  /* istanbul ignore file */
41
+
42
42
  var NODE = {
43
43
  LOG: "\x1B[38;5;144m",
44
44
  INFO: "\x1B[38;5;81m",
@@ -50,17 +50,17 @@ var NODE = {
50
50
  DURATION: "\x1B[38;5;140m",
51
51
  RESET: "\x1B[0m",
52
52
  logLevel: function logLevel() {
53
- var _global$LOG_LEVEL;
53
+ var _ref;
54
54
  return (// @ts-expect-error ignore
55
- (_global$LOG_LEVEL = global.LOG_LEVEL) !== null && _global$LOG_LEVEL !== void 0 ? _global$LOG_LEVEL : process.env.NODE_ENV !== "production" ? LOG_LEVEL.DEBUG : LOG_LEVEL.WARNING
55
+ (_ref = global.LOG_LEVEL) !== null && _ref !== void 0 ? _ref : process.env.NODE_ENV !== "production" ? LOG_LEVEL.DEBUG : LOG_LEVEL.WARNING
56
56
  );
57
57
  },
58
58
  makeLog: function makeLog(level) {
59
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
60
- process = _ref.process,
61
- module = _ref.module,
62
- duration = _ref.duration,
63
- totalTime = _ref.totalTime;
59
+ var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
60
+ process = _ref2.process,
61
+ module = _ref2.module,
62
+ duration = _ref2.duration,
63
+ totalTime = _ref2.totalTime;
64
64
  var ret = [];
65
65
  if (process) ret.push("".concat(this.PROCESS, "Process: ").concat(process).concat(this.RESET));
66
66
  if (module) ret.push("".concat(this.PROCESS, "Module: ").concat(module).concat(this.RESET));
@@ -118,17 +118,17 @@ var BROWSER = {
118
118
  PROCESS: "#87af87",
119
119
  DURATION: "#af87d7",
120
120
  logLevel: function logLevel() {
121
- var _ref2;
121
+ var _ref3;
122
122
  return (// @ts-expect-error ignore
123
- (_ref2 = typeof window !== "undefined" ? window.LOG_LEVEL : undefined) !== null && _ref2 !== void 0 ? _ref2 : process.env.NODE_ENV !== "production" ? LOG_LEVEL.DEBUG : LOG_LEVEL.WARNING
123
+ (_ref3 = typeof window !== "undefined" ? window.LOG_LEVEL : undefined) !== null && _ref3 !== void 0 ? _ref3 : process.env.NODE_ENV !== "production" ? LOG_LEVEL.DEBUG : LOG_LEVEL.WARNING
124
124
  );
125
125
  },
126
126
  makeLog: function makeLog(level, color) {
127
- var _ref3 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
128
- process = _ref3.process,
129
- module = _ref3.module,
130
- duration = _ref3.duration,
131
- totalTime = _ref3.totalTime;
127
+ var _ref4 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
128
+ process = _ref4.process,
129
+ module = _ref4.module,
130
+ duration = _ref4.duration,
131
+ totalTime = _ref4.totalTime;
132
132
  var ret = [];
133
133
  var colors = ["color:".concat(this.TIME, ";font-weight:bold;"), "color:".concat(color, ";font-weight:bold;")];
134
134
  if (module) ret.push("%cModule: ".concat(module));
@@ -189,16 +189,16 @@ var BROWSER = {
189
189
  (_console9 = console).error.apply(_console9, [logs].concat(_toConsumableArray(colors), ["\n".concat(msg, "\n")], rest));
190
190
  },
191
191
  warning: function warning(msg, opts) {
192
- var _console10;
192
+ var _console0;
193
193
  if (+this.logLevel() < LOG_LEVEL.WARNING) return;
194
194
  var _this$makeLog9 = this.makeLog("%cWARNING", this.WARNING, opts),
195
- _this$makeLog10 = _slicedToArray(_this$makeLog9, 2),
196
- logs = _this$makeLog10[0],
197
- colors = _this$makeLog10[1];
198
- for (var _len10 = arguments.length, rest = new Array(_len10 > 2 ? _len10 - 2 : 0), _key10 = 2; _key10 < _len10; _key10++) {
199
- rest[_key10 - 2] = arguments[_key10];
195
+ _this$makeLog0 = _slicedToArray(_this$makeLog9, 2),
196
+ logs = _this$makeLog0[0],
197
+ colors = _this$makeLog0[1];
198
+ for (var _len0 = arguments.length, rest = new Array(_len0 > 2 ? _len0 - 2 : 0), _key0 = 2; _key0 < _len0; _key0++) {
199
+ rest[_key0 - 2] = arguments[_key0];
200
200
  }
201
- (_console10 = console).warn.apply(_console10, [logs].concat(_toConsumableArray(colors), ["\n".concat(msg, "\ntest")], rest));
201
+ (_console0 = console).warn.apply(_console0, [logs].concat(_toConsumableArray(colors), ["\n".concat(msg, "\ntest")], rest));
202
202
  }
203
203
  };
204
204
  var logger = function logger() {
@@ -207,9 +207,9 @@ var logger = function logger() {
207
207
  };
208
208
 
209
209
  /**
210
- * @internal
210
+ * Returns a logger object with log/debug/info/error/warning methods, adapted for Node or browser. Optionally takes a module name.
211
211
  */
212
- var useLogger = function useLogger(mod) {
212
+ var getLogger = function getLogger(mod) {
213
213
  return {
214
214
  timer: function timer(process) {
215
215
  var startTime = new Date().getTime();
@@ -226,8 +226,8 @@ var useLogger = function useLogger(mod) {
226
226
  };
227
227
  return {
228
228
  log: function log(msg) {
229
- for (var _len11 = arguments.length, rest = new Array(_len11 > 1 ? _len11 - 1 : 0), _key11 = 1; _key11 < _len11; _key11++) {
230
- rest[_key11 - 1] = arguments[_key11];
229
+ for (var _len1 = arguments.length, rest = new Array(_len1 > 1 ? _len1 - 1 : 0), _key1 = 1; _key1 < _len1; _key1++) {
230
+ rest[_key1 - 1] = arguments[_key1];
231
231
  }
232
232
  return self.log.apply(self, [msg, {
233
233
  process: process,
@@ -236,8 +236,8 @@ var useLogger = function useLogger(mod) {
236
236
  }].concat(rest));
237
237
  },
238
238
  debug: function debug(msg) {
239
- for (var _len12 = arguments.length, rest = new Array(_len12 > 1 ? _len12 - 1 : 0), _key12 = 1; _key12 < _len12; _key12++) {
240
- rest[_key12 - 1] = arguments[_key12];
239
+ for (var _len10 = arguments.length, rest = new Array(_len10 > 1 ? _len10 - 1 : 0), _key10 = 1; _key10 < _len10; _key10++) {
240
+ rest[_key10 - 1] = arguments[_key10];
241
241
  }
242
242
  return self.debug.apply(self, [msg, {
243
243
  process: process,
@@ -246,8 +246,8 @@ var useLogger = function useLogger(mod) {
246
246
  }].concat(rest));
247
247
  },
248
248
  info: function info(msg) {
249
- for (var _len13 = arguments.length, rest = new Array(_len13 > 1 ? _len13 - 1 : 0), _key13 = 1; _key13 < _len13; _key13++) {
250
- rest[_key13 - 1] = arguments[_key13];
249
+ for (var _len11 = arguments.length, rest = new Array(_len11 > 1 ? _len11 - 1 : 0), _key11 = 1; _key11 < _len11; _key11++) {
250
+ rest[_key11 - 1] = arguments[_key11];
251
251
  }
252
252
  return self.info.apply(self, [msg, {
253
253
  process: process,
@@ -256,8 +256,8 @@ var useLogger = function useLogger(mod) {
256
256
  }].concat(rest));
257
257
  },
258
258
  error: function error(msg) {
259
- for (var _len14 = arguments.length, rest = new Array(_len14 > 1 ? _len14 - 1 : 0), _key14 = 1; _key14 < _len14; _key14++) {
260
- rest[_key14 - 1] = arguments[_key14];
259
+ for (var _len12 = arguments.length, rest = new Array(_len12 > 1 ? _len12 - 1 : 0), _key12 = 1; _key12 < _len12; _key12++) {
260
+ rest[_key12 - 1] = arguments[_key12];
261
261
  }
262
262
  return self.error.apply(self, [msg, {
263
263
  process: process,
@@ -266,8 +266,8 @@ var useLogger = function useLogger(mod) {
266
266
  }].concat(rest));
267
267
  },
268
268
  warning: function warning(msg) {
269
- for (var _len15 = arguments.length, rest = new Array(_len15 > 1 ? _len15 - 1 : 0), _key15 = 1; _key15 < _len15; _key15++) {
270
- rest[_key15 - 1] = arguments[_key15];
269
+ for (var _len13 = arguments.length, rest = new Array(_len13 > 1 ? _len13 - 1 : 0), _key13 = 1; _key13 < _len13; _key13++) {
270
+ rest[_key13 - 1] = arguments[_key13];
271
271
  }
272
272
  return self.warning.apply(self, [msg, {
273
273
  process: process,
@@ -277,8 +277,8 @@ var useLogger = function useLogger(mod) {
277
277
  },
278
278
  end: function end() {
279
279
  var msg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "completed";
280
- for (var _len16 = arguments.length, rest = new Array(_len16 > 1 ? _len16 - 1 : 0), _key16 = 1; _key16 < _len16; _key16++) {
281
- rest[_key16 - 1] = arguments[_key16];
280
+ for (var _len14 = arguments.length, rest = new Array(_len14 > 1 ? _len14 - 1 : 0), _key14 = 1; _key14 < _len14; _key14++) {
281
+ rest[_key14 - 1] = arguments[_key14];
282
282
  }
283
283
  return self.info.apply(self, [msg, {
284
284
  process: process,
@@ -288,52 +288,52 @@ var useLogger = function useLogger(mod) {
288
288
  }
289
289
  };
290
290
  },
291
- log: function log(msg, _ref4) {
291
+ log: function log(msg, opts) {
292
292
  var _logger;
293
- _ref4.module;
294
- var opts = _objectWithoutProperties(_ref4, _excluded);
295
- for (var _len17 = arguments.length, rest = new Array(_len17 > 2 ? _len17 - 2 : 0), _key17 = 2; _key17 < _len17; _key17++) {
296
- rest[_key17 - 2] = arguments[_key17];
293
+ for (var _len15 = arguments.length, rest = new Array(_len15 > 2 ? _len15 - 2 : 0), _key15 = 2; _key15 < _len15; _key15++) {
294
+ rest[_key15 - 2] = arguments[_key15];
297
295
  }
298
- (_logger = logger()) === null || _logger === void 0 || _logger.log.apply(_logger, [msg, opts].concat(rest));
296
+ (_logger = logger()) === null || _logger === void 0 || _logger.log.apply(_logger, [msg, _objectSpread({
297
+ module: mod
298
+ }, opts)].concat(rest));
299
299
  },
300
- debug: function debug(msg, _ref5) {
300
+ debug: function debug(msg, opts) {
301
301
  var _logger2;
302
- _ref5.module;
303
- var opts = _objectWithoutProperties(_ref5, _excluded2);
304
- for (var _len18 = arguments.length, rest = new Array(_len18 > 2 ? _len18 - 2 : 0), _key18 = 2; _key18 < _len18; _key18++) {
305
- rest[_key18 - 2] = arguments[_key18];
302
+ for (var _len16 = arguments.length, rest = new Array(_len16 > 2 ? _len16 - 2 : 0), _key16 = 2; _key16 < _len16; _key16++) {
303
+ rest[_key16 - 2] = arguments[_key16];
306
304
  }
307
- (_logger2 = logger()) === null || _logger2 === void 0 || _logger2.debug.apply(_logger2, [msg, opts].concat(rest));
305
+ (_logger2 = logger()) === null || _logger2 === void 0 || _logger2.debug.apply(_logger2, [msg, _objectSpread({
306
+ module: mod
307
+ }, opts)].concat(rest));
308
308
  },
309
- info: function info(msg, _ref6) {
309
+ info: function info(msg, opts) {
310
310
  var _logger3;
311
- _ref6.module;
312
- var opts = _objectWithoutProperties(_ref6, _excluded3);
313
- for (var _len19 = arguments.length, rest = new Array(_len19 > 2 ? _len19 - 2 : 0), _key19 = 2; _key19 < _len19; _key19++) {
314
- rest[_key19 - 2] = arguments[_key19];
311
+ for (var _len17 = arguments.length, rest = new Array(_len17 > 2 ? _len17 - 2 : 0), _key17 = 2; _key17 < _len17; _key17++) {
312
+ rest[_key17 - 2] = arguments[_key17];
315
313
  }
316
- (_logger3 = logger()) === null || _logger3 === void 0 || _logger3.info.apply(_logger3, [msg, opts].concat(rest));
314
+ (_logger3 = logger()) === null || _logger3 === void 0 || _logger3.info.apply(_logger3, [msg, _objectSpread({
315
+ module: mod
316
+ }, opts)].concat(rest));
317
317
  },
318
- error: function error(msg, _ref7) {
318
+ error: function error(msg, opts) {
319
319
  var _logger4;
320
- _ref7.module;
321
- var opts = _objectWithoutProperties(_ref7, _excluded4);
322
- for (var _len20 = arguments.length, rest = new Array(_len20 > 2 ? _len20 - 2 : 0), _key20 = 2; _key20 < _len20; _key20++) {
323
- rest[_key20 - 2] = arguments[_key20];
320
+ for (var _len18 = arguments.length, rest = new Array(_len18 > 2 ? _len18 - 2 : 0), _key18 = 2; _key18 < _len18; _key18++) {
321
+ rest[_key18 - 2] = arguments[_key18];
324
322
  }
325
- (_logger4 = logger()) === null || _logger4 === void 0 || _logger4.error.apply(_logger4, [msg, opts].concat(rest));
323
+ (_logger4 = logger()) === null || _logger4 === void 0 || _logger4.error.apply(_logger4, [msg, _objectSpread({
324
+ module: mod
325
+ }, opts)].concat(rest));
326
326
  },
327
- warning: function warning(msg, _ref8) {
327
+ warning: function warning(msg, opts) {
328
328
  var _logger5;
329
- _ref8.module;
330
- var opts = _objectWithoutProperties(_ref8, _excluded5);
331
- for (var _len21 = arguments.length, rest = new Array(_len21 > 2 ? _len21 - 2 : 0), _key21 = 2; _key21 < _len21; _key21++) {
332
- rest[_key21 - 2] = arguments[_key21];
329
+ for (var _len19 = arguments.length, rest = new Array(_len19 > 2 ? _len19 - 2 : 0), _key19 = 2; _key19 < _len19; _key19++) {
330
+ rest[_key19 - 2] = arguments[_key19];
333
331
  }
334
- (_logger5 = logger()) === null || _logger5 === void 0 || _logger5.warning.apply(_logger5, [msg, opts].concat(rest));
332
+ (_logger5 = logger()) === null || _logger5 === void 0 || _logger5.warning.apply(_logger5, [msg, _objectSpread({
333
+ module: mod
334
+ }, opts)].concat(rest));
335
335
  }
336
336
  };
337
337
  };
338
338
 
339
- export { useLogger };
339
+ export { getLogger };
@@ -0,0 +1,97 @@
1
+ 'use client';
2
+
3
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
4
+ import { isEmpty } from '../matchers/isEmpty.js';
5
+ import { isArray, isObject, isString } from '../matchers/typeChecks.js';
6
+
7
+ /**
8
+ * Convert a decimal degree coordinate to Degrees, Minutes, Seconds (DMS) format.
9
+ * Takes a single coordinate value and returns a formatted string with direction
10
+ * indicators (N/S for latitude, E/W for longitude).
11
+ *
12
+ * @param {number} coord - The decimal degree coordinate to convert.
13
+ * @param {boolean} [isLat=false] - Whether this is a latitude coordinate (affects direction suffix).
14
+ * @returns {string} A string in the format `"degrees˚minutes'seconds" Direction` (e.g., `"40˚42'51.36"N"`).
15
+ */
16
+ function convertToDMS(coord) {
17
+ var isLat = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
18
+ var degree = Math.floor(Math.abs(coord));
19
+ var hour = (Math.abs(coord) - degree) * 60;
20
+ var minute = (hour - Math.floor(hour)) * 60;
21
+ return "".concat(degree, "\u02DA").concat(Math.floor(hour), "'").concat(minute.toFixed(2), "\"").concat(coord < 0 ? isLat ? "S" : "W" : isLat ? "N" : "E");
22
+ }
23
+
24
+ /**
25
+ * Convert various formats of longitude and latitude to a tuple of [lon, lat].
26
+ * This function supports:
27
+ * - Arrays with two or three elements (e.g., [lon, lat] or [lon, lat, alt])
28
+ * - Objects with properties `lng`, `lat`, `lon`, or `longitude` and `latitude`
29
+ * - Strings in the format "lat,lon"
30
+ * The function will return a tuple of numbers [lon, lat].
31
+ *
32
+ * @param {LngLatLike} lonLat - The input longitude and latitude in various formats.
33
+ * @returns { [lon: number, lat: number] } A tuple of [lon, lat] where lon and lat are numbers.
34
+ * @throws Error if the input is not a valid format.
35
+ */
36
+ function convertToLonLat(lonLat) {
37
+ if (isEmpty(lonLat)) {
38
+ throw Error("Invalid geo coordinates");
39
+ }
40
+ if (isArray(lonLat) && lonLat.length === 2 || isArray(lonLat) && lonLat.length === 3) {
41
+ return [Number(lonLat[0]), Number(lonLat[1])];
42
+ }
43
+ if (isObject(lonLat)) {
44
+ if ("longitude" in lonLat) {
45
+ return [lonLat.longitude, lonLat.latitude];
46
+ }
47
+ return ["lon" in lonLat ? lonLat.lon : lonLat.lng, lonLat.lat];
48
+ }
49
+ if (isString(lonLat)) {
50
+ var _lonLat$split = lonLat.split(","),
51
+ _lonLat$split2 = _slicedToArray(_lonLat$split, 2),
52
+ _lat = _lonLat$split2[0],
53
+ _lon = _lonLat$split2[1];
54
+ if (!isNaN(+_lat) && !isNaN(+_lon)) return [+_lon, +_lat];
55
+ }
56
+ throw Error("Invalid geo coordinates");
57
+ }
58
+ function getLatitudeLongitude(lonLat) {
59
+ var _convertToLonLat = convertToLonLat(lonLat),
60
+ _convertToLonLat2 = _slicedToArray(_convertToLonLat, 2),
61
+ lon = _convertToLonLat2[0],
62
+ lat = _convertToLonLat2[1];
63
+ return {
64
+ latitude: lat,
65
+ longitude: lon
66
+ };
67
+ }
68
+
69
+ /**
70
+ * Convert a latitude and longitude to a human-readable text format.
71
+ * This function takes a latitude and longitude in various formats and
72
+ * returns a string in the format "degrees˚minutes'seconds" with direction (N/S, E/W).
73
+ *
74
+ * This function supports:
75
+ *
76
+ * - Objects with properties `lng`, `lat`, `lon`, or `longitude` and `latitude`
77
+ * - Arrays with two or three elements (e.g., [lon, lat] or [lon, lat, alt])
78
+ * - Strings in the format "lat,lon"
79
+ *
80
+ * @param {LngLatLike} latlon - The latitude and longitude in various formats.
81
+ * @returns {string} A string representation of the location in DMS format.
82
+ *
83
+ * @example
84
+ * ```jsx
85
+ * const location = getLocationAsText({ lat: 40.7128, lng: -74.0060 });
86
+ * console.log(location); // "40˚42'51.36"N, 74˚0'21.60"W"
87
+ * ```
88
+ */
89
+ function getLocationAsText(latlon) {
90
+ var _convertToLonLat3 = convertToLonLat(latlon),
91
+ _convertToLonLat4 = _slicedToArray(_convertToLonLat3, 2),
92
+ lon = _convertToLonLat4[0],
93
+ lat = _convertToLonLat4[1];
94
+ return "".concat(convertToDMS(lat, true), ", ").concat(convertToDMS(lon));
95
+ }
96
+
97
+ export { convertToLonLat, getLatitudeLongitude, getLocationAsText };
package/dist/esm/index.js CHANGED
@@ -1,52 +1,70 @@
1
1
  'use client';
2
2
 
3
- export { ascii } from './_ascii.js';
4
- export { getBoundingBox, getBox } from './_boundingBox.js';
5
- export { default as Countries } from './_countries.js';
6
- export { debounce } from './_debounce.js';
7
- export { dedupe, flatten, flattenAndDedupe, groupBy } from './_dedupe.js';
8
- export { _fetch as fetch } from './_fetch.js';
9
- export { default as FileUtil } from './_fileType.js';
10
- export { Format } from './_format.js';
11
- export { getByPath, getValue } from './_getByPath.js';
12
- export { hash, shortHash, uuid } from './_hash.js';
13
- export { interpolate, renderTemplate } from './_interpolate.js';
14
- export { compareValues, isEqual, matchString } from './_isEqual.js';
15
- export { isArray, isBoolean, isColor, isEmpty, isFalse, isNil, isNull, isNumber, isObject, isRtl, isString, isSvgPath, isTrue, isUndefined } from './_isType.js';
16
- export { mergeRefs } from './_mergeRefs.js';
17
- export { iconToken, tokenize } from './_tokenize.js';
18
- export { getImageColorset } from './getImageColorset.js';
19
- export { useLogger } from './useLogger.js';
20
- import './yup.js';
3
+ export { getBoundingBox, getBox } from './css/boundingBox.js';
4
+ export { cn } from './css/cn.js';
5
+ export { getImageColorset } from './css/imageColorset.js';
6
+ export { dedupe } from './lists/dedupe.js';
7
+ export { flatten, flattenAndDedupe } from './lists/flatten.js';
8
+ export { getByPath, getValue } from './lists/getByPath.js';
9
+ export { groupBy } from './lists/groupBy.js';
10
+ export { default as Countries } from './data/countries.js';
11
+ export { default as FileUtil } from './data/fileType.js';
12
+ export { Format } from './data/format.js';
13
+ export { debounce } from './helpers/debounce.js';
14
+ export { getLogger } from './helpers/getLogger.js';
15
+ export { convertToLonLat, getLatitudeLongitude, getLocationAsText } from './helpers/lonlat.js';
16
+ export { compareValues } from './matchers/compare.js';
17
+ export { isEmpty } from './matchers/isEmpty.js';
18
+ export { isEqual } from './matchers/isEqual.js';
19
+ export { isDefined, isNil, isNull, isUndefined } from './matchers/nullChecks.js';
20
+ export { isArray, isBoolean, isColor, isFalse, isNumber, isObject, isString, isSvgPath, isTrue } from './matchers/typeChecks.js';
21
+ export { hash, shortHash, uuid } from './strings/hash.js';
22
+ export { interpolate } from './strings/interpolate.js';
23
+ export { matchString } from './strings/matchString.js';
24
+ export { renderTemplate } from './strings/template.js';
25
+ export { iconToken, tokenize } from './strings/tokenize.js';
26
+ export { mergeRefs } from './utils/mergeRefs.js';
27
+ import './utils/yup.js';
21
28
  import * as _yup from 'yup';
22
29
  export { _yup as yup };
23
30
 
24
- /*
31
+ /**
25
32
  * React Fabric
26
- * @version: 1.0.0
33
+ * @version 1.0.0
34
+ * @license MIT
35
+ * @copyright 2024 Adarsh Pastakia
27
36
  *
37
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
38
+ * of this software and associated documentation files (the "Software"), to deal
39
+ * in the Software without restriction, including without limitation the rights
40
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
41
+ * copies of the Software, and to permit persons to whom the Software is
42
+ * furnished to do so, subject to the following conditions:
28
43
  *
29
- * The MIT License (MIT)
30
- * Copyright (c) 2024 Adarsh Pastakia
44
+ * The above copyright notice and this permission notice shall be included in all
45
+ * copies or substantial portions of the Software.
31
46
  *
32
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
33
- * and associated documentation files (the "Software"), to deal in the Software without restriction,
34
- * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
35
- * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
36
- * subject to the following conditions:
37
- *
38
- * The above copyright notice and this permission notice shall be included in all copies or substantial
39
- * portions of the Software.
40
- *
41
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
42
- * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
43
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
44
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
47
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
48
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
49
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
50
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
51
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
52
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
53
+ * SOFTWARE.
45
54
  */
46
55
 
56
+ /* istanbul ignore file */
57
+
58
+ var UTILITIES_PACKAGE = "@react-fabric/utilities";
59
+ var UTILITIES_VERSION = "1.0.0";
47
60
  var EMPTY_ARRAY = [];
48
61
  Object.freeze(EMPTY_ARRAY);
49
62
  var EMPTY_OBJECT = {};
50
63
  Object.freeze(EMPTY_OBJECT);
64
+ var EMPTY_FC = function EMPTY_FC() {
65
+ return function () {
66
+ return null;
67
+ };
68
+ };
51
69
 
52
- export { EMPTY_ARRAY, EMPTY_OBJECT };
70
+ export { EMPTY_ARRAY, EMPTY_FC, EMPTY_OBJECT, UTILITIES_PACKAGE, UTILITIES_VERSION };
@@ -0,0 +1,54 @@
1
+ 'use client';
2
+
3
+ import { isEmpty } from '../matchers/isEmpty.js';
4
+
5
+ /**
6
+ * React Fabric
7
+ * @version 1.0.0
8
+ * @license MIT
9
+ * @copyright 2024 Adarsh Pastakia
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in all
19
+ * copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ * SOFTWARE.
28
+ */
29
+
30
+
31
+ /**
32
+ * Remove duplicates from a list of objects based on a key or the entire object.
33
+ * If a key is provided, it will deduplicate based on the value of that key.
34
+ * If no key is provided, it will deduplicate based on the entire object.
35
+ * This is useful for normalizing data structures that may have nested arrays or objects.
36
+ *
37
+ * @param list
38
+ * @param key
39
+ * @typedef {T} AnyObject - A generic type representing list items.
40
+ * @returns {T[]} - A new array with duplicates removed.
41
+ */
42
+ function dedupe(list, key) {
43
+ var filtered = list.filter(function (i) {
44
+ return !isEmpty(i);
45
+ });
46
+ if (!key) {
47
+ return Array.from(new Set(filtered).values());
48
+ }
49
+ return Array.from(new Map(filtered.map(function (obj) {
50
+ return [obj[key], obj];
51
+ })).values());
52
+ }
53
+
54
+ export { dedupe };
@@ -0,0 +1,65 @@
1
+ 'use client';
2
+
3
+ import { isEmpty } from '../matchers/isEmpty.js';
4
+ import { dedupe } from './dedupe.js';
5
+
6
+ /**
7
+ * React Fabric
8
+ * @version 1.0.0
9
+ * @license MIT
10
+ * @copyright 2024 Adarsh Pastakia
11
+ *
12
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ * of this software and associated documentation files (the "Software"), to deal
14
+ * in the Software without restriction, including without limitation the rights
15
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ * copies of the Software, and to permit persons to whom the Software is
17
+ * furnished to do so, subject to the following conditions:
18
+ *
19
+ * The above copyright notice and this permission notice shall be included in all
20
+ * copies or substantial portions of the Software.
21
+ *
22
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ * SOFTWARE.
29
+ */
30
+
31
+
32
+ /**
33
+ * Flatten a list of objects, removing any empty objects.
34
+ * It will flatten up to 5 levels deep and filter out any empty objects.
35
+ * This is useful for normalizing data structures that may have nested arrays or objects.
36
+ *
37
+ * @param list
38
+ * @typedef {T} AnyObject - A generic type representing list items.
39
+ * @returns {T[]} - A flattened array of objects.
40
+ */
41
+ function flatten(list) {
42
+ return list.flat(5).filter(function (i) {
43
+ return !isEmpty(i);
44
+ });
45
+ }
46
+
47
+ /**
48
+ * Flatten a list of objects and remove duplicates based on a key or the entire object.
49
+ * If a key is provided, it will deduplicate based on the value of that key.
50
+ * If no key is provided, it will deduplicate based on the entire object.
51
+ * This is useful for normalizing data structures that may have nested arrays or objects.
52
+ * Flattening is done first, followed by deduplication.
53
+ *
54
+ * @param list
55
+ * @param key
56
+ * @typedef {T} AnyObject - A generic type representing list items.
57
+ * @returns {T[]} - A new array with duplicates removed.
58
+ */
59
+ function flattenAndDedupe() {
60
+ var list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
61
+ var key = arguments.length > 1 ? arguments[1] : undefined;
62
+ return dedupe(flatten(list), key);
63
+ }
64
+
65
+ export { flatten, flattenAndDedupe };