@fluixi/core 1.0.0-alpha.100
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/LICENSE +21 -0
- package/README.md +334 -0
- package/dist/cdn/core.global.js +2 -0
- package/dist/cli/generate.cjs +5639 -0
- package/dist/cli/generate.d.ts +7 -0
- package/dist/cli/generate.d.ts.map +1 -0
- package/dist/cli/generate.js +2580 -0
- package/dist/cli/generate.mjs +5644 -0
- package/dist/cli/index.cjs +5639 -0
- package/dist/cli/index.d.ts +7 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +2580 -0
- package/dist/cli/index.mjs +5644 -0
- package/dist/cli/run.cjs +64 -0
- package/dist/cli/run.d.ts +3 -0
- package/dist/cli/run.d.ts.map +1 -0
- package/dist/cli/run.js +62 -0
- package/dist/cli/run.mjs +40 -0
- package/dist/fluixi.d.ts +5 -0
- package/dist/src/cdn/chunk-RKBFEFZP.mjs +987 -0
- package/dist/src/cdn/core.cjs +1592 -0
- package/dist/src/cdn/core.d.ts +16 -0
- package/dist/src/cdn/core.d.ts.map +1 -0
- package/dist/src/cdn/core.js +15 -0
- package/dist/src/cdn/core.mjs +714 -0
- package/dist/src/cdn/router-V2THK27H.mjs +74 -0
- package/dist/src/index.cjs +1711 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +11 -0
- package/dist/src/index.mjs +1833 -0
- package/dist/src/jsx-dev-runtime.cjs +26 -0
- package/dist/src/jsx-dev-runtime.d.ts +2 -0
- package/dist/src/jsx-dev-runtime.d.ts.map +1 -0
- package/dist/src/jsx-dev-runtime.js +1 -0
- package/dist/src/jsx-dev-runtime.mjs +24 -0
- package/dist/src/jsx-runtime.cjs +26 -0
- package/dist/src/jsx-runtime.d.ts +7 -0
- package/dist/src/jsx-runtime.d.ts.map +1 -0
- package/dist/src/jsx-runtime.js +8 -0
- package/dist/src/jsx-runtime.mjs +24 -0
- package/dist/src/lib/client/chunk-FDOPDB6Z.mjs +53 -0
- package/dist/src/lib/client/index.cjs +1210 -0
- package/dist/src/lib/client/index.d.ts +51 -0
- package/dist/src/lib/client/index.d.ts.map +1 -0
- package/dist/src/lib/client/index.js +174 -0
- package/dist/src/lib/client/index.mjs +293 -0
- package/dist/src/lib/client/router-4PTBPZLQ.mjs +891 -0
- package/dist/src/lib/context/context.cjs +81 -0
- package/dist/src/lib/context/context.d.ts +73 -0
- package/dist/src/lib/context/context.d.ts.map +1 -0
- package/dist/src/lib/context/context.js +93 -0
- package/dist/src/lib/context/context.mjs +64 -0
- package/dist/src/lib/context/index.cjs +83 -0
- package/dist/src/lib/context/index.d.ts +3 -0
- package/dist/src/lib/context/index.d.ts.map +1 -0
- package/dist/src/lib/context/index.js +1 -0
- package/dist/src/lib/context/index.mjs +64 -0
- package/dist/src/lib/control-flow.cjs +35 -0
- package/dist/src/lib/control-flow.d.ts +4 -0
- package/dist/src/lib/control-flow.d.ts.map +1 -0
- package/dist/src/lib/control-flow.js +1 -0
- package/dist/src/lib/control-flow.mjs +25 -0
- package/dist/src/lib/core.cjs +1710 -0
- package/dist/src/lib/core.d.ts +91 -0
- package/dist/src/lib/core.d.ts.map +1 -0
- package/dist/src/lib/core.js +158 -0
- package/dist/src/lib/core.mjs +1833 -0
- package/dist/src/lib/env/index.cjs +44 -0
- package/dist/src/lib/env/index.d.ts +26 -0
- package/dist/src/lib/env/index.d.ts.map +1 -0
- package/dist/src/lib/env/index.js +31 -0
- package/dist/src/lib/env/index.mjs +23 -0
- package/dist/src/lib/i18n/index.cjs +123 -0
- package/dist/src/lib/i18n/index.d.ts +110 -0
- package/dist/src/lib/i18n/index.d.ts.map +1 -0
- package/dist/src/lib/i18n/index.js +164 -0
- package/dist/src/lib/i18n/index.mjs +103 -0
- package/dist/src/lib/index.cjs +598 -0
- package/dist/src/lib/index.d.ts +81 -0
- package/dist/src/lib/index.d.ts.map +1 -0
- package/dist/src/lib/index.js +130 -0
- package/dist/src/lib/index.mjs +688 -0
- package/dist/src/lib/isomorphic.cjs +90 -0
- package/dist/src/lib/isomorphic.d.ts +114 -0
- package/dist/src/lib/isomorphic.d.ts.map +1 -0
- package/dist/src/lib/isomorphic.js +132 -0
- package/dist/src/lib/isomorphic.mjs +69 -0
- package/dist/src/lib/jsx-runtime/index.cjs +21 -0
- package/dist/src/lib/jsx-runtime/index.d.ts +13 -0
- package/dist/src/lib/jsx-runtime/index.d.ts.map +1 -0
- package/dist/src/lib/jsx-runtime/index.js +13 -0
- package/dist/src/lib/jsx-runtime/index.mjs +4 -0
- package/dist/src/lib/jsx-runtime/jsx-dev-runtime.cjs +21 -0
- package/dist/src/lib/jsx-runtime/jsx-dev-runtime.d.ts +2 -0
- package/dist/src/lib/jsx-runtime/jsx-dev-runtime.d.ts.map +1 -0
- package/dist/src/lib/jsx-runtime/jsx-dev-runtime.js +1 -0
- package/dist/src/lib/jsx-runtime/jsx-dev-runtime.mjs +4 -0
- package/dist/src/lib/plugins/fluixi-routes-plugin.cjs +302 -0
- package/dist/src/lib/plugins/fluixi-routes-plugin.d.ts +35 -0
- package/dist/src/lib/plugins/fluixi-routes-plugin.d.ts.map +1 -0
- package/dist/src/lib/plugins/fluixi-routes-plugin.js +118 -0
- package/dist/src/lib/plugins/fluixi-routes-plugin.mjs +271 -0
- package/dist/src/lib/plugins/index.cjs +311 -0
- package/dist/src/lib/plugins/index.d.ts +6 -0
- package/dist/src/lib/plugins/index.d.ts.map +1 -0
- package/dist/src/lib/plugins/index.js +7 -0
- package/dist/src/lib/plugins/index.mjs +279 -0
- package/dist/src/lib/plugins/route-codegen.cjs +73 -0
- package/dist/src/lib/plugins/route-codegen.d.ts +12 -0
- package/dist/src/lib/plugins/route-codegen.d.ts.map +1 -0
- package/dist/src/lib/plugins/route-codegen.js +80 -0
- package/dist/src/lib/plugins/route-codegen.mjs +52 -0
- package/dist/src/lib/plugins/route-scanner.cjs +189 -0
- package/dist/src/lib/plugins/route-scanner.d.ts +38 -0
- package/dist/src/lib/plugins/route-scanner.d.ts.map +1 -0
- package/dist/src/lib/plugins/route-scanner.js +215 -0
- package/dist/src/lib/plugins/route-scanner.mjs +158 -0
- package/dist/src/lib/plugins/vite.cjs +27 -0
- package/dist/src/lib/plugins/vite.d.ts +3 -0
- package/dist/src/lib/plugins/vite.d.ts.map +1 -0
- package/dist/src/lib/plugins/vite.js +1 -0
- package/dist/src/lib/plugins/vite.mjs +6 -0
- package/dist/src/lib/render/await.cjs +38 -0
- package/dist/src/lib/render/await.d.ts +26 -0
- package/dist/src/lib/render/await.d.ts.map +1 -0
- package/dist/src/lib/render/await.js +45 -0
- package/dist/src/lib/render/await.mjs +17 -0
- package/dist/src/lib/render/component.cjs +221 -0
- package/dist/src/lib/render/component.d.ts +296 -0
- package/dist/src/lib/render/component.d.ts.map +1 -0
- package/dist/src/lib/render/component.js +514 -0
- package/dist/src/lib/render/component.mjs +214 -0
- package/dist/src/lib/render/deferred.cjs +175 -0
- package/dist/src/lib/render/deferred.d.ts +36 -0
- package/dist/src/lib/render/deferred.d.ts.map +1 -0
- package/dist/src/lib/render/deferred.js +141 -0
- package/dist/src/lib/render/deferred.mjs +158 -0
- package/dist/src/lib/render/index.cjs +573 -0
- package/dist/src/lib/render/index.d.ts +98 -0
- package/dist/src/lib/render/index.d.ts.map +1 -0
- package/dist/src/lib/render/index.js +180 -0
- package/dist/src/lib/render/index.mjs +590 -0
- package/dist/src/lib/render/lazy.cjs +67 -0
- package/dist/src/lib/render/lazy.d.ts +49 -0
- package/dist/src/lib/render/lazy.d.ts.map +1 -0
- package/dist/src/lib/render/lazy.js +105 -0
- package/dist/src/lib/render/lazy.mjs +50 -0
- package/dist/src/lib/render/suspense.cjs +141 -0
- package/dist/src/lib/render/suspense.d.ts +65 -0
- package/dist/src/lib/render/suspense.d.ts.map +1 -0
- package/dist/src/lib/render/suspense.js +196 -0
- package/dist/src/lib/render/suspense.mjs +136 -0
- package/dist/src/lib/render/versions.cjs +35 -0
- package/dist/src/lib/render/versions.d.ts +2 -0
- package/dist/src/lib/render/versions.d.ts.map +1 -0
- package/dist/src/lib/render/versions.js +21 -0
- package/dist/src/lib/render/versions.mjs +14 -0
- package/dist/src/lib/router/data.cjs +228 -0
- package/dist/src/lib/router/data.d.ts +142 -0
- package/dist/src/lib/router/data.d.ts.map +1 -0
- package/dist/src/lib/router/data.js +258 -0
- package/dist/src/lib/router/data.mjs +214 -0
- package/dist/src/lib/router/index.cjs +921 -0
- package/dist/src/lib/router/index.d.ts +274 -0
- package/dist/src/lib/router/index.d.ts.map +1 -0
- package/dist/src/lib/router/index.js +904 -0
- package/dist/src/lib/router/index.mjs +938 -0
- package/dist/src/lib/router/scroll.cjs +79 -0
- package/dist/src/lib/router/scroll.d.ts +19 -0
- package/dist/src/lib/router/scroll.d.ts.map +1 -0
- package/dist/src/lib/router/scroll.js +68 -0
- package/dist/src/lib/router/scroll.mjs +58 -0
- package/dist/src/lib/router/transition.cjs +75 -0
- package/dist/src/lib/router/transition.d.ts +81 -0
- package/dist/src/lib/router/transition.d.ts.map +1 -0
- package/dist/src/lib/router/transition.js +136 -0
- package/dist/src/lib/router/transition.mjs +54 -0
- package/dist/src/lib/server/hydration.cjs +169 -0
- package/dist/src/lib/server/hydration.d.ts +198 -0
- package/dist/src/lib/server/hydration.d.ts.map +1 -0
- package/dist/src/lib/server/hydration.js +345 -0
- package/dist/src/lib/server/hydration.mjs +148 -0
- package/dist/src/lib/server/index.cjs +406 -0
- package/dist/src/lib/server/index.d.ts +115 -0
- package/dist/src/lib/server/index.d.ts.map +1 -0
- package/dist/src/lib/server/index.js +164 -0
- package/dist/src/lib/server/index.mjs +384 -0
- package/dist/src/lib/server/reactive.cjs +197 -0
- package/dist/src/lib/server/reactive.d.ts +239 -0
- package/dist/src/lib/server/reactive.d.ts.map +1 -0
- package/dist/src/lib/server/reactive.js +413 -0
- package/dist/src/lib/server/reactive.mjs +176 -0
- package/dist/src/lib/storage/cache.cjs +51 -0
- package/dist/src/lib/storage/cache.d.ts +18 -0
- package/dist/src/lib/storage/cache.d.ts.map +1 -0
- package/dist/src/lib/storage/cache.js +42 -0
- package/dist/src/lib/storage/cache.mjs +30 -0
- package/dist/src/lib/storage/index.cjs +246 -0
- package/dist/src/lib/storage/index.d.ts +83 -0
- package/dist/src/lib/storage/index.d.ts.map +1 -0
- package/dist/src/lib/storage/index.js +179 -0
- package/dist/src/lib/storage/index.mjs +231 -0
- package/dist/src/lib/storage/persisted.cjs +91 -0
- package/dist/src/lib/storage/persisted.d.ts +53 -0
- package/dist/src/lib/storage/persisted.d.ts.map +1 -0
- package/dist/src/lib/storage/persisted.js +75 -0
- package/dist/src/lib/storage/persisted.mjs +70 -0
- package/dist/src/lib/theme/color-scheme.cjs +281 -0
- package/dist/src/lib/theme/color-scheme.d.ts +61 -0
- package/dist/src/lib/theme/color-scheme.d.ts.map +1 -0
- package/dist/src/lib/theme/color-scheme.js +120 -0
- package/dist/src/lib/theme/color-scheme.mjs +265 -0
- package/dist/src/lib/theme/index.cjs +267 -0
- package/dist/src/lib/theme/index.d.ts +78 -0
- package/dist/src/lib/theme/index.d.ts.map +1 -0
- package/dist/src/lib/theme/index.js +135 -0
- package/dist/src/lib/theme/index.mjs +251 -0
- package/dist/src/lib/theme/provider.cjs +346 -0
- package/dist/src/lib/theme/provider.d.ts +34 -0
- package/dist/src/lib/theme/provider.d.ts.map +1 -0
- package/dist/src/lib/theme/provider.js +60 -0
- package/dist/src/lib/theme/provider.mjs +332 -0
- package/dist/src/lib/utils/index.cjs +209 -0
- package/dist/src/lib/utils/index.d.ts +286 -0
- package/dist/src/lib/utils/index.d.ts.map +1 -0
- package/dist/src/lib/utils/index.js +434 -0
- package/dist/src/lib/utils/index.mjs +188 -0
- package/dist/src/routes.cjs +37 -0
- package/dist/src/routes.d.ts +22 -0
- package/dist/src/routes.d.ts.map +1 -0
- package/dist/src/routes.js +20 -0
- package/dist/src/routes.mjs +17 -0
- package/dist/src/server.cjs +405 -0
- package/dist/src/server.d.ts +63 -0
- package/dist/src/server.d.ts.map +1 -0
- package/dist/src/server.js +62 -0
- package/dist/src/server.mjs +382 -0
- package/dist/src/utils.cjs +21 -0
- package/dist/src/utils.d.ts +10 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/src/utils.js +9 -0
- package/dist/src/utils.mjs +4 -0
- package/dist/src/version.generated.cjs +26 -0
- package/dist/src/version.generated.d.ts +3 -0
- package/dist/src/version.generated.d.ts.map +1 -0
- package/dist/src/version.generated.js +3 -0
- package/dist/src/version.generated.mjs +5 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -0
- package/package.json +164 -0
- package/src/index.ts +19 -0
- package/types/fluixi.d.ts +5 -0
- package/types/vinxi.d.ts +50 -0
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { type TransitionMode } from './transition.js';
|
|
2
|
+
import { type GetAtPath } from '@fluixi/utils/object';
|
|
3
|
+
import type { IsUndefined } from '@fluixi/utils/primitive';
|
|
4
|
+
import { type RouteDefinition, type Router as CoreRouter, type HistoryAdapter, type RouterLocation, type NavigateOptions } from '@fluixi/router';
|
|
5
|
+
interface RouterCtxValue {
|
|
6
|
+
router: CoreRouter<any>;
|
|
7
|
+
location: () => RouterLocation;
|
|
8
|
+
params: () => Record<string, string>;
|
|
9
|
+
/** True from a navigation's start until the route it lands on has its modules and data. */
|
|
10
|
+
isRouting: () => boolean;
|
|
11
|
+
/** Counts a layer's data load toward `isRouting` until the promise settles. */
|
|
12
|
+
trackLoad: <T>(result: T) => T;
|
|
13
|
+
}
|
|
14
|
+
export interface RouterProps<C = any> {
|
|
15
|
+
routes: RouteDefinition<C>[];
|
|
16
|
+
base?: string;
|
|
17
|
+
history?: HistoryAdapter;
|
|
18
|
+
/**
|
|
19
|
+
* Rendered when the current URL matches no route, a component, an element, or any renderable.
|
|
20
|
+
* Defaults to a minimal built-in 404 so an unmatched URL never renders a blank page. For a 404
|
|
21
|
+
* that keeps your layout/chrome, add a catch-all file route instead (`[...slug].tsx` -> `*`).
|
|
22
|
+
*/
|
|
23
|
+
notFound?: any;
|
|
24
|
+
/**
|
|
25
|
+
* How route changes are presented. `'auto'` (the default) hands the DOM swap to the
|
|
26
|
+
* browser's View Transition API where there is one, and navigates directly where
|
|
27
|
+
* there is not; `'none'` always navigates directly.
|
|
28
|
+
*
|
|
29
|
+
* A reader who asked for reduced motion never gets an animation either way. Styling
|
|
30
|
+
* is the native mechanism: `::view-transition-old(root)` and
|
|
31
|
+
* `::view-transition-new(root)`: so the router imposes no visual style of its own.
|
|
32
|
+
*/
|
|
33
|
+
transition?: TransitionMode;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The router. Matches the current URL against `routes` and renders what matches.
|
|
37
|
+
*
|
|
38
|
+
* Supplies the router context everything below reaches through `useRouter`,
|
|
39
|
+
* `useNavigate` and `Link`, so those only work inside it. `history` defaults to a
|
|
40
|
+
* browser history; pass a memory history for tests or a server render. An unmatched URL
|
|
41
|
+
* renders `notFound`, which defaults to a minimal built-in page so a bad URL is never
|
|
42
|
+
* blank. For a 404 that keeps your layout, add a catch-all file route instead.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* html`<${Router} routes=${routes} base="/app" />`;
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare function Router<C = any>(props: RouterProps<C>): any;
|
|
50
|
+
/** Renders this layout's child route, inside this layout's context. */
|
|
51
|
+
export declare function Outlet(): any;
|
|
52
|
+
/**
|
|
53
|
+
* Whether a navigation is in progress: from the moment it starts until the route it lands on
|
|
54
|
+
* has loaded its modules and its route data. For a progress bar or a busy cursor.
|
|
55
|
+
*
|
|
56
|
+
* `delay` holds the `true` back until the navigation has lasted that many milliseconds, so a
|
|
57
|
+
* navigation that settles at once shows nothing. It still turns `false` the moment it ends.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```tsx
|
|
61
|
+
* const routing = useIsRouting({ delay: 120 });
|
|
62
|
+
* <div class="progress" data-active={() => (routing() ? '' : undefined)} />
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export declare function useIsRouting(options?: {
|
|
66
|
+
delay?: number;
|
|
67
|
+
}): () => boolean;
|
|
68
|
+
/** Navigate to `to` on mount (replace by default). Renders nothing. */
|
|
69
|
+
export declare function Redirect(props: {
|
|
70
|
+
to: string;
|
|
71
|
+
replace?: boolean;
|
|
72
|
+
}): null;
|
|
73
|
+
/**
|
|
74
|
+
* The router context: the router itself, the current match, and the location.
|
|
75
|
+
*
|
|
76
|
+
* Safe to call during a server render, where a detached context yields a no-op stub
|
|
77
|
+
* rather than throwing, since an SSR pass has nowhere to navigate to. On the client a
|
|
78
|
+
* missing router is genuine misuse and throws, because the alternative is a component
|
|
79
|
+
* that silently never navigates.
|
|
80
|
+
*/
|
|
81
|
+
export declare function useRouter(): RouterCtxValue;
|
|
82
|
+
/**
|
|
83
|
+
* Reactive merged params across all matched layers, as an accessor. Deep-equal
|
|
84
|
+
* memoized so it only notifies when a value actually changes (the underlying
|
|
85
|
+
* params object is rebuilt on every transition).
|
|
86
|
+
*/
|
|
87
|
+
export declare function useParams<T extends Record<string, string> = Record<string, string>>(): () => T;
|
|
88
|
+
/** Params introduced at the nearest matched layer. */
|
|
89
|
+
export declare function useLevelParams(): Record<string, string>;
|
|
90
|
+
/**
|
|
91
|
+
* Reactive accessor for a single route param. Default `===` equality on the
|
|
92
|
+
* string value, so it only re-triggers when this key changes, not when other
|
|
93
|
+
* params at the same level change.
|
|
94
|
+
*/
|
|
95
|
+
export declare function useParam(key: string): () => string | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* Derive a stable value from route params. Only re-triggers when the selector's
|
|
98
|
+
* return value changes. For object returns, pass a custom `equals`.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* const ids = useParamSelector((p) => ({ wsId: p.workspaceId, chId: p.channelId }), deepEqual);
|
|
102
|
+
*/
|
|
103
|
+
export declare function useParamSelector<T>(selector: (params: Record<string, string>) => T, equals?: (a: T, b: T) => boolean): () => T;
|
|
104
|
+
/**
|
|
105
|
+
* Match a path pattern against the current pathname, reactively. Returns the
|
|
106
|
+
* matched `{ params, path }` or null.
|
|
107
|
+
*/
|
|
108
|
+
export declare function useMatch(path: (() => string) | string): () => {
|
|
109
|
+
params: Record<string, string>;
|
|
110
|
+
path: string;
|
|
111
|
+
} | null;
|
|
112
|
+
/**
|
|
113
|
+
* Read/write the current query string. Returns `[params, setParams]`: `params`
|
|
114
|
+
* is a reactive accessor of the parsed query; `setParams` merges the given keys
|
|
115
|
+
* (null deletes) and navigates. Matches the old router.
|
|
116
|
+
*/
|
|
117
|
+
export declare function useSearchParams(): readonly [
|
|
118
|
+
() => Record<string, string>,
|
|
119
|
+
(next: Record<string, string | null>, options?: NavigateOptions) => void
|
|
120
|
+
];
|
|
121
|
+
/**
|
|
122
|
+
* Stable accessor from any reactive source with deep-equal memoization. Pass a
|
|
123
|
+
* `key` to select a nested property. Only re-triggers downstream when the value
|
|
124
|
+
* (or selected field) actually changes.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* const ws = select(store.activeWorkspace); // whole object
|
|
128
|
+
* const id = select(store.activeWorkspace, 'id'); // single field
|
|
129
|
+
*/
|
|
130
|
+
export declare function select<T, K extends string = never>(source: () => T, key?: K): () => IsUndefined<K> extends true ? T : GetAtPath<T, K>;
|
|
131
|
+
/**
|
|
132
|
+
* The current location as a reactive object: reading a property (pathname, etc.)
|
|
133
|
+
* subscribes to location changes. Matches the old router's useLocation().
|
|
134
|
+
*/
|
|
135
|
+
export declare function useLocation(): RouterLocation;
|
|
136
|
+
export interface LinkNavigationOptions {
|
|
137
|
+
/** Replace the current history entry instead of pushing a new one. */
|
|
138
|
+
replace?: boolean;
|
|
139
|
+
/** How this navigation is presented. Defaults to the Router's own setting. */
|
|
140
|
+
transition?: TransitionMode;
|
|
141
|
+
/**
|
|
142
|
+
* Called with the resolved URL before navigating. Return false to leave the click
|
|
143
|
+
* alone, for a section of the app that must load as a document (a different
|
|
144
|
+
* bundle, a server-rendered admin area, a file route).
|
|
145
|
+
*/
|
|
146
|
+
shouldNavigate?: (url: URL, anchor: HTMLAnchorElement) => boolean;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* A delegated click handler that turns plain `<a>` elements into client-side navigations.
|
|
150
|
+
*
|
|
151
|
+
* `<Link>` covers the links an app writes as JSX. This covers the ones it doesn't own:
|
|
152
|
+
* markdown or CMS HTML dropped in through `innerHTML`, where there is no component to
|
|
153
|
+
* bind to and the anchors arrive as prerendered text. Put it on the container and every
|
|
154
|
+
* link inside it navigates without reloading the document:
|
|
155
|
+
*
|
|
156
|
+
* ```tsx
|
|
157
|
+
* const onClick = useLinkNavigation();
|
|
158
|
+
* <article onClick={onClick} innerHTML={doc.html} />
|
|
159
|
+
* ```
|
|
160
|
+
*
|
|
161
|
+
* The anchors stay real anchors: middle-click, right-click -> open in new tab, "copy
|
|
162
|
+
* link address" and crawlers all keep working, because the element is untouched and only
|
|
163
|
+
* a plain left-click is intercepted.
|
|
164
|
+
*
|
|
165
|
+
* Left alone: modified clicks, anything but the primary button, an already-prevented
|
|
166
|
+
* event, `target`, `download`, `rel="external"`, a non-http scheme (`mailto:`, `tel:`),
|
|
167
|
+
* another origin, and a hash pointing inside the current page, that last one is the
|
|
168
|
+
* browser's scroll, and hijacking it breaks in-page anchors.
|
|
169
|
+
*/
|
|
170
|
+
export declare function useLinkNavigation(options?: LinkNavigationOptions): (event: MouseEvent) => void;
|
|
171
|
+
/**
|
|
172
|
+
* A function that navigates, for use outside a `Link`.
|
|
173
|
+
*
|
|
174
|
+
* Reach for it after an action rather than for a plain link: a form that redirects on
|
|
175
|
+
* success, a guard that bounces an unauthenticated visitor. Prefer `Link` for anything a
|
|
176
|
+
* visitor clicks, since an anchor is what middle-click, copy-link and a crawler expect.
|
|
177
|
+
*
|
|
178
|
+
* Navigation is a no-op during a server render, for the reason `useRouter` explains.
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```ts
|
|
182
|
+
* const navigate = useNavigate();
|
|
183
|
+
* await save(form);
|
|
184
|
+
* navigate(`/posts/${id}`, { replace: true });
|
|
185
|
+
* ```
|
|
186
|
+
*/
|
|
187
|
+
export declare function useNavigate(): (to: string, options?: NavigateOptions & {
|
|
188
|
+
transition?: TransitionMode;
|
|
189
|
+
}) => void;
|
|
190
|
+
/**
|
|
191
|
+
* The resolved data for the nearest route that declared a `data` loader. Always
|
|
192
|
+
* returns a callable accessor (matching the old router): it suspends under
|
|
193
|
+
* <Suspense> while loading and yields undefined when no ancestor declared data.
|
|
194
|
+
*/
|
|
195
|
+
export declare function useRouteData<T = any>(): () => T | undefined;
|
|
196
|
+
type MaybeAccessor<T> = T | (() => T);
|
|
197
|
+
export interface LinkProps {
|
|
198
|
+
href: MaybeAccessor<string>;
|
|
199
|
+
replace?: MaybeAccessor<boolean>;
|
|
200
|
+
/** Override active state. Defaults to current pathname === href. */
|
|
201
|
+
active?: MaybeAccessor<boolean>;
|
|
202
|
+
class?: MaybeAccessor<string>;
|
|
203
|
+
className?: MaybeAccessor<string>;
|
|
204
|
+
/** Class added while the link is active. */
|
|
205
|
+
activeClass?: MaybeAccessor<string>;
|
|
206
|
+
slot?: string;
|
|
207
|
+
children?: any;
|
|
208
|
+
/**
|
|
209
|
+
* Everything else is forwarded onto the `<a>`: id, style, title, aria-*,
|
|
210
|
+
* data-*, event handlers. Typed openly because the forwarding is
|
|
211
|
+
* allow-by-default: a prop this interface forgot still reaches the DOM, and
|
|
212
|
+
* refusing it here would only mean the type disagreeing with the runtime.
|
|
213
|
+
*/
|
|
214
|
+
[key: string]: unknown;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* An anchor that navigates without a full page load.
|
|
218
|
+
*
|
|
219
|
+
* Renders a real `<a href>`, so middle-click, copy-link, and a crawler all behave. A
|
|
220
|
+
* plain left click is intercepted and routed instead.
|
|
221
|
+
*
|
|
222
|
+
* Active state defaults to the current pathname matching `href`, and `activeClass` is
|
|
223
|
+
* added while it holds. Override `active` when a section link should stay lit for its
|
|
224
|
+
* children.
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* ```ts
|
|
228
|
+
* html`<${Link} href="/about" activeClass="current">About</${Link}>`;
|
|
229
|
+
* ```
|
|
230
|
+
*/
|
|
231
|
+
export declare function Link(props: LinkProps): any;
|
|
232
|
+
/** Alias for {@link Link}. */
|
|
233
|
+
export declare const A: typeof Link;
|
|
234
|
+
import type { Action } from './data.js';
|
|
235
|
+
export interface ActionFormProps {
|
|
236
|
+
/** The action to run on submit (typically wrapping a `"use server"` function). */
|
|
237
|
+
action: Action<any, any>;
|
|
238
|
+
/** Extra class on the <form>. */
|
|
239
|
+
class?: string;
|
|
240
|
+
children?: any;
|
|
241
|
+
[key: string]: any;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* A `<form>` wired to a router action: on submit it builds `FormData` from the form and calls
|
|
245
|
+
* `action(formData)` (which tracks submission state via `useSubmission`), without a full
|
|
246
|
+
* page navigation. The markup carries `method="post"` + `action={action.url}` so it's
|
|
247
|
+
* progressive-enhancement-ready.
|
|
248
|
+
*
|
|
249
|
+
* <ActionForm action={save}>
|
|
250
|
+
* <input name="title" />
|
|
251
|
+
* <button>Save</button>
|
|
252
|
+
* </ActionForm>
|
|
253
|
+
*
|
|
254
|
+
* It sends what the fields hold and checks nothing. For a form whose fields are validated
|
|
255
|
+
* first, use `@fluixi-ui/form`'s `Form` with an `action`.
|
|
256
|
+
*/
|
|
257
|
+
export declare function ActionForm(props: ActionFormProps): any;
|
|
258
|
+
/**
|
|
259
|
+
* Download the lazy component chunks for the route(s) matching `pathname` and resolve when
|
|
260
|
+
* they're all loaded. Await this before hydrating: once each matched lazy file-route is
|
|
261
|
+
* resolved it renders synchronously on the first pass (no Suspense fallback, no late
|
|
262
|
+
* re-render), so hydration adopts the server DOM in place instead of building a duplicate
|
|
263
|
+
* subtree next to it. No-op for routes with no lazy components. Safe to call when the URL
|
|
264
|
+
* matches nothing (resolves immediately).
|
|
265
|
+
*/
|
|
266
|
+
export declare function preloadRoutes<C = any>(routes: RouteDefinition<C>[], pathname: string): Promise<void>;
|
|
267
|
+
export { createMemoryHistory, createBrowserHistory, matchRoutes, matchPath, } from '@fluixi/router';
|
|
268
|
+
export type { RouteDefinition, RouteMatch, MatchedRoute, RouterLocation, NavigateOptions, HistoryAdapter, } from '@fluixi/router';
|
|
269
|
+
export { cache, action, revalidate, createAsync, useSubmission, useSubmissions, useAction, } from './data.js';
|
|
270
|
+
export type { RouteDataArgs, RouteLoadFunc, Action, ActionOptions, CacheOptions, Submission, CacheFn, } from './data.js';
|
|
271
|
+
export { lazy } from '../render/lazy.js';
|
|
272
|
+
export { supportsViewTransitions, prefersReducedMotion, type TransitionMode, } from './transition.js';
|
|
273
|
+
export { runWithOwner } from '@fluixi/reactive/signal';
|
|
274
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/router/index.ts"],"names":[],"mappings":"AAyBA,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,iBAAiB,CAAC;AAUzB,OAAO,EAAO,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAI3D,OAAO,EAKL,KAAK,eAAe,EAEpB,KAAK,MAAM,IAAI,UAAU,EACzB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,eAAe,EACrB,MAAM,gBAAgB,CAAC;AAIxB,UAAU,cAAc;IACtB,MAAM,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC;IACxB,QAAQ,EAAE,MAAM,cAAc,CAAC;IAC/B,MAAM,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,2FAA2F;IAC3F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