@timber-js/app 0.2.0-alpha.228 → 0.2.0-alpha.229

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/agent-skill.md +9 -0
  2. package/dist/_chunks/{actions-DprvPi7O.js → actions-DHum77eH.js} +3 -3
  3. package/dist/_chunks/{actions-DprvPi7O.js.map → actions-DHum77eH.js.map} +1 -1
  4. package/dist/_chunks/{cache-api-BjE-nNC0.js → cache-api-BZJNt01a.js} +4 -4
  5. package/dist/_chunks/{cache-api-BjE-nNC0.js.map → cache-api-BZJNt01a.js.map} +1 -1
  6. package/dist/_chunks/{chains-DaDEXv0c.js → chains-D-RRc7CM.js} +2 -2
  7. package/dist/_chunks/{chains-DaDEXv0c.js.map → chains-D-RRc7CM.js.map} +1 -1
  8. package/dist/_chunks/chains-KblEfYzm.js +1 -0
  9. package/dist/_chunks/{classify-BuIifN5v.js → classify-_W0RWa5w.js} +2 -2
  10. package/dist/_chunks/{classify-BuIifN5v.js.map → classify-_W0RWa5w.js.map} +1 -1
  11. package/dist/_chunks/{cli-check-B_fDvxhs.js → cli-check-B-JZkpBD.js} +3 -3
  12. package/dist/_chunks/{cli-check-B_fDvxhs.js.map → cli-check-B-JZkpBD.js.map} +1 -1
  13. package/dist/_chunks/{cli-schema-sync-D9OLUUFv.js → cli-schema-sync-CAllbqRB.js} +2 -2
  14. package/dist/_chunks/{cli-schema-sync-D9OLUUFv.js.map → cli-schema-sync-CAllbqRB.js.map} +1 -1
  15. package/dist/_chunks/{cli-schema-sync-CUIk0G2X.js → cli-schema-sync-y_8ijmzO.js} +1 -1
  16. package/dist/_chunks/{client-dep-entries-COuyF8-c.js → client-dep-entries-C9hv-3k9.js} +2 -2
  17. package/dist/_chunks/{client-dep-entries-COuyF8-c.js.map → client-dep-entries-C9hv-3k9.js.map} +1 -1
  18. package/dist/_chunks/{convention-lint-BHY0d5AQ.js → convention-lint-CrDKERHg.js} +3 -3
  19. package/dist/_chunks/{convention-lint-BHY0d5AQ.js.map → convention-lint-CrDKERHg.js.map} +1 -1
  20. package/dist/_chunks/dev-server-L8biS7Az.js +1 -0
  21. package/dist/_chunks/{dev-server-BaM7q3pr.js → dev-server-Rq659RR1.js} +8 -2
  22. package/dist/_chunks/dev-server-Rq659RR1.js.map +1 -0
  23. package/dist/_chunks/{build-manifest-Y4jl7nwU.js → dev-span-_NzMX-au.js} +25 -2
  24. package/dist/_chunks/dev-span-_NzMX-au.js.map +1 -0
  25. package/dist/_chunks/{error-boundary-D3YyVVuP.js → error-boundary-OHK1mI99.js} +3 -3
  26. package/dist/_chunks/{error-boundary-D3YyVVuP.js.map → error-boundary-OHK1mI99.js.map} +1 -1
  27. package/dist/_chunks/{flight-source-node-CZJ9Drb7.js → flight-source-node-BGanuoSS.js} +2 -2
  28. package/dist/_chunks/{flight-source-node-CZJ9Drb7.js.map → flight-source-node-BGanuoSS.js.map} +1 -1
  29. package/dist/_chunks/{global-context-DbxNWeBP.js → global-context-CFSSysdJ.js} +32 -2
  30. package/dist/_chunks/global-context-CFSSysdJ.js.map +1 -0
  31. package/dist/_chunks/{json-lossy-check-BNwKrm2R.js → json-lossy-check-BXM45k8p.js} +2 -2
  32. package/dist/_chunks/{json-lossy-check-BNwKrm2R.js.map → json-lossy-check-BXM45k8p.js.map} +1 -1
  33. package/dist/_chunks/{live-graph-DiRVmRrC.js → live-graph-C7-yA8W9.js} +4 -4
  34. package/dist/_chunks/{live-graph-DiRVmRrC.js.map → live-graph-C7-yA8W9.js.map} +1 -1
  35. package/dist/_chunks/{logger-DRMij51J.js → logger-YtMSKfft.js} +100 -57
  36. package/dist/_chunks/logger-YtMSKfft.js.map +1 -0
  37. package/dist/_chunks/navigation-root-CoGHIMiE.js +239 -0
  38. package/dist/_chunks/navigation-root-CoGHIMiE.js.map +1 -0
  39. package/dist/_chunks/{node-response-C-dQn-0N.js → node-response-D3hXWb8y.js} +2 -2
  40. package/dist/_chunks/{node-response-C-dQn-0N.js.map → node-response-D3hXWb8y.js.map} +1 -1
  41. package/dist/_chunks/{poison-scan-CqPGN0ru.js → poison-scan-CRSP06Es.js} +2 -2
  42. package/dist/_chunks/{poison-scan-CqPGN0ru.js.map → poison-scan-CRSP06Es.js.map} +1 -1
  43. package/dist/_chunks/{scanner-C__vsQ8d.js → scanner-BNQ4qnLX.js} +2 -2
  44. package/dist/_chunks/{scanner-C__vsQ8d.js.map → scanner-BNQ4qnLX.js.map} +1 -1
  45. package/dist/_chunks/segment-context-GAyTjjtS.js +33 -0
  46. package/dist/_chunks/segment-context-GAyTjjtS.js.map +1 -0
  47. package/dist/_chunks/{sizeof-DcEcQaSL.js → sizeof-Cmx6Fs-Y.js} +2 -2
  48. package/dist/_chunks/{sizeof-DcEcQaSL.js.map → sizeof-Cmx6Fs-Y.js.map} +1 -1
  49. package/dist/_chunks/{status-page-marker-C8POawuF.js → status-page-marker-U6B1aFMb.js} +3 -32
  50. package/dist/_chunks/status-page-marker-U6B1aFMb.js.map +1 -0
  51. package/dist/_chunks/{walkers-D6KY4jyS.js → walkers-D_QHR_nf.js} +3 -3
  52. package/dist/_chunks/{walkers-D6KY4jyS.js.map → walkers-D_QHR_nf.js.map} +1 -1
  53. package/dist/adapters/cloudflare-kv-cache.js +1 -1
  54. package/dist/analyze/crawl-entry.js +3 -3
  55. package/dist/analyze/graph-command.js +2 -2
  56. package/dist/cache/index.js +2 -2
  57. package/dist/cache/stores/memory.js +1 -1
  58. package/dist/cli.js +3 -3
  59. package/dist/client/browser-entry/hmr.d.ts +7 -1
  60. package/dist/client/browser-entry/hmr.d.ts.map +1 -1
  61. package/dist/client/dev-pill/index.d.ts +32 -0
  62. package/dist/client/dev-pill/index.d.ts.map +1 -0
  63. package/dist/client/dev-pill/store.d.ts +96 -0
  64. package/dist/client/dev-pill/store.d.ts.map +1 -0
  65. package/dist/client/dev-pill/view.d.ts +9 -0
  66. package/dist/client/dev-pill/view.d.ts.map +1 -0
  67. package/dist/client/error-boundary.js +1 -1
  68. package/dist/client/index.d.ts +1 -0
  69. package/dist/client/index.d.ts.map +1 -1
  70. package/dist/client/index.js +3 -3
  71. package/dist/client/internal.js +16 -7
  72. package/dist/client/internal.js.map +1 -1
  73. package/dist/client/navigation-context.d.ts +20 -0
  74. package/dist/client/navigation-context.d.ts.map +1 -1
  75. package/dist/client/router-lifecycle.d.ts +4 -1
  76. package/dist/client/router-lifecycle.d.ts.map +1 -1
  77. package/dist/client/use-pending-navigation.d.ts +33 -9
  78. package/dist/client/use-pending-navigation.d.ts.map +1 -1
  79. package/dist/config-types.d.ts +10 -0
  80. package/dist/config-types.d.ts.map +1 -1
  81. package/dist/config-validation.d.ts.map +1 -1
  82. package/dist/dev-tools/await-span.d.ts +17 -0
  83. package/dist/dev-tools/await-span.d.ts.map +1 -0
  84. package/dist/dev-tools/instrumentation.d.ts.map +1 -1
  85. package/dist/dev-tools/logger.d.ts.map +1 -1
  86. package/dist/dev-tools/logs.d.ts.map +1 -1
  87. package/dist/dev-tools/span-sink.d.ts +42 -0
  88. package/dist/dev-tools/span-sink.d.ts.map +1 -0
  89. package/dist/index.d.ts.map +1 -1
  90. package/dist/index.js +282 -9
  91. package/dist/index.js.map +1 -1
  92. package/dist/plugins/dev-await.d.ts +40 -0
  93. package/dist/plugins/dev-await.d.ts.map +1 -0
  94. package/dist/plugins/entries.d.ts.map +1 -1
  95. package/dist/routing/index.js +2 -2
  96. package/dist/server/index.js +2 -2
  97. package/dist/server/internal.js +9 -8
  98. package/dist/server/internal.js.map +1 -1
  99. package/dist/server/pipeline.d.ts +8 -0
  100. package/dist/server/pipeline.d.ts.map +1 -1
  101. package/dist/server/rsc-entry/index.d.ts.map +1 -1
  102. package/dist/server/slot-resolver.d.ts.map +1 -1
  103. package/dist/server/tracing.d.ts +18 -8
  104. package/dist/server/tracing.d.ts.map +1 -1
  105. package/dist/shared/dev-span.d.ts +97 -0
  106. package/dist/shared/dev-span.d.ts.map +1 -0
  107. package/docs/api/31-api-client.mdx +27 -1
  108. package/docs/api/34-api-config.mdx +21 -1
  109. package/docs/learn/09-streaming.mdx +7 -1
  110. package/package.json +3 -3
  111. package/src/client/browser-entry/hmr.ts +13 -1
  112. package/src/client/browser-entry/index.ts +4 -1
  113. package/src/client/dev-pill/index.ts +128 -0
  114. package/src/client/dev-pill/store.ts +231 -0
  115. package/src/client/dev-pill/view.ts +278 -0
  116. package/src/client/index.ts +1 -0
  117. package/src/client/navigation-context.ts +5 -2
  118. package/src/client/router-lifecycle.ts +23 -3
  119. package/src/client/use-pending-navigation.ts +93 -14
  120. package/src/config-types.ts +10 -0
  121. package/src/config-validation.ts +10 -0
  122. package/src/dev-tools/await-span.ts +40 -0
  123. package/src/dev-tools/instrumentation.ts +20 -0
  124. package/src/dev-tools/logger.ts +3 -37
  125. package/src/dev-tools/logs.ts +10 -1
  126. package/src/dev-tools/span-sink.ts +132 -0
  127. package/src/index.ts +2 -0
  128. package/src/plugins/dev-await.ts +268 -0
  129. package/src/plugins/entries.ts +2 -0
  130. package/src/server/pipeline.ts +14 -0
  131. package/src/server/rsc-entry/index.ts +7 -1
  132. package/src/server/slot-resolver.ts +45 -5
  133. package/src/server/tracing.ts +121 -87
  134. package/src/shared/dev-span.ts +182 -0
  135. package/dist/_chunks/build-manifest-Y4jl7nwU.js.map +0 -1
  136. package/dist/_chunks/chains-BS8fQYao.js +0 -1
  137. package/dist/_chunks/dev-server-BaM7q3pr.js.map +0 -1
  138. package/dist/_chunks/dev-server-NnGosJ06.js +0 -1
  139. package/dist/_chunks/global-context-DbxNWeBP.js.map +0 -1
  140. package/dist/_chunks/logger-DRMij51J.js.map +0 -1
  141. package/dist/_chunks/navigation-root-M3B2ZrdO.js +0 -122
  142. package/dist/_chunks/navigation-root-M3B2ZrdO.js.map +0 -1
  143. package/dist/_chunks/segment-context-CYiGTi3K.js +0 -131
  144. package/dist/_chunks/segment-context-CYiGTi3K.js.map +0 -1
  145. package/dist/_chunks/status-page-marker-C8POawuF.js.map +0 -1
