@gracile/engine 0.0.4-next.3 → 0.0.4-next.34
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/ambient.d.ts +6 -0
- package/dist/assertions.d.ts +1 -1
- package/dist/assertions.d.ts.map +1 -1
- package/dist/build/static.d.ts +11 -2
- package/dist/build/static.d.ts.map +1 -1
- package/dist/build/static.js +28 -15
- package/dist/dev/dev.d.ts +5 -2
- package/dist/dev/dev.d.ts.map +1 -1
- package/dist/dev/dev.js +14 -7
- package/dist/dev/server.d.ts +22 -2
- package/dist/dev/server.d.ts.map +1 -1
- package/dist/dev/server.js +49 -22
- package/dist/preview.d.ts +1 -1
- package/dist/preview.d.ts.map +1 -1
- package/dist/preview.js +3 -0
- package/dist/render/route-template.d.ts +14 -3
- package/dist/render/route-template.d.ts.map +1 -1
- package/dist/render/route-template.js +42 -14
- package/dist/render/utils.d.ts.map +1 -0
- package/dist/routes/collect.d.ts +2 -3
- package/dist/routes/collect.d.ts.map +1 -1
- package/dist/routes/collect.js +4 -1
- package/dist/routes/load-module.d.ts +5 -1
- package/dist/routes/load-module.d.ts.map +1 -1
- package/dist/routes/load-module.js +13 -4
- package/dist/routes/match.d.ts +4 -2
- package/dist/routes/match.d.ts.map +1 -1
- package/dist/routes/match.js +9 -6
- package/dist/routes/route.d.ts +7 -1
- package/dist/routes/route.d.ts.map +1 -1
- package/dist/routes/route.js +6 -1
- package/dist/server/env.d.ts +5 -0
- package/dist/server/env.d.ts.map +1 -0
- package/dist/server/env.js +6 -0
- package/dist/server/request.d.ts +12 -0
- package/dist/server/request.d.ts.map +1 -0
- package/dist/{dev → server}/request.js +32 -12
- package/dist/server/server.d.ts +4 -0
- package/dist/server/server.d.ts.map +1 -0
- package/dist/server/server.js +26 -0
- package/dist/server/utils.d.ts +3 -0
- package/dist/server/utils.d.ts.map +1 -0
- package/dist/server/utils.js +21 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/user-config.d.ts +11 -0
- package/dist/user-config.d.ts.map +1 -1
- package/dist/user-config.js +9 -0
- package/dist/vite/build.d.ts.map +1 -1
- package/dist/vite/build.js +82 -7
- package/dist/vite/config.d.ts +2 -0
- package/dist/vite/config.d.ts.map +1 -1
- package/dist/vite/config.js +11 -1
- package/dist/vite/plugins/build-routes.d.ts +28 -0
- package/dist/vite/plugins/build-routes.d.ts.map +1 -0
- package/dist/vite/plugins/build-routes.js +98 -0
- package/dist/vite/plugins/virtual-routes.d.ts +11 -0
- package/dist/vite/plugins/virtual-routes.d.ts.map +1 -0
- package/dist/vite/plugins/virtual-routes.js +42 -0
- package/dist/vite/server.d.ts +4 -1
- package/dist/vite/server.d.ts.map +1 -1
- package/dist/vite/server.js +5 -3
- package/package.json +11 -12
- package/dist/dev/request.d.ts +0 -4
- package/dist/dev/request.d.ts.map +0 -1
- package/dist/vite/plugins/html-static-pages.d.ts +0 -13
- package/dist/vite/plugins/html-static-pages.d.ts.map +0 -1
- package/dist/vite/plugins/html-static-pages.js +0 -58
- package/dist/vite/utils.d.ts.map +0 -1
- /package/dist/{vite → render}/utils.d.ts +0 -0
- /package/dist/{vite → render}/utils.js +0 -0
package/dist/routes/route.d.ts
CHANGED
|
@@ -6,14 +6,16 @@ export type Method = MethodHtml & MethodNonHtml;
|
|
|
6
6
|
export type ModuleOptions = {
|
|
7
7
|
staticPaths?: StaticPathsGeneric;
|
|
8
8
|
handler?: HandlerGeneric;
|
|
9
|
-
|
|
9
|
+
prerender?: boolean | undefined;
|
|
10
10
|
document?: DocumentTemplate<RouteContextGeneric>;
|
|
11
|
+
template?: (context: RouteContextGeneric) => RouteTemplateResult;
|
|
11
12
|
};
|
|
12
13
|
export declare class RouteModule {
|
|
13
14
|
#private;
|
|
14
15
|
get staticPaths(): StaticPathsGeneric | undefined;
|
|
15
16
|
get handler(): Handler<object | Response | undefined> | Partial<Record<MethodHtml, Handler<object | Response | undefined>> & Record<MethodNonHtml, Handler<Response>>> | undefined;
|
|
16
17
|
get document(): DocumentTemplate<RouteContextGeneric> | undefined;
|
|
18
|
+
get prerender(): boolean | undefined;
|
|
17
19
|
get template(): ((context: RouteContextGeneric) => RouteTemplateResult) | undefined;
|
|
18
20
|
constructor(options: ModuleOptions);
|
|
19
21
|
}
|
|
@@ -59,5 +61,9 @@ export interface Route {
|
|
|
59
61
|
pattern: URLPattern;
|
|
60
62
|
hasParams: boolean;
|
|
61
63
|
pageAssets: string[];
|
|
64
|
+
prerender: boolean | null;
|
|
62
65
|
}
|
|
66
|
+
export type RoutesManifest = Map<string, Route>;
|
|
67
|
+
export type RoutesImports = Map<string, () => Record<string, unknown>>;
|
|
68
|
+
export type RoutesAssets = Map<string, string>;
|
|
63
69
|
//# sourceMappingURL=route.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../src/routes/route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAK1C,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,CAAC;AACxC,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;AACjE,MAAM,MAAM,MAAM,GAAG,UAAU,GAAG,aAAa,CAAC;AAehD,MAAM,MAAM,aAAa,GAAG;IAC3B,WAAW,CAAC,EAAE,kBAAkB,CAAmB;IACnD,OAAO,CAAC,EAAE,cAAc,CAAC;IAEzB,
|
|
1
|
+
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../src/routes/route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAK1C,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,CAAC;AACxC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,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AACvE,MAAM,MAAM,YAAY,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC"}
|
package/dist/routes/route.js
CHANGED
|
@@ -12,6 +12,10 @@ export class RouteModule {
|
|
|
12
12
|
get document() {
|
|
13
13
|
return this.#document;
|
|
14
14
|
}
|
|
15
|
+
#prerender;
|
|
16
|
+
get prerender() {
|
|
17
|
+
return this.#prerender;
|
|
18
|
+
}
|
|
15
19
|
#template;
|
|
16
20
|
get template() {
|
|
17
21
|
return this.#template;
|
|
@@ -23,10 +27,11 @@ export class RouteModule {
|
|
|
23
27
|
typeof options.handler === 'function') &&
|
|
24
28
|
options.handler)
|
|
25
29
|
this.#handler = options.handler;
|
|
26
|
-
// if (options.fragment) this.#fragment = options.fragment;
|
|
27
30
|
if (typeof options.template === 'function')
|
|
28
31
|
this.#template = options.template;
|
|
29
32
|
if (typeof options.document === 'function')
|
|
30
33
|
this.#document = options.document;
|
|
34
|
+
if (typeof options.prerender === 'boolean')
|
|
35
|
+
this.#prerender = options.prerender;
|
|
31
36
|
}
|
|
32
37
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/server/env.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,cAAc,CAAC;AACxC,eAAO,MAAM,UAAU,YAAY,CAAC;AACpC,eAAO,MAAM,WAAW,IAAI,CAAC;AAE7B,eAAO,MAAM,UAAU,4BAEM,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { NextFunction, Request as ExpressRequest, Response as ExpressResponse } from 'express';
|
|
2
|
+
import type { ViteDevServer } from 'vite';
|
|
3
|
+
import type * as R from '../routes/route.js';
|
|
4
|
+
export declare function createRequestHandler({ vite, routes, routeImports, routeAssets, root, serverMode, }: {
|
|
5
|
+
vite?: ViteDevServer | undefined;
|
|
6
|
+
routes: R.RoutesManifest;
|
|
7
|
+
routeImports?: R.RoutesImports | undefined;
|
|
8
|
+
routeAssets?: R.RoutesAssets;
|
|
9
|
+
root: string;
|
|
10
|
+
serverMode?: boolean | undefined;
|
|
11
|
+
}): (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => Promise<void | ExpressResponse<any, Record<string, any>>>;
|
|
12
|
+
//# sourceMappingURL=request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/server/request.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACX,YAAY,EACZ,OAAO,IAAI,cAAc,EACzB,QAAQ,IAAI,eAAe,EAC3B,MAAM,SAAS,CAAC;AAEjB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAS1C,OAAO,KAAK,KAAK,CAAC,MAAM,oBAAoB,CAAC;AAM7C,wBAAgB,oBAAoB,CAAC,EACpC,IAAI,EACJ,MAAM,EACN,YAAY,EACZ,WAAW,EACX,IAAI,EACJ,UAAU,GACV,EAAE;IACF,IAAI,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IACjC,MAAM,EAAE,CAAC,CAAC,cAAc,CAAC;IACzB,YAAY,CAAC,EAAE,CAAC,CAAC,aAAa,GAAG,SAAS,CAAC;IAC3C,WAAW,CAAC,EAAE,CAAC,CAAC,YAAY,CAAC;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACjC,SAEM,cAAc,OACd,eAAe,QACd,YAAY,+DA4MnB"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { Writable } from 'node:stream';
|
|
1
|
+
import { Readable, Writable } from 'node:stream';
|
|
2
2
|
import { logger } from '@gracile/internal-utils/logger';
|
|
3
3
|
import { createServerAdapter } from '@whatwg-node/server';
|
|
4
4
|
import c from 'picocolors';
|
|
5
5
|
import { /* errorInline, */ errorPage } from '../errors/templates.js';
|
|
6
6
|
import { renderRouteTemplate, } from '../render/route-template.js';
|
|
7
|
+
import { renderSsrTemplate } from '../render/utils.js';
|
|
7
8
|
import { getRoute } from '../routes/match.js';
|
|
8
|
-
import { renderSsrTemplate } from '../vite/utils.js';
|
|
9
9
|
// NOTE: Find a more canonical way to ponyfill the Node HTTP request to standard Request
|
|
10
10
|
// @ts-expect-error Abusing this feature!
|
|
11
11
|
const adapter = createServerAdapter((request) => request);
|
|
12
|
-
export function
|
|
12
|
+
export function createRequestHandler({ vite, routes, routeImports, routeAssets, root, serverMode, }) {
|
|
13
13
|
return async (req, res, next) => {
|
|
14
14
|
const url = req.originalUrl;
|
|
15
15
|
logger.info(`[${c.yellow(req.method)}] ${c.yellow(url)}`, {
|
|
@@ -23,7 +23,16 @@ export function createDevRequestHandler(vite) {
|
|
|
23
23
|
return next();
|
|
24
24
|
const requestPonyfilled = (await Promise.resolve(adapter.handleNodeRequest(req)));
|
|
25
25
|
async function renderPageFn(handlerInfos, routeInfos) {
|
|
26
|
-
const { output } = await renderRouteTemplate(
|
|
26
|
+
const { output } = await renderRouteTemplate({
|
|
27
|
+
request: requestPonyfilled,
|
|
28
|
+
vite,
|
|
29
|
+
mode: 'dev',
|
|
30
|
+
routeInfos,
|
|
31
|
+
handlerInfos,
|
|
32
|
+
routeAssets,
|
|
33
|
+
root,
|
|
34
|
+
serverMode,
|
|
35
|
+
});
|
|
27
36
|
return output;
|
|
28
37
|
}
|
|
29
38
|
try {
|
|
@@ -31,6 +40,8 @@ export function createDevRequestHandler(vite) {
|
|
|
31
40
|
const moduleInfos = await getRoute({
|
|
32
41
|
url: requestPonyfilled.url,
|
|
33
42
|
vite,
|
|
43
|
+
routes,
|
|
44
|
+
routeImports,
|
|
34
45
|
});
|
|
35
46
|
let output;
|
|
36
47
|
// TODO: should move this to `special-file` so we don't recalculate on each request
|
|
@@ -124,11 +135,12 @@ export function createDevRequestHandler(vite) {
|
|
|
124
135
|
// Maybe just returning nothing is better to not break the page?
|
|
125
136
|
// Should send a overlay message anyway via WebSocket
|
|
126
137
|
// vite.ws.send()
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
138
|
+
if (vite)
|
|
139
|
+
setTimeout(() => {
|
|
140
|
+
vite.hot.send('gracile:ssr-error', {
|
|
141
|
+
message: errorMessage,
|
|
142
|
+
});
|
|
143
|
+
}, 500);
|
|
132
144
|
res.end('' /* errorInline(error) */);
|
|
133
145
|
})
|
|
134
146
|
.pipe(res);
|
|
@@ -137,14 +149,22 @@ export function createDevRequestHandler(vite) {
|
|
|
137
149
|
}
|
|
138
150
|
catch (e) {
|
|
139
151
|
const error = e;
|
|
140
|
-
vite
|
|
152
|
+
if (vite)
|
|
153
|
+
vite.ssrFixStacktrace(error);
|
|
154
|
+
else
|
|
155
|
+
logger.error(error.message);
|
|
141
156
|
if (error.cause === 404) {
|
|
157
|
+
// TODO: Handle 404 with dedicated page
|
|
158
|
+
if (!vite)
|
|
159
|
+
return next(e);
|
|
142
160
|
return res.status(404).end('404');
|
|
143
161
|
// TODO: use a nice framework service page
|
|
144
162
|
// .redirect(new URL('/__404/', requestPonyfilled.url).href)
|
|
145
163
|
}
|
|
146
|
-
|
|
147
|
-
|
|
164
|
+
let errorTemplate = await renderSsrTemplate(errorPage(error));
|
|
165
|
+
if (vite)
|
|
166
|
+
errorTemplate = await vite.transformIndexHtml(url, errorTemplate);
|
|
167
|
+
res.status(500).end(errorTemplate);
|
|
148
168
|
}
|
|
149
169
|
return next();
|
|
150
170
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server/server.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAUtD,eAAO,MAAM,aAAa,EAAE,aAkB3B,CAAC;AAEF,OAAO,EAAE,+BAA+B,IAAI,iBAAiB,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { setCurrentWorkingDirectory } from '@gracile/internal-utils/paths';
|
|
2
|
+
import {} from 'express';
|
|
3
|
+
import { routeAssets, routeImports, routes } from 'gracile:routes';
|
|
4
|
+
import { createRequestHandler } from './request.js';
|
|
5
|
+
routes.forEach((route, pattern) => {
|
|
6
|
+
routes.set(pattern, {
|
|
7
|
+
...route,
|
|
8
|
+
pattern: new URLPattern(pattern, 'http://gracile'),
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
export const createHandler = async ({ root = process.cwd(),
|
|
12
|
+
// hmrPort,
|
|
13
|
+
// NOTE: We need type parity with the dev. version of this function
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
15
|
+
} = {}) => {
|
|
16
|
+
setCurrentWorkingDirectory(root);
|
|
17
|
+
const gracileHandler = createRequestHandler({
|
|
18
|
+
root,
|
|
19
|
+
routes,
|
|
20
|
+
routeImports,
|
|
21
|
+
routeAssets,
|
|
22
|
+
serverMode: true,
|
|
23
|
+
});
|
|
24
|
+
return { handlers: [gracileHandler], vite: null };
|
|
25
|
+
};
|
|
26
|
+
export { printNodeHttpServerAddressInfos as printAddressInfos } from './utils.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/server/utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAKnC,wBAAgB,+BAA+B,CAAC,QAAQ,EAAE,MAAM,6BAsB/D"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// NOTE: Util. to pretty print for user provided server.
|
|
2
|
+
import { logger } from '@gracile/internal-utils/logger';
|
|
3
|
+
import { DEV } from 'esm-env';
|
|
4
|
+
import c from 'picocolors';
|
|
5
|
+
import { IP_EXPOSED } from './env.js';
|
|
6
|
+
export function printNodeHttpServerAddressInfos(instance) {
|
|
7
|
+
const infos = instance.address();
|
|
8
|
+
logger.info(c.green(`${DEV ? 'development' : 'production'} server started`), {
|
|
9
|
+
timestamp: true,
|
|
10
|
+
});
|
|
11
|
+
if (typeof infos === 'object' && infos && infos.port && infos.address) {
|
|
12
|
+
logger.info(`
|
|
13
|
+
${c.dim('┃')} Local ${c.cyan(`http://localhost:${infos.port}/`)}` +
|
|
14
|
+
`${infos.address === IP_EXPOSED
|
|
15
|
+
? `${c.dim('┃')} Network ${c.cyan(`http://${infos.address}:${infos.port}/`)}`
|
|
16
|
+
: ''}
|
|
17
|
+
`);
|
|
18
|
+
return infos;
|
|
19
|
+
}
|
|
20
|
+
throw Error('Invalid address/port.');
|
|
21
|
+
}
|