@visulima/pail 4.0.0-alpha.2 → 4.0.0-alpha.21

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 (131) hide show
  1. package/CHANGELOG.md +371 -0
  2. package/LICENSE.md +148 -879
  3. package/README.md +323 -0
  4. package/dist/error.d.ts +103 -0
  5. package/dist/error.js +5 -0
  6. package/dist/index.browser.d.ts +557 -45
  7. package/dist/index.browser.js +19 -12
  8. package/dist/index.server.d.ts +724 -63
  9. package/dist/index.server.js +27 -529
  10. package/dist/middleware/elysia.d.ts +73 -0
  11. package/dist/middleware/elysia.js +1 -0
  12. package/dist/middleware/express.d.ts +88 -0
  13. package/dist/middleware/express.js +1 -0
  14. package/dist/middleware/fastify.d.ts +83 -0
  15. package/dist/middleware/fastify.js +1 -0
  16. package/dist/middleware/hono.d.ts +87 -0
  17. package/dist/middleware/hono.js +1 -0
  18. package/dist/middleware/next/handler.d.ts +103 -0
  19. package/dist/middleware/next/handler.js +1 -0
  20. package/dist/middleware/sveltekit.d.ts +125 -0
  21. package/dist/middleware/sveltekit.js +1 -0
  22. package/dist/object-tree.d.ts +67 -70
  23. package/dist/object-tree.js +2 -89
  24. package/dist/packem_shared/AbstractJsonReporter-CF0KKdQS.js +1 -0
  25. package/dist/packem_shared/AbstractJsonReporter-CVwjgboT.js +1 -0
  26. package/dist/packem_shared/JsonReporter-BJFnahby.js +1 -0
  27. package/dist/packem_shared/JsonReporter-CnLM-d0U.js +2 -0
  28. package/dist/packem_shared/PrettyReporter-D75CJT0C.js +5 -0
  29. package/dist/packem_shared/PrettyReporter-D9aBMmxI.js +45 -0
  30. package/dist/packem_shared/abstract-json-reporter.d-Boj5w068.d.ts +61 -0
  31. package/dist/packem_shared/abstract-pretty-reporter-zijeSUgy.js +34 -0
  32. package/dist/packem_shared/constants-DKfCaSUR.js +1 -0
  33. package/dist/packem_shared/constants-ep2nsfdy.js +1 -0
  34. package/dist/packem_shared/create-middleware-logger.d-MK7moe4r.d.ts +47 -0
  35. package/dist/packem_shared/createPailError-CbU1Ogfa.js +5 -0
  36. package/dist/packem_shared/headers-D-K_EnkH.js +1 -0
  37. package/dist/packem_shared/index-COQEZODZ.js +1 -0
  38. package/dist/packem_shared/pailMiddleware-B5DJoBYl.js +1 -0
  39. package/dist/packem_shared/storage-DaXAlpiO.js +1 -0
  40. package/dist/packem_shared/types.d-Ck_RSjLg.d.ts +246 -0
  41. package/dist/packem_shared/types.d-Cz9S7jZh.d.ts +201 -0
  42. package/dist/packem_shared/types.d-xxE3FOD3.d.ts +229 -0
  43. package/dist/packem_shared/useLogger-DB34CuU5.js +1 -0
  44. package/dist/packem_shared/wide-event.d-DkYD7YVK.d.ts +705 -0
  45. package/dist/packem_shared/write-console-log-based-on-level-DDSKGBKj.js +1 -0
  46. package/dist/packem_shared/write-stream-B6BXco86.js +1 -0
  47. package/dist/processor/caller/caller-processor.d.ts +49 -47
  48. package/dist/processor/caller/caller-processor.js +1 -59
  49. package/dist/processor/environment-processor.d.ts +124 -0
  50. package/dist/processor/environment-processor.js +1 -0
  51. package/dist/processor/message-formatter-processor.d.ts +51 -50
  52. package/dist/processor/message-formatter-processor.js +1 -66
  53. package/dist/processor/opentelemetry-processor.d.ts +69 -66
  54. package/dist/processor/opentelemetry-processor.js +1 -52
  55. package/dist/processor/redact-processor.d.ts +60 -41
  56. package/dist/processor/redact-processor.js +1 -30
  57. package/dist/processor/sampling-processor.d.ts +112 -0
  58. package/dist/processor/sampling-processor.js +1 -0
  59. package/dist/reporter/file/json-file-reporter.d.ts +91 -42
  60. package/dist/reporter/file/json-file-reporter.js +2 -136
  61. package/dist/reporter/http/abstract-http-reporter.d.ts +213 -211
  62. package/dist/reporter/http/abstract-http-reporter.js +2 -435
  63. package/dist/reporter/http/http-reporter.d.ts +40 -36
  64. package/dist/reporter/http/http-reporter.edge-light.d.ts +430 -38
  65. package/dist/reporter/http/http-reporter.edge-light.js +2 -651
  66. package/dist/reporter/http/http-reporter.js +1 -13
  67. package/dist/reporter/json/index.browser.d.ts +98 -3
  68. package/dist/reporter/json/index.browser.js +1 -2
  69. package/dist/reporter/json/index.d.ts +51 -3
  70. package/dist/reporter/json/index.js +1 -2
  71. package/dist/reporter/pretty/index.browser.d.ts +105 -2
  72. package/dist/reporter/pretty/index.browser.js +1 -1
  73. package/dist/reporter/pretty/index.d.ts +183 -2
  74. package/dist/reporter/pretty/index.js +1 -1
  75. package/dist/reporter/simple/simple-reporter.server.d.ts +133 -18
  76. package/dist/reporter/simple/simple-reporter.server.js +8 -186
  77. package/dist/wide-event.d.ts +5 -0
  78. package/dist/wide-event.js +1 -0
  79. package/package.json +87 -37
  80. package/dist/constants.d.ts +0 -37
  81. package/dist/interactive/index.d.ts +0 -2
  82. package/dist/interactive/index.js +0 -2
  83. package/dist/interactive/interactive-manager.d.ts +0 -108
  84. package/dist/interactive/interactive-stream-hook.d.ts +0 -68
  85. package/dist/packem_shared/AbstractJsonReporter-BaZ33PlE.js +0 -204
  86. package/dist/packem_shared/InteractiveManager-CbE7d1kY.js +0 -172
  87. package/dist/packem_shared/InteractiveStreamHook-DiSubbJ1.js +0 -21
  88. package/dist/packem_shared/JsonReporter-BRw4skd5.js +0 -28
  89. package/dist/packem_shared/JsonReporter-VzgyLEYz.js +0 -58
  90. package/dist/packem_shared/PrettyReporter-C2wVB7yu.js +0 -222
  91. package/dist/packem_shared/PrettyReporter-DySIXBjQ.js +0 -169
  92. package/dist/packem_shared/abstract-pretty-reporter-Di_sdm2r.js +0 -50
  93. package/dist/packem_shared/constants-omsTHUWB.js +0 -119
  94. package/dist/packem_shared/format-label-De49vNPd.js +0 -1193
  95. package/dist/packem_shared/get-longest-label-C9PWeyKq.js +0 -9
  96. package/dist/packem_shared/index-BomQ3E6J.js +0 -650
  97. package/dist/packem_shared/index-EZ_WSQZS.js +0 -1146
  98. package/dist/packem_shared/interactive-stream-hook-DG4BtN12.js +0 -141
  99. package/dist/packem_shared/pail.browser-u2CSR_af.js +0 -1427
  100. package/dist/packem_shared/write-console-log-based-on-level-DBmRYXpj.js +0 -14
  101. package/dist/packem_shared/write-stream-BG8fhcs3.js +0 -6
  102. package/dist/pail.browser.d.ts +0 -412
  103. package/dist/pail.server.d.ts +0 -233
  104. package/dist/processor/caller/get-caller-filename.d.ts +0 -23
  105. package/dist/progress-bar.d.ts +0 -136
  106. package/dist/progress-bar.js +0 -404
  107. package/dist/reporter/file/utils/rotating-file-stream.d.ts +0 -48
  108. package/dist/reporter/http/utils/compression.d.ts +0 -7
  109. package/dist/reporter/http/utils/log-size-error.d.ts +0 -30
  110. package/dist/reporter/http/utils/retry.d.ts +0 -27
  111. package/dist/reporter/json/abstract-json-reporter.d.ts +0 -61
  112. package/dist/reporter/json/json-reporter.browser.d.ts +0 -40
  113. package/dist/reporter/json/json-reporter.server.d.ts +0 -50
  114. package/dist/reporter/pretty/abstract-pretty-reporter.d.ts +0 -83
  115. package/dist/reporter/pretty/pretty-reporter.browser.d.ts +0 -36
  116. package/dist/reporter/pretty/pretty-reporter.server.d.ts +0 -70
  117. package/dist/reporter/raw/raw-reporter.browser.d.ts +0 -5
  118. package/dist/reporter/raw/raw-reporter.server.d.ts +0 -13
  119. package/dist/reporter/utils/default-inspector-config.d.ts +0 -3
  120. package/dist/reporter/utils/format-label.d.ts +0 -3
  121. package/dist/spinner.d.ts +0 -220
  122. package/dist/spinner.js +0 -2150
  123. package/dist/types.d.ts +0 -241
  124. package/dist/utils/ansi-escapes.d.ts +0 -4
  125. package/dist/utils/arrayify.d.ts +0 -2
  126. package/dist/utils/get-longest-badge.d.ts +0 -4
  127. package/dist/utils/get-longest-label.d.ts +0 -4
  128. package/dist/utils/merge-types.d.ts +0 -4
  129. package/dist/utils/stream/safe-stream-handler.d.ts +0 -21
  130. package/dist/utils/write-console-log-based-on-level.d.ts +0 -4
  131. package/dist/utils/write-stream.d.ts +0 -2
@@ -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 };