@react-fabric/utilities 1.0.0-beta.0

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 (79) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +10 -0
  3. package/dist/cjs/_ascii.js +76 -0
  4. package/dist/cjs/_boundingBox.js +59 -0
  5. package/dist/cjs/_countries.js +2805 -0
  6. package/dist/cjs/_debounce.js +53 -0
  7. package/dist/cjs/_dedupe.js +63 -0
  8. package/dist/cjs/_fetch.js +128 -0
  9. package/dist/cjs/_fileType.js +967 -0
  10. package/dist/cjs/_format.js +118 -0
  11. package/dist/cjs/_getByPath.js +125 -0
  12. package/dist/cjs/_hash.js +67 -0
  13. package/dist/cjs/_interpolate.js +47 -0
  14. package/dist/cjs/_isEqual.js +108 -0
  15. package/dist/cjs/_isType.js +98 -0
  16. package/dist/cjs/_mergeRefs.js +40 -0
  17. package/dist/cjs/_tokenize.js +67 -0
  18. package/dist/cjs/getImageColorset.js +70 -0
  19. package/dist/cjs/index.js +116 -0
  20. package/dist/cjs/useLogger.js +339 -0
  21. package/dist/cjs/yup.js +172 -0
  22. package/dist/esm/_ascii.js +76 -0
  23. package/dist/esm/_boundingBox.js +58 -0
  24. package/dist/esm/_countries.js +2805 -0
  25. package/dist/esm/_debounce.js +53 -0
  26. package/dist/esm/_dedupe.js +60 -0
  27. package/dist/esm/_fetch.js +128 -0
  28. package/dist/esm/_fileType.js +967 -0
  29. package/dist/esm/_format.js +120 -0
  30. package/dist/esm/_getByPath.js +124 -0
  31. package/dist/esm/_hash.js +65 -0
  32. package/dist/esm/_interpolate.js +46 -0
  33. package/dist/esm/_isEqual.js +106 -0
  34. package/dist/esm/_isType.js +85 -0
  35. package/dist/esm/_mergeRefs.js +40 -0
  36. package/dist/esm/_tokenize.js +66 -0
  37. package/dist/esm/getImageColorset.js +70 -0
  38. package/dist/esm/index.js +52 -0
  39. package/dist/esm/useLogger.js +339 -0
  40. package/dist/esm/yup.js +152 -0
  41. package/dist/types/_ascii.d.ts +5 -0
  42. package/dist/types/_boundingBox.d.ts +10 -0
  43. package/dist/types/_countries.d.ts +85 -0
  44. package/dist/types/_debounce.d.ts +8 -0
  45. package/dist/types/_dedupe.d.ts +4 -0
  46. package/dist/types/_fetch.d.ts +23 -0
  47. package/dist/types/_fileType.d.ts +926 -0
  48. package/dist/types/_format.d.ts +27 -0
  49. package/dist/types/_getByPath.d.ts +10 -0
  50. package/dist/types/_hash.d.ts +16 -0
  51. package/dist/types/_interpolate.d.ts +6 -0
  52. package/dist/types/_isEqual.d.ts +15 -0
  53. package/dist/types/_isType.d.ts +14 -0
  54. package/dist/types/_mergeRefs.d.ts +1 -0
  55. package/dist/types/_tokenize.d.ts +8 -0
  56. package/dist/types/getImageColorset.d.ts +1 -0
  57. package/dist/types/index.d.ts +22 -0
  58. package/dist/types/useLogger.d.ts +25 -0
  59. package/dist/types/yup.d.ts +1 -0
  60. package/package.json +48 -0
  61. package/src/_ascii.ts +93 -0
  62. package/src/_boundingBox.ts +72 -0
  63. package/src/_countries.ts +3046 -0
  64. package/src/_debounce.ts +42 -0
  65. package/src/_dedupe.ts +56 -0
  66. package/src/_fetch.ts +109 -0
  67. package/src/_fileType.ts +993 -0
  68. package/src/_format.ts +141 -0
  69. package/src/_getByPath.ts +108 -0
  70. package/src/_hash.ts +62 -0
  71. package/src/_interpolate.ts +42 -0
  72. package/src/_isEqual.ts +102 -0
  73. package/src/_isType.ts +105 -0
  74. package/src/_mergeRefs.ts +33 -0
  75. package/src/_tokenize.ts +69 -0
  76. package/src/getImageColorset.ts +81 -0
  77. package/src/index.ts +51 -0
  78. package/src/useLogger.ts +304 -0
  79. package/src/yup.ts +75 -0
