@hamur/adapter-solid 0.0.2 → 0.0.4

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.
@@ -9,9 +9,9 @@ import type { $Fetch, FetchCheckedInput, FetchInputField } from "hamur/app";
9
9
  import type { StateKey } from "hamur/app";
10
10
  import type { HamurEvent } from "hamur/server";
11
11
  import type { LinkDefaults, LinkSlot, Navigation, UseLinkOptions } from "hamur/adapter";
12
- import type { ActionOptions, ActionRunner, PrefetchOn, Handler, AfterNavigateHook, BeforeNavigateHook, NavigateHook, NavigationBlocker, NavigationGuard, Blocker, ShouldBlock, UseBlockerOptions, SnapshotOptions } from "hamur/adapter";
12
+ import type { ActionOptions, ActionRunner, ActionValue, FailureOf, PrefetchOn, Handler, AfterNavigateHook, BeforeNavigateHook, NavigateHook, NavigationBlocker, NavigationGuard, Blocker, ShouldBlock, UseBlockerOptions, SnapshotOptions } from "hamur/adapter";
13
13
  import type { FieldsOf, HamurLinkProps } from "hamur/app";
14
- import type { ActionFailure, AppContext, FormSubmitArgs, PendingRun, PickFrom, RouteLocation, AsyncDataOptions, ClientRuntimeConfig, SiteConfig, ErrorPageProps, FetchData, AsyncDataStatus, HeadInput, HeadSafeInput, SeoMetaInput, UseCookieOptions, HamurError } from "hamur/app";
14
+ import type { AppContext, FormSubmitArgs, PendingRun, PickFrom, RouteLocation, AsyncDataOptions, ClientRuntimeConfig, SiteConfig, ErrorPageProps, FetchData, AsyncDataStatus, HeadInput, HeadSafeInput, SeoMetaInput, UseCookieOptions, HamurError } from "hamur/app";
15
15
  import type { RouteLoaderData, UseDataArgs, AsyncDataHandler, ErrorBoundaryFallbackProps, FetchRequest, GetCachedData, CheckedTarget, NavigationState, RouteValue, RouterApi } from "hamur/adapter";
16
16
  export { addRouteMiddleware, clearError, disableScrollHandling, forbidden, navigateTo, notFound, permanentRedirect, refreshCookie, setPageLayout, showError, unauthorized, } from "hamur/app";
17
17
  export { defineLazyHydrationComponent } from "./lazy-hydration.ts";
@@ -140,10 +140,10 @@ export declare function useAction<I, O>(fn: Handler<I, O>, options?: ActionOptio
140
140
  instance?: string | number;
141
141
  }): {
142
142
  run: ActionRunner<I, O>["run"];
143
- state: Accessor<O | undefined>;
143
+ state: Accessor<ActionValue<O> | undefined>;
144
144
  pending: Accessor<boolean>;
145
145
  error: Accessor<HamurError | undefined>;
146
- failure: Accessor<ActionFailure | undefined>;
146
+ failure: Accessor<FailureOf<O> | undefined>;
147
147
  reset(): void;
148
148
  };
