@visulima/pail 4.0.0-alpha.1 → 4.0.0-alpha.11

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 (91) hide show
  1. package/CHANGELOG.md +204 -0
  2. package/LICENSE.md +434 -52
  3. package/README.md +323 -0
  4. package/dist/error.d.ts +104 -0
  5. package/dist/error.js +76 -0
  6. package/dist/index.browser.d.ts +3 -1
  7. package/dist/index.browser.js +1490 -3
  8. package/dist/index.server.d.ts +3 -5
  9. package/dist/index.server.js +2380 -110
  10. package/dist/middleware/elysia.d.ts +71 -0
  11. package/dist/middleware/elysia.js +70 -0
  12. package/dist/middleware/express.d.ts +86 -0
  13. package/dist/middleware/express.js +29 -0
  14. package/dist/middleware/fastify.d.ts +81 -0
  15. package/dist/middleware/fastify.js +46 -0
  16. package/dist/middleware/hono.d.ts +85 -0
  17. package/dist/middleware/hono.js +33 -0
  18. package/dist/middleware/next/handler.d.ts +36 -0
  19. package/dist/middleware/next/handler.js +53 -0
  20. package/dist/middleware/next/middleware.d.ts +59 -0
  21. package/dist/middleware/next/storage.d.ts +14 -0
  22. package/dist/middleware/shared/create-middleware-logger.d.ts +82 -0
  23. package/dist/middleware/shared/headers.d.ts +14 -0
  24. package/dist/middleware/shared/routes.d.ts +30 -0
  25. package/dist/middleware/shared/storage.d.ts +29 -0
  26. package/dist/middleware/sveltekit.d.ts +123 -0
  27. package/dist/middleware/sveltekit.js +43 -0
  28. package/dist/object-tree.d.ts +2 -2
  29. package/dist/object-tree.js +7 -7
  30. package/dist/packem_shared/{AbstractJsonReporter-BaZ33PlE.js → AbstractJsonReporter-BO8Calb4.js} +112 -32
  31. package/dist/packem_shared/AbstractJsonReporter-nOj0Ft1F.js +284 -0
  32. package/dist/packem_shared/{JsonReporter-BRw4skd5.js → JsonReporter-CCmj7oYL.js} +2 -2
  33. package/dist/packem_shared/{JsonReporter-VzgyLEYz.js → JsonReporter-Ck2PIAEw.js} +2 -2
  34. package/dist/packem_shared/PrettyReporter-BCvyNzXO.js +2720 -0
  35. package/dist/packem_shared/{PrettyReporter-DySIXBjQ.js → PrettyReporter-BtTr13Ha.js} +55 -11
  36. package/dist/packem_shared/abstract-pretty-reporter-CXAKYCb8.js +2635 -0
  37. package/dist/packem_shared/constants-B1RjD_ps.js +99 -0
  38. package/dist/packem_shared/createPailError-B_sgL0nF.js +76 -0
  39. package/dist/packem_shared/headers-BxHWM6KI.js +127 -0
  40. package/dist/packem_shared/{index-BomQ3E6J.js → index-Bx3-C0j9.js} +29 -21
  41. package/dist/packem_shared/pailMiddleware-Ci88geIF.js +24 -0
  42. package/dist/packem_shared/storage-D0vqz8OX.js +36 -0
  43. package/dist/packem_shared/{InteractiveStreamHook-DiSubbJ1.js → useLogger-D0rU3lcX.js} +13 -1
  44. package/dist/packem_shared/{write-console-log-based-on-level-DBmRYXpj.js → write-console-log-based-on-level-ree2lDPw.js} +5 -4
  45. package/dist/packem_shared/{write-stream-BG8fhcs3.js → write-stream-MDqyXmc_.js} +1 -1
  46. package/dist/pail.browser.d.ts +1 -1
  47. package/dist/pail.server.d.ts +1 -76
  48. package/dist/processor/caller/caller-processor.js +1 -1
  49. package/dist/processor/environment-processor.d.ts +124 -0
  50. package/dist/processor/environment-processor.js +89 -0
  51. package/dist/processor/message-formatter-processor.d.ts +2 -3
  52. package/dist/processor/message-formatter-processor.js +654 -5
  53. package/dist/processor/opentelemetry-processor.js +4 -4
  54. package/dist/processor/redact-processor.d.ts +1 -1
  55. package/dist/processor/redact-processor.js +2 -1
  56. package/dist/processor/sampling-processor.d.ts +111 -0
  57. package/dist/processor/sampling-processor.js +59 -0
  58. package/dist/reporter/file/json-file-reporter.js +1 -1
  59. package/dist/reporter/http/abstract-http-reporter.js +23 -26
  60. package/dist/reporter/http/http-reporter.edge-light.js +134 -57
  61. package/dist/reporter/json/abstract-json-reporter.d.ts +1 -1
  62. package/dist/reporter/json/index.browser.js +2 -2
  63. package/dist/reporter/json/index.js +2 -2
  64. package/dist/reporter/pretty/index.browser.js +1 -1
  65. package/dist/reporter/pretty/index.js +1 -1
  66. package/dist/reporter/pretty/pretty-reporter.server.d.ts +1 -1
  67. package/dist/reporter/raw/raw-reporter.server.d.ts +1 -1
  68. package/dist/reporter/simple/simple-reporter.server.d.ts +1 -1
  69. package/dist/reporter/simple/simple-reporter.server.js +8 -12
  70. package/dist/types.d.ts +4 -4
  71. package/dist/utils/write-console-log-based-on-level.d.ts +1 -1
  72. package/dist/wide-event.d.ts +300 -0
  73. package/dist/wide-event.js +284 -0
  74. package/package.json +73 -20
  75. package/dist/interactive/index.d.ts +0 -2
  76. package/dist/interactive/index.js +0 -2
  77. package/dist/interactive/interactive-manager.d.ts +0 -108
  78. package/dist/interactive/interactive-stream-hook.d.ts +0 -68
  79. package/dist/packem_shared/InteractiveManager-CZ85hGNW.js +0 -172
  80. package/dist/packem_shared/PrettyReporter-DgZB2eBG.js +0 -222
  81. package/dist/packem_shared/abstract-pretty-reporter-Di_sdm2r.js +0 -50
  82. package/dist/packem_shared/format-label-De49vNPd.js +0 -1193
  83. package/dist/packem_shared/get-longest-label-C9PWeyKq.js +0 -9
  84. package/dist/packem_shared/index-DqKWykfa.js +0 -1146
  85. package/dist/packem_shared/interactive-stream-hook-DG4BtN12.js +0 -141
  86. package/dist/packem_shared/pail.browser-u2CSR_af.js +0 -1427
  87. package/dist/progress-bar.d.ts +0 -136
  88. package/dist/progress-bar.js +0 -404
  89. package/dist/spinner.d.ts +0 -220
  90. package/dist/spinner.js +0 -2150
  91. package/dist/utils/ansi-escapes.d.ts +0 -4
