@design-edito/tools 0.1.27 → 0.1.28

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. package/agnostic/css/bem/index.js +2 -2
  2. package/agnostic/css/index.js +10 -10
  3. package/agnostic/errors/index.js +2 -2
  4. package/agnostic/html/hyper-json/cast/index.js +3 -3
  5. package/agnostic/html/hyper-json/index.js +4 -4
  6. package/agnostic/html/hyper-json/transformers/append/index.js +3 -3
  7. package/agnostic/html/hyper-json/transformers/classList/index.js +3 -3
  8. package/agnostic/html/hyper-json/transformers/index.js +3 -3
  9. package/agnostic/html/hyper-json/transformers/join/index.js +3 -3
  10. package/agnostic/html/hyper-json/transformers/length/index.js +3 -3
  11. package/agnostic/html/hyper-json/transformers/print/index.js +3 -3
  12. package/agnostic/html/hyper-json/transformers/push/index.js +3 -3
  13. package/agnostic/html/hyper-json/transformers/querySelector/index.js +3 -3
  14. package/agnostic/html/hyper-json/transformers/ref/index.js +3 -3
  15. package/agnostic/html/hyper-json/transformers/replace/index.js +3 -3
  16. package/agnostic/html/hyper-json/transformers/split/index.js +3 -3
  17. package/agnostic/html/hyper-json/transformers/toArray/index.js +3 -3
  18. package/agnostic/html/hyper-json/transformers/toBoolean/index.js +3 -3
  19. package/agnostic/html/hyper-json/transformers/toElement/index.js +3 -3
  20. package/agnostic/html/hyper-json/transformers/toNodeList/index.js +3 -3
  21. package/agnostic/html/hyper-json/transformers/toNull/index.js +3 -3
  22. package/agnostic/html/hyper-json/transformers/toNumber/index.js +3 -3
  23. package/agnostic/html/hyper-json/transformers/toRecord/index.js +3 -3
  24. package/agnostic/html/hyper-json/transformers/toRef/index.js +3 -3
  25. package/agnostic/html/hyper-json/transformers/toString/index.js +3 -3
  26. package/agnostic/html/hyper-json/transformers/toText/index.js +3 -3
  27. package/agnostic/html/hyper-json/transformers/toTransformer/index.js +3 -3
  28. package/agnostic/html/hyper-json/transformers/transformSelected/index.js +3 -3
  29. package/agnostic/html/hyper-json/transformers/trim/index.js +3 -3
  30. package/agnostic/html/hyper-json/tree/index.js +3 -3
  31. package/agnostic/html/hyper-json/utils/index.js +3 -3
  32. package/agnostic/html/index.js +19 -19
  33. package/agnostic/html/sanitize/index.js +4 -4
  34. package/agnostic/html/selector-to-element/index.js +4 -4
  35. package/agnostic/html/string-to-nodes/index.js +5 -5
  36. package/agnostic/misc/index.js +19 -16
  37. package/agnostic/misc/logs/index.d.ts +5 -44
  38. package/agnostic/misc/logs/index.js +4 -1
  39. package/agnostic/misc/logs/logger/index.d.ts +42 -0
  40. package/agnostic/misc/logs/logger/index.js +6 -0
  41. package/agnostic/misc/logs/make-text-block/index.d.ts +1 -0
  42. package/agnostic/misc/logs/make-text-block/index.js +6 -0
  43. package/agnostic/misc/logs/styles/index.d.ts +11 -0
  44. package/agnostic/misc/logs/styles/index.js +7 -0
  45. package/agnostic/misc/lorem-ipsum/index.js +3 -3
  46. package/agnostic/numbers/index.js +3 -3
  47. package/agnostic/objects/index.js +7 -7
  48. package/agnostic/strings/index.js +10 -10
  49. package/agnostic/time/index.js +3 -3
  50. package/chunks/chunk-B2O7PFSF.js +1108 -0
  51. package/chunks/chunk-BEJSITDG.js +31 -0
  52. package/chunks/chunk-H4PP6AHP.js +15 -0
  53. package/chunks/chunk-JWKI6G6E.js +102 -0
  54. package/chunks/chunk-L3OCRR3V.js +25 -0
  55. package/chunks/chunk-TEB7KZWB.js +21 -0
  56. package/node/files/index.js +4 -4
  57. 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,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
+ };
@@ -0,0 +1,21 @@
1
+ import {
2
+ Logger
3
+ } from "./chunk-JWKI6G6E.js";
4
+ import {
5
+ styles
6
+ } from "./chunk-L3OCRR3V.js";
7
+ import {
8
+ makeTextBlock
9
+ } from "./chunk-H4PP6AHP.js";
10
+
11
+ // src/agnostic/misc/logs/index.ts
12
+ var Logs;
13
+ ((Logs2) => {
14
+ Logs2.makeTextBlock = makeTextBlock;
15
+ Logs2.styles = styles;
16
+ Logs2.Logger = Logger;
17
+ })(Logs || (Logs = {}));
18
+
19
+ export {
20
+ Logs
21
+ };
@@ -1,12 +1,12 @@
1
1
  import {
2
- isInDirectory
3
- } from "../../chunks/chunk-NRITRUZW.js";
2
+ Subpaths
3
+ } from "../../chunks/chunk-HGCG2J77.js";
4
4
  import {
5
5
  readWrite
6
6
  } from "../../chunks/chunk-7DBNMU6N.js";
7
7
  import {
8
- Subpaths
9
- } from "../../chunks/chunk-HGCG2J77.js";
8
+ isInDirectory
9
+ } from "../../chunks/chunk-NRITRUZW.js";
10
10
  import "../../chunks/chunk-LQFKUNVQ.js";
11
11
 
12
12
  // src/node/files/index.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@design-edito/tools",
3
- "version": "0.1.27",
3
+ "version": "0.1.28",
4
4
  "description": "",
5
5
  "author": "Maxime Fabas",
6
6
  "license": "ISC",