@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.
- package/agent-skill.md +9 -0
- package/dist/_chunks/{actions-DprvPi7O.js → actions-DHum77eH.js} +3 -3
- package/dist/_chunks/{actions-DprvPi7O.js.map → actions-DHum77eH.js.map} +1 -1
- package/dist/_chunks/{cache-api-BjE-nNC0.js → cache-api-BZJNt01a.js} +4 -4
- package/dist/_chunks/{cache-api-BjE-nNC0.js.map → cache-api-BZJNt01a.js.map} +1 -1
- package/dist/_chunks/{chains-DaDEXv0c.js → chains-D-RRc7CM.js} +2 -2
- package/dist/_chunks/{chains-DaDEXv0c.js.map → chains-D-RRc7CM.js.map} +1 -1
- package/dist/_chunks/chains-KblEfYzm.js +1 -0
- package/dist/_chunks/{classify-BuIifN5v.js → classify-_W0RWa5w.js} +2 -2
- package/dist/_chunks/{classify-BuIifN5v.js.map → classify-_W0RWa5w.js.map} +1 -1
- package/dist/_chunks/{cli-check-B_fDvxhs.js → cli-check-B-JZkpBD.js} +3 -3
- package/dist/_chunks/{cli-check-B_fDvxhs.js.map → cli-check-B-JZkpBD.js.map} +1 -1
- package/dist/_chunks/{cli-schema-sync-D9OLUUFv.js → cli-schema-sync-CAllbqRB.js} +2 -2
- package/dist/_chunks/{cli-schema-sync-D9OLUUFv.js.map → cli-schema-sync-CAllbqRB.js.map} +1 -1
- package/dist/_chunks/{cli-schema-sync-CUIk0G2X.js → cli-schema-sync-y_8ijmzO.js} +1 -1
- package/dist/_chunks/{client-dep-entries-COuyF8-c.js → client-dep-entries-C9hv-3k9.js} +2 -2
- package/dist/_chunks/{client-dep-entries-COuyF8-c.js.map → client-dep-entries-C9hv-3k9.js.map} +1 -1
- package/dist/_chunks/{convention-lint-BHY0d5AQ.js → convention-lint-CrDKERHg.js} +3 -3
- package/dist/_chunks/{convention-lint-BHY0d5AQ.js.map → convention-lint-CrDKERHg.js.map} +1 -1
- package/dist/_chunks/dev-server-L8biS7Az.js +1 -0
- package/dist/_chunks/{dev-server-BaM7q3pr.js → dev-server-Rq659RR1.js} +8 -2
- package/dist/_chunks/dev-server-Rq659RR1.js.map +1 -0
- package/dist/_chunks/{build-manifest-Y4jl7nwU.js → dev-span-_NzMX-au.js} +25 -2
- package/dist/_chunks/dev-span-_NzMX-au.js.map +1 -0
- package/dist/_chunks/{error-boundary-D3YyVVuP.js → error-boundary-OHK1mI99.js} +3 -3
- package/dist/_chunks/{error-boundary-D3YyVVuP.js.map → error-boundary-OHK1mI99.js.map} +1 -1
- package/dist/_chunks/{flight-source-node-CZJ9Drb7.js → flight-source-node-BGanuoSS.js} +2 -2
- package/dist/_chunks/{flight-source-node-CZJ9Drb7.js.map → flight-source-node-BGanuoSS.js.map} +1 -1
- package/dist/_chunks/{global-context-DbxNWeBP.js → global-context-CFSSysdJ.js} +32 -2
- package/dist/_chunks/global-context-CFSSysdJ.js.map +1 -0
- package/dist/_chunks/{json-lossy-check-BNwKrm2R.js → json-lossy-check-BXM45k8p.js} +2 -2
- package/dist/_chunks/{json-lossy-check-BNwKrm2R.js.map → json-lossy-check-BXM45k8p.js.map} +1 -1
- package/dist/_chunks/{live-graph-DiRVmRrC.js → live-graph-C7-yA8W9.js} +4 -4
- package/dist/_chunks/{live-graph-DiRVmRrC.js.map → live-graph-C7-yA8W9.js.map} +1 -1
- package/dist/_chunks/{logger-DRMij51J.js → logger-YtMSKfft.js} +100 -57
- package/dist/_chunks/logger-YtMSKfft.js.map +1 -0
- package/dist/_chunks/navigation-root-CoGHIMiE.js +239 -0
- package/dist/_chunks/navigation-root-CoGHIMiE.js.map +1 -0
- package/dist/_chunks/{node-response-C-dQn-0N.js → node-response-D3hXWb8y.js} +2 -2
- package/dist/_chunks/{node-response-C-dQn-0N.js.map → node-response-D3hXWb8y.js.map} +1 -1
- package/dist/_chunks/{poison-scan-CqPGN0ru.js → poison-scan-CRSP06Es.js} +2 -2
- package/dist/_chunks/{poison-scan-CqPGN0ru.js.map → poison-scan-CRSP06Es.js.map} +1 -1
- package/dist/_chunks/{scanner-C__vsQ8d.js → scanner-BNQ4qnLX.js} +2 -2
- package/dist/_chunks/{scanner-C__vsQ8d.js.map → scanner-BNQ4qnLX.js.map} +1 -1
- package/dist/_chunks/segment-context-GAyTjjtS.js +33 -0
- package/dist/_chunks/segment-context-GAyTjjtS.js.map +1 -0
- package/dist/_chunks/{sizeof-DcEcQaSL.js → sizeof-Cmx6Fs-Y.js} +2 -2
- package/dist/_chunks/{sizeof-DcEcQaSL.js.map → sizeof-Cmx6Fs-Y.js.map} +1 -1
- package/dist/_chunks/{status-page-marker-C8POawuF.js → status-page-marker-U6B1aFMb.js} +3 -32
- package/dist/_chunks/status-page-marker-U6B1aFMb.js.map +1 -0
- package/dist/_chunks/{walkers-D6KY4jyS.js → walkers-D_QHR_nf.js} +3 -3
- package/dist/_chunks/{walkers-D6KY4jyS.js.map → walkers-D_QHR_nf.js.map} +1 -1
- package/dist/adapters/cloudflare-kv-cache.js +1 -1
- package/dist/analyze/crawl-entry.js +3 -3
- package/dist/analyze/graph-command.js +2 -2
- package/dist/cache/index.js +2 -2
- package/dist/cache/stores/memory.js +1 -1
- package/dist/cli.js +3 -3
- package/dist/client/browser-entry/hmr.d.ts +7 -1
- package/dist/client/browser-entry/hmr.d.ts.map +1 -1
- package/dist/client/dev-pill/index.d.ts +32 -0
- package/dist/client/dev-pill/index.d.ts.map +1 -0
- package/dist/client/dev-pill/store.d.ts +96 -0
- package/dist/client/dev-pill/store.d.ts.map +1 -0
- package/dist/client/dev-pill/view.d.ts +9 -0
- package/dist/client/dev-pill/view.d.ts.map +1 -0
- package/dist/client/error-boundary.js +1 -1
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +3 -3
- package/dist/client/internal.js +16 -7
- package/dist/client/internal.js.map +1 -1
- package/dist/client/navigation-context.d.ts +20 -0
- package/dist/client/navigation-context.d.ts.map +1 -1
- package/dist/client/router-lifecycle.d.ts +4 -1
- package/dist/client/router-lifecycle.d.ts.map +1 -1
- package/dist/client/use-pending-navigation.d.ts +33 -9
- package/dist/client/use-pending-navigation.d.ts.map +1 -1
- package/dist/config-types.d.ts +10 -0
- package/dist/config-types.d.ts.map +1 -1
- package/dist/config-validation.d.ts.map +1 -1
- package/dist/dev-tools/await-span.d.ts +17 -0
- package/dist/dev-tools/await-span.d.ts.map +1 -0
- package/dist/dev-tools/instrumentation.d.ts.map +1 -1
- package/dist/dev-tools/logger.d.ts.map +1 -1
- package/dist/dev-tools/logs.d.ts.map +1 -1
- package/dist/dev-tools/span-sink.d.ts +42 -0
- package/dist/dev-tools/span-sink.d.ts.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +282 -9
- package/dist/index.js.map +1 -1
- package/dist/plugins/dev-await.d.ts +40 -0
- package/dist/plugins/dev-await.d.ts.map +1 -0
- package/dist/plugins/entries.d.ts.map +1 -1
- package/dist/routing/index.js +2 -2
- package/dist/server/index.js +2 -2
- package/dist/server/internal.js +9 -8
- package/dist/server/internal.js.map +1 -1
- package/dist/server/pipeline.d.ts +8 -0
- package/dist/server/pipeline.d.ts.map +1 -1
- package/dist/server/rsc-entry/index.d.ts.map +1 -1
- package/dist/server/slot-resolver.d.ts.map +1 -1
- package/dist/server/tracing.d.ts +18 -8
- package/dist/server/tracing.d.ts.map +1 -1
- package/dist/shared/dev-span.d.ts +97 -0
- package/dist/shared/dev-span.d.ts.map +1 -0
- package/docs/api/31-api-client.mdx +27 -1
- package/docs/api/34-api-config.mdx +21 -1
- package/docs/learn/09-streaming.mdx +7 -1
- package/package.json +3 -3
- package/src/client/browser-entry/hmr.ts +13 -1
- package/src/client/browser-entry/index.ts +4 -1
- package/src/client/dev-pill/index.ts +128 -0
- package/src/client/dev-pill/store.ts +231 -0
- package/src/client/dev-pill/view.ts +278 -0
- package/src/client/index.ts +1 -0
- package/src/client/navigation-context.ts +5 -2
- package/src/client/router-lifecycle.ts +23 -3
- package/src/client/use-pending-navigation.ts +93 -14
- package/src/config-types.ts +10 -0
- package/src/config-validation.ts +10 -0
- package/src/dev-tools/await-span.ts +40 -0
- package/src/dev-tools/instrumentation.ts +20 -0
- package/src/dev-tools/logger.ts +3 -37
- package/src/dev-tools/logs.ts +10 -1
- package/src/dev-tools/span-sink.ts +132 -0
- package/src/index.ts +2 -0
- package/src/plugins/dev-await.ts +268 -0
- package/src/plugins/entries.ts +2 -0
- package/src/server/pipeline.ts +14 -0
- package/src/server/rsc-entry/index.ts +7 -1
- package/src/server/slot-resolver.ts +45 -5
- package/src/server/tracing.ts +121 -87
- package/src/shared/dev-span.ts +182 -0
- package/dist/_chunks/build-manifest-Y4jl7nwU.js.map +0 -1
- package/dist/_chunks/chains-BS8fQYao.js +0 -1
- package/dist/_chunks/dev-server-BaM7q3pr.js.map +0 -1
- package/dist/_chunks/dev-server-NnGosJ06.js +0 -1
- package/dist/_chunks/global-context-DbxNWeBP.js.map +0 -1
- package/dist/_chunks/logger-DRMij51J.js.map +0 -1
- package/dist/_chunks/navigation-root-M3B2ZrdO.js +0 -122
- package/dist/_chunks/navigation-root-M3B2ZrdO.js.map +0 -1
- package/dist/_chunks/segment-context-CYiGTi3K.js +0 -131
- package/dist/_chunks/segment-context-CYiGTi3K.js.map +0 -1
- package/dist/_chunks/status-page-marker-C8POawuF.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-types.d.ts","sourceRoot":"","sources":["../src/config-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,uDAAuD;AACvD,MAAM,WAAW,sBAAsB;IACrC,yEAAyE;IACzE,QAAQ,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC7B;;;;;;;;;;OAUG;IACH,KAAK,CAA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,OAAO,CAAC;KAC/B,CAAC;IACF,SAAS,CAAC,EAAE;QACV,wDAAwD;QACxD,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,qCAAqC;QACrC,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,wCAAwC;QACxC,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,qDAAqD;QACrD,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,kFAAkF;QAClF,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,kCAAkC;QAClC,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;CACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-validation.d.ts","sourceRoot":"","sources":["../src/config-validation.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAM1D,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,KAAK,CAAC,EAAE,IAAI,CAAC;CACd;AAuCD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,gBAAgB,GAAG,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"config-validation.d.ts","sourceRoot":"","sources":["../src/config-validation.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAM1D,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,KAAK,CAAC,EAAE,IAAI,CAAC;CACd;AAuCD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,gBAAgB,GAAG,WAAW,EAAE,CAoOtE;AA+ED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,WAAW,EAAE,EACrB,EAAE,KAAY,EAAE,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,GACzC,MAAM,CAkBR;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,WAAW,EAAE,EACrB,KAAK,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAA2C,GACnE,IAAI,CAKN;AAeD;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAOpE;AAID,UAAU,aAAa;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,IAAI,GAAG,SAAS,CAAC;CAC1B;AAOD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,aAAa,EAAE,CAmB1E;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,aAAa,EAAE,GAAG,MAAM,CAgBnE"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dev await wrapper — the runtime half of the dev await transform
|
|
3
|
+
* (`plugins/dev-await.ts`). Each `await x` in app server code calls this
|
|
4
|
+
* with a thunk for `x`, so the awaited work runs inside a `timber.await`
|
|
5
|
+
* span and appears in the terminal tree and the dev request pill nested
|
|
6
|
+
* under the component, middleware or action that awaited it.
|
|
7
|
+
*
|
|
8
|
+
* See design/50-dev-request-pill.md §"Phase 2".
|
|
9
|
+
*/
|
|
10
|
+
export type DevAwaitWrapper = (thunk: () => Promise<unknown>, label: string, location: string) => Promise<unknown>;
|
|
11
|
+
/**
|
|
12
|
+
* Install the wrapper on `globalThis[DEV_AWAIT_KEY]`. Transformed modules
|
|
13
|
+
* look it up per call, so a module evaluated before this ran still gets
|
|
14
|
+
* spans once it has. Idempotent: a repeat install replaces the wrapper.
|
|
15
|
+
*/
|
|
16
|
+
export declare function installDevAwait(): void;
|
|
17
|
+
//# sourceMappingURL=await-span.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"await-span.d.ts","sourceRoot":"","sources":["../../src/dev-tools/await-span.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,MAAM,MAAM,eAAe,GAAG,CAC5B,KAAK,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,EAC7B,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,KACb,OAAO,CAAC,OAAO,CAAC,CAAC;AAEtB;;;;GAIG;AACH,wBAAgB,eAAe,IAAI,IAAI,CActC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../src/dev-tools/instrumentation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,YAAY,EAClB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAKL,KAAK,eAAe,EACrB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../src/dev-tools/instrumentation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,YAAY,EAClB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAKL,KAAK,eAAe,EACrB,MAAM,aAAa,CAAC;AAOrB,MAAM,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC;AAazC;;;;;;GAMG;AACH,wBAAgB,kBAAkB,IAAI,eAAe,CAwDpD;AAgCD;;;;;;;;;;;GAWG;AACH,qBAAa,gBAAiB,YAAW,aAAa;IACpD;;;;;;;OAOG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAO;IAEjD,OAAO,CAAC,YAAY,CAAqC;IACzD,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,MAAM,CAAkB;IAEhC,YAAY,MAAM,EAAE,eAAe,EAGlC;IAED,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,GAAG,IAAI,CAE5C;IAED,KAAK,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,CAkC9B;IAED,OAAO,CAAC,MAAM;IAUR,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAE9B;IAEK,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAEhC;CACF;AAID;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI,CA6BhE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/dev-tools/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/dev-tools/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAKlE,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;AAE3E,MAAM,WAAW,eAAe;IAC9B,qCAAqC;IACrC,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,8DAA8D;IAC9D,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AA2JD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,eAAe,GAAG,UAAU,CAMnE;AAID;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE,MAAM,CAAC,EAAE,eAAe,GAAG,MAAM,CAgDtF;AAwGD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,MAAM,CAc1F;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,YAAY,EAAE,GAAG,MAAM,CA6BxD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logs.d.ts","sourceRoot":"","sources":["../../src/dev-tools/logs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,EAAE,MAAM,MAAM,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"logs.d.ts","sourceRoot":"","sources":["../../src/dev-tools/logs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,EAAE,MAAM,MAAM,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAK1D;;;;;GAKG;AACH,eAAO,MAAM,eAAe,EAAE,IAAI,CAAC,OAAO,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAMtF,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAqDpE;AAID,iDAAiD;AACjD,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC;AAIzE,8CAA8C;AAC9C,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,cAAc,CAAC;IACtB,IAAI,EAAE,OAAO,EAAE,CAAC;IAChB,gEAAgE;IAChE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,mCAAmC;IACnC,SAAS,EAAE,MAAM,CAAC;CACnB;AA2ID;;;;;;;;;;GAUG;AACH,wBAAgB,yBAAyB,IAAI,OAAO,CAsBnD;AAiGD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAyBzD"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Span sink — streams finished dev spans to the browser over HMR, for the
|
|
3
|
+
* dev request pill. See design/50-dev-request-pill.md §"Transport".
|
|
4
|
+
*
|
|
5
|
+
* Two halves that run in different module graphs of one process:
|
|
6
|
+
* - `installSpanSink()` runs in the dev server plugin, which owns the HMR
|
|
7
|
+
* channel.
|
|
8
|
+
* - `forwardSpan()` runs in `DevSpanProcessor` (RSC graph) on every span end.
|
|
9
|
+
* They meet at `globalThis[DEV_SPAN_SINK_KEY]`. With nothing installed (a
|
|
10
|
+
* production build under TIMBER_DEBUG, unit tests), forwarding is a no-op —
|
|
11
|
+
* this is what keeps the browser channel gated to `vite dev`.
|
|
12
|
+
*/
|
|
13
|
+
import type { ReadableSpan } from '@opentelemetry/sdk-trace-base';
|
|
14
|
+
import { type DevSpanPayload } from '../shared/dev-span.ts';
|
|
15
|
+
/** Project an OTEL span onto the browser payload. */
|
|
16
|
+
export declare function toDevSpanPayload(span: ReadableSpan): DevSpanPayload;
|
|
17
|
+
/** Called by DevSpanProcessor for every finished span. */
|
|
18
|
+
export declare function forwardSpan(span: ReadableSpan): void;
|
|
19
|
+
/** The slice of Vite's HMR channel the sink uses. */
|
|
20
|
+
export interface SpanSinkChannel {
|
|
21
|
+
send(event: string, data: unknown): void;
|
|
22
|
+
on(event: string, listener: (data: unknown, client: {
|
|
23
|
+
send(event: string, data: unknown): void;
|
|
24
|
+
}) => void): void;
|
|
25
|
+
off(event: string, listener: (...args: never[]) => void): void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Install the sink that broadcasts spans on the dev server's HMR channel,
|
|
29
|
+
* and answers replay requests from it.
|
|
30
|
+
*
|
|
31
|
+
* Broadcasting alone loses most of a document load: the root span ends when
|
|
32
|
+
* the pipeline returns its Response, tens of milliseconds in, and the page's
|
|
33
|
+
* HMR socket connects later than that. So the sink keeps recent traces, and
|
|
34
|
+
* a tab that learns a trace ID asks for it (`DEV_SPAN_REPLAY_EVENT`); the
|
|
35
|
+
* answer goes to that tab alone. The tab dedupes by span ID, so a span that
|
|
36
|
+
* arrives both ways counts once.
|
|
37
|
+
*
|
|
38
|
+
* Returns the uninstall function; an uninstall only removes its own sink, so
|
|
39
|
+
* a restarted server's sink survives the old server's close.
|
|
40
|
+
*/
|
|
41
|
+
export declare function installSpanSink(hot: SpanSinkChannel): () => void;
|
|
42
|
+
//# sourceMappingURL=span-sink.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"span-sink.d.ts","sourceRoot":"","sources":["../../src/dev-tools/span-sink.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAML,KAAK,cAAc,EAEpB,MAAM,uBAAuB,CAAC;AAc/B,qDAAqD;AACrD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,YAAY,GAAG,cAAc,CAwBnE;AAED,0DAA0D;AAC1D,wBAAgB,WAAW,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,CAUpD;AAKD,qDAAqD;AACrD,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;IACzC,EAAE,CACA,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE;QAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,CAAA;KAAE,KAAK,IAAI,GACtF,IAAI,CAAC;IACR,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,IAAI,GAAG,IAAI,CAAC;CAChE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,IAAI,CA4BhE"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAU,YAAY,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAU,YAAY,EAAE,MAAM,MAAM,CAAC;AA8CjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAa1D,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAQ1D,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAElG;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,MAAM;CAAG;AAE1B;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,gBAAgB,GAAG,gBAAgB,CAEvE;AAyGD,wBAAgB,MAAM,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,YAAY,EAAE,CAyXhE;eAEc,MAAM"}
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { a as formatMissingPeers, i as checkPeerDependencies, n as timberDevServer, o as reportConfigErrors, s as validateConfig } from "./_chunks/dev-server-
|
|
1
|
+
import { a as formatMissingPeers, i as checkPeerDependencies, n as timberDevServer, o as reportConfigErrors, s as validateConfig } from "./_chunks/dev-server-Rq659RR1.js";
|
|
2
2
|
import { i as resolveRenderTimeoutMs } from "./_chunks/render-timeout-MrrqD1wd.js";
|
|
3
3
|
import { t as writeFileAtomic } from "./_chunks/write-file-atomic-DW8m_Atv.js";
|
|
4
|
-
import { d as collectInterceptionRewrites, l as getPrerenderExport, n as scanRoutes } from "./_chunks/scanner-
|
|
5
|
-
import { b as swallow } from "./_chunks/logger-
|
|
6
|
-
import { c as buildDirToRouteMap, n as formatConventionWarnings, o as flushCodegenWrites, r as lintConventions, s as writeRouteCodegen, t as checkAppDirExists } from "./_chunks/convention-lint-
|
|
4
|
+
import { d as collectInterceptionRewrites, l as getPrerenderExport, n as scanRoutes } from "./_chunks/scanner-BNQ4qnLX.js";
|
|
5
|
+
import { b as swallow } from "./_chunks/logger-YtMSKfft.js";
|
|
6
|
+
import { c as buildDirToRouteMap, n as formatConventionWarnings, o as flushCodegenWrites, r as lintConventions, s as writeRouteCodegen, t as checkAppDirExists } from "./_chunks/convention-lint-CrDKERHg.js";
|
|
7
7
|
import { a as contextAdapter, c as loadTimberConfigFile, d as resolveBuildDir, f as resolveClientJavascript, l as mergeFileConfig, m as createNoopTimer, o as createPluginContext, r as adapterConfig, u as resolveAppDir } from "./_chunks/plugin-context-FCkaNLUB.js";
|
|
8
8
|
import { i as withBasePath, n as normalizeBasePath, t as isRelativeBase } from "./_chunks/base-path-DDIx0FXe.js";
|
|
9
|
-
import { r as validateSchemaAgainstRoutes, t as collectLeafRoutes } from "./_chunks/walkers-
|
|
9
|
+
import { r as validateSchemaAgainstRoutes, t as collectLeafRoutes } from "./_chunks/walkers-D_QHR_nf.js";
|
|
10
10
|
import { i as poisonPillSource, r as markerFor, t as EXPLICIT_MARKERS } from "./_chunks/poison-rules-Bmz-lCPi.js";
|
|
11
11
|
import { n as rscPayloadPath, t as RSC_PAYLOAD_DIR } from "./_chunks/rsc-payload-path-EphpDB-J.js";
|
|
12
12
|
import { a as REDIRECTS_FILE, n as detectFsIdentity, o as RESERVED_OUTPUT_PATHS, r as fsKey, t as EXACT_FS_IDENTITY } from "./_chunks/fs-identity-BmQ_Agg-.js";
|
|
13
|
-
import {
|
|
13
|
+
import { a as EMPTY_BUILD_MANIFEST, n as DEV_SPAN_REPLAY_EVENT, r as DEV_SPAN_SINK_KEY, t as DEV_SPAN_EVENT } from "./_chunks/dev-span-_NzMX-au.js";
|
|
14
14
|
import { t as fnv1aHash } from "./_chunks/fast-hash-DddxkU5Y.js";
|
|
15
|
-
import { i as detectDirective } from "./_chunks/classify-
|
|
15
|
+
import { i as detectDirective } from "./_chunks/classify-_W0RWa5w.js";
|
|
16
16
|
import { t as formatSize } from "./_chunks/format-DuPOoXUP.js";
|
|
17
17
|
import { createLogger, esmExternalRequirePlugin, isRunnableDevEnvironment, parseAst } from "vite";
|
|
18
18
|
import { basename, dirname, extname, isAbsolute, join, normalize, relative, resolve, win32 } from "node:path";
|
|
@@ -228,6 +228,7 @@ function generateConfigModule(ctx) {
|
|
|
228
228
|
base: ctx.base,
|
|
229
229
|
dev: ctx.dev ?? false,
|
|
230
230
|
slowPhaseMs: ctx.config.dev?.slowPhaseMs ?? 200,
|
|
231
|
+
devRequestPill: ctx.config.dev?.requestPill ?? true,
|
|
231
232
|
slowRequestMs: ctx.config.slowRequestMs ?? 3e3,
|
|
232
233
|
topLoader: ctx.config.topLoader,
|
|
233
234
|
debug: ctx.config.debug ?? false,
|
|
@@ -5601,6 +5602,52 @@ function timberBuildManifest(ctx) {
|
|
|
5601
5602
|
}
|
|
5602
5603
|
};
|
|
5603
5604
|
}
|
|
5605
|
+
// src/dev-tools/span-sink.ts
|
|
5606
|
+
/** Traces the server keeps for replay. Oldest-inserted is evicted. */
|
|
5607
|
+
var MAX_REPLAY_TRACES = 64;
|
|
5608
|
+
/**
|
|
5609
|
+
* Install the sink that broadcasts spans on the dev server's HMR channel,
|
|
5610
|
+
* and answers replay requests from it.
|
|
5611
|
+
*
|
|
5612
|
+
* Broadcasting alone loses most of a document load: the root span ends when
|
|
5613
|
+
* the pipeline returns its Response, tens of milliseconds in, and the page's
|
|
5614
|
+
* HMR socket connects later than that. So the sink keeps recent traces, and
|
|
5615
|
+
* a tab that learns a trace ID asks for it (`DEV_SPAN_REPLAY_EVENT`); the
|
|
5616
|
+
* answer goes to that tab alone. The tab dedupes by span ID, so a span that
|
|
5617
|
+
* arrives both ways counts once.
|
|
5618
|
+
*
|
|
5619
|
+
* Returns the uninstall function; an uninstall only removes its own sink, so
|
|
5620
|
+
* a restarted server's sink survives the old server's close.
|
|
5621
|
+
*/
|
|
5622
|
+
function installSpanSink(hot) {
|
|
5623
|
+
const globals = globalThis;
|
|
5624
|
+
const recent = /* @__PURE__ */ new Map();
|
|
5625
|
+
const sink = (span) => {
|
|
5626
|
+
let spans = recent.get(span.traceId);
|
|
5627
|
+
if (!spans) {
|
|
5628
|
+
if (recent.size >= MAX_REPLAY_TRACES) {
|
|
5629
|
+
const oldest = recent.keys().next().value;
|
|
5630
|
+
if (oldest !== void 0) recent.delete(oldest);
|
|
5631
|
+
}
|
|
5632
|
+
spans = [];
|
|
5633
|
+
recent.set(span.traceId, spans);
|
|
5634
|
+
}
|
|
5635
|
+
spans.push(span);
|
|
5636
|
+
hot.send(DEV_SPAN_EVENT, span);
|
|
5637
|
+
};
|
|
5638
|
+
const onReplay = (data, client) => {
|
|
5639
|
+
if (typeof data !== "object" || data === null || !("traceId" in data)) return;
|
|
5640
|
+
const { traceId } = data;
|
|
5641
|
+
if (typeof traceId !== "string") return;
|
|
5642
|
+
for (const span of recent.get(traceId) ?? []) client.send(DEV_SPAN_EVENT, span);
|
|
5643
|
+
};
|
|
5644
|
+
globals[DEV_SPAN_SINK_KEY] = sink;
|
|
5645
|
+
hot.on(DEV_SPAN_REPLAY_EVENT, onReplay);
|
|
5646
|
+
return () => {
|
|
5647
|
+
hot.off(DEV_SPAN_REPLAY_EVENT, onReplay);
|
|
5648
|
+
if (globals[DEV_SPAN_SINK_KEY] === sink) delete globals[DEV_SPAN_SINK_KEY];
|
|
5649
|
+
};
|
|
5650
|
+
}
|
|
5604
5651
|
// src/dev-tools/logs.ts
|
|
5605
5652
|
/**
|
|
5606
5653
|
* Snapshot of the original console methods, captured at module load time
|
|
@@ -5862,7 +5909,12 @@ function timberDevLogs(_ctx) {
|
|
|
5862
5909
|
name: "timber-dev-logs",
|
|
5863
5910
|
apply: "serve",
|
|
5864
5911
|
configureServer(server) {
|
|
5865
|
-
|
|
5912
|
+
const unpatch = patchConsole(server, _ctx.root);
|
|
5913
|
+
const uninstallSink = _ctx.config.dev?.requestPill === false ? () => {} : installSpanSink(server.hot);
|
|
5914
|
+
cleanup = () => {
|
|
5915
|
+
unpatch();
|
|
5916
|
+
uninstallSink();
|
|
5917
|
+
};
|
|
5866
5918
|
server.httpServer?.on("close", () => {
|
|
5867
5919
|
cleanup?.();
|
|
5868
5920
|
cleanup = null;
|
|
@@ -9098,6 +9150,226 @@ function timberPrerenderSugar(ctx) {
|
|
|
9098
9150
|
}
|
|
9099
9151
|
};
|
|
9100
9152
|
}
|
|
9153
|
+
// src/plugins/dev-await.ts
|
|
9154
|
+
/**
|
|
9155
|
+
* timber-dev-await — dev-only transform that turns every `await` in app
|
|
9156
|
+
* server code into a span, so postgres queries, redis calls and SDK
|
|
9157
|
+
* requests appear in the terminal tree and the dev request pill without
|
|
9158
|
+
* per-library instrumentation.
|
|
9159
|
+
*
|
|
9160
|
+
* const rows = await db.select().from(users);
|
|
9161
|
+
* // becomes
|
|
9162
|
+
* const rows = await __timber_await$(async () => (db.select().from(users)),
|
|
9163
|
+
* "db.select().from(users)", "app/users/page.tsx:12");
|
|
9164
|
+
*
|
|
9165
|
+
* `__timber_await$` is declared once per module and looks the wrapper up on
|
|
9166
|
+
* `globalThis[DEV_AWAIT_KEY]` at call time (installed with dev tracing,
|
|
9167
|
+
* `dev-tools/await-span.ts`); with none installed it calls the thunk. A
|
|
9168
|
+
* global rather than an injected import, so the rewrite needs no resolvable
|
|
9169
|
+
* specifier from a workspace package outside the app.
|
|
9170
|
+
*
|
|
9171
|
+
* Scope: the RSC environment, `vite dev` only; every module outside
|
|
9172
|
+
* node_modules and outside timber itself, so a monorepo's `packages/db`
|
|
9173
|
+
* (where the query actually is) is covered. Skipped: `'use client'`
|
|
9174
|
+
* modules, top-level await (no request to nest under), awaits of literals,
|
|
9175
|
+
* `await import()` (module loading, and plugin-rsc injects one per layout),
|
|
9176
|
+
* awaits whose operand contains `yield` (an async arrow can't hold it).
|
|
9177
|
+
* `for await` and `await using` are not AwaitExpressions and are untouched.
|
|
9178
|
+
*
|
|
9179
|
+
* See design/50-dev-request-pill.md §"Phase 2".
|
|
9180
|
+
*/
|
|
9181
|
+
/** The per-module helper's name; `$` keeps it out of the way of app identifiers. */
|
|
9182
|
+
var HELPER = "__timber_await$";
|
|
9183
|
+
/** Longest label kept, in characters. */
|
|
9184
|
+
var LABEL_MAX = 80;
|
|
9185
|
+
var SCRIPT_RE = /\.[cm]?[jt]sx?$/;
|
|
9186
|
+
function isNode(value) {
|
|
9187
|
+
return typeof value === "object" && value !== null && typeof value.type === "string" && typeof value.start === "number";
|
|
9188
|
+
}
|
|
9189
|
+
function children(node) {
|
|
9190
|
+
const out = [];
|
|
9191
|
+
for (const key of Object.keys(node)) {
|
|
9192
|
+
const value = node[key];
|
|
9193
|
+
if (Array.isArray(value)) {
|
|
9194
|
+
for (const item of value) if (isNode(item)) out.push(item);
|
|
9195
|
+
} else if (isNode(value)) out.push(value);
|
|
9196
|
+
}
|
|
9197
|
+
return out;
|
|
9198
|
+
}
|
|
9199
|
+
var FUNCTION_TYPES = /* @__PURE__ */ new Set([
|
|
9200
|
+
"FunctionDeclaration",
|
|
9201
|
+
"FunctionExpression",
|
|
9202
|
+
"ArrowFunctionExpression"
|
|
9203
|
+
]);
|
|
9204
|
+
function containsYield(node) {
|
|
9205
|
+
if (node.type === "YieldExpression") return true;
|
|
9206
|
+
if (FUNCTION_TYPES.has(node.type)) return false;
|
|
9207
|
+
return children(node).some(containsYield);
|
|
9208
|
+
}
|
|
9209
|
+
/** Leading directive prologue: `'use server'`, `'use client'`, `'use strict'`. */
|
|
9210
|
+
function directives(program) {
|
|
9211
|
+
const body = program.body ?? [];
|
|
9212
|
+
const names = [];
|
|
9213
|
+
let end = 0;
|
|
9214
|
+
for (const stmt of body) {
|
|
9215
|
+
if (typeof stmt.directive !== "string") break;
|
|
9216
|
+
names.push(stmt.directive);
|
|
9217
|
+
end = stmt.end;
|
|
9218
|
+
}
|
|
9219
|
+
return {
|
|
9220
|
+
names,
|
|
9221
|
+
end
|
|
9222
|
+
};
|
|
9223
|
+
}
|
|
9224
|
+
/** A string or template that starts like a URL: `scheme://`, `/path`, `?query`, or `${base}/path`. */
|
|
9225
|
+
var URL_START = /^(?:[a-z][a-z0-9+.-]*:\/\/|\/|\?|\$\{[^}]*\}\/)/i;
|
|
9226
|
+
/** `scheme://user:pass@host` → `scheme://…@host`. */
|
|
9227
|
+
function redactUserinfo(text) {
|
|
9228
|
+
return text.replace(/:\/\/[^/@\s]*@/g, "://…@");
|
|
9229
|
+
}
|
|
9230
|
+
/**
|
|
9231
|
+
* The operand's source with URL secrets cut out. Labels are source text,
|
|
9232
|
+
* but source can hold literals: `fetch('https://api/x?token=abc')` would
|
|
9233
|
+
* put the token in a span attribute that reaches the browser, the replay
|
|
9234
|
+
* buffer and any OTEL exporter. In string and template literals that start
|
|
9235
|
+
* like a URL, everything from the first `?` or `#` becomes `?…` / `#…`,
|
|
9236
|
+
* and userinfo becomes `…@`. Other strings (a SQL `?` placeholder) and
|
|
9237
|
+
* code (`a?.b`, ternaries) are left alone. Codex review on #1272.
|
|
9238
|
+
*/
|
|
9239
|
+
function redactedSource(code, arg) {
|
|
9240
|
+
const edits = [];
|
|
9241
|
+
const visit = (node) => {
|
|
9242
|
+
if (node.type === "Literal" && typeof node.value === "string") {
|
|
9243
|
+
const inner = code.slice(node.start + 1, node.end - 1);
|
|
9244
|
+
if (URL_START.test(inner)) {
|
|
9245
|
+
const cut = inner.search(/[?#]/);
|
|
9246
|
+
const kept = cut === -1 ? inner : `${inner.slice(0, cut)}${inner[cut]}…`;
|
|
9247
|
+
edits.push({
|
|
9248
|
+
start: node.start + 1,
|
|
9249
|
+
end: node.end - 1,
|
|
9250
|
+
text: redactUserinfo(kept)
|
|
9251
|
+
});
|
|
9252
|
+
}
|
|
9253
|
+
return;
|
|
9254
|
+
}
|
|
9255
|
+
if (node.type === "TemplateLiteral") {
|
|
9256
|
+
const inner = code.slice(node.start + 1, node.end - 1);
|
|
9257
|
+
const quasis = node.quasis ?? [];
|
|
9258
|
+
if (URL_START.test(inner)) {
|
|
9259
|
+
for (const quasi of quasis) {
|
|
9260
|
+
const raw = code.slice(quasi.start, quasi.end);
|
|
9261
|
+
const cut = raw.search(/[?#]/);
|
|
9262
|
+
if (cut === -1) {
|
|
9263
|
+
edits.push({
|
|
9264
|
+
start: quasi.start,
|
|
9265
|
+
end: quasi.end,
|
|
9266
|
+
text: redactUserinfo(raw)
|
|
9267
|
+
});
|
|
9268
|
+
continue;
|
|
9269
|
+
}
|
|
9270
|
+
edits.push({
|
|
9271
|
+
start: quasi.start,
|
|
9272
|
+
end: node.end - 1,
|
|
9273
|
+
text: `${redactUserinfo(raw.slice(0, cut))}${raw[cut]}…`
|
|
9274
|
+
});
|
|
9275
|
+
return;
|
|
9276
|
+
}
|
|
9277
|
+
return;
|
|
9278
|
+
}
|
|
9279
|
+
}
|
|
9280
|
+
for (const child of children(node)) visit(child);
|
|
9281
|
+
};
|
|
9282
|
+
visit(arg);
|
|
9283
|
+
let out = "";
|
|
9284
|
+
let at = arg.start;
|
|
9285
|
+
for (const edit of edits.sort((a, b) => a.start - b.start)) {
|
|
9286
|
+
if (edit.start < at) continue;
|
|
9287
|
+
out += code.slice(at, edit.start) + edit.text;
|
|
9288
|
+
at = edit.end;
|
|
9289
|
+
}
|
|
9290
|
+
return out + code.slice(at, arg.end);
|
|
9291
|
+
}
|
|
9292
|
+
function label(source) {
|
|
9293
|
+
const collapsed = source.replace(/\s+/g, " ").trim();
|
|
9294
|
+
return collapsed.length > LABEL_MAX ? `${collapsed.slice(0, 79)}…` : collapsed;
|
|
9295
|
+
}
|
|
9296
|
+
/**
|
|
9297
|
+
* Rewrite the awaits in one module. Returns null when nothing changed.
|
|
9298
|
+
* Exported for tests; `relPath` is the location prefix shown in the pill.
|
|
9299
|
+
*/
|
|
9300
|
+
function instrumentAwaits(code, relPath) {
|
|
9301
|
+
if (!code.includes("await")) return null;
|
|
9302
|
+
let parsed;
|
|
9303
|
+
try {
|
|
9304
|
+
parsed = parseAst(code, { lang: "jsx" });
|
|
9305
|
+
} catch {
|
|
9306
|
+
return null;
|
|
9307
|
+
}
|
|
9308
|
+
if (!isNode(parsed)) return null;
|
|
9309
|
+
const program = parsed;
|
|
9310
|
+
const prologue = directives(program);
|
|
9311
|
+
if (prologue.names.includes("use client")) return null;
|
|
9312
|
+
const lineStarts = [0];
|
|
9313
|
+
for (let i = 0; i < code.length; i++) if (code[i] === "\n") lineStarts.push(i + 1);
|
|
9314
|
+
const lineOf = (offset) => {
|
|
9315
|
+
let lo = 0;
|
|
9316
|
+
let hi = lineStarts.length - 1;
|
|
9317
|
+
while (lo < hi) {
|
|
9318
|
+
const mid = lo + hi + 1 >> 1;
|
|
9319
|
+
if (lineStarts[mid] <= offset) lo = mid;
|
|
9320
|
+
else hi = mid - 1;
|
|
9321
|
+
}
|
|
9322
|
+
return lo + 1;
|
|
9323
|
+
};
|
|
9324
|
+
const s = new MagicString(code);
|
|
9325
|
+
let count = 0;
|
|
9326
|
+
const visit = (node, inFunction) => {
|
|
9327
|
+
const nowInFunction = inFunction || FUNCTION_TYPES.has(node.type);
|
|
9328
|
+
for (const child of children(node)) visit(child, nowInFunction);
|
|
9329
|
+
if (node.type !== "AwaitExpression" || !nowInFunction) return;
|
|
9330
|
+
const arg = node.argument;
|
|
9331
|
+
if (!isNode(arg) || arg.type === "Literal" || containsYield(arg)) return;
|
|
9332
|
+
if (arg.type === "ImportExpression") return;
|
|
9333
|
+
const text = JSON.stringify(label(redactedSource(code, arg)));
|
|
9334
|
+
const location = JSON.stringify(`${relPath}:${lineOf(node.start)}`);
|
|
9335
|
+
s.prependRight(arg.start, `${HELPER}(async () => (`);
|
|
9336
|
+
s.appendLeft(arg.end, `), ${text}, ${location})`);
|
|
9337
|
+
count++;
|
|
9338
|
+
};
|
|
9339
|
+
visit(program, false);
|
|
9340
|
+
if (count === 0) return null;
|
|
9341
|
+
const helper = `\nconst ${HELPER} = (f, l, c) => (globalThis[Symbol.for("timber.dev.await")] ?? ((g) => g()))(f, l, c);\n`;
|
|
9342
|
+
s.appendLeft(prologue.end, helper);
|
|
9343
|
+
return {
|
|
9344
|
+
code: s.toString(),
|
|
9345
|
+
map: s.generateMap({ hires: true })
|
|
9346
|
+
};
|
|
9347
|
+
}
|
|
9348
|
+
/** Directory of the nearest package.json above this file: timber itself. */
|
|
9349
|
+
function findTimberRoot() {
|
|
9350
|
+
let dir = dirname(fileURLToPath(import.meta.url));
|
|
9351
|
+
while (!existsSync(join(dir, "package.json"))) {
|
|
9352
|
+
const parent = dirname(dir);
|
|
9353
|
+
if (parent === dir) break;
|
|
9354
|
+
dir = parent;
|
|
9355
|
+
}
|
|
9356
|
+
return dir;
|
|
9357
|
+
}
|
|
9358
|
+
function timberDevAwait(ctx) {
|
|
9359
|
+
const timberRoot = findTimberRoot();
|
|
9360
|
+
return {
|
|
9361
|
+
name: "timber-dev-await",
|
|
9362
|
+
apply: "serve",
|
|
9363
|
+
applyToEnvironment: (env) => env.name === "rsc",
|
|
9364
|
+
transform(code, id) {
|
|
9365
|
+
if (id.startsWith("\0")) return;
|
|
9366
|
+
const file = id.split("?")[0];
|
|
9367
|
+
if (!SCRIPT_RE.test(file) || file.includes("/node_modules/")) return;
|
|
9368
|
+
if (file.startsWith(`${timberRoot}/`)) return;
|
|
9369
|
+
return instrumentAwaits(code, relative(ctx.root, file)) ?? void 0;
|
|
9370
|
+
}
|
|
9371
|
+
};
|
|
9372
|
+
}
|
|
9101
9373
|
// src/plugins/cloudflare-wasm.ts
|
|
9102
9374
|
/**
|
|
9103
9375
|
* timber-cloudflare-wasm — Handle WASM modules for Cloudflare Workers builds.
|
|
@@ -10309,7 +10581,7 @@ function timber(config) {
|
|
|
10309
10581
|
console: originalConsole
|
|
10310
10582
|
});
|
|
10311
10583
|
ctx.timer.start("client-deps-scan");
|
|
10312
|
-
const { clientOptimizeDepsEntries, skipUseServerScanPlugin } = await import("./_chunks/client-dep-entries-
|
|
10584
|
+
const { clientOptimizeDepsEntries, skipUseServerScanPlugin } = await import("./_chunks/client-dep-entries-C9hv-3k9.js");
|
|
10313
10585
|
const entries = await clientOptimizeDepsEntries(resolvedRoot, BROWSER_ENTRY_FILE, buildDir);
|
|
10314
10586
|
ctx.timer.end("client-deps-scan");
|
|
10315
10587
|
return {
|
|
@@ -10379,6 +10651,7 @@ function timber(config) {
|
|
|
10379
10651
|
report: buildReport.api
|
|
10380
10652
|
}),
|
|
10381
10653
|
timberDevLogs(ctx),
|
|
10654
|
+
timberDevAwait(ctx),
|
|
10382
10655
|
timberDevServer(ctx)
|
|
10383
10656
|
];
|
|
10384
10657
|
}
|