149
149
  export declare function ClientOnly(props: {
@@ -321,7 +321,7 @@ export declare function useCookie<T = string>(name: string, options?: Omit<UseCo
321
321
  export interface UseAsyncDataOptions<T = unknown, R = T, K extends keyof T & string = never, D = T> extends Omit<AsyncDataOptions<T, R, D>, "pick"> {
322
322
  /** Accessors whose change re-runs the handler. `false` is accepted and does nothing: nothing watches implicitly. */
323
323
  watch?: ReadonlyArray<() => unknown> | false;
324
- getCachedData?: GetCachedData<T>;
324
+ getCachedData?: GetCachedData<NoInfer<T>>;
325
325
  /** Top-level keys of an object result to keep. */
326
326
  pick?: readonly K[];
327
327
  }
@@ -345,10 +345,10 @@ export declare function useAsyncData<I, R, T = R, K extends keyof T & string = n
345
345
  default: () => D;
346
346
  }): UseAsyncDataResult<PickFrom<T, K>, D>;
347
347
  export declare function useAsyncData<I, R, T = R, K extends keyof T & string = never>(fn: Handler<I, R>, input?: NoInfer<I> | Accessor<NoInfer<I>>, options?: UseAsyncDataOptions<T, R, K, undefined>): UseAsyncDataResult<PickFrom<T, K>>;
348
- export declare function useAsyncData<T = unknown, R = T, K extends keyof T & string = never, D = T>(key: string | Accessor<string>, handler: AsyncDataHandler<R>, options: UseAsyncDataOptions<T, R, K, D> & {
348
+ export declare function useAsyncData<R, T = R, K extends keyof T & string = never, D = T>(key: string | Accessor<string>, handler: AsyncDataHandler<R>, options: UseAsyncDataOptions<T, R, K, D> & {
349
349
  default: () => D;
350
350
  }): UseAsyncDataResult<PickFrom<T, K>, D>;
351
- export declare function useAsyncData<T = unknown, R = T, K extends keyof T & string = never>(key: string | Accessor<string>, handler: AsyncDataHandler<R>, options?: UseAsyncDataOptions<T, R, K, undefined>): UseAsyncDataResult<PickFrom<T, K>>;
351
+ export declare function useAsyncData<R, T = R, K extends keyof T & string = never>(key: string | Accessor<string>, handler: AsyncDataHandler<R>, options?: UseAsyncDataOptions<T, R, K, undefined>): UseAsyncDataResult<PickFrom<T, K>>;
352
352
  /** What a literal `useFetch` call is checked against; any other call stays loose. */
353
353
  type FetchInput<X> = X extends {
354
354
  key: infer K extends string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hamur/adapter-solid",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -71,6 +71,6 @@
71
71
  "@solidjs/babel-plugin": "^2.0.3",
72
72
  "@babel/core": "^8.1.4",
73
73
  "@babel/preset-typescript": "^8.0.7",
74
- "hamur": "^0.0.2"
74
+ "hamur": ">=0.0.4 <0.1.0"
75
75
  }
76
76
  }
package/src/index.ts CHANGED
@@ -118,6 +118,8 @@ import type { LinkDefaults, LinkSlot, Navigation, UseLinkOptions } from "hamur/a
118
118
  import type {
119
119
  ActionOptions,
120
120
  ActionRunner,
121
+ ActionValue,
122
+ FailureOf,
121
123
  FormStatus,
122
124
  PrefetchOn,
123
125
  Handler,
@@ -135,7 +137,6 @@ import type {
135
137
  import type { FieldsOf, HamurLinkProps, HandlerFormInstance } from "hamur/app"
136
138
  import { linkPending } from "hamur/adapter"
137
139
  import type {
138
- ActionFailure,
139
140
  AppContext,
140
141
  FormSubmitArgs,
141
142
  PendingRun,
@@ -775,10 +776,10 @@ export function useAction<I, O>(
775
776
  options: ActionOptions<O> & { instance?: string | number } = {},
776
777
  ): {
777
778
  run: ActionRunner<I, O>["run"]
778
- state: Accessor<O | undefined>
779
+ state: Accessor<ActionValue<O> | undefined>
779
780
  pending: Accessor<boolean>
780
781
  error: Accessor<HamurError | undefined>
781
- failure: Accessor<ActionFailure | undefined>
782
+ failure: Accessor<FailureOf<O> | undefined>
782
783
  reset(): void
783
784
  } {
784
785
  const router = useRouter()
@@ -1619,7 +1620,7 @@ export interface UseAsyncDataOptions<T = unknown, R = T, K extends keyof T & str
1619
1620
  > {
1620
1621
  /** Accessors whose change re-runs the handler. `false` is accepted and does nothing: nothing watches implicitly. */
1621
1622
  watch?: ReadonlyArray<() => unknown> | false
1622
- getCachedData?: GetCachedData<T>
1623
+ getCachedData?: GetCachedData<NoInfer<T>>
1623
1624
  /** Top-level keys of an object result to keep. */
1624
1625
  pick?: readonly K[]
1625
1626
  }
@@ -1653,12 +1654,12 @@ export function useAsyncData<I, R, T = R, K extends keyof T & string = never>(
1653
1654
  input?: NoInfer<I> | Accessor<NoInfer<I>>,
1654
1655
  options?: UseAsyncDataOptions<T, R, K, undefined>,
1655
1656
  ): UseAsyncDataResult<PickFrom<T, K>>
1656
- export function useAsyncData<T = unknown, R = T, K extends keyof T & string = never, D = T>(
1657
+ export function useAsyncData<R, T = R, K extends keyof T & string = never, D = T>(
1657
1658
  key: string | Accessor<string>,
1658
1659
  handler: AsyncDataHandler<R>,
1659
1660
  options: UseAsyncDataOptions<T, R, K, D> & { default: () => D },
1660
1661
  ): UseAsyncDataResult<PickFrom<T, K>, D>
1661
- export function useAsyncData<T = unknown, R = T, K extends keyof T & string = never>(
1662
+ export function useAsyncData<R, T = R, K extends keyof T & string = never>(
1662
1663
  key: string | Accessor<string>,
1663
1664
  handler: AsyncDataHandler<R>,
1664
1665
  options?: UseAsyncDataOptions<T, R, K, undefined>,