@tylix/core 0.5.0 → 0.5.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/package.json +5 -5
- package/src/discovery/registerFeatureRoutes.d.ts +7 -2
- package/src/discovery/registerFeatureRoutes.js +27 -2
- package/src/discovery/registerRouteFiles.d.ts +1 -1
- package/src/http/Server.js +79 -5
- package/src/http/debug/buildDebugPayload.js +138 -0
- package/src/http/debug/renderDebugPage.js +688 -0
- package/src/runtime/useApi.js +366 -3
|
@@ -0,0 +1,688 @@
|
|
|
1
|
+
const SQL_KEYWORDS = new Set(
|
|
2
|
+
(
|
|
3
|
+
'SELECT FROM WHERE INSERT INTO VALUES UPDATE SET DELETE CREATE TABLE ALTER ADD DROP COLUMN ' +
|
|
4
|
+
'INDEX UNIQUE PRIMARY KEY FOREIGN REFERENCES JOIN LEFT RIGHT INNER OUTER ON AS AND OR NOT NULL ' +
|
|
5
|
+
'IN IS LIKE ORDER BY GROUP HAVING LIMIT OFFSET ASC DESC DISTINCT COUNT RETURNING IF EXISTS ' +
|
|
6
|
+
'DEFAULT AUTO_INCREMENT AUTOINCREMENT'
|
|
7
|
+
).split(' '),
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
const JS_KEYWORDS = new Set(
|
|
11
|
+
(
|
|
12
|
+
'const let var function return if else for while await async new throw try catch finally class ' +
|
|
13
|
+
'import export from default of in typeof instanceof null undefined true false this extends static ' +
|
|
14
|
+
'switch case break continue yield delete void super'
|
|
15
|
+
).split(' '),
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
const DRIVER_LABELS = {
|
|
19
|
+
mysql: 'MySQL',
|
|
20
|
+
postgres: 'PostgreSQL',
|
|
21
|
+
sqlite: 'SQLite',
|
|
22
|
+
mongodb: 'MongoDB',
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const STATUS_TEXT = {
|
|
26
|
+
400: 'Bad Request',
|
|
27
|
+
401: 'Unauthorized',
|
|
28
|
+
403: 'Forbidden',
|
|
29
|
+
404: 'Not Found',
|
|
30
|
+
500: 'Internal Server Error',
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const ICONS = {
|
|
34
|
+
sun: '<svg class="i i-sun" viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"/></svg>',
|
|
35
|
+
moon: '<svg class="i i-moon" viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z"/></svg>',
|
|
36
|
+
bulb: '<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 18h6M10 22h4M12 2a7 7 0 0 0-4 12.7c.6.5 1 1.2 1 2V17h6v-.3c0-.8.4-1.5 1-2A7 7 0 0 0 12 2z"/></svg>',
|
|
37
|
+
alert: '<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10.3 3.9L1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0zM12 9v4M12 17h.01"/></svg>',
|
|
38
|
+
copy: '<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>',
|
|
39
|
+
external: '<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6M15 3h6v6M10 14L21 3"/></svg>',
|
|
40
|
+
bolt: '<svg viewBox="0 0 24 24" width="15" height="15" fill="currentColor"><path d="M13 2L4 14h6l-1 8 9-12h-6z"/></svg>',
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function esc(value) {
|
|
44
|
+
return String(value ?? '')
|
|
45
|
+
.replace(/&/g, '&')
|
|
46
|
+
.replace(/</g, '<')
|
|
47
|
+
.replace(/>/g, '>')
|
|
48
|
+
.replace(/"/g, '"')
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function splitPath(p) {
|
|
52
|
+
const i = Math.max(p.lastIndexOf('/'), p.lastIndexOf('\\'))
|
|
53
|
+
return i < 0 ? ['', p] : [p.slice(0, i + 1), p.slice(i + 1)]
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function absolutePath(file, cwd) {
|
|
57
|
+
if (!file) return ''
|
|
58
|
+
if (file.startsWith('/') || /^[A-Za-z]:[\\/]/.test(file)) return file
|
|
59
|
+
return `${String(cwd).replace(/[\\/]$/, '')}/${file}`
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// ---------------------------------------------------------------
|
|
63
|
+
// Highlighters (server side, so the page needs no libraries)
|
|
64
|
+
// ---------------------------------------------------------------
|
|
65
|
+
|
|
66
|
+
function highlightSql(sql, culprits) {
|
|
67
|
+
const re =
|
|
68
|
+
/('(?:[^'\\]|\\.)*')|(`[^`]*`|"[^"]*")|(\?|\$\d+)|(\d+(?:\.\d+)?)|([A-Za-z_][\w]*)/g
|
|
69
|
+
let out = ''
|
|
70
|
+
let last = 0
|
|
71
|
+
let m
|
|
72
|
+
while ((m = re.exec(sql))) {
|
|
73
|
+
out += esc(sql.slice(last, m.index))
|
|
74
|
+
const [token, str, quoted, placeholder, num, word] = m
|
|
75
|
+
if (str) out += `<span class="t-str">${esc(token)}</span>`
|
|
76
|
+
else if (quoted) {
|
|
77
|
+
const culprit = culprits.has(token.slice(1, -1))
|
|
78
|
+
out += `<span class="${culprit ? 't-culprit' : 't-id'}">${esc(token)}</span>`
|
|
79
|
+
} else if (placeholder) out += `<span class="t-ph">${esc(token)}</span>`
|
|
80
|
+
else if (num) out += `<span class="t-num">${esc(token)}</span>`
|
|
81
|
+
else if (SQL_KEYWORDS.has(word.toUpperCase()))
|
|
82
|
+
out += `<span class="t-kw">${esc(token)}</span>`
|
|
83
|
+
else if (culprits.has(word)) out += `<span class="t-culprit">${esc(token)}</span>`
|
|
84
|
+
else out += esc(token)
|
|
85
|
+
last = re.lastIndex
|
|
86
|
+
}
|
|
87
|
+
return out + esc(sql.slice(last))
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// One line at a time: good enough for a snippet, and never throws.
|
|
91
|
+
function highlightJs(line) {
|
|
92
|
+
const re =
|
|
93
|
+
/(\/\/.*$)|('(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*`)|(\b\d+(?:\.\d+)?\b)|([A-Za-z_$][\w$]*)/g
|
|
94
|
+
let out = ''
|
|
95
|
+
let last = 0
|
|
96
|
+
let m
|
|
97
|
+
while ((m = re.exec(line))) {
|
|
98
|
+
out += esc(line.slice(last, m.index))
|
|
99
|
+
const [token, comment, str, num, word] = m
|
|
100
|
+
if (comment) out += `<span class="t-com">${esc(token)}</span>`
|
|
101
|
+
else if (str) out += `<span class="t-str">${esc(token)}</span>`
|
|
102
|
+
else if (num) out += `<span class="t-num">${esc(token)}</span>`
|
|
103
|
+
else if (JS_KEYWORDS.has(word)) out += `<span class="t-kw">${esc(token)}</span>`
|
|
104
|
+
else if (line[re.lastIndex] === '(') out += `<span class="t-fn">${esc(token)}</span>`
|
|
105
|
+
else out += esc(token)
|
|
106
|
+
last = re.lastIndex
|
|
107
|
+
}
|
|
108
|
+
return out + esc(line.slice(last))
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// ---------------------------------------------------------------
|
|
112
|
+
// Sections
|
|
113
|
+
// ---------------------------------------------------------------
|
|
114
|
+
|
|
115
|
+
function renderSource(source, cwd) {
|
|
116
|
+
if (!source) return ''
|
|
117
|
+
const abs = absolutePath(source.file, cwd)
|
|
118
|
+
const [dir, base] = splitPath(source.file)
|
|
119
|
+
const rows = source.lines
|
|
120
|
+
.map((text, i) => {
|
|
121
|
+
const n = source.start + i
|
|
122
|
+
const hit = n === source.line
|
|
123
|
+
return `<div class="cl${hit ? ' cl--hit' : ''}"><span class="cl-mark">${
|
|
124
|
+
hit ? '›' : ''
|
|
125
|
+
}</span><span class="cl-n">${n}</span><span class="cl-t">${highlightJs(text) || ' '}</span></div>`
|
|
126
|
+
})
|
|
127
|
+
.join('')
|
|
128
|
+
return `<section class="card block">
|
|
129
|
+
<div class="card-head">
|
|
130
|
+
<h2>Where it happened</h2>
|
|
131
|
+
<div class="card-tools">
|
|
132
|
+
<a class="btn btn-sm" href="vscode://file/${esc(abs)}:${source.line}:${source.column}">${ICONS.external}<span>Open in VS Code</span></a>
|
|
133
|
+
<button class="btn btn-sm" data-copy="path">${ICONS.copy}<span>Copy path</span></button>
|
|
134
|
+
</div>
|
|
135
|
+
</div>
|
|
136
|
+
<div class="filebar mono"><span class="dir">${esc(dir)}</span><b>${esc(base)}</b><span class="pos">:${source.line}:${source.column}</span></div>
|
|
137
|
+
<div class="code">${rows}</div>
|
|
138
|
+
</section>`
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function typeOf(v) {
|
|
142
|
+
if (v === null) return 'null'
|
|
143
|
+
if (Array.isArray(v)) return 'array'
|
|
144
|
+
return typeof v
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function renderSql(p) {
|
|
148
|
+
if (!p.sql) return ''
|
|
149
|
+
const culprits = new Set([p.table, p.column].filter(Boolean))
|
|
150
|
+
const params = (p.params ?? []).length
|
|
151
|
+
? `<div class="params"><h3>Parameters</h3>${p.params
|
|
152
|
+
.map(
|
|
153
|
+
(v, i) =>
|
|
154
|
+
`<div class="param"><span class="pi">${i + 1}</span><span class="pv mono">${esc(
|
|
155
|
+
JSON.stringify(v) ?? String(v),
|
|
156
|
+
)}</span><span class="pt">${typeOf(v)}</span></div>`,
|
|
157
|
+
)
|
|
158
|
+
.join('')}</div>`
|
|
159
|
+
: ''
|
|
160
|
+
return `<section class="card block">
|
|
161
|
+
<div class="card-head">
|
|
162
|
+
<h2>${p.driver === 'mongodb' ? 'Operation' : 'Query'}</h2>
|
|
163
|
+
<div class="card-tools"><button class="btn btn-sm" data-copy="sql">${ICONS.copy}<span>Copy</span></button></div>
|
|
164
|
+
</div>
|
|
165
|
+
<div class="sql-grid${params ? ' has-params' : ''}">
|
|
166
|
+
<pre class="sql mono">${highlightSql(p.sql, culprits)}</pre>${params}
|
|
167
|
+
</div>
|
|
168
|
+
</section>`
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function renderFrames(frames) {
|
|
172
|
+
if (!frames.length) return '<p class="muted">No stack frames available.</p>'
|
|
173
|
+
const firstApp = frames.findIndex((f) => f.kind === 'app')
|
|
174
|
+
const hidden = frames.filter((f) => f.kind !== 'app').length
|
|
175
|
+
const items = frames
|
|
176
|
+
.map((f, i) => {
|
|
177
|
+
const [dir, base] = splitPath(f.short)
|
|
178
|
+
return `<li class="frame ${f.kind}${i === firstApp ? ' frame--first' : ''}">
|
|
179
|
+
<span class="fi">${i + 1}</span>
|
|
180
|
+
<div class="fmain">
|
|
181
|
+
<span class="ffn">${esc(f.fn || '<anonymous>')}</span>
|
|
182
|
+
<span class="floc mono"><span class="dir">${esc(dir)}</span><b>${esc(base)}</b><span class="pos">:${f.line}:${f.column}</span></span>
|
|
183
|
+
</div>
|
|
184
|
+
${
|
|
185
|
+
f.kind === 'app'
|
|
186
|
+
? '<span class="tag tag-app">your code</span>'
|
|
187
|
+
: `<span class="tag">${f.kind === 'internal' ? 'node' : 'framework'}</span>`
|
|
188
|
+
}
|
|
189
|
+
</li>`
|
|
190
|
+
})
|
|
191
|
+
.join('')
|
|
192
|
+
return `<div class="toolbar">
|
|
193
|
+
<label class="switch"><input type="checkbox" id="show-vendor" /><span class="slider"></span>
|
|
194
|
+
<span>Show framework and Node frames (${hidden})</span></label>
|
|
195
|
+
<button class="btn btn-sm" data-copy="stack">${ICONS.copy}<span>Copy stack</span></button>
|
|
196
|
+
</div>
|
|
197
|
+
<ol class="frames" id="frames">${items}</ol>`
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function kvRows(obj) {
|
|
201
|
+
const entries = Object.entries(obj ?? {})
|
|
202
|
+
if (!entries.length) return '<p class="muted">None</p>'
|
|
203
|
+
return `<div class="kv">${entries
|
|
204
|
+
.map(
|
|
205
|
+
([k, v]) =>
|
|
206
|
+
`<div class="kv-row"><span class="kv-k mono">${esc(k)}</span><span class="kv-v mono">${esc(
|
|
207
|
+
typeof v === 'object' && v !== null ? JSON.stringify(v) : v,
|
|
208
|
+
)}</span></div>`,
|
|
209
|
+
)
|
|
210
|
+
.join('')}</div>`
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function glance(p) {
|
|
214
|
+
const rows = [
|
|
215
|
+
['Status', `${p.status} ${STATUS_TEXT[p.status] ?? ''}`.trim()],
|
|
216
|
+
['Type', p.name],
|
|
217
|
+
['Driver', p.driver ? (DRIVER_LABELS[p.driver] ?? p.driver) : null],
|
|
218
|
+
['Kind', p.kind ? p.kind.replace(/_/g, ' ') : null],
|
|
219
|
+
['Code', p.code],
|
|
220
|
+
['Table', p.table],
|
|
221
|
+
['Column', p.column],
|
|
222
|
+
['Detail', p.detail],
|
|
223
|
+
['Time', new Date().toLocaleTimeString('en-GB')],
|
|
224
|
+
].filter(([, v]) => v !== null && v !== undefined && v !== '')
|
|
225
|
+
return `<aside class="card glance"><h2>At a glance</h2>${rows
|
|
226
|
+
.map(
|
|
227
|
+
([k, v]) =>
|
|
228
|
+
`<div class="g-row"><span class="g-k">${esc(k)}</span><span class="g-v mono">${esc(v)}</span></div>`,
|
|
229
|
+
)
|
|
230
|
+
.join('')}</aside>`
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// ---------------------------------------------------------------
|
|
234
|
+
// Browser script. Serialized with toString(), so it must not
|
|
235
|
+
// reference anything from this module.
|
|
236
|
+
// ---------------------------------------------------------------
|
|
237
|
+
function clientMain() {
|
|
238
|
+
var data = JSON.parse(document.getElementById('debug-data').textContent)
|
|
239
|
+
var FENCE = String.fromCharCode(96, 96, 96)
|
|
240
|
+
var NL = String.fromCharCode(10)
|
|
241
|
+
var toastTimer = null
|
|
242
|
+
|
|
243
|
+
function absPath() {
|
|
244
|
+
if (!data.source) return ''
|
|
245
|
+
var f = data.source.file
|
|
246
|
+
var abs = f.charAt(0) === '/' || /^[A-Za-z]:[\\/]/.test(f) ? f : data.env.cwd.replace(/[\\/]$/, '') + '/' + f
|
|
247
|
+
return abs + ':' + data.source.line + ':' + data.source.column
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function stackText() {
|
|
251
|
+
return data.frames
|
|
252
|
+
.map(function (f) {
|
|
253
|
+
return 'at ' + (f.fn || '<anonymous>') + ' (' + f.file + ':' + f.line + ':' + f.column + ')'
|
|
254
|
+
})
|
|
255
|
+
.join(NL)
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function toMarkdown(p) {
|
|
259
|
+
var L = []
|
|
260
|
+
L.push('## ' + (p.title || p.name), '')
|
|
261
|
+
L.push('**' + p.name + (p.driver ? ' (' + p.driver + ')' : '') + ':** ' + p.message)
|
|
262
|
+
if (p.hint) L.push('', '**Hint:** ' + p.hint)
|
|
263
|
+
if (p.sql) {
|
|
264
|
+
L.push('', FENCE + 'sql', p.sql, FENCE)
|
|
265
|
+
if (p.params && p.params.length) L.push('Params: ' + JSON.stringify(p.params))
|
|
266
|
+
}
|
|
267
|
+
L.push('', '**Request:** ' + p.request.method + ' ' + p.request.url)
|
|
268
|
+
var app = p.frames.filter(function (f) { return f.kind === 'app' }).slice(0, 8)
|
|
269
|
+
if (app.length) {
|
|
270
|
+
L.push('', FENCE)
|
|
271
|
+
app.forEach(function (f) {
|
|
272
|
+
L.push('at ' + (f.fn || '<anonymous>') + ' (' + f.short + ':' + f.line + ':' + f.column + ')')
|
|
273
|
+
})
|
|
274
|
+
L.push(FENCE)
|
|
275
|
+
}
|
|
276
|
+
return L.join(NL)
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function toast(text) {
|
|
280
|
+
var el = document.getElementById('toast')
|
|
281
|
+
el.textContent = text
|
|
282
|
+
el.classList.add('show')
|
|
283
|
+
clearTimeout(toastTimer)
|
|
284
|
+
toastTimer = setTimeout(function () { el.classList.remove('show') }, 1600)
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function copy(text, label) {
|
|
288
|
+
function done() { toast(label + ' copied') }
|
|
289
|
+
function fallback() {
|
|
290
|
+
var ta = document.createElement('textarea')
|
|
291
|
+
ta.value = text
|
|
292
|
+
document.body.appendChild(ta)
|
|
293
|
+
ta.select()
|
|
294
|
+
try { document.execCommand('copy') } catch (e) {}
|
|
295
|
+
document.body.removeChild(ta)
|
|
296
|
+
done()
|
|
297
|
+
}
|
|
298
|
+
if (navigator.clipboard && window.isSecureContext) {
|
|
299
|
+
navigator.clipboard.writeText(text).then(done, fallback)
|
|
300
|
+
} else fallback()
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
var COPY = {
|
|
304
|
+
sql: function () { return [data.sql, 'SQL'] },
|
|
305
|
+
json: function () { return [JSON.stringify(data, null, 2), 'JSON'] },
|
|
306
|
+
raw: function () { return [JSON.stringify(data, null, 2), 'JSON'] },
|
|
307
|
+
md: function () { return [toMarkdown(data), 'Markdown'] },
|
|
308
|
+
path: function () { return [absPath(), 'Path'] },
|
|
309
|
+
stack: function () { return [stackText(), 'Stack trace'] }
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
document.querySelectorAll('[data-copy]').forEach(function (btn) {
|
|
313
|
+
btn.addEventListener('click', function () {
|
|
314
|
+
var pair = COPY[btn.getAttribute('data-copy')]()
|
|
315
|
+
copy(pair[0], pair[1])
|
|
316
|
+
})
|
|
317
|
+
})
|
|
318
|
+
|
|
319
|
+
var tabs = ['overview', 'stack', 'request', 'raw']
|
|
320
|
+
function showTab(name) {
|
|
321
|
+
if (tabs.indexOf(name) < 0) name = 'overview'
|
|
322
|
+
document.querySelectorAll('.tab').forEach(function (t) {
|
|
323
|
+
t.classList.toggle('active', t.getAttribute('data-tab') === name)
|
|
324
|
+
})
|
|
325
|
+
document.querySelectorAll('.panel').forEach(function (p) {
|
|
326
|
+
p.hidden = p.id !== 'panel-' + name
|
|
327
|
+
})
|
|
328
|
+
}
|
|
329
|
+
document.querySelectorAll('.tab').forEach(function (t) {
|
|
330
|
+
t.addEventListener('click', function () {
|
|
331
|
+
var name = t.getAttribute('data-tab')
|
|
332
|
+
showTab(name)
|
|
333
|
+
history.replaceState(null, '', '#' + name)
|
|
334
|
+
})
|
|
335
|
+
})
|
|
336
|
+
showTab(location.hash.slice(1))
|
|
337
|
+
|
|
338
|
+
var vendor = document.getElementById('show-vendor')
|
|
339
|
+
if (vendor) {
|
|
340
|
+
vendor.addEventListener('change', function () {
|
|
341
|
+
document.getElementById('frames').classList.toggle('show-all', vendor.checked)
|
|
342
|
+
})
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
function toggleTheme() {
|
|
346
|
+
var dark = document.documentElement.classList.toggle('dark')
|
|
347
|
+
try { localStorage.setItem('theme', dark ? 'dark' : 'light') } catch (e) {}
|
|
348
|
+
}
|
|
349
|
+
document.getElementById('theme-toggle').addEventListener('click', toggleTheme)
|
|
350
|
+
|
|
351
|
+
document.addEventListener('keydown', function (e) {
|
|
352
|
+
if (e.metaKey || e.ctrlKey || e.altKey) return
|
|
353
|
+
var tag = (e.target && e.target.tagName) || ''
|
|
354
|
+
if (tag === 'INPUT' || tag === 'TEXTAREA') return
|
|
355
|
+
var n = parseInt(e.key, 10)
|
|
356
|
+
if (n >= 1 && n <= tabs.length) {
|
|
357
|
+
showTab(tabs[n - 1])
|
|
358
|
+
history.replaceState(null, '', '#' + tabs[n - 1])
|
|
359
|
+
} else if (e.key === 't') toggleTheme()
|
|
360
|
+
})
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// ---------------------------------------------------------------
|
|
364
|
+
// Styles
|
|
365
|
+
// ---------------------------------------------------------------
|
|
366
|
+
const CSS = `
|
|
367
|
+
* { box-sizing: border-box; }
|
|
368
|
+
:root {
|
|
369
|
+
--bg:#eef2f7; --surface:#ffffff; --surface-2:#f6f8fb; --border:#dde3ec; --border-strong:#c3ccd9;
|
|
370
|
+
--text:#0f172a; --text-2:#475569; --text-3:#8492a6;
|
|
371
|
+
--accent:#059669; --accent-soft:rgba(5,150,105,.09); --accent-ring:rgba(5,150,105,.28);
|
|
372
|
+
--danger:#e11d48; --danger-soft:rgba(225,29,72,.08); --danger-ring:rgba(225,29,72,.3);
|
|
373
|
+
--warn:#b45309; --warn-soft:rgba(245,158,11,.12);
|
|
374
|
+
--code-bg:#f6f8fb; --shadow:0 1px 2px rgba(15,23,42,.05), 0 8px 24px rgba(15,23,42,.05);
|
|
375
|
+
--kw:#7c3aed; --str:#047857; --num:#b45309; --com:#94a3b8; --fn:#2563eb;
|
|
376
|
+
}
|
|
377
|
+
html.dark {
|
|
378
|
+
--bg:#050816; --surface:#0d1424; --surface-2:#0a101e; --border:#1c2740; --border-strong:#2b3a5c;
|
|
379
|
+
--text:#e6edf8; --text-2:#9aa8c2; --text-3:#64748b;
|
|
380
|
+
--accent:#34d399; --accent-soft:rgba(52,211,153,.1); --accent-ring:rgba(52,211,153,.3);
|
|
381
|
+
--danger:#fb7185; --danger-soft:rgba(251,113,133,.1); --danger-ring:rgba(251,113,133,.35);
|
|
382
|
+
--warn:#fbbf24; --warn-soft:rgba(251,191,36,.1);
|
|
383
|
+
--code-bg:#080d1a; --shadow:none;
|
|
384
|
+
--kw:#c4b5fd; --str:#6ee7b7; --num:#fbbf24; --com:#5b6b8a; --fn:#7dd3fc;
|
|
385
|
+
}
|
|
386
|
+
html { color-scheme: light; } html.dark { color-scheme: dark; }
|
|
387
|
+
body { margin:0; background:var(--bg); color:var(--text); -webkit-font-smoothing:antialiased;
|
|
388
|
+
font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Inter, sans-serif; font-size:14px; line-height:1.55; }
|
|
389
|
+
.mono, pre, code { font-family: ui-monospace, "JetBrains Mono", "SF Mono", Consolas, monospace; }
|
|
390
|
+
.i { display:block; } html.dark .i-moon { display:none; } html:not(.dark) .i-sun { display:none; }
|
|
391
|
+
|
|
392
|
+
/* top bar */
|
|
393
|
+
.topbar { position:sticky; top:0; z-index:10; background:color-mix(in srgb, var(--bg) 82%, transparent);
|
|
394
|
+
backdrop-filter:blur(10px); border-bottom:1px solid var(--border); }
|
|
395
|
+
.topbar-in { max-width:1120px; margin:0 auto; padding:10px 24px; display:flex; align-items:center; justify-content:space-between; gap:16px; }
|
|
396
|
+
.brand { display:flex; align-items:center; gap:10px; font-weight:700; letter-spacing:.01em; }
|
|
397
|
+
.logo { width:26px; height:26px; border-radius:8px; display:grid; place-items:center; color:#fff;
|
|
398
|
+
background:linear-gradient(135deg,#10b981,#059669); }
|
|
399
|
+
.brand small { font-weight:600; font-size:11px; letter-spacing:.08em; text-transform:uppercase; color:var(--text-3);
|
|
400
|
+
border:1px solid var(--border-strong); border-radius:999px; padding:1px 8px; }
|
|
401
|
+
.top-right { display:flex; align-items:center; gap:10px; color:var(--text-3); font-size:12px; }
|
|
402
|
+
|
|
403
|
+
.shell { max-width:1120px; margin:0 auto; padding:28px 24px 48px; }
|
|
404
|
+
|
|
405
|
+
/* buttons */
|
|
406
|
+
.btn { font:inherit; font-size:13px; font-weight:500; display:inline-flex; align-items:center; gap:7px; padding:7px 14px;
|
|
407
|
+
border-radius:10px; cursor:pointer; text-decoration:none; color:var(--text); background:var(--surface);
|
|
408
|
+
border:1px solid var(--border-strong); transition:border-color .12s, background .12s, transform .05s; }
|
|
409
|
+
.btn:hover { border-color:var(--accent); background:var(--accent-soft); }
|
|
410
|
+
.btn:active { transform:translateY(1px); }
|
|
411
|
+
.btn-sm { font-size:12px; padding:5px 10px; border-radius:8px; }
|
|
412
|
+
.btn-icon { padding:7px; }
|
|
413
|
+
|
|
414
|
+
/* hero */
|
|
415
|
+
.hero { position:relative; overflow:hidden; background:var(--surface); border:1px solid var(--border);
|
|
416
|
+
border-radius:18px; padding:28px 30px 24px; box-shadow:var(--shadow); }
|
|
417
|
+
.hero::before { content:""; position:absolute; inset:0 0 auto 0; height:4px; background:linear-gradient(90deg,var(--danger),#f97316); }
|
|
418
|
+
.hero::after { content:""; position:absolute; inset:0; pointer-events:none;
|
|
419
|
+
background:radial-gradient(600px 160px at 0% 0%, var(--danger-soft), transparent 70%); }
|
|
420
|
+
.hero > * { position:relative; z-index:1; }
|
|
421
|
+
.chips { display:flex; flex-wrap:wrap; gap:8px; margin-bottom:14px; }
|
|
422
|
+
.chip { font-size:11px; font-weight:700; letter-spacing:.06em; text-transform:uppercase; padding:3px 10px;
|
|
423
|
+
border-radius:999px; border:1px solid var(--border-strong); color:var(--text-2); background:var(--surface-2); }
|
|
424
|
+
.chip.danger { color:var(--danger); background:var(--danger-soft); border-color:var(--danger-ring); }
|
|
425
|
+
.chip.accent { color:var(--accent); background:var(--accent-soft); border-color:var(--accent-ring); }
|
|
426
|
+
h1 { font-size:28px; line-height:1.25; margin:0 0 12px; font-weight:750; letter-spacing:-.015em; }
|
|
427
|
+
.message { margin:0 0 16px; padding:11px 14px; font-size:13px; line-height:1.6; color:var(--text-2);
|
|
428
|
+
background:var(--code-bg); border:1px solid var(--border); border-left:3px solid var(--danger);
|
|
429
|
+
border-radius:10px; white-space:pre-wrap; word-break:break-word; }
|
|
430
|
+
.reqline { display:flex; flex-wrap:wrap; align-items:center; gap:10px; margin-bottom:18px; }
|
|
431
|
+
.method { font-size:11px; font-weight:800; letter-spacing:.06em; padding:3px 9px; border-radius:7px;
|
|
432
|
+
color:var(--accent); background:var(--accent-soft); border:1px solid var(--accent-ring); }
|
|
433
|
+
.url { font-size:13px; color:var(--text-2); word-break:break-all; }
|
|
434
|
+
.hero-actions { display:flex; flex-wrap:wrap; gap:8px; }
|
|
435
|
+
|
|
436
|
+
/* tabs */
|
|
437
|
+
.tabs { display:flex; gap:4px; margin:22px 0 18px; border-bottom:1px solid var(--border); overflow-x:auto; }
|
|
438
|
+
.tab { font:inherit; font-size:13px; font-weight:600; padding:10px 14px; background:none; border:0; cursor:pointer;
|
|
439
|
+
color:var(--text-2); border-bottom:2px solid transparent; margin-bottom:-1px; white-space:nowrap; display:flex; gap:8px; align-items:center; }
|
|
440
|
+
.tab:hover { color:var(--text); }
|
|
441
|
+
.tab.active { color:var(--accent); border-bottom-color:var(--accent); }
|
|
442
|
+
.tab kbd { font:600 10px ui-monospace, monospace; color:var(--text-3); border:1px solid var(--border-strong);
|
|
443
|
+
border-radius:5px; padding:0 5px; }
|
|
444
|
+
.count { font-size:11px; background:var(--accent-soft); color:var(--accent); border-radius:999px; padding:0 7px; }
|
|
445
|
+
|
|
446
|
+
/* overview grid */
|
|
447
|
+
.grid { display:grid; grid-template-columns:minmax(0,1fr) 290px; gap:18px; align-items:start; }
|
|
448
|
+
@media (max-width: 900px) { .grid { grid-template-columns:1fr; } .hero { padding:22px 18px; } h1 { font-size:23px; } }
|
|
449
|
+
.stack-col { display:flex; flex-direction:column; gap:18px; min-width:0; }
|
|
450
|
+
|
|
451
|
+
.card { background:var(--surface); border:1px solid var(--border); border-radius:14px; box-shadow:var(--shadow); overflow:hidden; }
|
|
452
|
+
.card-head { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:12px 16px; border-bottom:1px solid var(--border); }
|
|
453
|
+
.card-tools { display:flex; gap:8px; flex-wrap:wrap; }
|
|
454
|
+
h2 { margin:0; font-size:11.5px; font-weight:700; letter-spacing:.08em; text-transform:uppercase; color:var(--text-2); }
|
|
455
|
+
h3 { margin:0 0 8px; font-size:11px; font-weight:700; letter-spacing:.08em; text-transform:uppercase; color:var(--text-3); }
|
|
456
|
+
.muted { color:var(--text-3); font-size:13px; }
|
|
457
|
+
|
|
458
|
+
.callout { display:flex; gap:12px; padding:14px 16px; border-radius:14px; border:1px solid; line-height:1.6; }
|
|
459
|
+
.callout .ci { flex:none; margin-top:1px; }
|
|
460
|
+
.callout strong { display:block; font-size:11px; letter-spacing:.08em; text-transform:uppercase; margin-bottom:2px; }
|
|
461
|
+
.callout.fix { background:var(--accent-soft); border-color:var(--accent-ring); }
|
|
462
|
+
.callout.fix .ci, .callout.fix strong { color:var(--accent); }
|
|
463
|
+
.callout.cause { background:var(--warn-soft); border-color:rgba(245,158,11,.35); }
|
|
464
|
+
.callout.cause .ci, .callout.cause strong { color:var(--warn); }
|
|
465
|
+
|
|
466
|
+
/* source */
|
|
467
|
+
.filebar { padding:8px 16px; font-size:12.5px; color:var(--text-2); background:var(--surface-2); border-bottom:1px solid var(--border); word-break:break-all; }
|
|
468
|
+
.filebar .dir { color:var(--text-3); } .filebar b { color:var(--text); font-weight:600; } .pos { color:var(--text-3); }
|
|
469
|
+
.code { background:var(--code-bg); padding:8px 0; overflow-x:auto; }
|
|
470
|
+
.cl { display:flex; font-family:ui-monospace,"JetBrains Mono",Consolas,monospace; font-size:13px; line-height:1.9; min-width:max-content; }
|
|
471
|
+
.cl-mark { flex:0 0 22px; text-align:center; color:var(--danger); font-weight:800; }
|
|
472
|
+
.cl-n { flex:0 0 44px; text-align:right; padding-right:16px; color:var(--text-3); user-select:none; }
|
|
473
|
+
.cl-t { white-space:pre; color:var(--text-2); padding-right:24px; }
|
|
474
|
+
.cl--hit { background:var(--danger-soft); box-shadow:inset 3px 0 0 var(--danger); }
|
|
475
|
+
.cl--hit .cl-n { color:var(--danger); font-weight:700; } .cl--hit .cl-t { color:var(--text); }
|
|
476
|
+
|
|
477
|
+
/* syntax */
|
|
478
|
+
.t-kw { color:var(--kw); font-weight:600; } .t-str { color:var(--str); } .t-num { color:var(--num); }
|
|
479
|
+
.t-com { color:var(--com); font-style:italic; } .t-fn { color:var(--fn); } .t-ph { color:var(--warn); } .t-id { color:var(--text); }
|
|
480
|
+
.t-culprit { color:var(--danger); background:var(--danger-soft); border-radius:4px; padding:0 4px; font-weight:700;
|
|
481
|
+
box-shadow:inset 0 -2px 0 var(--danger-ring); }
|
|
482
|
+
|
|
483
|
+
/* sql */
|
|
484
|
+
.sql-grid { display:grid; gap:0; }
|
|
485
|
+
.sql-grid.has-params { grid-template-columns:minmax(0,1.8fr) minmax(210px,1fr); }
|
|
486
|
+
@media (max-width: 700px) { .sql-grid.has-params { grid-template-columns:1fr; } }
|
|
487
|
+
pre.sql { margin:0; padding:16px; font-size:13px; line-height:1.75; background:var(--code-bg); white-space:pre-wrap; word-break:break-word; overflow-x:auto; }
|
|
488
|
+
.params { padding:14px 16px; border-left:1px solid var(--border); background:var(--surface-2); }
|
|
489
|
+
@media (max-width: 700px) { .params { border-left:0; border-top:1px solid var(--border); } }
|
|
490
|
+
.param { display:flex; align-items:baseline; gap:10px; padding:5px 0; border-bottom:1px dashed var(--border); font-size:12.5px; }
|
|
491
|
+
.param:last-child { border-bottom:0; }
|
|
492
|
+
.pi { color:var(--text-3); width:16px; flex:none; } .pv { flex:1; word-break:break-all; }
|
|
493
|
+
.pt { font-size:10px; font-weight:700; letter-spacing:.06em; text-transform:uppercase; color:var(--text-3); }
|
|
494
|
+
|
|
495
|
+
/* sidebar */
|
|
496
|
+
.glance { padding:14px 16px 8px; position:sticky; top:68px; }
|
|
497
|
+
.glance h2 { margin-bottom:8px; }
|
|
498
|
+
.g-row { display:flex; justify-content:space-between; gap:14px; padding:8px 0; border-top:1px solid var(--border); font-size:12.5px; }
|
|
499
|
+
.g-k { color:var(--text-3); flex:none; } .g-v { text-align:right; word-break:break-word; }
|
|
500
|
+
@media (max-width: 900px) { .glance { position:static; } }
|
|
501
|
+
|
|
502
|
+
/* stack */
|
|
503
|
+
.toolbar { display:flex; justify-content:space-between; align-items:center; gap:12px; flex-wrap:wrap; margin-bottom:14px; }
|
|
504
|
+
.switch { display:inline-flex; align-items:center; gap:10px; font-size:13px; color:var(--text-2); cursor:pointer; user-select:none; }
|
|
505
|
+
.switch input { position:absolute; opacity:0; pointer-events:none; }
|
|
506
|
+
.slider { width:34px; height:20px; border-radius:999px; background:var(--border-strong); position:relative; transition:background .15s; flex:none; }
|
|
507
|
+
.slider::after { content:""; position:absolute; top:3px; left:3px; width:14px; height:14px; border-radius:50%; background:#fff; transition:transform .15s; }
|
|
508
|
+
.switch input:checked + .slider { background:var(--accent); }
|
|
509
|
+
.switch input:checked + .slider::after { transform:translateX(14px); }
|
|
510
|
+
.switch input:focus-visible + .slider { outline:2px solid var(--accent-ring); outline-offset:2px; }
|
|
511
|
+
ol.frames { list-style:none; margin:0; padding:0; background:var(--surface); border:1px solid var(--border); border-radius:14px; overflow:hidden; box-shadow:var(--shadow); }
|
|
512
|
+
.frame { display:flex; align-items:center; gap:14px; padding:11px 16px; border-bottom:1px solid var(--border); }
|
|
513
|
+
.frame:last-child { border-bottom:0; }
|
|
514
|
+
.fi { flex:0 0 22px; color:var(--text-3); font-size:12px; text-align:right; }
|
|
515
|
+
.fmain { flex:1; min-width:0; display:flex; flex-direction:column; gap:1px; }
|
|
516
|
+
.ffn { font-weight:600; font-size:13.5px; } .floc { font-size:12px; color:var(--text-2); word-break:break-all; }
|
|
517
|
+
.floc .dir { color:var(--text-3); } .floc b { color:var(--text); font-weight:600; }
|
|
518
|
+
.tag { flex:none; font-size:10px; font-weight:700; letter-spacing:.06em; text-transform:uppercase; padding:2px 8px;
|
|
519
|
+
border-radius:999px; color:var(--text-3); border:1px solid var(--border-strong); }
|
|
520
|
+
.tag-app { color:var(--accent); background:var(--accent-soft); border-color:var(--accent-ring); }
|
|
521
|
+
.frame.app { background:linear-gradient(90deg, var(--accent-soft), transparent 60%); }
|
|
522
|
+
.frame--first { background:linear-gradient(90deg, var(--danger-soft), transparent 70%); box-shadow:inset 3px 0 0 var(--danger); }
|
|
523
|
+
.frame.vendor, .frame.internal { opacity:.72; }
|
|
524
|
+
.frames:not(.show-all) .frame.vendor, .frames:not(.show-all) .frame.internal { display:none; }
|
|
525
|
+
|
|
526
|
+
/* request / raw */
|
|
527
|
+
.sections { display:grid; gap:18px; }
|
|
528
|
+
.section { padding:0; } .section .body { padding:6px 16px 14px; }
|
|
529
|
+
.kv-row { display:flex; gap:20px; padding:9px 0; border-bottom:1px solid var(--border); font-size:12.5px; }
|
|
530
|
+
.kv-row:last-child { border-bottom:0; }
|
|
531
|
+
.kv-k { flex:0 0 190px; color:var(--text-3); word-break:break-word; } .kv-v { flex:1; word-break:break-all; }
|
|
532
|
+
@media (max-width: 700px) { .kv-row { flex-direction:column; gap:2px; } .kv-k { flex:none; } }
|
|
533
|
+
pre.raw { margin:0; padding:16px; font-size:12px; line-height:1.65; overflow:auto; max-height:70vh; background:var(--code-bg); }
|
|
534
|
+
|
|
535
|
+
.foot { margin-top:30px; text-align:center; font-size:12px; color:var(--text-3); line-height:1.8; }
|
|
536
|
+
.foot code { background:var(--surface); border:1px solid var(--border); border-radius:6px; padding:1px 6px; color:var(--text-2); }
|
|
537
|
+
|
|
538
|
+
#toast { position:fixed; left:50%; bottom:26px; transform:translate(-50%, 20px); opacity:0; pointer-events:none;
|
|
539
|
+
background:var(--text); color:var(--bg); font-size:13px; font-weight:600; padding:9px 16px; border-radius:999px;
|
|
540
|
+
transition:opacity .15s, transform .15s; z-index:50; }
|
|
541
|
+
#toast.show { opacity:1; transform:translate(-50%, 0); }
|
|
542
|
+
`
|
|
543
|
+
|
|
544
|
+
// ---------------------------------------------------------------
|
|
545
|
+
// Page
|
|
546
|
+
// ---------------------------------------------------------------
|
|
547
|
+
export function renderDebugPage(p) {
|
|
548
|
+
const driverLabel = p.driver ? (DRIVER_LABELS[p.driver] ?? p.driver) : null
|
|
549
|
+
const firstLine = String(p.message).split('\n')[0]
|
|
550
|
+
const headline = p.title || firstLine
|
|
551
|
+
const showMessage = p.title || String(p.message).includes('\n')
|
|
552
|
+
const appFrames = p.frames.filter((f) => f.kind === 'app').length
|
|
553
|
+
const driverSaid = p.cause && p.cause.message !== p.message
|
|
554
|
+
|
|
555
|
+
const json = JSON.stringify(p).replace(/</g, '\\u003c').replace(/\u2028|\u2029/g, '')
|
|
556
|
+
|
|
557
|
+
return `<!DOCTYPE html>
|
|
558
|
+
<html lang="en">
|
|
559
|
+
<head>
|
|
560
|
+
<meta charset="UTF-8" />
|
|
561
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
562
|
+
<title>${esc(p.status)} · ${esc(headline)}</title>
|
|
563
|
+
<script>
|
|
564
|
+
(function () {
|
|
565
|
+
var stored = null;
|
|
566
|
+
try { stored = localStorage.getItem("theme"); } catch (e) {}
|
|
567
|
+
var prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
568
|
+
if (stored === "dark" || (!stored && prefersDark)) document.documentElement.classList.add("dark");
|
|
569
|
+
})();
|
|
570
|
+
</script>
|
|
571
|
+
<style>${CSS}</style>
|
|
572
|
+
</head>
|
|
573
|
+
<body>
|
|
574
|
+
<div class="topbar"><div class="topbar-in">
|
|
575
|
+
<div class="brand"><span class="logo">${ICONS.bolt}</span>Tylix <small>Debug</small></div>
|
|
576
|
+
<div class="top-right">
|
|
577
|
+
<span class="mono">Node ${esc(p.env.node)} · ${esc(p.env.nodeEnv)}</span>
|
|
578
|
+
<button class="btn btn-icon" id="theme-toggle" title="Toggle theme (t)" aria-label="Toggle theme">${ICONS.sun}${ICONS.moon}</button>
|
|
579
|
+
</div>
|
|
580
|
+
</div></div>
|
|
581
|
+
|
|
582
|
+
<div class="shell">
|
|
583
|
+
<header class="hero">
|
|
584
|
+
<div class="chips">
|
|
585
|
+
<span class="chip danger">${esc(p.status)} ${esc(STATUS_TEXT[p.status] ?? '')}</span>
|
|
586
|
+
<span class="chip">${esc(p.name)}</span>
|
|
587
|
+
${driverLabel ? `<span class="chip accent">${esc(driverLabel)}</span>` : ''}
|
|
588
|
+
${p.kind ? `<span class="chip">${esc(p.kind.replace(/_/g, ' '))}</span>` : ''}
|
|
589
|
+
${p.code ? `<span class="chip mono">${esc(p.code)}</span>` : ''}
|
|
590
|
+
</div>
|
|
591
|
+
<h1>${esc(headline)}</h1>
|
|
592
|
+
${showMessage ? `<p class="message mono">${esc(p.message)}</p>` : ''}
|
|
593
|
+
<div class="reqline">
|
|
594
|
+
<span class="method">${esc(p.request.method)}</span>
|
|
595
|
+
<span class="url mono">${esc(p.request.url)}</span>
|
|
596
|
+
</div>
|
|
597
|
+
<div class="hero-actions">
|
|
598
|
+
<button class="btn" data-copy="md">${ICONS.copy}<span>Copy as Markdown</span></button>
|
|
599
|
+
<button class="btn" data-copy="json">${ICONS.copy}<span>Copy JSON</span></button>
|
|
600
|
+
</div>
|
|
601
|
+
</header>
|
|
602
|
+
|
|
603
|
+
<nav class="tabs">
|
|
604
|
+
<button class="tab" data-tab="overview">Overview <kbd>1</kbd></button>
|
|
605
|
+
<button class="tab" data-tab="stack">Stack trace <span class="count">${appFrames} yours</span> <kbd>2</kbd></button>
|
|
606
|
+
<button class="tab" data-tab="request">Request <kbd>3</kbd></button>
|
|
607
|
+
<button class="tab" data-tab="raw">Raw <kbd>4</kbd></button>
|
|
608
|
+
</nav>
|
|
609
|
+
|
|
610
|
+
<div class="panel" id="panel-overview">
|
|
611
|
+
<div class="grid">
|
|
612
|
+
<div class="stack-col">
|
|
613
|
+
${
|
|
614
|
+
p.hint
|
|
615
|
+
? `<div class="callout fix"><span class="ci">${ICONS.bulb}</span><div><strong>How to fix</strong>${esc(p.hint)}</div></div>`
|
|
616
|
+
: ''
|
|
617
|
+
}
|
|
618
|
+
${
|
|
619
|
+
driverSaid
|
|
620
|
+
? `<div class="callout cause"><span class="ci">${ICONS.alert}</span><div><strong>The driver said</strong><span class="mono">${esc(
|
|
621
|
+
p.cause.name,
|
|
622
|
+
)}${p.cause.code ? ` (${esc(p.cause.code)})` : ''}: ${esc(p.cause.message)}</span></div></div>`
|
|
623
|
+
: ''
|
|
624
|
+
}
|
|
625
|
+
${renderSource(p.source, p.env.cwd)}
|
|
626
|
+
${renderSql(p)}
|
|
627
|
+
${
|
|
628
|
+
!p.hint && !p.source && !p.sql
|
|
629
|
+
? '<p class="muted">No extra details for this error. Open the Stack trace tab.</p>'
|
|
630
|
+
: ''
|
|
631
|
+
}
|
|
632
|
+
</div>
|
|
633
|
+
${glance(p)}
|
|
634
|
+
</div>
|
|
635
|
+
</div>
|
|
636
|
+
|
|
637
|
+
<div class="panel" id="panel-stack" hidden>${renderFrames(p.frames)}</div>
|
|
638
|
+
|
|
639
|
+
<div class="panel" id="panel-request" hidden>
|
|
640
|
+
<div class="sections">
|
|
641
|
+
<section class="card section"><div class="card-head"><h2>Request</h2></div><div class="body">${kvRows({
|
|
642
|
+
Method: p.request.method,
|
|
643
|
+
URL: p.request.url,
|
|
644
|
+
'Client IP': p.request.ip,
|
|
645
|
+
})}</div></section>
|
|
646
|
+
<section class="card section"><div class="card-head"><h2>Query string</h2></div><div class="body">${kvRows(
|
|
647
|
+
p.request.query,
|
|
648
|
+
)}</div></section>
|
|
649
|
+
<section class="card section"><div class="card-head"><h2>Route params</h2></div><div class="body">${kvRows(
|
|
650
|
+
p.request.params,
|
|
651
|
+
)}</div></section>
|
|
652
|
+
<section class="card section"><div class="card-head"><h2>Body</h2></div>${
|
|
653
|
+
p.request.body
|
|
654
|
+
? `<pre class="raw mono">${esc(p.request.body)}</pre>`
|
|
655
|
+
: '<div class="body"><p class="muted">Empty</p></div>'
|
|
656
|
+
}</section>
|
|
657
|
+
<section class="card section"><div class="card-head"><h2>Headers</h2></div><div class="body">${kvRows(
|
|
658
|
+
p.request.headers,
|
|
659
|
+
)}</div></section>
|
|
660
|
+
<section class="card section"><div class="card-head"><h2>Environment</h2></div><div class="body">${kvRows({
|
|
661
|
+
Node: p.env.node,
|
|
662
|
+
Platform: p.env.platform,
|
|
663
|
+
NODE_ENV: p.env.nodeEnv,
|
|
664
|
+
'Working directory': p.env.cwd,
|
|
665
|
+
})}</div></section>
|
|
666
|
+
</div>
|
|
667
|
+
</div>
|
|
668
|
+
|
|
669
|
+
<div class="panel" id="panel-raw" hidden>
|
|
670
|
+
<section class="card">
|
|
671
|
+
<div class="card-head"><h2>Raw payload</h2>
|
|
672
|
+
<div class="card-tools"><button class="btn btn-sm" data-copy="raw">${ICONS.copy}<span>Copy JSON</span></button></div></div>
|
|
673
|
+
<pre class="raw mono">${esc(JSON.stringify(p, null, 2))}</pre>
|
|
674
|
+
</section>
|
|
675
|
+
</div>
|
|
676
|
+
|
|
677
|
+
<footer class="foot">
|
|
678
|
+
Debug mode is on. Set <code>APP_DEBUG=false</code> in production, because this page shows SQL, request data and source code.<br />
|
|
679
|
+
Shortcuts: <code>1</code>–<code>4</code> switch tabs · <code>t</code> toggles theme
|
|
680
|
+
</footer>
|
|
681
|
+
</div>
|
|
682
|
+
|
|
683
|
+
<div id="toast" role="status" aria-live="polite"></div>
|
|
684
|
+
<script id="debug-data" type="application/json">${json}</script>
|
|
685
|
+
<script>(${clientMain.toString()})()</script>
|
|
686
|
+
</body>
|
|
687
|
+
</html>`
|
|
688
|
+
}
|