@rangojs/router 0.6.0 → 0.7.0

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.
@@ -1,6 +1,6 @@
1
1
  import type { SearchSchemaValue } from "../search-params.js";
2
2
  import type { TrailingSlashMode } from "../types.js";
3
- import type { UrlPatterns } from "../urls/pattern-types.js";
3
+ import type { PartialPrerenderProps, UrlPatterns } from "../urls/pattern-types.js";
4
4
  import type { ClientTransitionConfig, ClientUrlPatterns } from "./types.js";
5
5
  export interface ClientUrlReference {
6
6
  readonly $$typeof: symbol;
@@ -10,6 +10,15 @@ export type ClientUrlDefinitionSource = ClientUrlReference | ClientUrlPatterns;
10
10
  export interface ClientUrlProjectionOptions {
11
11
  readonly search?: Readonly<Record<string, SearchSchemaValue>>;
12
12
  readonly trailingSlash?: TrailingSlashMode;
13
+ /**
14
+ * The `ppr` path option, JSON-projected. Materialization passes it onto
15
+ * the group route's server `path()` verbatim, so the manifest entry
16
+ * carries it and the runtime shell capture/serve lanes engage exactly as
17
+ * for a hand-written server route (search is part of shell identity —
18
+ * the capture render seeds the key's own search, so group static parts
19
+ * may read useSearchParams).
20
+ */
21
+ readonly ppr?: true | Readonly<PartialPrerenderProps>;
13
22
  }
14
23
  export interface ClientUrlProjectionRoute {
15
24
  readonly id: string;
@@ -15,7 +15,7 @@ export interface ClientUrlItem {
15
15
  export type ClientUrlItemInput = ClientUrlItem | readonly ClientUrlItemInput[];
16
16
  export type ClientUrlItems = readonly ClientUrlItemInput[];
17
17
  export type ClientUrlUse = () => ClientUrlItems;
18
- export type ClientPathOptions<TName extends string = string, TSearch extends SearchSchema = SearchSchema> = Pick<PathOptions<TName, TSearch>, "name" | "search" | "trailingSlash">;
18
+ export type ClientPathOptions<TName extends string = string, TSearch extends SearchSchema = SearchSchema> = Pick<PathOptions<TName, TSearch>, "name" | "search" | "trailingSlash" | "ppr">;
19
19
  export type ClientPathFn = <const TPattern extends string, const TName extends string = UnnamedRoute, const TSearch extends SearchSchema = {}>(pattern: TPattern, component: ComponentType, optionsOrUse?: ClientPathOptions<TName, TSearch> | ClientUrlUse, use?: ClientUrlUse) => ClientUrlItem & TypedRouteItem<TName, TPattern, unknown, TSearch>;
20
20
  export type ClientLayoutFn = <const TItems extends ClientUrlItems>(component: ComponentType, children: () => TItems) => ClientUrlItem & TypedLayoutItem<ExtractRoutes<TItems>>;
21
21
  /**
@@ -104,7 +104,10 @@ export interface ClientUrlHelpers {
104
104
  * Pass `{ stream: "navigation" }` to await this loader before first flush
105
105
  * on DOCUMENT requests (see {@link LoaderOptions}) — the opt-in for loaders
106
106
  * whose data, handle pushes, or thrown notFound()/redirect() must be in the
107
- * SSR'd HTML. Per-loader: a dynamic sibling keeps streaming.
107
+ * SSR'd HTML. Per-loader: a dynamic sibling keeps streaming. Under a
108
+ * `ppr` group route the flag BAKES: the loader executes at shell capture
109
+ * and its settled return freezes into the shell (nested promises stay
110
+ * live holes).
108
111
  */
109
112
  readonly loader: <TData>(definition: LoaderDefinition<TData>, optionsOrUse?: LoaderOptions | ClientUrlUse, use?: ClientUrlUse) => ClientUrlItem;
110
113
  readonly loading: (component: ReactNode) => ClientUrlItem;
@@ -28,15 +28,15 @@ import { type RequestContext } from "../../server/request-context.js";
28
28
  export declare function isShellCaptureActive(reqCtx?: RequestContext<any> | undefined): boolean;
29
29
  export { createMaskedLoaderPromise } from "./mask-nested.js";
30
30
  /**
31
- * Lane decision for an entry's loaders under PPR (the loading() value decides;
32
- * docs/design/loader-container-bake.md):
33
- *
34
- * - RENDERABLE loading() (the LoaderBoundary Suspense fallback) — the LIVE
35
- * lane: masked at capture, guaranteed fresh on every serve. Returns true.
36
- * - No loading() (absent, or explicitly `false`, incl. `loading(x, { ssr:
37
- * false })` under the SSR manifest) the BAKE lane: the loader executes
38
- * during capture, its settled container bakes, nested pending promises hole
39
- * at the consumer's own Suspense. Returns false.
31
+ * Entry-level lane input for an entry's loaders under PPR (the loading()
32
+ * value; docs/design/loader-container-bake.md). The CAPTURE decision itself
33
+ * is per LOADER in loader-cache.ts: a `stream: "navigation"`
34
+ * (awaitBeforeFlush) loader BAKES at capture regardless of this value — the
35
+ * flag's document promise ("data in the HTML before first flush") maps to
36
+ * the frozen prelude while every other loader is LIVE (masked at capture,
37
+ * fresh on every serve), postponing at loading() or an inline Suspense.
38
+ * This helper still gates which entries pass a bake segment key for the
39
+ * legacy loading()-less shape and the HIT-tail seed overlay.
40
40
  *
41
41
  * Mirrors segment-system's isRenderableLoading so the mask decision and the
42
42
  * tree's boundary placement can never disagree.
@@ -151,7 +151,10 @@ export type PathHelpers<TEnv> = {
151
151
  * Pass `{ stream: "navigation" }` to await this loader before first flush
152
152
  * on DOCUMENT requests (see {@link LoaderOptions}) — the opt-in for loaders
153
153
  * whose data, handle pushes, or thrown notFound()/redirect() must be in the
154
- * SSR'd HTML. Per-loader: a dynamic sibling keeps streaming.
154
+ * SSR'd HTML. Per-loader: a dynamic sibling keeps streaming. Under a
155
+ * `ppr` route the flag BAKES: the loader executes at shell capture and
156
+ * its settled return freezes into the shell (nested promises stay live
157
+ * holes) — the pre-flush promise applied to the prelude.
155
158
  */
156
159
  loader: <TData>(loaderDef: LoaderDefinition<TData>, optionsOrUse?: LoaderOptions | (() => LoaderUseItem[]), use?: () => LoaderUseItem[]) => LoaderItem;
157
160
  /**
@@ -4,17 +4,6 @@ import type { Plugin } from "vite";
4
4
  * Handles scoped packages (@org/name) and nested node_modules.
5
5
  * Returns null if the path doesn't contain a valid package reference.
6
6
  *
7
- * NOTE: This is a lossy transformation. It maps a specific submodule path
8
- * (e.g., pkg/internal/context.js) to the package root (pkg). The load()
9
- * hook then re-exports via the bare specifier, which resolves to the
10
- * package entry point. This works for packages that barrel-export their
11
- * "use client" symbols from the root, which covers the common case
12
- * (component libraries like @mantine/core, @chakra-ui/react, etc.).
13
- * Packages whose client symbols are only available from deep subpaths
14
- * (not re-exported from the root) would lose those symbols after the
15
- * rewrite. A more precise approach would resolve through the package's
16
- * exports map to find the correct entry point, but that adds significant
17
- * complexity for a rare edge case.
18
7
  * See: https://github.com/cloudflare/vinext/pull/413
19
8
  */
20
9
  export declare function extractPackageName(absolutePath: string): string | null;