@gracile/engine 0.8.0-next.0 → 0.8.0-next.2
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 +1 -2
- package/dist/server/request.d.ts.map +1 -1
- package/dist/server/request.js +16 -11
- package/dist/vite/build-routes.d.ts +4 -19
- package/dist/vite/build-routes.d.ts.map +1 -1
- package/dist/vite/build-routes.js +1 -1
- package/dist/vite/html-routes.d.ts +2 -4
- package/dist/vite/html-routes.d.ts.map +1 -1
- package/dist/vite/virtual-routes.d.ts +3 -10
- package/dist/vite/virtual-routes.d.ts.map +1 -1
- package/package.json +5 -5
package/ambient.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/server/request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAOvC,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAQlD,OAAO,KAAK,KAAK,CAAC,MAAM,oBAAoB,CAAC;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAIvD,KAAK,gBAAgB,GAAG;IAAE,QAAQ,EAAE,QAAQ,CAAC;IAAC,IAAI,CAAC,EAAE,KAAK,CAAC;IAAC,IAAI,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC;AAC3E,KAAK,wBAAwB,GAAG;IAC/B,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,YAAY,CAAC;CACnB,CAAC;AAEF,MAAM,WAAW,cAAc;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,CAC5B,OAAO,EAAE,OAAO,EAChB,MAAM,CAAC,EAAE,OAAO,KACZ,OAAO,CAAC,gBAAgB,GAAG,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WAAW,CAAC,EAAE,CAAC,CAAC,YAAY,CAAC;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACjC,aAAa,EAAE,aAAa,CAAC;CAC7B,kBA8QA"}
|
package/dist/server/request.js
CHANGED
|
@@ -8,6 +8,10 @@ import { renderRouteTemplate } from '../render/route-template.js';
|
|
|
8
8
|
import { renderLitTemplate } from '../render/utils.js';
|
|
9
9
|
import { getRoute } from '../routes/match.js';
|
|
10
10
|
const CONTENT_TYPE_HTML = { 'Content-Type': 'text/html' };
|
|
11
|
+
const PREMISE_REGEXES = {
|
|
12
|
+
properties: /\/__(.*?)\.props\.json$/,
|
|
13
|
+
document: /\/__(.*?)\.doc\.html$/,
|
|
14
|
+
};
|
|
11
15
|
export function isRedirect(response) {
|
|
12
16
|
const location = response.headers.get('location');
|
|
13
17
|
if (response.status >= 300 && response.status <= 303 && location) {
|
|
@@ -25,13 +29,14 @@ export function createGracileHandler({ vite, routes, routeImports, routeAssets,
|
|
|
25
29
|
try {
|
|
26
30
|
// MARK: Rewrite hidden route siblings
|
|
27
31
|
const fullUrl = requestedUrl.replace(/\/__(.*)$/, '/');
|
|
32
|
+
// MARK: Setup premises
|
|
33
|
+
const propertiesOnly = PREMISE_REGEXES.properties.test(requestedUrl);
|
|
34
|
+
const documentOnly = PREMISE_REGEXES.document.test(requestedUrl);
|
|
35
|
+
const allowPremises = Boolean(gracileConfig.pages?.premises?.expose);
|
|
36
|
+
if (allowPremises === false && (propertiesOnly || documentOnly))
|
|
37
|
+
throw new Error('Accessed a page premise but they are not activated. You must enable `pages.premises.expose`.');
|
|
38
|
+
const premises = allowPremises ? { propertiesOnly, documentOnly } : null;
|
|
28
39
|
// MARK: Get route infos
|
|
29
|
-
const exposePremises = gracileConfig.pages?.premises?.expose
|
|
30
|
-
? {
|
|
31
|
-
propsOnly: /\/__(.*?)\.props\.json$/.test(requestedUrl),
|
|
32
|
-
docOnly: /\/__(.*?)\.doc\.html$/.test(requestedUrl),
|
|
33
|
-
}
|
|
34
|
-
: null;
|
|
35
40
|
const routeOptions = {
|
|
36
41
|
url: fullUrl,
|
|
37
42
|
vite,
|
|
@@ -65,7 +70,7 @@ export function createGracileHandler({ vite, routes, routeImports, routeAssets,
|
|
|
65
70
|
root,
|
|
66
71
|
serverMode,
|
|
67
72
|
routeInfos,
|
|
68
|
-
docOnly:
|
|
73
|
+
docOnly: premises?.documentOnly,
|
|
69
74
|
};
|
|
70
75
|
logger.info(`[${c.yellow(method)}] ${c.yellow(fullUrl)}`, {
|
|
71
76
|
timestamp: true,
|
|
@@ -122,7 +127,7 @@ export function createGracileHandler({ vite, routes, routeImports, routeAssets,
|
|
|
122
127
|
routeTemplateOptions.routeInfos.props = hasTopLevelHandler
|
|
123
128
|
? handlerOutput
|
|
124
129
|
: { [method]: handlerOutput };
|
|
125
|
-
if (
|
|
130
|
+
if (premises?.documentOnly) {
|
|
126
131
|
const { document } = await renderRouteTemplate(routeTemplateOptions);
|
|
127
132
|
return {
|
|
128
133
|
response: new Response(document, {
|
|
@@ -130,7 +135,7 @@ export function createGracileHandler({ vite, routes, routeImports, routeAssets,
|
|
|
130
135
|
}),
|
|
131
136
|
};
|
|
132
137
|
}
|
|
133
|
-
if (
|
|
138
|
+
if (premises?.propertiesOnly)
|
|
134
139
|
return {
|
|
135
140
|
response: Response.json(routeTemplateOptions.routeInfos.props),
|
|
136
141
|
};
|
|
@@ -146,7 +151,7 @@ export function createGracileHandler({ vite, routes, routeImports, routeAssets,
|
|
|
146
151
|
}
|
|
147
152
|
}
|
|
148
153
|
else {
|
|
149
|
-
if (
|
|
154
|
+
if (premises?.documentOnly) {
|
|
150
155
|
const { document } = await renderRouteTemplate(routeTemplateOptions);
|
|
151
156
|
return {
|
|
152
157
|
response: new Response(document, {
|
|
@@ -154,7 +159,7 @@ export function createGracileHandler({ vite, routes, routeImports, routeAssets,
|
|
|
154
159
|
}),
|
|
155
160
|
};
|
|
156
161
|
}
|
|
157
|
-
if (
|
|
162
|
+
if (premises?.propertiesOnly)
|
|
158
163
|
return {
|
|
159
164
|
response: Response.json(routeTemplateOptions.routeInfos.props || {}),
|
|
160
165
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { type ViteDevServer } from 'vite';
|
|
1
|
+
import { type Plugin, type ViteDevServer } from 'vite';
|
|
2
|
+
import { type RenderedRouteDefinition } from '../routes/render.js';
|
|
2
3
|
import type { RoutesManifest } from '../routes/route.js';
|
|
3
4
|
import type { GracileConfig } from '../user-config.js';
|
|
4
5
|
export declare const buildRoutes: ({ routes, viteServerForBuild, root, gracileConfig, serverMode, }: {
|
|
@@ -9,24 +10,8 @@ export declare const buildRoutes: ({ routes, viteServerForBuild, root, gracileCo
|
|
|
9
10
|
serverMode?: boolean;
|
|
10
11
|
}) => Promise<{
|
|
11
12
|
routes: RoutesManifest;
|
|
12
|
-
renderedRoutes:
|
|
13
|
+
renderedRoutes: RenderedRouteDefinition[];
|
|
13
14
|
inputList: string[];
|
|
14
|
-
plugin:
|
|
15
|
-
name: string;
|
|
16
|
-
apply: "build";
|
|
17
|
-
enforce: "pre";
|
|
18
|
-
resolveId(this: import("rollup").PluginContext, id: string): string | null;
|
|
19
|
-
load(this: import("rollup").PluginContext, id: string): string | null;
|
|
20
|
-
buildStart?: never;
|
|
21
|
-
generateBundle?: never;
|
|
22
|
-
} | {
|
|
23
|
-
name: string;
|
|
24
|
-
enforce: "post";
|
|
25
|
-
buildStart(this: import("rollup").PluginContext): void;
|
|
26
|
-
generateBundle(this: import("rollup").PluginContext, _: import("rollup").NormalizedOutputOptions, bundle: import("rollup").OutputBundle): void;
|
|
27
|
-
apply?: never;
|
|
28
|
-
resolveId?: never;
|
|
29
|
-
load?: never;
|
|
30
|
-
})[];
|
|
15
|
+
plugin: Plugin[];
|
|
31
16
|
}>;
|
|
32
17
|
//# sourceMappingURL=build-routes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-routes.d.ts","sourceRoot":"","sources":["../../src/vite/build-routes.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"build-routes.d.ts","sourceRoot":"","sources":["../../src/vite/build-routes.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgB,KAAK,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,MAAM,CAAC;AAErE,OAAO,EAEN,KAAK,uBAAuB,EAC5B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AASvD,eAAO,MAAM,WAAW,qEAMrB;IACF,MAAM,EAAE,cAAc,CAAC;IACvB,kBAAkB,EAAE,aAAa,CAAC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,aAAa,CAAC;IAC7B,UAAU,CAAC,EAAE,OAAO,CAAC;CACrB,KAAG,OAAO,CAAC;IACX,MAAM,EAAE,cAAc,CAAC;IACvB,cAAc,EAAE,uBAAuB,EAAE,CAAC;IAC1C,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,MAAM,EAAE,MAAM,EAAE,CAAC;CACjB,CA6JA,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { basename, extname, join } from 'node:path';
|
|
2
2
|
import { createFilter } from 'vite';
|
|
3
|
-
import { renderRoutes } from '../routes/render.js';
|
|
3
|
+
import { renderRoutes, } from '../routes/render.js';
|
|
4
4
|
import { REGEX_TAG_LINK, REGEX_TAG_SCRIPT } from '../render/route-template.js';
|
|
5
5
|
function stripPremises(input) {
|
|
6
6
|
return input
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
1
2
|
/**
|
|
2
3
|
* It make it possible to have HTML routes. It's funny,
|
|
3
4
|
* but not THAT useful.
|
|
4
5
|
* @todo Make tests and document this simple feature.
|
|
5
6
|
*/
|
|
6
|
-
export declare function htmlRoutesLoader():
|
|
7
|
-
name: string;
|
|
8
|
-
load(this: import("rollup").PluginContext, id: string): Promise<string | null>;
|
|
9
|
-
}[];
|
|
7
|
+
export declare function htmlRoutesLoader(): Plugin[];
|
|
10
8
|
//# sourceMappingURL=html-routes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-routes.d.ts","sourceRoot":"","sources":["../../src/vite/html-routes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"html-routes.d.ts","sourceRoot":"","sources":["../../src/vite/html-routes.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,EAAE,CAoB3C"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Plugin } from 'vite';
|
|
1
2
|
import type { RenderedRouteDefinition } from '../routes/render.js';
|
|
2
3
|
import type { RoutesManifest } from '../routes/route.js';
|
|
3
4
|
import type { GracileConfig } from '../user-config.js';
|
|
@@ -7,18 +8,10 @@ import type { GracileConfig } from '../user-config.js';
|
|
|
7
8
|
export declare function virtualRoutes({ routes, renderedRoutes, }: {
|
|
8
9
|
routes: RoutesManifest;
|
|
9
10
|
renderedRoutes: RenderedRouteDefinition[];
|
|
10
|
-
}):
|
|
11
|
-
name: string;
|
|
12
|
-
resolveId(this: import("rollup").PluginContext, id: string): "\0gracile:routes" | null;
|
|
13
|
-
load(this: import("rollup").PluginContext, id: string): string | null;
|
|
14
|
-
}[];
|
|
11
|
+
}): Plugin[];
|
|
15
12
|
export declare function virtualRoutesClient({ routes: routesMap, mode, gracileConfig, }: {
|
|
16
13
|
routes: RoutesManifest;
|
|
17
14
|
mode: 'static' | 'server';
|
|
18
15
|
gracileConfig: GracileConfig;
|
|
19
|
-
}):
|
|
20
|
-
name: string;
|
|
21
|
-
resolveId(this: import("rollup").PluginContext, id: string): "\0gracile:client:routes" | null;
|
|
22
|
-
load(this: import("rollup").PluginContext, id: string): string | null;
|
|
23
|
-
}[];
|
|
16
|
+
}): Plugin[];
|
|
24
17
|
//# sourceMappingURL=virtual-routes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtual-routes.d.ts","sourceRoot":"","sources":["../../src/vite/virtual-routes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"virtual-routes.d.ts","sourceRoot":"","sources":["../../src/vite/virtual-routes.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,MAAM,CAAC;AAEjD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD;;GAEG;AACH,wBAAgB,aAAa,CAAC,EAE7B,MAAM,EACN,cAAc,GACd,EAAE;IAEF,MAAM,EAAE,cAAc,CAAC;IACvB,cAAc,EAAE,uBAAuB,EAAE,CAAC;CAC1C,GAAG,MAAM,EAAE,CAyEX;AAKD,wBAAgB,mBAAmB,CAAC,EACnC,MAAM,EAAE,SAAS,EACjB,IAAe,EACf,aAAa,GACb,EAAE;IACF,MAAM,EAAE,cAAc,CAAC;IACvB,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC1B,aAAa,EAAE,aAAa,CAAC;CAC7B,GAAG,MAAM,EAAE,CAsDX"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gracile/engine",
|
|
3
|
-
"version": "0.8.0-next.
|
|
3
|
+
"version": "0.8.0-next.2",
|
|
4
4
|
"description": "A thin, full-stack, web framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"custom-elements",
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
"!/dist/typedoc-entrypoint.*"
|
|
44
44
|
],
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@gracile-labs/better-errors": "^0.1.2-next.
|
|
47
|
-
"@gracile/internal-utils": "^0.5.0-next.
|
|
46
|
+
"@gracile-labs/better-errors": "^0.1.2-next.2",
|
|
47
|
+
"@gracile/internal-utils": "^0.5.0-next.2",
|
|
48
48
|
"@whatwg-node/server": "^0.9.50",
|
|
49
49
|
"fdir": "^6.4.2",
|
|
50
50
|
"picocolors": "^1.1.1",
|
|
51
51
|
"urlpattern-polyfill": "^10.0.0",
|
|
52
|
-
"vite": "^
|
|
52
|
+
"vite": "^6.0.5"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"@lit-labs/ssr": "^3.2.2",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"access": "public",
|
|
61
61
|
"provenance": true
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "b4c0be43ac4e41d69b5219b6a1b87333dc46b7f0"
|
|
64
64
|
}
|