@@ -159,6 +159,14 @@ export interface PipelineConfig {
159
159
  * Default: `'total'`.
160
160
  */
161
161
  serverTiming?: 'detailed' | 'total' | false;
162
+ /**
163
+ * Add a `timber-trace;desc="<traceId>"` Server-Timing entry to every
164
+ * response, whatever `serverTiming` is, so the dev request pill can match
165
+ * the page and its fetches to their spans. Set by the dev RSC entry only:
166
+ * it must never be on in a production build, `TIMBER_DEBUG` included.
167
+ * See design/50-dev-request-pill.md §"Correlation".
168
+ */
169
+ devTraceTiming?: boolean;
162
170
  /**
163
171
  * Auto-generated sitemap handler. When provided, the pipeline intercepts
164
172
  * `/sitemap.xml` and `/sitemap/N.xml` requests and delegates to this
@@ -1 +1 @@
1
- {"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/server/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAa3D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAS5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAK9D;;;;;;;;GAQG;AACH,MAAM,WAAW,UAAU;IACzB,mDAAmD;IACnD,QAAQ,EAAE,mBAAmB,EAAE,CAAC;IAChC;;;;OAIG;IACH,aAAa,EAAE,aAAa,CAAC;IAC7B;;;;;OAKG;IACH,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;IACpD,oEAAoE;IACp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AAC,EACrC,OAAO,EACP,SAAS,EACT,KAAK,EACL,CAAC,EACD,YAAY,EACZ,cAAc,EACd,GAAG,EACH,eAAe,EACf,YAAY,GACb,EAAE,oBAAoB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAyIzD"}
@@ -86,10 +86,6 @@ export interface PlatformTracer {
86
86
  export declare function setPlatformTracer(tracer: PlatformTracer | undefined): void;
87
87
  /** The registered native platform tracer, if any. */
88
88
  export declare function getPlatformTracer(): PlatformTracer | undefined;
89
- /**
90
- * Get the timber.js OTEL tracer. Returns null if @opentelemetry/api is not available.
91
- */
92
- export declare function getTracer(): Promise<import('@opentelemetry/api').Tracer | null>;
93
89
  /**
94
90
  * Run a function within a framework span. Composes two emission channels:
95
91
  *
@@ -97,16 +93,31 @@ export declare function getTracer(): Promise<import('@opentelemetry/api').Tracer
97
93
  * (Cloudflare Workers), the fn is wrapped in platformTracer.enterSpan()
98
94
  * so it appears in the platform's native trace view.
99
95
  * - **OTEL span** — when an OTEL SDK is active, the fn also runs inside an
100
- * OTEL span (dual emission). No SDK and no platform tracer = zero overhead.
96
+ * OTEL span (dual emission). With no SDK the OTEL span is the API's
97
+ * non-recording no-op.
101
98
  *
102
99
  * Automatically:
100
+ * - Invokes fn synchronously, in the caller's frame — a wrapped server
101
+ * component still sees React's render dispatcher (see getTracer())
103
102
  * - Creates the span as a child of the current context
104
103
  * - Runs fn in its own trace scope carrying the span's IDs, for log–trace
105
104
  * correlation and setSpanAttribute()
106
105
  * - Ends the span when the function completes
107
106
  * - Records exceptions on error (OTEL channel)
108
107
  */
109
- export declare function withSpan<T>(name: string, attributes: Record<string, string | number | boolean>, fn: () => T | Promise<T>): Promise<T>;
108
+ export declare function withSpan<T>(name: string, attributes: Record<string, string | number | boolean>, fn: () => T | PromiseLike<T>): Promise<T>;
109
+ /**
110
+ * The span core of {@link withSpan}, keeping the shape of the call: `fn` runs
111
+ * synchronously, a value it returns comes back as that value, a promise as a
112
+ * promise, and a synchronous throw is rethrown synchronously.
113
+ *
114
+ * For a framework wrapper that invokes a server component inside a span.
115
+ * React drives a synchronous component through throws: `use()` on a pending
116
+ * promise throws, and Flight retries the component once it settles. That only
117
+ * works if the throw leaves the wrapper synchronously — `withSpan()` would
118
+ * turn it into a rejection, which Flight reports as a render error.
119
+ */
120
+ export declare function traceCall<T>(name: string, attributes: Record<string, string | number | boolean>, fn: () => T | PromiseLike<T>): T | Promise<T>;
110
121
  /**
111
122
  * Set an attribute on the current active span (if any).
112
123
  * Used for setting span attributes after span creation (e.g. timber.result on access spans).
@@ -121,8 +132,7 @@ export declare function addSpanEvent(name: string, attributes?: Record<string, s
121
132
  * Fire-and-forget span event — no await, no microtask overhead.
122
133
  *
123
134
  * Used on the cache hot path where awaiting addSpanEvent creates an
124
- * unnecessary microtask per cache operation. If OTEL is not loaded yet,
125
- * the event is silently dropped (acceptable for diagnostics).
135
+ * unnecessary microtask per cache operation.
126
136
  *
127
137
  * See TIM-370 for perf motivation.
128
138
  */
@@ -1 +1 @@
1
- {"version":3,"file":"tracing.d.ts","sourceRoot":"","sources":["../../src/server/tracing.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAY,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI9D,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAIpD;;;;;;;GAOG;AACH,wBAAgB,UAAU,IAAI,MAAM,CASnC;AAED;;GAEG;AACH,wBAAgB,SAAS,IAAI,MAAM,GAAG,SAAS,CAE9C;AAID;;;GAGG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAE5D;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAKvD;AAiBD;;;GAG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AKf;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,GACrD,IAAI,CAKN;AAED;;;;GAIG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAWlE"}
@@ -0,0 +1,97 @@
1
+ /**
2
+ * The wire contract between the dev server's span sink and the dev request
3
+ * pill in the browser. Dev-only; see design/50-dev-request-pill.md.
4
+ *
5
+ * Isomorphic: no server, client, or build-time imports.
6
+ */
7
+ /** HMR event that carries one finished span to the browser. */
8
+ export declare const DEV_SPAN_EVENT = "timber:span";
9
+ /** HMR event a tab sends to ask for a trace's spans that ended before it connected. */
10
+ export declare const DEV_SPAN_REPLAY_EVENT = "timber:span-replay";
11
+ /**
12
+ * `globalThis` key holding the span sink. The dev server plugin installs it
13
+ * and `DevSpanProcessor` (RSC module graph, same process, separate module
14
+ * instances) reads it, so the hand-off is a `Symbol.for` global.
15
+ */
16
+ export declare const DEV_SPAN_SINK_KEY: unique symbol;
17
+ /** The `Server-Timing` metric whose `desc` is the response's trace ID. */
18
+ export declare const TRACE_TIMING_NAME = "timber-trace";
19
+ /**
20
+ * `globalThis` key holding the dev await wrapper. The dev await transform
21
+ * (`plugins/dev-await.ts`) rewrites `await x` in app server code to call
22
+ * it, looked up at call time; dev tracing installs it. With nothing
23
+ * installed the call is a plain await. See design/50-dev-request-pill.md
24
+ * §"Phase 2".
25
+ */
26
+ export declare const DEV_AWAIT_KEY: unique symbol;
27
+ /** Span name for one awaited call in app server code. */
28
+ export declare const AWAIT_SPAN_NAME = "timber.await";
29
+ /**
30
+ * Await spans shorter than this are dropped before they reach the terminal
31
+ * tree or the pill: `await params` and other awaits of settled values would
32
+ * otherwise drown the I/O the spans exist to show.
33
+ */
34
+ export declare const AWAIT_SPAN_MIN_MS = 1;
35
+ /** Root span of every pipeline request. */
36
+ export declare const ROOT_SPAN_NAME = "http.server.request";
37
+ /**
38
+ * The span attributes that may reach the browser — the ones the pill reads,
39
+ * and nothing else. An allowlist of keys, not of prefixes: a prefix let
40
+ * through `timber.fetch_error` (an error message that can quote a full URL)
41
+ * and user attributes such as `url.full` or
42
+ * `http.request.header.authorization`. Typing the payload with this list
43
+ * means the pill cannot read an attribute that isn't on it.
44
+ */
45
+ export declare const DEV_SPAN_ATTRIBUTES: readonly ['http.request.method', 'http.response.status_code',
46
+ /** Query and fragment stripped. */
47
+ 'http.url',
48
+ /** Query and fragment stripped. */
49
+ 'url.path', 'timber.route', 'timber.segment', 'timber.slot', 'timber.action_name', 'timber.cache_status',
50
+ /** The awaited expression's source text, whitespace collapsed, truncated. */
51
+ 'timber.await_label',
52
+ /** `path/relative/to/root.ts:line` of the await. */
53
+ 'timber.await_location'];
54
+ export type DevSpanAttribute = (typeof DEV_SPAN_ATTRIBUTES)[number];
55
+ /** Attributes that hold a URL; sent without query or fragment. */
56
+ export declare const DEV_SPAN_URL_ATTRIBUTES: ReadonlySet<DevSpanAttribute>;
57
+ export type DevSpanSink = (span: DevSpanPayload) => void;
58
+ /** One finished span, projected for the browser. */
59
+ export interface DevSpanPayload {
60
+ traceId: string;
61
+ spanId: string;
62
+ /** Absent for the root span. */
63
+ parentSpanId?: string;
64
+ name: string;
65
+ /** Epoch milliseconds. */
66
+ startMs: number;
67
+ /** Epoch milliseconds. */
68
+ endMs: number;
69
+ error: boolean;
70
+ /** Only `DEV_SPAN_ATTRIBUTES`; URLs without query or fragment. */
71
+ attributes: Partial<Record<DevSpanAttribute, string | number | boolean>>;
72
+ /** Names of `timber.*` span events, e.g. `timber.cache.hit`. */
73
+ events: string[];
74
+ }
75
+ /**
76
+ * Read the trace ID from `Server-Timing` metrics, either a raw header value
77
+ * or the `serverTiming` entries of a `PerformanceResourceTiming`.
78
+ */
79
+ export declare function traceIdFromServerTiming(timing: string | null | readonly {
80
+ name: string;
81
+ description: string;
82
+ }[]): string | null;
83
+ /** The `Server-Timing` entry that carries a trace ID. */
84
+ export declare function traceTimingEntry(traceId: string): string;
85
+ /** Span attributes as either side holds them (OTEL also allows arrays). */
86
+ type SpanAttributes = Readonly<Record<string, unknown>>;
87
+ /**
88
+ * Map a span to its display label and environment tag. One mapping for the
89
+ * terminal tree and the dev request pill, so the two never name a span
90
+ * differently.
91
+ */
92
+ export declare function devSpanLabel(name: string, attrs: SpanAttributes): {
93
+ label: string;
94
+ env: string;
95
+ };
96
+ export {};
97
+ //# sourceMappingURL=dev-span.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev-span.d.ts","sourceRoot":"","sources":["../../src/shared/dev-span.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,+DAA+D;AAC/D,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;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,IAAI,CAAC;AAEnC,2CAA2C;AAC3C,eAAO,MAAM,cAAc,wBAAwB,CAAC;AAEpD;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,YAC9B,qBAAqB,EACrB,2BAA2B;AAC3B,mCAAmC;AACnC,UAAU;AACV,mCAAmC;AACnC,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,oBAAoB,EACpB,qBAAqB;AACrB,6EAA6E;AAC7E,oBAAoB;AACpB,oDAAoD;AACpD,uBAAuB,CACf,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,mBAAmB,CAAC,CA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edLayoutSegments(); // ["settings", "profile"]
94
94
  ```
95
95
 
96
- ### `usePendingNavigation()`
96
+ ### `usePendingNavigation(select?)`
97
97
 
98
98
  Returns whether a navigation is in flight. Use instead of wrapping `children` in `<Suspense>`.
99
99
 
@@ -101,6 +101,32 @@ Returns whether a navigation is in flight. Use instead of wrapping `children` in
101
101
  const pending = usePendingNavigation();
102
102
  ```
103
103
 
104
+ Pass a selector to ask where the navigation is going. It receives `to`, the destination as a `URL`, and `from`, the page the navigation is leaving, as the calling component rendered it. `to` keeps the `#fragment` of a link or `router.push()` that has one. Back/forward and refresh carry none. The hook returns the selector's result while a navigation is pending, and `false` when none is:
105
+
106
+ ```tsx
107
+ // true while this page is being replaced: same path, new query, or a refresh.
108
+ const replacing = usePendingNavigation((to, from) => to.pathname === from.pathname);
109
+
110
+ // Which sort is loading, or false.
111
+ const loadingSort = usePendingNavigation((to) => to.searchParams.get('sort'));
112
+ ```
113
+
114
+ When a navigation starts, is replaced or ends, the component re-renders only if the selector's result changes, so return a primitive. Like `usePathname()`, the selector form also re-renders when a new page commits. Client-side navigations are reported: a `<Link>`, `router.push()` / `replace()`, back/forward, and `router.refresh()`, where `to` equals `from`. A navigation that replaces another reports the newest one. A redirect that the router follows reports the redirect's destination. Full page loads are not reported.
115
+
116
+ **Recipe: dim a list while its own sort, filter or page navigation loads.** A list that dims on any pending navigation also dims when the user clicks a link to another page. Compare the paths:
117
+
118
+ ```tsx title="app/songs/song-table.tsx"
119
+ 'use client';
120
+ import { usePendingNavigation } from '@timber-js/app/client';
121
+
122
+ export function SongTable({ children }: { children: React.ReactNode }) {
123
+ const replacing = usePendingNavigation((to, from) => to.pathname === from.pathname);
124
+ return <table className={replacing ? 'opacity-50' : undefined}>{children}</table>;
125
+ }
126
+ ```
127
+
128
+ `from` is the page the navigation left, not the address bar. On back/forward the browser updates the address bar before the new page renders, so `window.location` already shows the destination. `from` stays the departed page until the navigation ends, even after the destination is on screen. So a component in a shared layout never reads a link to another page as "same page", even while that page streams in.
129
+
104
130
  ### `useLinkStatus()`
105
131
 
106
132
  Per-link pending state. Must be used inside a `<Link>` component's children.
@@ -36,6 +36,7 @@ interface TimberUserConfig {
36
36
  dev?: {
37
37
  slowPhaseMs?: number;
38
38
  hostname?: string | false;
39
+ requestPill?: boolean;
39
40
  };
40
41
  budget?: {
41
42
  firstLoadJs?: number;
@@ -220,7 +221,26 @@ Forward browser console output to the server terminal in dev mode. Sets the mini
220
221
  - **Type:** `number`
221
222
  - **Default:** `200`
222
223
 
223
- Threshold in milliseconds to highlight slow phases in dev logging output.
224
+ Threshold in milliseconds to highlight slow phases in dev logging output and in the dev request pill.
225
+
226
+ ### `dev.requestPill`
227
+
228
+ - **Type:** `boolean`
229
+ - **Default:** `true`
230
+
231
+ The dev request pill: a small pill in the bottom-right corner of every page in dev that shows the server work behind it, as a waterfall of phases, `fetch()` calls and awaited calls. See [Developer Experience](/docs/developer-experience#request-pill).
232
+
233
+ To get it out of the way in one browser, minimize it with its **×** button; it shrinks to a dot and stays that way across reloads. To turn it off for everyone, set `false`: no pill, and the dev server stops streaming spans to the browser.
234
+
235
+ ```ts title="timber.config.ts"
236
+ export default {
237
+ dev: {
238
+ requestPill: false,
239
+ },
240
+ };
241
+ ```
242
+
243
+ It never appears in a browser driven by automation (Playwright, Selenium, Puppeteer), so it can't intercept clicks in your e2e tests.
224
244
 
225
245
  ### `dev.hostname`
226
246
 
@@ -91,7 +91,13 @@ export default function Layout({ children }: { children: React.ReactNode }) {
91
91
  }
92
92
  ```
93
93
 
94
- The framework warns in dev mode when this is detected. For navigation loading states, use `usePendingNavigation()` instead.
94
+ The framework warns in dev mode when this is detected. For navigation loading states, use `usePendingNavigation()` instead. It keeps the departing page on screen and tells you a navigation is in flight. Its selector form tells you where the navigation is going, so a list can dim only for its own sort, filter or page changes and not when the user leaves the page:
95
+
96
+ ```tsx
97
+ const replacing = usePendingNavigation((to, from) => to.pathname === from.pathname);
98
+ ```
99
+
100
+ See [`usePendingNavigation`](/docs/api-client#usependingnavigationselect).
95
101
 
96
102
  ## `deferSuspenseFor`
97
103
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@timber-js/app",
3
- "version": "0.2.0-alpha.228",
3
+ "version": "0.2.0-alpha.229",
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",
@@ -157,8 +157,8 @@
157
157
  "cookie": "^2.0.1",
158
158
  "jsonc-parser": "^3.3.1",
159
159
  "magic-string": "^1.4.5",
160
- "nitro": "3.0.261102-rc",
161
- "oxc-transform-react": "^0.156.0",
160
+ "nitro": "3.0.261103-rc",
161
+ "oxc-transform-react": "^0.157.0",
162
162
  "srvx": "^1.0.8"
163
163
  },
164
164
  "peerDependencies": {
@@ -17,6 +17,7 @@ import {
17
17
  showCompilingOverlay,
18
18
  hideCompilingOverlay,
19
19
  } from '../browser-dev.ts';
20
+ import { setupDevPill } from '../dev-pill/index.ts';
20
21
 
21
22
  type HotApi = {
22
23
  on(event: string, cb: (...args: unknown[]) => void): void;
@@ -30,7 +31,14 @@ type HotApi = {
30
31
  * In production builds, `import.meta.hot` is undefined and this
31
32
  * function is a no-op.
32
33
  */
33
- export function setupHmr(router: RouterInstance): void {
34
+ export interface HmrOptions {
35
+ /** `dev.requestPill` from timber.config.ts. */
36
+ requestPill: boolean;
37
+ /** `dev.slowPhaseMs` from timber.config.ts. */
38
+ slowPhaseMs: number;
39
+ }
40
+
41
+ export function setupHmr(router: RouterInstance, options: HmrOptions): void {
34
42
  // Vite injects import.meta.hot in dev mode. Cast to access it without
35
43
  // requiring vite/client types in the package tsconfig.
36
44
  const hot = (import.meta as unknown as { hot?: HotApi }).hot;
@@ -67,4 +75,8 @@ export function setupHmr(router: RouterInstance): void {
67
75
  // The server source-maps the stack and sends it back via Vite's
68
76
  // error overlay protocol. See dev-server.ts §client error listener.
69
77
  setupClientErrorForwarding(hot);
78
+
79
+ // Server spans behind the current page, streamed as they end.
80
+ // See design/50-dev-request-pill.md.
81
+ if (options.requestPill) setupDevPill(hot, { slowMs: options.slowPhaseMs });
70
82
  }
@@ -114,7 +114,10 @@ function bootstrap(runtimeConfig: typeof config, formState: ReactFormState | nul
114
114
  setupPostHydration({ router, navApiController });
115
115
 
116
116
  // Step 6: HMR (dev-only, no-op in production)
117
- setupHmr(router);
117
+ setupHmr(router, {
118
+ requestPill: ((runtimeConfig as Record<string, unknown>).devRequestPill as boolean) ?? true,
119
+ slowPhaseMs: ((runtimeConfig as Record<string, unknown>).slowPhaseMs as number) ?? 200,
120
+ });
118
121
 
119
122
  // Step 7: Without a payload there is nothing to hydrate: the page is the
120
123
  // server's HTML until the first navigation, and is ready now.
@@ -0,0 +1,128 @@
1
+ /**
2
+ * Dev request pill — wiring. Feeds the store from three places:
3
+ *
4
+ * - HMR `timber:span` events: every finished server span, as it ends.
5
+ * - The document's navigation timing entry, whose `serverTiming` carries the
6
+ * page's trace ID (the one response header page JS can read for the
7
+ * document itself).
8
+ * - A dev-only `window.fetch` wrapper that reads the same entry from every
9
+ * same-origin response: RSC navigations, server actions, and the app's
10
+ * own calls to `route.ts` handlers. Wrapping fetch keeps the router
11
+ * unaware of the pill.
12
+ *
13
+ * Loaded only from the dev HMR setup (`import.meta.hot`), so it never ships
14
+ * in a production bundle. See design/50-dev-request-pill.md.
15
+ */
16
+
17
+ import {
18
+ DEV_SPAN_EVENT,
19
+ DEV_SPAN_REPLAY_EVENT,
20
+ traceIdFromServerTiming,
21
+ type DevSpanPayload,
22
+ } from '../../shared/dev-span.ts';
23
+ import { RSC_CONTENT_TYPE } from '../../shared/rsc-media-type.ts';
24
+ import { DevPillStore, pageKey, type DevRequest } from './store.ts';
25
+ import { mountDevPill } from './view.ts';
26
+
27
+ type Hot = {
28
+ on(event: string, cb: (data: unknown) => void): void;
29
+ send(event: string, data: unknown): void;
30
+ };
31
+
32
+ /** Classify a same-origin fetch; null for cross-origin (no trace to read). */
33
+ export function describeFetch(
34
+ input: RequestInfo | URL,
35
+ init: RequestInit | undefined,
36
+ baseUrl: string
37
+ ): Omit<DevRequest, 'traceId'> | null {
38
+ const request = input instanceof Request ? input : null;
39
+ const url = new URL(request ? request.url : String(input), baseUrl);
40
+ if (url.origin !== new URL(baseUrl).origin) return null;
41
+ const headers = new Headers(init?.headers ?? request?.headers);
42
+ const method = (init?.method ?? request?.method ?? 'GET').toUpperCase();
43
+ const kind = headers.has('x-rsc-action')
44
+ ? 'action'
45
+ : (headers.get('Accept') ?? '').includes(RSC_CONTENT_TYPE)
46
+ ? 'navigation'
47
+ : 'fetch';
48
+ return { kind, method, path: url.pathname, page: pageKey(url) };
49
+ }
50
+
51
+ /**
52
+ * Set by a test's init script to keep the pill under automation (the
53
+ * pill's own e2e test). See `isAutomated()`.
54
+ */
55
+ export const DEV_PILL_FORCE_KEY = '__timber_dev_pill';
56
+
57
+ /**
58
+ * A browser driven by automation (Playwright, Selenium, Puppeteer) gets no
59
+ * pill: a fixed overlay intercepts clicks on whatever sits under it, which
60
+ * broke a link click in our own suite and would break the app's e2e tests
61
+ * run against `vite dev`. Nothing is installed at all — no overlay, no
62
+ * fetch wrapper — so an automated run behaves as it did without the pill.
63
+ */
64
+ function isAutomated(): boolean {
65
+ const forced = DEV_PILL_FORCE_KEY in window && window[DEV_PILL_FORCE_KEY] === true;
66
+ return navigator.webdriver === true && !forced;
67
+ }
68
+
69
+ export function setupDevPill(hot: Hot, options: { slowMs: number }): void {
70
+ if (isAutomated()) return;
71
+
72
+ const store = new DevPillStore(() => pageKey(new URL(window.location.href)), options.slowMs);
73
+
74
+ // Spans that ended before this tab connected (most of a document load)
75
+ // are only on the server: ask for each trace the tab learns. Asked again
76
+ // on every (re)connect, since a send before the socket opens can be lost.
77
+ const claimed = new Set<string>();
78
+ const requestReplay = (traceId: string) => {
79
+ try {
80
+ hot.send(DEV_SPAN_REPLAY_EVENT, { traceId });
81
+ } catch {
82
+ // Not connected yet; vite:ws:connect asks again.
83
+ }
84
+ };
85
+ const claim = (request: DevRequest) => {
86
+ claimed.add(request.traceId);
87
+ store.addRequest(request);
88
+ requestReplay(request.traceId);
89
+ };
90
+ hot.on('vite:ws:connect', () => claimed.forEach(requestReplay));
91
+
92
+ hot.on(DEV_SPAN_EVENT, (data) => store.addSpan(data as DevSpanPayload));
93
+
94
+ const nav = performance.getEntriesByType('navigation')[0] as
95
+ | PerformanceNavigationTiming
96
+ | undefined;
97
+ // Empty outside a secure context (a LAN IP over http): the document then
98
+ // has no trace, and the pill appears with the first navigation.
99
+ const documentTrace = traceIdFromServerTiming(nav?.serverTiming ?? null);
100
+ if (documentTrace) {
101
+ claim({
102
+ traceId: documentTrace,
103
+ kind: 'document',
104
+ method: 'GET',
105
+ path: window.location.pathname,
106
+ page: pageKey(new URL(window.location.href)),
107
+ });
108
+ }
109
+
110
+ const originalFetch = window.fetch;
111
+ window.fetch = async (input, init) => {
112
+ const response = await originalFetch(input, init);
113
+ try {
114
+ const traceId = traceIdFromServerTiming(response.headers.get('Server-Timing'));
115
+ const described = traceId ? describeFetch(input, init, window.location.href) : null;
116
+ if (traceId && described) claim({ traceId, ...described });
117
+ } catch {
118
+ // Observing a response must never break the fetch that made it.
119
+ }
120
+ return response;
121
+ };
122
+
123
+ // Fired inside a navigation's commit, when the address bar moves.
124
+ window.addEventListener('timber:navigation-end', () => store.navigationCommitted());
125
+ window.addEventListener('popstate', () => store.navigationCommitted());
126
+
127
+ mountDevPill(store);
128
+ }