Skip to content

Commit

Permalink
Fix EntryContext type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
markdalgleish committed Jun 21, 2024
1 parent 37375c5 commit 3a7879b
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 292 deletions.
58 changes: 0 additions & 58 deletions packages/react-router/__tests__/server-runtime/serialize-test.ts

This file was deleted.

5 changes: 3 additions & 2 deletions packages/react-router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ export {
PrefetchPageLinks,
} from "./lib/dom/ssr/components";
export type { ScriptsProps } from "./lib/dom/ssr/components";
export type { EntryContext } from "./lib/dom/ssr/entry";
export type {
HtmlLinkDescriptor,
LinkDescriptor,
Expand Down Expand Up @@ -396,6 +397,7 @@ export type {
// TODO: (v7) Clean up code paths for these exports
// ActionFunction,
// ActionFunctionArgs,
// EntryContext,
// ErrorResponse,
// HtmlLinkDescriptor,
// LinkDescriptor,
Expand All @@ -405,14 +407,14 @@ export type {
// ServerRuntimeMetaArgs,
// ServerRuntimeMetaDescriptor,
// ServerRuntimeMetaFunction,
// SerializeFrom,
AppLoadContext,
Cookie,
CookieOptions,
CookieParseOptions,
CookieSerializeOptions,
CookieSignatureOptions,
DataFunctionArgs,
EntryContext,
FlashSessionData,
HandleDataRequestFunction,
HandleDocumentRequestFunction,
Expand All @@ -423,7 +425,6 @@ export type {
HandleErrorFunction,
PageLinkDescriptor,
RequestHandler,
SerializeFrom,
ServerBuild,
ServerEntryModule,
Session,
Expand Down
1 change: 1 addition & 0 deletions packages/react-router/lib/dom/ssr/entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export interface EntryContext extends RemixContextObject {
export interface FutureConfig {
v3_fetcherPersist: boolean;
v3_relativeSplatPath: boolean;
v3_throwAbortReason: boolean;
}

export interface AssetsManifest {
Expand Down
1 change: 1 addition & 0 deletions packages/react-router/lib/dom/ssr/routes-test-stub.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export function createRoutesStub(
future: {
v3_fetcherPersist: future?.v3_fetcherPersist === true,
v3_relativeSplatPath: future?.v3_relativeSplatPath === true,
v3_throwAbortReason: future?.v3_throwAbortReason === true,
},
manifest: {
routes: {},
Expand Down
6 changes: 5 additions & 1 deletion packages/react-router/lib/server-runtime/build.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import type { ActionFunctionArgs, LoaderFunctionArgs } from "./routeModules";
import type { AssetsManifest, EntryContext, FutureConfig } from "./entry";
import type {
AssetsManifest,
EntryContext,
FutureConfig,
} from "../dom/ssr/entry";
import type { ServerRouteManifest } from "./routes";
import type { AppLoadContext } from "./data";

Expand Down
46 changes: 1 addition & 45 deletions packages/react-router/lib/server-runtime/entry.ts
Original file line number Diff line number Diff line change
@@ -1,50 +1,6 @@
import type { StaticHandlerContext } from "../router";
import type { SerializedError } from "./errors";
import type { RouteManifest, ServerRouteManifest, EntryRoute } from "./routes";
import type { ServerRouteManifest } from "./routes";
import type { RouteModules, EntryRouteModule } from "./routeModules";

export interface EntryContext {
manifest: AssetsManifest;
routeModules: RouteModules<EntryRouteModule>;
criticalCss?: string;
serverHandoffString?: string;
serverHandoffStream?: ReadableStream<Uint8Array>;
renderMeta?: {
didRenderScripts?: boolean;
streamCache?: Record<
number,
Promise<void> & {
result?: {
done: boolean;
value: string;
};
error?: unknown;
}
>;
};
staticHandlerContext: StaticHandlerContext;
future: FutureConfig;
isSpaMode: boolean;
serializeError(error: Error): SerializedError;
}

export interface FutureConfig {
v3_fetcherPersist: boolean;
v3_relativeSplatPath: boolean;
v3_throwAbortReason: boolean;
}

export interface AssetsManifest {
entry: {
imports: string[];
module: string;
};
routes: RouteManifest<EntryRoute>;
url: string;
version: string;
hmrRuntime?: string;
}

export function createEntryRouteModules(
manifest: ServerRouteManifest
): RouteModules<EntryRouteModule> {
Expand Down
4 changes: 0 additions & 4 deletions packages/react-router/lib/server-runtime/reexport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ export type { SignFunction, UnsignFunction } from "./crypto";

export type { AppLoadContext } from "./data";

export type { EntryContext } from "./entry";

export type {
HtmlLinkDescriptor,
LinkDescriptor,
Expand All @@ -50,8 +48,6 @@ export type {
ServerRuntimeMetaFunction,
} from "./routeModules";

export type { SerializeFrom } from "./serialize";

export type { RequestHandler } from "./server";

export type {
Expand Down
9 changes: 8 additions & 1 deletion packages/react-router/lib/server-runtime/routeModules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type {
} from "../router";
import type { AppData, AppLoadContext } from "./data";
import type { LinkDescriptor } from "./links";
import type { SerializeFrom } from "./serialize";
import type { SerializeFrom } from "../dom/ssr/components";
import type { ResponseStub } from "./single-fetch";

export interface RouteModules<RouteModule> {
Expand All @@ -34,6 +34,13 @@ export type ActionFunction = (
args: ActionFunctionArgs
) => ReturnType<RRActionFunction>;

// export interface ActionFunction<Context = any> {
// (
// args: ActionFunctionArgs<Context>,
// handlerCtx?: unknown
// ): DataFunctionReturnValue;
// }

/**
* Arguments passed to a route `action` function
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/react-router/lib/server-runtime/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {
ActionFunctionArgs as RRActionFunctionArgs,
} from "../router";
import { callRouteAction, callRouteLoader } from "./data";
import type { FutureConfig } from "./entry";
import type { FutureConfig } from "../dom/ssr/entry";
import type { ServerRouteModule } from "./routeModules";
import type { DataStrategyCtx } from "./single-fetch";

Expand Down
Loading

0 comments on commit 3a7879b

Please sign in to comment.