@hamur/adapter-preact 0.0.2 → 0.0.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.
- package/dist/types/src/index.d.ts +7 -7
- package/package.json +2 -2
- package/src/index.ts +8 -7
|
@@ -10,10 +10,10 @@ import type { HamurEvent } from "hamur/server";
|
|
|
10
10
|
import type { AppHooks, WebVitalMetric } from "hamur/app";
|
|
11
11
|
import type { AnnouncerActions, AnnouncerPoliteness, AnnouncerState, RouteAnnouncerActions, RouteAnnouncerPoliteness, RouteAnnouncerState, LoadingIndicatorActions, LoadingIndicatorProps, LoadingIndicatorOptions, LoadingIndicatorState, TimeInput } from "hamur/adapter";
|
|
12
12
|
import type { LinkDefaults, LinkSlot, UseLinkOptions } from "hamur/adapter";
|
|
13
|
-
import type { ActionOptions, ActionRunner, FormStatus, PrefetchOn, Handler, AfterNavigateHook, BeforeNavigateHook, NavigateHook, Navigation, NavigationBlocker, NavigationGuard, Blocker, ShouldBlock, UseBlockerOptions, SnapshotOptions } from "hamur/adapter";
|
|
13
|
+
import type { ActionOptions, ActionRunner, ActionValue, FailureOf, FormStatus, PrefetchOn, Handler, AfterNavigateHook, BeforeNavigateHook, NavigateHook, Navigation, NavigationBlocker, NavigationGuard, Blocker, ShouldBlock, UseBlockerOptions, SnapshotOptions } from "hamur/adapter";
|
|
14
14
|
import type { HandlerForm, HamurLinkProps } from "hamur/app";
|
|
15
15
|
import type { RouteLoaderData, UseDataArgs, AsyncDataHandler, ErrorBoundaryFallbackProps, FetchRequest, GetCachedData, CheckedTarget, NavigationState, RouteValue, RouterApi } from "hamur/adapter";
|
|
16
|
-
import type {
|
|
16
|
+
import type { AppContext, FormSubmitArgs, PendingRun, PickFrom, RouteLocation, ClientRuntimeConfig, SiteConfig, FetchData, AsyncDataOptions, AsyncDataStatus, UseCookieOptions, ErrorPageProps, HeadInput, HeadSafeInput, SeoMetaInput, HamurError } from "hamur/app";
|
|
17
17
|
export { addRouteMiddleware, clearError, disableScrollHandling, forbidden, navigateTo, notFound, permanentRedirect, refreshCookie, setPageLayout, showError, unauthorized, } from "hamur/app";
|
|
18
18
|
export { defineLazyHydrationComponent } from "./lazy-hydration.ts";
|
|
19
19
|
export { Island } from "./island.ts";
|
|
@@ -123,10 +123,10 @@ export declare function useFormStatus(): FormStatus;
|
|
|
123
123
|
export declare function useForm<I, O>(fn: Handler<I, O>): HandlerForm<I, O>;
|
|
124
124
|
export interface UseActionResult<I, O> {
|
|
125
125
|
run: ActionRunner<I, O>["run"];
|
|
126
|
-
state: O | undefined;
|
|
126
|
+
state: ActionValue<O> | undefined;
|
|
127
127
|
pending: boolean;
|
|
128
128
|
error: HamurError | undefined;
|
|
129
|
-
failure:
|
|
129
|
+
failure: FailureOf<O> | undefined;
|
|
130
130
|
reset(): void;
|
|
131
131
|
}
|
|
132
132
|
export declare function useAction<I, O>(fn: Handler<I, O>, options?: ActionOptions<O> & {
|
|
@@ -358,7 +358,7 @@ export declare function useCookie<T = string>(name: string, options?: Omit<UseCo
|
|
|
358
358
|
export interface UseAsyncDataOptions<T = unknown, R = T, K extends keyof T & string = never, D = T> extends Omit<AsyncDataOptions<T, R, D>, "pick"> {
|
|
359
359
|
/** Values that re-run the handler when they change. `false` is accepted and does nothing: nothing watches implicitly. */
|
|
360
360
|
watch?: readonly unknown[] | false;
|
|
361
|
-
getCachedData?: GetCachedData<T
|
|
361
|
+
getCachedData?: GetCachedData<NoInfer<T>>;
|
|
362
362
|
/** Top-level keys of an object result to keep. */
|
|
363
363
|
pick?: readonly K[];
|
|
364
364
|
}
|
|
@@ -382,10 +382,10 @@ export declare function useAsyncData<I, R, T = R, K extends keyof T & string = n
|
|
|
382
382
|
default: () => D;
|
|
383
383
|
}): UseAsyncDataResult<PickFrom<T, K>, D>;
|
|
384
384
|
export declare function useAsyncData<I, R, T = R, K extends keyof T & string = never>(fn: Handler<I, R>, input?: NoInfer<I> | (() => NoInfer<I>), options?: UseAsyncDataOptions<T, R, K, undefined>): UseAsyncDataResult<PickFrom<T, K>>;
|
|
385
|
-
export declare function useAsyncData<T =
|
|
385
|
+
export declare function useAsyncData<R, T = R, K extends keyof T & string = never, D = T>(keyOrGetter: string | (() => string), handler: AsyncDataHandler<R>, options: UseAsyncDataOptions<T, R, K, D> & {
|
|
386
386
|
default: () => D;
|
|
387
387
|
}): UseAsyncDataResult<PickFrom<T, K>, D>;
|
|
388
|
-
export declare function useAsyncData<T =
|
|
388
|
+
export declare function useAsyncData<R, T = R, K extends keyof T & string = never>(keyOrGetter: string | (() => string), handler: AsyncDataHandler<R>, options?: UseAsyncDataOptions<T, R, K, undefined>): UseAsyncDataResult<PickFrom<T, K>>;
|
|
389
389
|
/** What a literal `useFetch` call is checked against; any other call stays loose. */
|
|
390
390
|
type FetchInput<X> = X extends {
|
|
391
391
|
key: infer K extends string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hamur/adapter-preact",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -68,6 +68,6 @@
|
|
|
68
68
|
"peerDependencies": {
|
|
69
69
|
"preact": "^11.0.2",
|
|
70
70
|
"preact-render-to-string": "^6.8.1",
|
|
71
|
-
"hamur": "^0.0.
|
|
71
|
+
"hamur": "^0.0.3"
|
|
72
72
|
}
|
|
73
73
|
}
|
package/src/index.ts
CHANGED
|
@@ -123,6 +123,8 @@ import type { LinkDefaults, LinkSlot, ResolvedLinkDefaults, UseLinkOptions } fro
|
|
|
123
123
|
import type {
|
|
124
124
|
ActionOptions,
|
|
125
125
|
ActionRunner,
|
|
126
|
+
ActionValue,
|
|
127
|
+
FailureOf,
|
|
126
128
|
FormStatus,
|
|
127
129
|
PrefetchOn,
|
|
128
130
|
Handler,
|
|
@@ -156,7 +158,6 @@ import type {
|
|
|
156
158
|
RouterApi,
|
|
157
159
|
} from "hamur/adapter"
|
|
158
160
|
import type {
|
|
159
|
-
ActionFailure,
|
|
160
161
|
AppContext,
|
|
161
162
|
FormSubmitArgs,
|
|
162
163
|
PendingRun,
|
|
@@ -650,10 +651,10 @@ export function useForm<I, O>(fn: Handler<I, O>): HandlerForm<I, O> {
|
|
|
650
651
|
|
|
651
652
|
export interface UseActionResult<I, O> {
|
|
652
653
|
run: ActionRunner<I, O>["run"]
|
|
653
|
-
state: O | undefined
|
|
654
|
+
state: ActionValue<O> | undefined
|
|
654
655
|
pending: boolean
|
|
655
656
|
error: HamurError | undefined
|
|
656
|
-
failure:
|
|
657
|
+
failure: FailureOf<O> | undefined
|
|
657
658
|
reset(): void
|
|
658
659
|
}
|
|
659
660
|
|
|
@@ -1591,7 +1592,7 @@ export interface UseAsyncDataOptions<T = unknown, R = T, K extends keyof T & str
|
|
|
1591
1592
|
> {
|
|
1592
1593
|
/** Values that re-run the handler when they change. `false` is accepted and does nothing: nothing watches implicitly. */
|
|
1593
1594
|
watch?: readonly unknown[] | false
|
|
1594
|
-
getCachedData?: GetCachedData<T
|
|
1595
|
+
getCachedData?: GetCachedData<NoInfer<T>>
|
|
1595
1596
|
/** Top-level keys of an object result to keep. */
|
|
1596
1597
|
pick?: readonly K[]
|
|
1597
1598
|
}
|
|
@@ -1625,12 +1626,12 @@ export function useAsyncData<I, R, T = R, K extends keyof T & string = never>(
|
|
|
1625
1626
|
input?: NoInfer<I> | (() => NoInfer<I>),
|
|
1626
1627
|
options?: UseAsyncDataOptions<T, R, K, undefined>,
|
|
1627
1628
|
): UseAsyncDataResult<PickFrom<T, K>>
|
|
1628
|
-
export function useAsyncData<T =
|
|
1629
|
+
export function useAsyncData<R, T = R, K extends keyof T & string = never, D = T>(
|
|
1629
1630
|
keyOrGetter: string | (() => string),
|
|
1630
1631
|
handler: AsyncDataHandler<R>,
|
|
1631
1632
|
options: UseAsyncDataOptions<T, R, K, D> & { default: () => D },
|
|
1632
1633
|
): UseAsyncDataResult<PickFrom<T, K>, D>
|
|
1633
|
-
export function useAsyncData<T =
|
|
1634
|
+
export function useAsyncData<R, T = R, K extends keyof T & string = never>(
|
|
1634
1635
|
keyOrGetter: string | (() => string),
|
|
1635
1636
|
handler: AsyncDataHandler<R>,
|
|
1636
1637
|
options?: UseAsyncDataOptions<T, R, K, undefined>,
|
|
@@ -1802,7 +1803,7 @@ function fetchWith<T, R, K extends keyof T & string, D>(
|
|
|
1802
1803
|
const request = requestOf(rest)
|
|
1803
1804
|
const app = useApp()
|
|
1804
1805
|
const fetcher = client ?? app.fetch ?? $fetch
|
|
1805
|
-
return useAsyncData<
|
|
1806
|
+
return useAsyncData<R, T, K, D>(
|
|
1806
1807
|
key ?? fetchKey(url, request),
|
|
1807
1808
|
({ signal }) => fetcher<R>(url, { ...request, signal: signalOf(request.signal, signal) }),
|
|
1808
1809
|
{ server, lazy, default: init as () => D, transform, immediate, dedupe, pick, watch, getCachedData },
|