@@ -1,141 +0,0 @@
1
- import { createRequire as __cjs_createRequire } from "node:module";
2
-
3
- const __cjs_require = __cjs_createRequire(import.meta.url);
4
-
5
- const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
6
-
7
- const __cjs_getBuiltinModule = (module) => {
8
- // Check if we're in Node.js and version supports getBuiltinModule
9
- if (typeof __cjs_getProcess !== "undefined" && __cjs_getProcess.versions && __cjs_getProcess.versions.node) {
10
- const [major, minor] = __cjs_getProcess.versions.node.split(".").map(Number);
11
- // Node.js 20.16.0+ and 22.3.0+
12
- if (major > 22 || (major === 22 && minor >= 3) || (major === 20 && minor >= 16)) {
13
- return __cjs_getProcess.getBuiltinModule(module);
14
- }
15
- }
16
- // Fallback to createRequire
17
- return __cjs_require(module);
18
- };
19
-
20
- const {
21
- StringDecoder
22
- } = __cjs_getBuiltinModule("node:string_decoder");
23
-
24
- const ESC = "\x1B[";
25
- const eraseScreen = `${ESC}2J`;
26
- const eraseLine = `${ESC}2K`;
27
- const cursorLeft = `${ESC}G`;
28
- const cursorUp = (count = 1) => `${ESC + count}A`;
29
- const clearTerminal = process.platform === "win32" ? `${eraseScreen}${ESC}0f` : (
30
- // 1. Erases the screen (Only done in case `2` is not supported)
31
- // 2. Erases the whole screen including scrollback buffer
32
- // 3. Moves cursor to the top-left position
33
- // More info: https://www.real-world-systems.com/docs/ANSIcode.html
34
- `${eraseScreen}${ESC}3J${ESC}H`
35
- );
36
- const cursorHide = `${ESC}?25l`;
37
- const cursorShow = `${ESC}?25h`;
38
- const eraseLines = (count) => {
39
- let clear = "";
40
- for (let index = 0; index < count; index++) {
41
- clear += eraseLine + (index < count - 1 ? cursorUp() : "");
42
- }
43
- if (count) {
44
- clear += cursorLeft;
45
- }
46
- return clear;
47
- };
48
-
49
- class InteractiveStreamHook {
50
- /** Constant indicating the stream write operation was successful */
51
- static DRAIN = true;
52
- #decoder = new StringDecoder();
53
- #history = [];
54
- #method;
55
- #stream;
56
- /**
57
- * Creates a new InteractiveStreamHook for the given stream.
58
- * @param stream The Node.js WriteStream to hook into (usually stdout or stderr)
59
- */
60
- constructor(stream) {
61
- this.#method = stream.write;
62
- this.#stream = stream;
63
- }
64
- /**
65
- * Activates the stream hook.
66
- *
67
- * When active, all writes to the stream are captured in history instead of
68
- * being written immediately. This allows for interactive features like
69
- * progress bars that can update dynamically.
70
- */
71
- active() {
72
- this.write(cursorHide);
73
- this.#stream.write = (data, ...arguments_) => {
74
- const callback = arguments_.at(-1);
75
- this.#history.push(
76
- // prettier-ignore
77
- this.#decoder.write(
78
- typeof data === "string" ? Buffer.from(data, typeof arguments_[0] === "string" ? arguments_[0] : void 0) : Buffer.from(data)
79
- )
80
- );
81
- if (typeof callback === "function") {
82
- callback();
83
- }
84
- return InteractiveStreamHook.DRAIN;
85
- };
86
- }
87
- /**
88
- * Erases the specified number of lines from the terminal.
89
- *
90
- * Uses ANSI escape sequences to remove lines from the current cursor position
91
- * upwards, which is useful for clearing previous output in interactive applications.
92
- * @param count Number of lines to erase (including the current line)
93
- */
94
- erase(count) {
95
- if (count > 0) {
96
- this.write(eraseLines(count + 1));
97
- }
98
- }
99
- /**
100
- * Deactivates the stream hook and replays captured output.
101
- *
102
- * Restores normal stream operation and outputs all captured history.
103
- * Optionally adds a newline separator before replaying the history.
104
- * @param separateHistory Whether to add a newline before replaying history
105
- */
106
- inactive(separateHistory = false) {
107
- if (this.#history.length > 0) {
108
- if (separateHistory) {
109
- this.write("\n");
110
- }
111
- this.#history.forEach((element) => {
112
- this.write(element);
113
- });
114
- this.#history = [];
115
- }
116
- this.renew();
117
- }
118
- /**
119
- * Renews the stream hook state.
120
- *
121
- * Restores the original stream write method and shows the cursor.
122
- * This is typically called when temporarily suspending interactive mode.
123
- */
124
- renew() {
125
- this.#stream.write = this.#method;
126
- this.write(cursorShow);
127
- }
128
- /**
129
- * Writes a message directly to the underlying stream.
130
- *
131
- * Bypasses the hook mechanism and writes directly using the original
132
- * stream write method. Useful for writing control sequences or
133
- * messages that should not be captured in history.
134
- * @param message The message to write to the stream
135
- */
136
- write(message) {
137
- this.#method.apply(this.#stream, [message]);
138
- }
139
- }
140
-
141
- export { InteractiveStreamHook as I, clearTerminal as c };