rasengan 1.0.0-beta.6 → 1.0.0-beta.60
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/CHANGELOG.md +19 -0
- package/README.md +36 -0
- package/bin.js +13 -0
- package/lib/esm/cli/index.js +40 -0
- package/lib/esm/client.js +2 -0
- package/lib/esm/core/config/index.js +3 -0
- package/lib/esm/core/config/type.js +6 -0
- package/lib/esm/core/config/utils/define-config.js +80 -0
- package/lib/esm/core/config/utils/load-modules.js +78 -0
- package/lib/esm/core/config/utils/path.js +16 -0
- package/lib/esm/core/config/vite/defaults.js +93 -0
- package/lib/esm/core/dynamic/index.js +21 -0
- package/lib/esm/core/index.js +2 -0
- package/lib/esm/core/middlewares/index.js +1 -0
- package/lib/esm/core/middlewares/logger.js +6 -0
- package/lib/esm/core/plugins/index.js +167 -0
- package/lib/esm/core/utils/log.js +9 -0
- package/lib/esm/entries/client/render.js +28 -0
- package/lib/esm/entries/server/entry.server.js +30 -0
- package/lib/esm/entries/server/index.js +31 -0
- package/lib/esm/index.js +5 -0
- package/lib/esm/plugin.js +2 -0
- package/lib/esm/routing/components/index.js +104 -0
- package/lib/esm/routing/components/template.js +64 -0
- package/lib/esm/routing/index.js +5 -0
- package/lib/{routing → esm/routing}/interfaces.js +19 -2
- package/lib/esm/routing/utils/define-router.js +78 -0
- package/lib/esm/routing/utils/define-routes-group.js +44 -0
- package/lib/esm/routing/utils/generate-metadata.js +83 -0
- package/lib/esm/routing/utils/generate-routes.js +301 -0
- package/lib/esm/routing/utils/index.js +4 -0
- package/lib/esm/scripts/build-command.js +17 -0
- package/lib/esm/scripts/generate-package-json.js +23 -0
- package/lib/esm/scripts/utils/check-os.js +7 -0
- package/lib/esm/scripts/utils/copy.js +16 -0
- package/lib/esm/server/build/index.js +11 -0
- package/lib/esm/server/build/manifest.js +91 -0
- package/lib/esm/server/build/rendering.js +18 -0
- package/lib/esm/server/dev/handlers.js +125 -0
- package/lib/esm/server/dev/server.js +174 -0
- package/lib/esm/server/dev/utils.js +192 -0
- package/lib/esm/server/node/index.js +69 -0
- package/lib/esm/server/node/rendering.js +44 -0
- package/lib/esm/server/node/stream.js +129 -0
- package/lib/esm/server/node/utils.js +91 -0
- package/lib/esm/server/runtime/mode.js +14 -0
- package/lib/esm/server/runtime/utils.js +5 -0
- package/lib/esm/server/virtual/index.js +8 -0
- package/lib/esm/server.js +4 -0
- package/lib/tsconfig.esm.tsbuildinfo +1 -0
- package/lib/tsconfig.types.tsbuildinfo +1 -0
- package/lib/types/client.d.ts +2 -0
- package/lib/types/core/config/index.d.ts +3 -0
- package/lib/types/core/config/type.d.ts +66 -0
- package/lib/types/core/config/utils/define-config.d.ts +7 -0
- package/lib/types/core/config/utils/load-modules.d.ts +19 -0
- package/lib/types/core/config/utils/path.d.ts +7 -0
- package/lib/types/core/config/vite/defaults.d.ts +3 -0
- package/lib/types/core/dynamic/index.d.ts +13 -0
- package/lib/types/core/index.d.ts +1 -0
- package/lib/types/core/middlewares/index.d.ts +1 -0
- package/lib/types/core/middlewares/logger.d.ts +2 -0
- package/lib/types/core/plugins/index.d.ts +18 -0
- package/lib/types/core/types.d.ts +15 -0
- package/lib/types/core/utils/log.d.ts +2 -0
- package/lib/types/entries/client/render.d.ts +5 -0
- package/lib/types/entries/server/entry.server.d.ts +20 -0
- package/lib/types/entries/server/index.d.ts +14 -0
- package/lib/types/index.d.ts +6 -0
- package/lib/types/plugin.d.ts +3 -0
- package/lib/types/routing/components/index.d.ts +22 -0
- package/lib/types/routing/components/template.d.ts +41 -0
- package/lib/types/routing/index.d.ts +6 -0
- package/lib/{routing → types/routing}/interfaces.d.ts +18 -6
- package/lib/types/routing/types.d.ts +213 -0
- package/lib/types/routing/utils/define-router.d.ts +8 -0
- package/lib/types/routing/utils/define-routes-group.d.ts +7 -0
- package/lib/types/routing/utils/generate-metadata.d.ts +7 -0
- package/lib/types/routing/utils/generate-routes.d.ts +13 -0
- package/lib/types/routing/utils/index.d.ts +4 -0
- package/lib/types/scripts/utils/check-os.d.ts +1 -0
- package/lib/types/scripts/utils/copy.d.ts +1 -0
- package/lib/types/server/build/index.d.ts +13 -0
- package/lib/types/server/build/manifest.d.ts +27 -0
- package/lib/types/server/build/rendering.d.ts +7 -0
- package/lib/types/server/dev/handlers.d.ts +27 -0
- package/lib/types/server/dev/server.d.ts +1 -0
- package/lib/types/server/dev/utils.d.ts +39 -0
- package/lib/types/server/node/index.d.ts +9 -0
- package/lib/types/server/node/rendering.d.ts +9 -0
- package/lib/types/server/node/stream.d.ts +7 -0
- package/lib/types/server/node/utils.d.ts +18 -0
- package/lib/types/server/runtime/mode.d.ts +9 -0
- package/lib/types/server/runtime/utils.d.ts +4 -0
- package/lib/types/server/virtual/index.d.ts +5 -0
- package/lib/types/server.d.ts +4 -0
- package/package.json +97 -47
- package/{tsconfig.json → tsconfig.base.json} +6 -16
- package/tsconfig.esm.json +8 -0
- package/tsconfig.types.json +10 -0
- package/types/client.d.ts +71 -0
- package/vite.config.ts +28 -65
- package/lib/cli/dirname.d.ts +0 -2
- package/lib/cli/dirname.js +0 -5
- package/lib/cli/index.d.ts +0 -2
- package/lib/cli/index.js +0 -99
- package/lib/config/index.d.ts +0 -58
- package/lib/config/index.js +0 -106
- package/lib/config/type.d.ts +0 -85
- package/lib/core/components/index.d.ts +0 -22
- package/lib/core/components/index.js +0 -67
- package/lib/core/index.d.ts +0 -2
- package/lib/core/index.js +0 -1
- package/lib/core/interfaces.d.ts +0 -93
- package/lib/core/interfaces.js +0 -114
- package/lib/core/types.d.ts +0 -45
- package/lib/decorators/index.d.ts +0 -2
- package/lib/decorators/index.js +0 -2
- package/lib/decorators/route.d.ts +0 -8
- package/lib/decorators/route.js +0 -20
- package/lib/decorators/router.d.ts +0 -8
- package/lib/decorators/router.js +0 -34
- package/lib/decorators/types.d.ts +0 -52
- package/lib/entries/entry-client.js +0 -14
- package/lib/entries/entry-server.d.ts +0 -6
- package/lib/entries/entry-server.js +0 -21
- package/lib/hooks/index.d.ts +0 -0
- package/lib/hooks/index.js +0 -0
- package/lib/index.d.ts +0 -6
- package/lib/index.js +0 -9
- package/lib/routing/components/index.d.ts +0 -38
- package/lib/routing/components/index.js +0 -81
- package/lib/routing/index.d.ts +0 -5
- package/lib/routing/index.js +0 -5
- package/lib/routing/types.d.ts +0 -9
- package/lib/routing/utils/index.d.ts +0 -38
- package/lib/routing/utils/index.js +0 -252
- package/lib/server/functions/vercel/_rasengan/server/index.d.ts +0 -2
- package/lib/server/functions/vercel/_rasengan/server/index.js +0 -91
- package/lib/server/functions/vercel/api/index.d.ts +0 -2
- package/lib/server/functions/vercel/api/index.js +0 -91
- package/lib/server/functions/vercel/vercel.json +0 -16
- package/lib/server/utils/createFetchRequest.d.ts +0 -5
- package/lib/server/utils/createFetchRequest.js +0 -33
- package/lib/server/utils/getIp.d.ts +0 -1
- package/lib/server/utils/getIp.js +0 -29
- package/lib/server/utils/handleError.d.ts +0 -2
- package/lib/server/utils/handleError.js +0 -27
- package/lib/server/utils/index.d.ts +0 -5
- package/lib/server/utils/index.js +0 -7
- package/lib/server/utils/log.d.ts +0 -7
- package/lib/server/utils/log.js +0 -74
- package/server.js +0 -238
- package/tsconfig.lib.json +0 -41
- package/tsconfig.node.json +0 -11
- package/types/image.d.ts +0 -44
- package/types/style.d.ts +0 -4
- /package/lib/{core → esm/core}/types.js +0 -0
- /package/lib/{decorators → esm/routing}/types.js +0 -0
- /package/lib/{config/type.js → types/cli/index.d.ts} +0 -0
- /package/lib/{entries/entry-client.d.ts → types/scripts/build-command.d.ts} +0 -0
- /package/lib/{routing/types.js → types/scripts/generate-package-json.d.ts} +0 -0
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { FunctionComponent } from 'react';
|
|
2
|
+
import { RouteObject as RRRouteObject } from 'react-router';
|
|
3
|
+
import { RouterComponent } from './interfaces.js';
|
|
4
|
+
export type MetadataLink = {
|
|
5
|
+
rel: string;
|
|
6
|
+
type?: string;
|
|
7
|
+
sizes?: string;
|
|
8
|
+
href: string;
|
|
9
|
+
};
|
|
10
|
+
export type MetaTag = {
|
|
11
|
+
name?: string;
|
|
12
|
+
property?: string;
|
|
13
|
+
content: string;
|
|
14
|
+
};
|
|
15
|
+
export type MetadataWithoutTitleAndDescription = {
|
|
16
|
+
/**
|
|
17
|
+
* Configuring link preview on social media like facebook, linkedin, etc.
|
|
18
|
+
*/
|
|
19
|
+
openGraph?: {
|
|
20
|
+
type?: string;
|
|
21
|
+
title?: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
url: string;
|
|
24
|
+
image: string;
|
|
25
|
+
width?: string;
|
|
26
|
+
height?: string;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Configuring link preview on twitter
|
|
30
|
+
*/
|
|
31
|
+
twitter?: {
|
|
32
|
+
card: 'summary_large_image' | 'summary';
|
|
33
|
+
image: string;
|
|
34
|
+
title: string;
|
|
35
|
+
description?: string;
|
|
36
|
+
creator?: string;
|
|
37
|
+
site?: string;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Configuring link tags to define icons and others
|
|
41
|
+
*/
|
|
42
|
+
links?: Array<MetadataLink>;
|
|
43
|
+
/**
|
|
44
|
+
* Other metadata tags
|
|
45
|
+
*/
|
|
46
|
+
metaTags?: Array<MetaTag>;
|
|
47
|
+
};
|
|
48
|
+
export type Metadata = MetadataWithoutTitleAndDescription & {
|
|
49
|
+
/**
|
|
50
|
+
* Title of the pate
|
|
51
|
+
*/
|
|
52
|
+
title?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Description of the page
|
|
55
|
+
*/
|
|
56
|
+
description?: string;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Props for Router Decorators
|
|
60
|
+
*/
|
|
61
|
+
export type RouterProps = {
|
|
62
|
+
/**
|
|
63
|
+
* Usefull to collect sub routers
|
|
64
|
+
*/
|
|
65
|
+
imports?: Array<Promise<RouterComponent>>;
|
|
66
|
+
/**
|
|
67
|
+
* Usefull to define a layout
|
|
68
|
+
*/
|
|
69
|
+
layout?: LayoutComponent;
|
|
70
|
+
/**
|
|
71
|
+
* Usefull to collect pages
|
|
72
|
+
*/
|
|
73
|
+
pages?: Array<PageComponent | MDXPageComponent | Array<PageComponent | MDXPageComponent>>;
|
|
74
|
+
/**
|
|
75
|
+
* Usefull to display a screen that let know to the user that the page is loading.
|
|
76
|
+
*/
|
|
77
|
+
loaderComponent?: FunctionComponent;
|
|
78
|
+
/**
|
|
79
|
+
* Usefull to display a screen that let know to the user that the page is not found.
|
|
80
|
+
*/
|
|
81
|
+
notFoundComponent?: FunctionComponent;
|
|
82
|
+
/**
|
|
83
|
+
* Determines whether the current page should use the parent layout, or render its own layout.
|
|
84
|
+
*/
|
|
85
|
+
useParentLayout?: boolean;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Options for the loader function that loads data for a page from the server
|
|
89
|
+
*/
|
|
90
|
+
export type LoaderOptions = {
|
|
91
|
+
params: {
|
|
92
|
+
[key: string]: any;
|
|
93
|
+
};
|
|
94
|
+
request: Request;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Data returned from the loader function
|
|
98
|
+
*/
|
|
99
|
+
export type LoaderResponse = {
|
|
100
|
+
props?: {
|
|
101
|
+
[key: string]: any;
|
|
102
|
+
};
|
|
103
|
+
redirect?: string;
|
|
104
|
+
meta?: Metadata | MetadataWithoutTitleAndDescription;
|
|
105
|
+
};
|
|
106
|
+
export type RouteLoaderFunction = (options: LoaderOptions) => Promise<LoaderResponse>;
|
|
107
|
+
export type LoaderFunction = ({ params, request, }: {
|
|
108
|
+
params: Record<string, string>;
|
|
109
|
+
request: Request;
|
|
110
|
+
}) => Promise<LoaderResponse | Response>;
|
|
111
|
+
export type RouteObject = RRRouteObject & {
|
|
112
|
+
loader?: LoaderFunction;
|
|
113
|
+
/**
|
|
114
|
+
* Routes children
|
|
115
|
+
*/
|
|
116
|
+
children?: Array<RouteObject>;
|
|
117
|
+
/**
|
|
118
|
+
* Determines if the route is nested
|
|
119
|
+
*/
|
|
120
|
+
nested?: boolean;
|
|
121
|
+
};
|
|
122
|
+
export type RoutesGroupProps = {
|
|
123
|
+
/**
|
|
124
|
+
* Path of the group
|
|
125
|
+
*/
|
|
126
|
+
path: string;
|
|
127
|
+
/**
|
|
128
|
+
* Routes children
|
|
129
|
+
*/
|
|
130
|
+
children: Array<PageComponent | MDXPageComponent | Array<PageComponent | MDXPageComponent>>;
|
|
131
|
+
};
|
|
132
|
+
export type RasenganPageComponentProps = {
|
|
133
|
+
page: PageComponent;
|
|
134
|
+
data: LoaderResponse;
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* Props for react components
|
|
138
|
+
*/
|
|
139
|
+
export type ReactComponentProps = {
|
|
140
|
+
[key: string]: any;
|
|
141
|
+
params: {
|
|
142
|
+
[key: string]: any;
|
|
143
|
+
};
|
|
144
|
+
} | any;
|
|
145
|
+
/**
|
|
146
|
+
* Layout component that represents a layout
|
|
147
|
+
*/
|
|
148
|
+
export type LayoutComponent<T = ReactComponentProps> = FunctionComponent<T> & {
|
|
149
|
+
/**
|
|
150
|
+
* Base path for the page
|
|
151
|
+
*/
|
|
152
|
+
path: string;
|
|
153
|
+
/**
|
|
154
|
+
* Metadata for the page
|
|
155
|
+
*/
|
|
156
|
+
metadata?: MetadataWithoutTitleAndDescription;
|
|
157
|
+
/**
|
|
158
|
+
* Loader function that loads data for the page from the server
|
|
159
|
+
*/
|
|
160
|
+
loader?: RouteLoaderFunction;
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* Page component that extends LayoutComponent and represents a page
|
|
164
|
+
*/
|
|
165
|
+
export type PageComponent<T = ReactComponentProps> = LayoutComponent<T> & {
|
|
166
|
+
/**
|
|
167
|
+
* Metadata for the page omit title
|
|
168
|
+
*/
|
|
169
|
+
metadata?: Metadata;
|
|
170
|
+
};
|
|
171
|
+
/**
|
|
172
|
+
* A React functional component that represents an MDX page.
|
|
173
|
+
*
|
|
174
|
+
* The `MDXPageComponent` type extends the `React.FC<ReactComponentProps>` type,
|
|
175
|
+
* which means it is a React functional component that accepts the standard props for a React component.
|
|
176
|
+
*
|
|
177
|
+
* The `MDXPageComponent` type also has an optional `metadata` property of type `Metadata`,
|
|
178
|
+
* which can be used to store metadata about the page.
|
|
179
|
+
*/
|
|
180
|
+
export type MDXPageComponent = FunctionComponent & {
|
|
181
|
+
metadata?: {
|
|
182
|
+
path: string;
|
|
183
|
+
metadata: Metadata;
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
/**
|
|
187
|
+
* A React functional component that represents a simple block element.
|
|
188
|
+
*/
|
|
189
|
+
export type MDXRendererProps = {
|
|
190
|
+
children: MDXPageComponent;
|
|
191
|
+
className?: string;
|
|
192
|
+
};
|
|
193
|
+
/**
|
|
194
|
+
* Template props
|
|
195
|
+
*/
|
|
196
|
+
export type TemplateProps = {
|
|
197
|
+
Head: FunctionComponent<{
|
|
198
|
+
children: React.ReactNode;
|
|
199
|
+
}>;
|
|
200
|
+
Body: FunctionComponent<{
|
|
201
|
+
children: React.ReactNode;
|
|
202
|
+
}>;
|
|
203
|
+
Script: FunctionComponent<{
|
|
204
|
+
children?: React.ReactNode;
|
|
205
|
+
}>;
|
|
206
|
+
};
|
|
207
|
+
/**
|
|
208
|
+
* Props for the base Component that takes the app router
|
|
209
|
+
*/
|
|
210
|
+
export type RootComponentProps = {
|
|
211
|
+
router: Promise<RouterComponent>;
|
|
212
|
+
children: React.ReactNode;
|
|
213
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RouterProps } from '../types.js';
|
|
2
|
+
import { RouterComponent } from '../interfaces.js';
|
|
3
|
+
/**
|
|
4
|
+
* This function adds metadata to a router
|
|
5
|
+
* @param option
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export declare const defineRouter: (option: RouterProps) => (Router: new () => RouterComponent) => Promise<RouterComponent>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RoutesGroupProps, PageComponent, MDXPageComponent } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Recursively loops through an array of `PageComponent`, `MDXPageComponent`, or `RoutesGroupProps` and extracts all the pages into a single array.
|
|
4
|
+
* @param option - An object containing the `path` and `children` properties, which are used to define a routes group.
|
|
5
|
+
* @returns An array of `PageComponent` or `MDXPageComponent` objects.
|
|
6
|
+
*/
|
|
7
|
+
export declare const defineRoutesGroup: (option: RoutesGroupProps) => (PageComponent | MDXPageComponent)[];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Metadata } from '../types.js';
|
|
2
|
+
import { JSX } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* This function generates metadata useful for pages to show images when sharing on social media
|
|
5
|
+
* @param {Metadata[]} metadatas
|
|
6
|
+
*/
|
|
7
|
+
export declare const generateMetadata: (metadatas: Metadata[]) => JSX.Element[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RouterComponent } from '../interfaces.js';
|
|
2
|
+
import { RouteObject, LayoutComponent } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* This function receives a router component and get a formated router first
|
|
5
|
+
* and then return a router.
|
|
6
|
+
*/
|
|
7
|
+
export declare const getRouter: (routerInstance: RouterComponent) => () => import("react/jsx-runtime.js").JSX.Element;
|
|
8
|
+
/**
|
|
9
|
+
* This function receives a router component and return a formated router for static routing
|
|
10
|
+
* @param router Represents the router component
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
export declare const generateRoutes: (router: RouterComponent, isRoot?: boolean, parentLayout?: LayoutComponent | undefined) => RouteObject[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function checkOsPlateform(osname: "aix" | "darwin" | "freebsd" | "linux" | "openbsd" | "sunos" | "win32"): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function generateCopyExecaArray(from: string, to: string): Array<string>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface BuildOptions {
|
|
2
|
+
buildDirectory: string;
|
|
3
|
+
manifestPathDirectory: string;
|
|
4
|
+
assetPathDirectory: string;
|
|
5
|
+
clientPathDirectory: string;
|
|
6
|
+
serverPathDirectory: string;
|
|
7
|
+
entryServerPath: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const resolveBuildOptions: ({ buildDirectory, clientPathDirectory, serverPathDirectory, }: {
|
|
10
|
+
buildDirectory?: string;
|
|
11
|
+
clientPathDirectory?: string;
|
|
12
|
+
serverPathDirectory?: string;
|
|
13
|
+
}) => BuildOptions;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
interface ResolvedAssets {
|
|
2
|
+
scripts: string[];
|
|
3
|
+
styles: string[];
|
|
4
|
+
}
|
|
5
|
+
export declare class ManifestManager {
|
|
6
|
+
private _manifestPath;
|
|
7
|
+
private _manifest;
|
|
8
|
+
private _entry;
|
|
9
|
+
constructor(manifestPath: string);
|
|
10
|
+
/**
|
|
11
|
+
* Load the manifest file.
|
|
12
|
+
*/
|
|
13
|
+
private loadManifest;
|
|
14
|
+
/**
|
|
15
|
+
* Resolve all assets for a given page.
|
|
16
|
+
* @param pageName - The name of the page to resolve.
|
|
17
|
+
* @returns Resolved assets with scripts and styles.
|
|
18
|
+
*/
|
|
19
|
+
resolveAssets(pageName: string): ResolvedAssets;
|
|
20
|
+
/**
|
|
21
|
+
* Generate meta tags for a given page.
|
|
22
|
+
* @param pageName - The name of the page to generate meta tags for.
|
|
23
|
+
* @returns HTML string containing script and style tags.
|
|
24
|
+
*/
|
|
25
|
+
generateMetaTags(pageName: string): import("react/jsx-runtime").JSX.Element[];
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FunctionComponent } from "react";
|
|
2
|
+
import { AppConfig } from "../../core/config/type.js";
|
|
3
|
+
import { TemplateProps } from "../../routing/types.js";
|
|
4
|
+
export declare const renderIndexHTML: (template: FunctionComponent<TemplateProps>, options: {
|
|
5
|
+
rootPath: string;
|
|
6
|
+
config: AppConfig;
|
|
7
|
+
}) => Promise<void>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { StaticHandler, StaticHandlerContext } from 'react-router';
|
|
2
|
+
import { AppConfig, Redirect } from '../../core/config/type.js';
|
|
3
|
+
import type * as Express from 'express';
|
|
4
|
+
import { ModuleRunner } from 'vite/module-runner';
|
|
5
|
+
/**
|
|
6
|
+
* Handle redirect request
|
|
7
|
+
* @param req
|
|
8
|
+
* @param res
|
|
9
|
+
* @param options
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
export declare function handleRedirectRequest(req: Express.Request, res: Express.Response, { context, redirects, }: {
|
|
13
|
+
context: StaticHandlerContext | Response;
|
|
14
|
+
redirects: Redirect[];
|
|
15
|
+
}): Promise<void>;
|
|
16
|
+
export declare function handleDocumentRequest(req: Express.Request, res: Express.Response, runner: ModuleRunner, options: {
|
|
17
|
+
rootPath: string;
|
|
18
|
+
__dirname: string;
|
|
19
|
+
config: AppConfig;
|
|
20
|
+
handler: StaticHandler;
|
|
21
|
+
}): Promise<any>;
|
|
22
|
+
export declare function handleDataRequest(request: Express.Request, handler: StaticHandler): Promise<Response>;
|
|
23
|
+
export declare function handleSpaModeRequest(res: Express.Response, runner: ModuleRunner, options: {
|
|
24
|
+
rootPath: string;
|
|
25
|
+
__dirname: string;
|
|
26
|
+
config: AppConfig;
|
|
27
|
+
}): Promise<Express.Response<any, Record<string, any>>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ServerMode } from '../runtime/mode.js';
|
|
2
|
+
import { StaticHandlerContext } from 'react-router';
|
|
3
|
+
import { Metadata } from '../../routing/types.js';
|
|
4
|
+
import type * as Express from 'express';
|
|
5
|
+
import { Redirect } from '../../core/config/type.js';
|
|
6
|
+
export default function getIPAddress(): string;
|
|
7
|
+
/**
|
|
8
|
+
* Log server info after the server is started
|
|
9
|
+
* @param {number} port The port the server is running on
|
|
10
|
+
* @param {boolean} isProduction Whether the server is running in production mode
|
|
11
|
+
* @param {boolean} open Whether to open the browser automatically
|
|
12
|
+
*/
|
|
13
|
+
export declare function logServerInfo(port: number, mode: ServerMode, open?: boolean): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* This function extracts the meta data from the React Router context
|
|
16
|
+
* @param context React Router context
|
|
17
|
+
*/
|
|
18
|
+
export declare function extractMetaFromRRContext(context: StaticHandlerContext): {
|
|
19
|
+
page: Metadata;
|
|
20
|
+
layout: Metadata;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* This function extracts the headers from the React Router context
|
|
24
|
+
* @param context React Router context
|
|
25
|
+
*/
|
|
26
|
+
export declare function extractHeadersFromRRContext(context: StaticHandlerContext): Headers;
|
|
27
|
+
/**
|
|
28
|
+
* Check if the request is a document request
|
|
29
|
+
* @param request Express request object
|
|
30
|
+
*/
|
|
31
|
+
export declare function isDocumentRequest(request: Express.Request): boolean;
|
|
32
|
+
export declare function isDataRequest(request: Express.Request): boolean;
|
|
33
|
+
export declare function isResourceRequest(request: Express.Request): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Check if the request is an Redirect request
|
|
36
|
+
* @param context Response context
|
|
37
|
+
*/
|
|
38
|
+
export declare function isRedirectResponse(context: Response): boolean;
|
|
39
|
+
export declare function isStaticRedirectFromConfig(req: Express.Request, redirects: Redirect[]): Promise<boolean>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type * as Express from 'express';
|
|
2
|
+
import { BuildOptions } from '../build/index.js';
|
|
3
|
+
interface CreateRequestHandlerOptions {
|
|
4
|
+
build: BuildOptions;
|
|
5
|
+
}
|
|
6
|
+
export declare function createRequestHandler(options: CreateRequestHandlerOptions): (req: Express.Request, res: Express.Response) => Promise<void | Response>;
|
|
7
|
+
export declare function handleDocumentRequest(): void;
|
|
8
|
+
export declare function handleDataRequest(): void;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type * as Express from 'express';
|
|
2
|
+
/**
|
|
3
|
+
* Render a React component to a stream.
|
|
4
|
+
* @param Component
|
|
5
|
+
* @param res
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export declare const renderToStream: (Component: React.ReactNode, res: Express.Response) => Promise<unknown>;
|
|
9
|
+
export declare const renderToString: (Component: React.ReactNode) => string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Readable, Writable } from 'node:stream';
|
|
2
|
+
export declare function writeReadableStreamToWritable(stream: ReadableStream, writable: Writable): Promise<void>;
|
|
3
|
+
export declare function writeAsyncIterableToWritable(iterable: AsyncIterable<Uint8Array>, writable: Writable): Promise<void>;
|
|
4
|
+
export declare function readableStreamToString(stream: ReadableStream<Uint8Array>, encoding?: BufferEncoding): Promise<string>;
|
|
5
|
+
export declare const createReadableStreamFromReadable: (source: Readable & {
|
|
6
|
+
readableHighWaterMark?: number;
|
|
7
|
+
}) => ReadableStream<ArrayBufferView<ArrayBufferLike>>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type * as Express from 'express';
|
|
2
|
+
/**
|
|
3
|
+
* This function is used to create a Rasengan request from an Express request.
|
|
4
|
+
* Reference: https://github.com/remix-run/react-router/blob/main/packages/react-router-express/server.ts#L86
|
|
5
|
+
*/
|
|
6
|
+
export default function createRasenganRequest(req: Express.Request, res: Express.Response): Request;
|
|
7
|
+
/**
|
|
8
|
+
* This function is used to send a Rasengan response to an Express response.
|
|
9
|
+
* @param res
|
|
10
|
+
* @param nodeResponse
|
|
11
|
+
*/
|
|
12
|
+
export declare function sendRasenganResponse(res: Express.Response, nodeResponse: Response): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* This function is used to create a Rasengan headers from Express request headers.
|
|
15
|
+
* @param requestHeaders
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
export declare function createRasenganHeaders(requestHeaders: Record<string, string | string[]>): Headers;
|
package/package.json
CHANGED
|
@@ -1,30 +1,50 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rasengan",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.0.0-beta.
|
|
4
|
+
"version": "1.0.0-beta.60",
|
|
5
|
+
"description": "The modern React Framework",
|
|
5
6
|
"type": "module",
|
|
6
|
-
"main": "lib/index.js",
|
|
7
|
+
"main": "lib/esm/index.js",
|
|
7
8
|
"bin": {
|
|
8
|
-
"rasengan": "
|
|
9
|
+
"rasengan": "bin.js"
|
|
9
10
|
},
|
|
10
11
|
"exports": {
|
|
11
12
|
".": {
|
|
13
|
+
"types": "./lib/types/index.d.ts",
|
|
12
14
|
"import": {
|
|
13
|
-
"types": "./lib/index.d.ts",
|
|
14
|
-
"default": "./lib/index.js"
|
|
15
|
+
"types": "./lib/types/index.d.ts",
|
|
16
|
+
"default": "./lib/esm/index.js"
|
|
15
17
|
},
|
|
16
18
|
"require": {
|
|
17
|
-
"types": "./lib/index.d.ts",
|
|
18
|
-
"default": "./lib/index.js"
|
|
19
|
-
}
|
|
19
|
+
"types": "./lib/types/index.d.ts",
|
|
20
|
+
"default": "./lib/esm/index.js"
|
|
21
|
+
},
|
|
22
|
+
"default": "./lib/esm/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./types/client": {
|
|
25
|
+
"types": "./types/client.d.ts"
|
|
20
26
|
},
|
|
21
|
-
"./
|
|
22
|
-
|
|
27
|
+
"./package.json": "./package.json",
|
|
28
|
+
"./dynamic": {
|
|
29
|
+
"types": "./lib/types/core/dynamic/index.d.ts",
|
|
30
|
+
"import": "./lib/esm/core/dynamic/index.js",
|
|
31
|
+
"require": "./lib/esm/core/dynamic/index.js"
|
|
23
32
|
},
|
|
24
|
-
"./
|
|
25
|
-
"types": "./types/
|
|
33
|
+
"./server": {
|
|
34
|
+
"types": "./lib/types/server.d.ts",
|
|
35
|
+
"import": "./lib/esm/server.js",
|
|
36
|
+
"require": "./lib/esm/server.js"
|
|
26
37
|
},
|
|
27
|
-
"./
|
|
38
|
+
"./client": {
|
|
39
|
+
"types": "./lib/types/client.d.ts",
|
|
40
|
+
"import": "./lib/esm/client.js",
|
|
41
|
+
"require": "./lib/esm/client.js"
|
|
42
|
+
},
|
|
43
|
+
"./plugin": {
|
|
44
|
+
"types": "./lib/types/plugin.d.ts",
|
|
45
|
+
"import": "./lib/esm/plugin.js",
|
|
46
|
+
"require": "./lib/esm/plugin.js"
|
|
47
|
+
}
|
|
28
48
|
},
|
|
29
49
|
"author": {
|
|
30
50
|
"name": "dilane3",
|
|
@@ -35,60 +55,90 @@
|
|
|
35
55
|
},
|
|
36
56
|
"repository": {
|
|
37
57
|
"type": "git",
|
|
38
|
-
"url": "https://github.com/rasengan/
|
|
39
|
-
"issues": "https://github.com/rasengan/
|
|
58
|
+
"url": "https://github.com/rasengan-dev/rasenganjs.git",
|
|
59
|
+
"issues": "https://github.com/rasengan-dev/rasenganjs/issues"
|
|
40
60
|
},
|
|
41
61
|
"homepage": "https://rasengan.dev",
|
|
42
|
-
"scripts": {
|
|
43
|
-
"dev": "node server",
|
|
44
|
-
"build": "npm run build:client && npm run build:server",
|
|
45
|
-
"build:client": "vite build --ssrManifest --outDir dist/client",
|
|
46
|
-
"build:server": "vite build --ssr node_modules/rasengan/lib/entries/entry-server.js --outDir dist/server",
|
|
47
|
-
"build:lib": "tsc -p tsconfig.lib.json",
|
|
48
|
-
"preview": "cross-env NODE_ENV=production node server",
|
|
49
|
-
"deploy": "npm publish --access public",
|
|
50
|
-
"deploy:beta": "npm run deploy --tag beta",
|
|
51
|
-
"pack": "npm pack --pack-destination ./../packages/rasengan/"
|
|
52
|
-
},
|
|
53
62
|
"dependencies": {
|
|
54
|
-
"@vercel/node": "^3.0.14",
|
|
55
63
|
"@vitejs/plugin-react": "^4.2.1",
|
|
56
64
|
"chalk": "^5.3.0",
|
|
57
65
|
"commander": "^11.1.0",
|
|
58
66
|
"compression": "^1.7.4",
|
|
59
|
-
"cross-spawn": "^7.0.3",
|
|
60
67
|
"execa": "^8.0.1",
|
|
61
68
|
"express": "^4.18.2",
|
|
62
69
|
"inquirer": "^9.2.12",
|
|
63
|
-
"keypress": "^0.2.1",
|
|
64
|
-
"node-fetch": "^3.3.2",
|
|
65
70
|
"open": "^10.1.0",
|
|
66
71
|
"ora": "^7.0.1",
|
|
67
|
-
"react-
|
|
68
|
-
"react-router-dom": "^6.20.1",
|
|
69
|
-
"sirv": "^2.0.3",
|
|
70
|
-
"vite": "^5.0.12"
|
|
72
|
+
"react-router": "^7.0.0"
|
|
71
73
|
},
|
|
72
74
|
"peerDependencies": {
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
+
"@types/node": "^18.0.0 || >=20.0.0",
|
|
76
|
+
"less": "*",
|
|
77
|
+
"react": "^19.0.0",
|
|
78
|
+
"react-dom": "^19.0.0",
|
|
79
|
+
"sass": "*",
|
|
80
|
+
"stylus": "*",
|
|
81
|
+
"vite": "^6.0.0",
|
|
82
|
+
"@rasenganjs/mdx": "^1.1.0-beta.1"
|
|
83
|
+
},
|
|
84
|
+
"peerDependenciesMeta": {
|
|
85
|
+
"@types/node": {
|
|
86
|
+
"optional": true
|
|
87
|
+
},
|
|
88
|
+
"sass": {
|
|
89
|
+
"optional": true
|
|
90
|
+
},
|
|
91
|
+
"stylus": {
|
|
92
|
+
"optional": true
|
|
93
|
+
},
|
|
94
|
+
"less": {
|
|
95
|
+
"optional": true
|
|
96
|
+
},
|
|
97
|
+
"@rasenganjs/mdx": {
|
|
98
|
+
"optional": true
|
|
99
|
+
}
|
|
75
100
|
},
|
|
76
101
|
"devDependencies": {
|
|
77
102
|
"@types/compression": "^1.7.4",
|
|
78
|
-
"@types/cross-spawn": "^6.0.4",
|
|
79
103
|
"@types/express": "^4.17.19",
|
|
80
104
|
"@types/node": "^20.8.6",
|
|
81
|
-
"@types/react": "^
|
|
82
|
-
"@types/react-dom": "^
|
|
83
|
-
"cross-env": "^7.0.3"
|
|
84
|
-
"typescript": "^5.2.2"
|
|
85
|
-
},
|
|
86
|
-
"resolutions": {
|
|
87
|
-
"@vitejs/plugin-react": "^4.2.1"
|
|
105
|
+
"@types/react": "^19.0.1",
|
|
106
|
+
"@types/react-dom": "^19.0.1",
|
|
107
|
+
"cross-env": "^7.0.3"
|
|
88
108
|
},
|
|
89
109
|
"license": "MIT",
|
|
90
110
|
"engines": {
|
|
91
|
-
"node": ">=
|
|
92
|
-
|
|
111
|
+
"node": ">=20.13.1"
|
|
112
|
+
},
|
|
113
|
+
"files": [
|
|
114
|
+
"lib/",
|
|
115
|
+
"types/",
|
|
116
|
+
"bin.js",
|
|
117
|
+
"CHANGELOG.md",
|
|
118
|
+
"LICENSE.md",
|
|
119
|
+
"README.md",
|
|
120
|
+
"tsconfig.esm.json",
|
|
121
|
+
"tsconfig.types.json",
|
|
122
|
+
"tsconfig.base.json",
|
|
123
|
+
"vite.config.ts"
|
|
124
|
+
],
|
|
125
|
+
"keywords": [
|
|
126
|
+
"rasengan",
|
|
127
|
+
"frontend",
|
|
128
|
+
"framework",
|
|
129
|
+
"react framework",
|
|
130
|
+
"react",
|
|
131
|
+
"vite",
|
|
132
|
+
"ssr",
|
|
133
|
+
"ssg",
|
|
134
|
+
"spa"
|
|
135
|
+
],
|
|
136
|
+
"scripts": {
|
|
137
|
+
"build:compile": "tsc -b ./tsconfig.esm.json ./tsconfig.types.json",
|
|
138
|
+
"build:clean": "rimraf ./lib",
|
|
139
|
+
"build": "pnpm run build:clean & pnpm run build:compile",
|
|
140
|
+
"deploy": "pnpm publish --access public",
|
|
141
|
+
"deploy:beta": "pnpm run deploy --tag beta",
|
|
142
|
+
"pack": "pnpm pack --pack-destination ./release/"
|
|
93
143
|
}
|
|
94
|
-
}
|
|
144
|
+
}
|