fondu 0.9.1 → 0.9.3

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.
@@ -3,7 +3,7 @@ import type { Context, MiddlewareHandler } from 'hono';
3
3
  /** https, directly or behind a proxy that says so */
4
4
  export declare const isSecure: (c: Context) => boolean;
5
5
  /** Flash data for the next page (`page.flash` / `usePage().flash`, Inertia's `flash` event). */
6
- export declare function flash(c: Context, data: Partial<FlashData> & Record<string, unknown>): void;
6
+ export declare function flash(c: Context, data: Partial<FlashData>): void;
7
7
  /** Validation errors for the next page (its `errors` prop). */
8
8
  export declare function flashErrors(c: Context, errors: Record<string, unknown>): void;
9
9
  /** The next page clears the browser history Inertia kept (and encrypted): after signing out, for example. */
@@ -9,17 +9,21 @@ type Shareable<T> = {
9
9
  [K in keyof T]?: T[K] | (() => T[K] | Promise<T[K]>);
10
10
  };
11
11
  /** Props every page of this request gets (a middleware calls it: the signed-in user…). */
12
- export declare function share(c: Context, props: Shareable<SharedPageProps> & Record<string, unknown>): void;
12
+ export declare function share(c: Context, props: Shareable<SharedPageProps>): void;
13
13
  type PageName = [keyof Pages] extends [never] ? string : Extract<keyof Pages, string>;
14
14
  type ComponentProps<N> = N extends keyof Pages ? Pages[N] extends {
15
15
  default: (...args: infer A) => unknown;
16
16
  } ? A extends [infer P, ...unknown[]] ? P : Record<string, never> : Record<string, unknown> : Record<string, unknown>;
17
+ /** the props a page names: not an index signature (a page without props takes `Record<string, never>`) */
18
+ type Named<P> = keyof {
19
+ [K in keyof P as string extends K ? never : number extends K ? never : K]: 0;
20
+ };
17
21
  /** shared props the page takes with the same type: `render` may leave them out (every page gets them) */
18
22
  type FromShared<P> = {
19
- [K in keyof P & keyof SharedPageProps]: SharedPageProps[K] extends P[K] ? K : never;
20
- }[keyof P & keyof SharedPageProps];
23
+ [K in Named<P> & keyof SharedPageProps]: SharedPageProps[K] extends P[K] ? K : never;
24
+ }[Named<P> & keyof SharedPageProps];
21
25
  /** a page prop named like a shared prop, of another type: it would hide the shared one from the layout */
22
- type Clashing<P> = string extends keyof SharedPageProps ? never : Exclude<keyof P & keyof SharedPageProps, FromShared<P>>;
26
+ type Clashing<P> = string extends keyof SharedPageProps ? never : Exclude<Named<P> & keyof SharedPageProps, FromShared<P>>;
23
27
  type ClashError = 'fondu: this page prop has the name of a shared prop (share()); rename it';
24
28
  /** what `render` takes: the component's props, less `errors` and the shared props it gets anyway (may still be given) */
25
29
  type OwnProps<N> = Omit<ComponentProps<N>, FromShared<ComponentProps<N>> | Clashing<ComponentProps<N>> | 'errors'> & Partial<Pick<ComponentProps<N>, FromShared<ComponentProps<N>>>> & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fondu",
3
- "version": "0.9.1",
3
+ "version": "0.9.3",
4
4
  "description": "A small meta-framework for full-stack React apps, built on Hono, Vite and Inertia. It runs on Bun, Cloudflare Workers and Node.",
5
5
  "keywords": [
6
6
  "bun",