@stacksjs/components 0.2.855 → 0.2.858
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/dist/ContextMenu-43g3w5tp.stx +188 -0
- package/dist/DataGrid-7rt7v865.stx +376 -0
- package/dist/GraphView-0t3t9mec.stx +320 -0
- package/dist/JsonTree-satc4010.stx +317 -0
- package/dist/PreviewFrame-erbgvzj8.stx +257 -0
- package/dist/SplitPane-7sqfdwqa.stx +159 -0
- package/dist/component-api/component-api.js +36 -0
- package/dist/context-menu/context-menu.js +575 -0
- package/dist/data-grid/data-grid.js +1244 -0
- package/dist/graph-view/graph-view.js +1408 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +22 -20
- package/dist/json-tree/json-tree.js +1121 -0
- package/dist/preview-frame/preview-frame.js +356 -0
- package/dist/split-pane/split-pane.js +364 -0
- package/dist/ui/context-menu/ContextMenu.d.ts +14 -0
- package/dist/ui/context-menu/context-menu.d.ts +8 -0
- package/dist/ui/context-menu/core.d.ts +74 -0
- package/dist/ui/context-menu/index.d.ts +11 -0
- package/dist/ui/context-menu/view.d.ts +36 -0
- package/dist/ui/data-grid/DataGrid.d.ts +30 -0
- package/dist/ui/data-grid/core.d.ts +141 -0
- package/dist/ui/data-grid/data-grid.d.ts +9 -0
- package/dist/ui/data-grid/index.d.ts +20 -0
- package/dist/ui/data-grid/view.d.ts +56 -0
- package/dist/ui/graph-view/GraphView.d.ts +21 -0
- package/dist/ui/graph-view/core/edges.d.ts +34 -0
- package/dist/ui/graph-view/core/force.d.ts +10 -0
- package/dist/ui/graph-view/core/graph.d.ts +83 -0
- package/dist/ui/graph-view/core/index.d.ts +5 -0
- package/dist/ui/graph-view/core/layered.d.ts +24 -0
- package/dist/ui/graph-view/core/viewport.d.ts +34 -0
- package/dist/ui/graph-view/graph-view.d.ts +9 -0
- package/dist/ui/graph-view/index.d.ts +21 -0
- package/dist/ui/graph-view/view.d.ts +51 -0
- package/dist/ui/json-tree/JsonTree.d.ts +18 -0
- package/dist/ui/json-tree/core.d.ts +108 -0
- package/dist/ui/json-tree/index.d.ts +18 -0
- package/dist/ui/json-tree/json-tree.d.ts +10 -0
- package/dist/ui/json-tree/tinker.d.ts +84 -0
- package/dist/ui/json-tree/view.d.ts +59 -0
- package/dist/ui/preview-frame/PreviewFrame.d.ts +44 -0
- package/dist/ui/preview-frame/core.d.ts +81 -0
- package/dist/ui/preview-frame/index.d.ts +19 -0
- package/dist/ui/preview-frame/preview-frame.d.ts +8 -0
- package/dist/ui/preview-frame/view.d.ts +37 -0
- package/dist/ui/split-pane/SplitPane.d.ts +18 -0
- package/dist/ui/split-pane/core.d.ts +58 -0
- package/dist/ui/split-pane/index.d.ts +15 -0
- package/dist/ui/split-pane/split-pane.d.ts +8 -0
- package/dist/ui/split-pane/view.d.ts +27 -0
- package/dist/ui/virtual-table/index.d.ts +6 -0
- package/dist/utils/component-api.d.ts +4 -0
- package/package.json +38 -3
- package/src/index.ts +8 -0
- package/src/ui/code-editor/README.md +2 -1
- package/src/ui/context-menu/ContextMenu.stx +188 -0
- package/src/ui/context-menu/README.md +117 -0
- package/src/ui/context-menu/context-menu.ts +8 -0
- package/src/ui/context-menu/core.ts +250 -0
- package/src/ui/context-menu/index.ts +16 -0
- package/src/ui/context-menu/view.ts +540 -0
- package/src/ui/data-grid/DataGrid.stx +376 -0
- package/src/ui/data-grid/README.md +204 -0
- package/src/ui/data-grid/core.ts +813 -0
- package/src/ui/data-grid/data-grid.ts +9 -0
- package/src/ui/data-grid/index.ts +34 -0
- package/src/ui/data-grid/view.ts +806 -0
- package/src/ui/graph-view/GraphView.stx +320 -0
- package/src/ui/graph-view/README.md +210 -0
- package/src/ui/graph-view/core/edges.ts +180 -0
- package/src/ui/graph-view/core/force.ts +237 -0
- package/src/ui/graph-view/core/graph.ts +277 -0
- package/src/ui/graph-view/core/index.ts +5 -0
- package/src/ui/graph-view/core/layered.ts +256 -0
- package/src/ui/graph-view/core/viewport.ts +141 -0
- package/src/ui/graph-view/graph-view.ts +9 -0
- package/src/ui/graph-view/index.ts +35 -0
- package/src/ui/graph-view/view.ts +809 -0
- package/src/ui/json-tree/JsonTree.stx +317 -0
- package/src/ui/json-tree/README.md +193 -0
- package/src/ui/json-tree/core.ts +588 -0
- package/src/ui/json-tree/index.ts +28 -0
- package/src/ui/json-tree/json-tree.ts +10 -0
- package/src/ui/json-tree/tinker.ts +349 -0
- package/src/ui/json-tree/view.ts +665 -0
- package/src/ui/preview-frame/PreviewFrame.stx +257 -0
- package/src/ui/preview-frame/README.md +107 -0
- package/src/ui/preview-frame/core.ts +195 -0
- package/src/ui/preview-frame/index.ts +31 -0
- package/src/ui/preview-frame/preview-frame.ts +8 -0
- package/src/ui/preview-frame/view.ts +336 -0
- package/src/ui/split-pane/README.md +87 -0
- package/src/ui/split-pane/SplitPane.stx +159 -0
- package/src/ui/split-pane/core.ts +200 -0
- package/src/ui/split-pane/index.ts +24 -0
- package/src/ui/split-pane/split-pane.ts +8 -0
- package/src/ui/split-pane/view.ts +305 -0
- package/src/ui/virtual-table/index.ts +6 -0
- package/src/utils/component-api.ts +72 -0
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tinker results as tree nodes.
|
|
3
|
+
*
|
|
4
|
+
* `@stacksjs/tinker` describes any runtime value as a bounded, JSON-safe tree
|
|
5
|
+
* of tagged nodes (`serialize.ts` in that package). This turns one of those
|
|
6
|
+
* into the generic nodes `./core` shows. The type below is a structural copy,
|
|
7
|
+
* so this package needs no dependency on that one and a value from any
|
|
8
|
+
* version that keeps the shape is accepted.
|
|
9
|
+
*/
|
|
10
|
+
import type { TreeNode, TreeOpenKind } from './core'
|
|
11
|
+
|
|
12
|
+
export interface TinkerStackFrame {
|
|
13
|
+
function?: string
|
|
14
|
+
file?: string
|
|
15
|
+
line?: number
|
|
16
|
+
column?: number
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface TinkerErrorValue {
|
|
20
|
+
t: 'error'
|
|
21
|
+
name: string
|
|
22
|
+
message: string
|
|
23
|
+
stack?: string
|
|
24
|
+
frames?: TinkerStackFrame[]
|
|
25
|
+
cause?: TinkerValue
|
|
26
|
+
entries?: Array<[string, TinkerValue]>
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface TinkerModelValue {
|
|
30
|
+
t: 'model'
|
|
31
|
+
id: number
|
|
32
|
+
model: string
|
|
33
|
+
table?: string
|
|
34
|
+
primaryKey?: string
|
|
35
|
+
key?: TinkerValue
|
|
36
|
+
attributes: Array<[string, TinkerValue]>
|
|
37
|
+
hidden?: string[]
|
|
38
|
+
loaded?: Array<[string, TinkerValue]>
|
|
39
|
+
relations?: Array<{ kind: string, model: string, name?: string }>
|
|
40
|
+
more?: number
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface TinkerHtmlValue {
|
|
44
|
+
t: 'html'
|
|
45
|
+
kind: 'mail' | 'view' | 'html'
|
|
46
|
+
title?: string
|
|
47
|
+
html: string
|
|
48
|
+
text?: string
|
|
49
|
+
truncated?: number
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export type TinkerValue =
|
|
53
|
+
| { t: 'undefined' }
|
|
54
|
+
| { t: 'null' }
|
|
55
|
+
| { t: 'boolean', v: boolean }
|
|
56
|
+
| { t: 'number', v: number | 'NaN' | 'Infinity' | '-Infinity' | '-0' }
|
|
57
|
+
| { t: 'bigint', v: string }
|
|
58
|
+
| { t: 'string', v: string, truncated?: number }
|
|
59
|
+
| { t: 'symbol', v: string }
|
|
60
|
+
| { t: 'function', name: string, kind: 'function' | 'async' | 'class' | 'generator' }
|
|
61
|
+
| { t: 'date', v: string | null }
|
|
62
|
+
| { t: 'regexp', v: string }
|
|
63
|
+
| { t: 'url', v: string }
|
|
64
|
+
| { t: 'promise' }
|
|
65
|
+
| { t: 'bytes', ctor: string, length: number, hex: string }
|
|
66
|
+
| { t: 'array', id: number, ctor?: string, length: number, items: TinkerValue[], more?: number }
|
|
67
|
+
| { t: 'object', id: number, ctor?: string, entries: Array<[string, TinkerValue]>, more?: number }
|
|
68
|
+
| { t: 'map', id: number, size: number, entries: Array<[TinkerValue, TinkerValue]>, more?: number }
|
|
69
|
+
| { t: 'set', id: number, size: number, items: TinkerValue[], more?: number }
|
|
70
|
+
| TinkerModelValue
|
|
71
|
+
| TinkerHtmlValue
|
|
72
|
+
| { t: 'ref', id: number }
|
|
73
|
+
| { t: 'cut', reason: 'depth' | 'nodes', ctor?: string }
|
|
74
|
+
| TinkerErrorValue
|
|
75
|
+
|
|
76
|
+
export interface FromTinkerOptions {
|
|
77
|
+
/**
|
|
78
|
+
* Put in front of every node id. Two results shown in one tree both number
|
|
79
|
+
* their objects from one, so each needs its own prefix for a cycle to point
|
|
80
|
+
* at the right node. Default `t`.
|
|
81
|
+
*/
|
|
82
|
+
idPrefix?: string
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** What the tree's `meta` holds for a model node. */
|
|
86
|
+
export interface TinkerModelMeta {
|
|
87
|
+
model: string
|
|
88
|
+
table?: string
|
|
89
|
+
primaryKey?: string
|
|
90
|
+
hidden: string[]
|
|
91
|
+
relations: Array<{ kind: string, model: string, name?: string }>
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** What the tree's `meta` holds for rendered markup. */
|
|
95
|
+
export interface TinkerHtmlMeta {
|
|
96
|
+
kind: TinkerHtmlValue['kind']
|
|
97
|
+
title?: string
|
|
98
|
+
text?: string
|
|
99
|
+
truncated?: number
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const CONTAINERS = new Set(['array', 'object', 'map', 'set', 'model', 'error'])
|
|
103
|
+
const STRING_PREVIEW = 120
|
|
104
|
+
const SUMMARY_KEYS = 5
|
|
105
|
+
|
|
106
|
+
function isRecordLike(value: TinkerValue): boolean {
|
|
107
|
+
return value.t === 'object' || value.t === 'model'
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Whether a value reads as rows: a list whose members are objects or models. */
|
|
111
|
+
function isTabular(items: TinkerValue[]): boolean {
|
|
112
|
+
return items.length > 0 && items.slice(0, 20).every(isRecordLike)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function hasNestedContainer(values: TinkerValue[]): boolean {
|
|
116
|
+
return values.some(value => CONTAINERS.has(value.t))
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function quoted(text: string, truncated?: number): string {
|
|
120
|
+
const shown = text.length > STRING_PREVIEW ? `${text.slice(0, STRING_PREVIEW)}…` : text
|
|
121
|
+
return truncated ? `${JSON.stringify(shown)} (${truncated} more characters)` : JSON.stringify(shown)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function frameLocation(frame: TinkerStackFrame): string {
|
|
125
|
+
if (!frame.file)
|
|
126
|
+
return ''
|
|
127
|
+
return [frame.file, frame.line, frame.column].filter(part => part !== undefined).join(':')
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Turn a tinker value into a tree node.
|
|
132
|
+
*
|
|
133
|
+
* Every container keeps the serializer's object id (prefixed), which is what a
|
|
134
|
+
* `ref` names, so following a cycle in the tree lands on the right node.
|
|
135
|
+
*/
|
|
136
|
+
export function fromTinkerValue(value: TinkerValue, label?: string, options: FromTinkerOptions = {}): TreeNode {
|
|
137
|
+
const prefix = options.idPrefix ?? 't'
|
|
138
|
+
const idOf = (id: number): string => `${prefix}${id}`
|
|
139
|
+
|
|
140
|
+
const named = (node: TreeNode, name: string | undefined): TreeNode => {
|
|
141
|
+
if (name !== undefined)
|
|
142
|
+
node.label = name
|
|
143
|
+
return node
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const short = (inner: TinkerValue): string => walk(inner, undefined).preview ?? inner.t
|
|
147
|
+
|
|
148
|
+
const open = (node: TreeNode, kinds: TreeOpenKind[]): TreeNode => {
|
|
149
|
+
if (kinds.length > 0)
|
|
150
|
+
node.openable = kinds.length === 1 ? kinds[0] : kinds
|
|
151
|
+
return node
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function walk(current: TinkerValue, name: string | undefined): TreeNode {
|
|
155
|
+
switch (current.t) {
|
|
156
|
+
case 'undefined':
|
|
157
|
+
return named({ kind: 'undefined', value: undefined, preview: 'undefined' }, name)
|
|
158
|
+
case 'null':
|
|
159
|
+
return named({ kind: 'null', value: null, preview: 'null' }, name)
|
|
160
|
+
case 'boolean':
|
|
161
|
+
return named({ kind: 'boolean', value: current.v, preview: String(current.v) }, name)
|
|
162
|
+
case 'number': {
|
|
163
|
+
const number = typeof current.v === 'number' ? current.v : (current.v === '-0' ? -0 : Number(current.v))
|
|
164
|
+
return named({ kind: 'number', value: number, preview: String(current.v) }, name)
|
|
165
|
+
}
|
|
166
|
+
case 'bigint':
|
|
167
|
+
return named({ kind: 'bigint', value: current.v, preview: `${current.v}n` }, name)
|
|
168
|
+
case 'string':
|
|
169
|
+
return named({ kind: 'string', value: current.v, preview: quoted(current.v, current.truncated) }, name)
|
|
170
|
+
case 'symbol':
|
|
171
|
+
return named({ kind: 'symbol', preview: `Symbol(${current.v})` }, name)
|
|
172
|
+
case 'function': {
|
|
173
|
+
const preview = current.kind === 'class'
|
|
174
|
+
? `class ${current.name}`
|
|
175
|
+
: `${current.kind === 'async' ? 'async ' : ''}ƒ${current.kind === 'generator' ? '*' : ''} ${current.name}()`
|
|
176
|
+
return named({ kind: 'function', preview }, name)
|
|
177
|
+
}
|
|
178
|
+
case 'date':
|
|
179
|
+
return named({ kind: 'date', value: current.v, preview: current.v ?? 'Invalid Date' }, name)
|
|
180
|
+
case 'regexp':
|
|
181
|
+
return named({ kind: 'regexp', value: current.v, preview: current.v }, name)
|
|
182
|
+
case 'url':
|
|
183
|
+
return named({ kind: 'url', value: current.v, preview: current.v }, name)
|
|
184
|
+
case 'promise':
|
|
185
|
+
return named({ kind: 'promise', preview: 'Promise' }, name)
|
|
186
|
+
case 'bytes': {
|
|
187
|
+
const cut = current.length * 2 > current.hex.length
|
|
188
|
+
return named({ kind: 'bytes', value: current.hex, preview: `${current.ctor}(${current.length}) <${current.hex}${cut ? '…' : ''}>` }, name)
|
|
189
|
+
}
|
|
190
|
+
case 'ref':
|
|
191
|
+
return named({ kind: 'ref', ref: idOf(current.id), preview: '[Circular]' }, name)
|
|
192
|
+
case 'cut':
|
|
193
|
+
return named({ kind: 'cut', preview: `${current.ctor ?? 'Object'} … (${current.reason === 'depth' ? 'too deep to show' : 'result too large to show'})` }, name)
|
|
194
|
+
|
|
195
|
+
case 'array': {
|
|
196
|
+
const node: TreeNode = {
|
|
197
|
+
id: idOf(current.id),
|
|
198
|
+
kind: 'array',
|
|
199
|
+
preview: `${current.ctor ?? 'Array'}(${current.length})`,
|
|
200
|
+
children: current.items.map((item, index) => walk(item, String(index))),
|
|
201
|
+
}
|
|
202
|
+
if (current.more)
|
|
203
|
+
node.more = current.more
|
|
204
|
+
return named(open(node, isTabular(current.items) ? ['table'] : []), name)
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
case 'set': {
|
|
208
|
+
const node: TreeNode = {
|
|
209
|
+
id: idOf(current.id),
|
|
210
|
+
kind: 'set',
|
|
211
|
+
preview: `Set(${current.size})`,
|
|
212
|
+
children: current.items.map((item, index) => walk(item, String(index))),
|
|
213
|
+
}
|
|
214
|
+
if (current.more)
|
|
215
|
+
node.more = current.more
|
|
216
|
+
return named(open(node, isTabular(current.items) ? ['table'] : []), name)
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
case 'object': {
|
|
220
|
+
const keys = current.entries.slice(0, SUMMARY_KEYS).map(([key]) => key).join(', ')
|
|
221
|
+
const total = current.entries.length + (current.more ?? 0)
|
|
222
|
+
const body = total === 0 ? '{}' : `{${keys}${total > SUMMARY_KEYS ? ', …' : ''}}`
|
|
223
|
+
const node: TreeNode = {
|
|
224
|
+
id: idOf(current.id),
|
|
225
|
+
kind: 'object',
|
|
226
|
+
preview: current.ctor && current.ctor !== 'Object' ? `${current.ctor} ${body}` : body,
|
|
227
|
+
children: current.entries.map(([key, inner]) => walk(inner, key)),
|
|
228
|
+
}
|
|
229
|
+
if (current.more)
|
|
230
|
+
node.more = current.more
|
|
231
|
+
return named(open(node, hasNestedContainer(current.entries.map(entry => entry[1])) ? ['graph'] : []), name)
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
case 'map': {
|
|
235
|
+
const node: TreeNode = {
|
|
236
|
+
id: idOf(current.id),
|
|
237
|
+
kind: 'map',
|
|
238
|
+
preview: `Map(${current.size})`,
|
|
239
|
+
children: current.entries.map(([key, inner], index) => {
|
|
240
|
+
// A scalar key names its entry. A key that is itself a container
|
|
241
|
+
// has to be shown, so the entry holds both sides.
|
|
242
|
+
if (!CONTAINERS.has(key.t)) {
|
|
243
|
+
const child = walk(inner, short(key))
|
|
244
|
+
child.key = key.t === 'string' ? key.v : short(key)
|
|
245
|
+
return child
|
|
246
|
+
}
|
|
247
|
+
return { kind: 'entry', label: String(index), key: index, preview: `${short(key)} => ${short(inner)}`, children: [walk(key, 'key'), walk(inner, 'value')] }
|
|
248
|
+
}),
|
|
249
|
+
}
|
|
250
|
+
if (current.more)
|
|
251
|
+
node.more = current.more
|
|
252
|
+
return named(open(node, hasNestedContainer(current.entries.map(entry => entry[1])) ? ['graph'] : []), name)
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
case 'model': {
|
|
256
|
+
const children = current.attributes.map(([key, inner]) => walk(inner, key))
|
|
257
|
+
for (const [relation, inner] of current.loaded ?? []) {
|
|
258
|
+
const child = walk(inner, relation)
|
|
259
|
+
child.meta = child.meta ?? { relation: true }
|
|
260
|
+
children.push(child)
|
|
261
|
+
}
|
|
262
|
+
if (current.hidden?.length) {
|
|
263
|
+
children.push({
|
|
264
|
+
kind: 'hidden',
|
|
265
|
+
label: '[hidden]',
|
|
266
|
+
key: '[hidden]',
|
|
267
|
+
preview: current.hidden.join(', '),
|
|
268
|
+
children: current.hidden.map((hidden, index) => ({ kind: 'hidden', label: String(index), value: hidden, preview: hidden })),
|
|
269
|
+
})
|
|
270
|
+
}
|
|
271
|
+
if (current.relations?.length) {
|
|
272
|
+
children.push({
|
|
273
|
+
kind: 'relations',
|
|
274
|
+
label: '[relations]',
|
|
275
|
+
key: '[relations]',
|
|
276
|
+
preview: `${current.relations.length} declared`,
|
|
277
|
+
children: current.relations.map(relation => ({
|
|
278
|
+
kind: 'relation',
|
|
279
|
+
label: relation.name ?? relation.model,
|
|
280
|
+
value: relation,
|
|
281
|
+
preview: `${relation.kind} ${relation.model}`,
|
|
282
|
+
})),
|
|
283
|
+
})
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
const meta: TinkerModelMeta = { model: current.model, hidden: current.hidden ?? [], relations: current.relations ?? [] }
|
|
287
|
+
if (current.table)
|
|
288
|
+
meta.table = current.table
|
|
289
|
+
if (current.primaryKey)
|
|
290
|
+
meta.primaryKey = current.primaryKey
|
|
291
|
+
const node: TreeNode = {
|
|
292
|
+
id: idOf(current.id),
|
|
293
|
+
kind: 'model',
|
|
294
|
+
preview: current.key ? `${current.model} #${short(current.key).replace(/^"|"$/g, '')}` : current.model,
|
|
295
|
+
children,
|
|
296
|
+
meta,
|
|
297
|
+
}
|
|
298
|
+
if (current.more)
|
|
299
|
+
node.more = current.more
|
|
300
|
+
return named(open(node, ['graph']), name)
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
case 'html': {
|
|
304
|
+
const meta: TinkerHtmlMeta = { kind: current.kind }
|
|
305
|
+
if (current.title)
|
|
306
|
+
meta.title = current.title
|
|
307
|
+
if (current.text)
|
|
308
|
+
meta.text = current.text
|
|
309
|
+
if (current.truncated)
|
|
310
|
+
meta.truncated = current.truncated
|
|
311
|
+
const cut = current.truncated ? `, ${current.truncated} more cut` : ''
|
|
312
|
+
const title = current.title ? `: ${current.title}` : ''
|
|
313
|
+
return named(open({ kind: 'html', value: current.html, preview: `${current.kind}${title} (${current.html.length} characters${cut})`, meta }, ['preview']), name)
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
case 'error': {
|
|
317
|
+
const children: TreeNode[] = [{ kind: 'string', label: 'message', value: current.message, preview: quoted(current.message) }]
|
|
318
|
+
if (current.frames?.length) {
|
|
319
|
+
children.push({
|
|
320
|
+
kind: 'stack',
|
|
321
|
+
label: 'stack',
|
|
322
|
+
preview: `${current.frames.length} frames`,
|
|
323
|
+
value: current.stack,
|
|
324
|
+
children: current.frames.map((frame, index) => ({
|
|
325
|
+
kind: 'frame',
|
|
326
|
+
label: String(index),
|
|
327
|
+
value: frame,
|
|
328
|
+
preview: [frame.function, frameLocation(frame)].filter(Boolean).join(' at ') || '(unknown)',
|
|
329
|
+
meta: frame,
|
|
330
|
+
})),
|
|
331
|
+
})
|
|
332
|
+
}
|
|
333
|
+
else if (current.stack) {
|
|
334
|
+
children.push({ kind: 'string', label: 'stack', value: current.stack, preview: quoted(current.stack) })
|
|
335
|
+
}
|
|
336
|
+
if (current.cause)
|
|
337
|
+
children.push(walk(current.cause, 'cause'))
|
|
338
|
+
for (const [key, inner] of current.entries ?? [])
|
|
339
|
+
children.push(walk(inner, key))
|
|
340
|
+
return named({ kind: 'error', preview: current.message ? `${current.name}: ${current.message}` : current.name, children }, name)
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// A tag this version does not know: show that it is there instead of dropping it.
|
|
345
|
+
return named({ kind: 'unknown', preview: String((current as { t?: unknown }).t ?? 'unknown') }, name)
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
return walk(value, label)
|
|
349
|
+
}
|