@pylonsync/sdk 0.3.247 → 0.3.249
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/package.json +1 -1
- package/src/index.ts +27 -6
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -331,8 +331,11 @@ export interface RouteDefinition {
|
|
|
331
331
|
* NOT matched as navigable URLs — the host renders `not-found` for
|
|
332
332
|
* unmatched URLs (HTTP 404) and `error` on render failure (HTTP 500).
|
|
333
333
|
* `path` records the segment prefix the boundary covers (`/` for root).
|
|
334
|
+
* `"route"` is a form/method handler (`app/.../route.ts` exporting
|
|
335
|
+
* POST/PUT/PATCH/DELETE) — matched on its `path` for non-GET requests only,
|
|
336
|
+
* never rendered as a page.
|
|
334
337
|
*/
|
|
335
|
-
kind?: "page" | "not-found" | "error";
|
|
338
|
+
kind?: "page" | "not-found" | "error" | "route";
|
|
336
339
|
}
|
|
337
340
|
|
|
338
341
|
export function defineRoute(route: RouteDefinition): RouteDefinition {
|
|
@@ -506,8 +509,8 @@ export interface ManifestRoute {
|
|
|
506
509
|
auth?: string;
|
|
507
510
|
component?: string;
|
|
508
511
|
layouts?: string[];
|
|
509
|
-
/** "not-found" / "error"
|
|
510
|
-
kind?: "page" | "not-found" | "error";
|
|
512
|
+
/** "not-found" / "error" boundaries, or "route" form handlers; omitted for normal pages. */
|
|
513
|
+
kind?: "page" | "not-found" | "error" | "route";
|
|
511
514
|
}
|
|
512
515
|
|
|
513
516
|
export interface ManifestInputField {
|
|
@@ -669,8 +672,9 @@ export function routesToManifest(routes: RouteDefinition[]): ManifestRoute[] {
|
|
|
669
672
|
* ones at each depth — so the Rust matcher's first-match-wins
|
|
670
673
|
* lookup picks the right route.
|
|
671
674
|
*
|
|
672
|
-
*
|
|
673
|
-
*
|
|
675
|
+
* `not-found.tsx` / `error.tsx` boundaries are emitted as `kind`-tagged
|
|
676
|
+
* routes here; `loading.tsx` is resolved at render time by the SSR runtime
|
|
677
|
+
* (filesystem walk), so it needs no discovery entry.
|
|
674
678
|
*/
|
|
675
679
|
export async function discoverAppRoutes(opts?: {
|
|
676
680
|
appDir?: string;
|
|
@@ -719,8 +723,10 @@ export async function discoverAppRoutes(opts?: {
|
|
|
719
723
|
layouts: string[];
|
|
720
724
|
kind: "not-found" | "error";
|
|
721
725
|
};
|
|
726
|
+
type RouteHandlerHit = { segments: string[]; component: string };
|
|
722
727
|
const pages: PageHit[] = [];
|
|
723
728
|
const boundaries: BoundaryHit[] = [];
|
|
729
|
+
const routeHandlers: RouteHandlerHit[] = [];
|
|
724
730
|
|
|
725
731
|
// Resolve the first existing `<base>.{tsx,ts,jsx,js}` in `dir` and
|
|
726
732
|
// return it as a cwd-relative, extension-less module path (or null).
|
|
@@ -770,6 +776,12 @@ export async function discoverAppRoutes(opts?: {
|
|
|
770
776
|
kind: "error",
|
|
771
777
|
});
|
|
772
778
|
}
|
|
779
|
+
// Form/method handler (`route.ts` exporting POST/PUT/PATCH/DELETE). Matched
|
|
780
|
+
// on its path for non-GET requests only — never rendered, no layouts.
|
|
781
|
+
const routeHere = findModule(dir, "route");
|
|
782
|
+
if (routeHere) {
|
|
783
|
+
routeHandlers.push({ segments: [...segments], component: routeHere });
|
|
784
|
+
}
|
|
773
785
|
for (const e of entries) {
|
|
774
786
|
if (!e.isDirectory()) continue;
|
|
775
787
|
if (e.name.startsWith(".") || e.name === "node_modules") continue;
|
|
@@ -842,7 +854,16 @@ export async function discoverAppRoutes(opts?: {
|
|
|
842
854
|
kind: b.kind,
|
|
843
855
|
}));
|
|
844
856
|
|
|
845
|
-
|
|
857
|
+
// Form/method handlers. Keyed by the SAME path token form as pages
|
|
858
|
+
// (`:param` / `*catch-all`), matched by the host for non-GET methods only.
|
|
859
|
+
const routeRoutes: RouteDefinition[] = routeHandlers.map((r) => ({
|
|
860
|
+
path: segmentsToPath(r.segments),
|
|
861
|
+
mode: "ssr" as const,
|
|
862
|
+
component: r.component,
|
|
863
|
+
kind: "route" as const,
|
|
864
|
+
}));
|
|
865
|
+
|
|
866
|
+
return [...pageRoutes, ...boundaryRoutes, ...routeRoutes];
|
|
846
867
|
}
|
|
847
868
|
|
|
848
869
|
export function queriesToManifest(queries: QueryDefinition[]): ManifestQuery[] {
|