@pracht/core 0.2.5 → 0.2.7
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/README.md +3 -3
- package/dist/index.d.mts +10 -11
- package/dist/index.mjs +491 -173
- package/package.json +1 -1
- package/dist/app-Cep0el7c.mjs +0 -241
package/README.md
CHANGED
|
@@ -35,16 +35,16 @@ metadata for the failure phase and matched framework files when available.
|
|
|
35
35
|
### Client
|
|
36
36
|
|
|
37
37
|
- `startApp()` — client-side hydration and runtime
|
|
38
|
+
- `useLocation()` — access the current pathname and search string separately
|
|
38
39
|
- `useRouteData()` — access loader data inside a route component
|
|
39
|
-
- `
|
|
40
|
-
- `useSubmitAction()` — submit a form action programmatically
|
|
40
|
+
- `useRevalidate()` — trigger a revalidation of the current route's data
|
|
41
41
|
- `<Form>` — progressive enhancement form component
|
|
42
42
|
|
|
43
43
|
### Types
|
|
44
44
|
|
|
45
45
|
- `LoaderData<T>` — infer the return type of a loader
|
|
46
46
|
- `RouteComponentProps<T>` — props type for route components
|
|
47
|
-
- `LoaderArgs` — argument type passed to loaders
|
|
47
|
+
- `LoaderArgs` — argument type passed to loaders
|
|
48
48
|
|
|
49
49
|
## Rendering Modes
|
|
50
50
|
|
package/dist/index.d.mts
CHANGED
|
@@ -35,7 +35,9 @@ interface TimeRevalidatePolicy {
|
|
|
35
35
|
}
|
|
36
36
|
type RouteRevalidate = TimeRevalidatePolicy;
|
|
37
37
|
type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
|
|
38
|
-
type ApiRouteArgs<TContext = RegisteredContext> = BaseRouteArgs<TContext
|
|
38
|
+
type ApiRouteArgs<TContext = RegisteredContext> = Omit<BaseRouteArgs<TContext>, "route"> & {
|
|
39
|
+
route: ResolvedApiRoute;
|
|
40
|
+
};
|
|
39
41
|
type ApiRouteHandler<TContext = RegisteredContext> = (args: ApiRouteArgs<TContext>) => MaybePromise<Response>;
|
|
40
42
|
interface ApiRouteModule<TContext = any> {
|
|
41
43
|
default?: ApiRouteHandler<TContext>;
|
|
@@ -286,10 +288,8 @@ interface HandlePrachtRequestOptions<TContext = unknown> {
|
|
|
286
288
|
/** Expose raw server error details in rendered HTML and route-state JSON. */
|
|
287
289
|
debugErrors?: boolean;
|
|
288
290
|
clientEntryUrl?: string;
|
|
289
|
-
/** Per-source-file CSS map produced by the vite plugin
|
|
291
|
+
/** Per-source-file CSS map produced by the vite plugin. */
|
|
290
292
|
cssManifest?: Record<string, string[]>;
|
|
291
|
-
/** @deprecated Pass cssManifest instead for per-page CSS resolution. */
|
|
292
|
-
cssUrls?: string[];
|
|
293
293
|
/** Per-source-file JS chunk map produced by the vite plugin for modulepreload hints. */
|
|
294
294
|
jsManifest?: Record<string, string[]>;
|
|
295
295
|
apiRoutes?: ResolvedApiRoute[];
|
|
@@ -318,12 +318,14 @@ declare function PrachtRuntimeProvider<TData>({
|
|
|
318
318
|
data,
|
|
319
319
|
params,
|
|
320
320
|
routeId,
|
|
321
|
+
stateVersion,
|
|
321
322
|
url
|
|
322
323
|
}: {
|
|
323
324
|
children: ComponentChildren;
|
|
324
325
|
data: TData;
|
|
325
326
|
params?: RouteParams;
|
|
326
327
|
routeId: string;
|
|
328
|
+
stateVersion?: number;
|
|
327
329
|
url: string;
|
|
328
330
|
}): _$preact.VNode<_$preact.Attributes & {
|
|
329
331
|
value: PrachtRuntimeValue | undefined;
|
|
@@ -334,12 +336,11 @@ declare function readHydrationState<TData = unknown>(): PrachtHydrationState<TDa
|
|
|
334
336
|
declare function useRouteData<TData = unknown>(): TData;
|
|
335
337
|
interface Location {
|
|
336
338
|
pathname: string;
|
|
339
|
+
search: string;
|
|
337
340
|
}
|
|
338
341
|
declare function useLocation(): Location;
|
|
339
342
|
declare function useParams(): RouteParams;
|
|
340
343
|
declare function useRevalidate(): () => Promise<unknown>;
|
|
341
|
-
/** @deprecated Use useRevalidate instead. */
|
|
342
|
-
declare const useRevalidateRoute: typeof useRevalidate;
|
|
343
344
|
declare function Form(props: FormProps): _$preact.VNode<_$preact.ClassAttributes<HTMLFormElement> & h.JSX.HTMLAttributes<HTMLFormElement>>;
|
|
344
345
|
type RouteStateResult = {
|
|
345
346
|
type: "data";
|
|
@@ -369,12 +370,10 @@ interface PrerenderAppOptions {
|
|
|
369
370
|
app: PrachtApp;
|
|
370
371
|
registry?: ModuleRegistry;
|
|
371
372
|
clientEntryUrl?: string;
|
|
372
|
-
/** Per-source-file CSS map produced by the vite plugin
|
|
373
|
+
/** Per-source-file CSS map produced by the vite plugin. */
|
|
373
374
|
cssManifest?: Record<string, string[]>;
|
|
374
375
|
/** Per-source-file JS map produced by the vite plugin for modulepreload hints. */
|
|
375
376
|
jsManifest?: Record<string, string[]>;
|
|
376
|
-
/** @deprecated Pass cssManifest instead for per-page CSS resolution. */
|
|
377
|
-
cssUrls?: string[];
|
|
378
377
|
}
|
|
379
378
|
declare function prerenderApp(options: PrerenderAppOptions): Promise<PrerenderResult[]>;
|
|
380
379
|
declare function prerenderApp(options: PrerenderAppOptions & {
|
|
@@ -388,7 +387,7 @@ declare global {
|
|
|
388
387
|
__PRACHT_ROUTER_READY__?: boolean;
|
|
389
388
|
}
|
|
390
389
|
}
|
|
391
|
-
type ModuleMap = Record<string, () => Promise<
|
|
390
|
+
type ModuleMap = Record<string, () => Promise<unknown>>;
|
|
392
391
|
type NavigateFn = (to: string, options?: {
|
|
393
392
|
replace?: boolean;
|
|
394
393
|
}) => Promise<void>;
|
|
@@ -403,4 +402,4 @@ interface InitClientRouterOptions {
|
|
|
403
402
|
}
|
|
404
403
|
declare function initClientRouter(options: InitClientRouterOptions): Promise<void>;
|
|
405
404
|
//#endregion
|
|
406
|
-
export { type ApiConfig, type ApiRouteArgs, type ApiRouteHandler, type ApiRouteMatch, type ApiRouteModule, type BaseRouteArgs, type DataModule, type ErrorBoundaryProps, Form, type FormProps, type GroupDefinition, type GroupMeta, type HandlePrachtRequestOptions, type HeadArgs, type HeadMetadata, type HeadersArgs, type HttpMethod, type ISGManifestEntry, type InitClientRouterOptions, type LoaderArgs, type LoaderData, type LoaderFn, type Location, type MiddlewareArgs, type MiddlewareFn, type MiddlewareModule, type MiddlewareResult, type ModuleImporter, type ModuleRef, type ModuleRegistry, type NavigateFn, type PrachtApp, type PrachtAppConfig, PrachtHttpError, type PrachtHydrationState, type PrachtRuntimeDiagnosticPhase, type PrachtRuntimeDiagnostics, PrachtRuntimeProvider, type PrefetchStrategy, type PrerenderAppOptions, type PrerenderAppResult, type PrerenderResult, type Register, type RenderMode, type ResolvedApiRoute, type ResolvedPrachtApp, type ResolvedRoute, type RouteComponentProps, type RouteConfig, type RouteDefinition, type RouteMatch, type RouteMeta, type RouteModule, type RouteParams, type RouteRevalidate, type RouteStateResult, type RouteTreeNode, type SerializedRouteError, type ShellModule, type ShellProps, type StartAppOptions, Suspense, type TimeRevalidatePolicy, applyDefaultSecurityHeaders, buildPathFromSegments, defineApp, forwardRef, group, handlePrachtRequest, initClientRouter, lazy, matchApiRoute, matchAppRoute, prerenderApp, readHydrationState, resolveApiRoutes, resolveApp, route, startApp, timeRevalidate, useIsHydrated, useLocation, useNavigate, useParams, useRevalidate,
|
|
405
|
+
export { type ApiConfig, type ApiRouteArgs, type ApiRouteHandler, type ApiRouteMatch, type ApiRouteModule, type BaseRouteArgs, type DataModule, type ErrorBoundaryProps, Form, type FormProps, type GroupDefinition, type GroupMeta, type HandlePrachtRequestOptions, type HeadArgs, type HeadMetadata, type HeadersArgs, type HttpMethod, type ISGManifestEntry, type InitClientRouterOptions, type LoaderArgs, type LoaderData, type LoaderFn, type Location, type MiddlewareArgs, type MiddlewareFn, type MiddlewareModule, type MiddlewareResult, type ModuleImporter, type ModuleRef, type ModuleRegistry, type NavigateFn, type PrachtApp, type PrachtAppConfig, PrachtHttpError, type PrachtHydrationState, type PrachtRuntimeDiagnosticPhase, type PrachtRuntimeDiagnostics, PrachtRuntimeProvider, type PrefetchStrategy, type PrerenderAppOptions, type PrerenderAppResult, type PrerenderResult, type Register, type RenderMode, type ResolvedApiRoute, type ResolvedPrachtApp, type ResolvedRoute, type RouteComponentProps, type RouteConfig, type RouteDefinition, type RouteMatch, type RouteMeta, type RouteModule, type RouteParams, type RouteRevalidate, type RouteStateResult, type RouteTreeNode, type SerializedRouteError, type ShellModule, type ShellProps, type StartAppOptions, Suspense, type TimeRevalidatePolicy, applyDefaultSecurityHeaders, buildPathFromSegments, defineApp, forwardRef, group, handlePrachtRequest, initClientRouter, lazy, matchApiRoute, matchAppRoute, prerenderApp, readHydrationState, resolveApiRoutes, resolveApp, route, startApp, timeRevalidate, useIsHydrated, useLocation, useNavigate, useParams, useRevalidate, useRouteData };
|