@timber-js/app 0.2.0-alpha.97 → 0.2.0-alpha.99
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/actions-CQ8Z8VGL.js +1061 -0
- package/dist/_chunks/actions-CQ8Z8VGL.js.map +1 -0
- package/dist/_chunks/build-output-helper-DXnW0qjz.js +61 -0
- package/dist/_chunks/build-output-helper-DXnW0qjz.js.map +1 -0
- package/dist/_chunks/{define-Itxvcd7F.js → define-B-Q_UMOD.js} +19 -23
- package/dist/_chunks/define-B-Q_UMOD.js.map +1 -0
- package/dist/_chunks/{define-C77ScO0m.js → define-CfBPoJb0.js} +24 -7
- package/dist/_chunks/define-CfBPoJb0.js.map +1 -0
- package/dist/_chunks/define-cookie-BjpIt4UC.js +194 -0
- package/dist/_chunks/define-cookie-BjpIt4UC.js.map +1 -0
- package/dist/_chunks/{format-CYBGxKtc.js → format-Bcn-Iv1x.js} +1 -1
- package/dist/_chunks/{format-CYBGxKtc.js.map → format-Bcn-Iv1x.js.map} +1 -1
- package/dist/_chunks/handler-store-B-lqaGyh.js +54 -0
- package/dist/_chunks/handler-store-B-lqaGyh.js.map +1 -0
- package/dist/_chunks/logger-0m8MsKdc.js +291 -0
- package/dist/_chunks/logger-0m8MsKdc.js.map +1 -0
- package/dist/_chunks/merge-search-params-BphMdht_.js +122 -0
- package/dist/_chunks/merge-search-params-BphMdht_.js.map +1 -0
- package/dist/_chunks/{metadata-routes-DS3eKNmf.js → metadata-routes-BU684ls2.js} +1 -1
- package/dist/_chunks/{metadata-routes-DS3eKNmf.js.map → metadata-routes-BU684ls2.js.map} +1 -1
- package/dist/_chunks/navigation-root-BCYczjml.js +96 -0
- package/dist/_chunks/navigation-root-BCYczjml.js.map +1 -0
- package/dist/_chunks/registry-I2ss-lvy.js +20 -0
- package/dist/_chunks/registry-I2ss-lvy.js.map +1 -0
- package/dist/_chunks/router-ref-h3-UaCQv.js +28 -0
- package/dist/_chunks/router-ref-h3-UaCQv.js.map +1 -0
- package/dist/_chunks/{schema-bridge-C3xl_vfb.js → schema-bridge-Cxu4l-7p.js} +1 -1
- package/dist/_chunks/{schema-bridge-C3xl_vfb.js.map → schema-bridge-Cxu4l-7p.js.map} +1 -1
- package/dist/_chunks/segment-classify-BjfuctV2.js +137 -0
- package/dist/_chunks/segment-classify-BjfuctV2.js.map +1 -0
- package/dist/_chunks/{segment-context-fHFLF1PE.js → segment-context-Dx_OizxD.js} +1 -1
- package/dist/_chunks/{segment-context-fHFLF1PE.js.map → segment-context-Dx_OizxD.js.map} +1 -1
- package/dist/_chunks/{router-ref-C8OCm7g7.js → ssr-data-B4CdH7rE.js} +2 -26
- package/dist/_chunks/ssr-data-B4CdH7rE.js.map +1 -0
- package/dist/_chunks/{stale-reload-BX5gL1r-.js → stale-reload-Bab885FO.js} +1 -1
- package/dist/_chunks/{stale-reload-BX5gL1r-.js.map → stale-reload-Bab885FO.js.map} +1 -1
- package/dist/_chunks/tracing-C8V-YGsP.js +329 -0
- package/dist/_chunks/tracing-C8V-YGsP.js.map +1 -0
- package/dist/_chunks/{use-query-states-BiV5GJgm.js → use-query-states-B2XTqxDR.js} +3 -19
- package/dist/_chunks/use-query-states-B2XTqxDR.js.map +1 -0
- package/dist/_chunks/{use-params-IOPu7E8t.js → use-segment-params-BkpKAQ7D.js} +9 -95
- package/dist/_chunks/use-segment-params-BkpKAQ7D.js.map +1 -0
- package/dist/_chunks/{interception-BbqMCVXa.js → walkers-Tg0Alwcg.js} +66 -87
- package/dist/_chunks/walkers-Tg0Alwcg.js.map +1 -0
- package/dist/_chunks/{dev-warnings-DpGRGoDi.js → warnings-Cg47l5sk.js} +3 -3
- package/dist/_chunks/warnings-Cg47l5sk.js.map +1 -0
- package/dist/adapters/build-output-helper.d.ts +28 -0
- package/dist/adapters/build-output-helper.d.ts.map +1 -0
- package/dist/adapters/cloudflare.d.ts.map +1 -1
- package/dist/adapters/cloudflare.js +8 -28
- package/dist/adapters/cloudflare.js.map +1 -1
- package/dist/adapters/nitro.d.ts.map +1 -1
- package/dist/adapters/nitro.js +63 -31
- package/dist/adapters/nitro.js.map +1 -1
- package/dist/adapters/shared.d.ts +16 -0
- package/dist/adapters/shared.d.ts.map +1 -0
- package/dist/cache/index.js +9 -2
- package/dist/cache/index.js.map +1 -1
- package/dist/cache/timber-cache.d.ts.map +1 -1
- package/dist/client/error-boundary.js +2 -1
- package/dist/client/error-boundary.js.map +1 -1
- package/dist/client/form.d.ts +10 -24
- package/dist/client/form.d.ts.map +1 -1
- package/dist/client/index.d.ts +1 -5
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +41 -91
- package/dist/client/index.js.map +1 -1
- package/dist/client/internal.d.ts +2 -1
- package/dist/client/internal.d.ts.map +1 -1
- package/dist/client/internal.js +81 -7
- package/dist/client/internal.js.map +1 -1
- package/dist/client/rsc-fetch.d.ts.map +1 -1
- package/dist/client/state.d.ts +1 -1
- package/dist/client/use-cookie.d.ts +8 -0
- package/dist/client/use-cookie.d.ts.map +1 -1
- package/dist/client/{use-params.d.ts → use-segment-params.d.ts} +1 -1
- package/dist/client/use-segment-params.d.ts.map +1 -0
- package/dist/codec.d.ts +1 -1
- package/dist/codec.d.ts.map +1 -1
- package/dist/codec.js +2 -2
- package/dist/config-types.d.ts +28 -0
- package/dist/config-types.d.ts.map +1 -1
- package/dist/cookies/define-cookie.d.ts +87 -35
- package/dist/cookies/define-cookie.d.ts.map +1 -1
- package/dist/cookies/index.d.ts +2 -1
- package/dist/cookies/index.d.ts.map +1 -1
- package/dist/cookies/index.js +48 -2
- package/dist/cookies/index.js.map +1 -0
- package/dist/cookies/json-cookie.d.ts +64 -0
- package/dist/cookies/json-cookie.d.ts.map +1 -0
- package/dist/cookies/validation.d.ts +46 -0
- package/dist/cookies/validation.d.ts.map +1 -0
- package/dist/{plugins/dev-404-page.d.ts → dev-tools/404-page.d.ts} +9 -19
- package/dist/dev-tools/404-page.d.ts.map +1 -0
- package/dist/{plugins/dev-browser-logs.d.ts → dev-tools/browser-logs.d.ts} +1 -1
- package/dist/dev-tools/browser-logs.d.ts.map +1 -0
- package/dist/{plugins/dev-error-page.d.ts → dev-tools/error-page.d.ts} +2 -2
- package/dist/dev-tools/error-page.d.ts.map +1 -0
- package/dist/{server/dev-holding-server.d.ts → dev-tools/holding-server.d.ts} +5 -3
- package/dist/dev-tools/holding-server.d.ts.map +1 -0
- package/dist/dev-tools/index.d.ts +31 -0
- package/dist/dev-tools/index.d.ts.map +1 -0
- package/dist/{server/dev-span-processor.d.ts → dev-tools/instrumentation.d.ts} +26 -6
- package/dist/dev-tools/instrumentation.d.ts.map +1 -0
- package/dist/{server/dev-logger.d.ts → dev-tools/logger.d.ts} +1 -1
- package/dist/dev-tools/logger.d.ts.map +1 -0
- package/dist/{plugins/dev-logs.d.ts → dev-tools/logs.d.ts} +1 -1
- package/dist/dev-tools/logs.d.ts.map +1 -0
- package/dist/{plugins/dev-error-overlay.d.ts → dev-tools/overlay.d.ts} +3 -12
- package/dist/dev-tools/overlay.d.ts.map +1 -0
- package/dist/dev-tools/stack-classifier.d.ts +34 -0
- package/dist/dev-tools/stack-classifier.d.ts.map +1 -0
- package/dist/{plugins/dev-terminal-error.d.ts → dev-tools/terminal.d.ts} +2 -2
- package/dist/dev-tools/terminal.d.ts.map +1 -0
- package/dist/{server/dev-warnings.d.ts → dev-tools/warnings.d.ts} +1 -1
- package/dist/dev-tools/warnings.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +285 -133
- package/dist/index.js.map +1 -1
- package/dist/plugin-context.d.ts +1 -1
- package/dist/plugin-context.d.ts.map +1 -1
- package/dist/plugins/adapter-build.d.ts.map +1 -1
- package/dist/plugins/build-report.d.ts +6 -4
- package/dist/plugins/build-report.d.ts.map +1 -1
- package/dist/routing/convention-lint.d.ts.map +1 -1
- package/dist/routing/index.d.ts +5 -3
- package/dist/routing/index.d.ts.map +1 -1
- package/dist/routing/index.js +3 -3
- package/dist/routing/scanner.d.ts +1 -10
- package/dist/routing/scanner.d.ts.map +1 -1
- package/dist/routing/segment-classify.d.ts +37 -8
- package/dist/routing/segment-classify.d.ts.map +1 -1
- package/dist/routing/status-file-lint.d.ts.map +1 -1
- package/dist/routing/types.d.ts +63 -23
- package/dist/routing/types.d.ts.map +1 -1
- package/dist/routing/walkers.d.ts +51 -0
- package/dist/routing/walkers.d.ts.map +1 -0
- package/dist/search-params/define.d.ts +25 -7
- package/dist/search-params/define.d.ts.map +1 -1
- package/dist/search-params/index.js +5 -3
- package/dist/search-params/index.js.map +1 -1
- package/dist/search-params/wrappers.d.ts +2 -2
- package/dist/search-params/wrappers.d.ts.map +1 -1
- package/dist/segment-params/define.d.ts +23 -6
- package/dist/segment-params/define.d.ts.map +1 -1
- package/dist/segment-params/index.js +1 -1
- package/dist/server/access-gate.d.ts +4 -3
- package/dist/server/access-gate.d.ts.map +1 -1
- package/dist/server/action-handler.d.ts +15 -6
- package/dist/server/action-handler.d.ts.map +1 -1
- package/dist/server/als-registry.d.ts +5 -5
- package/dist/server/als-registry.d.ts.map +1 -1
- package/dist/server/asset-headers.d.ts +1 -15
- package/dist/server/asset-headers.d.ts.map +1 -1
- package/dist/server/cookie-context.d.ts +170 -0
- package/dist/server/cookie-context.d.ts.map +1 -0
- package/dist/server/cookie-parsing.d.ts +51 -0
- package/dist/server/cookie-parsing.d.ts.map +1 -0
- package/dist/server/deny-boundary.d.ts +90 -0
- package/dist/server/deny-boundary.d.ts.map +1 -0
- package/dist/server/deny-renderer.d.ts.map +1 -1
- package/dist/server/early-hints-sender.d.ts.map +1 -1
- package/dist/server/html-injector-core.d.ts +212 -0
- package/dist/server/html-injector-core.d.ts.map +1 -0
- package/dist/server/html-injectors.d.ts +59 -59
- package/dist/server/html-injectors.d.ts.map +1 -1
- package/dist/server/index.d.ts +5 -4
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +4 -149
- package/dist/server/index.js.map +1 -1
- package/dist/server/internal.d.ts +6 -4
- package/dist/server/internal.d.ts.map +1 -1
- package/dist/server/internal.js +852 -852
- package/dist/server/internal.js.map +1 -1
- package/dist/server/logger.d.ts +14 -0
- package/dist/server/logger.d.ts.map +1 -1
- package/dist/server/middleware-runner.d.ts +17 -0
- package/dist/server/middleware-runner.d.ts.map +1 -1
- package/dist/server/node-stream-transforms.d.ts +46 -49
- package/dist/server/node-stream-transforms.d.ts.map +1 -1
- package/dist/server/param-coercion.d.ts +26 -0
- package/dist/server/param-coercion.d.ts.map +1 -0
- package/dist/server/pipeline-helpers.d.ts +95 -0
- package/dist/server/pipeline-helpers.d.ts.map +1 -0
- package/dist/server/pipeline-outcome.d.ts +49 -0
- package/dist/server/pipeline-outcome.d.ts.map +1 -0
- package/dist/server/pipeline-phases.d.ts +52 -0
- package/dist/server/pipeline-phases.d.ts.map +1 -0
- package/dist/server/pipeline.d.ts +51 -32
- package/dist/server/pipeline.d.ts.map +1 -1
- package/dist/server/port-resolution.d.ts +117 -0
- package/dist/server/port-resolution.d.ts.map +1 -0
- package/dist/server/request-context.d.ts +22 -159
- package/dist/server/request-context.d.ts.map +1 -1
- package/dist/server/route-element-builder.d.ts.map +1 -1
- package/dist/server/route-matcher.d.ts +20 -47
- package/dist/server/route-matcher.d.ts.map +1 -1
- package/dist/server/rsc-entry/action-middleware-runner.d.ts +66 -0
- package/dist/server/rsc-entry/action-middleware-runner.d.ts.map +1 -0
- package/dist/server/rsc-entry/helpers.d.ts +1 -1
- package/dist/server/rsc-entry/helpers.d.ts.map +1 -1
- package/dist/server/rsc-entry/index.d.ts.map +1 -1
- package/dist/server/rsc-entry/render-route.d.ts +50 -0
- package/dist/server/rsc-entry/render-route.d.ts.map +1 -0
- package/dist/server/rsc-entry/wrap-action-dispatch.d.ts +119 -0
- package/dist/server/rsc-entry/wrap-action-dispatch.d.ts.map +1 -0
- package/dist/server/state-tree-diff.d.ts.map +1 -1
- package/dist/server/status-code-resolver.d.ts +16 -11
- package/dist/server/status-code-resolver.d.ts.map +1 -1
- package/dist/server/tracing.d.ts +1 -1
- package/dist/server/tracing.d.ts.map +1 -1
- package/dist/server/tree-builder.d.ts +45 -16
- package/dist/server/tree-builder.d.ts.map +1 -1
- package/dist/server/types.d.ts +48 -0
- package/dist/server/types.d.ts.map +1 -1
- package/dist/server/utils/escape-html.d.ts +14 -0
- package/dist/server/utils/escape-html.d.ts.map +1 -0
- package/dist/shims/headers.d.ts +2 -2
- package/dist/shims/headers.d.ts.map +1 -1
- package/dist/shims/navigation-client.d.ts +3 -1
- package/dist/shims/navigation-client.d.ts.map +1 -1
- package/dist/shims/navigation.d.ts +9 -4
- package/dist/shims/navigation.d.ts.map +1 -1
- package/dist/utils/directive-parser.d.ts +0 -45
- package/dist/utils/directive-parser.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/adapters/build-output-helper.ts +77 -0
- package/src/adapters/cloudflare.ts +10 -50
- package/src/adapters/nitro.ts +66 -50
- package/src/adapters/shared.ts +40 -0
- package/src/cache/timber-cache.ts +3 -2
- package/src/client/form.tsx +17 -25
- package/src/client/index.ts +16 -9
- package/src/client/internal.ts +3 -2
- package/src/client/router.ts +1 -1
- package/src/client/rsc-fetch.ts +15 -0
- package/src/client/state.ts +2 -2
- package/src/client/use-cookie.ts +29 -0
- package/src/codec.ts +3 -7
- package/src/config-types.ts +28 -0
- package/src/cookies/define-cookie.ts +271 -78
- package/src/cookies/index.ts +11 -8
- package/src/cookies/json-cookie.ts +105 -0
- package/src/cookies/validation.ts +134 -0
- package/src/{plugins/dev-404-page.ts → dev-tools/404-page.ts} +17 -48
- package/src/{plugins/dev-error-page.ts → dev-tools/error-page.ts} +5 -32
- package/src/{server/dev-holding-server.ts → dev-tools/holding-server.ts} +4 -2
- package/src/dev-tools/index.ts +90 -0
- package/src/dev-tools/instrumentation.ts +176 -0
- package/src/{plugins/dev-logs.ts → dev-tools/logs.ts} +2 -2
- package/src/{plugins/dev-error-overlay.ts → dev-tools/overlay.ts} +5 -23
- package/src/dev-tools/stack-classifier.ts +75 -0
- package/src/{plugins/dev-terminal-error.ts → dev-tools/terminal.ts} +4 -38
- package/src/{server/dev-warnings.ts → dev-tools/warnings.ts} +1 -1
- package/src/index.ts +95 -34
- package/src/plugin-context.ts +1 -1
- package/src/plugins/adapter-build.ts +3 -1
- package/src/plugins/build-report.ts +13 -22
- package/src/plugins/dev-server.ts +3 -3
- package/src/plugins/routing.ts +14 -12
- package/src/plugins/shims.ts +1 -1
- package/src/plugins/static-build.ts +1 -1
- package/src/routing/codegen.ts +1 -1
- package/src/routing/convention-lint.ts +9 -8
- package/src/routing/index.ts +5 -3
- package/src/routing/interception.ts +1 -1
- package/src/routing/scanner.ts +22 -95
- package/src/routing/segment-classify.ts +107 -8
- package/src/routing/status-file-lint.ts +7 -5
- package/src/routing/types.ts +63 -23
- package/src/routing/walkers.ts +90 -0
- package/src/search-params/define.ts +71 -15
- package/src/search-params/wrappers.ts +9 -2
- package/src/segment-params/define.ts +66 -13
- package/src/server/access-gate.tsx +9 -8
- package/src/server/action-handler.ts +34 -38
- package/src/server/als-registry.ts +5 -5
- package/src/server/asset-headers.ts +8 -34
- package/src/server/cookie-context.ts +468 -0
- package/src/server/cookie-parsing.ts +135 -0
- package/src/server/{deny-page-resolver.ts → deny-boundary.ts} +78 -14
- package/src/server/deny-renderer.ts +7 -12
- package/src/server/early-hints-sender.ts +3 -2
- package/src/server/fallback-error.ts +2 -2
- package/src/server/html-injector-core.ts +403 -0
- package/src/server/html-injectors.ts +158 -297
- package/src/server/index.ts +13 -14
- package/src/server/internal.ts +10 -3
- package/src/server/logger.ts +23 -0
- package/src/server/middleware-runner.ts +44 -0
- package/src/server/node-stream-transforms.ts +108 -248
- package/src/server/param-coercion.ts +76 -0
- package/src/server/pipeline-helpers.ts +204 -0
- package/src/server/pipeline-outcome.ts +167 -0
- package/src/server/pipeline-phases.ts +409 -0
- package/src/server/pipeline.ts +70 -540
- package/src/server/port-resolution.ts +215 -0
- package/src/server/request-context.ts +46 -451
- package/src/server/route-element-builder.ts +8 -4
- package/src/server/route-matcher.ts +28 -60
- package/src/server/rsc-entry/action-middleware-runner.ts +167 -0
- package/src/server/rsc-entry/api-handler.ts +2 -2
- package/src/server/rsc-entry/error-renderer.ts +2 -2
- package/src/server/rsc-entry/helpers.ts +2 -7
- package/src/server/rsc-entry/index.ts +81 -366
- package/src/server/rsc-entry/render-route.ts +304 -0
- package/src/server/rsc-entry/rsc-payload.ts +1 -1
- package/src/server/rsc-entry/ssr-renderer.ts +2 -2
- package/src/server/rsc-entry/wrap-action-dispatch.ts +449 -0
- package/src/server/sitemap-generator.ts +1 -1
- package/src/server/slot-resolver.ts +1 -1
- package/src/server/ssr-entry.ts +1 -1
- package/src/server/state-tree-diff.ts +4 -1
- package/src/server/status-code-resolver.ts +112 -128
- package/src/server/tracing.ts +3 -3
- package/src/server/tree-builder.ts +134 -56
- package/src/server/types.ts +52 -0
- package/src/server/utils/escape-html.ts +20 -0
- package/src/shims/headers.ts +3 -3
- package/src/shims/navigation-client.ts +4 -3
- package/src/shims/navigation.ts +9 -7
- package/src/utils/directive-parser.ts +0 -392
- package/dist/_chunks/actions-DLnUaR65.js +0 -421
- package/dist/_chunks/actions-DLnUaR65.js.map +0 -1
- package/dist/_chunks/als-registry-HS0LGUl2.js +0 -41
- package/dist/_chunks/als-registry-HS0LGUl2.js.map +0 -1
- package/dist/_chunks/debug-ECi_61pb.js +0 -108
- package/dist/_chunks/debug-ECi_61pb.js.map +0 -1
- package/dist/_chunks/define-C77ScO0m.js.map +0 -1
- package/dist/_chunks/define-Itxvcd7F.js.map +0 -1
- package/dist/_chunks/define-cookie-BowvzoP0.js +0 -94
- package/dist/_chunks/define-cookie-BowvzoP0.js.map +0 -1
- package/dist/_chunks/dev-warnings-DpGRGoDi.js.map +0 -1
- package/dist/_chunks/interception-BbqMCVXa.js.map +0 -1
- package/dist/_chunks/merge-search-params-Cm_KIWDX.js +0 -41
- package/dist/_chunks/merge-search-params-Cm_KIWDX.js.map +0 -1
- package/dist/_chunks/request-context-CK5tZqIP.js +0 -478
- package/dist/_chunks/request-context-CK5tZqIP.js.map +0 -1
- package/dist/_chunks/router-ref-C8OCm7g7.js.map +0 -1
- package/dist/_chunks/segment-classify-BDNn6EzD.js +0 -65
- package/dist/_chunks/segment-classify-BDNn6EzD.js.map +0 -1
- package/dist/_chunks/tracing-CCYbKn5n.js +0 -238
- package/dist/_chunks/tracing-CCYbKn5n.js.map +0 -1
- package/dist/_chunks/use-params-IOPu7E8t.js.map +0 -1
- package/dist/_chunks/use-query-states-BiV5GJgm.js.map +0 -1
- package/dist/client/use-params.d.ts.map +0 -1
- package/dist/plugins/dev-404-page.d.ts.map +0 -1
- package/dist/plugins/dev-browser-logs.d.ts.map +0 -1
- package/dist/plugins/dev-error-overlay.d.ts.map +0 -1
- package/dist/plugins/dev-error-page.d.ts.map +0 -1
- package/dist/plugins/dev-logs.d.ts.map +0 -1
- package/dist/plugins/dev-terminal-error.d.ts.map +0 -1
- package/dist/server/deny-page-resolver.d.ts +0 -52
- package/dist/server/deny-page-resolver.d.ts.map +0 -1
- package/dist/server/dev-fetch-instrumentation.d.ts +0 -22
- package/dist/server/dev-fetch-instrumentation.d.ts.map +0 -1
- package/dist/server/dev-holding-server.d.ts.map +0 -1
- package/dist/server/dev-logger.d.ts.map +0 -1
- package/dist/server/dev-span-processor.d.ts.map +0 -1
- package/dist/server/dev-warnings.d.ts.map +0 -1
- package/dist/server/manifest-status-resolver.d.ts +0 -58
- package/dist/server/manifest-status-resolver.d.ts.map +0 -1
- package/dist/server/page-deny-boundary.d.ts +0 -31
- package/dist/server/page-deny-boundary.d.ts.map +0 -1
- package/src/server/dev-fetch-instrumentation.ts +0 -96
- package/src/server/dev-span-processor.ts +0 -78
- package/src/server/manifest-status-resolver.ts +0 -215
- package/src/server/page-deny-boundary.tsx +0 -56
- /package/src/client/{use-params.ts → use-segment-params.ts} +0 -0
- /package/src/{plugins/dev-browser-logs.ts → dev-tools/browser-logs.ts} +0 -0
- /package/src/{server/dev-logger.ts → dev-tools/logger.ts} +0 -0
|
@@ -2,53 +2,98 @@
|
|
|
2
2
|
* defineCookie — typed cookie definitions.
|
|
3
3
|
*
|
|
4
4
|
* Bundles name + codec + options into a reusable CookieDefinition<T>
|
|
5
|
-
* with
|
|
6
|
-
* and a
|
|
5
|
+
* with sync .get(), .set(), .delete() isomorphic methods (server + client)
|
|
6
|
+
* and a .useCookie() client hook.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
8
|
+
* Uses the registration pattern: server entry registers serverCookieImpl,
|
|
9
|
+
* client entry registers clientCookieImpl. This avoids top-level value
|
|
10
|
+
* imports from either environment and makes defineCookie isomorphic
|
|
11
|
+
* without `typeof window` checks.
|
|
10
12
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* IMPORTANT: This module must NOT have top-level value imports from either
|
|
15
|
-
* server or client modules. Server methods lazy-import request-context;
|
|
16
|
-
* useCookie() lazy-imports use-cookie. This ensures:
|
|
17
|
-
* - Client bundles don't pull in ALS/server code
|
|
18
|
-
* - RSC bundles don't pull in useSyncExternalStore/client code
|
|
19
|
-
* - Tree-shaking is not required for correctness
|
|
13
|
+
* Standard Schema objects (Zod, Valibot, ArkType) are auto-detected in
|
|
14
|
+
* the codec option — no explicit fromSchema() wrapper needed.
|
|
20
15
|
*
|
|
21
16
|
* See design/29-cookies.md §"Typed Cookies with Schema Validation"
|
|
22
17
|
*/
|
|
23
|
-
import type { CookieOptions } from '../server/
|
|
18
|
+
import type { CookieOptions } from '../server/cookie-context.js';
|
|
19
|
+
import type { ClientCookieOptions } from '../client/use-cookie.js';
|
|
24
20
|
import type { Codec } from '../codec.js';
|
|
21
|
+
import type { StandardSchemaV1 } from '../schema-bridge.js';
|
|
25
22
|
/**
|
|
26
23
|
* A codec that converts between string cookie values and typed values.
|
|
27
24
|
* Type alias for the shared Codec<T> protocol.
|
|
28
25
|
*/
|
|
29
26
|
export type CookieCodec<T> = Codec<T>;
|
|
30
27
|
/** Options for defineCookie: codec + CookieOptions merged. */
|
|
31
|
-
export interface DefineCookieOptions<T> extends CookieOptions {
|
|
32
|
-
/**
|
|
33
|
-
|
|
28
|
+
export interface DefineCookieOptions<T, HttpOnly extends boolean = boolean> extends CookieOptions {
|
|
29
|
+
/**
|
|
30
|
+
* Codec for parsing/serializing the cookie value.
|
|
31
|
+
* Accepts a Codec<T> or a Standard Schema object (Zod, Valibot, ArkType)
|
|
32
|
+
* which is auto-wrapped via fromSchema.
|
|
33
|
+
*/
|
|
34
|
+
codec: CookieCodec<T> | StandardSchemaV1<T>;
|
|
35
|
+
/**
|
|
36
|
+
* Prevent client-side JS access. Default: true.
|
|
37
|
+
* When true (or omitted), client methods (useCookie, get/set/delete on
|
|
38
|
+
* client) are omitted from the return type and throw at runtime.
|
|
39
|
+
*/
|
|
40
|
+
httpOnly?: HttpOnly;
|
|
34
41
|
}
|
|
35
|
-
/**
|
|
36
|
-
|
|
37
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Server-only cookie definition. Returned when httpOnly is true or omitted.
|
|
44
|
+
* Client methods are absent from the type — accessing them is a TS error.
|
|
45
|
+
*/
|
|
46
|
+
export interface ServerOnlyCookieDefinition<T> {
|
|
38
47
|
readonly name: string;
|
|
39
|
-
/** The resolved cookie options (without codec). */
|
|
40
48
|
readonly options: CookieOptions;
|
|
41
|
-
/** The codec used for parsing/serializing. */
|
|
42
49
|
readonly codec: CookieCodec<T>;
|
|
43
|
-
/**
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
|
|
50
|
+
/** Read the typed value. Sync, isomorphic (server + client). */
|
|
51
|
+
get(): T;
|
|
52
|
+
/** Set the typed value. Sync, isomorphic (server + client). */
|
|
53
|
+
set(value: T): void;
|
|
54
|
+
/** Delete the cookie. Sync, isomorphic (server + client). */
|
|
55
|
+
delete(): void;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Full cookie definition with client methods. Returned when httpOnly: false.
|
|
59
|
+
*/
|
|
60
|
+
export interface CookieDefinition<T> extends ServerOnlyCookieDefinition<T> {
|
|
49
61
|
/** Client: React hook for reading/writing this cookie. Returns [value, setter, deleter]. */
|
|
50
62
|
useCookie(): [T, (value: T) => void, () => void];
|
|
51
63
|
}
|
|
64
|
+
/** Server-side cookie impl: reads from ALS-backed cookie jar. */
|
|
65
|
+
export interface ServerCookieImpl {
|
|
66
|
+
getCookieJar(): {
|
|
67
|
+
get(name: string): string | undefined;
|
|
68
|
+
set(name: string, value: string, options?: CookieOptions): void;
|
|
69
|
+
delete(name: string, options?: Pick<CookieOptions, 'path' | 'domain'>): void;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/** Client-side cookie impl: reads/writes document.cookie via useCookie hook. */
|
|
73
|
+
export interface ClientCookieImpl {
|
|
74
|
+
useCookie(name: string, options?: ClientCookieOptions): [string | undefined, (value: string, options?: ClientCookieOptions) => void, () => void];
|
|
75
|
+
getCookieValue(name: string): string | undefined;
|
|
76
|
+
setCookieValue(name: string, value: string, options?: ClientCookieOptions): void;
|
|
77
|
+
deleteCookieValue(name: string, options?: ClientCookieOptions): void;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Register the server-side cookie implementation.
|
|
81
|
+
* Called by server entry at module load time.
|
|
82
|
+
* @internal
|
|
83
|
+
*/
|
|
84
|
+
export declare function _registerServerCookieImpl(impl: ServerCookieImpl): void;
|
|
85
|
+
/**
|
|
86
|
+
* Register the client-side cookie implementation.
|
|
87
|
+
* Called by client entry at module load time.
|
|
88
|
+
* @internal
|
|
89
|
+
*/
|
|
90
|
+
export declare function _registerClientCookieImpl(impl: ClientCookieImpl): void;
|
|
91
|
+
/**
|
|
92
|
+
* Register the fromSchema bridge function.
|
|
93
|
+
* Called by server/client entry at module load time.
|
|
94
|
+
* @internal
|
|
95
|
+
*/
|
|
96
|
+
export declare function _registerFromSchema(fn: (schema: StandardSchemaV1<unknown>) => CookieCodec<unknown>): void;
|
|
52
97
|
/**
|
|
53
98
|
* Register the client cookie module. Called by the client entry to wire
|
|
54
99
|
* up the lazy reference without a top-level import.
|
|
@@ -61,22 +106,29 @@ export declare function _registerUseCookieModule(mod: typeof import('../client/u
|
|
|
61
106
|
*
|
|
62
107
|
* ```ts
|
|
63
108
|
* import { defineCookie } from '@timber-js/app/cookies';
|
|
64
|
-
* import { fromSchema } from '@timber-js/app/codec';
|
|
65
109
|
* import { z } from 'zod/v4';
|
|
66
110
|
*
|
|
111
|
+
* // httpOnly: false — client methods available
|
|
67
112
|
* export const themeCookie = defineCookie('theme', {
|
|
68
|
-
* codec:
|
|
113
|
+
* codec: z.enum(['light', 'dark', 'system']).default('system'),
|
|
69
114
|
* httpOnly: false,
|
|
70
115
|
* maxAge: 60 * 60 * 24 * 365,
|
|
71
116
|
* });
|
|
72
117
|
*
|
|
73
|
-
* // Server
|
|
74
|
-
* const theme =
|
|
75
|
-
*
|
|
118
|
+
* // Server or client
|
|
119
|
+
* const theme = themeCookie.get();
|
|
120
|
+
* themeCookie.set('dark');
|
|
76
121
|
*
|
|
77
|
-
* // Client
|
|
122
|
+
* // Client hook
|
|
78
123
|
* const [theme, setTheme] = themeCookie.useCookie();
|
|
124
|
+
*
|
|
125
|
+
* // httpOnly: true (default) — server-only, no client methods
|
|
126
|
+
* export const sessionCookie = defineCookie('session', {
|
|
127
|
+
* codec: z.string(),
|
|
128
|
+
* });
|
|
129
|
+
* sessionCookie.get(); // works on server
|
|
130
|
+
* sessionCookie.useCookie(); // TS error — httpOnly cookie
|
|
79
131
|
* ```
|
|
80
132
|
*/
|
|
81
|
-
export declare function defineCookie<T>(name: string, options: DefineCookieOptions<T>): CookieDefinition<T>;
|
|
133
|
+
export declare function defineCookie<T, HttpOnly extends boolean = true>(name: string, options: DefineCookieOptions<T, HttpOnly>): HttpOnly extends false ? CookieDefinition<T> : ServerOnlyCookieDefinition<T>;
|
|
82
134
|
//# sourceMappingURL=define-cookie.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define-cookie.d.ts","sourceRoot":"","sources":["../../src/cookies/define-cookie.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"define-cookie.d.ts","sourceRoot":"","sources":["../../src/cookies/define-cookie.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAInE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D;;;GAGG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC;AAEtC,8DAA8D;AAC9D,MAAM,WAAW,mBAAmB,CAAC,CAAC,EAAE,QAAQ,SAAS,OAAO,GAAG,OAAO,CAAE,SAAQ,aAAa;IAC/F;;;;OAIG;IACH,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAC5C;;;;OAIG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,0BAA0B,CAAC,CAAC;IAC3C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IAE/B,gEAAgE;IAChE,GAAG,IAAI,CAAC,CAAC;IACT,+DAA+D;IAC/D,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IACpB,6DAA6D;IAC7D,MAAM,IAAI,IAAI,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB,CAAC,CAAC,CAAE,SAAQ,0BAA0B,CAAC,CAAC,CAAC;IACxE,4FAA4F;IAC5F,SAAS,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,EAAE,MAAM,IAAI,CAAC,CAAC;CAClD;AAQD,iEAAiE;AACjE,MAAM,WAAW,gBAAgB;IAC/B,YAAY,IAAI;QACd,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;QACtC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC;QAChE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,QAAQ,CAAC,GAAG,IAAI,CAAC;KAC9E,CAAC;CACH;AAED,gFAAgF;AAChF,MAAM,WAAW,gBAAgB;IAC/B,SAAS,CACP,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,mBAAmB,GAC5B,CAAC,MAAM,GAAG,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,KAAK,IAAI,EAAE,MAAM,IAAI,CAAC,CAAC;IAC5F,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACjD,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACjF,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,IAAI,CAAC;CACtE;AAMD;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,CAEtE;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,CAEtE;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,EAAE,EAAE,CAAC,MAAM,EAAE,gBAAgB,CAAC,OAAO,CAAC,KAAK,WAAW,CAAC,OAAO,CAAC,GAC9D,IAAI,CAEN;AAeD;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,cAAc,yBAAyB,CAAC,GAAG,IAAI,CAmC5F;AAiCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,QAAQ,SAAS,OAAO,GAAG,IAAI,EAC7D,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,mBAAmB,CAAC,CAAC,EAAE,QAAQ,CAAC,GACxC,QAAQ,SAAS,KAAK,GAAG,gBAAgB,CAAC,CAAC,CAAC,GAAG,0BAA0B,CAAC,CAAC,CAAC,CAmI9E"}
|
package/dist/cookies/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { defineCookie } from './define-cookie.js';
|
|
2
|
-
export type { CookieDefinition, CookieCodec, DefineCookieOptions } from './define-cookie.js';
|
|
2
|
+
export type { CookieDefinition, ServerOnlyCookieDefinition, CookieCodec, DefineCookieOptions, } from './define-cookie.js';
|
|
3
|
+
export { jsonCookieCodec } from './json-cookie.js';
|
|
3
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cookies/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cookies/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,YAAY,EACV,gBAAgB,EAChB,0BAA0B,EAC1B,WAAW,EACX,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAM5B,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/cookies/index.js
CHANGED
|
@@ -1,2 +1,48 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { i as defineCookie } from "../_chunks/define-cookie-BjpIt4UC.js";
|
|
2
|
+
//#region src/cookies/json-cookie.ts
|
|
3
|
+
/**
|
|
4
|
+
* Build a CookieCodec that JSON-encodes the value. The framework's
|
|
5
|
+
* cookie write path then URL-encodes the JSON string into a valid
|
|
6
|
+
* `cookie-octet` form, and the read path reverses both transforms.
|
|
7
|
+
*
|
|
8
|
+
* @param defaultValue - Returned by `parse` when the cookie is missing
|
|
9
|
+
* or the stored value cannot be JSON-parsed. Optional — if omitted,
|
|
10
|
+
* `parse` returns `undefined` on missing/malformed input.
|
|
11
|
+
*
|
|
12
|
+
* The default is **deep-cloned** on every fallback return via
|
|
13
|
+
* `structuredClone`, so mutating the parsed result in one request
|
|
14
|
+
* cannot leak into later requests that fall back to the same
|
|
15
|
+
* default. This matters for long-lived server processes where a
|
|
16
|
+
* codec is defined once at module load and shared across all
|
|
17
|
+
* requests — without the clone, a user doing
|
|
18
|
+
* `const prefs = prefsCookie.get(); prefs.lang = 'fr'` on a missing
|
|
19
|
+
* cookie would mutate the module-level default and poison every
|
|
20
|
+
* later fallback. See the "shared mutable default" regression test
|
|
21
|
+
* in `tests/define-cookie.test.ts`.
|
|
22
|
+
*/
|
|
23
|
+
function jsonCookieCodec(defaultValue) {
|
|
24
|
+
const cloneDefault = () => {
|
|
25
|
+
if (defaultValue === void 0 || defaultValue === null) return defaultValue;
|
|
26
|
+
return structuredClone(defaultValue);
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
parse(value) {
|
|
30
|
+
if (value === void 0 || value === "") return cloneDefault();
|
|
31
|
+
const raw = Array.isArray(value) ? value[value.length - 1] : value;
|
|
32
|
+
if (raw === void 0 || raw === "") return cloneDefault();
|
|
33
|
+
try {
|
|
34
|
+
return JSON.parse(raw);
|
|
35
|
+
} catch {
|
|
36
|
+
return cloneDefault();
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
serialize(value) {
|
|
40
|
+
if (value === null || value === void 0) return null;
|
|
41
|
+
return JSON.stringify(value);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
export { defineCookie, jsonCookieCodec };
|
|
47
|
+
|
|
48
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/cookies/json-cookie.ts"],"sourcesContent":["/**\n * jsonCookieCodec — Codec helper for storing JSON-serializable values in\n * cookies.\n *\n * The codec is intentionally minimal: `JSON.stringify` on serialize,\n * `JSON.parse` on parse. The framework handles the URL encoding /\n * decoding around it (see design/29-cookies.md §\"Encoding Contract\"):\n *\n * defineCookie.setCookie(value)\n * → codec.serialize: JSON.stringify → '{\"a\":1}'\n * → cookies().set: encodeURIComponent → '%7B%22a%22%3A1%7D'\n * → wire: Set-Cookie: prefs=%7B%22a%22%3A1%7D\n *\n * defineCookie.getCookie()\n * → wire: Cookie: prefs=%7B%22a%22%3A1%7D\n * → parseCookieHeader: decodeURIComponent → '{\"a\":1}'\n * → codec.parse: JSON.parse → { a: 1 }\n *\n * The same chain works on the client: `useCookie` auto-encodes on writes\n * and auto-decodes on reads, so `jsonCookieCodec` composes with both the\n * server `defineCookie` methods and the client `useCookie` hook with no\n * environment-specific branches.\n *\n * Parsing is total: any non-JSON value (or `undefined`) returns the\n * supplied default. This matches the \"never crash on user-controlled\n * cookie input\" semantics that `fromSchema` uses for typed search params.\n *\n * ```ts\n * import { defineCookie, jsonCookieCodec } from '@timber-js/app/cookies';\n *\n * interface Prefs { lang: string; fontSize: number }\n *\n * export const prefsCookie = defineCookie('prefs', {\n * codec: jsonCookieCodec<Prefs>({ lang: 'en', fontSize: 16 }),\n * httpOnly: false,\n * maxAge: 60 * 60 * 24 * 365,\n * });\n *\n * await prefsCookie.setCookie({ lang: 'fr', fontSize: 18 });\n * ```\n */\n\nimport type { Codec } from '../codec.js';\n\n/**\n * Build a CookieCodec that JSON-encodes the value. The framework's\n * cookie write path then URL-encodes the JSON string into a valid\n * `cookie-octet` form, and the read path reverses both transforms.\n *\n * @param defaultValue - Returned by `parse` when the cookie is missing\n * or the stored value cannot be JSON-parsed. Optional — if omitted,\n * `parse` returns `undefined` on missing/malformed input.\n *\n * The default is **deep-cloned** on every fallback return via\n * `structuredClone`, so mutating the parsed result in one request\n * cannot leak into later requests that fall back to the same\n * default. This matters for long-lived server processes where a\n * codec is defined once at module load and shared across all\n * requests — without the clone, a user doing\n * `const prefs = prefsCookie.get(); prefs.lang = 'fr'` on a missing\n * cookie would mutate the module-level default and poison every\n * later fallback. See the \"shared mutable default\" regression test\n * in `tests/define-cookie.test.ts`.\n */\nexport function jsonCookieCodec<T>(defaultValue?: T): Codec<T> {\n // Resolve the fallback at call time, not capture time, so every\n // fallback return produces a fresh deep copy. structuredClone handles\n // nested objects, arrays, dates, maps, sets — everything\n // JSON-serializable plus more. For primitives and undefined,\n // structuredClone is effectively a no-op.\n const cloneDefault = (): T => {\n if (defaultValue === undefined || defaultValue === null) {\n return defaultValue as T;\n }\n // structuredClone is a Node built-in since Node 17, available in\n // all supported runtimes.\n return structuredClone(defaultValue);\n };\n\n return {\n parse(value: string | string[] | undefined): T {\n if (value === undefined || value === '') {\n return cloneDefault();\n }\n // Cookies are single-valued by name; defensively pick the last\n // entry if a Codec consumer somehow passes an array.\n const raw = Array.isArray(value) ? value[value.length - 1] : value;\n if (raw === undefined || raw === '') {\n return cloneDefault();\n }\n try {\n return JSON.parse(raw) as T;\n } catch {\n return cloneDefault();\n }\n },\n\n serialize(value: T): string | null {\n if (value === null || value === undefined) {\n return null;\n }\n return JSON.stringify(value);\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAgEA,SAAgB,gBAAmB,cAA4B;CAM7D,MAAM,qBAAwB;AAC5B,MAAI,iBAAiB,KAAA,KAAa,iBAAiB,KACjD,QAAO;AAIT,SAAO,gBAAgB,aAAa;;AAGtC,QAAO;EACL,MAAM,OAAyC;AAC7C,OAAI,UAAU,KAAA,KAAa,UAAU,GACnC,QAAO,cAAc;GAIvB,MAAM,MAAM,MAAM,QAAQ,MAAM,GAAG,MAAM,MAAM,SAAS,KAAK;AAC7D,OAAI,QAAQ,KAAA,KAAa,QAAQ,GAC/B,QAAO,cAAc;AAEvB,OAAI;AACF,WAAO,KAAK,MAAM,IAAI;WAChB;AACN,WAAO,cAAc;;;EAIzB,UAAU,OAAyB;AACjC,OAAI,UAAU,QAAQ,UAAU,KAAA,EAC9B,QAAO;AAET,UAAO,KAAK,UAAU,MAAM;;EAE/B"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* jsonCookieCodec — Codec helper for storing JSON-serializable values in
|
|
3
|
+
* cookies.
|
|
4
|
+
*
|
|
5
|
+
* The codec is intentionally minimal: `JSON.stringify` on serialize,
|
|
6
|
+
* `JSON.parse` on parse. The framework handles the URL encoding /
|
|
7
|
+
* decoding around it (see design/29-cookies.md §"Encoding Contract"):
|
|
8
|
+
*
|
|
9
|
+
* defineCookie.setCookie(value)
|
|
10
|
+
* → codec.serialize: JSON.stringify → '{"a":1}'
|
|
11
|
+
* → cookies().set: encodeURIComponent → '%7B%22a%22%3A1%7D'
|
|
12
|
+
* → wire: Set-Cookie: prefs=%7B%22a%22%3A1%7D
|
|
13
|
+
*
|
|
14
|
+
* defineCookie.getCookie()
|
|
15
|
+
* → wire: Cookie: prefs=%7B%22a%22%3A1%7D
|
|
16
|
+
* → parseCookieHeader: decodeURIComponent → '{"a":1}'
|
|
17
|
+
* → codec.parse: JSON.parse → { a: 1 }
|
|
18
|
+
*
|
|
19
|
+
* The same chain works on the client: `useCookie` auto-encodes on writes
|
|
20
|
+
* and auto-decodes on reads, so `jsonCookieCodec` composes with both the
|
|
21
|
+
* server `defineCookie` methods and the client `useCookie` hook with no
|
|
22
|
+
* environment-specific branches.
|
|
23
|
+
*
|
|
24
|
+
* Parsing is total: any non-JSON value (or `undefined`) returns the
|
|
25
|
+
* supplied default. This matches the "never crash on user-controlled
|
|
26
|
+
* cookie input" semantics that `fromSchema` uses for typed search params.
|
|
27
|
+
*
|
|
28
|
+
* ```ts
|
|
29
|
+
* import { defineCookie, jsonCookieCodec } from '@timber-js/app/cookies';
|
|
30
|
+
*
|
|
31
|
+
* interface Prefs { lang: string; fontSize: number }
|
|
32
|
+
*
|
|
33
|
+
* export const prefsCookie = defineCookie('prefs', {
|
|
34
|
+
* codec: jsonCookieCodec<Prefs>({ lang: 'en', fontSize: 16 }),
|
|
35
|
+
* httpOnly: false,
|
|
36
|
+
* maxAge: 60 * 60 * 24 * 365,
|
|
37
|
+
* });
|
|
38
|
+
*
|
|
39
|
+
* await prefsCookie.setCookie({ lang: 'fr', fontSize: 18 });
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
import type { Codec } from '../codec.js';
|
|
43
|
+
/**
|
|
44
|
+
* Build a CookieCodec that JSON-encodes the value. The framework's
|
|
45
|
+
* cookie write path then URL-encodes the JSON string into a valid
|
|
46
|
+
* `cookie-octet` form, and the read path reverses both transforms.
|
|
47
|
+
*
|
|
48
|
+
* @param defaultValue - Returned by `parse` when the cookie is missing
|
|
49
|
+
* or the stored value cannot be JSON-parsed. Optional — if omitted,
|
|
50
|
+
* `parse` returns `undefined` on missing/malformed input.
|
|
51
|
+
*
|
|
52
|
+
* The default is **deep-cloned** on every fallback return via
|
|
53
|
+
* `structuredClone`, so mutating the parsed result in one request
|
|
54
|
+
* cannot leak into later requests that fall back to the same
|
|
55
|
+
* default. This matters for long-lived server processes where a
|
|
56
|
+
* codec is defined once at module load and shared across all
|
|
57
|
+
* requests — without the clone, a user doing
|
|
58
|
+
* `const prefs = prefsCookie.get(); prefs.lang = 'fr'` on a missing
|
|
59
|
+
* cookie would mutate the module-level default and poison every
|
|
60
|
+
* later fallback. See the "shared mutable default" regression test
|
|
61
|
+
* in `tests/define-cookie.test.ts`.
|
|
62
|
+
*/
|
|
63
|
+
export declare function jsonCookieCodec<T>(defaultValue?: T): Codec<T>;
|
|
64
|
+
//# sourceMappingURL=json-cookie.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-cookie.d.ts","sourceRoot":"","sources":["../../src/cookies/json-cookie.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEzC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,YAAY,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAwC7D"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cookie name and value validation per RFC 6265 §4.1.1.
|
|
3
|
+
*
|
|
4
|
+
* This module is pure — no server or client imports — so it can be loaded
|
|
5
|
+
* by both `server/request-context.ts` (which guards `getCookies().set()`)
|
|
6
|
+
* and `client/use-cookie.ts` (which guards `useCookie()`'s setter). The
|
|
7
|
+
* shared validator gives both sides identical encoding contracts:
|
|
8
|
+
* **the framework never silently encodes — callers emit `cookie-octet`
|
|
9
|
+
* bytes or get a developer-facing error.**
|
|
10
|
+
*
|
|
11
|
+
* Why this matters: see ONGOING_SECURITY.md H-3 (TIM-868) and
|
|
12
|
+
* design/29-cookies.md §"Cookie Name and Value Validation".
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Validate a cookie name against RFC 6265 §4.1.1 / RFC 7230 token rules.
|
|
16
|
+
* Throws a developer-facing error naming the offending byte and its index.
|
|
17
|
+
*/
|
|
18
|
+
export declare function assertValidCookieName(name: string): void;
|
|
19
|
+
/**
|
|
20
|
+
* Validate a cookie value against the RFC 6265 §4.1.1 `cookie-value`
|
|
21
|
+
* production:
|
|
22
|
+
*
|
|
23
|
+
* cookie-value = *cookie-octet / ( DQUOTE *cookie-octet DQUOTE )
|
|
24
|
+
* cookie-octet = %x21 / %x23-2B / %x2D-3A / %x3C-5B / %x5D-7E
|
|
25
|
+
*
|
|
26
|
+
* Both the bare `*cookie-octet` form and the DQUOTE-wrapped form are
|
|
27
|
+
* valid. The wrapped form is common in upstream `Set-Cookie` headers
|
|
28
|
+
* (e.g. `sid="abc"; Path=/`) and must be forwardable through
|
|
29
|
+
* `setFromHeaders` verbatim — stripping or rejecting the surrounding
|
|
30
|
+
* quotes would corrupt the on-the-wire bytes and break value semantics
|
|
31
|
+
* for the upstream service.
|
|
32
|
+
*
|
|
33
|
+
* Excluded bytes (in either form): CTL, whitespace (CR/LF/TAB/SP),
|
|
34
|
+
* interior DQUOTE, comma, semicolon, backslash, DEL, and anything
|
|
35
|
+
* non-ASCII. The smuggling primitive (`;`) is rejected regardless of
|
|
36
|
+
* wrapping.
|
|
37
|
+
*
|
|
38
|
+
* Throws a developer-facing error naming the offending byte and its
|
|
39
|
+
* index. Callers passing user-controlled data through the default
|
|
40
|
+
* `set()` path don't need to call this — `set()` auto-encodes via
|
|
41
|
+
* `encodeURIComponent`, whose output is always valid cookie-octet.
|
|
42
|
+
* This validator is for the `{ raw: true }` opt-out and for
|
|
43
|
+
* `setFromHeaders` forwarding.
|
|
44
|
+
*/
|
|
45
|
+
export declare function assertValidCookieValue(name: string, value: string): void;
|
|
46
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/cookies/validation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AA+BH;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAoBxD;AAaD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CA2BxE"}
|
|
@@ -12,33 +12,23 @@
|
|
|
12
12
|
*
|
|
13
13
|
* Design doc: 21-dev-server.md, 07-routing.md
|
|
14
14
|
*/
|
|
15
|
+
import type { SegmentNode } from '../routing/types.js';
|
|
15
16
|
interface RouteInfo {
|
|
16
17
|
/** URL path pattern (e.g., "/dashboard/[id]") */
|
|
17
18
|
path: string;
|
|
18
19
|
/** Whether this is a page route or API route handler */
|
|
19
20
|
type: 'page' | 'route';
|
|
20
21
|
}
|
|
21
|
-
/** Minimal segment node shape — matches ManifestSegmentNode. */
|
|
22
|
-
interface SegmentNode {
|
|
23
|
-
segmentName: string;
|
|
24
|
-
segmentType: string;
|
|
25
|
-
urlPath: string;
|
|
26
|
-
page?: {
|
|
27
|
-
filePath: string;
|
|
28
|
-
};
|
|
29
|
-
route?: {
|
|
30
|
-
filePath: string;
|
|
31
|
-
};
|
|
32
|
-
children: SegmentNode[];
|
|
33
|
-
slots: Record<string, SegmentNode> | Map<string, SegmentNode>;
|
|
34
|
-
}
|
|
35
22
|
/**
|
|
36
|
-
* Collect all routable paths from
|
|
23
|
+
* Collect all routable paths from a route tree (build-time scanner output
|
|
24
|
+
* or runtime route manifest).
|
|
37
25
|
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
26
|
+
* Wraps the shared `collectLeafRoutes` walker (TIM-848). Includes parallel
|
|
27
|
+
* slots so the dev 404 page can list slot pages too — they aren't
|
|
28
|
+
* separately addressable, but they're still useful to know about when
|
|
29
|
+
* debugging a missing route.
|
|
40
30
|
*/
|
|
41
|
-
export declare function collectRoutes(root: SegmentNode): RouteInfo[];
|
|
31
|
+
export declare function collectRoutes<TFile>(root: SegmentNode<TFile>): RouteInfo[];
|
|
42
32
|
/**
|
|
43
33
|
* Find routes similar to the requested path.
|
|
44
34
|
*
|
|
@@ -53,4 +43,4 @@ export declare function findSimilarRoutes(requestedPath: string, routes: RouteIn
|
|
|
53
43
|
*/
|
|
54
44
|
export declare function generateDev404Page(requestedPath: string, routes: RouteInfo[]): string;
|
|
55
45
|
export {};
|
|
56
|
-
//# sourceMappingURL=
|
|
46
|
+
//# sourceMappingURL=404-page.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"404-page.d.ts","sourceRoot":"","sources":["../../src/dev-tools/404-page.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAMvD,UAAU,SAAS;IACjB,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,wDAAwD;IACxD,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAID;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,IAAI,EAAE,WAAW,CAAC,KAAK,CAAC,GAAG,SAAS,EAAE,CAQ1E;AAmCD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,CAezF;AAQD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAiFrF"}
|
|
@@ -81,4 +81,4 @@ export declare function generateClientScript(threshold: BrowserLogLevel | 'none'
|
|
|
81
81
|
* Only active during `vite dev` (apply: 'serve').
|
|
82
82
|
*/
|
|
83
83
|
export declare function timberDevBrowserLogs(ctx: PluginContext): Plugin;
|
|
84
|
-
//# sourceMappingURL=
|
|
84
|
+
//# sourceMappingURL=browser-logs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-logs.d.ts","sourceRoot":"","sources":["../../src/dev-tools/browser-logs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,MAAM,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAI1D,6CAA6C;AAC7C,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AAExD,kEAAkE;AAClE,MAAM,MAAM,oBAAoB,GAAG,eAAe,GAAG,MAAM,GAAG,SAAS,CAAC;AAExE;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,eAAe,CAAC;IACvB,iCAAiC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,6DAA6D;IAC7D,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,gDAAgD;IAChD,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,qDAAqD;IACrD,SAAS,EAAE,MAAM,CAAC;CACnB;AA6BD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAsBnE;AAID;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,eAAe,EACtB,SAAS,EAAE,eAAe,GAAG,MAAM,GAClC,OAAO,CAGT;AAID;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAMzE;AAID;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,eAAe,GAAG,MAAM,GAAG,MAAM,CAgEhF;AAID;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CA6D/D"}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*
|
|
14
14
|
* Design doc: 21-dev-server.md §"Error Overlay"
|
|
15
15
|
*/
|
|
16
|
-
import { type ErrorPhase } from './
|
|
16
|
+
import { type ErrorPhase } from './overlay.js';
|
|
17
17
|
/**
|
|
18
18
|
* HMR connection options for the dev error page auto-reload WebSocket.
|
|
19
19
|
* Derived from Vite's resolved server config so the error page can
|
|
@@ -55,4 +55,4 @@ export declare function extractHmrOptions(config: {
|
|
|
55
55
|
* - Auto-reconnect script that watches for Vite HMR and reloads
|
|
56
56
|
*/
|
|
57
57
|
export declare function generateDevErrorPage(error: Error, phase: ErrorPhase, projectRoot: string, hmrOptions?: DevErrorHmrOptions): string;
|
|
58
|
-
//# sourceMappingURL=
|
|
58
|
+
//# sourceMappingURL=error-page.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-page.d.ts","sourceRoot":"","sources":["../../src/dev-tools/error-page.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAGL,KAAK,UAAU,EAChB,MAAM,cAAc,CAAC;AA8EtB;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAeD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE;IACxC,MAAM,CAAC,EAAE;QAAE,GAAG,CAAC,EAAE;YAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;YAAC,IAAI,CAAC,EAAE,MAAM,CAAC;YAAC,IAAI,CAAC,EAAE,MAAM,CAAC;YAAC,IAAI,CAAC,EAAE,MAAM,CAAA;SAAE,GAAG,OAAO,CAAA;KAAE,CAAC;IAChG,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,GAAG,kBAAkB,GAAG,SAAS,CAkBjC;AAID;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,UAAU,EACjB,WAAW,EAAE,MAAM,EACnB,UAAU,CAAC,EAAE,kBAAkB,GAC9B,MAAM,CAoIR"}
|
|
@@ -36,9 +36,11 @@ export interface HoldingServer {
|
|
|
36
36
|
*
|
|
37
37
|
* Usage (inside Vite plugin):
|
|
38
38
|
* ```ts
|
|
39
|
-
* // In config() hook — earliest point where port is known
|
|
39
|
+
* // In config() hook — earliest point where port is known.
|
|
40
|
+
* // Use bindWithBump() to honor the default-3000 + auto-bump policy
|
|
41
|
+
* // (see ../server/port-resolution.ts and TIM-842).
|
|
40
42
|
* const holding = createHoldingServer();
|
|
41
|
-
* holding.listen(
|
|
43
|
+
* await bindWithBump((p) => holding.listen(p), { startPort: 3000, autoBump: true });
|
|
42
44
|
*
|
|
43
45
|
* // In last plugin's configureServer() — wrap listen for seamless handoff
|
|
44
46
|
* const originalListen = server.listen.bind(server);
|
|
@@ -49,4 +51,4 @@ export interface HoldingServer {
|
|
|
49
51
|
* ```
|
|
50
52
|
*/
|
|
51
53
|
export declare function createHoldingServer(): HoldingServer;
|
|
52
|
-
//# sourceMappingURL=
|
|
54
|
+
//# sourceMappingURL=holding-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"holding-server.d.ts","sourceRoot":"","sources":["../../src/dev-tools/holding-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAMH,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEtC,kEAAkE;IAClE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AA8ED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,mBAAmB,IAAI,aAAa,CAmDnD"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dev tools barrel — re-exports all dev-only modules.
|
|
3
|
+
*
|
|
4
|
+
* Organized by concern, not by Vite plugin vs server module:
|
|
5
|
+
* - stack-classifier: frame classification for error display
|
|
6
|
+
* - overlay: Vite browser error overlay integration
|
|
7
|
+
* - error-page: self-contained HTML 500 page
|
|
8
|
+
* - 404-page: self-contained HTML 404 page
|
|
9
|
+
* - terminal: boxed terminal error output
|
|
10
|
+
* - logger: structured request tree logger
|
|
11
|
+
* - warnings: dev-mode footgun warnings
|
|
12
|
+
* - browser-logs: forward browser console to server
|
|
13
|
+
* - logs: forward server console to browser
|
|
14
|
+
* - holding-server: startup holding server
|
|
15
|
+
* - instrumentation: fetch tracing + OTEL span processor
|
|
16
|
+
*
|
|
17
|
+
* Dev-only: all modules in this subtree are only active during `vite dev`.
|
|
18
|
+
* They are never included in production builds.
|
|
19
|
+
*/
|
|
20
|
+
export { classifyFrame, classifyStack, type FrameType, type ClassifiedFrame, } from './stack-classifier.js';
|
|
21
|
+
export { sendErrorToOverlay, fixErrorStacktrace, classifyErrorPhase, extractComponentStack, parseFirstAppFrame, calculateModuleRunnerOffset, formatRscDebugContext, formatTerminalError, PHASE_LABELS, type ErrorPhase, type RscDebugComponentInfo, } from './overlay.js';
|
|
22
|
+
export { generateDevErrorPage, extractHmrOptions, type DevErrorHmrOptions } from './error-page.js';
|
|
23
|
+
export { generateDev404Page, collectRoutes, findSimilarRoutes } from './404-page.js';
|
|
24
|
+
export { formatTerminalError as formatTerminalErrorDirect } from './terminal.js';
|
|
25
|
+
export { formatSpanTree, formatSpanSummary, formatJson, resolveLogMode, type DevLogMode, type DevLoggerConfig, } from './logger.js';
|
|
26
|
+
export { warnSuspenseWrappingChildren, warnDenyInSuspense, warnRedirectInSuspense, warnRedirectInAccess, warnStaticRequestApi, warnSlowSlotWithoutSuspense, setViteServer, WarningId, type DevWarningConfig, _resetWarnings, _getEmitted, } from './warnings.js';
|
|
27
|
+
export { timberDevBrowserLogs, type BrowserLogLevel, type DevBrowserLogsConfig, } from './browser-logs.js';
|
|
28
|
+
export { timberDevLogs } from './logs.js';
|
|
29
|
+
export { createHoldingServer, type HoldingServer } from './holding-server.js';
|
|
30
|
+
export { instrumentDevFetch, DevSpanProcessor, type DevFetchCleanup } from './instrumentation.js';
|
|
31
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dev-tools/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EACL,aAAa,EACb,aAAa,EACb,KAAK,SAAS,EACd,KAAK,eAAe,GACrB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EAClB,2BAA2B,EAC3B,qBAAqB,EACrB,mBAAmB,EACnB,YAAY,EACZ,KAAK,UAAU,EACf,KAAK,qBAAqB,GAC3B,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,KAAK,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACnG,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAGrF,OAAO,EAAE,mBAAmB,IAAI,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAGjF,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,KAAK,UAAU,EACf,KAAK,eAAe,GACrB,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,4BAA4B,EAC5B,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,EACpB,oBAAoB,EACpB,2BAA2B,EAC3B,aAAa,EACb,SAAS,EACT,KAAK,gBAAgB,EACrB,cAAc,EACd,WAAW,GACZ,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,oBAAoB,EACpB,KAAK,eAAe,EACpB,KAAK,oBAAoB,GAC1B,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAG1C,OAAO,EAAE,mBAAmB,EAAE,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAG9E,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dev-mode OTEL instrumentation — fetch tracing and span processing.
|
|
3
|
+
*
|
|
4
|
+
* Combines two concerns:
|
|
5
|
+
* 1. Fetch instrumentation: patches globalThis.fetch to create OTEL spans
|
|
6
|
+
* for every fetch call, giving visibility into async data fetching in
|
|
7
|
+
* the dev request log tree.
|
|
8
|
+
* 2. Span processing: collects completed spans per-request and drives
|
|
9
|
+
* dev log output when the root span ends.
|
|
10
|
+
*
|
|
11
|
+
* Only activated in dev mode — zero overhead in production.
|
|
12
|
+
*
|
|
13
|
+
* Design ref: 17-logging.md §"Dev Logging", 21-dev-server.md §"Dev Logging"
|
|
14
|
+
*/
|
|
15
|
+
import type { SpanProcessor, ReadableSpan } from '@opentelemetry/sdk-trace-base';
|
|
16
|
+
import type { Span, Context } from '@opentelemetry/api';
|
|
17
|
+
import { type DevLoggerConfig } from './logger.js';
|
|
18
|
+
export type DevFetchCleanup = () => void;
|
|
19
|
+
/**
|
|
20
|
+
* Patch globalThis.fetch to wrap every call in an OTEL span.
|
|
21
|
+
*
|
|
22
|
+
* Returns a cleanup function that restores the original fetch.
|
|
23
|
+
* Only call this in dev mode.
|
|
24
|
+
*/
|
|
25
|
+
export declare function instrumentDevFetch(): DevFetchCleanup;
|
|
1
26
|
/**
|
|
2
27
|
* DevSpanProcessor — Custom OTEL SpanProcessor that drives dev log output.
|
|
3
28
|
*
|
|
@@ -9,12 +34,7 @@
|
|
|
9
34
|
* This replaces the old DevLogEmitter/DevLogEvents system. OTEL spans are
|
|
10
35
|
* now the single source of truth for dev logging — no more parallel event
|
|
11
36
|
* systems that can drift.
|
|
12
|
-
*
|
|
13
|
-
* Design doc: 17-logging.md §"Dev Logging", 21-dev-server.md §"Dev Logging"
|
|
14
37
|
*/
|
|
15
|
-
import type { SpanProcessor, ReadableSpan } from '@opentelemetry/sdk-trace-base';
|
|
16
|
-
import type { Span, Context } from '@opentelemetry/api';
|
|
17
|
-
import { type DevLoggerConfig } from './dev-logger.js';
|
|
18
38
|
export declare class DevSpanProcessor implements SpanProcessor {
|
|
19
39
|
private spansByTrace;
|
|
20
40
|
private mode;
|
|
@@ -26,4 +46,4 @@ export declare class DevSpanProcessor implements SpanProcessor {
|
|
|
26
46
|
shutdown(): Promise<void>;
|
|
27
47
|
forceFlush(): Promise<void>;
|
|
28
48
|
}
|
|
29
|
-
//# sourceMappingURL=
|
|
49
|
+
//# sourceMappingURL=instrumentation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../src/dev-tools/instrumentation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAKL,KAAK,eAAe,EACrB,MAAM,aAAa,CAAC;AAIrB,MAAM,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC;AAEzC;;;;;GAKG;AACH,wBAAgB,kBAAkB,IAAI,eAAe,CA+CpD;AA4BD;;;;;;;;;;;GAWG;AACH,qBAAa,gBAAiB,YAAW,aAAa;IACpD,OAAO,CAAC,YAAY,CAAqC;IACzD,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,MAAM,CAAkB;gBAEpB,MAAM,EAAE,eAAe;IAKnC,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,GAAG,IAAI;IAI7C,KAAK,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI;IAqB/B,OAAO,CAAC,MAAM;IAUR,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAIzB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;CAGlC"}
|
|
@@ -41,4 +41,4 @@ export declare function formatSpanSummary(spans: ReadableSpan[], _config?: DevLo
|
|
|
41
41
|
* to jq or feeding into external trace analysis tools.
|
|
42
42
|
*/
|
|
43
43
|
export declare function formatJson(spans: ReadableSpan[]): string;
|
|
44
|
-
//# sourceMappingURL=
|
|
44
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/dev-tools/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAIlE,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;AAmMD;;;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;AAyGD;;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"}
|
|
@@ -43,4 +43,4 @@ export declare function isFrameworkInternalCaller(): boolean;
|
|
|
43
43
|
* when the server closes. Only active during `vite dev`.
|
|
44
44
|
*/
|
|
45
45
|
export declare function timberDevLogs(_ctx: PluginContext): Plugin;
|
|
46
|
-
//# sourceMappingURL=
|
|
46
|
+
//# sourceMappingURL=logs.d.ts.map
|
|
@@ -0,0 +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,MAAM,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAI1D,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;AAoDD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAiBzD"}
|
|
@@ -19,15 +19,7 @@ import type { ViteDevServer } from 'vite';
|
|
|
19
19
|
export type ErrorPhase = 'module-transform' | 'proxy' | 'middleware' | 'access' | 'render' | 'handler';
|
|
20
20
|
/** Labels for terminal output. */
|
|
21
21
|
export declare const PHASE_LABELS: Record<ErrorPhase, string>;
|
|
22
|
-
export type FrameType
|
|
23
|
-
/**
|
|
24
|
-
* Classify a stack frame line by origin.
|
|
25
|
-
*
|
|
26
|
-
* - 'app': user application code (in project root, not node_modules)
|
|
27
|
-
* - 'framework': timber-app internal code
|
|
28
|
-
* - 'internal': node_modules, Node.js internals
|
|
29
|
-
*/
|
|
30
|
-
export declare function classifyFrame(frameLine: string, projectRoot: string): FrameType;
|
|
22
|
+
export { classifyFrame, classifyStack, type FrameType, type ClassifiedFrame } from './stack-classifier.js';
|
|
31
23
|
/**
|
|
32
24
|
* Extract the React component stack from an error, if present.
|
|
33
25
|
* React attaches this as `componentStack` during renderToReadableStream errors.
|
|
@@ -48,7 +40,7 @@ export declare function parseFirstAppFrame(stack: string, projectRoot: string):
|
|
|
48
40
|
* Falls back to 'render' if no specific phase can be determined.
|
|
49
41
|
*/
|
|
50
42
|
export declare function classifyErrorPhase(error: Error, projectRoot: string): ErrorPhase;
|
|
51
|
-
import { formatTerminalError as _formatTerminalError } from './
|
|
43
|
+
import { formatTerminalError as _formatTerminalError } from './terminal.js';
|
|
52
44
|
export declare const formatTerminalError: typeof _formatTerminalError;
|
|
53
45
|
/**
|
|
54
46
|
* Component info extracted from the RSC debug channel.
|
|
@@ -96,5 +88,4 @@ export declare function fixErrorStacktrace(server: ViteDevServer, error: Error,
|
|
|
96
88
|
* The dev server remains running — errors are handled, not fatal.
|
|
97
89
|
*/
|
|
98
90
|
export declare function sendErrorToOverlay(server: ViteDevServer, error: Error, phase: ErrorPhase, projectRoot: string, rscDebugComponents?: RscDebugComponentInfo[]): void;
|
|
99
|
-
|
|
100
|
-
//# sourceMappingURL=dev-error-overlay.d.ts.map
|
|
91
|
+
//# sourceMappingURL=overlay.d.ts.map
|