Skip to content

Commit 63e18a7

Browse files
committed
Reconcile capability surface with main's API typegen
Rebasing onto main crossed the capability work with the API-route typegen and declaration rename that landed there: - `pracht dev`'s watch-mode typegen now passes `capabilitiesOut` (required since capability declarations were added) and treats the generated capability declaration as a generated path, so writing it does not retrigger regeneration. - Export `DEFAULT_CAPABILITIES_OUT` alongside the other typegen defaults. - Update the capability typegen test to the renamed declaration output (`src/pracht.d.ts`, not `src/pracht-routes.d.ts`). - Reformat `FormProps` after merging the capability and Standard Schema form props.
1 parent 6e9fa6a commit 63e18a7

4 files changed

Lines changed: 18 additions & 6 deletions

File tree

packages/cli/src/commands/dev.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ import { collectAppGraph } from "../app-graph.js";
88
import { formatDevBanner, supportsColor } from "../dev-banner.js";
99
import { readProjectConfig, resolveProjectPath } from "../project.js";
1010
import { requirePositiveInteger } from "../utils.js";
11-
import { DEFAULT_DECLARATION_OUT, DEFAULT_RUNTIME_OUT, runTypegen } from "./typegen.js";
11+
import {
12+
DEFAULT_CAPABILITIES_OUT,
13+
DEFAULT_DECLARATION_OUT,
14+
DEFAULT_RUNTIME_OUT,
15+
runTypegen,
16+
} from "./typegen.js";
1217

1318
export default defineCommand({
1419
meta: {
@@ -86,7 +91,11 @@ function watchGeneratedRouteTypes(server: ViteDevServer, root: string): boolean
8691
return false;
8792
}
8893

89-
const generatedPaths = new Set([declarationPath, resolve(root, DEFAULT_RUNTIME_OUT)]);
94+
const generatedPaths = new Set([
95+
declarationPath,
96+
resolve(root, DEFAULT_RUNTIME_OUT),
97+
resolve(root, DEFAULT_CAPABILITIES_OUT),
98+
]);
9099
const appFilePath = resolveProjectPath(root, readProjectConfig(root).appFile);
91100
let queued: ReturnType<typeof setTimeout> | null = null;
92101
let running = false;
@@ -100,6 +109,7 @@ function watchGeneratedRouteTypes(server: ViteDevServer, root: string): boolean
100109
running = true;
101110
try {
102111
await runTypegen({
112+
capabilitiesOut: DEFAULT_CAPABILITIES_OUT,
103113
check: false,
104114
declarationOut: DEFAULT_DECLARATION_OUT,
105115
root,

packages/cli/src/commands/typegen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { runInspect, type InspectReport } from "./inspect.js";
1414
// the program, so its `Register` augmentation never applies.
1515
export const DEFAULT_DECLARATION_OUT = "src/pracht.d.ts";
1616
export const DEFAULT_RUNTIME_OUT = "src/pracht-routes.ts";
17-
const DEFAULT_CAPABILITIES_OUT = "src/pracht-capabilities.d.ts";
17+
export const DEFAULT_CAPABILITIES_OUT = "src/pracht-capabilities.d.ts";
1818
const LEGACY_DECLARATION_OUT = "src/pracht-routes.d.ts";
1919

2020
type RouteEntry = NonNullable<InspectReport["routes"]>[number];

packages/cli/test/pracht-cli.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ export function Component() {
650650

651651
expect(result).toMatchObject({
652652
capabilities: 2,
653-
files: ["src/pracht-routes.d.ts", "src/pracht-routes.ts", "src/pracht-capabilities.d.ts"],
653+
files: ["src/pracht.d.ts", "src/pracht-routes.ts", "src/pracht-capabilities.d.ts"],
654654
ok: true,
655655
});
656656
expect(declaration).toContain('declare module "@pracht/core"');

packages/framework/src/runtime-hooks.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,10 @@ type CapabilityFormResult<TName extends string> = TName extends RegisteredCapabi
5959
? CapabilityEnvelope<CapabilityOutputFor<TName>>
6060
: CapabilityEnvelope;
6161

62-
export interface FormProps<TName extends string = string>
63-
extends Omit<JSX.HTMLAttributes<HTMLFormElement>, "action" | "method"> {
62+
export interface FormProps<TName extends string = string> extends Omit<
63+
JSX.HTMLAttributes<HTMLFormElement>,
64+
"action" | "method"
65+
> {
6466
/**
6567
* Form action. Autocompletes API route paths registered by `pracht typegen`
6668
* while still accepting any URL string (dynamic segments must be

0 commit comments

Comments
 (0)