@timber-js/app 0.2.0-alpha.237 → 0.2.0-alpha.239
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/_chunks/chains-CmzbpG-6.js +1 -0
- package/dist/_chunks/{chains-BsGKkMTK.js → chains-DMoHX4yH.js} +2 -2
- package/dist/_chunks/{chains-BsGKkMTK.js.map → chains-DMoHX4yH.js.map} +1 -1
- package/dist/_chunks/{classify-cmE0Gins.js → classify-BwyAd-dZ.js} +3 -3
- package/dist/_chunks/{classify-cmE0Gins.js.map → classify-BwyAd-dZ.js.map} +1 -1
- package/dist/_chunks/{cli-check-BwiahbTC.js → cli-check-DQAD9MLo.js} +3 -3
- package/dist/_chunks/{cli-check-BwiahbTC.js.map → cli-check-DQAD9MLo.js.map} +1 -1
- package/dist/_chunks/{cli-schema-sync-Brw7kTmm.js → cli-schema-sync-C_xNLqBj.js} +1 -1
- package/dist/_chunks/{cli-schema-sync-B2ldclRO.js → cli-schema-sync-CmGls3dc.js} +2 -2
- package/dist/_chunks/{cli-schema-sync-B2ldclRO.js.map → cli-schema-sync-CmGls3dc.js.map} +1 -1
- package/dist/_chunks/{client-dep-entries-C1nMlLKV.js → client-dep-entries-C5BTQtFS.js} +2 -2
- package/dist/_chunks/{client-dep-entries-C1nMlLKV.js.map → client-dep-entries-C5BTQtFS.js.map} +1 -1
- package/dist/_chunks/{convention-lint-CLpuzY5h.js → convention-lint-GQA6WTRo.js} +2 -2
- package/dist/_chunks/{convention-lint-CLpuzY5h.js.map → convention-lint-GQA6WTRo.js.map} +1 -1
- package/dist/_chunks/dev-server--4_Ogy_6.js +1 -0
- package/dist/_chunks/{dev-server-lrdpD7Ws.js → dev-server-Cr3_Fu5A.js} +244 -26
- package/dist/_chunks/dev-server-Cr3_Fu5A.js.map +1 -0
- package/dist/_chunks/dev-span-RsVeYYc_.js.map +1 -1
- package/dist/_chunks/{scanner-CrB_h6FA.js → interception-CtNt9jPt.js} +169 -1043
- package/dist/_chunks/interception-CtNt9jPt.js.map +1 -0
- package/dist/_chunks/{live-graph-ChuFfmLi.js → live-graph-HcLScfiV.js} +4 -4
- package/dist/_chunks/{live-graph-ChuFfmLi.js.map → live-graph-HcLScfiV.js.map} +1 -1
- package/dist/_chunks/{metadata-routes-BL26HCDd.js → metadata-routes-MXNjWOt5.js} +60 -2
- package/dist/_chunks/metadata-routes-MXNjWOt5.js.map +1 -0
- package/dist/_chunks/{poison-scan-CJ9QfJWb.js → poison-scan-DONdiCGX.js} +2 -2
- package/dist/_chunks/{poison-scan-CJ9QfJWb.js.map → poison-scan-DONdiCGX.js.map} +1 -1
- package/dist/_chunks/scanner-DSAJjH0x.js +1043 -0
- package/dist/_chunks/scanner-DSAJjH0x.js.map +1 -0
- package/dist/_chunks/{walkers-BUvpsb2Q.js → walkers-96YopJds.js} +3 -3
- package/dist/_chunks/{walkers-BUvpsb2Q.js.map → walkers-96YopJds.js.map} +1 -1
- package/dist/analyze/crawl-entry.js +3 -3
- package/dist/analyze/graph-command.js +2 -2
- package/dist/cli.js +3 -3
- package/dist/config-types.d.ts +11 -0
- package/dist/config-types.d.ts.map +1 -1
- package/dist/config-validation.d.ts.map +1 -1
- package/dist/dev-tools/instrumentation.d.ts.map +1 -1
- package/dist/dev-tools/log-columns.d.ts +50 -0
- package/dist/dev-tools/log-columns.d.ts.map +1 -0
- package/dist/dev-tools/logger.d.ts +5 -0
- package/dist/dev-tools/logger.d.ts.map +1 -1
- package/dist/index.js +6 -155
- package/dist/index.js.map +1 -1
- package/dist/native/rsc/dev-tools/instrumentation.js +5 -1
- package/dist/native/rsc/dev-tools/instrumentation.js.map +1 -1
- package/dist/native/rsc/dev-tools/log-columns.js +69 -0
- package/dist/native/rsc/dev-tools/log-columns.js.map +1 -0
- package/dist/native/rsc/dev-tools/logger.js +60 -33
- package/dist/native/rsc/dev-tools/logger.js.map +1 -1
- package/dist/native/rsc/manifest.json +1 -0
- package/dist/native/rsc/shared/dev-span.js +5 -2
- package/dist/native/rsc/shared/dev-span.js.map +1 -1
- package/dist/native/rsc/shared/span-waterfall.js +13 -2
- package/dist/native/rsc/shared/span-waterfall.js.map +1 -1
- package/dist/native/ssr/dev-tools/instrumentation.js +5 -1
- package/dist/native/ssr/dev-tools/instrumentation.js.map +1 -1
- package/dist/native/ssr/dev-tools/log-columns.js +69 -0
- package/dist/native/ssr/dev-tools/log-columns.js.map +1 -0
- package/dist/native/ssr/dev-tools/logger.js +60 -33
- package/dist/native/ssr/dev-tools/logger.js.map +1 -1
- package/dist/native/ssr/manifest.json +1 -0
- package/dist/native/ssr/shared/dev-span.js +5 -2
- package/dist/native/ssr/shared/dev-span.js.map +1 -1
- package/dist/native/ssr/shared/span-waterfall.js +13 -2
- package/dist/native/ssr/shared/span-waterfall.js.map +1 -1
- package/dist/plugins/dev-precompile.d.ts +42 -14
- package/dist/plugins/dev-precompile.d.ts.map +1 -1
- package/dist/plugins/dev-server.d.ts.map +1 -1
- package/dist/routing/index.js +3 -2
- package/dist/routing/manifest-codegen.d.ts +2 -0
- package/dist/routing/manifest-codegen.d.ts.map +1 -1
- package/dist/server/internal.js +1 -2
- package/dist/server/internal.js.map +1 -1
- package/dist/shared/dev-span.d.ts +6 -0
- package/dist/shared/dev-span.d.ts.map +1 -1
- package/dist/shared/span-waterfall.d.ts.map +1 -1
- package/docs/api/34-api-config.mdx +18 -0
- package/package.json +1 -1
- package/src/config-types.ts +11 -0
- package/src/config-validation.ts +15 -8
- package/src/dev-tools/instrumentation.ts +4 -1
- package/src/dev-tools/log-columns.ts +156 -0
- package/src/dev-tools/logger.ts +107 -63
- package/src/plugins/dev-precompile.ts +108 -20
- package/src/plugins/dev-server.ts +12 -11
- package/src/routing/manifest-codegen.ts +2 -2
- package/src/shared/dev-span.ts +13 -1
- package/src/shared/span-waterfall.ts +36 -4
- package/dist/_chunks/chains-DHmoKxkO.js +0 -1
- package/dist/_chunks/dev-server-BGGGhHXx.js +0 -1
- package/dist/_chunks/dev-server-lrdpD7Ws.js.map +0 -1
- package/dist/_chunks/metadata-routes-BL26HCDd.js.map +0 -1
- package/dist/_chunks/scanner-CrB_h6FA.js.map +0 -1
- package/dist/_chunks/segment-keys-Y60KNc8C.js +0 -61
- package/dist/_chunks/segment-keys-Y60KNc8C.js.map +0 -1
- package/dist/_chunks/tree-match-Bqdr9szG.js +0 -168
- package/dist/_chunks/tree-match-Bqdr9szG.js.map +0 -1
|
@@ -104,6 +104,12 @@ export declare function traceIdFromServerTiming(timing: string | null | readonly
|
|
|
104
104
|
export declare function traceTimingEntry(traceId: string): string;
|
|
105
105
|
/** Span attributes as either side holds them (OTEL also allows arrays). */
|
|
106
106
|
type SpanAttributes = Readonly<Record<string, unknown>>;
|
|
107
|
+
/**
|
|
108
|
+
* A fetch URL as the terminal tree and the pill show it: without its scheme,
|
|
109
|
+
* which is `https://` for nearly every fetch and only makes the line longer
|
|
110
|
+
* (TIM-1631).
|
|
111
|
+
*/
|
|
112
|
+
export declare function fetchDisplayUrl(url: string): string;
|
|
107
113
|
/**
|
|
108
114
|
* Map a span to its display label and environment tag. One mapping for the
|
|
109
115
|
* terminal tree and the dev request pill, so the two never name a span
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-span.d.ts","sourceRoot":"","sources":["../../src/shared/dev-span.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AACH,eAAO,MAAM,cAAc,gBAAgB,CAAC;AAE5C,uFAAuF;AACvF,eAAO,MAAM,qBAAqB,uBAAuB,CAAC;AAE1D;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,eAAqC,CAAC;AAEpE,0EAA0E;AAC1E,eAAO,MAAM,iBAAiB,iBAAiB,CAAC;AAEhD;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,eAAiC,CAAC;AAE5D,yDAAyD;AACzD,eAAO,MAAM,eAAe,iBAAiB,CAAC;AAE9C;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,sBAAsB,CAAC;AA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estPill?: boolean;
|
|
40
|
+
precompile?: boolean;
|
|
40
41
|
};
|
|
41
42
|
budget?: {
|
|
42
43
|
firstLoadJs?: number;
|
|
@@ -242,6 +243,23 @@ export default {
|
|
|
242
243
|
|
|
243
244
|
It never appears in a browser driven by automation (Playwright, Selenium, Puppeteer), so it can't intercept clicks in your e2e tests.
|
|
244
245
|
|
|
246
|
+
### `dev.precompile`
|
|
247
|
+
|
|
248
|
+
- **Type:** `boolean`
|
|
249
|
+
- **Default:** `true`
|
|
250
|
+
|
|
251
|
+
Once the dev server is listening, compile your app's server code in the background: every route's layouts, pages and route handlers and the modules they statically import, for both server renders, starting with what `/` loads. A dynamic `import()` in your code still compiles at the request that reaches it. Nothing runs, so `instrumentation.ts` still runs at the first request. Without it, the first request to each page waits while Vite compiles its server code one module at a time.
|
|
252
|
+
|
|
253
|
+
Set `false` to leave compiling to each request, for example on a very large app where you only ever open a few routes. `TIMBER_DEV_PRECOMPILE=0` turns it off for a single run.
|
|
254
|
+
|
|
255
|
+
```ts title="timber.config.ts"
|
|
256
|
+
export default {
|
|
257
|
+
dev: {
|
|
258
|
+
precompile: false,
|
|
259
|
+
},
|
|
260
|
+
};
|
|
261
|
+
```
|
|
262
|
+
|
|
245
263
|
### `dev.hostname`
|
|
246
264
|
|
|
247
265
|
- **Type:** `string | false`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@timber-js/app",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.239",
|
|
4
4
|
"description": "Vite-native React framework built for Servers and Serverless Platforms — correct HTTP semantics, real status codes, pages that work without JavaScript",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare-workers",
|
package/src/config-types.ts
CHANGED
|
@@ -168,6 +168,17 @@ export interface TimberUserConfig {
|
|
|
168
168
|
* Default: `true`. Automated browsers (`navigator.webdriver`) never get it.
|
|
169
169
|
*/
|
|
170
170
|
requestPill?: boolean;
|
|
171
|
+
/**
|
|
172
|
+
* Compile the app's server code in the background once the dev server
|
|
173
|
+
* listens: every route's layouts, pages and handlers and what they
|
|
174
|
+
* import, in the RSC and SSR environments, `/` first. Nothing executes;
|
|
175
|
+
* the first request still runs the modules. `false` leaves compiling to
|
|
176
|
+
* each request, as Vite does by default (`TIMBER_DEV_PRECOMPILE=0` does
|
|
177
|
+
* the same for one run).
|
|
178
|
+
*
|
|
179
|
+
* Default: `true`. See design/21-dev-server.md §"Server Pre-compile".
|
|
180
|
+
*/
|
|
181
|
+
precompile?: boolean;
|
|
171
182
|
};
|
|
172
183
|
/**
|
|
173
184
|
* Control Server-Timing header output.
|
package/src/config-validation.ts
CHANGED
|
@@ -206,14 +206,21 @@ export function validateConfig(config: TimberUserConfig): ConfigError[] {
|
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
-
// dev
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
209
|
+
// Boolean dev switches — not fatal: dev-only, like dev.hostname below.
|
|
210
|
+
const devSwitches = [
|
|
211
|
+
['requestPill', 'the dev request pill'],
|
|
212
|
+
['precompile', 'the background server compile'],
|
|
213
|
+
] as const;
|
|
214
|
+
for (const [key, what] of devSwitches) {
|
|
215
|
+
const value = config.dev?.[key];
|
|
216
|
+
if (value !== undefined && typeof value !== 'boolean') {
|
|
217
|
+
errors.push({
|
|
218
|
+
field: `dev.${key}`,
|
|
219
|
+
message: `dev.${key} must be a boolean, got ${JSON.stringify(value)}.`,
|
|
220
|
+
value,
|
|
221
|
+
suggestion: `Use dev: { ${key}: false } to turn ${what} off.`,
|
|
222
|
+
});
|
|
223
|
+
}
|
|
217
224
|
}
|
|
218
225
|
|
|
219
226
|
// dev.hostname — not fatal: it is dev-only, so a typo must not fail
|
|
@@ -261,7 +261,10 @@ export class DevSpanProcessor implements SpanProcessor {
|
|
|
261
261
|
if (this.mode === 'summary') return formatSpanSummary(spans, this.config);
|
|
262
262
|
// Both 'tree' and 'verbose' use the tree formatter; tree hides
|
|
263
263
|
// explained waits and folds pass-through awaits, verbose prints every span.
|
|
264
|
-
|
|
264
|
+
// Lines are cut to a terminal's width so nothing wraps through the tree;
|
|
265
|
+
// a file or a pipe gets them whole.
|
|
266
|
+
const columns = process.stderr.isTTY ? process.stderr.columns : undefined;
|
|
267
|
+
return formatSpanTree(spans, { ...this.config, columns });
|
|
265
268
|
}
|
|
266
269
|
|
|
267
270
|
async shutdown(): Promise<void> {
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Column layout for the dev request tree: a start and a duration column
|
|
3
|
+
* before the tree, and every line cut to the terminal's width.
|
|
4
|
+
*
|
|
5
|
+
* Lines carry ANSI styling (`util.styleText`), so widths count only what
|
|
6
|
+
* the terminal draws: escape sequences take no columns.
|
|
7
|
+
*
|
|
8
|
+
* See design/21-dev-server.md §"Structured Request Tree" (TIM-1631).
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** SGR sequences (`\x1b[33m`) and OSC 8 hyperlinks (`\x1b]8;;url\x07`). */
|
|
12
|
+
const ESCAPE = /\x1b\[[0-9;]*m|\x1b\]8;;[^\x07]*\x07/y;
|
|
13
|
+
const RESET = '\x1b[0m';
|
|
14
|
+
|
|
15
|
+
/** Marks drawn on the character before them, and invisible format characters (ZWJ). */
|
|
16
|
+
const ZERO_WIDTH = /^[\p{Mn}\p{Me}\p{Cf}]$/u;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Cells a code point takes in a terminal: 0 for combining marks, variation
|
|
20
|
+
* selectors and format characters; 2 for East Asian wide and fullwidth
|
|
21
|
+
* characters (Hangul, CJK, kana, fullwidth forms) and emoji; 1 otherwise.
|
|
22
|
+
* The ranges are the wide blocks of Unicode's East Asian Width (UAX #11)
|
|
23
|
+
* that a URL or a source label can plausibly hold. Codex review on #1295:
|
|
24
|
+
* counting code points let a line with emoji or CJK text still wrap.
|
|
25
|
+
*/
|
|
26
|
+
function cellWidth(codePoint: number, char: string): number {
|
|
27
|
+
if (ZERO_WIDTH.test(char)) return 0;
|
|
28
|
+
const wide =
|
|
29
|
+
(codePoint >= 0x1100 && codePoint <= 0x115f) || // Hangul Jamo
|
|
30
|
+
(codePoint >= 0x2e80 && codePoint <= 0xa4cf && codePoint !== 0x303f) || // CJK … Yi
|
|
31
|
+
(codePoint >= 0xac00 && codePoint <= 0xd7a3) || // Hangul syllables
|
|
32
|
+
(codePoint >= 0xf900 && codePoint <= 0xfaff) || // CJK compatibility ideographs
|
|
33
|
+
(codePoint >= 0xfe30 && codePoint <= 0xfe4f) || // CJK compatibility forms
|
|
34
|
+
(codePoint >= 0xff00 && codePoint <= 0xff60) || // fullwidth forms
|
|
35
|
+
(codePoint >= 0xffe0 && codePoint <= 0xffe6) ||
|
|
36
|
+
(codePoint >= 0x1f300 && codePoint <= 0x1faff) || // emoji and pictographs
|
|
37
|
+
(codePoint >= 0x20000 && codePoint <= 0x3fffd); // CJK extensions
|
|
38
|
+
return wide ? 2 : 1;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Cells `text` takes in a terminal, escape sequences excluded. */
|
|
42
|
+
export function visibleWidth(text: string): number {
|
|
43
|
+
let width = 0;
|
|
44
|
+
for (let i = 0; i < text.length;) {
|
|
45
|
+
ESCAPE.lastIndex = i;
|
|
46
|
+
const escape = ESCAPE.exec(text);
|
|
47
|
+
if (escape) {
|
|
48
|
+
i += escape[0].length;
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const codePoint = text.codePointAt(i) ?? 0;
|
|
52
|
+
const char = String.fromCodePoint(codePoint);
|
|
53
|
+
i += char.length;
|
|
54
|
+
width += cellWidth(codePoint, char);
|
|
55
|
+
}
|
|
56
|
+
return width;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* `line` cut to `columns` with a trailing `…`, so a long URL or label never
|
|
61
|
+
* wraps through the tree's rails. Escape sequences are kept, and a style left
|
|
62
|
+
* open by the cut is reset. `columns` undefined (output is not a terminal:
|
|
63
|
+
* a file, a pipe, an agent reading the log) leaves the line whole.
|
|
64
|
+
*/
|
|
65
|
+
export function fitToWidth(line: string, columns: number | undefined): string {
|
|
66
|
+
if (columns === undefined || columns < 2 || visibleWidth(line) <= columns) return line;
|
|
67
|
+
let out = '';
|
|
68
|
+
let width = 0;
|
|
69
|
+
let styled = false;
|
|
70
|
+
for (let i = 0; i < line.length;) {
|
|
71
|
+
ESCAPE.lastIndex = i;
|
|
72
|
+
const escape = ESCAPE.exec(line);
|
|
73
|
+
if (escape) {
|
|
74
|
+
out += escape[0];
|
|
75
|
+
styled = escape[0] !== RESET;
|
|
76
|
+
i += escape[0].length;
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
const codePoint = line.codePointAt(i) ?? 0;
|
|
80
|
+
const char = String.fromCodePoint(codePoint);
|
|
81
|
+
const cells = cellWidth(codePoint, char);
|
|
82
|
+
// Leave a cell for the `…`; a wide character that would cross it stays out.
|
|
83
|
+
if (width + cells > columns - 1) break;
|
|
84
|
+
out += char;
|
|
85
|
+
i += char.length;
|
|
86
|
+
width += cells;
|
|
87
|
+
}
|
|
88
|
+
return `${out}…${styled ? RESET : ''}`;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* The fewest columns the cut part of a line keeps before {@link fitParts}
|
|
93
|
+
* gives up on keeping the tail whole: a URL cut to nothing says nothing.
|
|
94
|
+
*/
|
|
95
|
+
const MIN_HEAD = 12;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* `head` then `tail`, fitted to `columns` by cutting the head: the tail
|
|
99
|
+
* (a fetch's status and cache, an access outcome, the trace ID) is what the
|
|
100
|
+
* end of a line says, and a cut that drops it loses the point of the line.
|
|
101
|
+
* When the tail leaves the head less than {@link MIN_HEAD} columns, the
|
|
102
|
+
* whole line is cut instead.
|
|
103
|
+
*/
|
|
104
|
+
export function fitParts(head: string, tail: string, columns: number | undefined): string {
|
|
105
|
+
const line = head + tail;
|
|
106
|
+
if (columns === undefined || visibleWidth(line) <= columns) return line;
|
|
107
|
+
const budget = columns - visibleWidth(tail);
|
|
108
|
+
return budget >= MIN_HEAD ? fitToWidth(head, budget) + tail : fitToWidth(line, columns);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** A tree line, with the times shown in the columns before it. */
|
|
112
|
+
export interface ColumnLine {
|
|
113
|
+
/** Start, relative to the request, in ms. Absent on annotation lines. */
|
|
114
|
+
startMs?: number;
|
|
115
|
+
/** Duration in ms. Absent on annotation lines. */
|
|
116
|
+
durationMs?: number;
|
|
117
|
+
/** Past the slow threshold: the duration is highlighted. */
|
|
118
|
+
slow?: boolean;
|
|
119
|
+
text: string;
|
|
120
|
+
/** Kept whole when the line is cut to the terminal's width; see {@link fitParts}. */
|
|
121
|
+
tail?: string;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export interface ColumnStyles {
|
|
125
|
+
dim: (text: string) => string;
|
|
126
|
+
slow: (text: string) => string;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Lay out `rows` as `start dur text`, both columns right-aligned to the
|
|
131
|
+
* widest value (and their headers), then cut each line to `columns`,
|
|
132
|
+
* keeping its tail. The start is dimmed; the duration is the column to scan,
|
|
133
|
+
* so it is not.
|
|
134
|
+
*/
|
|
135
|
+
export function renderColumns(
|
|
136
|
+
rows: readonly ColumnLine[],
|
|
137
|
+
columns: number | undefined,
|
|
138
|
+
styles: ColumnStyles
|
|
139
|
+
): string[] {
|
|
140
|
+
const ms = (value: number | undefined) => (value === undefined ? '' : `${value}ms`);
|
|
141
|
+
const startWidth = Math.max('start'.length, ...rows.map((r) => ms(r.startMs).length));
|
|
142
|
+
const durWidth = Math.max('dur'.length, ...rows.map((r) => ms(r.durationMs).length));
|
|
143
|
+
const header = `${'start'.padStart(startWidth)} ${'dur'.padStart(durWidth)}`;
|
|
144
|
+
return [
|
|
145
|
+
fitToWidth(styles.dim(header), columns),
|
|
146
|
+
...rows.map((r) => {
|
|
147
|
+
const start = styles.dim(ms(r.startMs).padStart(startWidth));
|
|
148
|
+
const dur = ms(r.durationMs).padStart(durWidth);
|
|
149
|
+
return fitParts(
|
|
150
|
+
`${start} ${r.slow ? styles.slow(dur) : dur} ${r.text}`,
|
|
151
|
+
r.tail ?? '',
|
|
152
|
+
columns
|
|
153
|
+
);
|
|
154
|
+
}),
|
|
155
|
+
];
|
|
156
|
+
}
|
package/src/dev-tools/logger.ts
CHANGED
|
@@ -25,8 +25,10 @@ import {
|
|
|
25
25
|
FETCH_BODY_SPAN_NAME,
|
|
26
26
|
FETCH_SPAN_NAME,
|
|
27
27
|
ROOT_SPAN_NAME,
|
|
28
|
+
fetchDisplayUrl,
|
|
28
29
|
} from '../shared/dev-span.ts';
|
|
29
30
|
import { buildWaterfall, type WaterfallRow, type WaterfallSpan } from '../shared/span-waterfall.ts';
|
|
31
|
+
import { fitParts, renderColumns, type ColumnLine } from './log-columns.ts';
|
|
30
32
|
|
|
31
33
|
// ─── Configuration ──────────────────────────────────────────────────────────
|
|
32
34
|
|
|
@@ -37,6 +39,11 @@ export interface DevLoggerConfig {
|
|
|
37
39
|
mode?: DevLogMode;
|
|
38
40
|
/** Threshold in ms to highlight slow phases. Default: 200. */
|
|
39
41
|
slowPhaseMs?: number;
|
|
42
|
+
/**
|
|
43
|
+
* Terminal width to cut tree lines to, so nothing wraps through the tree.
|
|
44
|
+
* Undefined (stderr is not a terminal) prints lines whole.
|
|
45
|
+
*/
|
|
46
|
+
columns?: number;
|
|
40
47
|
}
|
|
41
48
|
|
|
42
49
|
// ─── Styling ────────────────────────────────────────────────────────────────
|
|
@@ -245,20 +252,23 @@ export function formatSpanTree(spans: ReadableSpan[], config?: DevLoggerConfig):
|
|
|
245
252
|
const traceId = root.spanContext().traceId;
|
|
246
253
|
const actionName = root.attributes['timber.action_name'] as string | undefined;
|
|
247
254
|
|
|
248
|
-
|
|
255
|
+
// A long path is cut before the trace ID is.
|
|
256
|
+
const dimTrace = ` ${style('dim', `trace_id: ${traceId}`)}`;
|
|
249
257
|
if (actionName) {
|
|
250
258
|
const actionFile = root.attributes['timber.action_file'] as string | undefined;
|
|
259
|
+
const action = `ACTION ${actionName}${actionFile ? ` (${actionFile})` : ''}`;
|
|
260
|
+
lines.push(fitParts(style('bold', action), dimTrace, config?.columns));
|
|
261
|
+
} else {
|
|
251
262
|
lines.push(
|
|
252
|
-
`${style('bold',
|
|
263
|
+
fitParts(`${colorMethod(method)} ${style('bold', path)}`, dimTrace, config?.columns)
|
|
253
264
|
);
|
|
254
|
-
} else {
|
|
255
|
-
lines.push(`${colorMethod(method)} ${style('bold', path)} ${dimTrace}`);
|
|
256
265
|
}
|
|
257
266
|
|
|
258
267
|
// The root is the header line; everything else is at least one level in.
|
|
259
268
|
const body = rows.filter((r) => r.span.span !== root);
|
|
269
|
+
const tree: ColumnLine[] = [];
|
|
260
270
|
for (const { item, prefix, connector } of treeConnectors(body, (r) => r.depth - 1)) {
|
|
261
|
-
formatRow(item,
|
|
271
|
+
formatRow(item, tree, prefix, connector, bodies, slowPhaseMs, rootStart);
|
|
262
272
|
}
|
|
263
273
|
|
|
264
274
|
// Result line
|
|
@@ -283,52 +293,71 @@ export function formatSpanTree(spans: ReadableSpan[], config?: DevLoggerConfig):
|
|
|
283
293
|
const omittedNote =
|
|
284
294
|
omitted.length > 0 ? style('dim', ` · ${omitted.join(', ')} (TIMBER_DEV_LOG=verbose)`) : '';
|
|
285
295
|
|
|
296
|
+
// The total sits in the duration column, under every row's duration.
|
|
297
|
+
tree.push({
|
|
298
|
+
durationMs: totalMs,
|
|
299
|
+
text: style(statusFmt, `✓ ${statusText}`),
|
|
300
|
+
tail: `${denyNote}${omittedNote}`,
|
|
301
|
+
});
|
|
286
302
|
lines.push(
|
|
287
|
-
|
|
303
|
+
...renderColumns(tree, config?.columns, {
|
|
304
|
+
dim: (text) => style('dim', text),
|
|
305
|
+
slow: (text) => style('yellow', text),
|
|
306
|
+
})
|
|
288
307
|
);
|
|
289
308
|
|
|
290
309
|
return lines.join('\n') + '\n';
|
|
291
310
|
}
|
|
292
311
|
|
|
293
|
-
/**
|
|
312
|
+
/**
|
|
313
|
+
* A fetch's own timing, for the parenthesized note after its URL: the time
|
|
314
|
+
* to headers, and the body read after them.
|
|
315
|
+
*/
|
|
294
316
|
interface FetchTiming {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
durationMs: number;
|
|
317
|
+
/** Time to headers. */
|
|
318
|
+
headersMs: number;
|
|
298
319
|
/** Time spent reading the body, 0 when it was never read or took <1ms. */
|
|
299
320
|
bodyMs: number;
|
|
321
|
+
/** The row's duration column, to leave out a note that repeats it. */
|
|
322
|
+
rowMs: number;
|
|
300
323
|
}
|
|
301
324
|
|
|
302
325
|
/**
|
|
303
|
-
*
|
|
326
|
+
* A fetch's text, in two parts: `head` is the method and URL (as the pill
|
|
327
|
+
* labels it, without the scheme), the part a narrow terminal cuts; `tail`
|
|
328
|
+
* is its own timing when the duration column doesn't already say it, cache
|
|
329
|
+
* status, and an error or 4xx/5xx status, which are kept.
|
|
304
330
|
*
|
|
305
|
-
* Output:
|
|
331
|
+
* Output: `fetch GET api.example.com/data` + ` (77ms + 51ms body) [cdn: HIT]`
|
|
306
332
|
*/
|
|
307
|
-
function
|
|
333
|
+
function formatFetchParts(span: ReadableSpan, timing: FetchTiming): { head: string; tail: string } {
|
|
308
334
|
const method = String(span.attributes['http.request.method'] ?? 'GET');
|
|
309
|
-
const url = String(span.attributes['http.url'] ?? '');
|
|
335
|
+
const url = fetchDisplayUrl(String(span.attributes['http.url'] ?? ''));
|
|
310
336
|
const statusCode = span.attributes['http.response.status_code'] as number | undefined;
|
|
311
337
|
const cacheStatus = span.attributes['timber.cache_status'] as string | undefined;
|
|
312
338
|
const fetchError = span.attributes['timber.fetch_error'] as string | undefined;
|
|
313
339
|
const isError = span.status.code === 2; // SpanStatusCode.ERROR
|
|
314
340
|
|
|
315
|
-
const {
|
|
316
|
-
const
|
|
317
|
-
let
|
|
318
|
-
|
|
341
|
+
const { headersMs, bodyMs, rowMs } = timing;
|
|
342
|
+
const head = `${style('dim', `fetch ${method}`)} ${url}`;
|
|
343
|
+
let text = '';
|
|
344
|
+
// The column shows the row's interval. A body read, or wrappers folded
|
|
345
|
+
// around the fetch, make the fetch's own time worth saying.
|
|
346
|
+
if (bodyMs > 0) text += ` ${style('dim', `(${headersMs}ms + ${bodyMs}ms body)`)}`;
|
|
347
|
+
else if (headersMs !== rowMs) text += ` ${style('dim', `(${headersMs}ms)`)}`;
|
|
319
348
|
|
|
320
349
|
if (cacheStatus) {
|
|
321
|
-
|
|
350
|
+
text += ` ${style('dim', `[cdn: ${cacheStatus}]`)}`;
|
|
322
351
|
}
|
|
323
352
|
|
|
324
353
|
if (isError) {
|
|
325
354
|
const errMsg = fetchError ? `: ${fetchError}` : '';
|
|
326
|
-
|
|
355
|
+
text += ` ${style('red', `ERROR${errMsg}`)}`;
|
|
327
356
|
} else if (statusCode && statusCode >= 400) {
|
|
328
|
-
|
|
357
|
+
text += ` ${style('yellow', String(statusCode))}`;
|
|
329
358
|
}
|
|
330
359
|
|
|
331
|
-
return
|
|
360
|
+
return { head, tail: text };
|
|
332
361
|
}
|
|
333
362
|
|
|
334
363
|
/** An access gate's result from its span: ` → DENY 403 (app/admin/access.ts)`. */
|
|
@@ -344,13 +373,14 @@ function accessOutcome(span: ReadableSpan): string {
|
|
|
344
373
|
* Format one row: its line, then its cache annotations.
|
|
345
374
|
*
|
|
346
375
|
* A folded row keeps the outer span's interval, which is the code that asked
|
|
347
|
-
* for the work
|
|
348
|
-
*
|
|
349
|
-
*
|
|
376
|
+
* for the work. When the chain ends in a fetch, the row names the outer span
|
|
377
|
+
* and then the fetch (`await getArtistDirectory() → fetch GET …`): the code
|
|
378
|
+
* that asked, and the I/O it did. Otherwise it reads as the outer span. Cache
|
|
379
|
+
* events from every span in the row are kept.
|
|
350
380
|
*/
|
|
351
381
|
function formatRow(
|
|
352
382
|
row: WaterfallRow<LogSpan>,
|
|
353
|
-
lines:
|
|
383
|
+
lines: ColumnLine[],
|
|
354
384
|
prefix: string,
|
|
355
385
|
connector: string,
|
|
356
386
|
bodies: ReadonlyMap<string | undefined, readonly LogSpan[]>,
|
|
@@ -363,19 +393,14 @@ function formatRow(
|
|
|
363
393
|
const leaf = row.folded.at(-1);
|
|
364
394
|
const startMs = Math.round(relativeMs(outer.startTime, rootStart));
|
|
365
395
|
const endMs = Math.round(relativeMs(outer.endTime, rootStart));
|
|
366
|
-
const durationMs = endMs - startMs;
|
|
367
|
-
const slow = (text: string) => (durationMs > slowPhaseMs ? style('yellow', text) : text);
|
|
368
396
|
const envTag = (span: ReadableSpan) =>
|
|
369
397
|
`${style('cyan', `[${devSpanLabel(span.name, span.attributes).env}]`)} `;
|
|
370
|
-
|
|
371
|
-
//
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
outer.name !== AWAIT_SPAN_NAME && row.folded.length > 0
|
|
375
|
-
? `${envTag(outer)}${slow(devSpanLabel(outer.name, outer.attributes).label)} → `
|
|
376
|
-
: '';
|
|
377
|
-
const lead = `${prefix}${connector} ${frame}`;
|
|
398
|
+
// A span's name as its row shows it: an await's label already starts with
|
|
399
|
+
// `await`, so it gets no environment tag.
|
|
400
|
+
const named = (span: ReadableSpan) =>
|
|
401
|
+
`${span.name === AWAIT_SPAN_NAME ? '' : envTag(span)}${devSpanLabel(span.name, span.attributes).label}`;
|
|
378
402
|
const outcome = accessOutcome(outer);
|
|
403
|
+
const lead = `${prefix}${connector} `;
|
|
379
404
|
|
|
380
405
|
if (leaf?.name === FETCH_SPAN_NAME || outer.name === FETCH_SPAN_NAME) {
|
|
381
406
|
const fetch = leaf?.name === FETCH_SPAN_NAME ? leaf : row.span;
|
|
@@ -383,33 +408,52 @@ function formatRow(
|
|
|
383
408
|
// The reads' own time: work the app did between headers and reading
|
|
384
409
|
// the body is not body time. Codex review on #1290.
|
|
385
410
|
const bodyMs = Math.round(reads.reduce((ms, r) => ms + (r.endMs - r.startMs), 0));
|
|
386
|
-
const
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
//
|
|
394
|
-
// review on #1290.
|
|
395
|
-
//
|
|
396
|
-
//
|
|
397
|
-
|
|
398
|
-
const
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
durationMs: Math.round(fetch.endMs - fetch.startMs),
|
|
411
|
+
const lastReadEnd = reads.reduce((end, r) => Math.max(end, r.endMs), -Infinity);
|
|
412
|
+
// The row runs to the end of the body read, past the fetch span's end.
|
|
413
|
+
const end =
|
|
414
|
+
lastReadEnd > -Infinity
|
|
415
|
+
? Math.max(endMs, Math.round(lastReadEnd - hrTimeToMs(rootStart)))
|
|
416
|
+
: endMs;
|
|
417
|
+
// The parenthesized time is the fetch's own: an outer loader's duration
|
|
418
|
+
// already includes the body read, so adding `+ body` to it counted the
|
|
419
|
+
// body twice. Codex review on #1290. Rounded from the same relative
|
|
420
|
+
// times as the columns, so an unfolded fetch's note never contradicts
|
|
421
|
+
// its duration column by a rounding.
|
|
422
|
+
const fetchStart = Math.round(relativeMs(fetch.span.startTime, rootStart));
|
|
423
|
+
const fetchEnd = Math.round(relativeMs(fetch.span.endTime, rootStart));
|
|
424
|
+
const fetchParts = formatFetchParts(fetch.span, {
|
|
425
|
+
headersMs: fetchEnd - fetchStart,
|
|
402
426
|
bodyMs,
|
|
427
|
+
rowMs: end - startMs,
|
|
428
|
+
});
|
|
429
|
+
// The outer span of a folded chain names the code that asked for the
|
|
430
|
+
// fetch; an access gate that folded into its fetch keeps its outcome.
|
|
431
|
+
// Codex review on #1290.
|
|
432
|
+
// `await fetch(url)` is the fetch itself: naming it would say it twice.
|
|
433
|
+
const askerName = named(outer);
|
|
434
|
+
const asker =
|
|
435
|
+
row.folded.length > 0 && !askerName.startsWith('await fetch(') ? `${askerName} → ` : '';
|
|
436
|
+
lines.push({
|
|
437
|
+
startMs,
|
|
438
|
+
durationMs: end - startMs,
|
|
439
|
+
slow: end - startMs > slowPhaseMs,
|
|
440
|
+
text: `${lead}${asker}${fetchParts.head}`,
|
|
441
|
+
tail: `${fetchParts.tail}${outcome ? style('dim', outcome) : ''}`,
|
|
403
442
|
});
|
|
404
|
-
lines.push(outcome ? `${fetchLine}${style('dim', outcome)}` : fetchLine);
|
|
405
443
|
} else {
|
|
406
|
-
|
|
407
|
-
//
|
|
408
|
-
//
|
|
409
|
-
const
|
|
410
|
-
const
|
|
411
|
-
const
|
|
412
|
-
lines.push(
|
|
444
|
+
// A framework span folded into its await keeps both names:
|
|
445
|
+
// `[proxy] proxy.ts → await next()`. Otherwise the row reads as its
|
|
446
|
+
// first await, the code that asked for the work.
|
|
447
|
+
const first = row.folded[0]?.span;
|
|
448
|
+
const frame = outer.name !== AWAIT_SPAN_NAME && first ? `${named(outer)} → ` : '';
|
|
449
|
+
const label = frame && first ? named(first) : named(outer);
|
|
450
|
+
lines.push({
|
|
451
|
+
startMs,
|
|
452
|
+
durationMs: endMs - startMs,
|
|
453
|
+
slow: endMs - startMs > slowPhaseMs,
|
|
454
|
+
text: `${lead}${frame}${label}`,
|
|
455
|
+
tail: outcome ? style('dim', outcome) : '',
|
|
456
|
+
});
|
|
413
457
|
}
|
|
414
458
|
|
|
415
459
|
// Span events (cache hits/misses) as child annotations
|
|
@@ -421,9 +465,9 @@ function formatRow(
|
|
|
421
465
|
const durMs = event.attributes?.['duration_ms'] as number | undefined;
|
|
422
466
|
const durStr = durMs !== undefined ? ` ${durMs < 1 ? '<1' : Math.round(durMs)}ms` : '';
|
|
423
467
|
const stale = event.attributes?.['stale'] ? ' (stale)' : '';
|
|
424
|
-
lines.push(
|
|
425
|
-
`${childPrefix}${style('dim', `└── ${key} timber.cache ${hitMiss}${durStr}${stale}`)}
|
|
426
|
-
);
|
|
468
|
+
lines.push({
|
|
469
|
+
text: `${childPrefix}${style('dim', `└── ${key} timber.cache ${hitMiss}${durStr}${stale}`)}`,
|
|
470
|
+
});
|
|
427
471
|
}
|
|
428
472
|
}
|
|
429
473
|
}
|