alepha 0.15.2 → 0.15.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +68 -80
- package/dist/api/audits/index.d.ts.map +1 -1
- package/dist/api/audits/index.js +8 -0
- package/dist/api/audits/index.js.map +1 -1
- package/dist/api/files/index.d.ts +170 -170
- package/dist/api/files/index.d.ts.map +1 -1
- package/dist/api/files/index.js +1 -0
- package/dist/api/files/index.js.map +1 -1
- package/dist/api/jobs/index.d.ts.map +1 -1
- package/dist/api/jobs/index.js +3 -0
- package/dist/api/jobs/index.js.map +1 -1
- package/dist/api/notifications/index.browser.js +1 -0
- package/dist/api/notifications/index.browser.js.map +1 -1
- package/dist/api/notifications/index.js +1 -0
- package/dist/api/notifications/index.js.map +1 -1
- package/dist/api/parameters/index.d.ts +260 -260
- package/dist/api/parameters/index.d.ts.map +1 -1
- package/dist/api/parameters/index.js +10 -0
- package/dist/api/parameters/index.js.map +1 -1
- package/dist/api/users/index.d.ts +12 -1
- package/dist/api/users/index.d.ts.map +1 -1
- package/dist/api/users/index.js +18 -2
- package/dist/api/users/index.js.map +1 -1
- package/dist/batch/index.d.ts +4 -4
- package/dist/bucket/index.d.ts +8 -0
- package/dist/bucket/index.d.ts.map +1 -1
- package/dist/bucket/index.js +7 -2
- package/dist/bucket/index.js.map +1 -1
- package/dist/cli/index.d.ts +196 -74
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +234 -50
- package/dist/cli/index.js.map +1 -1
- package/dist/command/index.d.ts +10 -0
- package/dist/command/index.d.ts.map +1 -1
- package/dist/command/index.js +67 -13
- package/dist/command/index.js.map +1 -1
- package/dist/core/index.browser.js +28 -21
- package/dist/core/index.browser.js.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +28 -21
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.native.js +28 -21
- package/dist/core/index.native.js.map +1 -1
- package/dist/email/index.d.ts +21 -13
- package/dist/email/index.d.ts.map +1 -1
- package/dist/email/index.js +10561 -4
- package/dist/email/index.js.map +1 -1
- package/dist/lock/core/index.d.ts +6 -1
- package/dist/lock/core/index.d.ts.map +1 -1
- package/dist/lock/core/index.js +9 -1
- package/dist/lock/core/index.js.map +1 -1
- package/dist/mcp/index.d.ts +5 -5
- package/dist/orm/index.bun.js +32 -16
- package/dist/orm/index.bun.js.map +1 -1
- package/dist/orm/index.d.ts +4 -1
- package/dist/orm/index.d.ts.map +1 -1
- package/dist/orm/index.js +34 -22
- package/dist/orm/index.js.map +1 -1
- package/dist/react/auth/index.browser.js +2 -1
- package/dist/react/auth/index.browser.js.map +1 -1
- package/dist/react/auth/index.js +2 -1
- package/dist/react/auth/index.js.map +1 -1
- package/dist/react/core/index.d.ts +3 -3
- package/dist/react/router/index.browser.js +9 -15
- package/dist/react/router/index.browser.js.map +1 -1
- package/dist/react/router/index.d.ts +305 -407
- package/dist/react/router/index.d.ts.map +1 -1
- package/dist/react/router/index.js +581 -781
- package/dist/react/router/index.js.map +1 -1
- package/dist/scheduler/index.d.ts +13 -1
- package/dist/scheduler/index.d.ts.map +1 -1
- package/dist/scheduler/index.js +42 -4
- package/dist/scheduler/index.js.map +1 -1
- package/dist/security/index.d.ts +42 -42
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/index.js +8 -7
- package/dist/security/index.js.map +1 -1
- package/dist/server/auth/index.d.ts +167 -167
- package/dist/server/compress/index.d.ts.map +1 -1
- package/dist/server/compress/index.js +1 -0
- package/dist/server/compress/index.js.map +1 -1
- package/dist/server/health/index.d.ts +17 -17
- package/dist/server/links/index.d.ts +39 -39
- package/dist/server/links/index.js +1 -1
- package/dist/server/links/index.js.map +1 -1
- package/dist/server/static/index.js +7 -2
- package/dist/server/static/index.js.map +1 -1
- package/dist/server/swagger/index.d.ts +8 -0
- package/dist/server/swagger/index.d.ts.map +1 -1
- package/dist/server/swagger/index.js +7 -2
- package/dist/server/swagger/index.js.map +1 -1
- package/dist/sms/index.d.ts +8 -0
- package/dist/sms/index.d.ts.map +1 -1
- package/dist/sms/index.js +7 -2
- package/dist/sms/index.js.map +1 -1
- package/dist/system/index.browser.js +734 -12
- package/dist/system/index.browser.js.map +1 -1
- package/dist/system/index.d.ts +8 -0
- package/dist/system/index.d.ts.map +1 -1
- package/dist/system/index.js +7 -2
- package/dist/system/index.js.map +1 -1
- package/dist/vite/index.d.ts +3 -2
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +42 -8
- package/dist/vite/index.js.map +1 -1
- package/dist/websocket/index.d.ts +34 -34
- package/dist/websocket/index.d.ts.map +1 -1
- package/package.json +9 -4
- package/src/api/audits/controllers/AdminAuditController.ts +8 -0
- package/src/api/files/controllers/AdminFileStatsController.ts +1 -0
- package/src/api/jobs/controllers/AdminJobController.ts +3 -0
- package/src/api/logs/TODO.md +13 -10
- package/src/api/notifications/controllers/AdminNotificationController.ts +1 -0
- package/src/api/parameters/controllers/AdminConfigController.ts +10 -0
- package/src/api/users/controllers/AdminIdentityController.ts +3 -0
- package/src/api/users/controllers/AdminSessionController.ts +3 -0
- package/src/api/users/controllers/AdminUserController.ts +5 -0
- package/src/cli/apps/AlephaPackageBuilderCli.ts +9 -0
- package/src/cli/atoms/buildOptions.ts +99 -9
- package/src/cli/commands/build.ts +150 -32
- package/src/cli/commands/db.ts +5 -7
- package/src/cli/commands/init.spec.ts +50 -6
- package/src/cli/commands/init.ts +28 -5
- package/src/cli/providers/ViteDevServerProvider.ts +31 -9
- package/src/cli/services/AlephaCliUtils.ts +16 -0
- package/src/cli/services/PackageManagerUtils.ts +2 -0
- package/src/cli/services/ProjectScaffolder.spec.ts +97 -0
- package/src/cli/services/ProjectScaffolder.ts +28 -6
- package/src/cli/templates/agentMd.ts +6 -1
- package/src/cli/templates/apiAppSecurityTs.ts +11 -0
- package/src/cli/templates/apiIndexTs.ts +18 -4
- package/src/cli/templates/webAppRouterTs.ts +25 -1
- package/src/cli/templates/webHelloComponentTsx.ts +15 -5
- package/src/command/helpers/Runner.spec.ts +135 -0
- package/src/command/helpers/Runner.ts +4 -1
- package/src/command/providers/CliProvider.spec.ts +325 -0
- package/src/command/providers/CliProvider.ts +117 -7
- package/src/core/Alepha.ts +32 -25
- package/src/email/index.workerd.ts +36 -0
- package/src/email/providers/WorkermailerEmailProvider.ts +221 -0
- package/src/lock/core/primitives/$lock.ts +13 -1
- package/src/orm/index.bun.ts +1 -1
- package/src/orm/index.ts +2 -6
- package/src/orm/providers/drivers/BunSqliteProvider.ts +4 -1
- package/src/orm/providers/drivers/CloudflareD1Provider.ts +57 -30
- package/src/orm/providers/drivers/DatabaseProvider.ts +9 -1
- package/src/orm/providers/drivers/NodeSqliteProvider.ts +4 -1
- package/src/react/auth/services/ReactAuth.ts +3 -1
- package/src/react/router/atoms/ssrManifestAtom.ts +7 -0
- package/src/react/router/hooks/useActive.ts +1 -1
- package/src/react/router/hooks/useRouter.ts +1 -1
- package/src/react/router/index.ts +4 -0
- package/src/react/router/primitives/$page.browser.spec.tsx +24 -24
- package/src/react/router/primitives/$page.spec.tsx +0 -32
- package/src/react/router/primitives/$page.ts +6 -14
- package/src/react/router/providers/ReactBrowserProvider.ts +6 -3
- package/src/react/router/providers/ReactPageProvider.ts +1 -1
- package/src/react/router/providers/ReactPreloadProvider.spec.ts +142 -0
- package/src/react/router/providers/ReactPreloadProvider.ts +85 -0
- package/src/react/router/providers/ReactServerProvider.ts +21 -82
- package/src/react/router/providers/ReactServerTemplateProvider.spec.ts +210 -0
- package/src/react/router/providers/ReactServerTemplateProvider.ts +228 -665
- package/src/react/router/providers/SSRManifestProvider.ts +7 -0
- package/src/react/router/services/ReactRouter.ts +13 -13
- package/src/scheduler/index.workerd.ts +43 -0
- package/src/scheduler/providers/CronProvider.ts +53 -6
- package/src/scheduler/providers/WorkerdCronProvider.ts +102 -0
- package/src/security/__tests__/ServerSecurityProvider.spec.ts +77 -0
- package/src/security/providers/ServerSecurityProvider.ts +30 -22
- package/src/server/compress/providers/ServerCompressProvider.ts +6 -0
- package/src/server/core/providers/NodeHttpServerProvider.spec.ts +9 -3
- package/src/server/links/providers/ServerLinksProvider.spec.ts +332 -0
- package/src/server/links/providers/ServerLinksProvider.ts +1 -1
- package/src/system/index.browser.ts +25 -0
- package/src/system/index.workerd.ts +1 -0
- package/src/system/providers/FileSystemProvider.ts +8 -0
- package/src/system/providers/NodeFileSystemProvider.ts +11 -2
- package/src/vite/tasks/buildServer.ts +2 -12
- package/src/vite/tasks/generateCloudflare.ts +47 -8
- package/src/vite/tasks/generateDocker.ts +4 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as alepha6 from "alepha";
|
|
2
2
|
import { Alepha, AlephaError, Async, FileLike, Json, KIND, Primitive, Static, StreamLike, TObject, TSchema } from "alepha";
|
|
3
3
|
import { DateTimeProvider } from "alepha/datetime";
|
|
4
4
|
import { ClientOnlyProps } from "alepha/react";
|
|
5
5
|
import { ServerHandler, ServerRequest, ServerRouterProvider } from "alepha/server";
|
|
6
6
|
import { ServerRouteCache } from "alepha/server/cache";
|
|
7
7
|
import { LinkProvider } from "alepha/server/links";
|
|
8
|
-
import * as
|
|
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";
|
|
@@ -47,8 +47,8 @@ declare class Redirection extends AlephaError {
|
|
|
47
47
|
}
|
|
48
48
|
//#endregion
|
|
49
49
|
//#region ../../src/react/router/providers/ReactPageProvider.d.ts
|
|
50
|
-
declare const envSchema$1:
|
|
51
|
-
REACT_STRICT_MODE:
|
|
50
|
+
declare const envSchema$1: alepha6.TObject<{
|
|
51
|
+
REACT_STRICT_MODE: alepha6.TBoolean;
|
|
52
52
|
}>;
|
|
53
53
|
declare module "alepha" {
|
|
54
54
|
interface Env extends Partial<Static<typeof envSchema$1>> {}
|
|
@@ -57,7 +57,7 @@ declare module "alepha" {
|
|
|
57
57
|
* Handle page routes for React applications. (Browser and Server)
|
|
58
58
|
*/
|
|
59
59
|
declare class ReactPageProvider {
|
|
60
|
-
protected readonly log:
|
|
60
|
+
protected readonly log: alepha_logger0.Logger;
|
|
61
61
|
protected readonly env: {
|
|
62
62
|
REACT_STRICT_MODE: boolean;
|
|
63
63
|
};
|
|
@@ -93,7 +93,7 @@ declare class ReactPageProvider {
|
|
|
93
93
|
}, params?: Record<string, any>): string;
|
|
94
94
|
compile(path: string, params?: Record<string, string>): string;
|
|
95
95
|
protected renderView(index: number, path: string, view: ReactNode | undefined, page: PageRoute): ReactNode;
|
|
96
|
-
protected readonly configure:
|
|
96
|
+
protected readonly configure: alepha6.HookPrimitive<"configure">;
|
|
97
97
|
protected map(pages: Array<PagePrimitive>, target: PagePrimitive): PageRouteEntry;
|
|
98
98
|
add(entry: PageRouteEntry): void;
|
|
99
99
|
protected createMatch(page: PageRoute): string;
|
|
@@ -518,7 +518,6 @@ interface PagePrimitiveOptions<TConfig extends PageConfigSchema = PageConfigSche
|
|
|
518
518
|
*/
|
|
519
519
|
[PAGE_PRELOAD_KEY]?: string;
|
|
520
520
|
}
|
|
521
|
-
type ErrorHandler = (error: Error, state: ReactRouterState) => ReactNode | Redirection | undefined;
|
|
522
521
|
declare class PagePrimitive<TConfig extends PageConfigSchema = PageConfigSchema, TProps extends object = TPropsDefault, TPropsParent extends object = TPropsParentDefault> extends Primitive<PagePrimitiveOptions<TConfig, TProps, TPropsParent>> {
|
|
523
522
|
protected readonly reactPageService: ReactPageService;
|
|
524
523
|
protected onInit(): void;
|
|
@@ -534,9 +533,8 @@ declare class PagePrimitive<TConfig extends PageConfigSchema = PageConfigSchema,
|
|
|
534
533
|
html: string;
|
|
535
534
|
response: Response;
|
|
536
535
|
}>;
|
|
537
|
-
match(url: string): boolean;
|
|
538
|
-
pathname(config: any): string;
|
|
539
536
|
}
|
|
537
|
+
type ErrorHandler = (error: Error, state: ReactRouterState) => ReactNode | Redirection | undefined;
|
|
540
538
|
interface PageConfigSchema {
|
|
541
539
|
query?: TSchema;
|
|
542
540
|
params?: TSchema;
|
|
@@ -578,7 +576,7 @@ type CssAnimation = {
|
|
|
578
576
|
};
|
|
579
577
|
//#endregion
|
|
580
578
|
//#region ../../src/react/router/services/ReactRouter.d.ts
|
|
581
|
-
interface
|
|
579
|
+
interface RouterPushOptions {
|
|
582
580
|
replace?: boolean;
|
|
583
581
|
params?: Record<string, string>;
|
|
584
582
|
query?: Record<string, string>;
|
|
@@ -624,10 +622,10 @@ declare class ReactRouter<T extends object> {
|
|
|
624
622
|
back(): Promise<void>;
|
|
625
623
|
forward(): Promise<void>;
|
|
626
624
|
invalidate(props?: Record<string, any>): Promise<void>;
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
anchor(path: string, options?:
|
|
630
|
-
anchor(path: keyof VirtualRouter<T>, options?:
|
|
625
|
+
push(path: string, options?: RouterPushOptions): Promise<void>;
|
|
626
|
+
push(path: keyof VirtualRouter<T>, options?: RouterPushOptions): Promise<void>;
|
|
627
|
+
anchor(path: string, options?: RouterPushOptions): AnchorProps;
|
|
628
|
+
anchor(path: keyof VirtualRouter<T>, options?: RouterPushOptions): AnchorProps;
|
|
631
629
|
base(path: string): string;
|
|
632
630
|
/**
|
|
633
631
|
* Set query params.
|
|
@@ -652,12 +650,12 @@ interface BrowserRoute extends Route {
|
|
|
652
650
|
* Implementation of AlephaRouter for React in browser environment.
|
|
653
651
|
*/
|
|
654
652
|
declare class ReactBrowserRouterProvider extends RouterProvider<BrowserRoute> {
|
|
655
|
-
protected readonly log:
|
|
653
|
+
protected readonly log: alepha_logger0.Logger;
|
|
656
654
|
protected readonly alepha: Alepha;
|
|
657
655
|
protected readonly pageApi: ReactPageProvider;
|
|
658
656
|
protected readonly browserHeadProvider: BrowserHeadProvider;
|
|
659
657
|
add(entry: PageRouteEntry): void;
|
|
660
|
-
protected readonly configure:
|
|
658
|
+
protected readonly configure: alepha6.HookPrimitive<"configure">;
|
|
661
659
|
transition(url: URL, previous?: PreviousLayerData[], meta?: {}): Promise<string | void>;
|
|
662
660
|
root(state: ReactRouterState): ReactNode;
|
|
663
661
|
}
|
|
@@ -666,8 +664,8 @@ declare class ReactBrowserRouterProvider extends RouterProvider<BrowserRoute> {
|
|
|
666
664
|
/**
|
|
667
665
|
* React browser renderer configuration atom
|
|
668
666
|
*/
|
|
669
|
-
declare const reactBrowserOptions:
|
|
670
|
-
scrollRestoration:
|
|
667
|
+
declare const reactBrowserOptions: alepha6.Atom<alepha6.TObject<{
|
|
668
|
+
scrollRestoration: alepha6.TUnsafe<"top" | "manual">;
|
|
671
669
|
}>, "alepha.react.browser.options">;
|
|
672
670
|
type ReactBrowserRendererOptions = Static<typeof reactBrowserOptions.schema>;
|
|
673
671
|
declare module "alepha" {
|
|
@@ -676,7 +674,7 @@ declare module "alepha" {
|
|
|
676
674
|
}
|
|
677
675
|
}
|
|
678
676
|
declare class ReactBrowserProvider {
|
|
679
|
-
protected readonly log:
|
|
677
|
+
protected readonly log: alepha_logger0.Logger;
|
|
680
678
|
protected readonly client: LinkProvider;
|
|
681
679
|
protected readonly alepha: Alepha;
|
|
682
680
|
protected readonly router: ReactBrowserRouterProvider;
|
|
@@ -708,14 +706,14 @@ declare class ReactBrowserProvider {
|
|
|
708
706
|
get url(): string;
|
|
709
707
|
pushState(path: string, replace?: boolean): void;
|
|
710
708
|
invalidate(props?: Record<string, any>): Promise<void>;
|
|
711
|
-
|
|
709
|
+
push(url: string, options?: RouterPushOptions): Promise<void>;
|
|
712
710
|
protected render(options?: RouterRenderOptions): Promise<void>;
|
|
713
711
|
/**
|
|
714
712
|
* Get embedded layers from the server.
|
|
715
713
|
*/
|
|
716
714
|
protected getHydrationState(): ReactHydrationState | undefined;
|
|
717
|
-
protected readonly onTransitionEnd:
|
|
718
|
-
readonly ready:
|
|
715
|
+
protected readonly onTransitionEnd: alepha6.HookPrimitive<"react:transition:end">;
|
|
716
|
+
readonly ready: alepha6.HookPrimitive<"ready">;
|
|
719
717
|
}
|
|
720
718
|
type ReactHydrationState = {
|
|
721
719
|
layers?: Array<PreviousLayerData>;
|
|
@@ -1104,13 +1102,227 @@ interface UseQueryParamsHookOptions {
|
|
|
1104
1102
|
* }
|
|
1105
1103
|
*
|
|
1106
1104
|
* const router = useRouter<App>();
|
|
1107
|
-
* router.
|
|
1105
|
+
* router.push("home"); // typesafe
|
|
1108
1106
|
*/
|
|
1109
1107
|
declare const useRouter: <T extends object = any>() => ReactRouter<T>;
|
|
1110
1108
|
//#endregion
|
|
1111
1109
|
//#region ../../src/react/router/hooks/useRouterState.d.ts
|
|
1112
1110
|
declare const useRouterState: () => ReactRouterState;
|
|
1113
1111
|
//#endregion
|
|
1112
|
+
//#region ../../src/react/router/atoms/ssrManifestAtom.d.ts
|
|
1113
|
+
/**
|
|
1114
|
+
* Schema for the SSR manifest atom.
|
|
1115
|
+
*/
|
|
1116
|
+
declare const ssrManifestAtomSchema: alepha6.TObject<{
|
|
1117
|
+
/**
|
|
1118
|
+
* Base path for assets (from Vite's base config).
|
|
1119
|
+
* Used to prefix asset URLs when serving from a subpath.
|
|
1120
|
+
* @example "/devtools" or "/"
|
|
1121
|
+
*/
|
|
1122
|
+
base: alepha6.TOptional<alepha6.TString>;
|
|
1123
|
+
/**
|
|
1124
|
+
* Preload manifest mapping short keys to source paths.
|
|
1125
|
+
* Generated by viteAlephaSsrPreload plugin at build time.
|
|
1126
|
+
*/
|
|
1127
|
+
preload: alepha6.TOptional<alepha6.TRecord<"^.*$", alepha6.TString>>;
|
|
1128
|
+
/**
|
|
1129
|
+
* Client manifest mapping source files to their output information.
|
|
1130
|
+
* Only includes fields actually used for preloading.
|
|
1131
|
+
*/
|
|
1132
|
+
client: alepha6.TOptional<alepha6.TRecord<"^.*$", alepha6.TObject<{
|
|
1133
|
+
file: alepha6.TString;
|
|
1134
|
+
isEntry: alepha6.TOptional<alepha6.TBoolean>;
|
|
1135
|
+
imports: alepha6.TOptional<alepha6.TArray<alepha6.TString>>;
|
|
1136
|
+
css: alepha6.TOptional<alepha6.TArray<alepha6.TString>>;
|
|
1137
|
+
}>>>;
|
|
1138
|
+
/**
|
|
1139
|
+
* Dev mode head content.
|
|
1140
|
+
* Contains pre-transformed scripts injected by Vite and plugins (React, etc.).
|
|
1141
|
+
* Only set in dev mode via ViteDevServerProvider.
|
|
1142
|
+
*/
|
|
1143
|
+
devHead: alepha6.TOptional<alepha6.TString>;
|
|
1144
|
+
}>;
|
|
1145
|
+
/**
|
|
1146
|
+
* Type for the SSR manifest schema.
|
|
1147
|
+
*/
|
|
1148
|
+
type SsrManifestAtomSchema = typeof ssrManifestAtomSchema;
|
|
1149
|
+
//#endregion
|
|
1150
|
+
//#region ../../src/react/router/providers/SSRManifestProvider.d.ts
|
|
1151
|
+
/**
|
|
1152
|
+
* Provider for SSR manifest data used for module preloading.
|
|
1153
|
+
*
|
|
1154
|
+
* The manifest is populated at build time by embedding data into the
|
|
1155
|
+
* generated index.js via the ssrManifestAtom. This eliminates filesystem
|
|
1156
|
+
* reads at runtime, making it optimal for serverless deployments.
|
|
1157
|
+
*
|
|
1158
|
+
* Manifest files are generated during `vite build`:
|
|
1159
|
+
* - manifest.json (client manifest)
|
|
1160
|
+
* - preload-manifest.json (from viteAlephaSsrPreload plugin)
|
|
1161
|
+
*/
|
|
1162
|
+
declare class SSRManifestProvider {
|
|
1163
|
+
protected readonly alepha: Alepha;
|
|
1164
|
+
/**
|
|
1165
|
+
* Get the manifest from the store at runtime.
|
|
1166
|
+
* This ensures the manifest is available even when set after module load.
|
|
1167
|
+
*/
|
|
1168
|
+
protected get manifest(): Static<SsrManifestAtomSchema>;
|
|
1169
|
+
/**
|
|
1170
|
+
* Get the full manifest object.
|
|
1171
|
+
*/
|
|
1172
|
+
getManifest(): Static<SsrManifestAtomSchema>;
|
|
1173
|
+
/**
|
|
1174
|
+
* Get the base path for assets (from Vite's base config).
|
|
1175
|
+
* Returns empty string if base is "/" (default), otherwise returns the base path.
|
|
1176
|
+
*/
|
|
1177
|
+
protected get base(): string;
|
|
1178
|
+
/**
|
|
1179
|
+
* Get the preload manifest.
|
|
1180
|
+
*/
|
|
1181
|
+
protected get preloadManifest(): PreloadManifest | undefined;
|
|
1182
|
+
/**
|
|
1183
|
+
* Get the client manifest.
|
|
1184
|
+
*/
|
|
1185
|
+
protected get clientManifest(): ClientManifest | undefined;
|
|
1186
|
+
/**
|
|
1187
|
+
* Resolve a preload key to its source path.
|
|
1188
|
+
*
|
|
1189
|
+
* The key is a short hash injected by viteAlephaSsrPreload plugin,
|
|
1190
|
+
* which maps to the full source path in the preload manifest.
|
|
1191
|
+
*
|
|
1192
|
+
* @param key - Short hash key (e.g., "a1b2c3d4")
|
|
1193
|
+
* @returns Source path (e.g., "src/pages/UserDetail.tsx") or undefined
|
|
1194
|
+
*/
|
|
1195
|
+
resolvePreloadKey(key: string): string | undefined;
|
|
1196
|
+
/**
|
|
1197
|
+
* Get all chunks required for a source file, including transitive dependencies.
|
|
1198
|
+
*
|
|
1199
|
+
* Uses the client manifest to recursively resolve all imported chunks.
|
|
1200
|
+
*
|
|
1201
|
+
* @param sourcePath - Source file path (e.g., "src/pages/Home.tsx")
|
|
1202
|
+
* @returns Array of chunk URLs to preload, or empty array if not found
|
|
1203
|
+
*/
|
|
1204
|
+
getChunks(sourcePath: string): string[];
|
|
1205
|
+
/**
|
|
1206
|
+
* Find manifest entry for a source path, trying different extensions.
|
|
1207
|
+
*/
|
|
1208
|
+
protected findManifestEntry(sourcePath: string): {
|
|
1209
|
+
file: string;
|
|
1210
|
+
isEntry?: boolean;
|
|
1211
|
+
imports?: string[];
|
|
1212
|
+
css?: string[];
|
|
1213
|
+
} | undefined;
|
|
1214
|
+
/**
|
|
1215
|
+
* Recursively collect all chunk URLs for a manifest entry.
|
|
1216
|
+
*/
|
|
1217
|
+
protected collectChunksRecursive(key: string, chunks: Set<string>, visited: Set<string>): void;
|
|
1218
|
+
/**
|
|
1219
|
+
* Collect modulepreload links for a route and its parent chain.
|
|
1220
|
+
*/
|
|
1221
|
+
collectPreloadLinks(route: PageRoute): Array<{
|
|
1222
|
+
rel: string;
|
|
1223
|
+
href: string;
|
|
1224
|
+
as?: string;
|
|
1225
|
+
crossorigin?: string;
|
|
1226
|
+
}>;
|
|
1227
|
+
/**
|
|
1228
|
+
* Get all chunks for multiple source files.
|
|
1229
|
+
*
|
|
1230
|
+
* @param sourcePaths - Array of source file paths
|
|
1231
|
+
* @returns Deduplicated array of chunk URLs
|
|
1232
|
+
*/
|
|
1233
|
+
getChunksForMultiple(sourcePaths: string[]): string[];
|
|
1234
|
+
/**
|
|
1235
|
+
* Check if manifest is loaded and available.
|
|
1236
|
+
*/
|
|
1237
|
+
isAvailable(): boolean;
|
|
1238
|
+
/**
|
|
1239
|
+
* Cached entry assets - computed once at first access.
|
|
1240
|
+
*/
|
|
1241
|
+
protected cachedEntryAssets: EntryAssets | null;
|
|
1242
|
+
/**
|
|
1243
|
+
* Get the entry point assets (main entry.js and associated CSS files).
|
|
1244
|
+
*
|
|
1245
|
+
* These assets are always required for all pages and can be preloaded
|
|
1246
|
+
* before page-specific loaders run.
|
|
1247
|
+
*
|
|
1248
|
+
* @returns Entry assets with js and css paths, or null if manifest unavailable
|
|
1249
|
+
*/
|
|
1250
|
+
getEntryAssets(): EntryAssets | null;
|
|
1251
|
+
/**
|
|
1252
|
+
* Build preload link tags for entry assets.
|
|
1253
|
+
*
|
|
1254
|
+
* @returns Array of link objects ready to be rendered
|
|
1255
|
+
*/
|
|
1256
|
+
getEntryPreloadLinks(): Array<{
|
|
1257
|
+
rel: string;
|
|
1258
|
+
href: string;
|
|
1259
|
+
as?: string;
|
|
1260
|
+
crossorigin?: string;
|
|
1261
|
+
}>;
|
|
1262
|
+
}
|
|
1263
|
+
/**
|
|
1264
|
+
* Entry assets structure containing the main entry JS and associated CSS files.
|
|
1265
|
+
*/
|
|
1266
|
+
interface EntryAssets {
|
|
1267
|
+
/** Main entry JavaScript file (e.g., "/assets/entry.abc123.js") */
|
|
1268
|
+
js?: string;
|
|
1269
|
+
/** Associated CSS files (e.g., ["/assets/style.abc123.css"]) */
|
|
1270
|
+
css: string[];
|
|
1271
|
+
}
|
|
1272
|
+
/**
|
|
1273
|
+
* Client manifest structure from Vite.
|
|
1274
|
+
* Only includes fields actually used for preloading.
|
|
1275
|
+
*/
|
|
1276
|
+
interface ClientManifest {
|
|
1277
|
+
[key: string]: {
|
|
1278
|
+
file: string;
|
|
1279
|
+
isEntry?: boolean;
|
|
1280
|
+
imports?: string[];
|
|
1281
|
+
css?: string[];
|
|
1282
|
+
};
|
|
1283
|
+
}
|
|
1284
|
+
/**
|
|
1285
|
+
* Preload manifest mapping short keys to source paths.
|
|
1286
|
+
* Generated by viteAlephaSsrPreload plugin at build time.
|
|
1287
|
+
*/
|
|
1288
|
+
type PreloadManifest = Record<string, string>;
|
|
1289
|
+
//#endregion
|
|
1290
|
+
//#region ../../src/react/router/providers/ReactPreloadProvider.d.ts
|
|
1291
|
+
/**
|
|
1292
|
+
* Adds HTTP Link headers for preloading entry assets.
|
|
1293
|
+
*
|
|
1294
|
+
* Benefits:
|
|
1295
|
+
* - Early Hints (103): Servers can send preload hints before the full response
|
|
1296
|
+
* - CDN optimization: Many CDNs use Link headers to optimize asset delivery
|
|
1297
|
+
* - Browser prefetching: Browsers can start fetching resources earlier
|
|
1298
|
+
*
|
|
1299
|
+
* The Link header is computed once at first request and cached for reuse.
|
|
1300
|
+
*/
|
|
1301
|
+
declare class ReactPreloadProvider {
|
|
1302
|
+
protected readonly alepha: Alepha;
|
|
1303
|
+
protected readonly ssrManifest: SSRManifestProvider;
|
|
1304
|
+
/**
|
|
1305
|
+
* Cached Link header value - computed once, reused for all requests.
|
|
1306
|
+
*/
|
|
1307
|
+
protected cachedLinkHeader: string | null | undefined;
|
|
1308
|
+
/**
|
|
1309
|
+
* Build the Link header string from entry assets.
|
|
1310
|
+
*
|
|
1311
|
+
* Format: <url>; rel=preload; as=type, <url>; rel=modulepreload
|
|
1312
|
+
*
|
|
1313
|
+
* @returns Link header string or null if no assets
|
|
1314
|
+
*/
|
|
1315
|
+
protected buildLinkHeader(): string | null;
|
|
1316
|
+
/**
|
|
1317
|
+
* Get the cached Link header, computing it on first access.
|
|
1318
|
+
*/
|
|
1319
|
+
protected getLinkHeader(): string | null;
|
|
1320
|
+
/**
|
|
1321
|
+
* Add Link header to HTML responses for asset preloading.
|
|
1322
|
+
*/
|
|
1323
|
+
protected readonly onResponse: alepha6.HookPrimitive<"server:onResponse">;
|
|
1324
|
+
}
|
|
1325
|
+
//#endregion
|
|
1114
1326
|
//#region ../../src/system/providers/FileSystemProvider.d.ts
|
|
1115
1327
|
/**
|
|
1116
1328
|
* Options for creating a file from a URL
|
|
@@ -1289,8 +1501,16 @@ interface CpOptions {
|
|
|
1289
1501
|
interface MkdirOptions {
|
|
1290
1502
|
/**
|
|
1291
1503
|
* If true, creates parent directories as needed
|
|
1504
|
+
*
|
|
1505
|
+
* @default true
|
|
1292
1506
|
*/
|
|
1293
1507
|
recursive?: boolean;
|
|
1508
|
+
/**
|
|
1509
|
+
* If true, does not throw an error if the directory already exists
|
|
1510
|
+
*
|
|
1511
|
+
* @default true
|
|
1512
|
+
*/
|
|
1513
|
+
force?: boolean;
|
|
1294
1514
|
/**
|
|
1295
1515
|
* File mode (permission and sticky bits)
|
|
1296
1516
|
*/
|
|
@@ -1403,202 +1623,94 @@ declare abstract class FileSystemProvider {
|
|
|
1403
1623
|
//#endregion
|
|
1404
1624
|
//#region ../../src/react/router/providers/ReactServerTemplateProvider.d.ts
|
|
1405
1625
|
/**
|
|
1406
|
-
* Handles HTML
|
|
1407
|
-
*
|
|
1408
|
-
* Responsibilities:
|
|
1409
|
-
* - Parse template once at startup into logical slots
|
|
1410
|
-
* - Pre-encode static parts as Uint8Array for zero-copy streaming
|
|
1411
|
-
* - Render dynamic parts (attributes, head content) efficiently
|
|
1412
|
-
* - Build hydration data for client-side rehydration
|
|
1626
|
+
* Handles HTML streaming for SSR.
|
|
1413
1627
|
*
|
|
1414
|
-
*
|
|
1415
|
-
*
|
|
1416
|
-
* on request handling and React rendering coordination.
|
|
1628
|
+
* Uses hardcoded HTML structure - all customization via $head primitive.
|
|
1629
|
+
* Pre-encodes static parts as Uint8Array for zero-copy streaming.
|
|
1417
1630
|
*/
|
|
1418
1631
|
declare class ReactServerTemplateProvider {
|
|
1419
|
-
protected readonly log:
|
|
1632
|
+
protected readonly log: alepha_logger0.Logger;
|
|
1420
1633
|
protected readonly alepha: Alepha;
|
|
1421
1634
|
/**
|
|
1422
|
-
* Shared TextEncoder
|
|
1635
|
+
* Shared TextEncoder - reused across all requests.
|
|
1423
1636
|
*/
|
|
1424
1637
|
protected readonly encoder: TextEncoder;
|
|
1425
1638
|
/**
|
|
1426
|
-
* Pre-encoded
|
|
1427
|
-
*/
|
|
1428
|
-
protected readonly
|
|
1639
|
+
* Pre-encoded static HTML parts for zero-copy streaming.
|
|
1640
|
+
*/
|
|
1641
|
+
protected readonly SLOTS: {
|
|
1642
|
+
readonly DOCTYPE: Uint8Array<ArrayBuffer>;
|
|
1643
|
+
readonly HTML_OPEN: Uint8Array<ArrayBuffer>;
|
|
1644
|
+
readonly HTML_CLOSE: Uint8Array<ArrayBuffer>;
|
|
1645
|
+
readonly HEAD_OPEN: Uint8Array<ArrayBuffer>;
|
|
1646
|
+
readonly HEAD_CLOSE: Uint8Array<ArrayBuffer>;
|
|
1647
|
+
readonly BODY_OPEN: Uint8Array<ArrayBuffer>;
|
|
1648
|
+
readonly BODY_CLOSE: Uint8Array<ArrayBuffer>;
|
|
1649
|
+
readonly ROOT_OPEN: Uint8Array<ArrayBuffer>;
|
|
1650
|
+
readonly ROOT_CLOSE: Uint8Array<ArrayBuffer>;
|
|
1651
|
+
readonly BODY_HTML_CLOSE: Uint8Array<ArrayBuffer>;
|
|
1429
1652
|
readonly HYDRATION_PREFIX: Uint8Array<ArrayBuffer>;
|
|
1430
1653
|
readonly HYDRATION_SUFFIX: Uint8Array<ArrayBuffer>;
|
|
1431
|
-
readonly EMPTY: Uint8Array<ArrayBuffer>;
|
|
1432
1654
|
};
|
|
1433
1655
|
/**
|
|
1434
|
-
*
|
|
1656
|
+
* Early head content (charset, viewport, entry assets).
|
|
1657
|
+
* Set once during configuration, reused for all requests.
|
|
1435
1658
|
*/
|
|
1436
|
-
protected
|
|
1659
|
+
protected earlyHeadContent: string;
|
|
1437
1660
|
/**
|
|
1438
1661
|
* Root element ID for React mounting.
|
|
1439
1662
|
*/
|
|
1440
|
-
|
|
1663
|
+
readonly rootId = "root";
|
|
1441
1664
|
/**
|
|
1442
|
-
* Regex
|
|
1665
|
+
* Regex for extracting root div content from HTML.
|
|
1443
1666
|
*/
|
|
1444
|
-
|
|
1667
|
+
readonly rootDivRegex: RegExp;
|
|
1445
1668
|
/**
|
|
1446
|
-
* Extract
|
|
1447
|
-
*
|
|
1448
|
-
* @param html - Full HTML string
|
|
1449
|
-
* @returns The content inside the root div, or undefined if not found
|
|
1669
|
+
* Extract content inside the root div from HTML.
|
|
1450
1670
|
*/
|
|
1451
1671
|
extractRootContent(html: string): string | undefined;
|
|
1452
1672
|
/**
|
|
1453
|
-
*
|
|
1454
|
-
|
|
1455
|
-
isReady(): boolean;
|
|
1456
|
-
/**
|
|
1457
|
-
* Get the parsed template slots.
|
|
1458
|
-
* Throws if template hasn't been parsed yet.
|
|
1459
|
-
*/
|
|
1460
|
-
getSlots(): TemplateSlots;
|
|
1461
|
-
/**
|
|
1462
|
-
* Parse an HTML template into logical slots for efficient streaming.
|
|
1463
|
-
*
|
|
1464
|
-
* This should be called once during server startup/configuration.
|
|
1465
|
-
* The parsed slots are cached and reused for all requests.
|
|
1673
|
+
* Set early head content (charset, viewport, entry assets).
|
|
1674
|
+
* Called once during server configuration.
|
|
1466
1675
|
*/
|
|
1467
|
-
|
|
1468
|
-
/**
|
|
1469
|
-
* Parse HTML attributes string into a record.
|
|
1470
|
-
*
|
|
1471
|
-
* Handles: key="value", key='value', key=value, and boolean key
|
|
1472
|
-
*/
|
|
1473
|
-
protected parseAttributes(attrStr: string): Record<string, string>;
|
|
1676
|
+
setEarlyHeadContent(entryAssets: string, globalHead?: SimpleHead): void;
|
|
1474
1677
|
/**
|
|
1475
1678
|
* Render attributes record to HTML string.
|
|
1476
|
-
*
|
|
1477
|
-
* @param attrs - Attributes to render
|
|
1478
|
-
* @returns HTML attribute string like ` lang="en" class="dark"`
|
|
1479
1679
|
*/
|
|
1480
|
-
renderAttributes(attrs
|
|
1481
|
-
/**
|
|
1482
|
-
* Render merged HTML attributes (original + dynamic).
|
|
1483
|
-
*/
|
|
1484
|
-
renderMergedHtmlAttrs(dynamicAttrs?: Record<string, string>): string;
|
|
1485
|
-
/**
|
|
1486
|
-
* Render merged body attributes (original + dynamic).
|
|
1487
|
-
*/
|
|
1488
|
-
renderMergedBodyAttrs(dynamicAttrs?: Record<string, string>): string;
|
|
1680
|
+
renderAttributes(attrs?: Record<string, string>): string;
|
|
1489
1681
|
/**
|
|
1490
1682
|
* Render head content (title, meta, link, script tags).
|
|
1491
|
-
*
|
|
1492
|
-
* @param head - Head data to render
|
|
1493
|
-
* @param includeOriginal - Whether to include original head content
|
|
1494
|
-
* @returns HTML string with head content
|
|
1495
1683
|
*/
|
|
1496
|
-
renderHeadContent(head?: SimpleHead
|
|
1497
|
-
/**
|
|
1498
|
-
* Render a meta tag.
|
|
1499
|
-
*/
|
|
1500
|
-
protected renderMetaTag(meta: {
|
|
1501
|
-
name?: string;
|
|
1502
|
-
property?: string;
|
|
1503
|
-
content: string;
|
|
1504
|
-
}): string;
|
|
1505
|
-
/**
|
|
1506
|
-
* Render a link tag.
|
|
1507
|
-
*/
|
|
1508
|
-
protected renderLinkTag(link: {
|
|
1509
|
-
rel: string;
|
|
1510
|
-
href: string;
|
|
1511
|
-
type?: string;
|
|
1512
|
-
as?: string;
|
|
1513
|
-
crossorigin?: string;
|
|
1514
|
-
}): string;
|
|
1515
|
-
/**
|
|
1516
|
-
* Render a script tag.
|
|
1517
|
-
*/
|
|
1518
|
-
protected renderScriptTag(script: string | (Record<string, string | boolean | undefined> & {
|
|
1519
|
-
content?: string;
|
|
1520
|
-
})): string;
|
|
1684
|
+
renderHeadContent(head?: SimpleHead): string;
|
|
1521
1685
|
/**
|
|
1522
1686
|
* Escape HTML special characters.
|
|
1523
1687
|
*/
|
|
1524
1688
|
escapeHtml(str: string): string;
|
|
1525
1689
|
/**
|
|
1526
1690
|
* Safely serialize data to JSON for embedding in HTML.
|
|
1527
|
-
* Escapes characters that could break out of script tags.
|
|
1528
1691
|
*/
|
|
1529
1692
|
safeJsonSerialize(data: unknown): string;
|
|
1530
1693
|
/**
|
|
1531
1694
|
* Build hydration data from router state.
|
|
1532
|
-
*
|
|
1533
|
-
* This creates the data structure that will be serialized to window.__ssr
|
|
1534
|
-
* for client-side rehydration.
|
|
1535
1695
|
*/
|
|
1536
1696
|
buildHydrationData(state: ReactRouterState): HydrationData;
|
|
1537
1697
|
/**
|
|
1538
|
-
*
|
|
1539
|
-
*
|
|
1540
|
-
* If an error occurs during React streaming, it injects error HTML instead of aborting,
|
|
1541
|
-
* ensuring users see an error message rather than a white screen.
|
|
1698
|
+
* Pipe React stream to controller with backpressure handling.
|
|
1699
|
+
* Returns true if stream completed successfully, false if error occurred.
|
|
1542
1700
|
*/
|
|
1543
|
-
protected
|
|
1701
|
+
protected pipeReactStream(controller: ReadableStreamDefaultController<Uint8Array>, reactStream: ReadableStream<Uint8Array>, state: ReactRouterState): Promise<boolean>;
|
|
1544
1702
|
/**
|
|
1545
|
-
*
|
|
1546
|
-
*
|
|
1547
|
-
* This is the main entry point for SSR streaming. It:
|
|
1548
|
-
* 1. Sends <head> immediately (browser starts downloading assets)
|
|
1549
|
-
* 2. Streams React content as it renders
|
|
1550
|
-
* 3. Appends hydration script and closing tags
|
|
1551
|
-
*
|
|
1552
|
-
* @param reactStream - ReadableStream from renderToReadableStream
|
|
1553
|
-
* @param state - Router state with head data
|
|
1554
|
-
* @param options - Streaming options
|
|
1703
|
+
* Stream complete HTML document (head already closed).
|
|
1704
|
+
* Used by both createHtmlStream and late phase of createEarlyHtmlStream.
|
|
1555
1705
|
*/
|
|
1556
|
-
|
|
1557
|
-
hydration?: boolean;
|
|
1558
|
-
onError?: (error: unknown) => void;
|
|
1559
|
-
}): ReadableStream<Uint8Array>;
|
|
1706
|
+
protected streamBodyAndClose(controller: ReadableStreamDefaultController<Uint8Array>, reactStream: ReadableStream<Uint8Array>, state: ReactRouterState, hydration: boolean): Promise<void>;
|
|
1560
1707
|
/**
|
|
1561
|
-
*
|
|
1562
|
-
*
|
|
1563
|
-
* Contains entry assets (JS + CSS) that are always required and can be
|
|
1564
|
-
* sent before page loaders run.
|
|
1565
|
-
*/
|
|
1566
|
-
protected earlyHeadContent: string;
|
|
1567
|
-
/**
|
|
1568
|
-
* Set the early head content (entry script + CSS).
|
|
1569
|
-
*
|
|
1570
|
-
* Also strips these assets from the original head content to avoid duplicates,
|
|
1571
|
-
* since we're moving them to the early phase.
|
|
1572
|
-
*
|
|
1573
|
-
* Automatically prepends critical meta tags (charset, viewport) if not present
|
|
1574
|
-
* in $head configuration, ensuring they're sent as early as possible.
|
|
1575
|
-
*
|
|
1576
|
-
* @param content - HTML string with entry assets
|
|
1577
|
-
* @param globalHead - Global head configuration from $head primitives
|
|
1578
|
-
* @param entryAssets - Entry asset paths to strip from original head
|
|
1579
|
-
*/
|
|
1580
|
-
setEarlyHeadContent(content: string, globalHead?: SimpleHead, entryAssets?: {
|
|
1581
|
-
js?: string;
|
|
1582
|
-
css: string[];
|
|
1583
|
-
}): void;
|
|
1584
|
-
/**
|
|
1585
|
-
* Escape special regex characters in a string.
|
|
1586
|
-
*/
|
|
1587
|
-
protected escapeRegExp(str: string): string;
|
|
1588
|
-
/**
|
|
1589
|
-
* Create an optimized HTML stream with early head streaming.
|
|
1590
|
-
*
|
|
1591
|
-
* This version sends critical assets (entry.js, CSS) BEFORE page loaders run,
|
|
1592
|
-
* allowing the browser to start downloading them immediately.
|
|
1708
|
+
* Create HTML stream with early head optimization.
|
|
1593
1709
|
*
|
|
1594
1710
|
* Flow:
|
|
1595
1711
|
* 1. Send DOCTYPE, <html>, <head> open, entry preloads (IMMEDIATE)
|
|
1596
|
-
* 2. Run async work (
|
|
1712
|
+
* 2. Run async work (page loaders)
|
|
1597
1713
|
* 3. Send rest of head, body, React content, hydration
|
|
1598
|
-
*
|
|
1599
|
-
* @param globalHead - Global head with htmlAttributes (from $head primitives)
|
|
1600
|
-
* @param asyncWork - Async function to run between early head and rest of stream
|
|
1601
|
-
* @param options - Streaming options
|
|
1602
1714
|
*/
|
|
1603
1715
|
createEarlyHtmlStream(globalHead: SimpleHead, asyncWork: () => Promise<{
|
|
1604
1716
|
state: ReactRouterState;
|
|
@@ -1610,59 +1722,26 @@ declare class ReactServerTemplateProvider {
|
|
|
1610
1722
|
onError?: (error: unknown) => void;
|
|
1611
1723
|
}): ReadableStream<Uint8Array>;
|
|
1612
1724
|
/**
|
|
1613
|
-
*
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
*
|
|
1621
|
-
*
|
|
1622
|
-
* Handles different states:
|
|
1623
|
-
* - headClosed=false, bodyStarted=false: Need to add head content, close head, open body, add error, close all
|
|
1624
|
-
* - headClosed=true, bodyStarted=false: Need to open body, add error, close all
|
|
1625
|
-
* - headClosed=true, bodyStarted=true: Already inside root div, add error, close all
|
|
1725
|
+
* Create HTML stream (non-early version, for testing/prerender).
|
|
1726
|
+
*/
|
|
1727
|
+
createHtmlStream(reactStream: ReadableStream<Uint8Array>, state: ReactRouterState, options?: {
|
|
1728
|
+
hydration?: boolean;
|
|
1729
|
+
onError?: (error: unknown) => void;
|
|
1730
|
+
}): ReadableStream<Uint8Array>;
|
|
1731
|
+
/**
|
|
1732
|
+
* Inject error HTML when streaming fails.
|
|
1626
1733
|
*/
|
|
1627
|
-
protected injectErrorHtml(controller: ReadableStreamDefaultController<Uint8Array>,
|
|
1734
|
+
protected injectErrorHtml(controller: ReadableStreamDefaultController<Uint8Array>, error: unknown, routerState: ReactRouterState | undefined, streamState: {
|
|
1628
1735
|
headClosed: boolean;
|
|
1629
1736
|
bodyStarted: boolean;
|
|
1630
1737
|
}): void;
|
|
1631
1738
|
/**
|
|
1632
|
-
* Render
|
|
1633
|
-
*
|
|
1634
|
-
* Falls back to ErrorViewer if:
|
|
1635
|
-
* - No router state is available
|
|
1636
|
-
* - The error handler returns null/undefined
|
|
1637
|
-
* - The error handler itself throws
|
|
1739
|
+
* Render error to HTML string.
|
|
1638
1740
|
*/
|
|
1639
1741
|
protected renderErrorToString(error: Error, routerState: ReactRouterState | undefined): string;
|
|
1640
1742
|
}
|
|
1641
1743
|
/**
|
|
1642
|
-
*
|
|
1643
|
-
*
|
|
1644
|
-
* Static parts are pre-encoded as Uint8Array for zero-copy streaming.
|
|
1645
|
-
* Dynamic parts (attributes, head content) are kept as strings/objects for merging.
|
|
1646
|
-
*/
|
|
1647
|
-
interface TemplateSlots {
|
|
1648
|
-
doctype: Uint8Array;
|
|
1649
|
-
htmlOpen: Uint8Array;
|
|
1650
|
-
htmlClose: Uint8Array;
|
|
1651
|
-
headOpen: Uint8Array;
|
|
1652
|
-
headClose: Uint8Array;
|
|
1653
|
-
bodyOpen: Uint8Array;
|
|
1654
|
-
bodyClose: Uint8Array;
|
|
1655
|
-
rootOpen: Uint8Array;
|
|
1656
|
-
rootClose: Uint8Array;
|
|
1657
|
-
scriptClose: Uint8Array;
|
|
1658
|
-
htmlOriginalAttrs: Record<string, string>;
|
|
1659
|
-
bodyOriginalAttrs: Record<string, string>;
|
|
1660
|
-
headOriginalContent: string;
|
|
1661
|
-
beforeRoot: string;
|
|
1662
|
-
afterRoot: string;
|
|
1663
|
-
}
|
|
1664
|
-
/**
|
|
1665
|
-
* Hydration state that gets serialized to window.__ssr
|
|
1744
|
+
* Hydration state serialized to window.__ssr
|
|
1666
1745
|
*/
|
|
1667
1746
|
interface HydrationData {
|
|
1668
1747
|
layers: Array<{
|
|
@@ -1676,174 +1755,6 @@ interface HydrationData {
|
|
|
1676
1755
|
[key: string]: unknown;
|
|
1677
1756
|
}
|
|
1678
1757
|
//#endregion
|
|
1679
|
-
//#region ../../src/react/router/atoms/ssrManifestAtom.d.ts
|
|
1680
|
-
/**
|
|
1681
|
-
* Schema for the SSR manifest atom.
|
|
1682
|
-
*/
|
|
1683
|
-
declare const ssrManifestAtomSchema: alepha16.TObject<{
|
|
1684
|
-
/**
|
|
1685
|
-
* Base path for assets (from Vite's base config).
|
|
1686
|
-
* Used to prefix asset URLs when serving from a subpath.
|
|
1687
|
-
* @example "/devtools" or "/"
|
|
1688
|
-
*/
|
|
1689
|
-
base: alepha16.TOptional<alepha16.TString>;
|
|
1690
|
-
/**
|
|
1691
|
-
* Preload manifest mapping short keys to source paths.
|
|
1692
|
-
* Generated by viteAlephaSsrPreload plugin at build time.
|
|
1693
|
-
*/
|
|
1694
|
-
preload: alepha16.TOptional<alepha16.TRecord<"^.*$", alepha16.TString>>;
|
|
1695
|
-
/**
|
|
1696
|
-
* Client manifest mapping source files to their output information.
|
|
1697
|
-
* Only includes fields actually used for preloading.
|
|
1698
|
-
*/
|
|
1699
|
-
client: alepha16.TOptional<alepha16.TRecord<"^.*$", alepha16.TObject<{
|
|
1700
|
-
file: alepha16.TString;
|
|
1701
|
-
isEntry: alepha16.TOptional<alepha16.TBoolean>;
|
|
1702
|
-
imports: alepha16.TOptional<alepha16.TArray<alepha16.TString>>;
|
|
1703
|
-
css: alepha16.TOptional<alepha16.TArray<alepha16.TString>>;
|
|
1704
|
-
}>>>;
|
|
1705
|
-
}>;
|
|
1706
|
-
/**
|
|
1707
|
-
* Type for the SSR manifest schema.
|
|
1708
|
-
*/
|
|
1709
|
-
type SsrManifestAtomSchema = typeof ssrManifestAtomSchema;
|
|
1710
|
-
//#endregion
|
|
1711
|
-
//#region ../../src/react/router/providers/SSRManifestProvider.d.ts
|
|
1712
|
-
/**
|
|
1713
|
-
* Provider for SSR manifest data used for module preloading.
|
|
1714
|
-
*
|
|
1715
|
-
* The manifest is populated at build time by embedding data into the
|
|
1716
|
-
* generated index.js via the ssrManifestAtom. This eliminates filesystem
|
|
1717
|
-
* reads at runtime, making it optimal for serverless deployments.
|
|
1718
|
-
*
|
|
1719
|
-
* Manifest files are generated during `vite build`:
|
|
1720
|
-
* - manifest.json (client manifest)
|
|
1721
|
-
* - preload-manifest.json (from viteAlephaSsrPreload plugin)
|
|
1722
|
-
*/
|
|
1723
|
-
declare class SSRManifestProvider {
|
|
1724
|
-
protected readonly alepha: Alepha;
|
|
1725
|
-
/**
|
|
1726
|
-
* Get the manifest from the store at runtime.
|
|
1727
|
-
* This ensures the manifest is available even when set after module load.
|
|
1728
|
-
*/
|
|
1729
|
-
protected get manifest(): Static<SsrManifestAtomSchema>;
|
|
1730
|
-
/**
|
|
1731
|
-
* Get the base path for assets (from Vite's base config).
|
|
1732
|
-
* Returns empty string if base is "/" (default), otherwise returns the base path.
|
|
1733
|
-
*/
|
|
1734
|
-
protected get base(): string;
|
|
1735
|
-
/**
|
|
1736
|
-
* Get the preload manifest.
|
|
1737
|
-
*/
|
|
1738
|
-
protected get preloadManifest(): PreloadManifest | undefined;
|
|
1739
|
-
/**
|
|
1740
|
-
* Get the client manifest.
|
|
1741
|
-
*/
|
|
1742
|
-
protected get clientManifest(): ClientManifest | undefined;
|
|
1743
|
-
/**
|
|
1744
|
-
* Resolve a preload key to its source path.
|
|
1745
|
-
*
|
|
1746
|
-
* The key is a short hash injected by viteAlephaSsrPreload plugin,
|
|
1747
|
-
* which maps to the full source path in the preload manifest.
|
|
1748
|
-
*
|
|
1749
|
-
* @param key - Short hash key (e.g., "a1b2c3d4")
|
|
1750
|
-
* @returns Source path (e.g., "src/pages/UserDetail.tsx") or undefined
|
|
1751
|
-
*/
|
|
1752
|
-
resolvePreloadKey(key: string): string | undefined;
|
|
1753
|
-
/**
|
|
1754
|
-
* Get all chunks required for a source file, including transitive dependencies.
|
|
1755
|
-
*
|
|
1756
|
-
* Uses the client manifest to recursively resolve all imported chunks.
|
|
1757
|
-
*
|
|
1758
|
-
* @param sourcePath - Source file path (e.g., "src/pages/Home.tsx")
|
|
1759
|
-
* @returns Array of chunk URLs to preload, or empty array if not found
|
|
1760
|
-
*/
|
|
1761
|
-
getChunks(sourcePath: string): string[];
|
|
1762
|
-
/**
|
|
1763
|
-
* Find manifest entry for a source path, trying different extensions.
|
|
1764
|
-
*/
|
|
1765
|
-
protected findManifestEntry(sourcePath: string): {
|
|
1766
|
-
file: string;
|
|
1767
|
-
isEntry?: boolean;
|
|
1768
|
-
imports?: string[];
|
|
1769
|
-
css?: string[];
|
|
1770
|
-
} | undefined;
|
|
1771
|
-
/**
|
|
1772
|
-
* Recursively collect all chunk URLs for a manifest entry.
|
|
1773
|
-
*/
|
|
1774
|
-
protected collectChunksRecursive(key: string, chunks: Set<string>, visited: Set<string>): void;
|
|
1775
|
-
/**
|
|
1776
|
-
* Collect modulepreload links for a route and its parent chain.
|
|
1777
|
-
*/
|
|
1778
|
-
collectPreloadLinks(route: PageRoute): Array<{
|
|
1779
|
-
rel: string;
|
|
1780
|
-
href: string;
|
|
1781
|
-
as?: string;
|
|
1782
|
-
crossorigin?: string;
|
|
1783
|
-
}>;
|
|
1784
|
-
/**
|
|
1785
|
-
* Get all chunks for multiple source files.
|
|
1786
|
-
*
|
|
1787
|
-
* @param sourcePaths - Array of source file paths
|
|
1788
|
-
* @returns Deduplicated array of chunk URLs
|
|
1789
|
-
*/
|
|
1790
|
-
getChunksForMultiple(sourcePaths: string[]): string[];
|
|
1791
|
-
/**
|
|
1792
|
-
* Check if manifest is loaded and available.
|
|
1793
|
-
*/
|
|
1794
|
-
isAvailable(): boolean;
|
|
1795
|
-
/**
|
|
1796
|
-
* Cached entry assets - computed once at first access.
|
|
1797
|
-
*/
|
|
1798
|
-
protected cachedEntryAssets: EntryAssets | null;
|
|
1799
|
-
/**
|
|
1800
|
-
* Get the entry point assets (main entry.js and associated CSS files).
|
|
1801
|
-
*
|
|
1802
|
-
* These assets are always required for all pages and can be preloaded
|
|
1803
|
-
* before page-specific loaders run.
|
|
1804
|
-
*
|
|
1805
|
-
* @returns Entry assets with js and css paths, or null if manifest unavailable
|
|
1806
|
-
*/
|
|
1807
|
-
getEntryAssets(): EntryAssets | null;
|
|
1808
|
-
/**
|
|
1809
|
-
* Build preload link tags for entry assets.
|
|
1810
|
-
*
|
|
1811
|
-
* @returns Array of link objects ready to be rendered
|
|
1812
|
-
*/
|
|
1813
|
-
getEntryPreloadLinks(): Array<{
|
|
1814
|
-
rel: string;
|
|
1815
|
-
href: string;
|
|
1816
|
-
as?: string;
|
|
1817
|
-
crossorigin?: string;
|
|
1818
|
-
}>;
|
|
1819
|
-
}
|
|
1820
|
-
/**
|
|
1821
|
-
* Entry assets structure containing the main entry JS and associated CSS files.
|
|
1822
|
-
*/
|
|
1823
|
-
interface EntryAssets {
|
|
1824
|
-
/** Main entry JavaScript file (e.g., "/assets/entry.abc123.js") */
|
|
1825
|
-
js?: string;
|
|
1826
|
-
/** Associated CSS files (e.g., ["/assets/style.abc123.css"]) */
|
|
1827
|
-
css: string[];
|
|
1828
|
-
}
|
|
1829
|
-
/**
|
|
1830
|
-
* Client manifest structure from Vite.
|
|
1831
|
-
* Only includes fields actually used for preloading.
|
|
1832
|
-
*/
|
|
1833
|
-
interface ClientManifest {
|
|
1834
|
-
[key: string]: {
|
|
1835
|
-
file: string;
|
|
1836
|
-
isEntry?: boolean;
|
|
1837
|
-
imports?: string[];
|
|
1838
|
-
css?: string[];
|
|
1839
|
-
};
|
|
1840
|
-
}
|
|
1841
|
-
/**
|
|
1842
|
-
* Preload manifest mapping short keys to source paths.
|
|
1843
|
-
* Generated by viteAlephaSsrPreload plugin at build time.
|
|
1844
|
-
*/
|
|
1845
|
-
type PreloadManifest = Record<string, string>;
|
|
1846
|
-
//#endregion
|
|
1847
1758
|
//#region ../../src/react/router/providers/ReactServerProvider.d.ts
|
|
1848
1759
|
/**
|
|
1849
1760
|
* React server provider responsible for SSR and static file serving.
|
|
@@ -1867,7 +1778,7 @@ declare class ReactServerProvider {
|
|
|
1867
1778
|
readonly expires: "0";
|
|
1868
1779
|
};
|
|
1869
1780
|
protected readonly fs: FileSystemProvider;
|
|
1870
|
-
protected readonly log:
|
|
1781
|
+
protected readonly log: alepha_logger0.Logger;
|
|
1871
1782
|
protected readonly alepha: Alepha;
|
|
1872
1783
|
protected readonly env: {
|
|
1873
1784
|
REACT_SSR_ENABLED?: boolean | undefined;
|
|
@@ -1892,27 +1803,16 @@ declare class ReactServerProvider {
|
|
|
1892
1803
|
/**
|
|
1893
1804
|
* Configure the React server provider.
|
|
1894
1805
|
*/
|
|
1895
|
-
readonly onConfigure:
|
|
1896
|
-
/**
|
|
1897
|
-
* Get the current HTML template.
|
|
1898
|
-
*/
|
|
1899
|
-
get template(): string;
|
|
1806
|
+
readonly onConfigure: alepha6.HookPrimitive<"configure">;
|
|
1900
1807
|
/**
|
|
1901
1808
|
* Register all pages as server routes.
|
|
1902
1809
|
*/
|
|
1903
|
-
protected registerPages(
|
|
1810
|
+
protected registerPages(): void;
|
|
1904
1811
|
/**
|
|
1905
1812
|
* Set up early head content with entry assets.
|
|
1906
1813
|
*
|
|
1907
1814
|
* This content is sent immediately when streaming starts, before page loaders run,
|
|
1908
1815
|
* allowing the browser to start downloading entry.js and CSS files early.
|
|
1909
|
-
*
|
|
1910
|
-
* Uses <script type="module"> instead of <link rel="modulepreload"> for JS
|
|
1911
|
-
* because the script needs to execute anyway - this way the browser starts
|
|
1912
|
-
* downloading, parsing, AND will execute as soon as ready.
|
|
1913
|
-
*
|
|
1914
|
-
* Also injects critical meta tags (charset, viewport) if not specified in $head,
|
|
1915
|
-
* and strips these assets from the original template head to avoid duplicates.
|
|
1916
1816
|
*/
|
|
1917
1817
|
protected setupEarlyHeadContent(): void;
|
|
1918
1818
|
/**
|
|
@@ -1926,7 +1826,7 @@ declare class ReactServerProvider {
|
|
|
1926
1826
|
/**
|
|
1927
1827
|
* Create the request handler for a page route.
|
|
1928
1828
|
*/
|
|
1929
|
-
protected createHandler(route: PageRoute
|
|
1829
|
+
protected createHandler(route: PageRoute): ServerHandler;
|
|
1930
1830
|
/**
|
|
1931
1831
|
* Core page rendering logic shared between SSR handler and static prerendering.
|
|
1932
1832
|
*
|
|
@@ -1958,25 +1858,23 @@ declare class ReactServerProvider {
|
|
|
1958
1858
|
*/
|
|
1959
1859
|
protected streamToString(stream: ReadableStream<Uint8Array>): Promise<string>;
|
|
1960
1860
|
}
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
REACT_SSR_ENABLED: alepha16.TOptional<alepha16.TBoolean>;
|
|
1861
|
+
declare const envSchema: alepha6.TObject<{
|
|
1862
|
+
REACT_SSR_ENABLED: alepha6.TOptional<alepha6.TBoolean>;
|
|
1964
1863
|
}>;
|
|
1965
1864
|
declare module "alepha" {
|
|
1966
1865
|
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
1967
1866
|
interface State {
|
|
1968
1867
|
"alepha.react.server.ssr"?: boolean;
|
|
1969
|
-
"alepha.react.server.template"?: string;
|
|
1970
1868
|
}
|
|
1971
1869
|
}
|
|
1972
1870
|
/**
|
|
1973
1871
|
* React server provider configuration atom
|
|
1974
1872
|
*/
|
|
1975
|
-
declare const reactServerOptions:
|
|
1976
|
-
publicDir:
|
|
1977
|
-
staticServer:
|
|
1978
|
-
disabled:
|
|
1979
|
-
path:
|
|
1873
|
+
declare const reactServerOptions: alepha6.Atom<alepha6.TObject<{
|
|
1874
|
+
publicDir: alepha6.TString;
|
|
1875
|
+
staticServer: alepha6.TObject<{
|
|
1876
|
+
disabled: alepha6.TBoolean;
|
|
1877
|
+
path: alepha6.TString;
|
|
1980
1878
|
}>;
|
|
1981
1879
|
}>, "alepha.react.server.options">;
|
|
1982
1880
|
type ReactServerProviderOptions = Static<typeof reactServerOptions.schema>;
|
|
@@ -2062,7 +1960,7 @@ declare module "alepha" {
|
|
|
2062
1960
|
* @see {@link $page}
|
|
2063
1961
|
* @module alepha.react.router
|
|
2064
1962
|
*/
|
|
2065
|
-
declare const AlephaReactRouter:
|
|
1963
|
+
declare const AlephaReactRouter: alepha6.Service<alepha6.Module>;
|
|
2066
1964
|
//#endregion
|
|
2067
|
-
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,
|
|
1965
|
+
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, ReactPreloadProvider, ReactRouter, ReactRouterState, ReactServerProvider, ReactServerProviderOptions, ReactServerTemplateProvider, Redirection, RouterLayerContext, RouterLayerContextValue, type RouterPushOptions, RouterRenderOptions, RouterStackItem, SSRManifestProvider, TPropsDefault, TPropsParentDefault, TransitionOptions, UseActiveHook, UseActiveOptions, UseQueryParamsHookOptions, VirtualRouter, isPageRoute, reactBrowserOptions, reactServerOptions, useActive, useQueryParams, useRouter, useRouterState };
|
|
2068
1966
|
//# sourceMappingURL=index.d.ts.map
|