@alepha/react 0.15.0 → 0.15.1
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/auth/index.browser.js +603 -242
- package/dist/auth/index.browser.js.map +1 -1
- package/dist/auth/index.d.ts +6 -6
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +1296 -922
- package/dist/auth/index.js.map +1 -1
- package/dist/core/index.d.ts +128 -128
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +20 -20
- package/dist/core/index.js.map +1 -1
- package/dist/form/index.d.ts +36 -36
- package/dist/form/index.d.ts.map +1 -1
- package/dist/form/index.js +15 -15
- package/dist/form/index.js.map +1 -1
- package/dist/head/index.browser.js +20 -0
- package/dist/head/index.browser.js.map +1 -1
- package/dist/head/index.d.ts +73 -65
- package/dist/head/index.d.ts.map +1 -1
- package/dist/head/index.js +20 -0
- package/dist/head/index.js.map +1 -1
- package/dist/i18n/index.d.ts +37 -37
- package/dist/i18n/index.d.ts.map +1 -1
- package/dist/i18n/index.js.map +1 -1
- package/dist/router/index.browser.js +605 -244
- package/dist/router/index.browser.js.map +1 -1
- package/dist/router/index.d.ts +539 -550
- package/dist/router/index.d.ts.map +1 -1
- package/dist/router/index.js +1296 -922
- package/dist/router/index.js.map +1 -1
- package/dist/websocket/index.d.ts +38 -38
- package/dist/websocket/index.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/auth/__tests__/$auth.spec.ts +162 -147
- package/src/auth/index.ts +9 -3
- package/src/auth/services/ReactAuth.ts +15 -5
- package/src/core/hooks/useAction.ts +1 -2
- package/src/core/index.ts +4 -4
- package/src/form/errors/FormValidationError.ts +4 -6
- package/src/form/hooks/useFormState.ts +1 -1
- package/src/form/index.ts +1 -1
- package/src/form/services/FormModel.ts +31 -25
- package/src/head/helpers/SeoExpander.ts +2 -1
- package/src/head/hooks/useHead.spec.tsx +2 -2
- package/src/head/index.browser.ts +2 -2
- package/src/head/index.ts +4 -4
- package/src/head/interfaces/Head.ts +15 -3
- package/src/head/primitives/$head.ts +2 -5
- package/src/head/providers/BrowserHeadProvider.ts +55 -0
- package/src/head/providers/HeadProvider.ts +4 -1
- package/src/i18n/__tests__/integration.spec.tsx +1 -1
- package/src/i18n/components/Localize.spec.tsx +2 -2
- package/src/i18n/hooks/useI18n.browser.spec.tsx +2 -2
- package/src/i18n/index.ts +1 -1
- package/src/i18n/primitives/$dictionary.ts +1 -1
- package/src/i18n/providers/I18nProvider.spec.ts +1 -1
- package/src/i18n/providers/I18nProvider.ts +1 -1
- package/src/router/__tests__/page-head-browser.browser.spec.ts +5 -1
- package/src/router/__tests__/page-head.spec.ts +11 -7
- package/src/router/__tests__/seo-head.spec.ts +7 -3
- package/src/router/atoms/ssrManifestAtom.ts +2 -11
- package/src/router/components/ErrorViewer.tsx +626 -167
- package/src/router/components/Link.tsx +4 -2
- package/src/router/components/NestedView.tsx +7 -9
- package/src/router/components/NotFound.tsx +2 -2
- package/src/router/hooks/useQueryParams.ts +1 -1
- package/src/router/hooks/useRouter.ts +1 -1
- package/src/router/hooks/useRouterState.ts +1 -1
- package/src/router/index.browser.ts +10 -11
- package/src/router/index.shared.ts +7 -7
- package/src/router/index.ts +10 -7
- package/src/router/primitives/$page.browser.spec.tsx +6 -1
- package/src/router/primitives/$page.spec.tsx +7 -1
- package/src/router/primitives/$page.ts +5 -9
- package/src/router/providers/ReactBrowserProvider.ts +17 -6
- package/src/router/providers/ReactBrowserRouterProvider.ts +1 -1
- package/src/router/providers/ReactPageProvider.ts +4 -3
- package/src/router/providers/ReactServerProvider.ts +29 -37
- package/src/router/providers/ReactServerTemplateProvider.ts +300 -137
- package/src/router/providers/SSRManifestProvider.ts +17 -60
- package/src/router/services/ReactPageService.ts +4 -1
- package/src/router/services/ReactRouter.ts +6 -5
package/dist/router/index.d.ts
CHANGED
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
import { ClientOnlyProps } from "@alepha/react";
|
|
2
|
-
import * as
|
|
2
|
+
import * as alepha6 from "alepha";
|
|
3
3
|
import { Alepha, AlephaError, Async, KIND, Primitive, Static, TObject, TSchema } from "alepha";
|
|
4
4
|
import { DateTimeProvider } from "alepha/datetime";
|
|
5
|
-
import
|
|
5
|
+
import { ServerHandler, ServerRequest, ServerRouterProvider } from "alepha/server";
|
|
6
|
+
import { ServerRouteCache } from "alepha/server/cache";
|
|
6
7
|
import { LinkProvider } from "alepha/server/links";
|
|
7
|
-
import
|
|
8
|
-
import { Route, RouterProvider } from "alepha/router";
|
|
8
|
+
import * as alepha_logger0 from "alepha/logger";
|
|
9
9
|
import * as react0 from "react";
|
|
10
10
|
import { AnchorHTMLAttributes, CSSProperties, FC, ReactNode } from "react";
|
|
11
11
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
12
|
-
import {
|
|
12
|
+
import { BrowserHeadProvider, Head, ServerHeadProvider, SimpleHead } from "@alepha/react/head";
|
|
13
13
|
import { FileSystemProvider } from "alepha/file";
|
|
14
14
|
import { ServerStaticProvider } from "alepha/server/static";
|
|
15
|
-
import {
|
|
15
|
+
import { Route, RouterProvider } from "alepha/router";
|
|
16
16
|
|
|
17
|
+
//#region ../../src/router/constants/PAGE_PRELOAD_KEY.d.ts
|
|
18
|
+
/**
|
|
19
|
+
* Symbol key for SSR module preloading path.
|
|
20
|
+
* Using Symbol.for() allows the Vite plugin to inject this at build time.
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
declare const PAGE_PRELOAD_KEY: unique symbol;
|
|
24
|
+
//#endregion
|
|
17
25
|
//#region ../../src/router/errors/Redirection.d.ts
|
|
18
26
|
/**
|
|
19
27
|
* Used for Redirection during the page loading.
|
|
@@ -39,8 +47,8 @@ declare class Redirection extends AlephaError {
|
|
|
39
47
|
}
|
|
40
48
|
//#endregion
|
|
41
49
|
//#region ../../src/router/providers/ReactPageProvider.d.ts
|
|
42
|
-
declare const envSchema$1:
|
|
43
|
-
REACT_STRICT_MODE:
|
|
50
|
+
declare const envSchema$1: alepha6.TObject<{
|
|
51
|
+
REACT_STRICT_MODE: alepha6.TBoolean;
|
|
44
52
|
}>;
|
|
45
53
|
declare module "alepha" {
|
|
46
54
|
interface Env extends Partial<Static<typeof envSchema$1>> {}
|
|
@@ -69,10 +77,10 @@ declare class ReactPageProvider {
|
|
|
69
77
|
root(state: ReactRouterState): ReactNode;
|
|
70
78
|
protected convertStringObjectToObject: (schema?: TSchema, value?: any) => any;
|
|
71
79
|
/**
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
80
|
+
* Create a new RouterState based on a given route and request.
|
|
81
|
+
* This method resolves the layers for the route, applying any query and params schemas defined in the route.
|
|
82
|
+
* It also handles errors and redirects.
|
|
83
|
+
*/
|
|
76
84
|
createLayers(route: PageRoute, state: ReactRouterState, previous?: PreviousLayerData[]): Promise<CreateLayersResult>;
|
|
77
85
|
protected getErrorHandler(route: PageRoute): ErrorHandler | undefined;
|
|
78
86
|
protected createElement(page: PageRoute, props: Record<string, any>): Promise<ReactNode>;
|
|
@@ -85,7 +93,7 @@ declare class ReactPageProvider {
|
|
|
85
93
|
}, params?: Record<string, any>): string;
|
|
86
94
|
compile(path: string, params?: Record<string, string>): string;
|
|
87
95
|
protected renderView(index: number, path: string, view: ReactNode | undefined, page: PageRoute): ReactNode;
|
|
88
|
-
protected readonly configure:
|
|
96
|
+
protected readonly configure: alepha6.HookPrimitive<"configure">;
|
|
89
97
|
protected map(pages: Array<PagePrimitive>, target: PagePrimitive): PageRouteEntry;
|
|
90
98
|
add(entry: PageRouteEntry): void;
|
|
91
99
|
protected createMatch(page: PageRoute): string;
|
|
@@ -98,9 +106,9 @@ interface PageRouteEntry extends Omit<PagePrimitiveOptions, "children" | "parent
|
|
|
98
106
|
}
|
|
99
107
|
interface ConcretePageRoute extends PageRoute {
|
|
100
108
|
/**
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
109
|
+
* When exported, static routes can be split into multiple pages with different params.
|
|
110
|
+
* We replace 'name' by the new name for each static entry, and old 'name' becomes 'staticName'.
|
|
111
|
+
*/
|
|
104
112
|
staticName?: string;
|
|
105
113
|
params?: Record<string, string>;
|
|
106
114
|
}
|
|
@@ -133,33 +141,33 @@ interface AnchorProps {
|
|
|
133
141
|
}
|
|
134
142
|
interface ReactRouterState {
|
|
135
143
|
/**
|
|
136
|
-
|
|
137
|
-
|
|
144
|
+
* Stack of layers for the current page.
|
|
145
|
+
*/
|
|
138
146
|
layers: Array<Layer>;
|
|
139
147
|
/**
|
|
140
|
-
|
|
141
|
-
|
|
148
|
+
* URL of the current page.
|
|
149
|
+
*/
|
|
142
150
|
url: URL;
|
|
143
151
|
/**
|
|
144
|
-
|
|
145
|
-
|
|
152
|
+
* Error handler for the current page.
|
|
153
|
+
*/
|
|
146
154
|
onError: ErrorHandler;
|
|
147
155
|
/**
|
|
148
|
-
|
|
149
|
-
|
|
156
|
+
* Params extracted from the URL for the current page.
|
|
157
|
+
*/
|
|
150
158
|
params: Record<string, any>;
|
|
151
159
|
/**
|
|
152
|
-
|
|
153
|
-
|
|
160
|
+
* Query parameters extracted from the URL for the current page.
|
|
161
|
+
*/
|
|
154
162
|
query: Record<string, string>;
|
|
155
163
|
/**
|
|
156
|
-
|
|
157
|
-
|
|
164
|
+
* Optional meta information associated with the current page.
|
|
165
|
+
*/
|
|
158
166
|
meta: Record<string, any>;
|
|
159
167
|
/**
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
168
|
+
* Head configuration for the current page (title, meta tags, etc.).
|
|
169
|
+
* Populated by HeadProvider during SSR.
|
|
170
|
+
*/
|
|
163
171
|
head: Head;
|
|
164
172
|
name?: string;
|
|
165
173
|
}
|
|
@@ -190,14 +198,6 @@ declare abstract class ReactPageService {
|
|
|
190
198
|
render(name: string, options?: PagePrimitiveRenderOptions): Promise<PagePrimitiveRenderResult>;
|
|
191
199
|
}
|
|
192
200
|
//#endregion
|
|
193
|
-
//#region ../../src/router/constants/PAGE_PRELOAD_KEY.d.ts
|
|
194
|
-
/**
|
|
195
|
-
* Symbol key for SSR module preloading path.
|
|
196
|
-
* Using Symbol.for() allows the Vite plugin to inject this at build time.
|
|
197
|
-
* @internal
|
|
198
|
-
*/
|
|
199
|
-
declare const PAGE_PRELOAD_KEY: unique symbol;
|
|
200
|
-
//#endregion
|
|
201
201
|
//#region ../../src/router/primitives/$page.d.ts
|
|
202
202
|
/**
|
|
203
203
|
* Main primitive for defining a React route in the application.
|
|
@@ -293,214 +293,214 @@ declare const $page: {
|
|
|
293
293
|
};
|
|
294
294
|
interface PagePrimitiveOptions<TConfig extends PageConfigSchema = PageConfigSchema, TProps extends object = TPropsDefault, TPropsParent extends object = TPropsParentDefault> {
|
|
295
295
|
/**
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
296
|
+
* Identifier name for the page. Must be unique.
|
|
297
|
+
*
|
|
298
|
+
* @default Primitive key
|
|
299
|
+
*/
|
|
300
300
|
name?: string;
|
|
301
301
|
/**
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
302
|
+
* Add a pathname to the page.
|
|
303
|
+
*
|
|
304
|
+
* Pathname can contain parameters, like `/post/:slug`.
|
|
305
|
+
*
|
|
306
|
+
* @default ""
|
|
307
|
+
*/
|
|
308
308
|
path?: string;
|
|
309
309
|
/**
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
310
|
+
* Add an input schema to define:
|
|
311
|
+
* - `params`: parameters from the pathname.
|
|
312
|
+
* - `query`: query parameters from the URL.
|
|
313
|
+
*/
|
|
314
314
|
schema?: TConfig;
|
|
315
315
|
/**
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
316
|
+
* Load data before rendering the page.
|
|
317
|
+
*
|
|
318
|
+
* This function receives
|
|
319
|
+
* - the request context (params, query, etc.)
|
|
320
|
+
* - the parent props (if page has a parent)
|
|
321
|
+
*
|
|
322
|
+
* > In SSR, the returned data will be serialized and sent to the client, then reused during the client-side hydration.
|
|
323
|
+
*
|
|
324
|
+
* Loader can be stopped by throwing an error, which will be handled by the `errorHandler` function.
|
|
325
|
+
* It's common to throw a `NotFoundError` to display a 404 page.
|
|
326
|
+
*
|
|
327
|
+
* RedirectError can be thrown to redirect the user to another page.
|
|
328
|
+
*/
|
|
329
329
|
loader?: (context: PageLoader<TConfig, TPropsParent>) => Async<TProps>;
|
|
330
330
|
/**
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
331
|
+
* Default props to pass to the component when rendering the page.
|
|
332
|
+
*
|
|
333
|
+
* Resolved props from the `resolve` function will override these default props.
|
|
334
|
+
*/
|
|
335
335
|
props?: () => Partial<TProps>;
|
|
336
336
|
/**
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
337
|
+
* The component to render when the page is loaded.
|
|
338
|
+
*
|
|
339
|
+
* If `lazy` is defined, this will be ignored.
|
|
340
|
+
* Prefer using `lazy` to improve the initial loading time.
|
|
341
|
+
*/
|
|
342
342
|
component?: FC<TProps & TPropsParent>;
|
|
343
343
|
/**
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
344
|
+
* Lazy load the component when the page is loaded.
|
|
345
|
+
*
|
|
346
|
+
* It's recommended to use this for components to improve the initial loading time
|
|
347
|
+
* and enable code-splitting.
|
|
348
|
+
*/
|
|
349
349
|
lazy?: () => Promise<{
|
|
350
350
|
default: FC<TProps & TPropsParent>;
|
|
351
351
|
}>;
|
|
352
352
|
/**
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
353
|
+
* Attach child pages to create nested routes.
|
|
354
|
+
* This will make the page a parent route.
|
|
355
|
+
*/
|
|
356
356
|
children?: Array<PagePrimitive> | (() => Array<PagePrimitive>);
|
|
357
357
|
/**
|
|
358
|
-
|
|
359
|
-
|
|
358
|
+
* Define a parent page for nested routing.
|
|
359
|
+
*/
|
|
360
360
|
parent?: PagePrimitive<PageConfigSchema, TPropsParent, any>;
|
|
361
361
|
/**
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
362
|
+
* Function to determine if the page can be accessed.
|
|
363
|
+
*
|
|
364
|
+
* If it returns false, the page will not be accessible and a 403 Forbidden error will be returned.
|
|
365
|
+
* This function can be used to implement permission-based access control.
|
|
366
|
+
*/
|
|
367
367
|
can?: () => boolean;
|
|
368
368
|
/**
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
369
|
+
* Catch any error from the `loader` function or during `rendering`.
|
|
370
|
+
*
|
|
371
|
+
* Expected to return one of the following:
|
|
372
|
+
* - a ReactNode to render an error page
|
|
373
|
+
* - a Redirection to redirect the user
|
|
374
|
+
* - undefined to let the error propagate
|
|
375
|
+
*
|
|
376
|
+
* If not defined, the error will be thrown and handled by the server or client error handler.
|
|
377
|
+
* If a leaf $page does not define an error handler, the error can be caught by parent pages.
|
|
378
|
+
*
|
|
379
|
+
* @example Catch a 404 from API and render a custom not found component:
|
|
380
|
+
* ```ts
|
|
381
|
+
* loader: async ({ params, query }) => {
|
|
382
|
+
* api.fetch("/api/resource", { params, query });
|
|
383
|
+
* },
|
|
384
|
+
* errorHandler: (error, context) => {
|
|
385
|
+
* if (HttpError.is(error, 404)) {
|
|
386
|
+
* return <ResourceNotFound />;
|
|
387
|
+
* }
|
|
388
|
+
* }
|
|
389
|
+
* ```
|
|
390
|
+
*
|
|
391
|
+
* @example Catch an 401 error and redirect the user to the login page:
|
|
392
|
+
* ```ts
|
|
393
|
+
* loader: async ({ params, query }) => {
|
|
394
|
+
* // but the user is not authenticated
|
|
395
|
+
* api.fetch("/api/resource", { params, query });
|
|
396
|
+
* },
|
|
397
|
+
* errorHandler: (error, context) => {
|
|
398
|
+
* if (HttpError.is(error, 401)) {
|
|
399
|
+
* // throwing a Redirection is also valid!
|
|
400
|
+
* return new Redirection("/login");
|
|
401
|
+
* }
|
|
402
|
+
* }
|
|
403
|
+
* ```
|
|
404
|
+
*/
|
|
405
405
|
errorHandler?: ErrorHandler;
|
|
406
406
|
/**
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
407
|
+
* If true, the page will be considered as a static page, immutable and cacheable.
|
|
408
|
+
* Replace boolean by an object to define static entries. (e.g. list of params/query)
|
|
409
|
+
*
|
|
410
|
+
* Browser-side: it only works with `alepha/vite`, which can pre-render the page at build time.
|
|
411
|
+
*
|
|
412
|
+
* Server-side: It will act as timeless cached page. You can use `cache` to configure the cache behavior.
|
|
413
|
+
*/
|
|
414
414
|
static?: boolean | {
|
|
415
415
|
entries?: Array<Partial<PageRequestConfig<TConfig>>>;
|
|
416
416
|
};
|
|
417
417
|
cache?: ServerRouteCache;
|
|
418
418
|
/**
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
419
|
+
* If true, force the page to be rendered only on the client-side (browser).
|
|
420
|
+
* It uses the `<ClientOnly/>` component to render the page.
|
|
421
|
+
*/
|
|
422
422
|
client?: boolean | ClientOnlyProps;
|
|
423
423
|
/**
|
|
424
|
-
|
|
425
|
-
|
|
424
|
+
* Called before the server response is sent to the client. (server only)
|
|
425
|
+
*/
|
|
426
426
|
onServerResponse?: (request: ServerRequest) => unknown;
|
|
427
427
|
/**
|
|
428
|
-
|
|
429
|
-
|
|
428
|
+
* Called when user leaves the page. (browser only)
|
|
429
|
+
*/
|
|
430
430
|
onLeave?: () => void;
|
|
431
431
|
/**
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
432
|
+
* @experimental
|
|
433
|
+
*
|
|
434
|
+
* Add a css animation when the page is loaded or unloaded.
|
|
435
|
+
* It uses CSS animations, so you need to define the keyframes in your CSS.
|
|
436
|
+
*
|
|
437
|
+
* @example Simple animation name
|
|
438
|
+
* ```ts
|
|
439
|
+
* animation: "fadeIn"
|
|
440
|
+
* ```
|
|
441
|
+
*
|
|
442
|
+
* CSS example:
|
|
443
|
+
* ```css
|
|
444
|
+
* @keyframes fadeIn {
|
|
445
|
+
* from { opacity: 0; }
|
|
446
|
+
* to { opacity: 1; }
|
|
447
|
+
* }
|
|
448
|
+
* ```
|
|
449
|
+
*
|
|
450
|
+
* @example Detailed animation
|
|
451
|
+
* ```ts
|
|
452
|
+
* animation: {
|
|
453
|
+
* enter: { name: "fadeIn", duration: 300 },
|
|
454
|
+
* exit: { name: "fadeOut", duration: 200, timing: "ease-in-out" },
|
|
455
|
+
* }
|
|
456
|
+
* ```
|
|
457
|
+
*
|
|
458
|
+
* @example Only exit animation
|
|
459
|
+
* ```ts
|
|
460
|
+
* animation: {
|
|
461
|
+
* exit: "fadeOut"
|
|
462
|
+
* }
|
|
463
|
+
* ```
|
|
464
|
+
*
|
|
465
|
+
* @example With custom timing function
|
|
466
|
+
* ```ts
|
|
467
|
+
* animation: {
|
|
468
|
+
* enter: { name: "fadeIn", duration: 300, timing: "cubic-bezier(0.4, 0, 0.2, 1)" },
|
|
469
|
+
* exit: { name: "fadeOut", duration: 200, timing: "ease-in-out" },
|
|
470
|
+
* }
|
|
471
|
+
* ```
|
|
472
|
+
*/
|
|
473
473
|
animation?: PageAnimation;
|
|
474
474
|
/**
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
475
|
+
* Head configuration for the page (title, meta tags, etc.).
|
|
476
|
+
*
|
|
477
|
+
* Can be a static object or a function that receives resolved props.
|
|
478
|
+
*
|
|
479
|
+
* @example Static head
|
|
480
|
+
* ```ts
|
|
481
|
+
* head: {
|
|
482
|
+
* title: "My Page",
|
|
483
|
+
* description: "Page description",
|
|
484
|
+
* }
|
|
485
|
+
* ```
|
|
486
|
+
*
|
|
487
|
+
* @example Dynamic head based on props
|
|
488
|
+
* ```ts
|
|
489
|
+
* head: (props) => ({
|
|
490
|
+
* title: props.user.name,
|
|
491
|
+
* description: `Profile of ${props.user.name}`,
|
|
492
|
+
* })
|
|
493
|
+
* ```
|
|
494
|
+
*/
|
|
495
495
|
head?: Head | ((props: TProps, previous?: Head) => Head);
|
|
496
496
|
/**
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
497
|
+
* Source path for SSR module preloading.
|
|
498
|
+
*
|
|
499
|
+
* This is automatically injected by the viteAlephaPreload plugin.
|
|
500
|
+
* It maps to the source file path used in Vite's SSR manifest.
|
|
501
|
+
*
|
|
502
|
+
* @internal
|
|
503
|
+
*/
|
|
504
504
|
[PAGE_PRELOAD_KEY]?: string;
|
|
505
505
|
}
|
|
506
506
|
type ErrorHandler = (error: Error, state: ReactRouterState) => ReactNode | Redirection | undefined;
|
|
@@ -509,11 +509,11 @@ declare class PagePrimitive<TConfig extends PageConfigSchema = PageConfigSchema,
|
|
|
509
509
|
protected onInit(): void;
|
|
510
510
|
get name(): string;
|
|
511
511
|
/**
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
512
|
+
* For testing or build purposes.
|
|
513
|
+
*
|
|
514
|
+
* This will render the page (HTML layout included or not) and return the HTML + context.
|
|
515
|
+
* Only valid for server-side rendering, it will throw an error if called on the client-side.
|
|
516
|
+
*/
|
|
517
517
|
render(options?: PagePrimitiveRenderOptions): Promise<PagePrimitiveRenderResult>;
|
|
518
518
|
fetch(options?: PagePrimitiveRenderOptions): Promise<{
|
|
519
519
|
html: string;
|
|
@@ -532,11 +532,11 @@ interface PagePrimitiveRenderOptions {
|
|
|
532
532
|
params?: Record<string, string>;
|
|
533
533
|
query?: Record<string, string>;
|
|
534
534
|
/**
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
535
|
+
* If true, the HTML layout will be included in the response.
|
|
536
|
+
* If false, only the page content will be returned.
|
|
537
|
+
*
|
|
538
|
+
* @default true
|
|
539
|
+
*/
|
|
540
540
|
html?: boolean;
|
|
541
541
|
hydration?: boolean;
|
|
542
542
|
}
|
|
@@ -562,24 +562,6 @@ type CssAnimation = {
|
|
|
562
562
|
timing?: string;
|
|
563
563
|
};
|
|
564
564
|
//#endregion
|
|
565
|
-
//#region ../../src/router/providers/ReactBrowserRouterProvider.d.ts
|
|
566
|
-
interface BrowserRoute extends Route {
|
|
567
|
-
page: PageRoute;
|
|
568
|
-
}
|
|
569
|
-
/**
|
|
570
|
-
* Implementation of AlephaRouter for React in browser environment.
|
|
571
|
-
*/
|
|
572
|
-
declare class ReactBrowserRouterProvider extends RouterProvider<BrowserRoute> {
|
|
573
|
-
protected readonly log: alepha_logger0.Logger;
|
|
574
|
-
protected readonly alepha: Alepha;
|
|
575
|
-
protected readonly pageApi: ReactPageProvider;
|
|
576
|
-
protected readonly browserHeadProvider: BrowserHeadProvider;
|
|
577
|
-
add(entry: PageRouteEntry): void;
|
|
578
|
-
protected readonly configure: alepha1.HookPrimitive<"configure">;
|
|
579
|
-
transition(url: URL, previous?: PreviousLayerData[], meta?: {}): Promise<string | void>;
|
|
580
|
-
root(state: ReactRouterState): ReactNode;
|
|
581
|
-
}
|
|
582
|
-
//#endregion
|
|
583
565
|
//#region ../../src/router/services/ReactRouter.d.ts
|
|
584
566
|
interface RouterGoOptions {
|
|
585
567
|
replace?: boolean;
|
|
@@ -587,8 +569,8 @@ interface RouterGoOptions {
|
|
|
587
569
|
query?: Record<string, string>;
|
|
588
570
|
meta?: Record<string, any>;
|
|
589
571
|
/**
|
|
590
|
-
|
|
591
|
-
|
|
572
|
+
* Recreate the whole page, ignoring the current state.
|
|
573
|
+
*/
|
|
592
574
|
force?: boolean;
|
|
593
575
|
}
|
|
594
576
|
/**
|
|
@@ -615,9 +597,9 @@ declare class ReactRouter<T extends object> {
|
|
|
615
597
|
query?: Record<string, any>;
|
|
616
598
|
}): string;
|
|
617
599
|
/**
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
600
|
+
* Reload the current page.
|
|
601
|
+
* This is equivalent to calling `go()` with the current pathname and search.
|
|
602
|
+
*/
|
|
621
603
|
reload(): Promise<void>;
|
|
622
604
|
getURL(): URL;
|
|
623
605
|
get location(): Location;
|
|
@@ -633,26 +615,44 @@ declare class ReactRouter<T extends object> {
|
|
|
633
615
|
anchor(path: keyof VirtualRouter<T>, options?: RouterGoOptions): AnchorProps;
|
|
634
616
|
base(path: string): string;
|
|
635
617
|
/**
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
618
|
+
* Set query params.
|
|
619
|
+
*
|
|
620
|
+
* @param record
|
|
621
|
+
* @param options
|
|
622
|
+
*/
|
|
641
623
|
setQueryParams(record: Record<string, any> | ((queryParams: Record<string, any>) => Record<string, any>), options?: {
|
|
642
624
|
/**
|
|
643
|
-
|
|
644
|
-
|
|
625
|
+
* If true, this will add a new entry to the history stack.
|
|
626
|
+
*/
|
|
645
627
|
push?: boolean;
|
|
646
628
|
}): void;
|
|
647
629
|
}
|
|
648
630
|
type VirtualRouter<T> = { [K in keyof T as T[K] extends PagePrimitive ? K : never]: T[K] };
|
|
649
631
|
//#endregion
|
|
632
|
+
//#region ../../src/router/providers/ReactBrowserRouterProvider.d.ts
|
|
633
|
+
interface BrowserRoute extends Route {
|
|
634
|
+
page: PageRoute;
|
|
635
|
+
}
|
|
636
|
+
/**
|
|
637
|
+
* Implementation of AlephaRouter for React in browser environment.
|
|
638
|
+
*/
|
|
639
|
+
declare class ReactBrowserRouterProvider extends RouterProvider<BrowserRoute> {
|
|
640
|
+
protected readonly log: alepha_logger0.Logger;
|
|
641
|
+
protected readonly alepha: Alepha;
|
|
642
|
+
protected readonly pageApi: ReactPageProvider;
|
|
643
|
+
protected readonly browserHeadProvider: BrowserHeadProvider;
|
|
644
|
+
add(entry: PageRouteEntry): void;
|
|
645
|
+
protected readonly configure: alepha6.HookPrimitive<"configure">;
|
|
646
|
+
transition(url: URL, previous?: PreviousLayerData[], meta?: {}): Promise<string | void>;
|
|
647
|
+
root(state: ReactRouterState): ReactNode;
|
|
648
|
+
}
|
|
649
|
+
//#endregion
|
|
650
650
|
//#region ../../src/router/providers/ReactBrowserProvider.d.ts
|
|
651
651
|
/**
|
|
652
652
|
* React browser renderer configuration atom
|
|
653
653
|
*/
|
|
654
|
-
declare const reactBrowserOptions:
|
|
655
|
-
scrollRestoration:
|
|
654
|
+
declare const reactBrowserOptions: alepha6.Atom<alepha6.TObject<{
|
|
655
|
+
scrollRestoration: alepha6.TUnsafe<"top" | "manual">;
|
|
656
656
|
}>, "alepha.react.browser.options">;
|
|
657
657
|
type ReactBrowserRendererOptions = Static<typeof reactBrowserOptions.schema>;
|
|
658
658
|
declare module "alepha" {
|
|
@@ -678,16 +678,16 @@ declare class ReactBrowserProvider {
|
|
|
678
678
|
};
|
|
679
679
|
get state(): ReactRouterState;
|
|
680
680
|
/**
|
|
681
|
-
|
|
682
|
-
|
|
681
|
+
* Accessor for Document DOM API.
|
|
682
|
+
*/
|
|
683
683
|
get document(): Document;
|
|
684
684
|
/**
|
|
685
|
-
|
|
686
|
-
|
|
685
|
+
* Accessor for History DOM API.
|
|
686
|
+
*/
|
|
687
687
|
get history(): History;
|
|
688
688
|
/**
|
|
689
|
-
|
|
690
|
-
|
|
689
|
+
* Accessor for Location DOM API.
|
|
690
|
+
*/
|
|
691
691
|
get location(): Location;
|
|
692
692
|
get base(): string;
|
|
693
693
|
get url(): string;
|
|
@@ -696,11 +696,11 @@ declare class ReactBrowserProvider {
|
|
|
696
696
|
go(url: string, options?: RouterGoOptions): Promise<void>;
|
|
697
697
|
protected render(options?: RouterRenderOptions): Promise<void>;
|
|
698
698
|
/**
|
|
699
|
-
|
|
700
|
-
|
|
699
|
+
* Get embedded layers from the server.
|
|
700
|
+
*/
|
|
701
701
|
protected getHydrationState(): ReactHydrationState | undefined;
|
|
702
|
-
protected readonly onTransitionEnd:
|
|
703
|
-
readonly ready:
|
|
702
|
+
protected readonly onTransitionEnd: alepha6.HookPrimitive<"react:transition:end">;
|
|
703
|
+
readonly ready: alepha6.HookPrimitive<"ready">;
|
|
704
704
|
}
|
|
705
705
|
type ReactHydrationState = {
|
|
706
706
|
layers?: Array<PreviousLayerData>;
|
|
@@ -719,7 +719,7 @@ interface ErrorViewerProps {
|
|
|
719
719
|
alepha: Alepha;
|
|
720
720
|
}
|
|
721
721
|
/**
|
|
722
|
-
* Error viewer component
|
|
722
|
+
* Error viewer component - Terminal/brutalist aesthetic
|
|
723
723
|
*/
|
|
724
724
|
declare const ErrorViewer: ({
|
|
725
725
|
error,
|
|
@@ -1114,187 +1114,183 @@ declare class ReactServerTemplateProvider {
|
|
|
1114
1114
|
protected readonly log: alepha_logger0.Logger;
|
|
1115
1115
|
protected readonly alepha: Alepha;
|
|
1116
1116
|
/**
|
|
1117
|
-
|
|
1118
|
-
|
|
1117
|
+
* Shared TextEncoder instance - reused across all requests.
|
|
1118
|
+
*/
|
|
1119
1119
|
protected readonly encoder: TextEncoder;
|
|
1120
1120
|
/**
|
|
1121
|
-
|
|
1122
|
-
|
|
1121
|
+
* Pre-encoded common strings for streaming.
|
|
1122
|
+
*/
|
|
1123
1123
|
protected readonly ENCODED: {
|
|
1124
1124
|
readonly HYDRATION_PREFIX: Uint8Array<ArrayBuffer>;
|
|
1125
1125
|
readonly HYDRATION_SUFFIX: Uint8Array<ArrayBuffer>;
|
|
1126
1126
|
readonly EMPTY: Uint8Array<ArrayBuffer>;
|
|
1127
1127
|
};
|
|
1128
1128
|
/**
|
|
1129
|
-
|
|
1130
|
-
|
|
1129
|
+
* Cached template slots - parsed once, reused for all requests.
|
|
1130
|
+
*/
|
|
1131
1131
|
protected slots: TemplateSlots | null;
|
|
1132
1132
|
/**
|
|
1133
|
-
|
|
1134
|
-
|
|
1133
|
+
* Root element ID for React mounting.
|
|
1134
|
+
*/
|
|
1135
1135
|
get rootId(): string;
|
|
1136
1136
|
/**
|
|
1137
|
-
|
|
1138
|
-
|
|
1137
|
+
* Regex pattern for matching the root div and extracting its content.
|
|
1138
|
+
*/
|
|
1139
1139
|
get rootDivRegex(): RegExp;
|
|
1140
1140
|
/**
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1141
|
+
* Extract the content inside the root div from HTML.
|
|
1142
|
+
*
|
|
1143
|
+
* @param html - Full HTML string
|
|
1144
|
+
* @returns The content inside the root div, or undefined if not found
|
|
1145
|
+
*/
|
|
1146
1146
|
extractRootContent(html: string): string | undefined;
|
|
1147
1147
|
/**
|
|
1148
|
-
|
|
1149
|
-
|
|
1148
|
+
* Check if template has been parsed and slots are available.
|
|
1149
|
+
*/
|
|
1150
1150
|
isReady(): boolean;
|
|
1151
1151
|
/**
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1152
|
+
* Get the parsed template slots.
|
|
1153
|
+
* Throws if template hasn't been parsed yet.
|
|
1154
|
+
*/
|
|
1155
1155
|
getSlots(): TemplateSlots;
|
|
1156
1156
|
/**
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
* @param template - The HTML template string (typically index.html)
|
|
1163
|
-
*/
|
|
1157
|
+
* Parse an HTML template into logical slots for efficient streaming.
|
|
1158
|
+
*
|
|
1159
|
+
* This should be called once during server startup/configuration.
|
|
1160
|
+
* The parsed slots are cached and reused for all requests.
|
|
1161
|
+
*/
|
|
1164
1162
|
parseTemplate(template: string): TemplateSlots;
|
|
1165
1163
|
/**
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1164
|
+
* Parse HTML attributes string into a record.
|
|
1165
|
+
*
|
|
1166
|
+
* Handles: key="value", key='value', key=value, and boolean key
|
|
1167
|
+
*/
|
|
1170
1168
|
protected parseAttributes(attrStr: string): Record<string, string>;
|
|
1171
1169
|
/**
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1170
|
+
* Render attributes record to HTML string.
|
|
1171
|
+
*
|
|
1172
|
+
* @param attrs - Attributes to render
|
|
1173
|
+
* @returns HTML attribute string like ` lang="en" class="dark"`
|
|
1174
|
+
*/
|
|
1177
1175
|
renderAttributes(attrs: Record<string, string>): string;
|
|
1178
1176
|
/**
|
|
1179
|
-
|
|
1180
|
-
|
|
1177
|
+
* Render merged HTML attributes (original + dynamic).
|
|
1178
|
+
*/
|
|
1181
1179
|
renderMergedHtmlAttrs(dynamicAttrs?: Record<string, string>): string;
|
|
1182
1180
|
/**
|
|
1183
|
-
|
|
1184
|
-
|
|
1181
|
+
* Render merged body attributes (original + dynamic).
|
|
1182
|
+
*/
|
|
1185
1183
|
renderMergedBodyAttrs(dynamicAttrs?: Record<string, string>): string;
|
|
1186
1184
|
/**
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1185
|
+
* Render head content (title, meta, link, script tags).
|
|
1186
|
+
*
|
|
1187
|
+
* @param head - Head data to render
|
|
1188
|
+
* @param includeOriginal - Whether to include original head content
|
|
1189
|
+
* @returns HTML string with head content
|
|
1190
|
+
*/
|
|
1193
1191
|
renderHeadContent(head?: SimpleHead, includeOriginal?: boolean): string;
|
|
1194
1192
|
/**
|
|
1195
|
-
|
|
1196
|
-
|
|
1193
|
+
* Render a meta tag.
|
|
1194
|
+
*/
|
|
1197
1195
|
protected renderMetaTag(meta: {
|
|
1198
1196
|
name?: string;
|
|
1199
1197
|
property?: string;
|
|
1200
1198
|
content: string;
|
|
1201
1199
|
}): string;
|
|
1202
1200
|
/**
|
|
1203
|
-
|
|
1204
|
-
|
|
1201
|
+
* Render a link tag.
|
|
1202
|
+
*/
|
|
1205
1203
|
protected renderLinkTag(link: {
|
|
1206
1204
|
rel: string;
|
|
1207
1205
|
href: string;
|
|
1206
|
+
type?: string;
|
|
1208
1207
|
as?: string;
|
|
1209
1208
|
crossorigin?: string;
|
|
1210
1209
|
}): string;
|
|
1211
1210
|
/**
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
protected renderScriptTag(script: Record<string, string | boolean>
|
|
1211
|
+
* Render a script tag.
|
|
1212
|
+
*/
|
|
1213
|
+
protected renderScriptTag(script: string | (Record<string, string | boolean | undefined> & {
|
|
1214
|
+
content?: string;
|
|
1215
|
+
})): string;
|
|
1215
1216
|
/**
|
|
1216
|
-
|
|
1217
|
-
|
|
1217
|
+
* Escape HTML special characters.
|
|
1218
|
+
*/
|
|
1218
1219
|
escapeHtml(str: string): string;
|
|
1219
1220
|
/**
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1221
|
+
* Safely serialize data to JSON for embedding in HTML.
|
|
1222
|
+
* Escapes characters that could break out of script tags.
|
|
1223
|
+
*/
|
|
1223
1224
|
safeJsonSerialize(data: unknown): string;
|
|
1224
1225
|
/**
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1226
|
+
* Build hydration data from router state.
|
|
1227
|
+
*
|
|
1228
|
+
* This creates the data structure that will be serialized to window.__ssr
|
|
1229
|
+
* for client-side rehydration.
|
|
1230
|
+
*/
|
|
1230
1231
|
buildHydrationData(state: ReactRouterState): HydrationData;
|
|
1231
1232
|
/**
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
*
|
|
1251
|
-
* @param reactStream - ReadableStream from renderToReadableStream
|
|
1252
|
-
* @param state - Router state with head data
|
|
1253
|
-
* @param options - Streaming options
|
|
1254
|
-
*/
|
|
1233
|
+
* Stream the body content: body tag, root div, React content, hydration, and closing tags.
|
|
1234
|
+
*
|
|
1235
|
+
* If an error occurs during React streaming, it injects error HTML instead of aborting,
|
|
1236
|
+
* ensuring users see an error message rather than a white screen.
|
|
1237
|
+
*/
|
|
1238
|
+
protected streamBodyContent(controller: ReadableStreamDefaultController<Uint8Array>, reactStream: ReadableStream<Uint8Array>, state: ReactRouterState, hydration: boolean): Promise<void>;
|
|
1239
|
+
/**
|
|
1240
|
+
* Create a ReadableStream that streams the HTML template with React content.
|
|
1241
|
+
*
|
|
1242
|
+
* This is the main entry point for SSR streaming. It:
|
|
1243
|
+
* 1. Sends <head> immediately (browser starts downloading assets)
|
|
1244
|
+
* 2. Streams React content as it renders
|
|
1245
|
+
* 3. Appends hydration script and closing tags
|
|
1246
|
+
*
|
|
1247
|
+
* @param reactStream - ReadableStream from renderToReadableStream
|
|
1248
|
+
* @param state - Router state with head data
|
|
1249
|
+
* @param options - Streaming options
|
|
1250
|
+
*/
|
|
1255
1251
|
createHtmlStream(reactStream: ReadableStream<Uint8Array>, state: ReactRouterState, options?: {
|
|
1256
1252
|
hydration?: boolean;
|
|
1257
1253
|
onError?: (error: unknown) => void;
|
|
1258
1254
|
}): ReadableStream<Uint8Array>;
|
|
1259
1255
|
/**
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1256
|
+
* Early head content for preloading.
|
|
1257
|
+
*
|
|
1258
|
+
* Contains entry assets (JS + CSS) that are always required and can be
|
|
1259
|
+
* sent before page loaders run.
|
|
1260
|
+
*/
|
|
1265
1261
|
protected earlyHeadContent: string;
|
|
1266
1262
|
/**
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1263
|
+
* Set the early head content (entry script + CSS).
|
|
1264
|
+
*
|
|
1265
|
+
* Also strips these assets from the original head content to avoid duplicates,
|
|
1266
|
+
* since we're moving them to the early phase.
|
|
1267
|
+
*
|
|
1268
|
+
* @param content - HTML string with entry assets
|
|
1269
|
+
* @param entryAssets - Entry asset paths to strip from original head
|
|
1270
|
+
*/
|
|
1275
1271
|
setEarlyHeadContent(content: string, entryAssets?: {
|
|
1276
1272
|
js?: string;
|
|
1277
1273
|
css: string[];
|
|
1278
1274
|
}): void;
|
|
1279
1275
|
/**
|
|
1280
|
-
|
|
1281
|
-
|
|
1276
|
+
* Escape special regex characters in a string.
|
|
1277
|
+
*/
|
|
1282
1278
|
protected escapeRegExp(str: string): string;
|
|
1283
1279
|
/**
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1280
|
+
* Create an optimized HTML stream with early head streaming.
|
|
1281
|
+
*
|
|
1282
|
+
* This version sends critical assets (entry.js, CSS) BEFORE page loaders run,
|
|
1283
|
+
* allowing the browser to start downloading them immediately.
|
|
1284
|
+
*
|
|
1285
|
+
* Flow:
|
|
1286
|
+
* 1. Send DOCTYPE, <html>, <head> open, entry preloads (IMMEDIATE)
|
|
1287
|
+
* 2. Run async work (createLayers, etc.)
|
|
1288
|
+
* 3. Send rest of head, body, React content, hydration
|
|
1289
|
+
*
|
|
1290
|
+
* @param globalHead - Global head with htmlAttributes (from $head primitives)
|
|
1291
|
+
* @param asyncWork - Async function to run between early head and rest of stream
|
|
1292
|
+
* @param options - Streaming options
|
|
1293
|
+
*/
|
|
1298
1294
|
createEarlyHtmlStream(globalHead: SimpleHead, asyncWork: () => Promise<{
|
|
1299
1295
|
state: ReactRouterState;
|
|
1300
1296
|
reactStream: ReadableStream<Uint8Array>;
|
|
@@ -1304,6 +1300,34 @@ declare class ReactServerTemplateProvider {
|
|
|
1304
1300
|
hydration?: boolean;
|
|
1305
1301
|
onError?: (error: unknown) => void;
|
|
1306
1302
|
}): ReadableStream<Uint8Array>;
|
|
1303
|
+
/**
|
|
1304
|
+
* Inject error HTML into the stream when an error occurs during streaming.
|
|
1305
|
+
*
|
|
1306
|
+
* Uses the router state's onError handler to render the error component,
|
|
1307
|
+
* falling back to ErrorViewer if no custom handler is defined.
|
|
1308
|
+
* Renders using renderToString to produce static HTML.
|
|
1309
|
+
*
|
|
1310
|
+
* Since we may have already sent partial HTML (DOCTYPE, <html>, <head>),
|
|
1311
|
+
* we need to complete the document with an error message instead of aborting.
|
|
1312
|
+
*
|
|
1313
|
+
* Handles different states:
|
|
1314
|
+
* - headClosed=false, bodyStarted=false: Need to add head content, close head, open body, add error, close all
|
|
1315
|
+
* - headClosed=true, bodyStarted=false: Need to open body, add error, close all
|
|
1316
|
+
* - headClosed=true, bodyStarted=true: Already inside root div, add error, close all
|
|
1317
|
+
*/
|
|
1318
|
+
protected injectErrorHtml(controller: ReadableStreamDefaultController<Uint8Array>, encoder: TextEncoder, slots: TemplateSlots, error: unknown, routerState: ReactRouterState | undefined, streamState: {
|
|
1319
|
+
headClosed: boolean;
|
|
1320
|
+
bodyStarted: boolean;
|
|
1321
|
+
}): void;
|
|
1322
|
+
/**
|
|
1323
|
+
* Render an error to HTML string using the router's error handler.
|
|
1324
|
+
*
|
|
1325
|
+
* Falls back to ErrorViewer if:
|
|
1326
|
+
* - No router state is available
|
|
1327
|
+
* - The error handler returns null/undefined
|
|
1328
|
+
* - The error handler itself throws
|
|
1329
|
+
*/
|
|
1330
|
+
protected renderErrorToString(error: Error, routerState: ReactRouterState | undefined): string;
|
|
1307
1331
|
}
|
|
1308
1332
|
/**
|
|
1309
1333
|
* Template slots - the template split into logical parts for efficient streaming.
|
|
@@ -1347,28 +1371,21 @@ interface HydrationData {
|
|
|
1347
1371
|
/**
|
|
1348
1372
|
* Schema for the SSR manifest atom.
|
|
1349
1373
|
*/
|
|
1350
|
-
declare const ssrManifestAtomSchema:
|
|
1351
|
-
/**
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
preload:
|
|
1356
|
-
/**
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
src: alepha1.TOptional<alepha1.TString>;
|
|
1366
|
-
isEntry: alepha1.TOptional<alepha1.TBoolean>;
|
|
1367
|
-
isDynamicEntry: alepha1.TOptional<alepha1.TBoolean>;
|
|
1368
|
-
imports: alepha1.TOptional<alepha1.TArray<alepha1.TString>>;
|
|
1369
|
-
dynamicImports: alepha1.TOptional<alepha1.TArray<alepha1.TString>>;
|
|
1370
|
-
css: alepha1.TOptional<alepha1.TArray<alepha1.TString>>;
|
|
1371
|
-
assets: alepha1.TOptional<alepha1.TArray<alepha1.TString>>;
|
|
1374
|
+
declare const ssrManifestAtomSchema: alepha6.TObject<{
|
|
1375
|
+
/**
|
|
1376
|
+
* Preload manifest mapping short keys to source paths.
|
|
1377
|
+
* Generated by viteAlephaSsrPreload plugin at build time.
|
|
1378
|
+
*/
|
|
1379
|
+
preload: alepha6.TOptional<alepha6.TRecord<"^.*$", alepha6.TString>>;
|
|
1380
|
+
/**
|
|
1381
|
+
* Client manifest mapping source files to their output information.
|
|
1382
|
+
* Only includes fields actually used for preloading.
|
|
1383
|
+
*/
|
|
1384
|
+
client: alepha6.TOptional<alepha6.TRecord<"^.*$", alepha6.TObject<{
|
|
1385
|
+
file: alepha6.TString;
|
|
1386
|
+
isEntry: alepha6.TOptional<alepha6.TBoolean>;
|
|
1387
|
+
imports: alepha6.TOptional<alepha6.TArray<alepha6.TString>>;
|
|
1388
|
+
css: alepha6.TOptional<alepha6.TArray<alepha6.TString>>;
|
|
1372
1389
|
}>>>;
|
|
1373
1390
|
}>;
|
|
1374
1391
|
/**
|
|
@@ -1386,72 +1403,58 @@ type SsrManifestAtomSchema = typeof ssrManifestAtomSchema;
|
|
|
1386
1403
|
*
|
|
1387
1404
|
* Manifest files are generated during `vite build`:
|
|
1388
1405
|
* - manifest.json (client manifest)
|
|
1389
|
-
* - ssr-manifest.json (SSR manifest)
|
|
1390
1406
|
* - preload-manifest.json (from viteAlephaSsrPreload plugin)
|
|
1391
1407
|
*/
|
|
1392
1408
|
declare class SSRManifestProvider {
|
|
1393
1409
|
protected readonly alepha: Alepha;
|
|
1394
1410
|
/**
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1411
|
+
* Get the manifest from the store at runtime.
|
|
1412
|
+
* This ensures the manifest is available even when set after module load.
|
|
1413
|
+
*/
|
|
1398
1414
|
protected get manifest(): Static<SsrManifestAtomSchema>;
|
|
1399
1415
|
/**
|
|
1400
|
-
|
|
1401
|
-
|
|
1416
|
+
* Get the preload manifest.
|
|
1417
|
+
*/
|
|
1402
1418
|
protected get preloadManifest(): PreloadManifest | undefined;
|
|
1403
1419
|
/**
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
protected get ssrManifest(): SSRManifest | undefined;
|
|
1407
|
-
/**
|
|
1408
|
-
* Get the client manifest.
|
|
1409
|
-
*/
|
|
1420
|
+
* Get the client manifest.
|
|
1421
|
+
*/
|
|
1410
1422
|
protected get clientManifest(): ClientManifest | undefined;
|
|
1411
1423
|
/**
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1424
|
+
* Resolve a preload key to its source path.
|
|
1425
|
+
*
|
|
1426
|
+
* The key is a short hash injected by viteAlephaSsrPreload plugin,
|
|
1427
|
+
* which maps to the full source path in the preload manifest.
|
|
1428
|
+
*
|
|
1429
|
+
* @param key - Short hash key (e.g., "a1b2c3d4")
|
|
1430
|
+
* @returns Source path (e.g., "src/pages/UserDetail.tsx") or undefined
|
|
1431
|
+
*/
|
|
1420
1432
|
resolvePreloadKey(key: string): string | undefined;
|
|
1421
1433
|
/**
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
*/
|
|
1434
|
+
* Get all chunks required for a source file, including transitive dependencies.
|
|
1435
|
+
*
|
|
1436
|
+
* Uses the client manifest to recursively resolve all imported chunks.
|
|
1437
|
+
*
|
|
1438
|
+
* @param sourcePath - Source file path (e.g., "src/pages/Home.tsx")
|
|
1439
|
+
* @returns Array of chunk URLs to preload, or empty array if not found
|
|
1440
|
+
*/
|
|
1430
1441
|
getChunks(sourcePath: string): string[];
|
|
1431
1442
|
/**
|
|
1432
|
-
|
|
1433
|
-
|
|
1443
|
+
* Find manifest entry for a source path, trying different extensions.
|
|
1444
|
+
*/
|
|
1434
1445
|
protected findManifestEntry(sourcePath: string): {
|
|
1435
1446
|
file: string;
|
|
1436
|
-
src?: string;
|
|
1437
1447
|
isEntry?: boolean;
|
|
1438
|
-
isDynamicEntry?: boolean;
|
|
1439
1448
|
imports?: string[];
|
|
1440
|
-
dynamicImports?: string[];
|
|
1441
1449
|
css?: string[];
|
|
1442
|
-
assets?: string[];
|
|
1443
1450
|
} | undefined;
|
|
1444
1451
|
/**
|
|
1445
|
-
|
|
1446
|
-
|
|
1452
|
+
* Recursively collect all chunk URLs for a manifest entry.
|
|
1453
|
+
*/
|
|
1447
1454
|
protected collectChunksRecursive(key: string, chunks: Set<string>, visited: Set<string>): void;
|
|
1448
1455
|
/**
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
protected getChunksFromSSRManifest(sourcePath: string): string[];
|
|
1452
|
-
/**
|
|
1453
|
-
* Collect modulepreload links for a route and its parent chain.
|
|
1454
|
-
*/
|
|
1456
|
+
* Collect modulepreload links for a route and its parent chain.
|
|
1457
|
+
*/
|
|
1455
1458
|
collectPreloadLinks(route: PageRoute): Array<{
|
|
1456
1459
|
rel: string;
|
|
1457
1460
|
href: string;
|
|
@@ -1459,34 +1462,34 @@ declare class SSRManifestProvider {
|
|
|
1459
1462
|
crossorigin?: string;
|
|
1460
1463
|
}>;
|
|
1461
1464
|
/**
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1465
|
+
* Get all chunks for multiple source files.
|
|
1466
|
+
*
|
|
1467
|
+
* @param sourcePaths - Array of source file paths
|
|
1468
|
+
* @returns Deduplicated array of chunk URLs
|
|
1469
|
+
*/
|
|
1467
1470
|
getChunksForMultiple(sourcePaths: string[]): string[];
|
|
1468
1471
|
/**
|
|
1469
|
-
|
|
1470
|
-
|
|
1472
|
+
* Check if manifest is loaded and available.
|
|
1473
|
+
*/
|
|
1471
1474
|
isAvailable(): boolean;
|
|
1472
1475
|
/**
|
|
1473
|
-
|
|
1474
|
-
|
|
1476
|
+
* Cached entry assets - computed once at first access.
|
|
1477
|
+
*/
|
|
1475
1478
|
protected cachedEntryAssets: EntryAssets | null;
|
|
1476
1479
|
/**
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1480
|
+
* Get the entry point assets (main entry.js and associated CSS files).
|
|
1481
|
+
*
|
|
1482
|
+
* These assets are always required for all pages and can be preloaded
|
|
1483
|
+
* before page-specific loaders run.
|
|
1484
|
+
*
|
|
1485
|
+
* @returns Entry assets with js and css paths, or null if manifest unavailable
|
|
1486
|
+
*/
|
|
1484
1487
|
getEntryAssets(): EntryAssets | null;
|
|
1485
1488
|
/**
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1489
|
+
* Build preload link tags for entry assets.
|
|
1490
|
+
*
|
|
1491
|
+
* @returns Array of link objects ready to be rendered
|
|
1492
|
+
*/
|
|
1490
1493
|
getEntryPreloadLinks(): Array<{
|
|
1491
1494
|
rel: string;
|
|
1492
1495
|
href: string;
|
|
@@ -1503,25 +1506,16 @@ interface EntryAssets {
|
|
|
1503
1506
|
/** Associated CSS files (e.g., ["/assets/style.abc123.css"]) */
|
|
1504
1507
|
css: string[];
|
|
1505
1508
|
}
|
|
1506
|
-
/**
|
|
1507
|
-
* SSR Manifest structure from Vite.
|
|
1508
|
-
* Maps source file paths to their required chunks/assets.
|
|
1509
|
-
*/
|
|
1510
|
-
type SSRManifest = Record<string, string[]>;
|
|
1511
1509
|
/**
|
|
1512
1510
|
* Client manifest structure from Vite.
|
|
1513
|
-
*
|
|
1511
|
+
* Only includes fields actually used for preloading.
|
|
1514
1512
|
*/
|
|
1515
1513
|
interface ClientManifest {
|
|
1516
1514
|
[key: string]: {
|
|
1517
1515
|
file: string;
|
|
1518
|
-
src?: string;
|
|
1519
1516
|
isEntry?: boolean;
|
|
1520
|
-
isDynamicEntry?: boolean;
|
|
1521
1517
|
imports?: string[];
|
|
1522
|
-
dynamicImports?: string[];
|
|
1523
1518
|
css?: string[];
|
|
1524
|
-
assets?: string[];
|
|
1525
1519
|
};
|
|
1526
1520
|
}
|
|
1527
1521
|
/**
|
|
@@ -1544,8 +1538,8 @@ type PreloadManifest = Record<string, string>;
|
|
|
1544
1538
|
*/
|
|
1545
1539
|
declare class ReactServerProvider {
|
|
1546
1540
|
/**
|
|
1547
|
-
|
|
1548
|
-
|
|
1541
|
+
* SSR response headers - pre-allocated to avoid object creation per request.
|
|
1542
|
+
*/
|
|
1549
1543
|
protected readonly SSR_HEADERS: {
|
|
1550
1544
|
readonly "content-type": "text/html";
|
|
1551
1545
|
readonly "cache-control": "no-store, no-cache, must-revalidate, proxy-revalidate";
|
|
@@ -1563,11 +1557,10 @@ declare class ReactServerProvider {
|
|
|
1563
1557
|
protected readonly serverHeadProvider: ServerHeadProvider;
|
|
1564
1558
|
protected readonly serverStaticProvider: ServerStaticProvider;
|
|
1565
1559
|
protected readonly serverRouterProvider: ServerRouterProvider;
|
|
1566
|
-
protected readonly serverTimingProvider: ServerTimingProvider;
|
|
1567
1560
|
protected readonly ssrManifestProvider: SSRManifestProvider;
|
|
1568
1561
|
/**
|
|
1569
|
-
|
|
1570
|
-
|
|
1562
|
+
* Cached check for ServerLinksProvider - avoids has() lookup per request.
|
|
1563
|
+
*/
|
|
1571
1564
|
protected hasServerLinksProvider: boolean;
|
|
1572
1565
|
protected readonly options: Readonly<{
|
|
1573
1566
|
publicDir: string;
|
|
@@ -1577,80 +1570,76 @@ declare class ReactServerProvider {
|
|
|
1577
1570
|
};
|
|
1578
1571
|
}>;
|
|
1579
1572
|
/**
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
readonly onConfigure:
|
|
1573
|
+
* Configure the React server provider.
|
|
1574
|
+
*/
|
|
1575
|
+
readonly onConfigure: alepha6.HookPrimitive<"configure">;
|
|
1583
1576
|
/**
|
|
1584
|
-
|
|
1585
|
-
|
|
1577
|
+
* Get the current HTML template.
|
|
1578
|
+
*/
|
|
1586
1579
|
get template(): string;
|
|
1587
1580
|
/**
|
|
1588
|
-
|
|
1589
|
-
|
|
1581
|
+
* Register all pages as server routes.
|
|
1582
|
+
*/
|
|
1590
1583
|
protected registerPages(templateLoader: TemplateLoader): Promise<void>;
|
|
1591
1584
|
/**
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1585
|
+
* Set up early head content with entry assets.
|
|
1586
|
+
*
|
|
1587
|
+
* This content is sent immediately when streaming starts, before page loaders run,
|
|
1588
|
+
* allowing the browser to start downloading entry.js and CSS files early.
|
|
1589
|
+
*
|
|
1590
|
+
* Uses <script type="module"> instead of <link rel="modulepreload"> for JS
|
|
1591
|
+
* because the script needs to execute anyway - this way the browser starts
|
|
1592
|
+
* downloading, parsing, AND will execute as soon as ready.
|
|
1593
|
+
*
|
|
1594
|
+
* Also strips these assets from the original template head to avoid duplicates.
|
|
1595
|
+
*/
|
|
1603
1596
|
protected setupEarlyHeadContent(): void;
|
|
1604
1597
|
/**
|
|
1605
|
-
|
|
1606
|
-
|
|
1598
|
+
* Get the public directory path where static files are located.
|
|
1599
|
+
*/
|
|
1607
1600
|
protected getPublicDirectory(): Promise<string>;
|
|
1608
1601
|
/**
|
|
1609
|
-
|
|
1610
|
-
|
|
1602
|
+
* Configure the static file server to serve files from the given root directory.
|
|
1603
|
+
*/
|
|
1611
1604
|
protected configureStaticServer(root: string): Promise<void>;
|
|
1612
1605
|
/**
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
protected configureVite(ssrEnabled: boolean): Promise<void>;
|
|
1616
|
-
/**
|
|
1617
|
-
* Create the request handler for a page route.
|
|
1618
|
-
*/
|
|
1606
|
+
* Create the request handler for a page route.
|
|
1607
|
+
*/
|
|
1619
1608
|
protected createHandler(route: PageRoute, templateLoader: TemplateLoader): ServerHandler;
|
|
1620
1609
|
/**
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1610
|
+
* Core page rendering logic shared between SSR handler and static prerendering.
|
|
1611
|
+
*
|
|
1612
|
+
* Handles:
|
|
1613
|
+
* - Layer resolution (loaders)
|
|
1614
|
+
* - Redirect detection
|
|
1615
|
+
* - Head content filling
|
|
1616
|
+
* - Preload link collection
|
|
1617
|
+
* - React stream rendering
|
|
1618
|
+
*
|
|
1619
|
+
* @param route - The page route to render
|
|
1620
|
+
* @param state - The router state
|
|
1621
|
+
* @returns Render result with redirect or React stream
|
|
1622
|
+
*/
|
|
1634
1623
|
protected renderPage(route: PageRoute, state: ReactRouterState): Promise<{
|
|
1635
1624
|
redirect?: string;
|
|
1636
1625
|
reactStream?: ReadableStream<Uint8Array>;
|
|
1637
1626
|
}>;
|
|
1638
1627
|
/**
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1628
|
+
* For testing purposes, renders a page to HTML string.
|
|
1629
|
+
* Uses the same streaming code path as production, then collects to string.
|
|
1630
|
+
*
|
|
1631
|
+
* @param name - Page name to render
|
|
1632
|
+
* @param options - Render options (params, query, html, hydration)
|
|
1633
|
+
*/
|
|
1645
1634
|
render(name: string, options?: PagePrimitiveRenderOptions): Promise<PagePrimitiveRenderResult>;
|
|
1646
1635
|
/**
|
|
1647
|
-
|
|
1648
|
-
|
|
1636
|
+
* Collect a ReadableStream into a string.
|
|
1637
|
+
*/
|
|
1649
1638
|
protected streamToString(stream: ReadableStream<Uint8Array>): Promise<string>;
|
|
1650
1639
|
}
|
|
1651
1640
|
type TemplateLoader = () => Promise<string | undefined>;
|
|
1652
|
-
declare const envSchema:
|
|
1653
|
-
REACT_SSR_ENABLED:
|
|
1641
|
+
declare const envSchema: alepha6.TObject<{
|
|
1642
|
+
REACT_SSR_ENABLED: alepha6.TOptional<alepha6.TBoolean>;
|
|
1654
1643
|
}>;
|
|
1655
1644
|
declare module "alepha" {
|
|
1656
1645
|
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
@@ -1662,11 +1651,11 @@ declare module "alepha" {
|
|
|
1662
1651
|
/**
|
|
1663
1652
|
* React server provider configuration atom
|
|
1664
1653
|
*/
|
|
1665
|
-
declare const reactServerOptions:
|
|
1666
|
-
publicDir:
|
|
1667
|
-
staticServer:
|
|
1668
|
-
disabled:
|
|
1669
|
-
path:
|
|
1654
|
+
declare const reactServerOptions: alepha6.Atom<alepha6.TObject<{
|
|
1655
|
+
publicDir: alepha6.TString;
|
|
1656
|
+
staticServer: alepha6.TObject<{
|
|
1657
|
+
disabled: alepha6.TBoolean;
|
|
1658
|
+
path: alepha6.TString;
|
|
1670
1659
|
}>;
|
|
1671
1660
|
}>, "alepha.react.server.options">;
|
|
1672
1661
|
type ReactServerProviderOptions = Static<typeof reactServerOptions.schema>;
|
|
@@ -1683,26 +1672,26 @@ declare module "alepha" {
|
|
|
1683
1672
|
}
|
|
1684
1673
|
interface Hooks {
|
|
1685
1674
|
/**
|
|
1686
|
-
|
|
1687
|
-
|
|
1675
|
+
* Fires when the React application is starting to be rendered on the server.
|
|
1676
|
+
*/
|
|
1688
1677
|
"react:server:render:begin": {
|
|
1689
1678
|
request?: ServerRequest;
|
|
1690
1679
|
state: ReactRouterState;
|
|
1691
1680
|
};
|
|
1692
1681
|
/**
|
|
1693
|
-
|
|
1694
|
-
|
|
1682
|
+
* Fires when the React application has been rendered on the server.
|
|
1683
|
+
*/
|
|
1695
1684
|
"react:server:render:end": {
|
|
1696
1685
|
request?: ServerRequest;
|
|
1697
1686
|
state: ReactRouterState;
|
|
1698
1687
|
html: string;
|
|
1699
1688
|
};
|
|
1700
1689
|
/**
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1690
|
+
* Fires when the React application is being rendered on the browser.
|
|
1691
|
+
*
|
|
1692
|
+
* Note: this one is not really necessary, it's a hack because we need to isolate renderer from server code in order
|
|
1693
|
+
* to avoid including react-dom/client in server bundles.
|
|
1694
|
+
*/
|
|
1706
1695
|
"react:browser:render": {
|
|
1707
1696
|
root: HTMLElement;
|
|
1708
1697
|
element: ReactNode;
|
|
@@ -1710,29 +1699,29 @@ declare module "alepha" {
|
|
|
1710
1699
|
hydration?: ReactHydrationState;
|
|
1711
1700
|
};
|
|
1712
1701
|
/**
|
|
1713
|
-
|
|
1714
|
-
|
|
1702
|
+
* Fires when a route transition is starting.
|
|
1703
|
+
*/
|
|
1715
1704
|
"react:transition:begin": {
|
|
1716
1705
|
previous: ReactRouterState;
|
|
1717
1706
|
state: ReactRouterState;
|
|
1718
1707
|
animation?: PageAnimation;
|
|
1719
1708
|
};
|
|
1720
1709
|
/**
|
|
1721
|
-
|
|
1722
|
-
|
|
1710
|
+
* Fires when a route transition has succeeded.
|
|
1711
|
+
*/
|
|
1723
1712
|
"react:transition:success": {
|
|
1724
1713
|
state: ReactRouterState;
|
|
1725
1714
|
};
|
|
1726
1715
|
/**
|
|
1727
|
-
|
|
1728
|
-
|
|
1716
|
+
* Fires when a route transition has failed.
|
|
1717
|
+
*/
|
|
1729
1718
|
"react:transition:error": {
|
|
1730
1719
|
state: ReactRouterState;
|
|
1731
1720
|
error: Error;
|
|
1732
1721
|
};
|
|
1733
1722
|
/**
|
|
1734
|
-
|
|
1735
|
-
|
|
1723
|
+
* Fires when a route transition has completed, regardless of success or failure.
|
|
1724
|
+
*/
|
|
1736
1725
|
"react:transition:end": {
|
|
1737
1726
|
state: ReactRouterState;
|
|
1738
1727
|
};
|
|
@@ -1752,7 +1741,7 @@ declare module "alepha" {
|
|
|
1752
1741
|
* @see {@link $page}
|
|
1753
1742
|
* @module alepha.react.router
|
|
1754
1743
|
*/
|
|
1755
|
-
declare const AlephaReactRouter:
|
|
1744
|
+
declare const AlephaReactRouter: alepha6.Service<alepha6.Module>;
|
|
1756
1745
|
//#endregion
|
|
1757
|
-
export { $page, AlephaReactRouter, AnchorProps, ClientManifest, ConcretePageRoute, CreateLayersResult, EntryAssets, ErrorHandler, ErrorViewer, HydrationData, Layer, Link, type LinkProps, _default as NestedView, NestedViewProps, NotFound, PAGE_PRELOAD_KEY, PageAnimation, PageConfigSchema, PageLoader, PagePrimitive, PagePrimitiveOptions, PagePrimitiveRenderOptions, PagePrimitiveRenderResult, PageRequestConfig, PageRoute, PageRouteEntry, PreloadManifest, PreviousLayerData, ReactBrowserProvider, ReactBrowserRendererOptions, ReactHydrationState, ReactPageProvider, ReactPageService, ReactRouter, ReactRouterState, ReactServerProvider, ReactServerProviderOptions, ReactServerTemplateProvider, Redirection, type RouterGoOptions, RouterLayerContext, RouterLayerContextValue, RouterRenderOptions, RouterStackItem,
|
|
1746
|
+
export { $page, AlephaReactRouter, AnchorProps, ClientManifest, ConcretePageRoute, CreateLayersResult, EntryAssets, ErrorHandler, ErrorViewer, HydrationData, Layer, Link, type LinkProps, _default as NestedView, NestedViewProps, NotFound, PAGE_PRELOAD_KEY, PageAnimation, PageConfigSchema, PageLoader, PagePrimitive, PagePrimitiveOptions, PagePrimitiveRenderOptions, PagePrimitiveRenderResult, PageRequestConfig, PageRoute, PageRouteEntry, PreloadManifest, PreviousLayerData, ReactBrowserProvider, ReactBrowserRendererOptions, ReactHydrationState, ReactPageProvider, ReactPageService, ReactRouter, ReactRouterState, ReactServerProvider, ReactServerProviderOptions, ReactServerTemplateProvider, Redirection, type RouterGoOptions, RouterLayerContext, RouterLayerContextValue, RouterRenderOptions, RouterStackItem, SSRManifestProvider, TPropsDefault, TPropsParentDefault, TemplateSlots, TransitionOptions, UseActiveHook, UseActiveOptions, UseQueryParamsHookOptions, VirtualRouter, isPageRoute, reactBrowserOptions, reactServerOptions, useActive, useQueryParams, useRouter, useRouterState };
|
|
1758
1747
|
//# sourceMappingURL=index.d.ts.map
|