rasengan 1.0.0-beta.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/LICENSE +21 -0
- package/lib/cli/dirname.d.ts +2 -0
- package/lib/cli/dirname.js +6 -0
- package/lib/cli/dirname.js.map +1 -0
- package/lib/cli/index.d.ts +2 -0
- package/lib/cli/index.js +101 -0
- package/lib/cli/index.js.map +1 -0
- package/lib/config/index.d.ts +39 -0
- package/lib/config/index.js +57 -0
- package/lib/config/index.js.map +1 -0
- package/lib/config/type.d.ts +68 -0
- package/lib/config/type.js +2 -0
- package/lib/config/type.js.map +1 -0
- package/lib/core/components/index.d.ts +26 -0
- package/lib/core/components/index.js +72 -0
- package/lib/core/components/index.js.map +1 -0
- package/lib/core/index.d.ts +2 -0
- package/lib/core/index.js +2 -0
- package/lib/core/index.js.map +1 -0
- package/lib/core/interfaces.d.ts +76 -0
- package/lib/core/interfaces.js +91 -0
- package/lib/core/interfaces.js.map +1 -0
- package/lib/core/types.d.ts +45 -0
- package/lib/core/types.js +2 -0
- package/lib/core/types.js.map +1 -0
- package/lib/decorators/index.d.ts +2 -0
- package/lib/decorators/index.js +3 -0
- package/lib/decorators/index.js.map +1 -0
- package/lib/decorators/route.d.ts +7 -0
- package/lib/decorators/route.js +25 -0
- package/lib/decorators/route.js.map +1 -0
- package/lib/decorators/router.d.ts +7 -0
- package/lib/decorators/router.js +24 -0
- package/lib/decorators/router.js.map +1 -0
- package/lib/decorators/types.d.ts +47 -0
- package/lib/decorators/types.js +2 -0
- package/lib/decorators/types.js.map +1 -0
- package/lib/entries/entry-client.d.ts +1 -0
- package/lib/entries/entry-client.js +15 -0
- package/lib/entries/entry-client.js.map +1 -0
- package/lib/entries/entry-server.d.ts +6 -0
- package/lib/entries/entry-server.js +20 -0
- package/lib/entries/entry-server.js.map +1 -0
- package/lib/hooks/index.d.ts +0 -0
- package/lib/hooks/index.js +1 -0
- package/lib/hooks/index.js.map +1 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.js +10 -0
- package/lib/index.js.map +1 -0
- package/lib/routing/components/index.d.ts +32 -0
- package/lib/routing/components/index.js +69 -0
- package/lib/routing/components/index.js.map +1 -0
- package/lib/routing/index.d.ts +3 -0
- package/lib/routing/index.js +4 -0
- package/lib/routing/index.js.map +1 -0
- package/lib/routing/interfaces.d.ts +67 -0
- package/lib/routing/interfaces.js +88 -0
- package/lib/routing/interfaces.js.map +1 -0
- package/lib/routing/types.d.ts +4 -0
- package/lib/routing/types.js +2 -0
- package/lib/routing/types.js.map +1 -0
- package/lib/routing/utils/index.d.ts +40 -0
- package/lib/routing/utils/index.js +256 -0
- package/lib/routing/utils/index.js.map +1 -0
- package/lib/server/functions/vercel/api/index.d.ts +2 -0
- package/lib/server/functions/vercel/api/index.js +91 -0
- package/lib/server/functions/vercel/api/index.js.map +1 -0
- package/lib/server/functions/vercel/vercel.json +12 -0
- package/lib/server/utils/createFetchRequest.d.ts +5 -0
- package/lib/server/utils/createFetchRequest.js +34 -0
- package/lib/server/utils/createFetchRequest.js.map +1 -0
- package/lib/server/utils/getIp.d.ts +1 -0
- package/lib/server/utils/getIp.js +30 -0
- package/lib/server/utils/getIp.js.map +1 -0
- package/lib/server/utils/handleError.d.ts +2 -0
- package/lib/server/utils/handleError.js +28 -0
- package/lib/server/utils/handleError.js.map +1 -0
- package/lib/server/utils/index.d.ts +5 -0
- package/lib/server/utils/index.js +8 -0
- package/lib/server/utils/index.js.map +1 -0
- package/lib/server/utils/log.d.ts +6 -0
- package/lib/server/utils/log.js +69 -0
- package/lib/server/utils/log.js.map +1 -0
- package/package.json +75 -0
- package/server.js +229 -0
- package/src/cli/dirname.ts +7 -0
- package/src/cli/index.ts +134 -0
- package/src/config/index.ts +67 -0
- package/src/config/type.ts +76 -0
- package/src/core/components/index.tsx +111 -0
- package/src/core/index.ts +14 -0
- package/src/core/interfaces.tsx +129 -0
- package/src/core/types.ts +43 -0
- package/src/decorators/index.ts +2 -0
- package/src/decorators/route.ts +32 -0
- package/src/decorators/router.ts +30 -0
- package/src/decorators/types.ts +54 -0
- package/src/entries/entry-client.tsx +33 -0
- package/src/entries/entry-server.tsx +50 -0
- package/src/hooks/index.ts +0 -0
- package/src/index.ts +11 -0
- package/src/routing/components/index.tsx +125 -0
- package/src/routing/index.ts +23 -0
- package/src/routing/interfaces.ts +105 -0
- package/src/routing/types.ts +3 -0
- package/src/routing/utils/index.tsx +342 -0
- package/src/server/functions/vercel/api/index.ts +122 -0
- package/src/server/functions/vercel/vercel.json +12 -0
- package/src/server/utils/createFetchRequest.ts +40 -0
- package/src/server/utils/getIp.ts +37 -0
- package/src/server/utils/handleError.ts +36 -0
- package/src/server/utils/index.ts +15 -0
- package/src/server/utils/log.ts +115 -0
- package/src/vite-env.d.ts +1 -0
- package/tsconfig.json +30 -0
- package/tsconfig.lib.json +41 -0
- package/tsconfig.node.json +11 -0
- package/vite.config.ts +45 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RouteDecoratorProps } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Decorator that add metadata for a page.
|
|
4
|
+
* @param props Object that define the necessary elements to create a router
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
export declare function Route(props: RouteDecoratorProps): (constructor: Function) => void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Router Decorators
|
|
2
|
+
/**
|
|
3
|
+
* Decorator that add metadata for a page.
|
|
4
|
+
* @param props Object that define the necessary elements to create a router
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
export function Route(props) {
|
|
8
|
+
return function (constructor) {
|
|
9
|
+
// Handle errors
|
|
10
|
+
if (!props.path)
|
|
11
|
+
throw new Error("You must provide a path in the route decorator");
|
|
12
|
+
// Add values to properties
|
|
13
|
+
// Define path of the page
|
|
14
|
+
constructor.prototype._path = props.path;
|
|
15
|
+
// Define title of the page
|
|
16
|
+
constructor.prototype._title =
|
|
17
|
+
props.title ||
|
|
18
|
+
constructor.name.charAt(0).toUpperCase() + constructor.name.slice(1);
|
|
19
|
+
// Define description of the page
|
|
20
|
+
constructor.prototype._description = props.description || "";
|
|
21
|
+
Object.seal(constructor);
|
|
22
|
+
Object.seal(constructor.prototype);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=route.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route.js","sourceRoot":"","sources":["../../src/decorators/route.ts"],"names":[],"mappings":"AAAA,oBAAoB;AAIpB;;;;GAIG;AACH,MAAM,UAAU,KAAK,CAAC,KAA0B;IAC9C,OAAO,UAAU,WAAqB;QACpC,gBAAgB;QAChB,IAAI,CAAC,KAAK,CAAC,IAAI;YACb,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;QAEpE,2BAA2B;QAE3B,0BAA0B;QAC1B,WAAW,CAAC,SAAS,CAAC,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC;QAEzC,2BAA2B;QAC3B,WAAW,CAAC,SAAS,CAAC,MAAM;YAC1B,KAAK,CAAC,KAAK;gBACX,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAEvE,iCAAiC;QACjC,WAAW,CAAC,SAAS,CAAC,YAAY,GAAG,KAAK,CAAC,WAAW,IAAI,EAAE,CAAC;QAE7D,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACzB,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IACrC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RouterDecoratorProps } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Decorator that define a new router.
|
|
4
|
+
* @param props Object that define the necessary elements to create a router
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
export declare function Router(props: RouterDecoratorProps): (constructor: Function) => void;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Router Decorators
|
|
2
|
+
import { DefaultLayout } from "../core/interfaces.js";
|
|
3
|
+
/**
|
|
4
|
+
* Decorator that define a new router.
|
|
5
|
+
* @param props Object that define the necessary elements to create a router
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export function Router(props) {
|
|
9
|
+
return function (constructor) {
|
|
10
|
+
// Handle errors
|
|
11
|
+
if (!props.pages)
|
|
12
|
+
throw new Error("You must provide a list of pages in the router decorator");
|
|
13
|
+
// Add values to properties
|
|
14
|
+
// Define sub routers if provided or set and empty array
|
|
15
|
+
constructor.prototype["_routers"] = props.imports || [];
|
|
16
|
+
// Define layout if provided or set a default one.
|
|
17
|
+
constructor.prototype["_layout"] = props.layout || DefaultLayout;
|
|
18
|
+
// Define pages
|
|
19
|
+
constructor.prototype["_pages"] = props.pages;
|
|
20
|
+
Object.seal(constructor);
|
|
21
|
+
Object.seal(constructor.prototype);
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.js","sourceRoot":"","sources":["../../src/decorators/router.ts"],"names":[],"mappings":"AAAA,oBAAoB;AAEpB,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAGtD;;;;GAIG;AACH,MAAM,UAAU,MAAM,CAAC,KAA2B;IAChD,OAAO,UAAU,WAAqB;QACpC,gBAAgB;QAChB,IAAI,CAAC,KAAK,CAAC,KAAK;YAAE,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;QAE9F,2BAA2B;QAE3B,wDAAwD;QACxD,WAAW,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC;QAExD,kDAAkD;QAClD,WAAW,CAAC,SAAS,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC,MAAM,IAAI,aAAa,CAAC;QAEjE,eAAe;QACf,WAAW,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC;QAE9C,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACzB,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IACrC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { LayoutComponent, PageComponent } from "../core/interfaces.js";
|
|
3
|
+
import { RouterComponent } from "../routing/interfaces.js";
|
|
4
|
+
/**
|
|
5
|
+
* Props for Router Decorators
|
|
6
|
+
*/
|
|
7
|
+
export type RouterDecoratorProps = {
|
|
8
|
+
/**
|
|
9
|
+
* Usefull to collect sub routers
|
|
10
|
+
*/
|
|
11
|
+
imports?: Array<RouterComponent>;
|
|
12
|
+
/**
|
|
13
|
+
* Usefull to define a layout
|
|
14
|
+
*/
|
|
15
|
+
layout?: LayoutComponent;
|
|
16
|
+
/**
|
|
17
|
+
* Usefull to collect pages
|
|
18
|
+
*/
|
|
19
|
+
pages: Array<PageComponent>;
|
|
20
|
+
/**
|
|
21
|
+
* Usefull to display a screen that let know to the user that the page is loading.
|
|
22
|
+
*/
|
|
23
|
+
loaderComponent?: React.FC;
|
|
24
|
+
/**
|
|
25
|
+
* Usefull to display a screen that let know to the user that the page is not found.
|
|
26
|
+
*/
|
|
27
|
+
notFoundComponent?: React.FC;
|
|
28
|
+
};
|
|
29
|
+
export type RouteDecoratorProps = RouteLayoutDecoratorProps & {
|
|
30
|
+
/**
|
|
31
|
+
* Title of the page
|
|
32
|
+
*/
|
|
33
|
+
title?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Description of the page
|
|
36
|
+
*/
|
|
37
|
+
description?: string;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Props for Layout Decorators
|
|
41
|
+
*/
|
|
42
|
+
export type RouteLayoutDecoratorProps = {
|
|
43
|
+
/**
|
|
44
|
+
* base path of the layout
|
|
45
|
+
*/
|
|
46
|
+
path: string;
|
|
47
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/decorators/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import ReactDOM from "react-dom/client";
|
|
4
|
+
// @ts-ignore
|
|
5
|
+
import App from "./../../../../src/main";
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
// import AppRouter from "./../../../../src/pages/app.router";
|
|
8
|
+
import { Component, ErrorBoundary } from "../core/components/index.js";
|
|
9
|
+
// @ts-ignore
|
|
10
|
+
import config from "./../../../../rasengan.config.js";
|
|
11
|
+
import * as pkg from "react-helmet-async";
|
|
12
|
+
// @ts-ignore
|
|
13
|
+
const { HelmetProvider } = pkg.default || pkg;
|
|
14
|
+
ReactDOM.hydrateRoot(document.getElementById("root"), config.reactStrictMode ? (_jsx(React.StrictMode, { children: _jsx(ErrorBoundary, { children: _jsx(HelmetProvider, { children: _jsx(App, { Component: Component }) }) }) })) : (_jsx(ErrorBoundary, { children: _jsx(HelmetProvider, { children: _jsx(App, { Component: Component }) }) })));
|
|
15
|
+
//# sourceMappingURL=entry-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry-client.js","sourceRoot":"","sources":["../../src/entries/entry-client.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,QAAQ,MAAM,kBAAkB,CAAC;AACxC,aAAa;AACb,OAAO,GAAG,MAAM,wBAAwB,CAAC;AACzC,aAAa;AACb,8DAA8D;AAC9D,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACvE,aAAa;AACb,OAAO,MAAM,MAAM,kCAAkC,CAAC;AAEtD,OAAO,KAAK,GAAG,MAAM,oBAAoB,CAAC;AAE1C,aAAa;AACb,MAAM,EAAE,cAAc,EAAE,GAAG,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC;AAE9C,QAAQ,CAAC,WAAW,CAClB,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAgB,EAC9C,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,CACvB,KAAC,KAAK,CAAC,UAAU,cACf,KAAC,aAAa,cACZ,KAAC,cAAc,cACb,KAAC,GAAG,IAAC,SAAS,EAAE,SAAS,GAAI,GACd,GACH,GACC,CACpB,CAAC,CAAC,CAAC,CACF,KAAC,aAAa,cACZ,KAAC,cAAc,cACb,KAAC,GAAG,IAAC,SAAS,EAAE,SAAS,GAAI,GACd,GACH,CACjB,CACF,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { StaticHandlerContext } from "react-router-dom/server.js";
|
|
2
|
+
import { Router } from "@remix-run/router";
|
|
3
|
+
export declare function render(router: Router, context: StaticHandlerContext, helmetContext?: any): {
|
|
4
|
+
html: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const staticRoutes: any;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import ReactDOMServer from "react-dom/server";
|
|
4
|
+
// @ts-ignore
|
|
5
|
+
import AppRouter from "./../../../../src/pages/app.router";
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
import { generateStaticRoutes, } from "../routing/utils/index.js";
|
|
8
|
+
import { StaticRouterProvider, } from "react-router-dom/server.js";
|
|
9
|
+
// @ts-ignore
|
|
10
|
+
import config from "./../../../../rasengan.config.js";
|
|
11
|
+
import { ErrorBoundary } from "../core/components";
|
|
12
|
+
import * as pkg from "react-helmet-async";
|
|
13
|
+
// @ts-ignore
|
|
14
|
+
const { HelmetProvider } = pkg.default || pkg;
|
|
15
|
+
export function render(router, context, helmetContext = {}) {
|
|
16
|
+
const html = ReactDOMServer.renderToString(config.reactStrictMode ? (_jsx(React.StrictMode, { children: _jsx(ErrorBoundary, { children: _jsx(HelmetProvider, { context: helmetContext, children: _jsx(StaticRouterProvider, { router: router, context: context }) }) }) })) : (_jsx(ErrorBoundary, { children: _jsx(HelmetProvider, { context: helmetContext, children: _jsx(StaticRouterProvider, { router: router, context: context }) }) })));
|
|
17
|
+
return { html };
|
|
18
|
+
}
|
|
19
|
+
export const staticRoutes = generateStaticRoutes(AppRouter);
|
|
20
|
+
//# sourceMappingURL=entry-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry-server.js","sourceRoot":"","sources":["../../src/entries/entry-server.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,aAAa;AACb,OAAO,SAAS,MAAM,oCAAoC,CAAC;AAE3D,aAAa;AACb,OAAO,EACL,oBAAoB,GACrB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAEL,oBAAoB,GACrB,MAAM,4BAA4B,CAAC;AAGpC,aAAa;AACb,OAAO,MAAM,MAAM,kCAAkC,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,KAAK,GAAG,MAAM,oBAAoB,CAAC;AAE1C,aAAa;AACb,MAAM,EAAE,cAAc,EAAE,GAAG,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC;AAE9C,MAAM,UAAU,MAAM,CACpB,MAAc,EACd,OAA6B,EAC7B,gBAAqB,EAAE;IAEvB,MAAM,IAAI,GAAG,cAAc,CAAC,cAAc,CACxC,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,CACvB,KAAC,KAAK,CAAC,UAAU,cACf,KAAC,aAAa,cACZ,KAAC,cAAc,IAAC,OAAO,EAAE,aAAa,YACpC,KAAC,oBAAoB,IAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAI,GAC3C,GACH,GACC,CACpB,CAAC,CAAC,CAAC,CACF,KAAC,aAAa,cACZ,KAAC,cAAc,IAAC,OAAO,EAAE,aAAa,YACpC,KAAC,oBAAoB,IAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAI,GAC3C,GACH,CACjB,CACF,CAAC;IACF,OAAO,EAAE,IAAI,EAAE,CAAC;AAClB,CAAC;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,oBAAoB,CAAC,SAAS,CAAC,CAAC"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":""}
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Imports
|
|
2
|
+
import createFetchRequest from "./server/utils/createFetchRequest.js";
|
|
3
|
+
// Exports
|
|
4
|
+
export * from "./core/index.js";
|
|
5
|
+
export * from "./routing/index.js";
|
|
6
|
+
export * from "./decorators/index.js";
|
|
7
|
+
export * from "./config/index.js";
|
|
8
|
+
export { createFetchRequest };
|
|
9
|
+
// export * as hooks from './hooks';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,OAAO,kBAAkB,MAAM,sCAAsC,CAAC;AAEtE,UAAU;AACV,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,CAAA;AAE7B,oCAAoC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { PageComponent } from "../../core/interfaces.js";
|
|
2
|
+
import { NotFoundComponentContainerProps } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Error boundary component that will be displayed if an error occurs during a routing
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
export declare function ErrorBoundary(): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
/**
|
|
9
|
+
* Component that will be displayed during a routing on the server side
|
|
10
|
+
* @returns React.ReactNode
|
|
11
|
+
*/
|
|
12
|
+
export declare const ServerComponent: ({ page, loader, }: {
|
|
13
|
+
page: PageComponent;
|
|
14
|
+
loader: React.ReactNode;
|
|
15
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
/**
|
|
17
|
+
* Component that will be displayed during a routing on the client side
|
|
18
|
+
* @returns React.ReactNode
|
|
19
|
+
*/
|
|
20
|
+
export declare const ClientComponent: ({ page, loader, }: {
|
|
21
|
+
page: PageComponent;
|
|
22
|
+
loader: React.ReactNode;
|
|
23
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
/**
|
|
25
|
+
* Component that will be displayed when a page is not found
|
|
26
|
+
* @returns React.ReactNode
|
|
27
|
+
*/
|
|
28
|
+
export declare const NotFoundPageComponent: () => import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
/**
|
|
30
|
+
* Component that will be displayed when a page is not found
|
|
31
|
+
*/
|
|
32
|
+
export declare const NotFoundComponentContainer: ({ content, }: NotFoundComponentContainerProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Suspense } from "react";
|
|
3
|
+
import { Link, useLoaderData, useRouteError } from "react-router-dom";
|
|
4
|
+
import { PageToRender } from "../../core/components/index.js";
|
|
5
|
+
/**
|
|
6
|
+
* Error boundary component that will be displayed if an error occurs during a routing
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export function ErrorBoundary() {
|
|
10
|
+
let error = useRouteError();
|
|
11
|
+
console.error(error);
|
|
12
|
+
return _jsx("div", { children: "Dang!" });
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Component that will be displayed during a routing on the server side
|
|
16
|
+
* @returns React.ReactNode
|
|
17
|
+
*/
|
|
18
|
+
export const ServerComponent = ({ page, loader, }) => {
|
|
19
|
+
// Default data
|
|
20
|
+
const data = {
|
|
21
|
+
props: {},
|
|
22
|
+
};
|
|
23
|
+
return (_jsx(Suspense, { fallback: loader, children: _jsx(PageToRender, { page: page, data: data }) }));
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Component that will be displayed during a routing on the client side
|
|
27
|
+
* @returns React.ReactNode
|
|
28
|
+
*/
|
|
29
|
+
export const ClientComponent = ({ page, loader, }) => {
|
|
30
|
+
// Default data
|
|
31
|
+
const defaultData = {
|
|
32
|
+
props: {},
|
|
33
|
+
};
|
|
34
|
+
const data = useLoaderData() || defaultData;
|
|
35
|
+
return (_jsx(Suspense, { fallback: loader, children: _jsx(PageToRender, { page: page, data: data }) }));
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Component that will be displayed when a page is not found
|
|
39
|
+
* @returns React.ReactNode
|
|
40
|
+
*/
|
|
41
|
+
export const NotFoundPageComponent = () => {
|
|
42
|
+
return (_jsxs("section", { style: {
|
|
43
|
+
display: "flex",
|
|
44
|
+
flexDirection: "column",
|
|
45
|
+
justifyContent: "center",
|
|
46
|
+
alignItems: "center",
|
|
47
|
+
height: "100vh",
|
|
48
|
+
width: "100vw",
|
|
49
|
+
}, children: [_jsx("h1", { style: {
|
|
50
|
+
fontSize: "3rem",
|
|
51
|
+
fontWeight: "bold",
|
|
52
|
+
marginBottom: 10,
|
|
53
|
+
}, children: "404 Page Not Found" }), _jsx("p", { style: {
|
|
54
|
+
fontSize: "1.2rem",
|
|
55
|
+
marginBottom: 20,
|
|
56
|
+
}, children: "The page you are looking for does not exist or has been moved." }), _jsx(Link, { to: "/", style: {
|
|
57
|
+
fontSize: "1.2rem",
|
|
58
|
+
fontWeight: 800,
|
|
59
|
+
marginBottom: 20,
|
|
60
|
+
textDecoration: "none",
|
|
61
|
+
}, children: "Go back to home page" })] }));
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Component that will be displayed when a page is not found
|
|
65
|
+
*/
|
|
66
|
+
export const NotFoundComponentContainer = ({ content, }) => {
|
|
67
|
+
return _jsx(_Fragment, { children: content({}) });
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/routing/components/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAK9D;;;GAGG;AACH,MAAM,UAAU,aAAa;IAC3B,IAAI,KAAK,GAAG,aAAa,EAAE,CAAC;IAE5B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAErB,OAAO,kCAAgB,CAAC;AAC1B,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,EAC9B,IAAI,EACJ,MAAM,GAIP,EAAE,EAAE;IACH,eAAe;IACf,MAAM,IAAI,GAAG;QACX,KAAK,EAAE,EAAE;KACV,CAAC;IAEF,OAAO,CACL,KAAC,QAAQ,IAAC,QAAQ,EAAE,MAAM,YACxB,KAAC,YAAY,IAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,GAAI,GAC/B,CACZ,CAAC;AACJ,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,EAC9B,IAAI,EACJ,MAAM,GAIP,EAAE,EAAE;IACH,eAAe;IACf,MAAM,WAAW,GAAG;QAClB,KAAK,EAAE,EAAE;KACV,CAAC;IAEF,MAAM,IAAI,GAAI,aAAa,EAAqB,IAAI,WAAW,CAAC;IAEhE,OAAO,CACL,KAAC,QAAQ,IAAC,QAAQ,EAAE,MAAM,YACxB,KAAC,YAAY,IAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,GAAI,GAC/B,CACZ,CAAC;AACJ,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,EAAE;IACxC,OAAO,CACL,mBACE,KAAK,EAAE;YACL,OAAO,EAAE,MAAM;YACf,aAAa,EAAE,QAAQ;YACvB,cAAc,EAAE,QAAQ;YACxB,UAAU,EAAE,QAAQ;YACpB,MAAM,EAAE,OAAO;YACf,KAAK,EAAE,OAAO;SACf,aAED,aACE,KAAK,EAAE;oBACL,QAAQ,EAAE,MAAM;oBAChB,UAAU,EAAE,MAAM;oBAClB,YAAY,EAAE,EAAE;iBACjB,mCAGE,EAEL,YACE,KAAK,EAAE;oBACL,QAAQ,EAAE,QAAQ;oBAClB,YAAY,EAAE,EAAE;iBACjB,+EAGC,EAEJ,KAAC,IAAI,IACH,EAAE,EAAC,GAAG,EACN,KAAK,EAAE;oBACL,QAAQ,EAAE,QAAQ;oBAClB,UAAU,EAAE,GAAG;oBACf,YAAY,EAAE,EAAE;oBAChB,cAAc,EAAE,MAAM;iBACvB,qCAGI,IACC,CACX,CAAC;AACJ,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,EACzC,OAAO,GACyB,EAAE,EAAE;IACpC,OAAO,4BAAG,OAAO,CAAC,EAAE,CAAC,GAAI,CAAC;AAC5B,CAAC,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { defineRouteLayout, defineRoutePage, defineRouter, } from "./utils/index.js";
|
|
2
|
+
export { RouterComponent } from "./interfaces.js";
|
|
3
|
+
export { Outlet, Link, useLocation, useNavigate, useParams, useSearchParams, useFetcher, useMatch, useRoutes, useResolvedPath, matchRoutes, generatePath, matchPath, createRoutesFromChildren, Navigate, } from "react-router-dom";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { defineRouteLayout, defineRoutePage, defineRouter, } from "./utils/index.js";
|
|
2
|
+
export { RouterComponent } from "./interfaces.js";
|
|
3
|
+
export { Outlet, Link, useLocation, useNavigate, useParams, useSearchParams, useFetcher, useMatch, useRoutes, useResolvedPath, matchRoutes, generatePath, matchPath, createRoutesFromChildren, Navigate, } from "react-router-dom";
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/routing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,YAAY,GACb,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EACL,MAAM,EACN,IAAI,EACJ,WAAW,EACX,WAAW,EACX,SAAS,EACT,eAAe,EACf,UAAU,EACV,QAAQ,EACR,SAAS,EACT,eAAe,EACf,WAAW,EACX,YAAY,EACZ,SAAS,EACT,wBAAwB,EACxB,QAAQ,GACT,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { LayoutComponent, PageComponent } from "../core/interfaces.js";
|
|
3
|
+
/**
|
|
4
|
+
* Router component that define a routing system
|
|
5
|
+
*/
|
|
6
|
+
export declare class RouterComponent {
|
|
7
|
+
/**
|
|
8
|
+
* Defines the layout applied to the Router
|
|
9
|
+
*/
|
|
10
|
+
private _layout;
|
|
11
|
+
/**
|
|
12
|
+
* Defines the list of sub routers
|
|
13
|
+
*/
|
|
14
|
+
private _routers;
|
|
15
|
+
/**
|
|
16
|
+
* Defines the list of pages
|
|
17
|
+
*/
|
|
18
|
+
private _pages;
|
|
19
|
+
/**
|
|
20
|
+
* Defines the loader component to display when pages aren't available
|
|
21
|
+
*/
|
|
22
|
+
private _loaderComponent;
|
|
23
|
+
/**
|
|
24
|
+
* Defines the not found component to display when pages aren't available
|
|
25
|
+
*/
|
|
26
|
+
private _notFoundComponent;
|
|
27
|
+
/**
|
|
28
|
+
* Get the layout value
|
|
29
|
+
*/
|
|
30
|
+
get layout(): LayoutComponent;
|
|
31
|
+
/**
|
|
32
|
+
* Get the list of routers
|
|
33
|
+
*/
|
|
34
|
+
get routers(): Array<RouterComponent>;
|
|
35
|
+
/**
|
|
36
|
+
* Get the list of pages
|
|
37
|
+
*/
|
|
38
|
+
get pages(): Array<PageComponent>;
|
|
39
|
+
/**
|
|
40
|
+
* Get the loader component
|
|
41
|
+
*/
|
|
42
|
+
get loaderComponent(): React.FC;
|
|
43
|
+
/**
|
|
44
|
+
* Get the not found component
|
|
45
|
+
*/
|
|
46
|
+
get notFoundComponent(): React.FC;
|
|
47
|
+
/**
|
|
48
|
+
* Set the layout value
|
|
49
|
+
*/
|
|
50
|
+
set layout(layout: LayoutComponent);
|
|
51
|
+
/**
|
|
52
|
+
* Set the list of routers
|
|
53
|
+
*/
|
|
54
|
+
set routers(routers: Array<RouterComponent>);
|
|
55
|
+
/**
|
|
56
|
+
* Set the list of pages
|
|
57
|
+
*/
|
|
58
|
+
set pages(pages: Array<PageComponent>);
|
|
59
|
+
/**
|
|
60
|
+
* Set the loader component
|
|
61
|
+
*/
|
|
62
|
+
set loaderComponent(loaderComponent: React.FC);
|
|
63
|
+
/**
|
|
64
|
+
* Set the not found component
|
|
65
|
+
*/
|
|
66
|
+
set notFoundComponent(notFoundComponent: React.FC);
|
|
67
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Router component that define a routing system
|
|
3
|
+
*/
|
|
4
|
+
export class RouterComponent {
|
|
5
|
+
/**
|
|
6
|
+
* Defines the layout applied to the Router
|
|
7
|
+
*/
|
|
8
|
+
_layout;
|
|
9
|
+
/**
|
|
10
|
+
* Defines the list of sub routers
|
|
11
|
+
*/
|
|
12
|
+
_routers;
|
|
13
|
+
/**
|
|
14
|
+
* Defines the list of pages
|
|
15
|
+
*/
|
|
16
|
+
_pages;
|
|
17
|
+
/**
|
|
18
|
+
* Defines the loader component to display when pages aren't available
|
|
19
|
+
*/
|
|
20
|
+
_loaderComponent;
|
|
21
|
+
/**
|
|
22
|
+
* Defines the not found component to display when pages aren't available
|
|
23
|
+
*/
|
|
24
|
+
_notFoundComponent;
|
|
25
|
+
// Getters
|
|
26
|
+
/**
|
|
27
|
+
* Get the layout value
|
|
28
|
+
*/
|
|
29
|
+
get layout() {
|
|
30
|
+
return this._layout;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Get the list of routers
|
|
34
|
+
*/
|
|
35
|
+
get routers() {
|
|
36
|
+
return this._routers;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Get the list of pages
|
|
40
|
+
*/
|
|
41
|
+
get pages() {
|
|
42
|
+
return this._pages;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Get the loader component
|
|
46
|
+
*/
|
|
47
|
+
get loaderComponent() {
|
|
48
|
+
return this._loaderComponent;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Get the not found component
|
|
52
|
+
*/
|
|
53
|
+
get notFoundComponent() {
|
|
54
|
+
return this._notFoundComponent;
|
|
55
|
+
}
|
|
56
|
+
// Setters
|
|
57
|
+
/**
|
|
58
|
+
* Set the layout value
|
|
59
|
+
*/
|
|
60
|
+
set layout(layout) {
|
|
61
|
+
this._layout = layout;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Set the list of routers
|
|
65
|
+
*/
|
|
66
|
+
set routers(routers) {
|
|
67
|
+
this._routers = routers;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Set the list of pages
|
|
71
|
+
*/
|
|
72
|
+
set pages(pages) {
|
|
73
|
+
this._pages = pages;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Set the loader component
|
|
77
|
+
*/
|
|
78
|
+
set loaderComponent(loaderComponent) {
|
|
79
|
+
this._loaderComponent = loaderComponent;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Set the not found component
|
|
83
|
+
*/
|
|
84
|
+
set notFoundComponent(notFoundComponent) {
|
|
85
|
+
this._notFoundComponent = notFoundComponent;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=interfaces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/routing/interfaces.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,OAAO,eAAe;IAC1B;;OAEG;IACK,OAAO,CAAmB;IAElC;;OAEG;IACK,QAAQ,CAA0B;IAE1C;;OAEG;IACK,MAAM,CAAwB;IAEtC;;OAEG;IACK,gBAAgB,CAAY;IAEpC;;OAEG;IACK,kBAAkB,CAAY;IAEtC,UAAU;IAEV;;OAEG;IACH,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;OAEG;IACH,IAAI,eAAe;QACjB,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,IAAI,iBAAiB;QACnB,OAAO,IAAI,CAAC,kBAAkB,CAAC;IACjC,CAAC;IAED,UAAU;IAEV;;OAEG;IACH,IAAI,MAAM,CAAC,MAAuB;QAChC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,IAAI,OAAO,CAAC,OAA+B;QACzC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,IAAI,KAAK,CAAC,KAA2B;QACnC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,IAAI,eAAe,CAAC,eAAyB;QAC3C,IAAI,CAAC,gBAAgB,GAAG,eAAe,CAAC;IAC1C,CAAC;IAED;;OAEG;IACH,IAAI,iBAAiB,CAAC,iBAA2B;QAC/C,IAAI,CAAC,kBAAkB,GAAG,iBAAiB,CAAC;IAC9C,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/routing/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { RouterComponent } from "../interfaces.js";
|
|
2
|
+
import { RouteDecoratorProps, RouteLayoutDecoratorProps, RouterDecoratorProps } from "../../decorators/types.js";
|
|
3
|
+
import { LayoutComponent, PageComponent } from "../../index.js";
|
|
4
|
+
/**
|
|
5
|
+
* This function receives a router component and get a formated router first
|
|
6
|
+
* and then return a router.
|
|
7
|
+
*/
|
|
8
|
+
export declare const getRouter: (router: RouterComponent) => () => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
/**
|
|
10
|
+
* This function receives a router component and return a formated router for static routing
|
|
11
|
+
* @param router Represents the router component
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
export declare const generateStaticRoutes: (router: RouterComponent, isRoot?: boolean) => any;
|
|
15
|
+
/**
|
|
16
|
+
* This function receives a router component and extract all metadatas of all pages
|
|
17
|
+
* and put all of them inside a map function in order to be used to enhance ssr
|
|
18
|
+
*/
|
|
19
|
+
export declare const extractPageMetadata: (router: RouterComponent) => Map<string, {
|
|
20
|
+
title: string;
|
|
21
|
+
description: string;
|
|
22
|
+
}>;
|
|
23
|
+
/**
|
|
24
|
+
* This function adds metadata to a page or a layout
|
|
25
|
+
* @param option
|
|
26
|
+
* @returns
|
|
27
|
+
*/
|
|
28
|
+
export declare const defineRoutePage: (option: RouteDecoratorProps) => (Component: new () => PageComponent) => PageComponent;
|
|
29
|
+
/**
|
|
30
|
+
* This function adds metadata to a page or a layout
|
|
31
|
+
* @param option
|
|
32
|
+
* @returns
|
|
33
|
+
*/
|
|
34
|
+
export declare const defineRouteLayout: (option: RouteLayoutDecoratorProps) => (Component: new () => LayoutComponent) => LayoutComponent;
|
|
35
|
+
/**
|
|
36
|
+
* This function adds metadata to a router
|
|
37
|
+
* @param option
|
|
38
|
+
* @returns
|
|
39
|
+
*/
|
|
40
|
+
export declare const defineRouter: (option: RouterDecoratorProps) => (Component: new () => RouterComponent) => RouterComponent;
|