@@ -0,0 +1,76 @@
1
+ 'use client';
2
+
3
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
4
+ import { isEmpty } from './_isType.js';
5
+
6
+ /** ***************** latin-ascii conversions *******************/
7
+ var conversions = {
8
+ AE: "Æ|Ǽ",
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Ŭ|Ů|Ű|Ų|Ư|Ǔ|Ǖ|Ǘ|Ǚ|Ǜ",
50
+ u: "ù|ú|û|ũ|ū|ŭ|ů|ű|ų|ư|ǔ|ǖ|ǘ|ǚ|ǜ",
51
+ Y: "Ý|Ÿ|Ŷ",
52
+ y: "ý|ÿ|ŷ",
53
+ W: "Ŵ",
54
+ w: "ŵ",
55
+ Z: "Ź|Ż|Ž",
56
+ z: "ź|ż|ž",
57
+ f: "ƒ"
58
+ };
59
+
60
+ /**
61
+ * latin to ascii converter for convenient searching
62
+ * @internal
63
+ */
64
+ var ascii = function ascii(str) {
65
+ if (isEmpty(str)) return "";
66
+ Object.entries(conversions).forEach(function (_ref) {
67
+ var _ref2 = _slicedToArray(_ref, 2),
68
+ a = _ref2[0],
69
+ l = _ref2[1];
70
+ var re = new RegExp(l, "g");
71
+ str = "".concat(str).replace(re, a);
72
+ });
73
+ return str;
74
+ };
75
+
76
+ export { ascii };
@@ -0,0 +1,58 @@
1
+ 'use client';
2
+
3
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
4
+ import { isEmpty } from './_isType.js';
5
+
6
+ var _getBox = function _getBox(box) {
7
+ var boundingBox = box;
8
+ if (isEmpty(box)) return [0, 0, 0, 0];
9
+ if (typeof box === "string") {
10
+ boundingBox = box.split(",");
11
+ }
12
+ if (Array.isArray(boundingBox)) {
13
+ boundingBox = boundingBox.map(function (b) {
14
+ return parseInt(b, 10);
15
+ });
16
+ }
17
+ return boundingBox;
18
+ };
19
+
20
+ /**
21
+ * box "x,y,w,h" | [x,y,w,h]
22
+ * returns canvas box [x,y,w,h]
23
+ */
24
+ var getBox = function getBox() {
25
+ var box = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "0,0,0,0";
26
+ var boundingBox = _getBox(box);
27
+ var _boundingBox = _slicedToArray(boundingBox, 4),
28
+ x = _boundingBox[0],
29
+ y = _boundingBox[1],
30
+ w = _boundingBox[2],
31
+ h = _boundingBox[3];
32
+ w = x < 0 ? w + x : w;
33
+ h = y < 0 ? h + y : h;
34
+ x = x > 0 ? x : 0;
35
+ y = y > 0 ? y : 0;
36
+ return [x, y, w, h];
37
+ };
38
+
39
+ /**
40
+ * box "x1,y1,x2,y2" | [x1,y1,x2,y2]
41
+ * returns canvas box [x,y,w,h]
42
+ */
43
+ var getBoundingBox = function getBoundingBox() {
44
+ var box = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "0,0,0,0";
45
+ var boundingBox = _getBox(box);
46
+ var _boundingBox2 = _slicedToArray(boundingBox, 4),
47
+ x1 = _boundingBox2[0],
48
+ y1 = _boundingBox2[1],
49
+ x2 = _boundingBox2[2],
50
+ y2 = _boundingBox2[3];
51
+ var w = x2 - x1;
52
+ var h = y2 - y1;
53
+ x1 = x1 > 0 ? x1 : 0;
54
+ y1 = y1 > 0 ? y1 : 0;
55
+ return [x1, y1, w, h];
56
+ };
57
+
58
+ export { getBoundingBox, getBox };