@alepha/react 0.13.2 → 0.13.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/index.browser.js +5 -0
- package/dist/auth/index.browser.js.map +1 -1
- package/dist/auth/index.d.ts +139 -68
- package/dist/auth/index.js +5 -0
- package/dist/auth/index.js.map +1 -1
- package/dist/core/index.browser.js +31 -10
- package/dist/core/index.browser.js.map +1 -1
- package/dist/core/index.d.ts +113 -83
- package/dist/core/index.js +40 -13
- package/dist/core/index.js.map +1 -1
- package/dist/head/index.browser.js +21 -10
- package/dist/head/index.browser.js.map +1 -1
- package/dist/head/index.d.ts +41 -38
- package/dist/head/index.js +22 -10
- package/dist/head/index.js.map +1 -1
- package/package.json +6 -6
- package/src/auth/services/ReactAuth.ts +10 -0
- package/src/core/components/NestedView.tsx +5 -1
- package/src/core/components/NotFound.tsx +10 -6
- package/src/core/providers/ReactBrowserRouterProvider.ts +1 -0
- package/src/core/providers/ReactPageProvider.ts +3 -0
- package/src/core/providers/ReactServerProvider.ts +23 -12
- package/src/core/services/ReactRouter.ts +16 -0
- package/src/head/interfaces/Head.ts +1 -0
- package/src/head/primitives/$head.ts +4 -1
- package/src/head/providers/BrowserHeadProvider.ts +13 -0
- package/src/head/providers/HeadProvider.ts +11 -9
- package/src/head/providers/ServerHeadProvider.ts +6 -0
package/dist/core/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as alepha48 from "alepha";
|
|
2
2
|
import { Alepha, AlephaError, Async, Atom, FileLike, Hook, Hooks, InstantiableClass, KIND, LogLevel, LoggerInterface, Primitive, Service, State, Static, StreamLike, TArray, TAtomObject, TFile, TObject, TRecord, TSchema, TStream, TString, TVoid } from "alepha";
|
|
3
3
|
import * as react0 from "react";
|
|
4
4
|
import React, { AnchorHTMLAttributes, CSSProperties, DependencyList, ErrorInfo, FC, PropsWithChildren, ReactNode } from "react";
|
|
@@ -10,15 +10,15 @@ import dayjsDuration from "dayjs/plugin/duration.js";
|
|
|
10
10
|
import DayjsApi, { Dayjs, ManipulateType, PluginFunc } from "dayjs";
|
|
11
11
|
|
|
12
12
|
//#region ../alepha/src/server/schemas/errorSchema.d.ts
|
|
13
|
-
declare const errorSchema:
|
|
14
|
-
error:
|
|
15
|
-
status:
|
|
16
|
-
message:
|
|
17
|
-
details:
|
|
18
|
-
requestId:
|
|
19
|
-
cause:
|
|
20
|
-
name:
|
|
21
|
-
message:
|
|
13
|
+
declare const errorSchema: alepha48.TObject<{
|
|
14
|
+
error: alepha48.TString;
|
|
15
|
+
status: alepha48.TInteger;
|
|
16
|
+
message: alepha48.TString;
|
|
17
|
+
details: alepha48.TOptional<alepha48.TString>;
|
|
18
|
+
requestId: alepha48.TOptional<alepha48.TString>;
|
|
19
|
+
cause: alepha48.TOptional<alepha48.TObject<{
|
|
20
|
+
name: alepha48.TString;
|
|
21
|
+
message: alepha48.TString;
|
|
22
22
|
}>>;
|
|
23
23
|
}>;
|
|
24
24
|
type ErrorSchema = Static<typeof errorSchema>;
|
|
@@ -257,15 +257,15 @@ interface WebRequestEvent {
|
|
|
257
257
|
}
|
|
258
258
|
//#endregion
|
|
259
259
|
//#region ../alepha/src/logger/schemas/logEntrySchema.d.ts
|
|
260
|
-
declare const logEntrySchema:
|
|
261
|
-
level:
|
|
262
|
-
message:
|
|
263
|
-
service:
|
|
264
|
-
module:
|
|
265
|
-
context:
|
|
266
|
-
app:
|
|
267
|
-
data:
|
|
268
|
-
timestamp:
|
|
260
|
+
declare const logEntrySchema: alepha48.TObject<{
|
|
261
|
+
level: alepha48.TUnsafe<"TRACE" | "SILENT" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
|
|
262
|
+
message: alepha48.TString;
|
|
263
|
+
service: alepha48.TString;
|
|
264
|
+
module: alepha48.TString;
|
|
265
|
+
context: alepha48.TOptional<alepha48.TString>;
|
|
266
|
+
app: alepha48.TOptional<alepha48.TString>;
|
|
267
|
+
data: alepha48.TOptional<alepha48.TAny>;
|
|
268
|
+
timestamp: alepha48.TNumber;
|
|
269
269
|
}>;
|
|
270
270
|
type LogEntry = Static<typeof logEntrySchema>;
|
|
271
271
|
//#endregion
|
|
@@ -280,8 +280,8 @@ declare class DateTimeProvider {
|
|
|
280
280
|
protected readonly timeouts: Timeout[];
|
|
281
281
|
protected readonly intervals: Interval[];
|
|
282
282
|
constructor();
|
|
283
|
-
protected readonly onStart:
|
|
284
|
-
protected readonly onStop:
|
|
283
|
+
protected readonly onStart: alepha48.HookPrimitive<"start">;
|
|
284
|
+
protected readonly onStop: alepha48.HookPrimitive<"stop">;
|
|
285
285
|
setLocale(locale: string): void;
|
|
286
286
|
isDateTime(value: unknown): value is DateTime;
|
|
287
287
|
/**
|
|
@@ -413,7 +413,7 @@ declare class Logger implements LoggerInterface {
|
|
|
413
413
|
}
|
|
414
414
|
//#endregion
|
|
415
415
|
//#region ../alepha/src/logger/index.d.ts
|
|
416
|
-
declare const envSchema$6:
|
|
416
|
+
declare const envSchema$6: alepha48.TObject<{
|
|
417
417
|
/**
|
|
418
418
|
* Default log level for the application.
|
|
419
419
|
*
|
|
@@ -430,14 +430,14 @@ declare const envSchema$6: alepha60.TObject<{
|
|
|
430
430
|
* LOG_LEVEL=my.module.name:debug,info # Set debug level for my.module.name and info for all other modules
|
|
431
431
|
* LOG_LEVEL=alepha:trace, info # Set trace level for all alepha modules and info for all other modules
|
|
432
432
|
*/
|
|
433
|
-
LOG_LEVEL:
|
|
433
|
+
LOG_LEVEL: alepha48.TOptional<alepha48.TString>;
|
|
434
434
|
/**
|
|
435
435
|
* Built-in log formats.
|
|
436
436
|
* - "json" - JSON format, useful for structured logging and log aggregation. {@link JsonFormatterProvider}
|
|
437
437
|
* - "pretty" - Simple text format, human-readable, with colors. {@link SimpleFormatterProvider}
|
|
438
438
|
* - "raw" - Raw format, no formatting, just the message. {@link RawFormatterProvider}
|
|
439
439
|
*/
|
|
440
|
-
LOG_FORMAT:
|
|
440
|
+
LOG_FORMAT: alepha48.TOptional<alepha48.TUnsafe<"json" | "pretty" | "raw">>;
|
|
441
441
|
}>;
|
|
442
442
|
declare module "alepha" {
|
|
443
443
|
interface Env extends Partial<Static<typeof envSchema$6>> {}
|
|
@@ -474,8 +474,8 @@ declare class ServerTimingProvider {
|
|
|
474
474
|
prefix: string;
|
|
475
475
|
disabled: boolean;
|
|
476
476
|
};
|
|
477
|
-
readonly onRequest:
|
|
478
|
-
readonly onResponse:
|
|
477
|
+
readonly onRequest: alepha48.HookPrimitive<"server:onRequest">;
|
|
478
|
+
readonly onResponse: alepha48.HookPrimitive<"server:onResponse">;
|
|
479
479
|
protected get handlerName(): string;
|
|
480
480
|
beginTiming(name: string): void;
|
|
481
481
|
endTiming(name: string): void;
|
|
@@ -539,11 +539,11 @@ declare class ServerProvider {
|
|
|
539
539
|
/**
|
|
540
540
|
* When a Node.js HTTP request is received from outside. (Vercel, AWS Lambda, etc.)
|
|
541
541
|
*/
|
|
542
|
-
protected readonly onNodeRequest:
|
|
542
|
+
protected readonly onNodeRequest: alepha48.HookPrimitive<"node:request">;
|
|
543
543
|
/**
|
|
544
544
|
* When a Web (Fetch API) request is received from outside. (Netlify, Cloudflare Workers, etc.)
|
|
545
545
|
*/
|
|
546
|
-
protected readonly onWebRequest:
|
|
546
|
+
protected readonly onWebRequest: alepha48.HookPrimitive<"web:request">;
|
|
547
547
|
/**
|
|
548
548
|
* Handle Node.js HTTP request event.
|
|
549
549
|
*
|
|
@@ -878,18 +878,18 @@ type ServerActionHandler<TConfig extends RequestConfigSchema = RequestConfigSche
|
|
|
878
878
|
interface ServerActionRequest<TConfig extends RequestConfigSchema> extends ServerRequest<TConfig> {}
|
|
879
879
|
//#endregion
|
|
880
880
|
//#region ../alepha/src/server/providers/BunHttpServerProvider.d.ts
|
|
881
|
-
declare const envSchema$5:
|
|
882
|
-
SERVER_PORT:
|
|
883
|
-
SERVER_HOST:
|
|
881
|
+
declare const envSchema$5: alepha48.TObject<{
|
|
882
|
+
SERVER_PORT: alepha48.TInteger;
|
|
883
|
+
SERVER_HOST: alepha48.TString;
|
|
884
884
|
}>;
|
|
885
885
|
declare module "alepha" {
|
|
886
886
|
interface Env extends Partial<Static<typeof envSchema$5>> {}
|
|
887
887
|
}
|
|
888
888
|
//#endregion
|
|
889
889
|
//#region ../alepha/src/server/providers/NodeHttpServerProvider.d.ts
|
|
890
|
-
declare const envSchema$4:
|
|
891
|
-
SERVER_PORT:
|
|
892
|
-
SERVER_HOST:
|
|
890
|
+
declare const envSchema$4: alepha48.TObject<{
|
|
891
|
+
SERVER_PORT: alepha48.TInteger;
|
|
892
|
+
SERVER_HOST: alepha48.TString;
|
|
893
893
|
}>;
|
|
894
894
|
declare module "alepha" {
|
|
895
895
|
interface Env extends Partial<Static<typeof envSchema$4>> {}
|
|
@@ -1077,8 +1077,8 @@ declare class Redirection extends Error {
|
|
|
1077
1077
|
}
|
|
1078
1078
|
//#endregion
|
|
1079
1079
|
//#region src/core/providers/ReactPageProvider.d.ts
|
|
1080
|
-
declare const envSchema$3:
|
|
1081
|
-
REACT_STRICT_MODE:
|
|
1080
|
+
declare const envSchema$3: alepha48.TObject<{
|
|
1081
|
+
REACT_STRICT_MODE: alepha48.TBoolean;
|
|
1082
1082
|
}>;
|
|
1083
1083
|
declare module "alepha" {
|
|
1084
1084
|
interface Env extends Partial<Static<typeof envSchema$3>> {}
|
|
@@ -1121,7 +1121,7 @@ declare class ReactPageProvider {
|
|
|
1121
1121
|
}, params?: Record<string, any>): string;
|
|
1122
1122
|
compile(path: string, params?: Record<string, string>): string;
|
|
1123
1123
|
protected renderView(index: number, path: string, view: ReactNode | undefined, page: PageRoute): ReactNode;
|
|
1124
|
-
protected readonly configure:
|
|
1124
|
+
protected readonly configure: alepha48.HookPrimitive<"configure">;
|
|
1125
1125
|
protected map(pages: Array<PagePrimitive>, target: PagePrimitive): PageRouteEntry;
|
|
1126
1126
|
add(entry: PageRouteEntry): void;
|
|
1127
1127
|
protected createMatch(page: PageRoute): string;
|
|
@@ -1192,6 +1192,7 @@ interface ReactRouterState {
|
|
|
1192
1192
|
* Optional meta information associated with the current page.
|
|
1193
1193
|
*/
|
|
1194
1194
|
meta: Record<string, any>;
|
|
1195
|
+
name?: string;
|
|
1195
1196
|
}
|
|
1196
1197
|
interface RouterStackItem {
|
|
1197
1198
|
route: PageRoute;
|
|
@@ -1539,15 +1540,15 @@ type CssAnimation = {
|
|
|
1539
1540
|
};
|
|
1540
1541
|
//#endregion
|
|
1541
1542
|
//#region ../alepha/src/security/schemas/userAccountInfoSchema.d.ts
|
|
1542
|
-
declare const userAccountInfoSchema:
|
|
1543
|
-
id:
|
|
1544
|
-
name:
|
|
1545
|
-
email:
|
|
1546
|
-
username:
|
|
1547
|
-
picture:
|
|
1548
|
-
sessionId:
|
|
1549
|
-
organizations:
|
|
1550
|
-
roles:
|
|
1543
|
+
declare const userAccountInfoSchema: alepha48.TObject<{
|
|
1544
|
+
id: alepha48.TString;
|
|
1545
|
+
name: alepha48.TOptional<alepha48.TString>;
|
|
1546
|
+
email: alepha48.TOptional<alepha48.TString>;
|
|
1547
|
+
username: alepha48.TOptional<alepha48.TString>;
|
|
1548
|
+
picture: alepha48.TOptional<alepha48.TString>;
|
|
1549
|
+
sessionId: alepha48.TOptional<alepha48.TString>;
|
|
1550
|
+
organizations: alepha48.TOptional<alepha48.TArray<alepha48.TString>>;
|
|
1551
|
+
roles: alepha48.TOptional<alepha48.TArray<alepha48.TString>>;
|
|
1551
1552
|
}>;
|
|
1552
1553
|
type UserAccount = Static<typeof userAccountInfoSchema>;
|
|
1553
1554
|
//#endregion
|
|
@@ -1573,8 +1574,8 @@ interface UserAccountToken extends UserAccount {
|
|
|
1573
1574
|
}
|
|
1574
1575
|
//#endregion
|
|
1575
1576
|
//#region ../alepha/src/security/providers/SecurityProvider.d.ts
|
|
1576
|
-
declare const envSchema$2:
|
|
1577
|
-
APP_SECRET:
|
|
1577
|
+
declare const envSchema$2: alepha48.TObject<{
|
|
1578
|
+
APP_SECRET: alepha48.TString;
|
|
1578
1579
|
}>;
|
|
1579
1580
|
declare module "alepha" {
|
|
1580
1581
|
interface Env extends Partial<Static<typeof envSchema$2>> {}
|
|
@@ -1667,23 +1668,23 @@ declare module "alepha/server" {
|
|
|
1667
1668
|
*/
|
|
1668
1669
|
//#endregion
|
|
1669
1670
|
//#region ../alepha/src/server-links/schemas/apiLinksResponseSchema.d.ts
|
|
1670
|
-
declare const apiLinkSchema:
|
|
1671
|
-
name:
|
|
1672
|
-
group:
|
|
1673
|
-
path:
|
|
1674
|
-
method:
|
|
1675
|
-
requestBodyType:
|
|
1676
|
-
service:
|
|
1671
|
+
declare const apiLinkSchema: alepha48.TObject<{
|
|
1672
|
+
name: alepha48.TString;
|
|
1673
|
+
group: alepha48.TOptional<alepha48.TString>;
|
|
1674
|
+
path: alepha48.TString;
|
|
1675
|
+
method: alepha48.TOptional<alepha48.TString>;
|
|
1676
|
+
requestBodyType: alepha48.TOptional<alepha48.TString>;
|
|
1677
|
+
service: alepha48.TOptional<alepha48.TString>;
|
|
1677
1678
|
}>;
|
|
1678
|
-
declare const apiLinksResponseSchema:
|
|
1679
|
-
prefix:
|
|
1680
|
-
links:
|
|
1681
|
-
name:
|
|
1682
|
-
group:
|
|
1683
|
-
path:
|
|
1684
|
-
method:
|
|
1685
|
-
requestBodyType:
|
|
1686
|
-
service:
|
|
1679
|
+
declare const apiLinksResponseSchema: alepha48.TObject<{
|
|
1680
|
+
prefix: alepha48.TOptional<alepha48.TString>;
|
|
1681
|
+
links: alepha48.TArray<alepha48.TObject<{
|
|
1682
|
+
name: alepha48.TString;
|
|
1683
|
+
group: alepha48.TOptional<alepha48.TString>;
|
|
1684
|
+
path: alepha48.TString;
|
|
1685
|
+
method: alepha48.TOptional<alepha48.TString>;
|
|
1686
|
+
requestBodyType: alepha48.TOptional<alepha48.TString>;
|
|
1687
|
+
service: alepha48.TOptional<alepha48.TString>;
|
|
1687
1688
|
}>>;
|
|
1688
1689
|
}>;
|
|
1689
1690
|
type ApiLinksResponse = Static<typeof apiLinksResponseSchema>;
|
|
@@ -1789,14 +1790,14 @@ declare class ReactBrowserRouterProvider extends RouterProvider<BrowserRoute> {
|
|
|
1789
1790
|
protected readonly alepha: Alepha;
|
|
1790
1791
|
protected readonly pageApi: ReactPageProvider;
|
|
1791
1792
|
add(entry: PageRouteEntry): void;
|
|
1792
|
-
protected readonly configure:
|
|
1793
|
+
protected readonly configure: alepha48.HookPrimitive<"configure">;
|
|
1793
1794
|
transition(url: URL, previous?: PreviousLayerData[], meta?: {}): Promise<string | void>;
|
|
1794
1795
|
root(state: ReactRouterState): ReactNode;
|
|
1795
1796
|
}
|
|
1796
1797
|
//#endregion
|
|
1797
1798
|
//#region src/core/providers/ReactBrowserProvider.d.ts
|
|
1798
|
-
declare const envSchema$1:
|
|
1799
|
-
REACT_ROOT_ID:
|
|
1799
|
+
declare const envSchema$1: alepha48.TObject<{
|
|
1800
|
+
REACT_ROOT_ID: alepha48.TString;
|
|
1800
1801
|
}>;
|
|
1801
1802
|
declare module "alepha" {
|
|
1802
1803
|
interface Env extends Partial<Static<typeof envSchema$1>> {}
|
|
@@ -1804,8 +1805,8 @@ declare module "alepha" {
|
|
|
1804
1805
|
/**
|
|
1805
1806
|
* React browser renderer configuration atom
|
|
1806
1807
|
*/
|
|
1807
|
-
declare const reactBrowserOptions:
|
|
1808
|
-
scrollRestoration:
|
|
1808
|
+
declare const reactBrowserOptions: alepha48.Atom<alepha48.TObject<{
|
|
1809
|
+
scrollRestoration: alepha48.TUnsafe<"top" | "manual">;
|
|
1809
1810
|
}>, "alepha.react.browser.options">;
|
|
1810
1811
|
type ReactBrowserRendererOptions = Static<typeof reactBrowserOptions.schema>;
|
|
1811
1812
|
declare module "alepha" {
|
|
@@ -1853,8 +1854,8 @@ declare class ReactBrowserProvider {
|
|
|
1853
1854
|
* Get embedded layers from the server.
|
|
1854
1855
|
*/
|
|
1855
1856
|
protected getHydrationState(): ReactHydrationState | undefined;
|
|
1856
|
-
protected readonly onTransitionEnd:
|
|
1857
|
-
readonly ready:
|
|
1857
|
+
protected readonly onTransitionEnd: alepha48.HookPrimitive<"react:transition:end">;
|
|
1858
|
+
readonly ready: alepha48.HookPrimitive<"ready">;
|
|
1858
1859
|
}
|
|
1859
1860
|
interface RouterGoOptions {
|
|
1860
1861
|
replace?: boolean;
|
|
@@ -2297,6 +2298,35 @@ declare class ReactRouter<T$1 extends object> {
|
|
|
2297
2298
|
isActive(href: string, options?: {
|
|
2298
2299
|
startWith?: boolean;
|
|
2299
2300
|
}): boolean;
|
|
2301
|
+
node(name: keyof VirtualRouter<T$1> | string, config?: {
|
|
2302
|
+
params?: Record<string, any>;
|
|
2303
|
+
query?: Record<string, any>;
|
|
2304
|
+
}): {
|
|
2305
|
+
label: any;
|
|
2306
|
+
href: string;
|
|
2307
|
+
children: undefined;
|
|
2308
|
+
type: "page";
|
|
2309
|
+
name: string;
|
|
2310
|
+
parent?: PageRoute;
|
|
2311
|
+
match: string;
|
|
2312
|
+
path?: string | undefined;
|
|
2313
|
+
schema?: PageConfigSchema | undefined;
|
|
2314
|
+
resolve?: ((context: PageResolve<PageConfigSchema, TPropsParentDefault>) => any) | undefined;
|
|
2315
|
+
component?: react0.FC<any> | undefined;
|
|
2316
|
+
lazy?: (() => Promise<{
|
|
2317
|
+
default: react0.FC<any>;
|
|
2318
|
+
}>) | undefined;
|
|
2319
|
+
can?: (() => boolean) | undefined;
|
|
2320
|
+
errorHandler?: ErrorHandler | undefined;
|
|
2321
|
+
static?: boolean | {
|
|
2322
|
+
entries?: Partial<PageRequestConfig<PageConfigSchema>>[] | undefined;
|
|
2323
|
+
} | undefined;
|
|
2324
|
+
cache?: ServerRouteCache | undefined;
|
|
2325
|
+
client?: (boolean | ClientOnlyProps) | undefined;
|
|
2326
|
+
onServerResponse?: ((request: ServerRequest) => unknown) | undefined;
|
|
2327
|
+
onLeave?: (() => void) | undefined;
|
|
2328
|
+
animation?: PageAnimation | undefined;
|
|
2329
|
+
};
|
|
2300
2330
|
path(name: keyof VirtualRouter<T$1> | string, config?: {
|
|
2301
2331
|
params?: Record<string, any>;
|
|
2302
2332
|
query?: Record<string, any>;
|
|
@@ -2561,7 +2591,7 @@ declare class ServerStaticProvider {
|
|
|
2561
2591
|
protected readonly fileDetector: FileDetector;
|
|
2562
2592
|
protected readonly log: Logger;
|
|
2563
2593
|
protected readonly directories: ServeDirectory[];
|
|
2564
|
-
protected readonly configure:
|
|
2594
|
+
protected readonly configure: alepha48.HookPrimitive<"configure">;
|
|
2565
2595
|
createStaticServer(options: ServePrimitiveOptions): Promise<void>;
|
|
2566
2596
|
createFileHandler(filepath: string, options: ServePrimitiveOptions): Promise<ServerHandler>;
|
|
2567
2597
|
protected getCacheFileTypes(): string[];
|
|
@@ -2577,10 +2607,10 @@ interface ServeDirectory {
|
|
|
2577
2607
|
}
|
|
2578
2608
|
//#endregion
|
|
2579
2609
|
//#region src/core/providers/ReactServerProvider.d.ts
|
|
2580
|
-
declare const envSchema:
|
|
2581
|
-
REACT_SSR_ENABLED:
|
|
2582
|
-
REACT_ROOT_ID:
|
|
2583
|
-
REACT_SERVER_TEMPLATE:
|
|
2610
|
+
declare const envSchema: alepha48.TObject<{
|
|
2611
|
+
REACT_SSR_ENABLED: alepha48.TOptional<alepha48.TBoolean>;
|
|
2612
|
+
REACT_ROOT_ID: alepha48.TString;
|
|
2613
|
+
REACT_SERVER_TEMPLATE: alepha48.TOptional<alepha48.TString>;
|
|
2584
2614
|
}>;
|
|
2585
2615
|
declare module "alepha" {
|
|
2586
2616
|
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
@@ -2591,11 +2621,11 @@ declare module "alepha" {
|
|
|
2591
2621
|
/**
|
|
2592
2622
|
* React server provider configuration atom
|
|
2593
2623
|
*/
|
|
2594
|
-
declare const reactServerOptions:
|
|
2595
|
-
publicDir:
|
|
2596
|
-
staticServer:
|
|
2597
|
-
disabled:
|
|
2598
|
-
path:
|
|
2624
|
+
declare const reactServerOptions: alepha48.Atom<alepha48.TObject<{
|
|
2625
|
+
publicDir: alepha48.TString;
|
|
2626
|
+
staticServer: alepha48.TObject<{
|
|
2627
|
+
disabled: alepha48.TBoolean;
|
|
2628
|
+
path: alepha48.TString;
|
|
2599
2629
|
}>;
|
|
2600
2630
|
}>, "alepha.react.server.options">;
|
|
2601
2631
|
type ReactServerProviderOptions = Static<typeof reactServerOptions.schema>;
|
|
@@ -2629,7 +2659,7 @@ declare class ReactServerProvider {
|
|
|
2629
2659
|
/**
|
|
2630
2660
|
* Configure the React server provider.
|
|
2631
2661
|
*/
|
|
2632
|
-
readonly onConfigure:
|
|
2662
|
+
readonly onConfigure: alepha48.HookPrimitive<"configure">;
|
|
2633
2663
|
get template(): string;
|
|
2634
2664
|
protected registerPages(templateLoader: TemplateLoader): Promise<void>;
|
|
2635
2665
|
/**
|
|
@@ -2765,7 +2795,7 @@ declare module "alepha" {
|
|
|
2765
2795
|
* @see {@link $page}
|
|
2766
2796
|
* @module alepha.react
|
|
2767
2797
|
*/
|
|
2768
|
-
declare const AlephaReact:
|
|
2798
|
+
declare const AlephaReact: alepha48.Service<alepha48.Module>;
|
|
2769
2799
|
//#endregion
|
|
2770
2800
|
export { $page, ActionContext, AlephaContext, AlephaReact, AnchorProps, ClientOnly, ConcretePageRoute, CreateLayersResult, ErrorBoundary, ErrorHandler, ErrorViewer, Layer, Link, type LinkProps, _default as NestedView, NotFoundPage as NotFound, PageAnimation, PageConfigSchema, PagePrimitive, PagePrimitiveOptions, PagePrimitiveRenderOptions, PagePrimitiveRenderResult, PageRequestConfig, PageResolve, PageRoute, PageRouteEntry, PreviousLayerData, ReactBrowserProvider, ReactBrowserRendererOptions, ReactHydrationState, ReactPageProvider, ReactRouter, ReactRouterState, ReactServerProvider, ReactServerProviderOptions, Redirection, RouterGoOptions, RouterLayerContext, RouterLayerContextValue, RouterRenderOptions, RouterStackItem, TPropsDefault, TPropsParentDefault, TransitionOptions, UseActionOptions, UseActionReturn, UseActiveHook, UseActiveOptions, UseQueryParamsHookOptions, UseSchemaReturn, UseStoreReturn, VirtualRouter, isPageRoute, reactBrowserOptions, reactServerOptions, ssrSchemaLoading, useAction, useActive, useAlepha, useClient, useEvents, useInject, useQueryParams, useRouter, useRouterState, useSchema, useStore };
|
|
2771
2801
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/core/index.js
CHANGED
|
@@ -487,7 +487,8 @@ const NestedView = (props) => {
|
|
|
487
487
|
useEvents({
|
|
488
488
|
"react:transition:begin": async ({ previous, state: state$1 }) => {
|
|
489
489
|
const layer = previous.layers[index];
|
|
490
|
-
if (
|
|
490
|
+
if (!layer) return;
|
|
491
|
+
if (`${state$1.url.pathname}/`.startsWith(`${layer.path}/`)) return;
|
|
491
492
|
const animationExit = parseAnimation(layer.route?.animation, state$1, "exit");
|
|
492
493
|
if (animationExit) {
|
|
493
494
|
const duration = animationExit.duration || 200;
|
|
@@ -579,25 +580,35 @@ function parseAnimation(animationLike, state, type = "enter") {
|
|
|
579
580
|
//#endregion
|
|
580
581
|
//#region src/core/components/NotFound.tsx
|
|
581
582
|
function NotFoundPage(props) {
|
|
582
|
-
return /* @__PURE__ */
|
|
583
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
583
584
|
style: {
|
|
584
|
-
|
|
585
|
+
width: "100%",
|
|
586
|
+
minHeight: "90vh",
|
|
587
|
+
boxSizing: "border-box",
|
|
585
588
|
display: "flex",
|
|
586
589
|
flexDirection: "column",
|
|
587
590
|
justifyContent: "center",
|
|
588
591
|
alignItems: "center",
|
|
589
592
|
textAlign: "center",
|
|
590
|
-
fontFamily: "sans-serif",
|
|
591
|
-
padding: "
|
|
593
|
+
fontFamily: "system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif",
|
|
594
|
+
padding: "2rem",
|
|
592
595
|
...props.style
|
|
593
596
|
},
|
|
594
|
-
children: /* @__PURE__ */ jsx("
|
|
597
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
595
598
|
style: {
|
|
596
|
-
fontSize: "
|
|
597
|
-
|
|
599
|
+
fontSize: "6rem",
|
|
600
|
+
fontWeight: 200,
|
|
601
|
+
lineHeight: 1
|
|
598
602
|
},
|
|
599
|
-
children: "404
|
|
600
|
-
})
|
|
603
|
+
children: "404"
|
|
604
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
605
|
+
style: {
|
|
606
|
+
fontSize: "0.875rem",
|
|
607
|
+
marginTop: "1rem",
|
|
608
|
+
opacity: .6
|
|
609
|
+
},
|
|
610
|
+
children: "Page not found"
|
|
611
|
+
})]
|
|
601
612
|
});
|
|
602
613
|
}
|
|
603
614
|
|
|
@@ -1012,8 +1023,7 @@ var ReactServerProvider = class {
|
|
|
1012
1023
|
async registerPages(templateLoader) {
|
|
1013
1024
|
const template = await templateLoader();
|
|
1014
1025
|
if (template) this.preprocessedTemplate = this.preprocessTemplate(template);
|
|
1015
|
-
for (const page of this.pageApi.getPages()) {
|
|
1016
|
-
if (page.children?.length) continue;
|
|
1026
|
+
for (const page of this.pageApi.getPages()) if (page.component || page.lazy) {
|
|
1017
1027
|
this.log.debug(`+ ${page.match} -> ${page.name}`);
|
|
1018
1028
|
this.serverRouterProvider.createRoute({
|
|
1019
1029
|
...page,
|
|
@@ -1110,6 +1120,7 @@ var ReactServerProvider = class {
|
|
|
1110
1120
|
onError: () => null,
|
|
1111
1121
|
layers: []
|
|
1112
1122
|
};
|
|
1123
|
+
state.name = route.name;
|
|
1113
1124
|
if (this.alepha.has(ServerLinksProvider)) this.alepha.store.set("alepha.server.request.apiLinks", await this.alepha.inject(ServerLinksProvider).getUserApiLinks({
|
|
1114
1125
|
user: serverRequest.user,
|
|
1115
1126
|
authorization: serverRequest.headers.authorization
|
|
@@ -1117,6 +1128,7 @@ var ReactServerProvider = class {
|
|
|
1117
1128
|
let target = route;
|
|
1118
1129
|
while (target) {
|
|
1119
1130
|
if (route.can && !route.can()) {
|
|
1131
|
+
this.log.warn(`Access to page '${route.name}' is forbidden by can() check`);
|
|
1120
1132
|
reply.status = 403;
|
|
1121
1133
|
reply.headers["content-type"] = "text/plain";
|
|
1122
1134
|
return "Forbidden";
|
|
@@ -1130,7 +1142,10 @@ var ReactServerProvider = class {
|
|
|
1130
1142
|
this.serverTimingProvider.beginTiming("createLayers");
|
|
1131
1143
|
const { redirect } = await this.pageApi.createLayers(route, state);
|
|
1132
1144
|
this.serverTimingProvider.endTiming("createLayers");
|
|
1133
|
-
if (redirect)
|
|
1145
|
+
if (redirect) {
|
|
1146
|
+
this.log.debug("Resolver resulted in redirection", { redirect });
|
|
1147
|
+
return reply.redirect(redirect);
|
|
1148
|
+
}
|
|
1134
1149
|
reply.headers["content-type"] = "text/html";
|
|
1135
1150
|
reply.headers["cache-control"] = "no-store, no-cache, must-revalidate, proxy-revalidate";
|
|
1136
1151
|
reply.headers.pragma = "no-cache";
|
|
@@ -1138,8 +1153,10 @@ var ReactServerProvider = class {
|
|
|
1138
1153
|
const html = this.renderToHtml(template, state);
|
|
1139
1154
|
if (html instanceof Redirection) {
|
|
1140
1155
|
reply.redirect(typeof html.redirect === "string" ? html.redirect : this.pageApi.href(html.redirect));
|
|
1156
|
+
this.log.debug("Rendering resulted in redirection", { redirect: html.redirect });
|
|
1141
1157
|
return;
|
|
1142
1158
|
}
|
|
1159
|
+
this.log.trace("Page rendered to HTML successfully");
|
|
1143
1160
|
const event = {
|
|
1144
1161
|
request: serverRequest,
|
|
1145
1162
|
state,
|
|
@@ -1292,6 +1309,7 @@ var ReactBrowserRouterProvider = class extends RouterProvider {
|
|
|
1292
1309
|
const { route, params } = this.match(pathname);
|
|
1293
1310
|
const query = {};
|
|
1294
1311
|
if (search) for (const [key, value] of new URLSearchParams(search).entries()) query[key] = String(value);
|
|
1312
|
+
state.name = route?.page.name;
|
|
1295
1313
|
state.query = query;
|
|
1296
1314
|
state.params = params ?? {};
|
|
1297
1315
|
if (isPageRoute(route)) {
|
|
@@ -1524,6 +1542,15 @@ var ReactRouter = class {
|
|
|
1524
1542
|
if (options.startWith && !isActive) isActive = current.startsWith(href);
|
|
1525
1543
|
return isActive;
|
|
1526
1544
|
}
|
|
1545
|
+
node(name, config = {}) {
|
|
1546
|
+
const page = this.pageApi.page(name);
|
|
1547
|
+
return {
|
|
1548
|
+
...page,
|
|
1549
|
+
label: page.label ?? page.name,
|
|
1550
|
+
href: this.path(name, config),
|
|
1551
|
+
children: void 0
|
|
1552
|
+
};
|
|
1553
|
+
}
|
|
1527
1554
|
path(name, config = {}) {
|
|
1528
1555
|
return this.pageApi.pathname(name, {
|
|
1529
1556
|
params: {
|