@design-edito/tools 0.1.27 → 0.1.29

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. package/agnostic/css/bem/index.js +2 -2
  2. package/agnostic/css/index.js +12 -9
  3. package/agnostic/html/hyper-json/cast/index.js +2 -2
  4. package/agnostic/html/hyper-json/index.js +3 -3
  5. package/agnostic/html/hyper-json/transformers/append/index.js +2 -2
  6. package/agnostic/html/hyper-json/transformers/classList/index.js +2 -2
  7. package/agnostic/html/hyper-json/transformers/index.js +2 -2
  8. package/agnostic/html/hyper-json/transformers/join/index.js +2 -2
  9. package/agnostic/html/hyper-json/transformers/length/index.js +2 -2
  10. package/agnostic/html/hyper-json/transformers/print/index.js +2 -2
  11. package/agnostic/html/hyper-json/transformers/push/index.js +2 -2
  12. package/agnostic/html/hyper-json/transformers/querySelector/index.js +2 -2
  13. package/agnostic/html/hyper-json/transformers/ref/index.js +2 -2
  14. package/agnostic/html/hyper-json/transformers/replace/index.js +2 -2
  15. package/agnostic/html/hyper-json/transformers/split/index.js +2 -2
  16. package/agnostic/html/hyper-json/transformers/toArray/index.js +2 -2
  17. package/agnostic/html/hyper-json/transformers/toBoolean/index.js +2 -2
  18. package/agnostic/html/hyper-json/transformers/toElement/index.js +2 -2
  19. package/agnostic/html/hyper-json/transformers/toNodeList/index.js +2 -2
  20. package/agnostic/html/hyper-json/transformers/toNull/index.js +2 -2
  21. package/agnostic/html/hyper-json/transformers/toNumber/index.js +2 -2
  22. package/agnostic/html/hyper-json/transformers/toRecord/index.js +2 -2
  23. package/agnostic/html/hyper-json/transformers/toRef/index.js +2 -2
  24. package/agnostic/html/hyper-json/transformers/toString/index.js +2 -2
  25. package/agnostic/html/hyper-json/transformers/toText/index.js +2 -2
  26. package/agnostic/html/hyper-json/transformers/toTransformer/index.js +2 -2
  27. package/agnostic/html/hyper-json/transformers/transformSelected/index.js +2 -2
  28. package/agnostic/html/hyper-json/transformers/trim/index.js +2 -2
  29. package/agnostic/html/hyper-json/tree/index.js +2 -2
  30. package/agnostic/html/hyper-json/utils/index.js +2 -2
  31. package/agnostic/html/index.js +12 -12
  32. package/agnostic/misc/index.js +20 -14
  33. package/agnostic/misc/logs/index.d.ts +5 -44
  34. package/agnostic/misc/logs/index.js +4 -1
  35. package/agnostic/misc/logs/logger/index.d.ts +42 -0
  36. package/agnostic/misc/logs/logger/index.js +6 -0
  37. package/agnostic/misc/logs/make-text-block/index.d.ts +1 -0
  38. package/agnostic/misc/logs/make-text-block/index.js +6 -0
  39. package/agnostic/misc/logs/styles/index.d.ts +11 -0
  40. package/agnostic/misc/logs/styles/index.js +7 -0
  41. package/agnostic/misc/lorem-ipsum/index.js +7 -4
  42. package/agnostic/numbers/index.js +3 -3
  43. package/agnostic/objects/index.js +10 -10
  44. package/agnostic/optim/index.js +3 -3
  45. package/agnostic/random/hex-char/index.d.ts +2 -0
  46. package/agnostic/random/hex-char/index.js +8 -0
  47. package/agnostic/random/index.d.ts +9 -7
  48. package/agnostic/random/index.js +4 -1
  49. package/agnostic/random/random/index.d.ts +3 -0
  50. package/agnostic/random/random/index.js +8 -0
  51. package/agnostic/random/uuid/index.d.ts +3 -0
  52. package/agnostic/random/uuid/index.js +11 -0
  53. package/agnostic/strings/index.js +7 -7
  54. package/agnostic/time/index.js +3 -3
  55. package/chunks/chunk-75BICI4L.js +20 -0
  56. package/chunks/chunk-B2O7PFSF.js +1108 -0
  57. package/chunks/chunk-BEJSITDG.js +31 -0
  58. package/chunks/chunk-D3ERTRDW.js +17 -0
  59. package/chunks/chunk-H4PP6AHP.js +15 -0
  60. package/chunks/chunk-JWKI6G6E.js +102 -0
  61. package/chunks/chunk-L3OCRR3V.js +25 -0
  62. package/chunks/chunk-LFUY5AWK.js +1108 -0
  63. package/chunks/chunk-OGBUSUE6.js +12 -0
  64. package/chunks/chunk-PXB7U2DH.js +31 -0
  65. package/chunks/chunk-S32K7POB.js +29 -0
  66. package/chunks/chunk-S7MJLTCR.js +211 -0
  67. package/chunks/chunk-TEB7KZWB.js +21 -0
  68. package/node/files/index.js +3 -3
  69. package/package.json +1 -1
