litzjs 0.0.0 → 0.1.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.
@@ -43,9 +43,37 @@ function trimPathSegments(value) {
43
43
  if (value === "/") return [];
44
44
  return value.replace(/^\/+|\/+$/g, "").split("/").filter(Boolean);
45
45
  }
46
+ function isWildcardSegment(segment) {
47
+ return segment.startsWith("*");
48
+ }
49
+ function getWildcardParamName(segment) {
50
+ if (segment === "*") return null;
51
+ if (segment.startsWith("*")) return segment.slice(1);
52
+ return null;
53
+ }
46
54
  function matchPathname(routePath, pathname) {
47
55
  const routeSegments = trimPathSegments(routePath);
48
56
  const pathSegments = trimPathSegments(pathname);
57
+ const lastRouteSegment = routeSegments[routeSegments.length - 1];
58
+ if (lastRouteSegment && isWildcardSegment(lastRouteSegment)) {
59
+ const staticSegments = routeSegments.slice(0, -1);
60
+ if (pathSegments.length < staticSegments.length) return null;
61
+ const params = {};
62
+ for (let index = 0; index < staticSegments.length; index += 1) {
63
+ const routeSegment = staticSegments[index];
64
+ const pathSegment = pathSegments[index];
65
+ if (!routeSegment || pathSegment === void 0) return null;
66
+ if (routeSegment.startsWith(":")) {
67
+ params[routeSegment.slice(1)] = decodeURIComponent(pathSegment);
68
+ continue;
69
+ }
70
+ if (routeSegment !== pathSegment) return null;
71
+ }
72
+ const remaining = pathSegments.slice(staticSegments.length).map(decodeURIComponent).join("/");
73
+ const paramName = getWildcardParamName(lastRouteSegment);
74
+ if (paramName) params[paramName] = remaining;
75
+ return params;
76
+ }
49
77
  if (routeSegments.length !== pathSegments.length) return null;
50
78
  const params = {};
51
79
  for (let index = 0; index < routeSegments.length; index += 1) {
@@ -63,6 +91,8 @@ function matchPathname(routePath, pathname) {
63
91
  function matchPrefixPathname(routePath, pathname) {
64
92
  const routeSegments = trimPathSegments(routePath);
65
93
  const pathSegments = trimPathSegments(pathname);
94
+ const lastRouteSegment = routeSegments[routeSegments.length - 1];
95
+ if (lastRouteSegment && isWildcardSegment(lastRouteSegment)) return matchPathname(routePath, pathname);
66
96
  if (routeSegments.length > pathSegments.length) return null;
67
97
  const params = {};
68
98
  for (let index = 0; index < routeSegments.length; index += 1) {
@@ -78,17 +108,29 @@ function matchPrefixPathname(routePath, pathname) {
78
108
  return params;
79
109
  }
80
110
  function extractRouteLikeParams(pathPattern, pathname) {
81
- return matchPrefixPathname(pathPattern, pathname) ?? matchPathname(pathPattern, pathname);
111
+ const prefixMatch = matchPrefixPathname(pathPattern, pathname);
112
+ if (prefixMatch) return prefixMatch;
113
+ const routeSegments = trimPathSegments(pathPattern);
114
+ const lastSegment = routeSegments[routeSegments.length - 1];
115
+ if (lastSegment && isWildcardSegment(lastSegment)) return null;
116
+ return matchPathname(pathPattern, pathname);
117
+ }
118
+ function segmentRank(segment) {
119
+ if (isWildcardSegment(segment)) return -1;
120
+ if (segment.startsWith(":")) return 0;
121
+ return 1;
82
122
  }
83
123
  function comparePathSpecificity(left, right) {
84
124
  const leftSegments = trimPathSegments(left);
85
125
  const rightSegments = trimPathSegments(right);
126
+ const leftHasWildcard = leftSegments.length > 0 && isWildcardSegment(leftSegments[leftSegments.length - 1] ?? "");
127
+ if (leftHasWildcard !== (rightSegments.length > 0 && isWildcardSegment(rightSegments[rightSegments.length - 1] ?? ""))) return leftHasWildcard ? 1 : -1;
86
128
  if (leftSegments.length !== rightSegments.length) return rightSegments.length - leftSegments.length;
87
129
  for (let index = 0; index < leftSegments.length; index += 1) {
88
130
  const leftSegment = leftSegments[index] ?? "";
89
131
  const rightSegment = rightSegments[index] ?? "";
90
- const leftRank = leftSegment.startsWith(":") ? 0 : 1;
91
- const rightRank = rightSegment.startsWith(":") ? 0 : 1;
132
+ const leftRank = segmentRank(leftSegment);
133
+ const rightRank = segmentRank(rightSegment);
92
134
  if (leftRank !== rightRank) return rightRank - leftRank;
93
135
  if (leftRank === 1 && leftSegment.length !== rightSegment.length) return rightSegment.length - leftSegment.length;
94
136
  }
@@ -43,9 +43,37 @@ function trimPathSegments(value) {
43
43
  if (value === "/") return [];
44
44
  return value.replace(/^\/+|\/+$/g, "").split("/").filter(Boolean);
45
45
  }
46
+ function isWildcardSegment(segment) {
47
+ return segment.startsWith("*");
48
+ }
49
+ function getWildcardParamName(segment) {
50
+ if (segment === "*") return null;
51
+ if (segment.startsWith("*")) return segment.slice(1);
52
+ return null;
53
+ }
46
54
  function matchPathname(routePath, pathname) {
47
55
  const routeSegments = trimPathSegments(routePath);
48
56
  const pathSegments = trimPathSegments(pathname);
57
+ const lastRouteSegment = routeSegments[routeSegments.length - 1];
58
+ if (lastRouteSegment && isWildcardSegment(lastRouteSegment)) {
59
+ const staticSegments = routeSegments.slice(0, -1);
60
+ if (pathSegments.length < staticSegments.length) return null;
61
+ const params = {};
62
+ for (let index = 0; index < staticSegments.length; index += 1) {
63
+ const routeSegment = staticSegments[index];
64
+ const pathSegment = pathSegments[index];
65
+ if (!routeSegment || pathSegment === void 0) return null;
66
+ if (routeSegment.startsWith(":")) {
67
+ params[routeSegment.slice(1)] = decodeURIComponent(pathSegment);
68
+ continue;
69
+ }
70
+ if (routeSegment !== pathSegment) return null;
71
+ }
72
+ const remaining = pathSegments.slice(staticSegments.length).map(decodeURIComponent).join("/");
73
+ const paramName = getWildcardParamName(lastRouteSegment);
74
+ if (paramName) params[paramName] = remaining;
75
+ return params;
76
+ }
49
77
  if (routeSegments.length !== pathSegments.length) return null;
50
78
  const params = {};
51
79
  for (let index = 0; index < routeSegments.length; index += 1) {
@@ -63,6 +91,8 @@ function matchPathname(routePath, pathname) {
63
91
  function matchPrefixPathname(routePath, pathname) {
64
92
  const routeSegments = trimPathSegments(routePath);
65
93
  const pathSegments = trimPathSegments(pathname);
94
+ const lastRouteSegment = routeSegments[routeSegments.length - 1];
95
+ if (lastRouteSegment && isWildcardSegment(lastRouteSegment)) return matchPathname(routePath, pathname);
66
96
  if (routeSegments.length > pathSegments.length) return null;
67
97
  const params = {};
68
98
  for (let index = 0; index < routeSegments.length; index += 1) {
@@ -78,17 +108,29 @@ function matchPrefixPathname(routePath, pathname) {
78
108
  return params;
79
109
  }
80
110
  function extractRouteLikeParams(pathPattern, pathname) {
81
- return matchPrefixPathname(pathPattern, pathname) ?? matchPathname(pathPattern, pathname);
111
+ const prefixMatch = matchPrefixPathname(pathPattern, pathname);
112
+ if (prefixMatch) return prefixMatch;
113
+ const routeSegments = trimPathSegments(pathPattern);
114
+ const lastSegment = routeSegments[routeSegments.length - 1];
115
+ if (lastSegment && isWildcardSegment(lastSegment)) return null;
116
+ return matchPathname(pathPattern, pathname);
117
+ }
118
+ function segmentRank(segment) {
119
+ if (isWildcardSegment(segment)) return -1;
120
+ if (segment.startsWith(":")) return 0;
121
+ return 1;
82
122
  }
83
123
  function comparePathSpecificity(left, right) {
84
124
  const leftSegments = trimPathSegments(left);
85
125
  const rightSegments = trimPathSegments(right);
126
+ const leftHasWildcard = leftSegments.length > 0 && isWildcardSegment(leftSegments[leftSegments.length - 1] ?? "");
127
+ if (leftHasWildcard !== (rightSegments.length > 0 && isWildcardSegment(rightSegments[rightSegments.length - 1] ?? ""))) return leftHasWildcard ? 1 : -1;
86
128
  if (leftSegments.length !== rightSegments.length) return rightSegments.length - leftSegments.length;
87
129
  for (let index = 0; index < leftSegments.length; index += 1) {
88
130
  const leftSegment = leftSegments[index] ?? "";
89
131
  const rightSegment = rightSegments[index] ?? "";
90
- const leftRank = leftSegment.startsWith(":") ? 0 : 1;
91
- const rightRank = rightSegment.startsWith(":") ? 0 : 1;
132
+ const leftRank = segmentRank(leftSegment);
133
+ const rightRank = segmentRank(rightSegment);
92
134
  if (leftRank !== rightRank) return rightRank - leftRank;
93
135
  if (leftRank === 1 && leftSegment.length !== rightSegment.length) return rightSegment.length - leftSegment.length;
94
136
  }
@@ -1,4 +1,4 @@
1
- import { t as INTERNAL_REQUEST_HEADER } from "./internal-transport-dsMykcNK.mjs";
1
+ import { t as INTERNAL_REQUEST_HEADER } from "./internal-transport-ceutGxl7.mjs";
2
2
  //#region src/server/internal-requests.ts
3
3
  async function parseInternalRequestBody(request) {
4
4
  if ((request.headers.get("content-type") ?? "").includes("application/json")) return await request.json();
@@ -1,4 +1,4 @@
1
- const require_internal_transport = require("./internal-transport-DR0r68ff.js");
1
+ const require_internal_transport = require("./internal-transport-Er_DZe-u.js");
2
2
  //#region src/server/internal-requests.ts
3
3
  async function parseInternalRequestBody(request) {
4
4
  if ((request.headers.get("content-type") ?? "").includes("application/json")) return await request.json();
package/dist/server.js CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_internal_transport = require("./internal-transport-DR0r68ff.js");
3
- const require_request_headers = require("./request-headers-ZPR3TQs3.js");
2
+ const require_internal_transport = require("./internal-transport-Er_DZe-u.js");
3
+ const require_request_headers = require("./request-headers-CpcQCSrb.js");
4
4
  //#region src/server/index.ts
5
5
  let rscRendererPromise;
6
6
  function createServer(options = {}) {
@@ -16,8 +16,8 @@ function createServer(options = {}) {
16
16
  return contextValue;
17
17
  }
18
18
  try {
19
- if (url.pathname === "/_litzjs/resource") return handleResourceRequest(request, manifest.resources ?? [], getContext);
20
- if (url.pathname === "/_litzjs/route" || url.pathname === "/_litzjs/action") return handleRouteRequest(request, manifest.routes ?? [], getContext);
19
+ if (url.pathname === "/_litzjs/resource") return await handleResourceRequest(request, manifest.resources ?? [], getContext);
20
+ if (url.pathname === "/_litzjs/route" || url.pathname === "/_litzjs/action") return await handleRouteRequest(request, manifest.routes ?? [], getContext);
21
21
  const apiResponse = await handleApiRequest(request, manifest.apiRoutes ?? [], getContext);
22
22
  if (apiResponse) return apiResponse;
23
23
  if (request.method === "GET" || request.method === "HEAD") {
package/dist/server.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { a as matchPathname, i as extractRouteLikeParams, s as trimPathSegments } from "./internal-transport-dsMykcNK.mjs";
2
- import { n as parseInternalRequestBody, t as createInternalHandlerHeaders } from "./request-headers-DepZ5tjg.mjs";
1
+ import { a as matchPathname, i as extractRouteLikeParams, s as trimPathSegments } from "./internal-transport-ceutGxl7.mjs";
2
+ import { n as parseInternalRequestBody, t as createInternalHandlerHeaders } from "./request-headers-B-mkIVuc.mjs";
3
3
  //#region src/server/index.ts
4
4
  let rscRendererPromise;
5
5
  function createServer(options = {}) {
@@ -15,8 +15,8 @@ function createServer(options = {}) {
15
15
  return contextValue;
16
16
  }
17
17
  try {
18
- if (url.pathname === "/_litzjs/resource") return handleResourceRequest(request, manifest.resources ?? [], getContext);
19
- if (url.pathname === "/_litzjs/route" || url.pathname === "/_litzjs/action") return handleRouteRequest(request, manifest.routes ?? [], getContext);
18
+ if (url.pathname === "/_litzjs/resource") return await handleResourceRequest(request, manifest.resources ?? [], getContext);
19
+ if (url.pathname === "/_litzjs/route" || url.pathname === "/_litzjs/action") return await handleRouteRequest(request, manifest.routes ?? [], getContext);
20
20
  const apiResponse = await handleApiRequest(request, manifest.apiRoutes ?? [], getContext);
21
21
  if (apiResponse) return apiResponse;
22
22
  if (request.method === "GET" || request.method === "HEAD") {
package/dist/vite.d.mts CHANGED
@@ -1,12 +1,14 @@
1
1
  /// <reference types="node" />
2
+ import { RscPluginOptions } from "@vitejs/plugin-rsc";
2
3
  import * as fs from "node:fs";
3
4
  import * as http from "node:http";
4
- import { Agent, ClientRequest, ClientRequestArgs, OutgoingHttpHeaders } from "node:http";
5
+ import { Agent, ClientRequest, ClientRequestArgs, IncomingMessage as IncomingMessage$1, OutgoingHttpHeaders, ServerResponse } from "node:http";
5
6
  import { Http2SecureServer } from "node:http2";
6
7
  import { EventEmitter } from "node:events";
7
8
  import { Server as Server$1, ServerOptions as ServerOptions$1 } from "node:https";
8
9
  import * as net from "node:net";
9
10
  import { Duplex, DuplexOptions, Stream } from "node:stream";
11
+ import esbuild from "esbuild";
10
12
  import { SecureContextOptions } from "node:tls";
11
13
  import { URL as URL$1 } from "node:url";
12
14
  import { ZlibOptions } from "node:zlib";
@@ -6146,27 +6148,6 @@ interface TransformOptions$1 extends BindingEnhancedTransformOptions {}
6146
6148
  * @category Utilities
6147
6149
  */
6148
6150
  //#endregion
6149
- //#region node_modules/esbuild/lib/main.d.ts
6150
- // Note: These declarations exist to avoid type errors when you omit "dom" from
6151
- // "lib" in your "tsconfig.json" file. TypeScript confusingly declares the
6152
- // global "WebAssembly" type in "lib.dom.d.ts" even though it has nothing to do
6153
- // with the browser DOM and is present in many non-browser JavaScript runtimes
6154
- // (e.g. node and deno). Declaring it here allows esbuild's API to be used in
6155
- // these scenarios.
6156
- //
6157
- // There's an open issue about getting this problem corrected (although these
6158
- // declarations will need to remain even if this is fixed for backward
6159
- // compatibility with older TypeScript versions):
6160
- //
6161
- // https://github.com/microsoft/TypeScript-DOM-lib-generator/issues/826
6162
- //
6163
- declare global {
6164
- namespace WebAssembly {
6165
- interface Module {}
6166
- }
6167
- interface URL {}
6168
- }
6169
- //#endregion
6170
6151
  //#region node_modules/vite/types/internal/esbuildOptions.d.ts
6171
6152
  /* eslint-enable @typescript-eslint/ban-ts-comment */
6172
6153
  type EsbuildTarget = string | string[];
@@ -10032,12 +10013,67 @@ type LitzPluginOptions = {
10032
10013
  api?: string[];
10033
10014
  resources?: string[];
10034
10015
  server?: string;
10016
+ embedAssets?: boolean;
10017
+ rsc?: Omit<RscPluginOptions, "entries" | "serverHandler">;
10018
+ };
10019
+ type DiscoveredRoute = {
10020
+ id: string;
10021
+ path: string;
10022
+ modulePath: string;
10023
+ };
10024
+ type DiscoveredLayout = {
10025
+ id: string;
10026
+ path: string;
10027
+ modulePath: string;
10035
10028
  };
10029
+ type DiscoveredResource = {
10030
+ path: string;
10031
+ modulePath: string;
10032
+ hasLoader: boolean;
10033
+ hasAction: boolean;
10034
+ hasComponent: boolean;
10035
+ };
10036
+ type DiscoveredApiRoute = {
10037
+ path: string;
10038
+ modulePath: string;
10039
+ };
10040
+ /**
10041
+ * Creates the Litz Vite plugin array. Returns the `@vitejs/plugin-rsc` plugins
10042
+ * plus the core Litz plugin. The mutable state variables below are populated
10043
+ * during `configResolved` and kept in sync during dev via file watching.
10044
+ */
10036
10045
  declare function litz(options?: LitzPluginOptions): Plugin[];
10046
+ declare function discoverAllManifests(root: string, routePatterns: string[], resourcePatterns: string[], apiPatterns: string[]): Promise<{
10047
+ routeManifest: DiscoveredRoute[];
10048
+ layoutManifest: DiscoveredLayout[];
10049
+ resourceManifest: DiscoveredResource[];
10050
+ apiManifest: DiscoveredApiRoute[];
10051
+ }>;
10037
10052
  declare function discoverServerEntry(root: string, configuredPath?: string): Promise<string | null>;
10053
+ declare function discoverRouteFromFile(root: string, file: string): Promise<DiscoveredRoute | null>;
10054
+ declare function discoverLayoutFromFile(root: string, file: string): Promise<DiscoveredLayout | null>;
10055
+ declare function discoverResourceFromFile(root: string, file: string): Promise<DiscoveredResource | null>;
10056
+ declare function discoverApiRouteFromFile(root: string, file: string): Promise<DiscoveredApiRoute | null>;
10057
+ declare function handleLitzResourceRequest(server: ViteDevServer, manifest: DiscoveredResource[], request: IncomingMessage$1, response: ServerResponse, next: Connect.NextFunction): Promise<void>;
10058
+ declare function handleLitzRouteRequest(server: ViteDevServer, manifest: DiscoveredRoute[], request: IncomingMessage$1, response: ServerResponse, next: Connect.NextFunction): Promise<void>;
10059
+ declare function handleLitzApiRequest(server: ViteDevServer, manifest: DiscoveredApiRoute[], request: IncomingMessage$1, response: ServerResponse, next: Connect.NextFunction): Promise<void>;
10060
+ declare function cleanupRscPluginArtifacts(serverOutDir: string): void;
10061
+ /**
10062
+ * Strips the default export from the bundled RSC server module and rebinds it
10063
+ * to `__litzjsServerHandler` so the wrapper can re-export it. Uses the
10064
+ * TypeScript compiler API to handle four export patterns:
10065
+ *
10066
+ * 1. Named export lists — `export { handler as default }` → extract the binding
10067
+ * 2. Export assignments — `export default expr` → `const __litzjsServerHandler = expr`
10068
+ * 3. Default function declarations — strip modifiers, keep name, set binding
10069
+ * 4. Default class declarations — same treatment as functions
10070
+ *
10071
+ * If no handler was directly declared (pattern 1), a final `const` binding is
10072
+ * appended from the recorded default expression.
10073
+ */
10038
10074
  declare function transformServerModuleSource(serverModuleSource: string): {
10039
10075
  source: string;
10040
10076
  handlerName: string;
10041
10077
  };
10042
10078
  //#endregion
10043
- export { LitzPluginOptions, discoverServerEntry, litz, transformServerModuleSource };
10079
+ export { LitzPluginOptions, cleanupRscPluginArtifacts, discoverAllManifests, discoverApiRouteFromFile, discoverLayoutFromFile, discoverResourceFromFile, discoverRouteFromFile, discoverServerEntry, handleLitzApiRequest, handleLitzResourceRequest, handleLitzRouteRequest, litz, transformServerModuleSource };
package/dist/vite.d.ts CHANGED
@@ -1,12 +1,14 @@
1
1
  /// <reference types="node" />
2
+ import { RscPluginOptions } from "@vitejs/plugin-rsc";
2
3
  import * as http from "node:http";
3
- import { Agent, ClientRequest, ClientRequestArgs, OutgoingHttpHeaders } from "node:http";
4
+ import { Agent, ClientRequest, ClientRequestArgs, IncomingMessage as IncomingMessage$1, OutgoingHttpHeaders, ServerResponse } from "node:http";
4
5
  import { Http2SecureServer } from "node:http2";
5
6
  import * as fs from "node:fs";
6
7
  import { EventEmitter } from "node:events";
7
8
  import { Server as Server$1, ServerOptions as ServerOptions$1 } from "node:https";
8
9
  import * as net from "node:net";
9
10
  import { Duplex, DuplexOptions, Stream } from "node:stream";
11
+ import esbuild from "esbuild";
10
12
  import { SecureContextOptions } from "node:tls";
11
13
  import { URL as URL$1 } from "node:url";
12
14
  import { ZlibOptions } from "node:zlib";
@@ -6146,27 +6148,6 @@ interface TransformOptions$1 extends BindingEnhancedTransformOptions {}
6146
6148
  * @category Utilities
6147
6149
  */
6148
6150
  //#endregion
6149
- //#region node_modules/esbuild/lib/main.d.ts
6150
- // Note: These declarations exist to avoid type errors when you omit "dom" from
6151
- // "lib" in your "tsconfig.json" file. TypeScript confusingly declares the
6152
- // global "WebAssembly" type in "lib.dom.d.ts" even though it has nothing to do
6153
- // with the browser DOM and is present in many non-browser JavaScript runtimes
6154
- // (e.g. node and deno). Declaring it here allows esbuild's API to be used in
6155
- // these scenarios.
6156
- //
6157
- // There's an open issue about getting this problem corrected (although these
6158
- // declarations will need to remain even if this is fixed for backward
6159
- // compatibility with older TypeScript versions):
6160
- //
6161
- // https://github.com/microsoft/TypeScript-DOM-lib-generator/issues/826
6162
- //
6163
- declare global {
6164
- namespace WebAssembly {
6165
- interface Module {}
6166
- }
6167
- interface URL {}
6168
- }
6169
- //#endregion
6170
6151
  //#region node_modules/vite/types/internal/esbuildOptions.d.ts
6171
6152
  /* eslint-enable @typescript-eslint/ban-ts-comment */
6172
6153
  type EsbuildTarget = string | string[];
@@ -10032,12 +10013,67 @@ type LitzPluginOptions = {
10032
10013
  api?: string[];
10033
10014
  resources?: string[];
10034
10015
  server?: string;
10016
+ embedAssets?: boolean;
10017
+ rsc?: Omit<RscPluginOptions, "entries" | "serverHandler">;
10018
+ };
10019
+ type DiscoveredRoute = {
10020
+ id: string;
10021
+ path: string;
10022
+ modulePath: string;
10023
+ };
10024
+ type DiscoveredLayout = {
10025
+ id: string;
10026
+ path: string;
10027
+ modulePath: string;
10035
10028
  };
10029
+ type DiscoveredResource = {
10030
+ path: string;
10031
+ modulePath: string;
10032
+ hasLoader: boolean;
10033
+ hasAction: boolean;
10034
+ hasComponent: boolean;
10035
+ };
10036
+ type DiscoveredApiRoute = {
10037
+ path: string;
10038
+ modulePath: string;
10039
+ };
10040
+ /**
10041
+ * Creates the Litz Vite plugin array. Returns the `@vitejs/plugin-rsc` plugins
10042
+ * plus the core Litz plugin. The mutable state variables below are populated
10043
+ * during `configResolved` and kept in sync during dev via file watching.
10044
+ */
10036
10045
  declare function litz(options?: LitzPluginOptions): Plugin[];
10046
+ declare function discoverAllManifests(root: string, routePatterns: string[], resourcePatterns: string[], apiPatterns: string[]): Promise<{
10047
+ routeManifest: DiscoveredRoute[];
10048
+ layoutManifest: DiscoveredLayout[];
10049
+ resourceManifest: DiscoveredResource[];
10050
+ apiManifest: DiscoveredApiRoute[];
10051
+ }>;
10037
10052
  declare function discoverServerEntry(root: string, configuredPath?: string): Promise<string | null>;
10053
+ declare function discoverRouteFromFile(root: string, file: string): Promise<DiscoveredRoute | null>;
10054
+ declare function discoverLayoutFromFile(root: string, file: string): Promise<DiscoveredLayout | null>;
10055
+ declare function discoverResourceFromFile(root: string, file: string): Promise<DiscoveredResource | null>;
10056
+ declare function discoverApiRouteFromFile(root: string, file: string): Promise<DiscoveredApiRoute | null>;
10057
+ declare function handleLitzResourceRequest(server: ViteDevServer, manifest: DiscoveredResource[], request: IncomingMessage$1, response: ServerResponse, next: Connect.NextFunction): Promise<void>;
10058
+ declare function handleLitzRouteRequest(server: ViteDevServer, manifest: DiscoveredRoute[], request: IncomingMessage$1, response: ServerResponse, next: Connect.NextFunction): Promise<void>;
10059
+ declare function handleLitzApiRequest(server: ViteDevServer, manifest: DiscoveredApiRoute[], request: IncomingMessage$1, response: ServerResponse, next: Connect.NextFunction): Promise<void>;
10060
+ declare function cleanupRscPluginArtifacts(serverOutDir: string): void;
10061
+ /**
10062
+ * Strips the default export from the bundled RSC server module and rebinds it
10063
+ * to `__litzjsServerHandler` so the wrapper can re-export it. Uses the
10064
+ * TypeScript compiler API to handle four export patterns:
10065
+ *
10066
+ * 1. Named export lists — `export { handler as default }` → extract the binding
10067
+ * 2. Export assignments — `export default expr` → `const __litzjsServerHandler = expr`
10068
+ * 3. Default function declarations — strip modifiers, keep name, set binding
10069
+ * 4. Default class declarations — same treatment as functions
10070
+ *
10071
+ * If no handler was directly declared (pattern 1), a final `const` binding is
10072
+ * appended from the recorded default expression.
10073
+ */
10038
10074
  declare function transformServerModuleSource(serverModuleSource: string): {
10039
10075
  source: string;
10040
10076
  handlerName: string;
10041
10077
  };
10042
10078
  //#endregion
10043
- export { LitzPluginOptions, discoverServerEntry, litz, transformServerModuleSource };
10079
+ export { LitzPluginOptions, cleanupRscPluginArtifacts, discoverAllManifests, discoverApiRouteFromFile, discoverLayoutFromFile, discoverResourceFromFile, discoverRouteFromFile, discoverServerEntry, handleLitzApiRequest, handleLitzResourceRequest, handleLitzRouteRequest, litz, transformServerModuleSource };