@timber-js/app 0.2.0-alpha.158 → 0.2.0-alpha.159
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-BA5tIpVu.js → actions-CBbP1hHO.js} +3 -3
- package/dist/_chunks/{actions-BA5tIpVu.js.map → actions-CBbP1hHO.js.map} +1 -1
- package/dist/_chunks/{build-output-helper-C8q4Zpf5.js → build-output-helper-DF5uScqS.js} +4 -1
- package/dist/_chunks/{build-output-helper-C8q4Zpf5.js.map → build-output-helper-DF5uScqS.js.map} +1 -1
- package/dist/_chunks/cache-api-DsWEYwVZ.js +1120 -0
- package/dist/_chunks/cache-api-DsWEYwVZ.js.map +1 -0
- package/dist/_chunks/{cli-schema-sync-DcmQrzJG.js → cli-schema-sync-Bivx4Rn7.js} +4 -3
- package/dist/_chunks/{cli-schema-sync-DcmQrzJG.js.map → cli-schema-sync-Bivx4Rn7.js.map} +1 -1
- package/dist/_chunks/dist-BA3u1z3W.js +423 -0
- package/dist/_chunks/dist-BA3u1z3W.js.map +1 -0
- package/dist/_chunks/{logger-C5v1IMuh.js → logger-CrRmZMlo.js} +81 -56
- package/dist/_chunks/logger-CrRmZMlo.js.map +1 -0
- package/dist/_chunks/{plugin-context-DUl3dnCF.js → plugin-context-DeAxFRMq.js} +3 -36
- package/dist/_chunks/plugin-context-DeAxFRMq.js.map +1 -0
- package/dist/_chunks/sizeof-lXffQ1Vr.js +35 -0
- package/dist/_chunks/sizeof-lXffQ1Vr.js.map +1 -0
- package/dist/_chunks/{walkers-D5jCGPum.js → walkers-DXbJkeCY.js} +217 -19
- package/dist/_chunks/walkers-DXbJkeCY.js.map +1 -0
- package/dist/adapters/build-output-helper.d.ts.map +1 -1
- package/dist/adapters/cloudflare.d.ts +28 -0
- package/dist/adapters/cloudflare.d.ts.map +1 -1
- package/dist/adapters/cloudflare.js +143 -9
- package/dist/adapters/cloudflare.js.map +1 -1
- package/dist/adapters/nitro.js +1 -1
- package/dist/cache/cache-api.d.ts +2 -0
- package/dist/cache/cache-api.d.ts.map +1 -1
- package/dist/cache/handler-store.d.ts +2 -0
- package/dist/cache/handler-store.d.ts.map +1 -1
- package/dist/cache/index.d.ts +2 -0
- package/dist/cache/index.d.ts.map +1 -1
- package/dist/cache/index.js +3 -186
- package/dist/cache/redis-handler.d.ts +17 -5
- package/dist/cache/redis-handler.d.ts.map +1 -1
- package/dist/cache/singleflight.d.ts +1 -1
- package/dist/cache/singleflight.d.ts.map +1 -1
- package/dist/cache/store.d.ts +53 -0
- package/dist/cache/store.d.ts.map +1 -0
- package/dist/cache/stores/cloudflare-kv.d.ts +38 -0
- package/dist/cache/stores/cloudflare-kv.d.ts.map +1 -0
- package/dist/cache/stores/cloudflare-kv.js +29 -0
- package/dist/cache/stores/cloudflare-kv.js.map +1 -0
- package/dist/cache/stores/memory.d.ts +42 -0
- package/dist/cache/stores/memory.d.ts.map +1 -0
- package/dist/cache/stores/memory.js +90 -0
- package/dist/cache/stores/memory.js.map +1 -0
- package/dist/cache/stores/redis.d.ts +69 -0
- package/dist/cache/stores/redis.d.ts.map +1 -0
- package/dist/cache/stores/redis.js +35 -0
- package/dist/cache/stores/redis.js.map +1 -0
- package/dist/cache/stores/vercel.d.ts +36 -0
- package/dist/cache/stores/vercel.d.ts.map +1 -0
- package/dist/cache/stores/vercel.js +33 -0
- package/dist/cache/stores/vercel.js.map +1 -0
- package/dist/cache/tag-aware-handler.d.ts +51 -0
- package/dist/cache/tag-aware-handler.d.ts.map +1 -0
- package/dist/cache/timber-cache.d.ts.map +1 -1
- package/dist/cdn/cloudflare-purge.d.ts +23 -0
- package/dist/cdn/cloudflare-purge.d.ts.map +1 -0
- package/dist/cdn/fastly-purge.d.ts +25 -0
- package/dist/cdn/fastly-purge.d.ts.map +1 -0
- package/dist/cdn/headers.d.ts +82 -0
- package/dist/cdn/headers.d.ts.map +1 -0
- package/dist/cdn/index.d.ts +5 -0
- package/dist/cdn/index.d.ts.map +1 -0
- package/dist/cdn/purge-store.d.ts +23 -0
- package/dist/cdn/purge-store.d.ts.map +1 -0
- package/dist/cli.js +2 -2
- package/dist/client/browser-entry/action-dispatch.d.ts.map +1 -1
- package/dist/client/browser-entry/post-hydration.d.ts.map +1 -1
- package/dist/client/browser-entry/router-init.d.ts.map +1 -1
- package/dist/client/history.d.ts +0 -3
- package/dist/client/history.d.ts.map +1 -1
- package/dist/client/index.js +0 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/internal.js +11 -86
- package/dist/client/internal.js.map +1 -1
- package/dist/client/navigation-api.d.ts +1 -3
- package/dist/client/navigation-api.d.ts.map +1 -1
- package/dist/client/router.d.ts +1 -4
- package/dist/client/router.d.ts.map +1 -1
- package/dist/client/rsc-fetch.d.ts +1 -11
- package/dist/client/rsc-fetch.d.ts.map +1 -1
- package/dist/client/segment-cache.d.ts +1 -3
- package/dist/client/segment-cache.d.ts.map +1 -1
- package/dist/client/use-cookie.d.ts.map +1 -1
- package/dist/config-types.d.ts +3 -1
- package/dist/config-types.d.ts.map +1 -1
- package/dist/config-validation.d.ts.map +1 -1
- package/dist/cookies/index.js +15 -11
- package/dist/cookies/index.js.map +1 -1
- package/dist/dev-tools/browser-logs.d.ts +28 -72
- package/dist/dev-tools/browser-logs.d.ts.map +1 -1
- package/dist/dev-tools/index.d.ts +1 -1
- package/dist/dev-tools/index.d.ts.map +1 -1
- package/dist/dev-tools/logger.d.ts.map +1 -1
- package/dist/dev-tools/terminal.d.ts.map +1 -1
- package/dist/fonts/transform.d.ts +4 -0
- package/dist/fonts/transform.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1269 -359
- package/dist/index.js.map +1 -1
- package/dist/plugin-context.d.ts +36 -0
- package/dist/plugin-context.d.ts.map +1 -1
- package/dist/plugins/build-report.d.ts +21 -0
- package/dist/plugins/build-report.d.ts.map +1 -1
- package/dist/plugins/cache.d.ts +5 -14
- package/dist/plugins/cache.d.ts.map +1 -1
- package/dist/plugins/callsite-ast.d.ts +95 -0
- package/dist/plugins/callsite-ast.d.ts.map +1 -0
- package/dist/plugins/callsite-jsx.d.ts +35 -0
- package/dist/plugins/callsite-jsx.d.ts.map +1 -0
- package/dist/plugins/entries.d.ts.map +1 -1
- package/dist/plugins/fonts.d.ts.map +1 -1
- package/dist/plugins/prebuilt-capture.d.ts +60 -0
- package/dist/plugins/prebuilt-capture.d.ts.map +1 -0
- package/dist/plugins/prebuilt.d.ts +82 -0
- package/dist/plugins/prebuilt.d.ts.map +1 -0
- package/dist/plugins/prerender-sugar.d.ts +42 -0
- package/dist/plugins/prerender-sugar.d.ts.map +1 -0
- package/dist/plugins/server-bundle.d.ts.map +1 -1
- package/dist/plugins/shims.d.ts.map +1 -1
- package/dist/plugins/static-build.d.ts.map +1 -1
- package/dist/routing/convention-lint.d.ts.map +1 -1
- package/dist/routing/export-detect.d.ts +56 -0
- package/dist/routing/export-detect.d.ts.map +1 -0
- package/dist/routing/index.js +2 -2
- package/dist/routing/manifest-codegen.d.ts.map +1 -1
- package/dist/rsc-runtime/rsc.d.ts +1 -1
- package/dist/rsc-runtime/rsc.d.ts.map +1 -1
- package/dist/server/action-handler.d.ts.map +1 -1
- package/dist/server/actions.d.ts +0 -3
- package/dist/server/actions.d.ts.map +1 -1
- package/dist/server/als-registry.d.ts +7 -0
- package/dist/server/als-registry.d.ts.map +1 -1
- package/dist/server/cookie-parsing.d.ts +15 -1
- package/dist/server/cookie-parsing.d.ts.map +1 -1
- package/dist/server/deny-renderer.d.ts.map +1 -1
- package/dist/server/html-injectors.d.ts +1 -0
- package/dist/server/html-injectors.d.ts.map +1 -1
- package/dist/server/index.js +2 -2
- package/dist/server/internal.d.ts +6 -1
- package/dist/server/internal.d.ts.map +1 -1
- package/dist/server/internal.js +563 -74
- package/dist/server/internal.js.map +1 -1
- package/dist/server/prebuilt/cache-key.d.ts +58 -0
- package/dist/server/prebuilt/cache-key.d.ts.map +1 -0
- package/dist/server/prebuilt/capture-state.d.ts +57 -0
- package/dist/server/prebuilt/capture-state.d.ts.map +1 -0
- package/dist/server/prebuilt/manifest-tag-index.d.ts +27 -0
- package/dist/server/prebuilt/manifest-tag-index.d.ts.map +1 -0
- package/dist/server/prebuilt/overlay.d.ts +100 -0
- package/dist/server/prebuilt/overlay.d.ts.map +1 -0
- package/dist/server/prebuilt/payload-source.d.ts +75 -0
- package/dist/server/prebuilt/payload-source.d.ts.map +1 -0
- package/dist/server/prebuilt/synthetic-store.d.ts +64 -0
- package/dist/server/prebuilt/synthetic-store.d.ts.map +1 -0
- package/dist/server/prebuilt-builder.d.ts +110 -0
- package/dist/server/prebuilt-builder.d.ts.map +1 -0
- package/dist/server/prebuilt-runtime.d.ts +101 -0
- package/dist/server/prebuilt-runtime.d.ts.map +1 -0
- package/dist/server/route-element-builder.d.ts +10 -8
- package/dist/server/route-element-builder.d.ts.map +1 -1
- package/dist/server/rsc-entry/helpers.d.ts +0 -5
- package/dist/server/rsc-entry/helpers.d.ts.map +1 -1
- package/dist/server/rsc-entry/index.d.ts +10 -0
- package/dist/server/rsc-entry/index.d.ts.map +1 -1
- package/dist/server/rsc-entry/render-route.d.ts.map +1 -1
- package/dist/server/rsc-entry/revalidate-renderer.d.ts.map +1 -1
- package/dist/server/rsc-entry/rsc-payload.d.ts +3 -4
- package/dist/server/rsc-entry/rsc-payload.d.ts.map +1 -1
- package/dist/server/sitemap-generator.d.ts +6 -6
- package/dist/server/sitemap-generator.d.ts.map +1 -1
- package/dist/server/tracing.d.ts +37 -3
- package/dist/server/tracing.d.ts.map +1 -1
- package/docs/api/32-api-cache.mdx +10 -4
- package/docs/learn/00-introduction.mdx +8 -13
- package/docs/learn/02-pages-and-layouts.mdx +9 -0
- package/docs/learn/06-forms-and-actions.mdx +0 -4
- package/docs/learn/07-typed-routes.mdx +127 -0
- package/docs/learn/09-caching.mdx +12 -1
- package/docs/learn/10-middleware.mdx +1 -0
- package/docs/learn/11-error-handling.mdx +9 -0
- package/docs/learn/13-configuration.mdx +28 -0
- package/docs/learn/14-deploying.mdx +52 -0
- package/docs/more/06-instrumentation.mdx +27 -1
- package/docs/more/07-security.mdx +8 -2
- package/docs/more/08-developer-experience.mdx +134 -0
- package/package.json +31 -2
- package/src/adapters/build-output-helper.ts +10 -0
- package/src/adapters/cloudflare.ts +178 -4
- package/src/cache/cache-api.ts +60 -0
- package/src/cache/handler-store.ts +8 -0
- package/src/cache/index.ts +4 -0
- package/src/cache/redis-handler.ts +25 -13
- package/src/cache/singleflight.ts +11 -11
- package/src/cache/store.ts +71 -0
- package/src/cache/stores/cloudflare-kv.ts +52 -0
- package/src/cache/stores/memory.ts +125 -0
- package/src/cache/stores/redis.ts +97 -0
- package/src/cache/stores/vercel.ts +59 -0
- package/src/cache/tag-aware-handler.ts +233 -0
- package/src/cache/timber-cache.ts +17 -7
- package/src/cdn/cloudflare-purge.ts +50 -0
- package/src/cdn/fastly-purge.ts +63 -0
- package/src/cdn/headers.ts +127 -0
- package/src/cdn/index.ts +16 -0
- package/src/cdn/purge-store.ts +34 -0
- package/src/client/browser-entry/action-dispatch.ts +1 -10
- package/src/client/browser-entry/post-hydration.ts +0 -1
- package/src/client/browser-entry/router-init.ts +0 -5
- package/src/client/history.ts +0 -4
- package/src/client/navigation-api.ts +5 -11
- package/src/client/router.ts +9 -43
- package/src/client/rsc-fetch.ts +5 -27
- package/src/client/segment-cache.ts +1 -4
- package/src/client/use-cookie.ts +18 -12
- package/src/config-types.ts +3 -1
- package/src/config-validation.ts +1 -0
- package/src/dev-tools/browser-logs.ts +37 -273
- package/src/dev-tools/index.ts +2 -2
- package/src/dev-tools/instrumentation.ts +1 -1
- package/src/dev-tools/logger.ts +33 -51
- package/src/dev-tools/terminal.ts +21 -22
- package/src/fonts/transform.ts +4 -43
- package/src/index.ts +16 -3
- package/src/plugin-context.ts +36 -0
- package/src/plugins/build-report.ts +133 -1
- package/src/plugins/cache.ts +32 -131
- package/src/plugins/callsite-ast.ts +167 -0
- package/src/plugins/callsite-jsx.ts +243 -0
- package/src/plugins/entries.ts +23 -4
- package/src/plugins/fonts.ts +16 -2
- package/src/plugins/prebuilt-capture.ts +208 -0
- package/src/plugins/prebuilt.ts +673 -0
- package/src/plugins/prerender-sugar.ts +329 -0
- package/src/plugins/server-bundle.ts +12 -0
- package/src/plugins/shims.ts +9 -0
- package/src/plugins/static-build.ts +0 -1
- package/src/routing/codegen.ts +1 -21
- package/src/routing/convention-lint.ts +85 -49
- package/src/routing/export-detect.ts +304 -0
- package/src/routing/manifest-codegen.ts +2 -11
- package/src/rsc-runtime/rsc.ts +7 -0
- package/src/server/action-handler.ts +11 -27
- package/src/server/actions.ts +3 -4
- package/src/server/als-registry.ts +7 -0
- package/src/server/cookie-parsing.ts +75 -59
- package/src/server/deny-renderer.ts +7 -15
- package/src/server/html-injectors.ts +11 -3
- package/src/server/internal.ts +17 -1
- package/src/server/prebuilt/cache-key.ts +224 -0
- package/src/server/prebuilt/capture-state.ts +89 -0
- package/src/server/prebuilt/manifest-tag-index.ts +46 -0
- package/src/server/prebuilt/overlay.ts +256 -0
- package/src/server/prebuilt/payload-source.ts +192 -0
- package/src/server/prebuilt/synthetic-store.ts +108 -0
- package/src/server/prebuilt-builder.ts +640 -0
- package/src/server/prebuilt-runtime.ts +706 -0
- package/src/server/route-element-builder.ts +40 -12
- package/src/server/rsc-entry/helpers.ts +0 -17
- package/src/server/rsc-entry/index.ts +83 -0
- package/src/server/rsc-entry/render-route.ts +6 -33
- package/src/server/rsc-entry/revalidate-renderer.ts +16 -11
- package/src/server/rsc-entry/rsc-payload.ts +5 -11
- package/src/server/sitemap-generator.ts +16 -10
- package/src/server/tracing.ts +88 -3
- package/dist/_chunks/cache-api-Cbyh3RW4.js +0 -401
- package/dist/_chunks/cache-api-Cbyh3RW4.js.map +0 -1
- package/dist/_chunks/logger-C5v1IMuh.js.map +0 -1
- package/dist/_chunks/plugin-context-DUl3dnCF.js.map +0 -1
- package/dist/_chunks/validation-CnKhGJsp.js +0 -113
- package/dist/_chunks/validation-CnKhGJsp.js.map +0 -1
- package/dist/_chunks/walkers-D5jCGPum.js.map +0 -1
- package/dist/cache/index.js.map +0 -1
- package/dist/client/head.d.ts +0 -16
- package/dist/client/head.d.ts.map +0 -1
- package/dist/client/navigation-api-types.d.ts +0 -90
- package/dist/client/navigation-api-types.d.ts.map +0 -1
- package/dist/server/client-module-map.d.ts +0 -47
- package/dist/server/client-module-map.d.ts.map +0 -1
- package/dist/shared/head-header.d.ts +0 -54
- package/dist/shared/head-header.d.ts.map +0 -1
- package/src/client/head.ts +0 -61
- package/src/client/navigation-api-types.ts +0 -112
- package/src/server/client-module-map.ts +0 -58
- package/src/shared/head-header.ts +0 -69
package/dist/plugin-context.d.ts
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import type { RouteTree } from './routing/types';
|
|
11
11
|
import type { BuildManifest } from './server/build-manifest';
|
|
12
|
+
import type { CaptureSummary } from './server/prebuilt-builder';
|
|
12
13
|
import type { StartupTimer } from './utils/startup-timer';
|
|
13
14
|
import type { TimberUserConfig } from './config-types.js';
|
|
14
15
|
import type { HoldingServer } from './dev-tools/holding-server.js';
|
|
@@ -75,6 +76,41 @@ export interface PluginContext {
|
|
|
75
76
|
* See design/27-chunking-strategy.md, TIM-1107.
|
|
76
77
|
*/
|
|
77
78
|
sharedModuleFacades?: Map<string, string[]>;
|
|
79
|
+
/**
|
|
80
|
+
* Module ID → prebuilt component IDs declared in it. Recorded by the
|
|
81
|
+
* timber-prebuilt transform (RSC environment, production builds only),
|
|
82
|
+
* consumed by the RSC `generateBundle` module-graph walk that computes
|
|
83
|
+
* `routePrebuiltComponents`. See design/44-render-at-build-time.md.
|
|
84
|
+
*/
|
|
85
|
+
prebuiltModuleComponents?: Map<string, string[]>;
|
|
86
|
+
/**
|
|
87
|
+
* Module ID → mapping of variable name to component ID for the prebuilt
|
|
88
|
+
* components declared in that module. Used at `generateBundle` time to
|
|
89
|
+
* trace imports from other modules back to specific component IDs.
|
|
90
|
+
*/
|
|
91
|
+
prebuiltBindingNames?: Map<string, Map<string, string>>;
|
|
92
|
+
/**
|
|
93
|
+
* Component ID → distinct static call-site prop objects captured from
|
|
94
|
+
* JSX usage sites during the transform and generateBundle phases.
|
|
95
|
+
* Consumed by the post-build capture pass to render with actual props
|
|
96
|
+
* instead of empty `{}`. See design/44 §Props Derivation.
|
|
97
|
+
*/
|
|
98
|
+
prebuiltCallSiteProps?: Map<string, Record<string, unknown>[]>;
|
|
99
|
+
/**
|
|
100
|
+
* Route file path (page or layout, absolute) → prebuilt component IDs
|
|
101
|
+
* transitively reachable from it. Computed during RSC `generateBundle`,
|
|
102
|
+
* consumed by the post-build capture pass (TIM-1119) to decide which
|
|
103
|
+
* components to render under which route's param combos.
|
|
104
|
+
*/
|
|
105
|
+
routePrebuiltComponents?: Map<string, string[]>;
|
|
106
|
+
/**
|
|
107
|
+
* Page file paths that were desugared from `export const prerender` by
|
|
108
|
+
* timber-prerender-sugar. The prebuilt transform uses this to verify
|
|
109
|
+
* the generated `cache.component(...)` call was picked up.
|
|
110
|
+
*/
|
|
111
|
+
prerenderSugarPages?: Set<string>;
|
|
112
|
+
/** Post-build prebuilt capture summary (populated by timber-prebuilt, consumed by build-report). */
|
|
113
|
+
captureSummary?: CaptureSummary;
|
|
78
114
|
}
|
|
79
115
|
/**
|
|
80
116
|
* Resolve the app directory. Checks (in order):
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-context.d.ts","sourceRoot":"","sources":["../src/plugin-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,KAAK,EAAE,gBAAgB,EAA0B,MAAM,mBAAmB,CAAC;AAClF,OAAO,KAAK,EA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oB,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CAqB1E;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,gBAAgB,EACxB,UAAU,EAAE,gBAAgB,GAC3B,MAAM,EAAE,CAgBV;AAWD;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,gBAAgB,EACxB,UAAU,EAAE,gBAAgB,GAC3B,gBAAgB,CAiBlB"}
|
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
import type { Plugin } from 'vite';
|
|
16
16
|
import type { PluginContext } from '../plugin-context.js';
|
|
17
17
|
import type { SegmentNode, RouteTree } from '../routing/types.js';
|
|
18
|
+
import type { CaptureSummary } from '../server/prebuilt-builder.js';
|
|
19
|
+
import type { PrebuiltManifest } from '../server/prebuilt/payload-source.js';
|
|
18
20
|
import { formatSize } from '../utils/format.js';
|
|
19
21
|
export type RouteType = 'static' | 'dynamic' | 'function';
|
|
20
22
|
export interface RouteEntry {
|
|
@@ -59,6 +61,25 @@ export declare function buildRouteReport(entries: RouteEntry[], sharedSize: numb
|
|
|
59
61
|
export declare function buildWarnings(entries: RouteEntry[], budget?: {
|
|
60
62
|
firstLoadJs?: number;
|
|
61
63
|
}): string[];
|
|
64
|
+
export interface PrebuiltComponentStats {
|
|
65
|
+
componentId: string;
|
|
66
|
+
entryCount: number;
|
|
67
|
+
totalBytes: number;
|
|
68
|
+
}
|
|
69
|
+
export interface PrebuiltReportData {
|
|
70
|
+
components: PrebuiltComponentStats[];
|
|
71
|
+
totalEntries: number;
|
|
72
|
+
totalBytes: number;
|
|
73
|
+
skippedCount: number;
|
|
74
|
+
skippedReasons: Array<{
|
|
75
|
+
componentId: string;
|
|
76
|
+
route: string;
|
|
77
|
+
message: string;
|
|
78
|
+
}>;
|
|
79
|
+
}
|
|
80
|
+
export declare function loadPrebuiltManifest(buildDir: string): PrebuiltManifest | null;
|
|
81
|
+
export declare function buildPrebuiltReportData(manifest: PrebuiltManifest | null, summary: CaptureSummary | undefined): PrebuiltReportData | null;
|
|
82
|
+
export declare function buildPrebuiltReport(data: PrebuiltReportData): string[];
|
|
62
83
|
interface ChunkSize {
|
|
63
84
|
raw: number;
|
|
64
85
|
gzip: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-report.d.ts","sourceRoot":"","sources":["../../src/plugins/build-report.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;
|
|
1
|
+
{"version":3,"file":"build-report.d.ts","sourceRoot":"","sources":["../../src/plugins/build-report.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAKH,OAAO,KAAK,EAAE,MAAM,EAAU,MAAM,MAAM,CAAC;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAE7E,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAIhD,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU,CAAC;AAE1D,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,SAAS,CAAC;IAChB,oDAAoD;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,oEAAoE;IACpE,aAAa,EAAE,MAAM,CAAC;CACvB;AAUD;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,WAAW,EAAE,EACvB,UAAU,GAAE,QAAQ,GAAG,QAAmB,GACzC,SAAS,CAYX;AAID,OAAO,EAAE,UAAU,EAAE,CAAC;AAQtB,UAAU,SAAS;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,WA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,eAAe;IACvB,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED,6EAA6E;AAC7E,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAYjG;AAOD,8DAA8D;AAC9D,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,GACtC,MAAM,GAAG,IAAI,CAOf;AA0BD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,EAClC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,GACvC,MAAM,EAAE,CAUV;AAgGD,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CA8F5D"}
|
package/dist/plugins/cache.d.ts
CHANGED
|
@@ -47,25 +47,16 @@
|
|
|
47
47
|
* referencing the same bindings — the same function, where an ID swap is
|
|
48
48
|
* harmless.
|
|
49
49
|
*
|
|
50
|
+
* AST helpers and the ID derivation are shared with timber-prebuilt
|
|
51
|
+
* (plugins/prebuilt.ts) via plugins/callsite-ast.ts.
|
|
52
|
+
*
|
|
50
53
|
* See TIM-997, TIM-1053, design/06-caching.md §"Cache Key Security".
|
|
51
54
|
*/
|
|
52
55
|
import type { Plugin } from 'vite';
|
|
53
56
|
import type { PluginContext } from '../plugin-context.js';
|
|
54
57
|
/**
|
|
55
|
-
* Generate a stable callsite ID
|
|
56
|
-
*
|
|
57
|
-
* expression, and an occurrence index among fully byte-identical
|
|
58
|
-
* (statement, call) pairs in the same file.
|
|
59
|
-
*
|
|
60
|
-
* The ID is deterministic and:
|
|
61
|
-
* - Stable across cold starts AND across builds/deploys for unchanged calls —
|
|
62
|
-
* inserting, deleting, or reordering other cache() calls does not affect it
|
|
63
|
-
* - Unique across different modules (relPath component)
|
|
64
|
-
* - Unique across distinct cache() calls within a module (statement + span
|
|
65
|
-
* hashes), with fully identical duplicates disambiguated by source-order
|
|
66
|
-
* occurrence
|
|
67
|
-
* - Fresh when the wrapped fn, opts, or enclosing statement change, which
|
|
68
|
-
* intentionally invalidates the old persisted entries
|
|
58
|
+
* Generate a stable callsite ID for a cache() call. See callsite-ast.ts for
|
|
59
|
+
* the derivation properties.
|
|
69
60
|
*/
|
|
70
61
|
declare function generateStableId(relativeModulePath: string, statementText: string, callSpanText: string, occurrence: number): string;
|
|
71
62
|
export declare function timberCacheTransform(ctx: PluginContext): Plugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/plugins/cache.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/plugins/cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAKH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAuC1D;;;GAGG;AACH,iBAAS,gBAAgB,CACvB,kBAAkB,EAAE,MAAM,EAC1B,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,GACjB,MAAM,CAQR;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAiE/D;AAGD,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared AST helpers for callsite-ID transforms.
|
|
3
|
+
*
|
|
4
|
+
* Both timber-cache-transform (plugins/cache.ts) and timber-prebuilt
|
|
5
|
+
* (plugins/prebuilt.ts) detect calls on bindings imported from the cache
|
|
6
|
+
* module and stamp them with content-derived stable IDs. The node shapes,
|
|
7
|
+
* import-binding resolution, recursive call walk, and ID derivation are
|
|
8
|
+
* identical — only the callee shape and rewrite differ per plugin.
|
|
9
|
+
*
|
|
10
|
+
* See TIM-997, TIM-1053, design/06-caching.md §"Cache Key Security".
|
|
11
|
+
*/
|
|
12
|
+
/** Module specifiers whose bindings the transforms track. */
|
|
13
|
+
export declare const CACHE_MODULE_SOURCES: Set<string>;
|
|
14
|
+
export interface PositionedNode {
|
|
15
|
+
type: string;
|
|
16
|
+
start: number;
|
|
17
|
+
end: number;
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
}
|
|
20
|
+
export interface IdentifierNode extends PositionedNode {
|
|
21
|
+
type: 'Identifier';
|
|
22
|
+
name: string;
|
|
23
|
+
}
|
|
24
|
+
export interface ImportDeclarationNode extends PositionedNode {
|
|
25
|
+
type: 'ImportDeclaration';
|
|
26
|
+
source: {
|
|
27
|
+
value: string;
|
|
28
|
+
};
|
|
29
|
+
specifiers: Array<PositionedNode & {
|
|
30
|
+
type: string;
|
|
31
|
+
local: IdentifierNode;
|
|
32
|
+
imported?: IdentifierNode;
|
|
33
|
+
}>;
|
|
34
|
+
}
|
|
35
|
+
export interface CallExpressionNode extends PositionedNode {
|
|
36
|
+
type: 'CallExpression';
|
|
37
|
+
callee: PositionedNode;
|
|
38
|
+
arguments: PositionedNode[];
|
|
39
|
+
}
|
|
40
|
+
export interface MemberExpressionNode extends PositionedNode {
|
|
41
|
+
type: 'MemberExpression';
|
|
42
|
+
object: PositionedNode;
|
|
43
|
+
property: PositionedNode;
|
|
44
|
+
computed: boolean;
|
|
45
|
+
}
|
|
46
|
+
export interface ProgramNode extends PositionedNode {
|
|
47
|
+
type: 'Program';
|
|
48
|
+
body: PositionedNode[];
|
|
49
|
+
}
|
|
50
|
+
export interface ImportBindings {
|
|
51
|
+
/** Local names bound to the named import (`import { cache as c }`). */
|
|
52
|
+
named: Set<string>;
|
|
53
|
+
/** Local names of namespace imports (`import * as ns`) of a tracked module. */
|
|
54
|
+
namespaces: Set<string>;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Find the local binding name(s) for `importedName` imported from one of
|
|
58
|
+
* `sources` — both named imports (including aliases) and namespace imports
|
|
59
|
+
* (TIM-1054).
|
|
60
|
+
*/
|
|
61
|
+
export declare function findImportBindings(program: ProgramNode, sources: ReadonlySet<string>, importedName: string): ImportBindings;
|
|
62
|
+
/**
|
|
63
|
+
* Recursively walk AST nodes collecting call expressions accepted by
|
|
64
|
+
* `matches`. Calls are typically at module scope, but calls inside
|
|
65
|
+
* functions/blocks are handled for completeness.
|
|
66
|
+
*
|
|
67
|
+
* NOTE: matching is by binding NAME, so nested scopes that shadow a tracked
|
|
68
|
+
* import can produce false positives for consumers of this walker (see
|
|
69
|
+
* TIM-1141 for the cache transform). The prebuilt transform avoids the
|
|
70
|
+
* class entirely by not using this walker — it allowlists top-level
|
|
71
|
+
* declarator positions instead (plugins/prebuilt.ts).
|
|
72
|
+
*/
|
|
73
|
+
export declare function findCallSites(node: PositionedNode, matches: (call: CallExpressionNode) => boolean, results: CallExpressionNode[]): void;
|
|
74
|
+
/**
|
|
75
|
+
* Generate a stable callsite ID from a module path, a kind discriminator
|
|
76
|
+
* ('cache' | 'component'), the source text of the enclosing top-level
|
|
77
|
+
* statement, the source text of the call expression, and an occurrence index
|
|
78
|
+
* among fully byte-identical (statement, call) pairs in the same file.
|
|
79
|
+
*
|
|
80
|
+
* The ID is deterministic and:
|
|
81
|
+
* - Stable across cold starts AND across builds/deploys for unchanged calls —
|
|
82
|
+
* inserting, deleting, or reordering other calls does not affect it
|
|
83
|
+
* - Unique across different modules (relPath component)
|
|
84
|
+
* - Unique across distinct calls within a module (statement + span hashes),
|
|
85
|
+
* with fully identical duplicates disambiguated by source-order occurrence
|
|
86
|
+
* - Fresh when the wrapped fn, opts, or enclosing statement change, which
|
|
87
|
+
* intentionally invalidates the old persisted entries
|
|
88
|
+
*
|
|
89
|
+
* The enclosing-statement text is included so that byte-identical calls in
|
|
90
|
+
* different scopes — e.g. two factory helpers with identical call spans —
|
|
91
|
+
* get distinct, insertion-stable IDs. See plugins/cache.ts header for the
|
|
92
|
+
* full derivation rationale (TIM-1053).
|
|
93
|
+
*/
|
|
94
|
+
export declare function generateStableCallsiteId(relativeModulePath: string, kind: string, statementText: string, callSpanText: string, occurrence: number): string;
|
|
95
|
+
//# sourceMappingURL=callsite-ast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callsite-ast.d.ts","sourceRoot":"","sources":["../../src/plugins/callsite-ast.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,6DAA6D;AAC7D,eAAO,MAAM,oBAAoB,aAAoD,CAAC;AAEtF,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,cAAe,SAAQ,cAAc;IACpD,IAAI,EAAE,YAAY,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,qBAAsB,SAAQ,cAAc;IAC3D,IAAI,EAAE,mBAAmB,CAAC;IAC1B,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1B,UAAU,EAAE,KAAK,CACf,cAAc,GAAG;QACf,IAAI,EAAE,M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
|
1
|
+
/**
|
|
2
|
+
* JSX call-site props extraction for prebuilt components (TIM-1142).
|
|
3
|
+
*
|
|
4
|
+
* At build time, the timber-prebuilt transform captures the exact props
|
|
5
|
+
* from each JSX usage site of a cache.component binding so the post-build
|
|
6
|
+
* capture pass can prerender entries for each distinct prop set. Only
|
|
7
|
+
* statically analyzable props (JSON-safe literals, arrays, and plain
|
|
8
|
+
* objects) are captured; dynamic/computed props bail — those call sites
|
|
9
|
+
* fall back to live rendering per design/44 §Props Derivation.
|
|
10
|
+
*
|
|
11
|
+
* See design/44-render-at-build-time.md §Props Derivation at Build Time.
|
|
12
|
+
*/
|
|
13
|
+
import type { PluginContext } from '../plugin-context.js';
|
|
14
|
+
import type { PositionedNode, ProgramNode } from './callsite-ast.js';
|
|
15
|
+
export type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
16
|
+
[key: string]: JsonValue;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Extract static props from a JSX element's attributes. Returns null if
|
|
20
|
+
* any attribute is dynamic (spread, computed expression, JSX element, etc.)
|
|
21
|
+
* — the component must fall back to dynamic rendering for that call site.
|
|
22
|
+
*/
|
|
23
|
+
export declare function extractStaticJsxProps(attributes: PositionedNode[]): Record<string, JsonValue> | null;
|
|
24
|
+
/**
|
|
25
|
+
* Walk an AST tree and collect JSX usages of the given binding names,
|
|
26
|
+
* returning the static props for each usage. Returns a map of
|
|
27
|
+
* bindingName → array of static prop objects (or null for dynamic props).
|
|
28
|
+
*/
|
|
29
|
+
export declare function collectJsxUsages(program: ProgramNode, bindingNames: Set<string>): Map<string, Array<Record<string, JsonValue> | null>>;
|
|
30
|
+
/**
|
|
31
|
+
* Add a distinct props object to the call-site-props map for a component,
|
|
32
|
+
* deduplicating by deep JSON value (recursively sorted keys).
|
|
33
|
+
*/
|
|
34
|
+
export declare function recordCallSiteProps(ctx: PluginContext, componentId: string, props: Record<string, JsonValue>): void;
|
|
35
|
+
//# sourceMappingURL=callsite-jsx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callsite-jsx.d.ts","sourceRoot":"","sources":["../../src/plugins/callsite-jsx.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAkB,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAsBrF,MAAM,MAAM,SAAS,GACjB,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,EAAE,GACX;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AA2EjC;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,cAAc,EAAE,GAC3B,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAI,CA+BlC;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,WAAW,EACpB,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,GACxB,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAI,CAAC,CAAC,CA0CtD;AAkBD;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,aAAa,EAClB,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAC/B,IAAI,CASN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entries.d.ts","sourceRoot":"","sources":["../../src/plugins/entries.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAInC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"entries.d.ts","sourceRoot":"","sources":["../../src/plugins/entries.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAInC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AA8J1D;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAUrE;AAED;;;;;;;;GAQG;AACH,wBAAgB,6BAA6B,CAAC,mBAAmB,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAwBxF;AA+DD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAmFxD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fonts.d.ts","sourceRoot":"","sources":["../../src/plugins/fonts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAiC,MAAM,MAAM,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AA2B1D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,uBAAuB,CAAC;AAE/B;;GAEG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"fonts.d.ts","sourceRoot":"","sources":["../../src/plugins/fonts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAiC,MAAM,MAAM,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AA2B1D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,uBAAuB,CAAC;AAE/B;;GAEG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAsMtD"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Post-build prebuilt capture — Node-side orchestration (TIM-1119).
|
|
3
|
+
*
|
|
4
|
+
* Runs from timber-prebuilt's `buildApp` post hook, after Vite's 5-step
|
|
5
|
+
* build sequence. Imports the BUILT `rsc/index.js` (the bundle carries
|
|
6
|
+
* the react-server condition resolved at build time, so a plain dynamic
|
|
7
|
+
* import works) and calls its `__timber_capturePrebuilt` export — the
|
|
8
|
+
* capture itself must run inside the bundle's module graph, where the
|
|
9
|
+
* component registry and flight renderer live. See
|
|
10
|
+
* server/prebuilt-builder.ts and design/44-render-at-build-time.md
|
|
11
|
+
* §Build Phase.
|
|
12
|
+
*
|
|
13
|
+
* This side owns PERSISTENCE: each captured payload is written to
|
|
14
|
+
* `.timber/dist/prebuilt/<componentId>/<cacheKey>.flight` atomically
|
|
15
|
+
* (temp file + rename — a crashed build never leaves a torn artifact
|
|
16
|
+
* under its final name), and `manifest.json` is written last, only after
|
|
17
|
+
* every payload it references is fully on disk. Keeping node:fs on the
|
|
18
|
+
* plugin side keeps it out of the server bundle, which must also run on
|
|
19
|
+
* Cloudflare Workers.
|
|
20
|
+
*
|
|
21
|
+
* NOTE: importing the built entry runs the app's production startup —
|
|
22
|
+
* instrumentation.ts register() and the configured cache handler load
|
|
23
|
+
* inside the build process. That is by design (prebuilt components may
|
|
24
|
+
* call timber.cache), and it only happens when the app actually declares
|
|
25
|
+
* prebuilt components.
|
|
26
|
+
*/
|
|
27
|
+
import type { PluginContext } from '../plugin-context.js';
|
|
28
|
+
import type { CaptureSummary, CapturedEntry } from '../server/prebuilt-builder.js';
|
|
29
|
+
export interface PrebuiltArtifactWriter {
|
|
30
|
+
write(entry: CapturedEntry): Promise<void>;
|
|
31
|
+
/** Write manifest.json (if any entries exist). Returns the entry count. */
|
|
32
|
+
finalize(): Promise<number>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Create the writer for `.timber/dist/prebuilt/`. Storage layout per
|
|
36
|
+
* design/44 §Storage: one directory per component ID, one `.flight` file
|
|
37
|
+
* per cache key, one manifest.json mapping componentId + key → file +
|
|
38
|
+
* metadata.
|
|
39
|
+
*/
|
|
40
|
+
export declare function createPrebuiltArtifactWriter(prebuiltDir: string): PrebuiltArtifactWriter;
|
|
41
|
+
/**
|
|
42
|
+
* Remove any `prebuilt/` output left by a previous build in this
|
|
43
|
+
* directory (watch mode, `emptyOutDir: false`). A stale manifest would
|
|
44
|
+
* make adapters ship payloads from an OLD build — reviving them serves
|
|
45
|
+
* outdated content with that build's chunk references instead of the
|
|
46
|
+
* intended miss → live render. Runs unconditionally at the start of the
|
|
47
|
+
* post-build hook, BEFORE the capture decision: a build whose app no
|
|
48
|
+
* longer declares any prebuilt components must also shed the artifacts
|
|
49
|
+
* (codex P2 on PR #836).
|
|
50
|
+
*/
|
|
51
|
+
export declare function cleanPrebuiltDir(buildDir: string): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Load the built RSC entry and run the capture pass. Throws (failing the
|
|
54
|
+
* build) on infrastructure errors — missing/unloadable entry — and on
|
|
55
|
+
* dynamic-context hard errors (cookies()/headers() in a prerendered
|
|
56
|
+
* component). Per-entry data errors skip-and-report per design/44
|
|
57
|
+
* §Build-Phase Error Handling.
|
|
58
|
+
*/
|
|
59
|
+
export declare function runPrebuiltCapture(ctx: PluginContext): Promise<CaptureSummary>;
|
|
60
|
+
//# sourceMappingURL=prebuilt-capture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prebuilt-capture.d.ts","sourceRoot":"","sources":["../../src/plugins/prebuilt-capture.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAOH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAkB,cAAc,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAanG,MAAM,WAAW,sBAAsB;IACrC,KAAK,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,2EAA2E;IAC3E,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CAC7B;AASD;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,WAAW,EAAE,MAAM,GAAG,sBAAsB,CAuCxF;AAED;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEtE;AASD;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC,CAyEpF"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* timber-prebuilt — Vite plugin that detects `cache.component(...)` call
|
|
3
|
+
* sites and rewrites them to `__prebuilt(stableId, component, options)`.
|
|
4
|
+
*
|
|
5
|
+
* `timber.cache.component(Component, { prerender: true })` is a build-time
|
|
6
|
+
* transform, not a runtime function (design/44-render-at-build-time.md
|
|
7
|
+
* §Registration, surface API renamed by design/45-cache-lifetimes.md). The
|
|
8
|
+
* rewrite registers the component in the server-side prebuilt registry under
|
|
9
|
+
* a stable ID that keys its cached flight payloads.
|
|
10
|
+
*
|
|
11
|
+
* Detected callsite forms (mirrors timber-cache-transform, TIM-1054):
|
|
12
|
+
* - named imports, including aliases:
|
|
13
|
+
* `import { cache } from '@timber-js/app/cache'` + `cache.component(fn, opts)`
|
|
14
|
+
* - namespace imports:
|
|
15
|
+
* `import * as timber` + `timber.cache.component(fn, opts)`
|
|
16
|
+
* Computed access (`cache['component']`) is deliberately not matched — the
|
|
17
|
+
* untransformed call reaches the runtime `cache.component` fallback
|
|
18
|
+
* (cache/cache-api.ts), which warns once and renders dynamically.
|
|
19
|
+
*
|
|
20
|
+
* Matching is an ALLOWLIST of module-scope positions: the direct initializer
|
|
21
|
+
* of a top-level variable declarator (including exported ones) and a
|
|
22
|
+
* top-level `export default cache.component(...)`, with TS expression
|
|
23
|
+
* wrappers (`as`, `satisfies`, `!`) unwrapped. Nothing else is walked — no
|
|
24
|
+
* function/class/loop bodies, no params, no call arguments. Two reasons:
|
|
25
|
+
* (1) `__prebuilt` must register exactly once at module load time; the
|
|
26
|
+
* post-build capture pass walks the registry after loading modules, so a
|
|
27
|
+
* call inside a function registers too late to ever be prebuilt, and a call
|
|
28
|
+
* in a loop would re-register per iteration. (2) Name-based callee matching
|
|
29
|
+
* is only shadow-proof in these positions — nested scopes can rebind `cache`
|
|
30
|
+
* (`function render(cache) {...}`, `for (const cache of caches) ...`), and
|
|
31
|
+
* rewriting those would corrupt user code; a top-level declarator initializer
|
|
32
|
+
* cannot see a shadow of an import binding (redeclaration error). Calls in
|
|
33
|
+
* other positions fall back to the runtime path like other untraceable forms.
|
|
34
|
+
*
|
|
35
|
+
* The rewrite per mode:
|
|
36
|
+
* production: cache.component(fn, opts) → __prebuilt("<id>", fn, opts)
|
|
37
|
+
* dev: cache.component(fn, opts) → __prebuiltDev("<name>", fn, opts)
|
|
38
|
+
*
|
|
39
|
+
* with `import { __prebuilt } from '#server-internal'` prepended. In dev the
|
|
40
|
+
* wrapper is a no-op that logs once per component and renders dynamically —
|
|
41
|
+
* no caching, no markers (design/44 §Dev Mode).
|
|
42
|
+
*
|
|
43
|
+
* Component identity: `<name>_<hash16>`, e.g. `blogbody_a1b2c3d4e5f6a7b8`.
|
|
44
|
+
* The name prefix is the declaring variable's name (lowercased, for legible
|
|
45
|
+
* manifest keys and log lines); the hash is the same content-derived callsite
|
|
46
|
+
* scheme as the data cache transform (callsite-ast.ts) — deterministic across
|
|
47
|
+
* builds for unchanged calls, immune to inserting/reordering other calls, and
|
|
48
|
+
* fresh when the component or its options change. Component cache entries are
|
|
49
|
+
* per-deploy (design/45 §Per-deploy namespacing) so cross-deploy ID reuse is
|
|
50
|
+
* not a poisoning vector, but content-derived IDs keep prebuilt artifacts
|
|
51
|
+
* addressable across incremental edits for free.
|
|
52
|
+
*
|
|
53
|
+
* The transform is skipped in the client environment: server components never
|
|
54
|
+
* execute there, and `#server-internal` resolves to an empty stub in the
|
|
55
|
+
* client bundle (plugins/shims.ts).
|
|
56
|
+
*
|
|
57
|
+
* See TIM-1118, design/44-render-at-build-time.md, design/45-cache-lifetimes.md.
|
|
58
|
+
*/
|
|
59
|
+
import type { Plugin } from 'vite';
|
|
60
|
+
import type { PluginContext } from '../plugin-context.js';
|
|
61
|
+
/**
|
|
62
|
+
* Generate the stable component ID for a cache.component() call site:
|
|
63
|
+
* `<sanitized-name>_<content-hash16>`. Exported for testing.
|
|
64
|
+
*/
|
|
65
|
+
export declare function generatePrebuiltId(relativeModulePath: string, statementText: string, callSpanText: string, occurrence: number, displayName: string): string;
|
|
66
|
+
/** Rollup getModuleInfo shape (subset — static + dynamic imports). */
|
|
67
|
+
export interface PrebuiltModuleInfo {
|
|
68
|
+
importedIds: string[];
|
|
69
|
+
dynamicallyImportedIds?: string[];
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Collect the prebuilt component IDs transitively reachable from a route
|
|
73
|
+
* file, following static AND dynamic imports. Same pattern as the
|
|
74
|
+
* client-reference walk in build-manifest.ts; dynamic imports are included
|
|
75
|
+
* because a dynamically-imported module still registers its components
|
|
76
|
+
* when it eventually loads — attribution over-approximating registration
|
|
77
|
+
* is handled at capture time (an attributed-but-unregistered component is
|
|
78
|
+
* reported and skipped).
|
|
79
|
+
*/
|
|
80
|
+
export declare function collectReachablePrebuiltComponents(entryModuleId: string, moduleComponents: Map<string, string[]>, getModuleInfo: (id: string) => PrebuiltModuleInfo | null): string[];
|
|
81
|
+
export declare function timberPrebuilt(ctx: PluginContext): Plugin;
|
|
82
|
+
//# sourceMappingURL=prebuilt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prebuilt.d.ts","sourceRoot":"","sources":["../../src/plugins/prebuilt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AAMH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAmM1D;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,kBAAkB,EAAE,MAAM,EAC1B,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,GAClB,MAAM,CAUR;AAID,sEAAsE;AACtE,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,sBAAsB,CAAC,EAAE,MAAM,EAAE,CAAC;CACnC;AAED;;;;;;;;GAQG;AACH,wBAAgB,kCAAkC,CAChD,aAAa,EAAE,MAAM,EACrB,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EACvC,aAAa,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,kBAAkB,GAAG,IAAI,GACvD,MAAM,EAAE,CAgBV;AA2HD,wBAAgB,cAAc,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAuOzD"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* timber-prerender-sugar — Vite plugin that desugars `export const prerender`
|
|
3
|
+
* on page and layout files into `cache.component(...)` wrappers.
|
|
4
|
+
*
|
|
5
|
+
* Design doc: design/45-cache-lifetimes.md §"Route-Level Static" and
|
|
6
|
+
* §"Layout Propagation".
|
|
7
|
+
*
|
|
8
|
+
* `export const prerender = true` on a page is pure sugar: it desugars to
|
|
9
|
+
* wrapping the page's default export in `timber.cache.component(Component,
|
|
10
|
+
* { prerender: true })`. Layout propagation cascades a layout's
|
|
11
|
+
* `export const prerender` to descendant pages via most-specific-wins:
|
|
12
|
+
* walk the segment tree from leaf to root, first explicit value wins.
|
|
13
|
+
*
|
|
14
|
+
* A layout that declares `export const prerender` is ALSO wrapped — the
|
|
15
|
+
* layout's flight payload is its own static shell (`children` is a
|
|
16
|
+
* separate component boundary), so caching it is natural (nav, sidebar,
|
|
17
|
+
* footer benefit from build-time rendering). See design/45 §Layout
|
|
18
|
+
* Propagation.
|
|
19
|
+
*
|
|
20
|
+
* This transform runs BEFORE timber-prebuilt so the generated
|
|
21
|
+
* `cache.component(...)` call is picked up by the callsite rewrite.
|
|
22
|
+
*/
|
|
23
|
+
import type { Plugin } from 'vite';
|
|
24
|
+
import type { PluginContext } from '../plugin-context.js';
|
|
25
|
+
import type { SegmentNode } from '../routing/types.js';
|
|
26
|
+
import { type PrerenderExportValue } from '../routing/export-detect.js';
|
|
27
|
+
/**
|
|
28
|
+
* Walk the segment tree and resolve the effective prerender value for
|
|
29
|
+
* every page and layout. Returns a map from file path to resolved value.
|
|
30
|
+
*
|
|
31
|
+
* **Pages:** walk from leaf toward root; first explicit `export const prerender`
|
|
32
|
+
* wins (page > nearest layout > ... > root layout). If none, dynamic.
|
|
33
|
+
*
|
|
34
|
+
* **Layouts:** a layout that declares `export const prerender` is wrapped
|
|
35
|
+
* directly (its own shell is a separate component boundary from `children`).
|
|
36
|
+
* Layouts without their own declaration are NOT wrapped — they don't
|
|
37
|
+
* inherit from ancestors, because wrapping a layout's shell without the
|
|
38
|
+
* author's explicit opt-in would cache content they may expect to be dynamic.
|
|
39
|
+
*/
|
|
40
|
+
export declare function resolvePagePrerender(root: SegmentNode): Map<string, PrerenderExportValue>;
|
|
41
|
+
export declare function timberPrerenderSugar(ctx: PluginContext): Plugin;
|
|
42
|
+
//# sourceMappingURL=prerender-sugar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prerender-sugar.d.ts","sourceRoot":"","sources":["../../src/plugins/prerender-sugar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAa,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAsB,KAAK,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAY5F;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,WAAW,GAAG,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAgCzF;AAuFD,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CA4J/D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-bundle.d.ts","sourceRoot":"","sources":["../../src/plugins/server-bundle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"server-bundle.d.ts","sourceRoot":"","sources":["../../src/plugins/server-bundle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AA4CnC,wBAAgB,kBAAkB,IAAI,MAAM,EAAE,CAuK7C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shims.d.ts","sourceRoot":"","sources":["../../src/plugins/shims.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAGnC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAsB1D;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"shims.d.ts","sourceRoot":"","sources":["../../src/plugins/shims.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAGnC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAsB1D;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAqBlD,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EA6BhD,CAAC;AA2CF;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CA0NvD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"static-build.d.ts","sourceRoot":"","sources":["../../src/plugins/static-build.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAM1D,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAmBD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,qBAAqB,EAAE,CA2BvF;AAMD;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"static-build.d.ts","sourceRoot":"","sources":["../../src/plugins/static-build.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAM1D,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAmBD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,qBAAqB,EAAE,CA2BvF;AAMD;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CA2C5D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convention-lint.d.ts","sourceRoot":"","sources":["../../src/routing/convention-lint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"convention-lint.d.ts","sourceRoot":"","sources":["../../src/routing/convention-lint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,YAAY,CAAC;AAWzD,MAAM,WAAW,iBAAiB;IAChC,kDAAkD;IAClD,EAAE,EAAE,MAAM,CAAC;IACX,0CAA0C;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,4DAA4D;IAC5D,OAAO,EAAE,MAAM,CAAC;IAChB,qFAAqF;IACrF,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;CACzB;AAID;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,iBAAiB,EAAE,CA2BpF;AAgQD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,GAAG,IAAI,CAe1E;AAWD;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,iBAAiB,EAAE,GAAG,MAAM,CAgC9E"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AST-based export detection for route files.
|
|
3
|
+
*
|
|
4
|
+
* Uses Vite's `parseAst` (backed by oxc) to precisely detect named and
|
|
5
|
+
* default exports, replacing the regex-based approach that was fragile
|
|
6
|
+
* with TypeScript syntax (type exports, `as` aliases, comments, etc.).
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Check if a file exports a specific named export.
|
|
10
|
+
* Returns false if the file doesn't exist or can't be parsed.
|
|
11
|
+
*/
|
|
12
|
+
export declare function fileHasExport(filePath: string, exportName: string): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Check if a file has any of the given named exports.
|
|
15
|
+
* Returns the set of matching export names.
|
|
16
|
+
*/
|
|
17
|
+
export declare function fileHasAnyExport(filePath: string, exportNames: readonly string[]): Set<string>;
|
|
18
|
+
/**
|
|
19
|
+
* Check if a file has a default export.
|
|
20
|
+
* Returns false if the file doesn't exist or can't be parsed.
|
|
21
|
+
*/
|
|
22
|
+
export declare function fileHasDefaultExport(filePath: string): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Check if a file has any `export * from '...'` declarations.
|
|
25
|
+
* Returns false if the file doesn't exist or can't be parsed.
|
|
26
|
+
*/
|
|
27
|
+
export declare function fileHasStarExport(filePath: string): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Parsed value of `export const prerender` from a route file.
|
|
30
|
+
*
|
|
31
|
+
* - `true` / `false` — literal boolean
|
|
32
|
+
* - `{ ttl?, tags? }` — ISR options object (prerender: true is implied)
|
|
33
|
+
* - `undefined` — no `export const prerender` found
|
|
34
|
+
*
|
|
35
|
+
* See design/45-cache-lifetimes.md §"Route-Level Static".
|
|
36
|
+
*/
|
|
37
|
+
export type PrerenderExportValue = boolean | {
|
|
38
|
+
ttl?: number;
|
|
39
|
+
tags?: string[];
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Extract the value of `export const prerender` from a file.
|
|
43
|
+
* Returns undefined if the file doesn't export `prerender` or can't be parsed.
|
|
44
|
+
*
|
|
45
|
+
* Supports:
|
|
46
|
+
* export const prerender = true;
|
|
47
|
+
* export const prerender = false;
|
|
48
|
+
* export const prerender = { ttl: 3600, tags: ['docs'] };
|
|
49
|
+
*/
|
|
50
|
+
export declare function getPrerenderExport(filePath: string): PrerenderExportValue | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Check if a file starts with a specific directive (e.g. "use client").
|
|
53
|
+
* Directives are string literal expression statements at the top of the file.
|
|
54
|
+
*/
|
|
55
|
+
export declare function fileHasDirective(filePath: string, directive: string): boolean;
|
|
56
|
+
//# sourceMappingURL=export-detect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export-detect.d.ts","sourceRoot":"","sources":["../../src/routing/export-detect.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAgGH;;;GAGG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAU3E;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAc9F;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAU9D;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAU3D;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AA8C/E;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,oBAAoB,GAAG,SAAS,CA+CrF;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAgB7E"}
|
package/dist/routing/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { i as INTERCEPTION_MARKERS, n as classifyUrlSegment, r as DEFAULT_PAGE_EXTENSIONS, t as classifySegment } from "../_chunks/segment-classify-CDDRVKs7.js";
|
|
2
|
-
import { i as scanRoutes } from "../_chunks/cli-schema-sync-
|
|
3
|
-
import { a as generateRouteMap, i as validateSchemaAgainstRoutes, n as collectInterceptionRewrites, r as collectDynamicSegmentsFromTree, t as collectLeafRoutes } from "../_chunks/walkers-
|
|
2
|
+
import { i as scanRoutes } from "../_chunks/cli-schema-sync-Bivx4Rn7.js";
|
|
3
|
+
import { a as generateRouteMap, i as validateSchemaAgainstRoutes, n as collectInterceptionRewrites, r as collectDynamicSegmentsFromTree, t as collectLeafRoutes } from "../_chunks/walkers-DXbJkeCY.js";
|
|
4
4
|
export { DEFAULT_PAGE_EXTENSIONS, INTERCEPTION_MARKERS, classifySegment, classifyUrlSegment, collectDynamicSegmentsFromTree, collectInterceptionRewrites, collectLeafRoutes, generateRouteMap, scanRoutes, validateSchemaAgainstRoutes };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest-codegen.d.ts","sourceRoot":"","sources":["../../src/routing/manifest-codegen.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"manifest-codegen.d.ts","sourceRoot":"","sources":["../../src/routing/manifest-codegen.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,OAAO,KAAK,EAAE,SAAS,EAA0B,MAAM,YAAY,CAAC;AA8BpE;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAyIhF;AAID;;;;GAIG;AACH,wBAAgB,kCAAkC,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CAuC1E;AAQD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CA8B3D"}
|
|
@@ -10,5 +10,5 @@
|
|
|
10
10
|
* Keep this as thin pass-through re-exports — the value is the single choke
|
|
11
11
|
* point, not abstraction.
|
|
12
12
|
*/
|
|
13
|
-
export { renderToReadableStream, loadServerAction, decodeReply, decodeAction, encryptActionBoundArgs, decryptActionBoundArgs, } from '@vitejs/plugin-rsc/rsc';
|
|
13
|
+
export { renderToReadableStream, loadServerAction, decodeReply, decodeAction, encryptActionBoundArgs, decryptActionBoundArgs, createFromReadableStream, } from '@vitejs/plugin-rsc/rsc';
|
|
14
14
|
//# sourceMappingURL=rsc.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rsc.d.ts","sourceRoot":"","sources":["../../src/rsc-runtime/rsc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,sBAAsB,EACtB,sBAAsB,
|
|
1
|
+
{"version":3,"file":"rsc.d.ts","sourceRoot":"","sources":["../../src/rsc-runtime/rsc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,sBAAsB,EACtB,sBAAsB,EAOtB,wBAAwB,GACzB,MAAM,wBAAwB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action-handler.d.ts","sourceRoot":"","sources":["../../src/server/action-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AASH,OAAO,EAAgB,KAAK,UAA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