@@ -0,0 +1,31 @@
1
+ import {
2
+ Cast,
3
+ Transformers,
4
+ Tree,
5
+ Utils
6
+ } from "./chunk-B2O7PFSF.js";
7
+ import {
8
+ Types
9
+ } from "./chunk-5GI5G45R.js";
10
+ import {
11
+ Serialize
12
+ } from "./chunk-DRNK3RLE.js";
13
+ import {
14
+ Crossenv
15
+ } from "./chunk-3LVR6KZH.js";
16
+
17
+ // src/agnostic/html/hyper-json/index.ts
18
+ var HyperJson;
19
+ ((HyperJson2) => {
20
+ HyperJson2.Cast = Cast;
21
+ HyperJson2.Crossenv = Crossenv;
22
+ HyperJson2.Serialize = Serialize;
23
+ HyperJson2.Transformers = Transformers;
24
+ HyperJson2.Tree = Tree;
25
+ HyperJson2.Types = Types;
26
+ HyperJson2.Utils = Utils;
27
+ })(HyperJson || (HyperJson = {}));
28
+
29
+ export {
30
+ HyperJson
31
+ };
@@ -0,0 +1,17 @@
1
+ // src/agnostic/random/random/index.ts
2
+ function random(bound1 = 1, bound2) {
3
+ const min = bound2 === void 0 ? 0 : bound1;
4
+ const max = bound2 === void 0 ? bound1 : bound2;
5
+ if (min === max || min > max) return void 0;
6
+ const range = max - min;
7
+ return Math.random() * range + min;
8
+ }
9
+ function randomInt(...args) {
10
+ const rand = random(...args);
11
+ return rand !== void 0 ? Math.floor(rand) : void 0;
12
+ }
13
+
14
+ export {
15
+ random,
16
+ randomInt
17
+ };
@@ -0,0 +1,15 @@
1
+ // src/agnostic/misc/logs/make-text-block/index.ts
2
+ function makeTextBlock(text, vPadding = 1, hPadding = vPadding) {
3
+ const lines = text.split("\n");
4
+ const longestLine = Math.max(...lines.map((line) => line.length));
5
+ const textBlockArr = new Array(lines.length + 2 * vPadding).fill(null).map(() => new Array(longestLine + hPadding * 2).fill(" "));
6
+ lines.forEach((line, linePos) => {
7
+ const chars = line.split("");
8
+ textBlockArr[linePos + vPadding]?.splice(hPadding, chars.length, ...chars);
9
+ });
10
+ return textBlockArr.map((lineArr) => lineArr.join("")).join("\n");
11
+ }
12
+
13
+ export {
14
+ makeTextBlock
15
+ };
@@ -0,0 +1,102 @@
1
+ // src/agnostic/misc/logs/logger/index.ts
2
+ var logsTimeOrigin = /* @__PURE__ */ new Date();
3
+ var Log = class {
4
+ type;
5
+ data;
6
+ time;
7
+ stack;
8
+ constructor(type, data) {
9
+ this.type = type;
10
+ this.data = data;
11
+ this.time = /* @__PURE__ */ new Date();
12
+ this.stack = new Error().stack ?? "";
13
+ }
14
+ get displayTime() {
15
+ return this.time.toLocaleDateString("en-US", {
16
+ year: "numeric",
17
+ month: "short",
18
+ day: "numeric",
19
+ weekday: "short",
20
+ hour: "numeric",
21
+ minute: "numeric",
22
+ second: "numeric"
23
+ }) + `:${this.time.getMilliseconds()}`;
24
+ }
25
+ get elapsedTimeMs() {
26
+ return (this.time.getTime() - logsTimeOrigin.getTime()) / 1e3;
27
+ }
28
+ get displayStack() {
29
+ return this.stack.split("\n").map((line) => line.trim()).slice(4).join("\n");
30
+ }
31
+ };
32
+ var Logger = class {
33
+ _private_threads = /* @__PURE__ */ new Map();
34
+ constructor() {
35
+ this.dir = this.dir.bind(this);
36
+ this.error = this.error.bind(this);
37
+ this.log = this.log.bind(this);
38
+ this.warn = this.warn.bind(this);
39
+ this.setLog = this.setLog.bind(this);
40
+ this.print = this.print.bind(this);
41
+ this.printThreads = this.printThreads.bind(this);
42
+ }
43
+ // assert (thread: string = '', ...args: ConsoleMethodsParams['assert']) { this.setLog(thread, 'assert', args) }
44
+ // count (thread: string = '', ...args: ConsoleMethodsParams['count']) { this.setLog(thread, 'count', args) }
45
+ // countReset (thread: string = '', ...args: ConsoleMethodsParams['countReset']) { this.setLog(thread, 'countReset', args) }
46
+ // debug (thread: string = '', ...args: ConsoleMethodsParams['debug']) { this.setLog(thread, 'debug', args) }
47
+ dir(thread = "", ...args) {
48
+ this.setLog(thread, "dir", args);
49
+ }
50
+ // dirxml (thread: string = '', ...args: ConsoleMethodsParams['dirxml']) { this.setLog(thread, 'dirxml', args) }
51
+ error(thread = "", ...args) {
52
+ this.setLog(thread, "error", args);
53
+ }
54
+ // group (thread: string = '', ...args: ConsoleMethodsParams['group']) { this.setLog(thread, 'group', args) }
55
+ // groupCollapsed (thread: string = '', ...args: ConsoleMethodsParams['groupCollapsed']) { this.setLog(thread, 'groupCollapsed', args) }
56
+ // groupEnd (thread: string = '', ...args: ConsoleMethodsParams['groupEnd']) { this.setLog(thread, 'groupEnd', args) }
57
+ // info (thread: string = '', ...args: ConsoleMethodsParams['info']) { this.setLog(thread, 'info', args) }
58
+ log(thread = "", ...args) {
59
+ this.setLog(thread, "log", args);
60
+ }
61
+ // table (thread: string = '', ...args: ConsoleMethodsParams['table']) { this.setLog(thread, 'table', args) }
62
+ // time (thread: string = '', ...args: ConsoleMethodsParams['time']) { this.setLog(thread, 'time', args) }
63
+ // timeEnd (thread: string = '', ...args: ConsoleMethodsParams['timeEnd']) { this.setLog(thread, 'timeEnd', args) }
64
+ // trace (thread: string = '', ...args: ConsoleMethodsParams['trace']) { this.setLog(thread, 'trace', args) }
65
+ warn(thread = "", ...args) {
66
+ this.setLog(thread, "warn", args);
67
+ }
68
+ setLog(threadName, type, data) {
69
+ const log = new Log(type, data);
70
+ const thread = this._private_threads.get(threadName) ?? [];
71
+ this._private_threads.set(threadName, [...thread, log]);
72
+ return this;
73
+ }
74
+ print(threadFilter, withStack) {
75
+ const allLogs = Array.from(this._private_threads.entries()).map(([threadName, logs]) => logs.map((log) => ({ threadName, log }))).flat().sort((eltA, eltB) => eltA.log.time.getTime() - eltB.log.time.getTime()).filter(({ threadName }) => {
76
+ if (threadFilter === void 0) return true;
77
+ return threadName === threadFilter;
78
+ });
79
+ allLogs.forEach(({ threadName, log }) => {
80
+ console.log(`%c${threadName}`, "font-weight: 800; color: white; background: black; padding: 4px;", `+${log.elapsedTimeMs}s \u2013`, log.displayTime);
81
+ if (withStack === true) console.log(`%c${log.displayStack}`, "color: grey; font-size: inherit;");
82
+ console[log.type](...log.data);
83
+ console.log("");
84
+ });
85
+ }
86
+ printThreads(withStack) {
87
+ Array.from(this._private_threads.entries()).forEach(([threadName, logs]) => {
88
+ console.group(`%c${threadName}`, "font-weight: 800; color: white; background: black; padding: 4px;");
89
+ logs.forEach((log) => {
90
+ console.log(`+${log.elapsedTimeMs}s \u2013`, log.displayTime);
91
+ if (withStack === true) console.log(`%c${log.displayStack}`, "color: grey; font-size: inherit;");
92
+ console[log.type](...log.data);
93
+ console.log("");
94
+ });
95
+ console.groupEnd();
96
+ });
97
+ }
98
+ };
99
+
100
+ export {
101
+ Logger
102
+ };
@@ -0,0 +1,25 @@
1
+ import {
2
+ makeTextBlock
3
+ } from "./chunk-H4PP6AHP.js";
4
+
5
+ // src/agnostic/misc/logs/styles/index.ts
6
+ import chalk from "chalk";
7
+ var styles = {
8
+ regular: (text) => text,
9
+ light: (text) => chalk.grey(text),
10
+ danger: (text) => chalk.bold.bgRed.whiteBright(makeTextBlock(`/!\\
11
+
12
+ ${text}
13
+ `, 2, 6)),
14
+ important: (text) => chalk.bold(text),
15
+ title: (text) => `# ${chalk.bold.underline(`${text}
16
+ `)}`,
17
+ info: (text) => chalk.blueBright(text),
18
+ success: (text) => chalk.greenBright(text),
19
+ error: (text) => chalk.red(text),
20
+ warning: (text) => chalk.yellow(text)
21
+ };
22
+
23
+ export {
24
+ styles
25
+ };