@browdacode/adonisjs-debugbar 0.0.0-stage → 1.0.1
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/CHANGELOG.md +31 -0
- package/LICENSE +21 -0
- package/README.md +187 -2
- package/build/configure.d.ts +3 -0
- package/build/configure.d.ts.map +1 -0
- package/build/configure.js +14 -0
- package/build/configure.js.map +1 -0
- package/build/index.d.ts +9 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +9 -0
- package/build/index.js.map +1 -0
- package/build/providers/debugbar_provider.d.ts +14 -0
- package/build/providers/debugbar_provider.d.ts.map +1 -0
- package/build/providers/debugbar_provider.js +177 -0
- package/build/providers/debugbar_provider.js.map +1 -0
- package/build/services/debugbar.d.ts +4 -0
- package/build/services/debugbar.d.ts.map +1 -0
- package/build/services/debugbar.js +7 -0
- package/build/services/debugbar.js.map +1 -0
- package/build/src/collectors/context_collectors.d.ts +21 -0
- package/build/src/collectors/context_collectors.d.ts.map +1 -0
- package/build/src/collectors/context_collectors.js +183 -0
- package/build/src/collectors/context_collectors.js.map +1 -0
- package/build/src/config.d.ts +8 -0
- package/build/src/config.d.ts.map +1 -0
- package/build/src/config.js +51 -0
- package/build/src/config.js.map +1 -0
- package/build/src/context/request_tracker.d.ts +34 -0
- package/build/src/context/request_tracker.d.ts.map +1 -0
- package/build/src/context/request_tracker.js +21 -0
- package/build/src/context/request_tracker.js.map +1 -0
- package/build/src/debugbar.d.ts +105 -0
- package/build/src/debugbar.d.ts.map +1 -0
- package/build/src/debugbar.js +606 -0
- package/build/src/debugbar.js.map +1 -0
- package/build/src/hooks/runtime_hooks.d.ts +37 -0
- package/build/src/hooks/runtime_hooks.d.ts.map +1 -0
- package/build/src/hooks/runtime_hooks.js +279 -0
- package/build/src/hooks/runtime_hooks.js.map +1 -0
- package/build/src/middleware/debugbar_middleware.d.ts +10 -0
- package/build/src/middleware/debugbar_middleware.d.ts.map +1 -0
- package/build/src/middleware/debugbar_middleware.js +114 -0
- package/build/src/middleware/debugbar_middleware.js.map +1 -0
- package/build/src/storage/file_storage.d.ts +21 -0
- package/build/src/storage/file_storage.d.ts.map +1 -0
- package/build/src/storage/file_storage.js +102 -0
- package/build/src/storage/file_storage.js.map +1 -0
- package/build/src/storage/memory_storage.d.ts +19 -0
- package/build/src/storage/memory_storage.d.ts.map +1 -0
- package/build/src/storage/memory_storage.js +75 -0
- package/build/src/storage/memory_storage.js.map +1 -0
- package/build/src/types.d.ts +282 -0
- package/build/src/types.d.ts.map +1 -0
- package/build/src/types.js +2 -0
- package/build/src/types.js.map +1 -0
- package/build/src/ui/render_script.d.ts +10 -0
- package/build/src/ui/render_script.d.ts.map +1 -0
- package/build/src/ui/render_script.js +990 -0
- package/build/src/ui/render_script.js.map +1 -0
- package/build/src/ui/styles.d.ts +5 -0
- package/build/src/ui/styles.d.ts.map +1 -0
- package/build/src/ui/styles.js +540 -0
- package/build/src/ui/styles.js.map +1 -0
- package/build/src/utils/mask.d.ts +19 -0
- package/build/src/utils/mask.d.ts.map +1 -0
- package/build/src/utils/mask.js +155 -0
- package/build/src/utils/mask.js.map +1 -0
- package/build/stubs/config/debugbar.stub +49 -0
- package/build/stubs/main.d.ts +2 -0
- package/build/stubs/main.d.ts.map +1 -0
- package/build/stubs/main.js +4 -0
- package/build/stubs/main.js.map +1 -0
- package/build/tests/debugbar.test.d.ts +2 -0
- package/build/tests/debugbar.test.d.ts.map +1 -0
- package/build/tests/debugbar.test.js +532 -0
- package/build/tests/debugbar.test.js.map +1 -0
- package/package.json +81 -4
- package/stubs/config/debugbar.stub +49 -0
- package/stubs/main.ts +4 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Debugbar } from '../debugbar.js';
|
|
2
|
+
import type { ViewKind } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Wraps an AdonisJS / Pino logger instance so logs emitted during an HTTP request
|
|
5
|
+
* are automatically captured in the active debugbar request context.
|
|
6
|
+
*/
|
|
7
|
+
export declare function hookLogger(logger: any, debugbar: Debugbar): void;
|
|
8
|
+
/**
|
|
9
|
+
* Classifies an Edge template path into layout, component, partial, or template.
|
|
10
|
+
* In AdonisJS 7 / Edge v6, `@layouts.*` are layouts and `@form`, `@field.root`,
|
|
11
|
+
* `@!button`, `@link`, etc. resolve to components/templates.
|
|
12
|
+
*/
|
|
13
|
+
export declare function classifyEdgeTemplate(templatePath: string): ViewKind;
|
|
14
|
+
/**
|
|
15
|
+
* Resolves the host AdonisJS application's `edge.js` singleton (from process.cwd())
|
|
16
|
+
* so we never hook a duplicate copy of edge.js.
|
|
17
|
+
*/
|
|
18
|
+
export declare function resolveHostEdge(): Promise<any | undefined>;
|
|
19
|
+
/**
|
|
20
|
+
* Hooks the global Edge instance (`import edge from 'edge.js'`) so all layouts,
|
|
21
|
+
* components, and partials are captured even when EdgeRenderer uses private fields.
|
|
22
|
+
*/
|
|
23
|
+
export declare function hookEdgeInstance(edgeInstance: any, debugbar: Debugbar): void;
|
|
24
|
+
/**
|
|
25
|
+
* Wraps `ctx.view` (EdgeRenderer) to capture rendered template names,
|
|
26
|
+
* explicit template state, and render duration (without Edge global helpers noise).
|
|
27
|
+
*/
|
|
28
|
+
export declare function hookEdgeView(view: any, debugbar: Debugbar): void;
|
|
29
|
+
/**
|
|
30
|
+
* Wraps `ctx.inertia` (if @adonisjs/inertia is installed) to capture rendered components & props.
|
|
31
|
+
*/
|
|
32
|
+
export declare function hookInertia(inertia: any, debugbar: Debugbar): void;
|
|
33
|
+
/**
|
|
34
|
+
* Extracts the first application-level stack frame (ignoring node internals, node_modules, and adonis-debugbar).
|
|
35
|
+
*/
|
|
36
|
+
export declare function extractAppCaller(): string | undefined;
|
|
37
|
+
//# sourceMappingURL=runtime_hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime_hooks.d.ts","sourceRoot":"","sources":["../../../src/hooks/runtime_hooks.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,KAAK,EAAY,QAAQ,EAAE,MAAM,aAAa,CAAA;AAkBrD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAuBhE;AA0BD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,MAAM,GAAG,QAAQ,CAMnE;AA6DD;;;GAGG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,GAAG,GAAG,SAAS,CAAC,CAahE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAe5E;AAYD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAwChE;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAqBlE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,SAAS,CAwBrD"}
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { pathToFileURL } from 'node:url';
|
|
4
|
+
const LOGGER_HOOKED = Symbol.for('adonis-debugbar.loggerHooked');
|
|
5
|
+
const VIEW_HOOKED = Symbol.for('adonis-debugbar.viewHooked');
|
|
6
|
+
const EDGE_HOOKED = Symbol.for('adonis-debugbar.edgeHooked');
|
|
7
|
+
const LOADER_HOOKED = Symbol.for('adonis-debugbar.loaderHooked');
|
|
8
|
+
const COMPILER_HOOKED = Symbol.for('adonis-debugbar.compilerHooked');
|
|
9
|
+
const INERTIA_HOOKED = Symbol.for('adonis-debugbar.inertiaHooked');
|
|
10
|
+
const LOG_LEVEL_MAP = {
|
|
11
|
+
trace: 'debug',
|
|
12
|
+
debug: 'debug',
|
|
13
|
+
info: 'info',
|
|
14
|
+
warn: 'warn',
|
|
15
|
+
error: 'error',
|
|
16
|
+
fatal: 'fatal',
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Wraps an AdonisJS / Pino logger instance so logs emitted during an HTTP request
|
|
20
|
+
* are automatically captured in the active debugbar request context.
|
|
21
|
+
*/
|
|
22
|
+
export function hookLogger(logger, debugbar) {
|
|
23
|
+
if (!logger || typeof logger !== 'object' || logger[LOGGER_HOOKED]) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
logger[LOGGER_HOOKED] = true;
|
|
27
|
+
for (const method of Object.keys(LOG_LEVEL_MAP)) {
|
|
28
|
+
const original = logger[method];
|
|
29
|
+
if (typeof original !== 'function')
|
|
30
|
+
continue;
|
|
31
|
+
logger[method] = function patchedLog(...args) {
|
|
32
|
+
try {
|
|
33
|
+
const level = LOG_LEVEL_MAP[method] ?? 'info';
|
|
34
|
+
const { message, context } = parsePinoArgs(args);
|
|
35
|
+
if (message) {
|
|
36
|
+
debugbar.log(level, message, context);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
// Never break host logging
|
|
41
|
+
}
|
|
42
|
+
return original.apply(this, args);
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function parsePinoArgs(args) {
|
|
47
|
+
if (args.length === 0)
|
|
48
|
+
return { message: '' };
|
|
49
|
+
const [first, second] = args;
|
|
50
|
+
if (typeof first === 'string') {
|
|
51
|
+
return {
|
|
52
|
+
message: first,
|
|
53
|
+
context: second && typeof second === 'object' ? second : undefined,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
if (first && typeof first === 'object') {
|
|
57
|
+
const obj = first;
|
|
58
|
+
const message = typeof second === 'string' ? second : String(obj.msg ?? obj.message ?? 'Log');
|
|
59
|
+
return {
|
|
60
|
+
message,
|
|
61
|
+
context: obj,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
return { message: String(first) };
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Classifies an Edge template path into layout, component, partial, or template.
|
|
68
|
+
* In AdonisJS 7 / Edge v6, `@layouts.*` are layouts and `@form`, `@field.root`,
|
|
69
|
+
* `@!button`, `@link`, etc. resolve to components/templates.
|
|
70
|
+
*/
|
|
71
|
+
export function classifyEdgeTemplate(templatePath) {
|
|
72
|
+
const normalized = templatePath.replace(/\\/g, '/').toLowerCase();
|
|
73
|
+
if (normalized.includes('layout'))
|
|
74
|
+
return 'layout';
|
|
75
|
+
if (normalized.includes('partial') || normalized.includes('include'))
|
|
76
|
+
return 'partial';
|
|
77
|
+
if (normalized.includes('component') || normalized.includes('template'))
|
|
78
|
+
return 'component';
|
|
79
|
+
return 'component';
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Wraps Edge's compiler (`asyncCompiler` / `compiler`) so cached layouts, components,
|
|
83
|
+
* and partials are still captured on every request.
|
|
84
|
+
*/
|
|
85
|
+
function hookEdgeCompiler(compiler, debugbar) {
|
|
86
|
+
if (!compiler || typeof compiler !== 'object' || compiler[COMPILER_HOOKED]) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
compiler[COMPILER_HOOKED] = true;
|
|
90
|
+
if (typeof compiler.compile === 'function') {
|
|
91
|
+
const originalCompile = compiler.compile;
|
|
92
|
+
compiler.compile = function patchedCompile(templatePath) {
|
|
93
|
+
const start = process.hrtime.bigint();
|
|
94
|
+
const result = originalCompile.apply(this, arguments);
|
|
95
|
+
try {
|
|
96
|
+
const durationMs = Math.round((Number(process.hrtime.bigint() - start) / 1_000_000) * 100) / 100;
|
|
97
|
+
const name = String(templatePath);
|
|
98
|
+
debugbar.recordView(name, undefined, durationMs, 'edge', classifyEdgeTemplate(name));
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
// Ignore hook errors
|
|
102
|
+
}
|
|
103
|
+
return result;
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Wraps Edge's loader.resolve so resolved disk paths are attached to views/components.
|
|
109
|
+
*/
|
|
110
|
+
function hookEdgeLoader(loader, debugbar) {
|
|
111
|
+
if (!loader || typeof loader !== 'object' || loader[LOADER_HOOKED]) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
loader[LOADER_HOOKED] = true;
|
|
115
|
+
if (typeof loader.resolve === 'function') {
|
|
116
|
+
const originalResolve = loader.resolve;
|
|
117
|
+
loader.resolve = function patchedResolve(templatePath) {
|
|
118
|
+
const start = process.hrtime.bigint();
|
|
119
|
+
const result = originalResolve.apply(this, arguments);
|
|
120
|
+
try {
|
|
121
|
+
const durationMs = Math.round((Number(process.hrtime.bigint() - start) / 1_000_000) * 100) / 100;
|
|
122
|
+
const rawPath = String(templatePath);
|
|
123
|
+
const resolvedPath = result && typeof result === 'object' && result.templatePath
|
|
124
|
+
? String(result.templatePath)
|
|
125
|
+
: rawPath;
|
|
126
|
+
debugbar.attachEdgeResolvedPath(rawPath, resolvedPath, durationMs);
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
// Ignore hook errors
|
|
130
|
+
}
|
|
131
|
+
return result;
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Resolves the host AdonisJS application's `edge.js` singleton (from process.cwd())
|
|
137
|
+
* so we never hook a duplicate copy of edge.js.
|
|
138
|
+
*/
|
|
139
|
+
export async function resolveHostEdge() {
|
|
140
|
+
const candidates = [join(process.cwd(), 'package.json'), import.meta.url];
|
|
141
|
+
for (const base of candidates) {
|
|
142
|
+
try {
|
|
143
|
+
const req = createRequire(base);
|
|
144
|
+
const resolved = req.resolve('edge.js');
|
|
145
|
+
const mod = await import(pathToFileURL(resolved).href);
|
|
146
|
+
if (mod?.default)
|
|
147
|
+
return mod.default;
|
|
148
|
+
}
|
|
149
|
+
catch {
|
|
150
|
+
// Try next candidate
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return undefined;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Hooks the global Edge instance (`import edge from 'edge.js'`) so all layouts,
|
|
157
|
+
* components, and partials are captured even when EdgeRenderer uses private fields.
|
|
158
|
+
*/
|
|
159
|
+
export function hookEdgeInstance(edgeInstance, debugbar) {
|
|
160
|
+
if (!edgeInstance || typeof edgeInstance !== 'object' || edgeInstance[EDGE_HOOKED]) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
edgeInstance[EDGE_HOOKED] = true;
|
|
164
|
+
if (edgeInstance.loader) {
|
|
165
|
+
hookEdgeLoader(edgeInstance.loader, debugbar);
|
|
166
|
+
}
|
|
167
|
+
if (edgeInstance.asyncCompiler) {
|
|
168
|
+
hookEdgeCompiler(edgeInstance.asyncCompiler, debugbar);
|
|
169
|
+
}
|
|
170
|
+
if (edgeInstance.compiler) {
|
|
171
|
+
hookEdgeCompiler(edgeInstance.compiler, debugbar);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
function sanitizeViewState(state) {
|
|
175
|
+
if (!state || typeof state !== 'object')
|
|
176
|
+
return undefined;
|
|
177
|
+
const clean = {};
|
|
178
|
+
for (const [key, val] of Object.entries(state)) {
|
|
179
|
+
if (typeof val === 'function')
|
|
180
|
+
continue;
|
|
181
|
+
clean[key] = val;
|
|
182
|
+
}
|
|
183
|
+
return Object.keys(clean).length > 0 ? clean : undefined;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Wraps `ctx.view` (EdgeRenderer) to capture rendered template names,
|
|
187
|
+
* explicit template state, and render duration (without Edge global helpers noise).
|
|
188
|
+
*/
|
|
189
|
+
export function hookEdgeView(view, debugbar) {
|
|
190
|
+
if (!view || typeof view !== 'object') {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
// Also hook if a custom/mocked view exposes `.edge` or `.loader`
|
|
194
|
+
if (view.edge)
|
|
195
|
+
hookEdgeInstance(view.edge, debugbar);
|
|
196
|
+
if (view.renderer?.edge)
|
|
197
|
+
hookEdgeInstance(view.renderer.edge, debugbar);
|
|
198
|
+
if (view.loader)
|
|
199
|
+
hookEdgeLoader(view.loader, debugbar);
|
|
200
|
+
if (view[VIEW_HOOKED]) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
view[VIEW_HOOKED] = true;
|
|
204
|
+
if (typeof view.render === 'function') {
|
|
205
|
+
const originalRender = view.render;
|
|
206
|
+
view.render = async function patchedRender(template, state) {
|
|
207
|
+
const start = process.hrtime.bigint();
|
|
208
|
+
try {
|
|
209
|
+
return await originalRender.apply(this, arguments);
|
|
210
|
+
}
|
|
211
|
+
finally {
|
|
212
|
+
const durationMs = Math.round((Number(process.hrtime.bigint() - start) / 1_000_000) * 100) / 100;
|
|
213
|
+
debugbar.recordView(String(template), sanitizeViewState(state), durationMs, 'edge', 'view');
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
if (typeof view.renderSync === 'function') {
|
|
218
|
+
const originalRenderSync = view.renderSync;
|
|
219
|
+
view.renderSync = function patchedRenderSync(template, state) {
|
|
220
|
+
const start = process.hrtime.bigint();
|
|
221
|
+
try {
|
|
222
|
+
return originalRenderSync.apply(this, arguments);
|
|
223
|
+
}
|
|
224
|
+
finally {
|
|
225
|
+
const durationMs = Math.round((Number(process.hrtime.bigint() - start) / 1_000_000) * 100) / 100;
|
|
226
|
+
debugbar.recordView(String(template), sanitizeViewState(state), durationMs, 'edge', 'view');
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Wraps `ctx.inertia` (if @adonisjs/inertia is installed) to capture rendered components & props.
|
|
233
|
+
*/
|
|
234
|
+
export function hookInertia(inertia, debugbar) {
|
|
235
|
+
if (!inertia || typeof inertia !== 'object' || inertia[INERTIA_HOOKED]) {
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
inertia[INERTIA_HOOKED] = true;
|
|
239
|
+
if (typeof inertia.render === 'function') {
|
|
240
|
+
const originalRender = inertia.render;
|
|
241
|
+
inertia.render = async function patchedInertiaRender(component, props) {
|
|
242
|
+
const start = process.hrtime.bigint();
|
|
243
|
+
try {
|
|
244
|
+
return await originalRender.apply(this, arguments);
|
|
245
|
+
}
|
|
246
|
+
finally {
|
|
247
|
+
const durationMs = Math.round((Number(process.hrtime.bigint() - start) / 1_000_000) * 100) / 100;
|
|
248
|
+
debugbar.recordView(String(component), props, durationMs, 'inertia');
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Extracts the first application-level stack frame (ignoring node internals, node_modules, and adonis-debugbar).
|
|
255
|
+
*/
|
|
256
|
+
export function extractAppCaller() {
|
|
257
|
+
const stack = new Error().stack;
|
|
258
|
+
if (!stack)
|
|
259
|
+
return undefined;
|
|
260
|
+
const lines = stack.split('\n').slice(1);
|
|
261
|
+
for (const rawLine of lines) {
|
|
262
|
+
const line = rawLine.trim();
|
|
263
|
+
if (!line ||
|
|
264
|
+
line.includes('node:internal') ||
|
|
265
|
+
line.includes('node_modules') ||
|
|
266
|
+
line.includes('adonis-debugbar') ||
|
|
267
|
+
line.includes('adonisjs-debugbar') ||
|
|
268
|
+
line.includes('src/debugbar.') ||
|
|
269
|
+
line.includes('build/src/debugbar.')) {
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
const match = line.match(/\((.+)\)$/) ?? line.match(/at\s+(.+)$/);
|
|
273
|
+
if (match?.[1]) {
|
|
274
|
+
return match[1].replace(/^file:\/\/\//, '');
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return undefined;
|
|
278
|
+
}
|
|
279
|
+
//# sourceMappingURL=runtime_hooks.js.map
|
|
@@ -0,0 +1 @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AAU,EAAE,SAAS,CAAC,CAAA;YACtE,CAAC;QACH,CAAC,CAAA;IACH,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,KAAK,GAAG,IAAI,KAAK,EAAE,CAAC,KAAK,CAAA;IAC/B,IAAI,CAAC,KAAK;QAAE,OAAO,SAAS,CAAA;IAE5B,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IACxC,KAAK,MAAM,OAAO,IAAI,KAAK,EAAE,CAAC;QAC5B,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,EAAE,CAAA;QAC3B,IACE,CAAC,IAAI;YACL,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC;YAC9B,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC;YAC7B,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC;YAChC,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC;YAClC,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC;YAC9B,IAAI,CAAC,QAAQ,CAAC,qBAAqB,CAAC,EACpC,CAAC;YACD,SAAQ;QACV,CAAC;QACD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAA;QACjE,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACf,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAA;QAC7C,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { HttpContext } from '@adonisjs/core/http';
|
|
2
|
+
import type { NextFn } from '@adonisjs/core/types/http';
|
|
3
|
+
/**
|
|
4
|
+
* HTTP middleware that tracks request lifecycle, SQL queries, logs, session, auth,
|
|
5
|
+
* redirects, and injects the Nuxt-style AdonisJS Debugbar into HTML responses.
|
|
6
|
+
*/
|
|
7
|
+
export default class DebugbarMiddleware {
|
|
8
|
+
handle(ctx: HttpContext, next: NextFn): Promise<unknown>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=debugbar_middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debugbar_middleware.d.ts","sourceRoot":"","sources":["../../../src/middleware/debugbar_middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAsCvD;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,kBAAkB;IAC/B,MAAM,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CA8F/D"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { hookEdgeInstance, hookEdgeView, hookInertia, hookLogger, resolveHostEdge, } from '../hooks/runtime_hooks.js';
|
|
2
|
+
import { injectDebugbarIntoHtml, renderDebugbarHtml } from '../ui/render_script.js';
|
|
3
|
+
const REDIRECT_COOKIE = '__adonis_debugbar_redirect';
|
|
4
|
+
function readCookie(cookieHeader, name) {
|
|
5
|
+
if (!cookieHeader)
|
|
6
|
+
return undefined;
|
|
7
|
+
for (const part of cookieHeader.split(';')) {
|
|
8
|
+
const [k, ...rest] = part.trim().split('=');
|
|
9
|
+
if (k === name)
|
|
10
|
+
return decodeURIComponent(rest.join('='));
|
|
11
|
+
}
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
function appendSetCookie(ctx, value) {
|
|
15
|
+
const res = ctx.response.response;
|
|
16
|
+
if (res && typeof res.appendHeader === 'function') {
|
|
17
|
+
res.appendHeader('Set-Cookie', value);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const existing = ctx.response.getHeader('set-cookie');
|
|
21
|
+
if (Array.isArray(existing)) {
|
|
22
|
+
ctx.response.header('Set-Cookie', [...existing, value]);
|
|
23
|
+
}
|
|
24
|
+
else if (typeof existing === 'string' && existing) {
|
|
25
|
+
ctx.response.header('Set-Cookie', [existing, value]);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
ctx.response.header('Set-Cookie', value);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* HTTP middleware that tracks request lifecycle, SQL queries, logs, session, auth,
|
|
33
|
+
* redirects, and injects the Nuxt-style AdonisJS Debugbar into HTML responses.
|
|
34
|
+
*/
|
|
35
|
+
export default class DebugbarMiddleware {
|
|
36
|
+
async handle(ctx, next) {
|
|
37
|
+
let debugbar;
|
|
38
|
+
let router;
|
|
39
|
+
try {
|
|
40
|
+
debugbar = await ctx.containerResolver.make('debugbar');
|
|
41
|
+
router = await ctx.containerResolver.make('router');
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return next();
|
|
45
|
+
}
|
|
46
|
+
if (!debugbar || !debugbar.isEnabled() || debugbar.shouldIgnore(ctx.request.url(false))) {
|
|
47
|
+
return next();
|
|
48
|
+
}
|
|
49
|
+
const activeCtx = debugbar.createRequestContext();
|
|
50
|
+
const rawCookieHeader = typeof ctx.request.header === 'function'
|
|
51
|
+
? ctx.request.header('cookie')
|
|
52
|
+
: ctx.request.headers?.()?.cookie;
|
|
53
|
+
const prevRedirectId = readCookie(rawCookieHeader ? String(rawCookieHeader) : undefined, REDIRECT_COOKIE);
|
|
54
|
+
if (prevRedirectId) {
|
|
55
|
+
const prevProfile = debugbar.getProfile(prevRedirectId);
|
|
56
|
+
if (prevProfile) {
|
|
57
|
+
activeCtx.redirectedFrom = {
|
|
58
|
+
id: prevProfile.id,
|
|
59
|
+
method: prevProfile.method,
|
|
60
|
+
path: prevProfile.path,
|
|
61
|
+
statusCode: prevProfile.statusCode,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
appendSetCookie(ctx, `${REDIRECT_COOKIE}=; Path=/; Max-Age=0; SameSite=Lax`);
|
|
65
|
+
}
|
|
66
|
+
hookLogger(ctx.logger, debugbar);
|
|
67
|
+
if (ctx.view) {
|
|
68
|
+
const hostEdge = await resolveHostEdge();
|
|
69
|
+
if (hostEdge)
|
|
70
|
+
hookEdgeInstance(hostEdge, debugbar);
|
|
71
|
+
hookEdgeView(ctx.view, debugbar);
|
|
72
|
+
}
|
|
73
|
+
hookInertia(ctx.inertia, debugbar);
|
|
74
|
+
return debugbar.tracker.run(activeCtx, async () => {
|
|
75
|
+
try {
|
|
76
|
+
await next();
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
debugbar.recordException(error);
|
|
80
|
+
throw error;
|
|
81
|
+
}
|
|
82
|
+
finally {
|
|
83
|
+
const rawContent = ctx.response.content;
|
|
84
|
+
const body = typeof ctx.response.getBody === 'function'
|
|
85
|
+
? ctx.response.getBody()
|
|
86
|
+
: Array.isArray(rawContent)
|
|
87
|
+
? rawContent[0]
|
|
88
|
+
: rawContent;
|
|
89
|
+
const responseSize = typeof body === 'string'
|
|
90
|
+
? Buffer.byteLength(body, 'utf8')
|
|
91
|
+
: Buffer.isBuffer(body)
|
|
92
|
+
? body.byteLength
|
|
93
|
+
: undefined;
|
|
94
|
+
const profile = debugbar.finalizeRequest(ctx, activeCtx, router, responseSize);
|
|
95
|
+
ctx.response.header('X-Debugbar-Id', profile.id);
|
|
96
|
+
if (profile.statusCode >= 300 && profile.statusCode < 400) {
|
|
97
|
+
appendSetCookie(ctx, `${REDIRECT_COOKIE}=${encodeURIComponent(profile.id)}; Path=/; Max-Age=15; SameSite=Lax`);
|
|
98
|
+
}
|
|
99
|
+
if (debugbar.config.injectHtml && typeof body === 'string') {
|
|
100
|
+
const contentType = String(ctx.response.getHeader('content-type') ?? '').toLowerCase();
|
|
101
|
+
const isHtml = contentType.includes('text/html') ||
|
|
102
|
+
(!contentType && /<html|<body|<!doctype/i.test(body));
|
|
103
|
+
if (isHtml) {
|
|
104
|
+
const snippet = renderDebugbarHtml(profile, debugbar.config.routePrefix);
|
|
105
|
+
const injected = injectDebugbarIntoHtml(body, snippet);
|
|
106
|
+
const generateEtag = Array.isArray(rawContent) ? rawContent[1] : undefined;
|
|
107
|
+
ctx.response.send(injected, generateEtag);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=debugbar_middleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debugbar_middleware.js","sourceRoot":"","sources":["../../../src/middleware/debugbar_middleware.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,UAAU,EACV,eAAe,GAChB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAEnF,MAAM,eAAe,GAAG,4BAA4B,CAAA;AAEpD,SAAS,UAAU,CAAC,YAAgC,EAAE,IAAY;IAChE,IAAI,CAAC,YAAY;QAAE,OAAO,SAAS,CAAA;IACnC,KAAK,MAAM,IAAI,IAAI,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QAC3C,MAAM,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAC3C,IAAI,CAAC,KAAK,IAAI;YAAE,OAAO,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;IAC3D,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AAED,SAAS,eAAe,CAAC,GAAgB,EAAE,KAAa;IACtD,MAAM,GAAG,GAAI,GAAG,CAAC,QAAgB,CAAC,QA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AoC,CACzF,CAAA;gBACH,CAAC;gBAED,IAAI,QAAS,CAAC,MAAM,CAAC,UAAU,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;oBAC5D,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAA;oBACtF,MAAM,MAAM,GACV,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC;wBACjC,CAAC,CAAC,WAAW,IAAI,wBAAwB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;oBAEvD,IAAI,MAAM,EAAE,CAAC;wBACX,MAAM,OAAO,GAAG,kBAAkB,CAAC,OAAO,EAAE,QAAS,CAAC,MAAM,CAAC,WAAW,CAAC,CAAA;wBACzE,MAAM,QAAQ,GAAG,sBAAsB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;wBACtD,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;wBAC1E,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAA;oBAC3C,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { DebugbarStorage, RequestProfile, RequestSummary } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* JSONL file-backed storage adapter that persists request profiles across dev server restarts.
|
|
4
|
+
*/
|
|
5
|
+
export declare class FileStorage implements DebugbarStorage {
|
|
6
|
+
private filePath;
|
|
7
|
+
private maxRequests;
|
|
8
|
+
private memory;
|
|
9
|
+
private lineCount;
|
|
10
|
+
constructor(filePath: string, maxRequests?: number);
|
|
11
|
+
setMaxRequests(max: number): void;
|
|
12
|
+
save(profile: RequestProfile): void;
|
|
13
|
+
get(id: string): RequestProfile | undefined;
|
|
14
|
+
latest(): RequestProfile | undefined;
|
|
15
|
+
listSummaries(): RequestSummary[];
|
|
16
|
+
clear(): void;
|
|
17
|
+
size(): number;
|
|
18
|
+
private loadFromDisk;
|
|
19
|
+
private compact;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=file_storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file_storage.d.ts","sourceRoot":"","sources":["../../../src/storage/file_storage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAGlF;;GAEG;AACH,qBAAa,WAAY,YAAW,eAAe;IAK/C,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,WAAW;IALrB,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,SAAS,CAAI;gBAGX,QAAQ,EAAE,MAAM,EAChB,WAAW,SAAK;IAM1B,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAKjC,IAAI,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI;IAcnC,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAI3C,MAAM,IAAI,cAAc,GAAG,SAAS;IAIpC,aAAa,IAAI,cAAc,EAAE;IAIjC,KAAK,IAAI,IAAI;IAYb,IAAI,IAAI,MAAM;IAId,OAAO,CAAC,YAAY;IAsBpB,OAAO,CAAC,OAAO;CAehB"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync, appendFileSync } from 'node:fs';
|
|
2
|
+
import { dirname } from 'node:path';
|
|
3
|
+
import { MemoryStorage } from './memory_storage.js';
|
|
4
|
+
/**
|
|
5
|
+
* JSONL file-backed storage adapter that persists request profiles across dev server restarts.
|
|
6
|
+
*/
|
|
7
|
+
export class FileStorage {
|
|
8
|
+
filePath;
|
|
9
|
+
maxRequests;
|
|
10
|
+
memory;
|
|
11
|
+
lineCount = 0;
|
|
12
|
+
constructor(filePath, maxRequests = 50) {
|
|
13
|
+
this.filePath = filePath;
|
|
14
|
+
this.maxRequests = maxRequests;
|
|
15
|
+
this.memory = new MemoryStorage(maxRequests);
|
|
16
|
+
this.loadFromDisk();
|
|
17
|
+
}
|
|
18
|
+
setMaxRequests(max) {
|
|
19
|
+
this.maxRequests = Math.max(1, max);
|
|
20
|
+
this.memory.setMaxRequests(this.maxRequests);
|
|
21
|
+
}
|
|
22
|
+
save(profile) {
|
|
23
|
+
this.memory.save(profile);
|
|
24
|
+
try {
|
|
25
|
+
mkdirSync(dirname(this.filePath), { recursive: true });
|
|
26
|
+
appendFileSync(this.filePath, `${JSON.stringify(profile)}\n`, 'utf8');
|
|
27
|
+
this.lineCount++;
|
|
28
|
+
if (this.lineCount > this.maxRequests * 2) {
|
|
29
|
+
this.compact();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
// Never crash request if disk write fails
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
get(id) {
|
|
37
|
+
return this.memory.get(id);
|
|
38
|
+
}
|
|
39
|
+
latest() {
|
|
40
|
+
return this.memory.latest();
|
|
41
|
+
}
|
|
42
|
+
listSummaries() {
|
|
43
|
+
return this.memory.listSummaries();
|
|
44
|
+
}
|
|
45
|
+
clear() {
|
|
46
|
+
this.memory.clear();
|
|
47
|
+
this.lineCount = 0;
|
|
48
|
+
try {
|
|
49
|
+
if (existsSync(this.filePath)) {
|
|
50
|
+
rmSync(this.filePath, { force: true });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
// Ignore cleanup errors
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
size() {
|
|
58
|
+
return this.memory.size();
|
|
59
|
+
}
|
|
60
|
+
loadFromDisk() {
|
|
61
|
+
try {
|
|
62
|
+
if (!existsSync(this.filePath))
|
|
63
|
+
return;
|
|
64
|
+
const content = readFileSync(this.filePath, 'utf8');
|
|
65
|
+
const lines = content.split('\n').filter((l) => l.trim().length > 0);
|
|
66
|
+
this.lineCount = lines.length;
|
|
67
|
+
const recent = lines.slice(-this.maxRequests);
|
|
68
|
+
for (const line of recent) {
|
|
69
|
+
try {
|
|
70
|
+
const parsed = JSON.parse(line);
|
|
71
|
+
if (parsed && parsed.id) {
|
|
72
|
+
this.memory.save(parsed);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
// Skip malformed lines
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
// Ignore read errors
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
compact() {
|
|
85
|
+
try {
|
|
86
|
+
const summaries = this.memory.listSummaries().reverse();
|
|
87
|
+
const lines = [];
|
|
88
|
+
for (const s of summaries) {
|
|
89
|
+
const profile = this.memory.get(s.id);
|
|
90
|
+
if (profile)
|
|
91
|
+
lines.push(JSON.stringify(profile));
|
|
92
|
+
}
|
|
93
|
+
mkdirSync(dirname(this.filePath), { recursive: true });
|
|
94
|
+
writeFileSync(this.filePath, lines.length ? `${lines.join('\n')}\n` : '', 'utf8');
|
|
95
|
+
this.lineCount = lines.length;
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
// Ignore compaction errors
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=file_storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file_storage.js","sourceRoot":"","sources":["../../../src/storage/file_storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AACpG,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW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,CAAC;wBACxB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;oBAC1B,CAAC;gBACH,CAAC;gBAAC,MAAM,CAAC;oBACP,uBAAuB;gBACzB,CAAC;YACH,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,qBAAqB;QACvB,CAAC;IACH,CAAC;IAEO,OAAO;QACb,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC,OAAO,EAAE,CAAA;YACvD,MAAM,KAAK,GAAa,EAAE,CAAA;YAC1B,KAAK,MAAM,CAAC,IAAI,SAAS,EAAE,CAAC;gBAC1B,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;gBACrC,IAAI,OAAO;oBAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAA;YAClD,CAAC;YACD,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;YACtD,aAAa,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,MAAM,CAAC,CAAA;YACjF,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,MAAM,CAAA;QAC/B,CAAC;QAAC,MAAM,CAAC;YACP,2BAA2B;QAC7B,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { DebugbarStorage, RequestProfile, RequestSummary } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Bounded in-memory ring buffer storing recent request profiles.
|
|
4
|
+
*/
|
|
5
|
+
export declare class MemoryStorage implements DebugbarStorage {
|
|
6
|
+
private maxRequests;
|
|
7
|
+
private profiles;
|
|
8
|
+
private order;
|
|
9
|
+
constructor(maxRequests?: number);
|
|
10
|
+
setMaxRequests(max: number): void;
|
|
11
|
+
save(profile: RequestProfile): void;
|
|
12
|
+
get(id: string): RequestProfile | undefined;
|
|
13
|
+
latest(): RequestProfile | undefined;
|
|
14
|
+
listSummaries(): RequestSummary[];
|
|
15
|
+
clear(): void;
|
|
16
|
+
size(): number;
|
|
17
|
+
private trim;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=memory_storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory_storage.d.ts","sourceRoot":"","sources":["../../../src/storage/memory_storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAElF;;GAEG;AACH,qBAAa,aAAc,YAAW,eAAe;IAIvC,OAAO,CAAC,WAAW;IAH/B,OAAO,CAAC,QAAQ,CAAoC;IACpD,OAAO,CAAC,KAAK,CAAe;gBAER,WAAW,SAAK;IAEpC,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAKjC,IAAI,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI;IAUnC,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAI3C,MAAM,IAAI,cAAc,GAAG,SAAS;IAKpC,aAAa,IAAI,cAAc,EAAE;IA4BjC,KAAK,IAAI,IAAI;IAKb,IAAI,IAAI,MAAM;IAId,OAAO,CAAC,IAAI;CAQb"}
|