@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.
- package/LICENSE +21 -0
- package/README.md +10 -0
- package/dist/cjs/_ascii.js +76 -0
- package/dist/cjs/_boundingBox.js +59 -0
- package/dist/cjs/_countries.js +2805 -0
- package/dist/cjs/_debounce.js +53 -0
- package/dist/cjs/_dedupe.js +63 -0
- package/dist/cjs/_fetch.js +128 -0
- package/dist/cjs/_fileType.js +967 -0
- package/dist/cjs/_format.js +118 -0
- package/dist/cjs/_getByPath.js +125 -0
- package/dist/cjs/_hash.js +67 -0
- package/dist/cjs/_interpolate.js +47 -0
- package/dist/cjs/_isEqual.js +108 -0
- package/dist/cjs/_isType.js +98 -0
- package/dist/cjs/_mergeRefs.js +40 -0
- package/dist/cjs/_tokenize.js +67 -0
- package/dist/cjs/getImageColorset.js +70 -0
- package/dist/cjs/index.js +116 -0
- package/dist/cjs/useLogger.js +339 -0
- package/dist/cjs/yup.js +172 -0
- package/dist/esm/_ascii.js +76 -0
- package/dist/esm/_boundingBox.js +58 -0
- package/dist/esm/_countries.js +2805 -0
- package/dist/esm/_debounce.js +53 -0
- package/dist/esm/_dedupe.js +60 -0
- package/dist/esm/_fetch.js +128 -0
- package/dist/esm/_fileType.js +967 -0
- package/dist/esm/_format.js +120 -0
- package/dist/esm/_getByPath.js +124 -0
- package/dist/esm/_hash.js +65 -0
- package/dist/esm/_interpolate.js +46 -0
- package/dist/esm/_isEqual.js +106 -0
- package/dist/esm/_isType.js +85 -0
- package/dist/esm/_mergeRefs.js +40 -0
- package/dist/esm/_tokenize.js +66 -0
- package/dist/esm/getImageColorset.js +70 -0
- package/dist/esm/index.js +52 -0
- package/dist/esm/useLogger.js +339 -0
- package/dist/esm/yup.js +152 -0
- package/dist/types/_ascii.d.ts +5 -0
- package/dist/types/_boundingBox.d.ts +10 -0
- package/dist/types/_countries.d.ts +85 -0
- package/dist/types/_debounce.d.ts +8 -0
- package/dist/types/_dedupe.d.ts +4 -0
- package/dist/types/_fetch.d.ts +23 -0
- package/dist/types/_fileType.d.ts +926 -0
- package/dist/types/_format.d.ts +27 -0
- package/dist/types/_getByPath.d.ts +10 -0
- package/dist/types/_hash.d.ts +16 -0
- package/dist/types/_interpolate.d.ts +6 -0
- package/dist/types/_isEqual.d.ts +15 -0
- package/dist/types/_isType.d.ts +14 -0
- package/dist/types/_mergeRefs.d.ts +1 -0
- package/dist/types/_tokenize.d.ts +8 -0
- package/dist/types/getImageColorset.d.ts +1 -0
- package/dist/types/index.d.ts +22 -0
- package/dist/types/useLogger.d.ts +25 -0
- package/dist/types/yup.d.ts +1 -0
- package/package.json +48 -0
- package/src/_ascii.ts +93 -0
- package/src/_boundingBox.ts +72 -0
- package/src/_countries.ts +3046 -0
- package/src/_debounce.ts +42 -0
- package/src/_dedupe.ts +56 -0
- package/src/_fetch.ts +109 -0
- package/src/_fileType.ts +993 -0
- package/src/_format.ts +141 -0
- package/src/_getByPath.ts +108 -0
- package/src/_hash.ts +62 -0
- package/src/_interpolate.ts +42 -0
- package/src/_isEqual.ts +102 -0
- package/src/_isType.ts +105 -0
- package/src/_mergeRefs.ts +33 -0
- package/src/_tokenize.ts +69 -0
- package/src/getImageColorset.ts +81 -0
- package/src/index.ts +51 -0
- package/src/useLogger.ts +304 -0
- package/src/yup.ts +75 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* React Fabric
|
|
5
|
+
* @version: 1.0.0
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* The MIT License (MIT)
|
|
9
|
+
* Copyright (c) 2024 Adarsh Pastakia
|
|
10
|
+
*
|
|
11
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
12
|
+
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
13
|
+
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
14
|
+
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
15
|
+
* subject to the following conditions:
|
|
16
|
+
*
|
|
17
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
18
|
+
* portions of the Software.
|
|
19
|
+
*
|
|
20
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
21
|
+
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
22
|
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
23
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/* istanbul ignore file */
|
|
27
|
+
|
|
28
|
+
var getImageColorset = function getImageColorset(el) {
|
|
29
|
+
// create canvas
|
|
30
|
+
var canvas = document.createElement("canvas");
|
|
31
|
+
canvas.width = Math.min(500, el.naturalWidth);
|
|
32
|
+
canvas.height = Math.min(500, el.naturalHeight);
|
|
33
|
+
var ctx = canvas.getContext("2d");
|
|
34
|
+
if (ctx != null) {
|
|
35
|
+
ctx.drawImage(el, 0, 0, el.naturalWidth, el.naturalHeight, 0, 0, canvas.width, canvas.height);
|
|
36
|
+
var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
|
37
|
+
var data = imageData.data;
|
|
38
|
+
var r, g, b;
|
|
39
|
+
var dark = 0;
|
|
40
|
+
var light = 0;
|
|
41
|
+
var totalPixels = 0;
|
|
42
|
+
var transparent = (data === null || data === void 0 ? void 0 : data[3]) === 0;
|
|
43
|
+
for (var x = 0, len = data.length; x < len; x += 4) {
|
|
44
|
+
if (data[x + 3] === 0) {
|
|
45
|
+
transparent = true;
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (transparent && data[x - 1] === 1) {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
r = data[x];
|
|
52
|
+
g = data[x + 1];
|
|
53
|
+
b = data[x + 2];
|
|
54
|
+
totalPixels++;
|
|
55
|
+
0.2126 * r + 0.7152 * g + 0.0722 * b < 128 ? dark++ : light++;
|
|
56
|
+
}
|
|
57
|
+
var diff = light / totalPixels - dark / totalPixels;
|
|
58
|
+
var ret = diff > 0 ? "light" : "dark";
|
|
59
|
+
if (transparent) {
|
|
60
|
+
ret += "_transparent";
|
|
61
|
+
}
|
|
62
|
+
return ret;
|
|
63
|
+
}
|
|
64
|
+
return "light";
|
|
65
|
+
};
|
|
66
|
+
if (typeof window !== "undefined")
|
|
67
|
+
// @ts-expect-error ignore
|
|
68
|
+
window.getImageColorset = getImageColorset;
|
|
69
|
+
|
|
70
|
+
export { getImageColorset };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
'use client';
|
|
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';
|
|
21
|
+
import * as _yup from 'yup';
|
|
22
|
+
export { _yup as yup };
|
|
23
|
+
|
|
24
|
+
/*
|
|
25
|
+
* React Fabric
|
|
26
|
+
* @version: 1.0.0
|
|
27
|
+
*
|
|
28
|
+
*
|
|
29
|
+
* The MIT License (MIT)
|
|
30
|
+
* Copyright (c) 2024 Adarsh Pastakia
|
|
31
|
+
*
|
|
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.
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
var EMPTY_ARRAY = [];
|
|
48
|
+
Object.freeze(EMPTY_ARRAY);
|
|
49
|
+
var EMPTY_OBJECT = {};
|
|
50
|
+
Object.freeze(EMPTY_OBJECT);
|
|
51
|
+
|
|
52
|
+
export { EMPTY_ARRAY, EMPTY_OBJECT };
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
4
|
+
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
5
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
6
|
+
|
|
7
|
+
var _excluded = ["module"],
|
|
8
|
+
_excluded2 = ["module"],
|
|
9
|
+
_excluded3 = ["module"],
|
|
10
|
+
_excluded4 = ["module"],
|
|
11
|
+
_excluded5 = ["module"];
|
|
12
|
+
/*
|
|
13
|
+
* React Fabric
|
|
14
|
+
* @version: 1.0.0
|
|
15
|
+
*
|
|
16
|
+
*
|
|
17
|
+
* The MIT License (MIT)
|
|
18
|
+
* Copyright (c) 2024 Adarsh Pastakia
|
|
19
|
+
*
|
|
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:
|
|
25
|
+
*
|
|
26
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
27
|
+
* portions of the Software.
|
|
28
|
+
*
|
|
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.
|
|
33
|
+
*/
|
|
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 || {});
|
|
41
|
+
/* istanbul ignore file */
|
|
42
|
+
var NODE = {
|
|
43
|
+
LOG: "\x1B[38;5;144m",
|
|
44
|
+
INFO: "\x1B[38;5;81m",
|
|
45
|
+
DEBUG: "\x1B[38;5;110m",
|
|
46
|
+
ERROR: "\x1B[38;5;161m",
|
|
47
|
+
WARNING: "\x1B[38;5;209m",
|
|
48
|
+
TIME: "\x1B[38;5;72m",
|
|
49
|
+
PROCESS: "\x1B[38;5;108m",
|
|
50
|
+
DURATION: "\x1B[38;5;140m",
|
|
51
|
+
RESET: "\x1B[0m",
|
|
52
|
+
logLevel: function logLevel() {
|
|
53
|
+
var _global$LOG_LEVEL;
|
|
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
|
|
56
|
+
);
|
|
57
|
+
},
|
|
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;
|
|
64
|
+
var ret = [];
|
|
65
|
+
if (process) ret.push("".concat(this.PROCESS, "Process: ").concat(process).concat(this.RESET));
|
|
66
|
+
if (module) ret.push("".concat(this.PROCESS, "Module: ").concat(module).concat(this.RESET));
|
|
67
|
+
if (duration) ret.push("".concat(this.DURATION, "Duration: ").concat(duration).concat(this.RESET));
|
|
68
|
+
if (module) ret.push("".concat(this.DURATION, "TotalTime: ").concat(totalTime).concat(this.RESET));
|
|
69
|
+
return ["[".concat(this.TIME).concat(new Date().toISOString()).concat(this.RESET, "] ").concat(level), ret.join(" ")].filter(Boolean).join("\n");
|
|
70
|
+
},
|
|
71
|
+
log: function log(msg, opts) {
|
|
72
|
+
var _console;
|
|
73
|
+
if (+this.logLevel() < LOG_LEVEL.DEBUG) return;
|
|
74
|
+
for (var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
75
|
+
rest[_key - 2] = arguments[_key];
|
|
76
|
+
}
|
|
77
|
+
(_console = console).log.apply(_console, [this.makeLog("".concat(this.LOG, "LOG").concat(this.RESET), opts), "\n".concat(msg, "\n")].concat(rest));
|
|
78
|
+
},
|
|
79
|
+
debug: function debug(msg, opts) {
|
|
80
|
+
var _console2;
|
|
81
|
+
if (+this.logLevel() < LOG_LEVEL.DEBUG) return;
|
|
82
|
+
for (var _len2 = arguments.length, rest = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
|
83
|
+
rest[_key2 - 2] = arguments[_key2];
|
|
84
|
+
}
|
|
85
|
+
(_console2 = console).debug.apply(_console2, [this.makeLog("".concat(this.DEBUG, "DEBUG").concat(this.RESET), opts), "\n".concat(msg, "\n")].concat(rest));
|
|
86
|
+
},
|
|
87
|
+
info: function info(msg, opts) {
|
|
88
|
+
var _console3;
|
|
89
|
+
if (+this.logLevel() < LOG_LEVEL.INFO) return;
|
|
90
|
+
for (var _len3 = arguments.length, rest = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
|
|
91
|
+
rest[_key3 - 2] = arguments[_key3];
|
|
92
|
+
}
|
|
93
|
+
(_console3 = console).info.apply(_console3, [this.makeLog("".concat(this.INFO, "INFO").concat(this.RESET), opts), "\n".concat(msg, "\n")].concat(rest));
|
|
94
|
+
},
|
|
95
|
+
error: function error(msg, opts) {
|
|
96
|
+
var _console4;
|
|
97
|
+
for (var _len4 = arguments.length, rest = new Array(_len4 > 2 ? _len4 - 2 : 0), _key4 = 2; _key4 < _len4; _key4++) {
|
|
98
|
+
rest[_key4 - 2] = arguments[_key4];
|
|
99
|
+
}
|
|
100
|
+
(_console4 = console).error.apply(_console4, [this.makeLog("".concat(this.ERROR, "ERROR").concat(this.RESET), opts), "\n".concat(msg, "\n")].concat(rest));
|
|
101
|
+
},
|
|
102
|
+
warning: function warning(msg, opts) {
|
|
103
|
+
var _console5;
|
|
104
|
+
if (+this.logLevel() < LOG_LEVEL.WARNING) return;
|
|
105
|
+
for (var _len5 = arguments.length, rest = new Array(_len5 > 2 ? _len5 - 2 : 0), _key5 = 2; _key5 < _len5; _key5++) {
|
|
106
|
+
rest[_key5 - 2] = arguments[_key5];
|
|
107
|
+
}
|
|
108
|
+
(_console5 = console).warn.apply(_console5, [this.makeLog("".concat(this.WARNING, "WARNING").concat(this.RESET), opts), "\n".concat(msg, "\n")].concat(rest));
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
var BROWSER = {
|
|
112
|
+
LOG: "#afaf87",
|
|
113
|
+
INFO: "#5fd7ff",
|
|
114
|
+
DEBUG: "#87afd7",
|
|
115
|
+
ERROR: "#d7005f",
|
|
116
|
+
WARNING: "#ff875f",
|
|
117
|
+
TIME: "#5faf87",
|
|
118
|
+
PROCESS: "#87af87",
|
|
119
|
+
DURATION: "#af87d7",
|
|
120
|
+
logLevel: function logLevel() {
|
|
121
|
+
var _ref2;
|
|
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
|
|
124
|
+
);
|
|
125
|
+
},
|
|
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;
|
|
132
|
+
var ret = [];
|
|
133
|
+
var colors = ["color:".concat(this.TIME, ";font-weight:bold;"), "color:".concat(color, ";font-weight:bold;")];
|
|
134
|
+
if (module) ret.push("%cModule: ".concat(module));
|
|
135
|
+
if (process) ret.push("%cProcess: ".concat(process));
|
|
136
|
+
if (duration) ret.push("%cDuration: ".concat(duration));
|
|
137
|
+
if (module) ret.push("%cTotalTime: ".concat(totalTime));
|
|
138
|
+
if (module) colors.push("color:".concat(this.PROCESS));
|
|
139
|
+
if (process) colors.push("color:".concat(this.PROCESS));
|
|
140
|
+
if (duration) colors.push("color:".concat(this.DURATION));
|
|
141
|
+
if (module) colors.push("color:".concat(this.DURATION));
|
|
142
|
+
return [["%c[".concat(new Date().toISOString(), "] ").concat(level), ret.join(" ")].filter(Boolean).join("\n"), colors];
|
|
143
|
+
},
|
|
144
|
+
log: function log(msg, opts) {
|
|
145
|
+
var _console6;
|
|
146
|
+
if (+this.logLevel() < LOG_LEVEL.DEBUG) return;
|
|
147
|
+
var _this$makeLog = this.makeLog("%cLOG", this.LOG, opts),
|
|
148
|
+
_this$makeLog2 = _slicedToArray(_this$makeLog, 2),
|
|
149
|
+
logs = _this$makeLog2[0],
|
|
150
|
+
colors = _this$makeLog2[1];
|
|
151
|
+
for (var _len6 = arguments.length, rest = new Array(_len6 > 2 ? _len6 - 2 : 0), _key6 = 2; _key6 < _len6; _key6++) {
|
|
152
|
+
rest[_key6 - 2] = arguments[_key6];
|
|
153
|
+
}
|
|
154
|
+
(_console6 = console).log.apply(_console6, [logs].concat(_toConsumableArray(colors), ["\n".concat(msg, "\n")], rest));
|
|
155
|
+
},
|
|
156
|
+
debug: function debug(msg, opts) {
|
|
157
|
+
var _console7;
|
|
158
|
+
if (+this.logLevel() < LOG_LEVEL.DEBUG) return;
|
|
159
|
+
var _this$makeLog3 = this.makeLog("%cDEBUG", this.DEBUG, opts),
|
|
160
|
+
_this$makeLog4 = _slicedToArray(_this$makeLog3, 2),
|
|
161
|
+
logs = _this$makeLog4[0],
|
|
162
|
+
colors = _this$makeLog4[1];
|
|
163
|
+
for (var _len7 = arguments.length, rest = new Array(_len7 > 2 ? _len7 - 2 : 0), _key7 = 2; _key7 < _len7; _key7++) {
|
|
164
|
+
rest[_key7 - 2] = arguments[_key7];
|
|
165
|
+
}
|
|
166
|
+
(_console7 = console).debug.apply(_console7, [logs].concat(_toConsumableArray(colors), ["\n".concat(msg, "\n")], rest));
|
|
167
|
+
},
|
|
168
|
+
info: function info(msg, opts) {
|
|
169
|
+
var _console8;
|
|
170
|
+
if (+this.logLevel() < LOG_LEVEL.INFO) return;
|
|
171
|
+
var _this$makeLog5 = this.makeLog("%cINFO", this.INFO, opts),
|
|
172
|
+
_this$makeLog6 = _slicedToArray(_this$makeLog5, 2),
|
|
173
|
+
logs = _this$makeLog6[0],
|
|
174
|
+
colors = _this$makeLog6[1];
|
|
175
|
+
for (var _len8 = arguments.length, rest = new Array(_len8 > 2 ? _len8 - 2 : 0), _key8 = 2; _key8 < _len8; _key8++) {
|
|
176
|
+
rest[_key8 - 2] = arguments[_key8];
|
|
177
|
+
}
|
|
178
|
+
(_console8 = console).info.apply(_console8, [logs].concat(_toConsumableArray(colors), ["\n".concat(msg, "\n")], rest));
|
|
179
|
+
},
|
|
180
|
+
error: function error(msg, opts) {
|
|
181
|
+
var _console9;
|
|
182
|
+
var _this$makeLog7 = this.makeLog("%cERROR", this.ERROR, opts),
|
|
183
|
+
_this$makeLog8 = _slicedToArray(_this$makeLog7, 2),
|
|
184
|
+
logs = _this$makeLog8[0],
|
|
185
|
+
colors = _this$makeLog8[1];
|
|
186
|
+
for (var _len9 = arguments.length, rest = new Array(_len9 > 2 ? _len9 - 2 : 0), _key9 = 2; _key9 < _len9; _key9++) {
|
|
187
|
+
rest[_key9 - 2] = arguments[_key9];
|
|
188
|
+
}
|
|
189
|
+
(_console9 = console).error.apply(_console9, [logs].concat(_toConsumableArray(colors), ["\n".concat(msg, "\n")], rest));
|
|
190
|
+
},
|
|
191
|
+
warning: function warning(msg, opts) {
|
|
192
|
+
var _console10;
|
|
193
|
+
if (+this.logLevel() < LOG_LEVEL.WARNING) return;
|
|
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];
|
|
200
|
+
}
|
|
201
|
+
(_console10 = console).warn.apply(_console10, [logs].concat(_toConsumableArray(colors), ["\n".concat(msg, "\ntest")], rest));
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
var logger = function logger() {
|
|
205
|
+
if (typeof window === "undefined") return NODE;
|
|
206
|
+
if (typeof window !== "undefined") return BROWSER;
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* @internal
|
|
211
|
+
*/
|
|
212
|
+
var useLogger = function useLogger(mod) {
|
|
213
|
+
return {
|
|
214
|
+
timer: function timer(process) {
|
|
215
|
+
var startTime = new Date().getTime();
|
|
216
|
+
var nextTime = new Date().getTime();
|
|
217
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
218
|
+
var self = this;
|
|
219
|
+
var getTime = function getTime() {
|
|
220
|
+
var ret = (new Date().getTime() - nextTime) / 1000;
|
|
221
|
+
nextTime = new Date().getTime();
|
|
222
|
+
return ret;
|
|
223
|
+
};
|
|
224
|
+
var getFullTime = function getFullTime() {
|
|
225
|
+
return (new Date().getTime() - startTime) / 1000;
|
|
226
|
+
};
|
|
227
|
+
return {
|
|
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];
|
|
231
|
+
}
|
|
232
|
+
return self.log.apply(self, [msg, {
|
|
233
|
+
process: process,
|
|
234
|
+
duration: getTime(),
|
|
235
|
+
totalTime: getFullTime()
|
|
236
|
+
}].concat(rest));
|
|
237
|
+
},
|
|
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];
|
|
241
|
+
}
|
|
242
|
+
return self.debug.apply(self, [msg, {
|
|
243
|
+
process: process,
|
|
244
|
+
duration: getTime(),
|
|
245
|
+
totalTime: getFullTime()
|
|
246
|
+
}].concat(rest));
|
|
247
|
+
},
|
|
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];
|
|
251
|
+
}
|
|
252
|
+
return self.info.apply(self, [msg, {
|
|
253
|
+
process: process,
|
|
254
|
+
duration: getTime(),
|
|
255
|
+
totalTime: getFullTime()
|
|
256
|
+
}].concat(rest));
|
|
257
|
+
},
|
|
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];
|
|
261
|
+
}
|
|
262
|
+
return self.error.apply(self, [msg, {
|
|
263
|
+
process: process,
|
|
264
|
+
duration: getTime(),
|
|
265
|
+
totalTime: getFullTime()
|
|
266
|
+
}].concat(rest));
|
|
267
|
+
},
|
|
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];
|
|
271
|
+
}
|
|
272
|
+
return self.warning.apply(self, [msg, {
|
|
273
|
+
process: process,
|
|
274
|
+
duration: getTime(),
|
|
275
|
+
totalTime: getFullTime()
|
|
276
|
+
}].concat(rest));
|
|
277
|
+
},
|
|
278
|
+
end: function end() {
|
|
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];
|
|
282
|
+
}
|
|
283
|
+
return self.info.apply(self, [msg, {
|
|
284
|
+
process: process,
|
|
285
|
+
duration: getTime(),
|
|
286
|
+
totalTime: getFullTime()
|
|
287
|
+
}].concat(rest));
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
},
|
|
291
|
+
log: function log(msg, _ref4) {
|
|
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];
|
|
297
|
+
}
|
|
298
|
+
(_logger = logger()) === null || _logger === void 0 || _logger.log.apply(_logger, [msg, opts].concat(rest));
|
|
299
|
+
},
|
|
300
|
+
debug: function debug(msg, _ref5) {
|
|
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];
|
|
306
|
+
}
|
|
307
|
+
(_logger2 = logger()) === null || _logger2 === void 0 || _logger2.debug.apply(_logger2, [msg, opts].concat(rest));
|
|
308
|
+
},
|
|
309
|
+
info: function info(msg, _ref6) {
|
|
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];
|
|
315
|
+
}
|
|
316
|
+
(_logger3 = logger()) === null || _logger3 === void 0 || _logger3.info.apply(_logger3, [msg, opts].concat(rest));
|
|
317
|
+
},
|
|
318
|
+
error: function error(msg, _ref7) {
|
|
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];
|
|
324
|
+
}
|
|
325
|
+
(_logger4 = logger()) === null || _logger4 === void 0 || _logger4.error.apply(_logger4, [msg, opts].concat(rest));
|
|
326
|
+
},
|
|
327
|
+
warning: function warning(msg, _ref8) {
|
|
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];
|
|
333
|
+
}
|
|
334
|
+
(_logger5 = logger()) === null || _logger5 === void 0 || _logger5.warning.apply(_logger5, [msg, opts].concat(rest));
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
export { useLogger };
|
package/dist/esm/yup.js
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as _yup from 'yup';
|
|
4
|
+
export { _yup as yup };
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
* React Fabric
|
|
8
|
+
* @version: 1.0.0
|
|
9
|
+
*
|
|
10
|
+
*
|
|
11
|
+
* The MIT License (MIT)
|
|
12
|
+
* Copyright (c) 2024 Adarsh Pastakia
|
|
13
|
+
*
|
|
14
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
15
|
+
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
16
|
+
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
17
|
+
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
18
|
+
* subject to the following conditions:
|
|
19
|
+
*
|
|
20
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
21
|
+
* portions of the Software.
|
|
22
|
+
*
|
|
23
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
24
|
+
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
25
|
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
26
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
_yup.setLocale({
|
|
30
|
+
mixed: {
|
|
31
|
+
"default": function _default(_ref) {
|
|
32
|
+
var path = _ref.path,
|
|
33
|
+
label = _ref.label;
|
|
34
|
+
return {
|
|
35
|
+
key: "form:yup.invalid",
|
|
36
|
+
values: {
|
|
37
|
+
path: path,
|
|
38
|
+
label: label
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
required: function required(_ref2) {
|
|
43
|
+
var path = _ref2.path,
|
|
44
|
+
label = _ref2.label;
|
|
45
|
+
return {
|
|
46
|
+
key: "form:yup.required",
|
|
47
|
+
values: {
|
|
48
|
+
path: path,
|
|
49
|
+
label: label
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
notType: function notType(_ref3) {
|
|
54
|
+
var type = _ref3.type,
|
|
55
|
+
path = _ref3.path,
|
|
56
|
+
label = _ref3.label;
|
|
57
|
+
return {
|
|
58
|
+
key: "form:yup.invalidType",
|
|
59
|
+
values: {
|
|
60
|
+
type: type,
|
|
61
|
+
path: path,
|
|
62
|
+
label: label
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
array: {
|
|
68
|
+
min: function min(_ref4) {
|
|
69
|
+
var _min = _ref4.min,
|
|
70
|
+
path = _ref4.path,
|
|
71
|
+
label = _ref4.label;
|
|
72
|
+
return {
|
|
73
|
+
key: "form:yup.arrayMin",
|
|
74
|
+
values: {
|
|
75
|
+
min: _min,
|
|
76
|
+
path: path,
|
|
77
|
+
label: label
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
},
|
|
81
|
+
max: function max(_ref5) {
|
|
82
|
+
var _max = _ref5.max,
|
|
83
|
+
path = _ref5.path,
|
|
84
|
+
label = _ref5.label;
|
|
85
|
+
return {
|
|
86
|
+
key: "form:yup.arrayMax",
|
|
87
|
+
values: {
|
|
88
|
+
max: _max,
|
|
89
|
+
path: path,
|
|
90
|
+
label: label
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
string: {
|
|
96
|
+
min: function min(_ref6) {
|
|
97
|
+
var _min2 = _ref6.min,
|
|
98
|
+
path = _ref6.path,
|
|
99
|
+
label = _ref6.label;
|
|
100
|
+
return {
|
|
101
|
+
key: "form:yup.stringMin",
|
|
102
|
+
values: {
|
|
103
|
+
min: _min2,
|
|
104
|
+
path: path,
|
|
105
|
+
label: label
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
},
|
|
109
|
+
max: function max(_ref7) {
|
|
110
|
+
var _max2 = _ref7.max,
|
|
111
|
+
path = _ref7.path,
|
|
112
|
+
label = _ref7.label;
|
|
113
|
+
return {
|
|
114
|
+
key: "form:yup.stringMax",
|
|
115
|
+
values: {
|
|
116
|
+
max: _max2,
|
|
117
|
+
path: path,
|
|
118
|
+
label: label
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
number: {
|
|
124
|
+
min: function min(_ref8) {
|
|
125
|
+
var _min3 = _ref8.min,
|
|
126
|
+
path = _ref8.path,
|
|
127
|
+
label = _ref8.label;
|
|
128
|
+
return {
|
|
129
|
+
key: "form:yup.numberMin",
|
|
130
|
+
values: {
|
|
131
|
+
min: _min3,
|
|
132
|
+
path: path,
|
|
133
|
+
label: label
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
},
|
|
137
|
+
max: function max(_ref9) {
|
|
138
|
+
var _max3 = _ref9.max,
|
|
139
|
+
path = _ref9.path,
|
|
140
|
+
label = _ref9.label;
|
|
141
|
+
return {
|
|
142
|
+
key: "form:yup.numberMax",
|
|
143
|
+
values: {
|
|
144
|
+
max: _max3,
|
|
145
|
+
path: path,
|
|
146
|
+
label: label
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
"boolean": {}
|
|
152
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* box "x,y,w,h" | [x,y,w,h]
|
|
3
|
+
* returns canvas box [x,y,w,h]
|
|
4
|
+
*/
|
|
5
|
+
export declare const getBox: (box?: string | [number, number, number, number]) => [number, number, number, number];
|
|
6
|
+
/**
|
|
7
|
+
* box "x1,y1,x2,y2" | [x1,y1,x2,y2]
|
|
8
|
+
* returns canvas box [x,y,w,h]
|
|
9
|
+
*/
|
|
10
|
+
export declare const getBoundingBox: (box?: string | [number, number, number, number]) => [number, number, number, number];
|