@gracile/engine 0.6.0 → 0.7.0-next.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/dist/build/static.d.ts +8 -2
- package/dist/build/static.d.ts.map +1 -1
- package/dist/build/static.js +38 -8
- package/dist/dev/dev.d.ts +4 -1
- package/dist/dev/dev.d.ts.map +1 -1
- package/dist/dev/dev.js +32 -19
- package/dist/dev/vite-logger.d.ts +2 -0
- package/dist/dev/vite-logger.d.ts.map +1 -0
- package/dist/dev/vite-logger.js +2 -0
- package/dist/errors/create-vite-better-error.d.ts +6 -0
- package/dist/errors/create-vite-better-error.d.ts.map +1 -0
- package/dist/errors/create-vite-better-error.js +27 -0
- package/dist/errors/errors-data.d.ts +81 -0
- package/dist/errors/errors-data.d.ts.map +1 -0
- package/dist/errors/errors-data.js +98 -0
- package/dist/errors/errors.d.ts +22 -0
- package/dist/errors/errors.d.ts.map +1 -0
- package/dist/errors/errors.js +122 -0
- package/dist/errors/pages.d.ts +4 -0
- package/dist/errors/pages.d.ts.map +1 -0
- package/dist/errors/pages.js +135 -0
- package/dist/logging/messages.d.ts +2 -0
- package/dist/logging/messages.d.ts.map +1 -0
- package/dist/logging/messages.js +6 -0
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +82 -43
- package/dist/render/markers.d.ts +3 -0
- package/dist/render/markers.d.ts.map +1 -0
- package/dist/render/markers.js +4 -0
- package/dist/render/route-template.d.ts +5 -10
- package/dist/render/route-template.d.ts.map +1 -1
- package/dist/render/route-template.js +68 -48
- package/dist/render/utils.d.ts +24 -1
- package/dist/render/utils.d.ts.map +1 -1
- package/dist/render/utils.js +23 -1
- package/dist/routes/collect.d.ts +2 -1
- package/dist/routes/collect.d.ts.map +1 -1
- package/dist/routes/collect.js +15 -11
- package/dist/routes/load-module.d.ts +1 -1
- package/dist/routes/load-module.d.ts.map +1 -1
- package/dist/routes/load-module.js +31 -5
- package/dist/routes/match.d.ts +1 -1
- package/dist/routes/match.d.ts.map +1 -1
- package/dist/routes/match.js +26 -12
- package/dist/routes/route.d.ts +2 -2
- package/dist/routes/route.d.ts.map +1 -1
- package/dist/routes/route.js +14 -12
- package/dist/server/adapters/hono.d.ts +5 -2
- package/dist/server/adapters/hono.d.ts.map +1 -1
- package/dist/server/adapters/hono.js +12 -6
- package/dist/server/adapters/node.d.ts +4 -2
- package/dist/server/adapters/node.d.ts.map +1 -1
- package/dist/server/adapters/node.js +27 -12
- package/dist/server/constants.d.ts +1 -1
- package/dist/server/constants.d.ts.map +1 -1
- package/dist/server/constants.js +1 -1
- package/dist/server/request.d.ts +7 -2
- package/dist/server/request.d.ts.map +1 -1
- package/dist/server/request.js +95 -69
- package/dist/server/utils.d.ts.map +1 -1
- package/dist/server/utils.js +5 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/user-config.d.ts +35 -1
- package/dist/user-config.d.ts.map +1 -1
- package/dist/vite/plugins/build-routes.d.ts +6 -2
- package/dist/vite/plugins/build-routes.d.ts.map +1 -1
- package/dist/vite/plugins/build-routes.js +69 -35
- package/dist/vite/plugins/virtual-routes.d.ts +10 -0
- package/dist/vite/plugins/virtual-routes.d.ts.map +1 -1
- package/dist/vite/plugins/virtual-routes.js +56 -4
- package/package.json +10 -11
- package/dist/assertions.d.ts +0 -13
- package/dist/assertions.d.ts.map +0 -1
- package/dist/assertions.js +0 -45
- package/dist/errors/templates.d.ts +0 -3
- package/dist/errors/templates.d.ts.map +0 -1
- package/dist/errors/templates.js +0 -69
package/dist/build/static.d.ts
CHANGED
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
import type { ViteDevServer } from 'vite';
|
|
2
|
+
import type { RoutesManifest } from '../routes/route.js';
|
|
2
3
|
import type { GracileConfig } from '../user-config.js';
|
|
3
4
|
export interface RenderedRouteDefinition {
|
|
4
5
|
absoluteId: string;
|
|
5
6
|
name: string;
|
|
6
7
|
html: string | null;
|
|
7
8
|
handlerAssets?: string;
|
|
9
|
+
static: {
|
|
10
|
+
props: unknown;
|
|
11
|
+
document: string | null;
|
|
12
|
+
};
|
|
8
13
|
savePrerender: boolean | null;
|
|
9
14
|
}
|
|
10
|
-
export declare function renderRoutes({ vite, serverMode, root, gracileConfig, }: {
|
|
15
|
+
export declare function renderRoutes({ routes, vite, serverMode, root, gracileConfig, }: {
|
|
16
|
+
routes: RoutesManifest;
|
|
11
17
|
vite: ViteDevServer;
|
|
12
18
|
serverMode: boolean;
|
|
13
19
|
root?: string;
|
|
14
20
|
gracileConfig: GracileConfig;
|
|
15
21
|
}): Promise<{
|
|
16
|
-
routes:
|
|
22
|
+
routes: RoutesManifest;
|
|
17
23
|
renderedRoutes: RenderedRouteDefinition[];
|
|
18
24
|
}>;
|
|
19
25
|
//# sourceMappingURL=static.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"static.d.ts","sourceRoot":"","sources":["../../src/build/static.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAK1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,MAAM,WAAW,uBAAuB;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAEpB,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,aAAa,EAAE,OAAO,GAAG,IAAI,CAAC;CAC9B;AAeD,wBAAsB,YAAY,CAAC,EAClC,IAAI,EACJ,UAAU,EACV,IAAoB,EACpB,aAAa,GACb,EAAE;IACF,IAAI,EAAE,aAAa,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,aAAa,CAAC;CAC7B;;;
|
|
1
|
+
{"version":3,"file":"static.d.ts","sourceRoot":"","sources":["../../src/build/static.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAK1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,MAAM,WAAW,uBAAuB;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAEpB,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,MAAM,EAAE;QACP,KAAK,EAAE,OAAO,CAAC;QACf,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;KACxB,CAAC;IAEF,aAAa,EAAE,OAAO,GAAG,IAAI,CAAC;CAC9B;AAeD,wBAAsB,YAAY,CAAC,EAClC,MAAM,EACN,IAAI,EACJ,UAAU,EACV,IAAoB,EACpB,aAAa,GACb,EAAE;IACF,MAAM,EAAE,cAAc,CAAC;IACvB,IAAI,EAAE,aAAa,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,aAAa,CAAC;CAC7B;;;GAwJA"}
|
package/dist/build/static.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Buffer } from 'node:buffer';
|
|
2
2
|
import path, { join } from 'node:path';
|
|
3
|
-
import {
|
|
3
|
+
import { getLogger } from '@gracile/internal-utils/logger/helpers';
|
|
4
4
|
import c from 'picocolors';
|
|
5
5
|
import { renderRouteTemplate } from '../render/route-template.js';
|
|
6
6
|
import { collectRoutes } from '../routes/collect.js';
|
|
@@ -17,10 +17,11 @@ async function streamToString(stream) {
|
|
|
17
17
|
}
|
|
18
18
|
return Buffer.concat(chunks).toString('utf-8');
|
|
19
19
|
}
|
|
20
|
-
export async function renderRoutes({ vite, serverMode, root = process.cwd(), gracileConfig, }) {
|
|
20
|
+
export async function renderRoutes({ routes, vite, serverMode, root = process.cwd(), gracileConfig, }) {
|
|
21
|
+
const logger = getLogger();
|
|
21
22
|
logger.info(c.green('Rendering routes…'), { timestamp: true });
|
|
22
23
|
// MARK: Collect
|
|
23
|
-
|
|
24
|
+
await collectRoutes(routes, root, gracileConfig.routes?.exclude);
|
|
24
25
|
const renderedRoutes = [];
|
|
25
26
|
// MARK: Iterate modules
|
|
26
27
|
await Promise.all([...routes].map(async ([patternString, route]) => {
|
|
@@ -31,15 +32,38 @@ export async function renderRoutes({ vite, serverMode, root = process.cwd(), gra
|
|
|
31
32
|
// NOTE: Skip rendering base document for server
|
|
32
33
|
if (serverMode && typeof routeModule.document !== 'function')
|
|
33
34
|
return;
|
|
34
|
-
const routeStaticPaths = routeModule.staticPaths?.();
|
|
35
|
+
const routeStaticPaths = await Promise.resolve(routeModule.staticPaths?.());
|
|
35
36
|
// MARK: Extract data
|
|
36
|
-
await Promise.all(
|
|
37
|
+
await Promise.all(
|
|
38
|
+
/* Single route */
|
|
39
|
+
(routeStaticPaths ?? [patternString]).map(async (staticPathOptions) => {
|
|
37
40
|
let pathnameWithParams = patternString;
|
|
38
41
|
let params = {};
|
|
39
42
|
let props;
|
|
43
|
+
// MARK: Handler data (for single route only, NOT dynamic)
|
|
44
|
+
if (routeModule.handler) {
|
|
45
|
+
const url = new URL(pathnameWithParams, 'http://gracile-static');
|
|
46
|
+
const context = {
|
|
47
|
+
url,
|
|
48
|
+
params: {},
|
|
49
|
+
// NOTE: STUB, maybe it should be better to remove them from typings?
|
|
50
|
+
// But that will make more mismatches between static and server.
|
|
51
|
+
request: new Request(url),
|
|
52
|
+
locals: {},
|
|
53
|
+
responseInit: {},
|
|
54
|
+
};
|
|
55
|
+
if (typeof routeModule.handler === 'function') {
|
|
56
|
+
props = await Promise.resolve(routeModule.handler(context));
|
|
57
|
+
}
|
|
58
|
+
else if ('GET' in routeModule.handler) {
|
|
59
|
+
props = {
|
|
60
|
+
GET: await Promise.resolve(routeModule.handler.GET(context)),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
40
64
|
// MARK: Convert pattern
|
|
41
65
|
// to real route with static parameters + get props. for after
|
|
42
|
-
if (typeof staticPathOptions === 'object') {
|
|
66
|
+
else if (typeof staticPathOptions === 'object') {
|
|
43
67
|
params = staticPathOptions.params;
|
|
44
68
|
props = staticPathOptions.props;
|
|
45
69
|
Object.entries(staticPathOptions.params).forEach(([paramName, value]) => {
|
|
@@ -60,11 +84,14 @@ export async function renderRoutes({ vite, serverMode, root = process.cwd(), gra
|
|
|
60
84
|
: 'index.html');
|
|
61
85
|
if (name === '404/index.html')
|
|
62
86
|
name = '404.html';
|
|
87
|
+
if (name === '500/index.html')
|
|
88
|
+
name = '500.html';
|
|
63
89
|
const url = new URL(pathnameWithParams, 'http://gracile-static');
|
|
64
90
|
// MARK: Render
|
|
65
|
-
const { output } = await renderRouteTemplate({
|
|
91
|
+
const { output, document } = await renderRouteTemplate({
|
|
66
92
|
//
|
|
67
|
-
request: { url: url.href },
|
|
93
|
+
// request: { url: url.href },
|
|
94
|
+
url: url.href,
|
|
68
95
|
vite,
|
|
69
96
|
mode: 'build',
|
|
70
97
|
routeInfos: {
|
|
@@ -79,6 +106,8 @@ export async function renderRoutes({ vite, serverMode, root = process.cwd(), gra
|
|
|
79
106
|
});
|
|
80
107
|
const htmlString = output ? await streamToString(output) : null;
|
|
81
108
|
const existing = renderedRoutes.find((rendered) => rendered?.name === name);
|
|
109
|
+
// NOTE: IIRC, this happens when two or more routes has the
|
|
110
|
+
// same priority, that will output the same static path.
|
|
82
111
|
if (existing)
|
|
83
112
|
throw new Error(`${c.red(`"${existing.name}" page was defined twice!`)}\n`);
|
|
84
113
|
const savePrerender = routeModule.prerender || null;
|
|
@@ -90,6 +119,7 @@ export async function renderRoutes({ vite, serverMode, root = process.cwd(), gra
|
|
|
90
119
|
name,
|
|
91
120
|
html: htmlString,
|
|
92
121
|
savePrerender,
|
|
122
|
+
static: { props, document },
|
|
93
123
|
};
|
|
94
124
|
renderedRoutes.push(rendered);
|
|
95
125
|
}));
|
package/dist/dev/dev.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { type ViteDevServer } from 'vite';
|
|
2
|
+
import type { RoutesManifest } from '../routes/route.js';
|
|
2
3
|
import { type GracileHandler } from '../server/request.js';
|
|
3
4
|
import type { GracileConfig } from '../user-config.js';
|
|
4
|
-
export declare function createDevHandler({ vite, gracileConfig, }: {
|
|
5
|
+
export declare function createDevHandler({ routes, vite, gracileConfig, }: {
|
|
6
|
+
routes: RoutesManifest;
|
|
5
7
|
vite: ViteDevServer;
|
|
6
8
|
gracileConfig: GracileConfig;
|
|
7
9
|
}): Promise<{
|
|
8
10
|
handler: GracileHandler;
|
|
11
|
+
routes: RoutesManifest;
|
|
9
12
|
}>;
|
|
10
13
|
//# sourceMappingURL=dev.d.ts.map
|
package/dist/dev/dev.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/dev/dev.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,MAAM,CAAC;AAG1C,OAAO,EAEN,KAAK,cAAc,EACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGvD,wBAAsB,gBAAgB,CAAC,EACtC,IAAI,EACJ,aAAa,GACb,EAAE;IACF,IAAI,EAAE,aAAa,CAAC;IACpB,aAAa,EAAE,aAAa,CAAC;CAC7B,GAAG,OAAO,CAAC;IACX,OAAO,EAAE,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/dev/dev.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,MAAM,CAAC;AAG1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAEN,KAAK,cAAc,EACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGvD,wBAAsB,gBAAgB,CAAC,EACtC,MAAM,EACN,IAAI,EACJ,aAAa,GACb,EAAE;IACF,MAAM,EAAE,cAAc,CAAC;IACvB,IAAI,EAAE,aAAa,CAAC;IACpB,aAAa,EAAE,aAAa,CAAC;CAC7B,GAAG,OAAO,CAAC;IACX,OAAO,EAAE,cAAc,CAAC;IACxB,MAAM,EAAE,cAAc,CAAC;CACvB,CAAC,CAgDD"}
|
package/dist/dev/dev.js
CHANGED
|
@@ -1,30 +1,43 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getLogger } from '@gracile/internal-utils/logger/helpers';
|
|
2
2
|
import c from 'picocolors';
|
|
3
3
|
import {} from 'vite';
|
|
4
|
-
import { collectRoutes } from '../routes/collect.js';
|
|
4
|
+
import { collectRoutes, WATCHED_FILES_REGEX } from '../routes/collect.js';
|
|
5
5
|
import { createGracileHandler, } from '../server/request.js';
|
|
6
6
|
import { generateRoutesTypings } from './route-typings.js';
|
|
7
|
-
export async function createDevHandler({ vite, gracileConfig, }) {
|
|
7
|
+
export async function createDevHandler({ routes, vite, gracileConfig, }) {
|
|
8
|
+
const logger = getLogger();
|
|
8
9
|
const root = vite.config.root;
|
|
9
|
-
logger.info(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
logger.info('');
|
|
11
|
+
logger.info(c.dim('Creating the request handler…'), { timestamp: true });
|
|
12
|
+
const collect = async () => {
|
|
13
|
+
await collectRoutes(routes, root, gracileConfig.routes?.exclude);
|
|
14
|
+
if (gracileConfig.experimental?.generateRoutesTypings)
|
|
15
|
+
await generateRoutesTypings(root, routes).catch((error) => logger.error(String(error)));
|
|
16
|
+
};
|
|
17
|
+
await collect();
|
|
18
|
+
let wait;
|
|
13
19
|
vite.watcher.on('all', (event, file) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
if (file.match(WATCHED_FILES_REGEX) &&
|
|
21
|
+
['add', 'unlink'].includes(event)
|
|
22
|
+
//
|
|
23
|
+
) {
|
|
24
|
+
clearTimeout(wait);
|
|
25
|
+
wait = setTimeout(() => {
|
|
26
|
+
collect()
|
|
27
|
+
.then(() => vite.hot.send('vite:invalidate'))
|
|
28
|
+
.catch((error) => logger.error(String(error)));
|
|
29
|
+
}, 100);
|
|
30
|
+
}
|
|
24
31
|
});
|
|
25
32
|
//
|
|
26
33
|
// NOTE: Wrong place?
|
|
27
34
|
const serverMode = false;
|
|
28
|
-
const gracile = createGracileHandler({
|
|
29
|
-
|
|
35
|
+
const gracile = createGracileHandler({
|
|
36
|
+
vite,
|
|
37
|
+
root,
|
|
38
|
+
serverMode,
|
|
39
|
+
routes,
|
|
40
|
+
gracileConfig,
|
|
41
|
+
});
|
|
42
|
+
return { handler: gracile, routes };
|
|
30
43
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite-logger.d.ts","sourceRoot":"","sources":["../../src/dev/vite-logger.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-vite-better-error.d.ts","sourceRoot":"","sources":["../../src/errors/create-vite-better-error.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAgB,aAAa,EAAE,MAAM,MAAM,CAAC;AAQxD,wBAAsB,mBAAmB,CAAC,EACzC,KAAK,EACL,IAAI,GACJ,EAAE;IACF,KAAK,EAAE,KAAK,CAAC;IACb,IAAI,EAAE,aAAa,CAAC;CACpB,mBA6BA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { pathToFileURL } from 'node:url';
|
|
2
|
+
import { getLogger } from '@gracile/internal-utils/logger/helpers';
|
|
3
|
+
import { formatErrorMessage } from '@gracile-labs/better-errors/dev/logger';
|
|
4
|
+
import { collectErrorMetadata } from '@gracile-labs/better-errors/dev/utils';
|
|
5
|
+
import { getViteErrorPayload } from '@gracile-labs/better-errors/dev/vite';
|
|
6
|
+
import { renderLitTemplate } from '../render/utils.js';
|
|
7
|
+
import { GRACILE_JS_ERRORS_DOCS_BASE, GracileErrorData } from './errors.js';
|
|
8
|
+
import { builtInErrorPage } from './pages.js';
|
|
9
|
+
const logger = getLogger();
|
|
10
|
+
export async function emitViteBetterError({ error, vite, }) {
|
|
11
|
+
const errorWithMetadata = collectErrorMetadata(error, pathToFileURL(vite.config.root));
|
|
12
|
+
logger.error(formatErrorMessage(errorWithMetadata, false, GracileErrorData, GRACILE_JS_ERRORS_DOCS_BASE), {
|
|
13
|
+
timestamp: true,
|
|
14
|
+
});
|
|
15
|
+
const payload = await getViteErrorPayload({
|
|
16
|
+
docsBaseUrl: GRACILE_JS_ERRORS_DOCS_BASE,
|
|
17
|
+
errorsData: GracileErrorData,
|
|
18
|
+
err: errorWithMetadata,
|
|
19
|
+
});
|
|
20
|
+
setTimeout(() => {
|
|
21
|
+
vite.hot.send(payload);
|
|
22
|
+
// NOTE: Arbitrary value. Lower seems to be too fast, higher is not guaranteed to work.
|
|
23
|
+
}, 200);
|
|
24
|
+
const errorPage = builtInErrorPage(error.name ?? 'Error', true);
|
|
25
|
+
const renderedErrorPage = await renderLitTemplate(errorPage);
|
|
26
|
+
return renderedErrorPage;
|
|
27
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export interface ErrorData {
|
|
2
|
+
name: string;
|
|
3
|
+
title: string;
|
|
4
|
+
message?: string | ((...params: any) => string) | undefined;
|
|
5
|
+
hint?: string | ((...params: any) => string) | undefined;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* @docs
|
|
9
|
+
* @kind heading
|
|
10
|
+
* @name Gracile Errors
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
|
+
export declare const FailedToLoadModuleSSR: {
|
|
16
|
+
readonly name: "FailedToLoadModuleSSR";
|
|
17
|
+
readonly title: "Could not import file.";
|
|
18
|
+
readonly message: (importName: string) => string;
|
|
19
|
+
readonly hint: "This is often caused by a typo in the import path. Please make sure the file exists.";
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
*/
|
|
27
|
+
export declare const InvalidRequestInAdapter: {
|
|
28
|
+
readonly name: "InvalidRequestInAdapter";
|
|
29
|
+
readonly title: "Invalid request in adapter.";
|
|
30
|
+
readonly message: (adapterName: string) => string;
|
|
31
|
+
readonly hint: "Check that you have configured the adapter correctly.";
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
*/
|
|
36
|
+
export declare const InvalidResponseInAdapter: {
|
|
37
|
+
readonly name: "InvalidResponseInAdapter";
|
|
38
|
+
readonly title: "Invalid response in adapter.";
|
|
39
|
+
readonly message: (adapterName: string) => string;
|
|
40
|
+
readonly hint: undefined;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
*
|
|
44
|
+
*/
|
|
45
|
+
export declare const InvalidRouteDocument: {
|
|
46
|
+
readonly name: "RoutePageRender";
|
|
47
|
+
readonly title: "Invalid route document configuration.";
|
|
48
|
+
readonly message: (routePath: string) => string;
|
|
49
|
+
readonly hint: undefined;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
*
|
|
53
|
+
*/
|
|
54
|
+
export declare const InvalidRouteDocumentResult: {
|
|
55
|
+
readonly name: "RoutePageRender";
|
|
56
|
+
readonly title: "Incorrect document template result.";
|
|
57
|
+
readonly message: (routePath: string) => string;
|
|
58
|
+
readonly hint: undefined;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
*
|
|
62
|
+
*/
|
|
63
|
+
export declare const InvalidRouteExport: {
|
|
64
|
+
readonly name: "InvalidRouteExport";
|
|
65
|
+
readonly title: "Invalid route export.";
|
|
66
|
+
readonly message: (routePath: string) => string;
|
|
67
|
+
readonly hint: "Should export a default `defineRoute` function.";
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
*
|
|
71
|
+
*/
|
|
72
|
+
export declare const CouldNotRenderRouteDocument: {
|
|
73
|
+
readonly name: "CouldNotRenderRouteDocument";
|
|
74
|
+
readonly title: "Could not render the route document.";
|
|
75
|
+
readonly message: (routePath: string) => string;
|
|
76
|
+
readonly hint: undefined;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
*
|
|
80
|
+
*/
|
|
81
|
+
//# sourceMappingURL=errors-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-data.d.ts","sourceRoot":"","sources":["../../src/errors/errors-data.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,SAAS;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,GAAG,MAAM,EAAE,GAAG,KAAK,MAAM,CAAC,GAAG,SAAS,CAAC;IAC5D,IAAI,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,GAAG,MAAM,EAAE,GAAG,KAAK,MAAM,CAAC,GAAG,SAAS,CAAC;CACzD;AAED;;;;GAIG;AAGH;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;mCAGX,MAAM;;CAEC,CAAC;AAC/B;;GAEG;AAgBH;;GAEG;AACH,eAAO,MAAM,uBAAuB;;;oCAGZ,MAAM;;CAGA,CAAC;AAC/B;;GAEG;AACH,eAAO,MAAM,wBAAwB;;;oCAGb,MAAM;;CAGA,CAAC;AAC/B;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;kCAGX,MAAM;;CAGE,CAAC;AAC/B;;GAEG;AACH,eAAO,MAAM,0BAA0B;;;kCAGjB,MAAM;;CAGE,CAAC;AAC/B;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;kCAGT,MAAM;;CAEE,CAAC;AAC/B;;GAEG;AACH,eAAO,MAAM,2BAA2B;;;kCAGlB,MAAM;;CAGE,CAAC;AAC/B;;GAEG"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
/**
|
|
3
|
+
* @docs
|
|
4
|
+
* @kind heading
|
|
5
|
+
* @name Gracile Errors
|
|
6
|
+
*/
|
|
7
|
+
// Gracile Errors, most errors will go here!
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
export const FailedToLoadModuleSSR = {
|
|
12
|
+
name: 'FailedToLoadModuleSSR',
|
|
13
|
+
title: 'Could not import file.',
|
|
14
|
+
message: (importName) => `Could not import \`${importName}\`.`,
|
|
15
|
+
hint: 'This is often caused by a typo in the import path. Please make sure the file exists.',
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
// export const FailedToGlobalLogger = {
|
|
21
|
+
// name: 'FailedToGlobalLogger',
|
|
22
|
+
// title: 'Could not get the global logger.',
|
|
23
|
+
// message: undefined,
|
|
24
|
+
// hint: 'This a Gracile internal fault.',
|
|
25
|
+
// };
|
|
26
|
+
// /**
|
|
27
|
+
// *
|
|
28
|
+
// */
|
|
29
|
+
// export const FailedToGetGracileVersion = {
|
|
30
|
+
// name: 'FailedToGetGracileVersion',
|
|
31
|
+
// title: 'Version must be set before.',
|
|
32
|
+
// message: undefined,
|
|
33
|
+
// hint: 'This a Gracile internal fault.',
|
|
34
|
+
// } as const satisfies ErrorData;
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
*/
|
|
38
|
+
export const InvalidRequestInAdapter = {
|
|
39
|
+
name: 'InvalidRequestInAdapter',
|
|
40
|
+
title: 'Invalid request in adapter.',
|
|
41
|
+
message: (adapterName) => `Invalid request for adapter name: \`${adapterName}\`.`,
|
|
42
|
+
hint: 'Check that you have configured the adapter correctly.',
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
*
|
|
46
|
+
*/
|
|
47
|
+
export const InvalidResponseInAdapter = {
|
|
48
|
+
name: 'InvalidResponseInAdapter',
|
|
49
|
+
title: 'Invalid response in adapter.',
|
|
50
|
+
message: (adapterName) => `Invalid response for adapter name: \`${adapterName}\`.`,
|
|
51
|
+
hint: undefined,
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
*
|
|
55
|
+
*/
|
|
56
|
+
export const InvalidRouteDocument = {
|
|
57
|
+
name: 'RoutePageRender',
|
|
58
|
+
title: 'Invalid route document configuration.',
|
|
59
|
+
message: (routePath) => `Route document must be a function for: \`${routePath}\`.`,
|
|
60
|
+
hint: undefined,
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
*
|
|
64
|
+
*/
|
|
65
|
+
export const InvalidRouteDocumentResult = {
|
|
66
|
+
name: 'RoutePageRender',
|
|
67
|
+
title: 'Incorrect document template result.',
|
|
68
|
+
message: (routePath) => `Incorrect document template result for: \`${routePath}\`.`,
|
|
69
|
+
hint: undefined,
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
*
|
|
73
|
+
*/
|
|
74
|
+
export const InvalidRouteExport = {
|
|
75
|
+
name: 'InvalidRouteExport',
|
|
76
|
+
title: 'Invalid route export.',
|
|
77
|
+
message: (routePath) => `Incorrect route module: \`${routePath}\`.`,
|
|
78
|
+
hint: `Should export a default \`defineRoute\` function.`,
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
*
|
|
82
|
+
*/
|
|
83
|
+
export const CouldNotRenderRouteDocument = {
|
|
84
|
+
name: 'CouldNotRenderRouteDocument',
|
|
85
|
+
title: 'Could not render the route document.',
|
|
86
|
+
message: (routePath) => `Could not render the route document for: \`${routePath}\`.`,
|
|
87
|
+
hint: undefined,
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
*
|
|
91
|
+
*/
|
|
92
|
+
// export const NoRoutesFound = {
|
|
93
|
+
// name: 'NoRoutesFound',
|
|
94
|
+
// title: 'Could not find any routes.',
|
|
95
|
+
// message: `Could not find any routes for your project.`,
|
|
96
|
+
// hint: 'You have to populate the `src/routes` folder.',
|
|
97
|
+
// };
|
|
98
|
+
// `Wrong template result for fragment template ${routeInfos.foundRoute.filePath}.`,
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { BetterError, type BuiltinErrorTypes } from '@gracile-labs/better-errors/errors';
|
|
2
|
+
export * as GracileErrorData from './errors-data.js';
|
|
3
|
+
export declare const GRACILE_JS_ERRORS_DOCS_BASE = "https://gracile.js.org/docs/references/errors";
|
|
4
|
+
type ErrorTypes = BuiltinErrorTypes | 'GracileError' | 'TemplateError' | 'InternalError' | 'TypeGuardError' | 'AggregateError';
|
|
5
|
+
export declare class GracileError extends BetterError<ErrorTypes> {
|
|
6
|
+
type: ErrorTypes;
|
|
7
|
+
static is(err: unknown): err is GracileError;
|
|
8
|
+
}
|
|
9
|
+
export declare class TemplateError extends GracileError {
|
|
10
|
+
type: ErrorTypes;
|
|
11
|
+
static is(err: unknown): err is TemplateError;
|
|
12
|
+
}
|
|
13
|
+
export declare class InternalError extends GracileError {
|
|
14
|
+
type: ErrorTypes;
|
|
15
|
+
static is(err: unknown): err is InternalError;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* An error util. that should never be called in theory.
|
|
19
|
+
*/
|
|
20
|
+
export declare class TypeGuardError extends Error {
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors/errors.ts"],"names":[],"mappings":"AAIA,OAAO,EACN,WAAW,EACX,KAAK,iBAAiB,EACtB,MAAM,oCAAoC,CAAC;AAI5C,OAAO,KAAK,gBAAgB,MAAM,kBAAkB,CAAC;AAErD,eAAO,MAAM,2BAA2B,kDACQ,CAAC;AAEjD,KAAK,UAAU,GACZ,iBAAiB,GACjB,cAAc,GACd,eAAe,GACf,eAAe,GACf,gBAAgB,GAChB,gBAAgB,CAAC;AAQpB,qBAAa,YAAa,SAAQ,WAAW,CAAC,UAAU,CAAC;IACxD,IAAI,EAAE,UAAU,CAAkB;IAElC,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,YAAY;CAG5C;AAED,qBAAa,aAAc,SAAQ,YAAY;IAC9C,IAAI,EAAE,UAAU,CAAmB;IAEnC,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,aAAa;CAG7C;AAED,qBAAa,aAAc,SAAQ,YAAY;IAC9C,IAAI,EAAE,UAAU,CAAmB;IAEnC,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,aAAa;CAG7C;AAuGD;;GAEG;AACH,qBAAa,cAAe,SAAQ,KAAK;CAAG"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/* eslint-disable max-classes-per-file */
|
|
2
|
+
/* eslint-disable @typescript-eslint/lines-between-class-members */
|
|
3
|
+
// NOTE: Taken and adapted from https://github.com/withGracile/Gracile/blob/cf65476b27053333cf5a36f6f9f46b794c98dfa2/packages/Gracile/src/core/errors/errors.ts
|
|
4
|
+
import { BetterError, } from '@gracile-labs/better-errors/errors';
|
|
5
|
+
// import { codeFrame } from '@gracile-labs/better-errors/printer';
|
|
6
|
+
export * as GracileErrorData from './errors-data.js';
|
|
7
|
+
export const GRACILE_JS_ERRORS_DOCS_BASE = 'https://gracile.js.org/docs/references/errors';
|
|
8
|
+
// | 'BetterError'
|
|
9
|
+
// | 'GracileUserError'
|
|
10
|
+
// | 'CompilerError'
|
|
11
|
+
// | 'CSSError'
|
|
12
|
+
// | 'MarkdownError'
|
|
13
|
+
export class GracileError extends BetterError {
|
|
14
|
+
type = 'GracileError';
|
|
15
|
+
static is(err) {
|
|
16
|
+
return err.type === 'GracileError';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export class TemplateError extends GracileError {
|
|
20
|
+
type = 'TemplateError';
|
|
21
|
+
static is(err) {
|
|
22
|
+
return err.type === 'TemplateError';
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export class InternalError extends GracileError {
|
|
26
|
+
type = 'InternalError';
|
|
27
|
+
static is(err) {
|
|
28
|
+
return err.type === 'InternalError';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//
|
|
32
|
+
// /* eslint-disable @typescript-eslint/lines-between-class-members */
|
|
33
|
+
// /* eslint-disable max-classes-per-file */
|
|
34
|
+
// import type { buildErrorMessage } from 'vite';
|
|
35
|
+
// export type RollupError = Parameters<typeof buildErrorMessage>['0'];
|
|
36
|
+
// export abstract class BetterError extends Error implements RollupError {
|
|
37
|
+
// // --- RollupError
|
|
38
|
+
// watchFiles?: string[];
|
|
39
|
+
// binding?: string;
|
|
40
|
+
// cause?: unknown;
|
|
41
|
+
// code?: string;
|
|
42
|
+
// exporter?: string;
|
|
43
|
+
// frame?: string;
|
|
44
|
+
// hook?: string;
|
|
45
|
+
// id?: string;
|
|
46
|
+
// ids?: string[];
|
|
47
|
+
// loc?: { column: number; file?: string; line: number };
|
|
48
|
+
// meta?: unknown;
|
|
49
|
+
// names?: string[];
|
|
50
|
+
// plugin?: string;
|
|
51
|
+
// pluginCode?: unknown;
|
|
52
|
+
// pos?: number;
|
|
53
|
+
// reexporter?: string;
|
|
54
|
+
// stack?: string;
|
|
55
|
+
// url?: string;
|
|
56
|
+
// // --- End RollupError
|
|
57
|
+
// constructor(message: string, options?: { cause?: unknown }) {
|
|
58
|
+
// super(message);
|
|
59
|
+
// this.name = 'BetterError';
|
|
60
|
+
// this.cause = options?.cause;
|
|
61
|
+
// }
|
|
62
|
+
// }
|
|
63
|
+
// export class GracileUnknownError extends BetterError {
|
|
64
|
+
// constructor(message: string, options?: { cause?: unknown }) {
|
|
65
|
+
// super(message, options);
|
|
66
|
+
// this.name = 'GracileUnknownError';
|
|
67
|
+
// }
|
|
68
|
+
// }
|
|
69
|
+
// export class SsrError extends BetterError {
|
|
70
|
+
// constructor(message: string, options?: { cause?: unknown }) {
|
|
71
|
+
// super(message, options);
|
|
72
|
+
// this.name = 'SsrError';
|
|
73
|
+
// }
|
|
74
|
+
// }
|
|
75
|
+
// export function isViteError(error: unknown): error is RollupError {
|
|
76
|
+
// if (
|
|
77
|
+
// typeof error === 'object' &&
|
|
78
|
+
// error &&
|
|
79
|
+
// 'message' in error &&
|
|
80
|
+
// 'plugin' in error &&
|
|
81
|
+
// typeof error.plugin === 'string' &&
|
|
82
|
+
// error.plugin.startsWith(`vite:`)
|
|
83
|
+
// )
|
|
84
|
+
// return true;
|
|
85
|
+
// return false;
|
|
86
|
+
// }
|
|
87
|
+
// // export type EsbuildError = {
|
|
88
|
+
// // plugin: 'vite:esbuild';
|
|
89
|
+
// // } & RollupError;
|
|
90
|
+
// // export class GracileRouterError extends Error implements e {
|
|
91
|
+
// // constructor(message: string, options: { cause: unknown }) {
|
|
92
|
+
// // super(message);
|
|
93
|
+
// // this.name = 'GracileRouterError';
|
|
94
|
+
// // this.cause = options.cause;
|
|
95
|
+
// // }
|
|
96
|
+
// // }
|
|
97
|
+
// /**
|
|
98
|
+
// * Special error that is exposed to users.
|
|
99
|
+
// * Compared to BetterError, it contains a subset of information.
|
|
100
|
+
// */
|
|
101
|
+
// export class GracileUserError extends Error {
|
|
102
|
+
// type: ErrorTypes = 'GracileUserError';
|
|
103
|
+
// /**
|
|
104
|
+
// * A message that explains to the user how they can fix the error.
|
|
105
|
+
// */
|
|
106
|
+
// hint: string | undefined;
|
|
107
|
+
// name = 'GracileUserError';
|
|
108
|
+
// constructor(message: string, hint?: string) {
|
|
109
|
+
// super();
|
|
110
|
+
// this.message = message;
|
|
111
|
+
// this.hint = hint;
|
|
112
|
+
// }
|
|
113
|
+
// static is(err: unknown): err is GracileUserError {
|
|
114
|
+
// return (err as GracileUserError).type === 'GracileUserError';
|
|
115
|
+
// }
|
|
116
|
+
// }
|
|
117
|
+
// ---
|
|
118
|
+
/**
|
|
119
|
+
* An error util. that should never be called in theory.
|
|
120
|
+
*/
|
|
121
|
+
export class TypeGuardError extends Error {
|
|
122
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function errorInline(error: Error): import("@lit-labs/ssr").ServerRenderedTemplate;
|
|
2
|
+
export declare function builtIn404Page(path: string, dev?: boolean): import("@lit-labs/ssr").ServerRenderedTemplate;
|
|
3
|
+
export declare function builtInErrorPage(name?: string, dev?: boolean): import("@lit-labs/ssr").ServerRenderedTemplate;
|
|
4
|
+
//# sourceMappingURL=pages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pages.d.ts","sourceRoot":"","sources":["../../src/errors/pages.ts"],"names":[],"mappings":"AAEA,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,kDASvC;AAgBD,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,UAAQ,kDAwFvD;AAOD,wBAAgB,gBAAgB,CAAC,IAAI,SAAU,EAAE,GAAG,UAAQ,kDAoB3D"}
|