@gracile/engine 0.1.1 → 0.2.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.
Files changed (54) hide show
  1. package/ambient.d.ts +9 -4
  2. package/dist/assertions.test.d.ts +2 -0
  3. package/dist/assertions.test.d.ts.map +1 -0
  4. package/dist/assertions.test.js +22 -0
  5. package/dist/dev/dev.d.ts +6 -7
  6. package/dist/dev/dev.d.ts.map +1 -1
  7. package/dist/dev/dev.js +25 -18
  8. package/dist/plugin.d.ts +5 -0
  9. package/dist/plugin.d.ts.map +1 -0
  10. package/dist/plugin.js +175 -0
  11. package/dist/render/route-template.d.ts.map +1 -1
  12. package/dist/render/route-template.js +21 -8
  13. package/dist/routes/collect.d.ts.map +1 -1
  14. package/dist/routes/collect.js +39 -30
  15. package/dist/routes/match.js +1 -1
  16. package/dist/routes/route.d.ts +4 -5
  17. package/dist/routes/route.d.ts.map +1 -1
  18. package/dist/routes/route.js +1 -2
  19. package/dist/server/env.d.ts +2 -1
  20. package/dist/server/env.d.ts.map +1 -1
  21. package/dist/server/env.js +5 -3
  22. package/dist/server/request.d.ts +1 -1
  23. package/dist/server/request.d.ts.map +1 -1
  24. package/dist/server/request.js +139 -97
  25. package/dist/server/utils.d.ts +21 -3
  26. package/dist/server/utils.d.ts.map +1 -1
  27. package/dist/server/utils.js +61 -10
  28. package/dist/tsconfig.tsbuildinfo +1 -1
  29. package/dist/vite/plugins/build-routes.d.ts.map +1 -1
  30. package/dist/vite/plugins/build-routes.js +1 -0
  31. package/dist/vite/plugins/virtual-routes.d.ts.map +1 -1
  32. package/dist/vite/plugins/virtual-routes.js +6 -1
  33. package/package.json +22 -26
  34. package/dist/build/build.d.ts +0 -2
  35. package/dist/build/build.d.ts.map +0 -1
  36. package/dist/build/build.js +0 -7
  37. package/dist/dev/server.d.ts +0 -30
  38. package/dist/dev/server.d.ts.map +0 -1
  39. package/dist/dev/server.js +0 -82
  40. package/dist/preview.d.ts +0 -6
  41. package/dist/preview.d.ts.map +0 -1
  42. package/dist/preview.js +0 -12
  43. package/dist/server/server.d.ts +0 -4
  44. package/dist/server/server.d.ts.map +0 -1
  45. package/dist/server/server.js +0 -25
  46. package/dist/vite/build.d.ts +0 -2
  47. package/dist/vite/build.d.ts.map +0 -1
  48. package/dist/vite/build.js +0 -114
  49. package/dist/vite/config.d.ts +0 -28
  50. package/dist/vite/config.d.ts.map +0 -1
  51. package/dist/vite/config.js +0 -74
  52. package/dist/vite/server.d.ts +0 -6
  53. package/dist/vite/server.d.ts.map +0 -1
  54. package/dist/vite/server.js +0 -20
package/ambient.d.ts CHANGED
@@ -1,7 +1,12 @@
1
1
  /// <reference types="vite/client" />
2
2
 
3
- declare module 'gracile:routes' {
4
- export const routes: import('./src/routes/route.js').RoutesManifest;
5
- export const routeImports: import('./src/routes/route.js').RoutesImports;
6
- export const routeAssets: import('./src/routes/route.js').RoutesAssets;
3
+ // NOTE: It's not exposed to user-land anyway, and gets bundled away
4
+ // declare module 'gracile:routes' {
5
+ // export const routes: import('./src/routes/route.js').RoutesManifest;
6
+ // export const routeImports: import('./src/routes/route.js').RoutesImports;
7
+ // export const routeAssets: import('./src/routes/route.js').RoutesAssets;
8
+ // }
9
+
10
+ declare namespace App {
11
+ interface Locals {}
7
12
  }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=assertions.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assertions.test.d.ts","sourceRoot":"","sources":["../src/assertions.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,22 @@
1
+ /* eslint-disable @typescript-eslint/no-floating-promises */
2
+ import assert from 'node:assert/strict';
3
+ import test, { describe } from 'node:test';
4
+ import { html as serverHtml } from '@lit-labs/ssr';
5
+ import { html } from 'lit';
6
+ import { isLitNormalTemplate, isLitServerTemplate, isLitTemplate, isUnknownObject, } from './assertions.js';
7
+ describe('should assert lit templates', () => {
8
+ test('assert lit', () => {
9
+ const lit = html ` <div>Hello</div> `;
10
+ const litServer = serverHtml ` <div>Hello</div> `;
11
+ assert.equal(isLitTemplate(lit), true);
12
+ assert.equal(isLitTemplate(litServer), true);
13
+ assert.equal(isLitNormalTemplate(lit), true);
14
+ assert.equal(isLitServerTemplate(litServer), true);
15
+ assert.equal(isUnknownObject({ something: 'something' }), true);
16
+ //
17
+ assert.equal(isLitTemplate([]), false);
18
+ assert.equal(isLitTemplate([]), false);
19
+ assert.equal(isLitNormalTemplate([]), false);
20
+ assert.equal(isLitServerTemplate([]), false);
21
+ });
22
+ });
package/dist/dev/dev.d.ts CHANGED
@@ -1,9 +1,8 @@
1
- export declare function dev(options: {
2
- port?: number | undefined;
3
- root?: string | undefined;
4
- expose?: boolean | undefined;
5
- }): Promise<void | {
6
- port: number;
7
- instance: import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>;
1
+ import { type ViteDevServer } from 'vite';
2
+ import { type ConnectLikeAsyncMiddleware } from '../server/request.js';
3
+ export declare function createHandlers({ vite, }: {
4
+ vite: ViteDevServer;
5
+ }): Promise<{
6
+ handlers: ConnectLikeAsyncMiddleware;
8
7
  }>;
9
8
  //# sourceMappingURL=dev.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/dev/dev.ts"],"names":[],"mappings":"AAYA,wBAAsB,GAAG,CAAC,OAAO,EAAE;IAClC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAC7B;;;GAuBA"}
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,EACN,KAAK,0BAA0B,EAE/B,MAAM,sBAAsB,CAAC;AAE9B,wBAAsB,cAAc,CAAC,EACpC,IAAI,GACJ,EAAE;IACF,IAAI,EAAE,aAAa,CAAC;CACpB,GAAG,OAAO,CAAC;IACX,QAAQ,EAAE,0BAA0B,CAAC;CACrC,CAAC,CA4BD"}
package/dist/dev/dev.js CHANGED
@@ -1,21 +1,28 @@
1
1
  import { logger } from '@gracile/internal-utils/logger';
2
- import { setCurrentWorkingDirectory } from '@gracile/internal-utils/paths';
3
2
  import c from 'picocolors';
4
- import { getConfigs } from '../vite/config.js';
5
- import { createStandaloneDevServer, DEFAULT_DEV_SERVER_PORT, DEFAULT_USER_SERVER_MODULE_ENTRYPOINT, startUserProvidedServer, } from './server.js';
6
- export async function dev(options) {
7
- logger.info(c.gray('\n— Development mode —\n'));
8
- const root = setCurrentWorkingDirectory(options.root);
9
- const { userConfigGracile } = await getConfigs(root, 'dev');
10
- const port = options.port ?? userConfigGracile?.port ?? DEFAULT_DEV_SERVER_PORT;
11
- const entrypoint = userConfigGracile?.server?.entrypoint ??
12
- DEFAULT_USER_SERVER_MODULE_ENTRYPOINT;
13
- if (userConfigGracile?.output === 'server') {
14
- logger.info(c.gray(`\n— User provided ${c.cyan('server')} mode —\n`));
15
- return startUserProvidedServer({
16
- root,
17
- entrypoint,
18
- });
19
- }
20
- return createStandaloneDevServer({ root, port });
3
+ import {} from 'vite';
4
+ import { collectRoutes } from '../routes/collect.js';
5
+ import { createGracileMiddleware, } from '../server/request.js';
6
+ export async function createHandlers({ vite, }) {
7
+ const root = vite.config.root;
8
+ logger.info(c.green('creating handler…'), { timestamp: true });
9
+ const routes = await collectRoutes(root /* vite */);
10
+ vite.watcher.on('all', (event, file) => {
11
+ // console.log({ event });
12
+ if (file.match(/\/src\/routes\/(.*)\.(ts|js)$/) &&
13
+ event === 'add'
14
+ /* &&
15
+ ['add', 'unlink',''].includes(event) */
16
+ )
17
+ collectRoutes(root /* { file, event } */ /* , vite */)
18
+ .then(() => {
19
+ vite.hot.send('vite:invalidate');
20
+ })
21
+ .catch((e) => logger.error(String(e)));
22
+ });
23
+ //
24
+ // NOTE: Wrong place?
25
+ const serverMode = false;
26
+ const gracile = createGracileMiddleware({ vite, root, serverMode, routes });
27
+ return { handlers: gracile };
21
28
  }
@@ -0,0 +1,5 @@
1
+ import { type PluginOption } from 'vite';
2
+ export declare const gracile: (config?: {
3
+ mode: "server" | "static";
4
+ }) => PluginOption;
5
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAGA,OAAO,EAAuB,KAAK,YAAY,EAAE,MAAM,MAAM,CAAC;AAU9D,eAAO,MAAM,OAAO,YAAa;IAChC,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAAC;CAC1B,KAAG,YA+MH,CAAC"}
package/dist/plugin.js ADDED
@@ -0,0 +1,175 @@
1
+ import { join } from 'node:path';
2
+ import { rename, rm } from 'fs/promises';
3
+ import { build, createServer } from 'vite';
4
+ import {} from './build/static.js';
5
+ import { createHandlers } from './dev/dev.js';
6
+ import { buildRoutes } from './vite/plugins/build-routes.js';
7
+ import { virtualRoutes } from './vite/plugins/virtual-routes.js';
8
+ export const gracile = (config) => {
9
+ const mode = config?.mode || 'static';
10
+ const clientAssets = {};
11
+ let routes = null;
12
+ let renderedRoutes = null;
13
+ let root = null;
14
+ return [
15
+ {
16
+ name: 'vite-plugin-gracile-serve-middleware',
17
+ apply: 'serve',
18
+ config() {
19
+ return {
20
+ // NOTE: Supresses message: `Could not auto-determine entry point from rollupOptions or html files…`
21
+ optimizeDeps: { include: [] },
22
+ };
23
+ },
24
+ async configureServer(server) {
25
+ // ({ plmugi: server.config.root });
26
+ const { handlers } = await createHandlers({ vite: server });
27
+ return () => {
28
+ server.middlewares.use((req, res, next) => {
29
+ Promise.resolve(handlers(req, res, next)).catch((error) => next(error));
30
+ });
31
+ };
32
+ },
33
+ },
34
+ {
35
+ name: 'vite-plugin-gracile-build',
36
+ apply: 'build',
37
+ async config(viteConfig) {
38
+ const viteServerForClientHtmlBuild = await createServer({
39
+ // configFile: false,
40
+ root: viteConfig.root || process.cwd(),
41
+ });
42
+ const htmlPages = await buildRoutes({
43
+ viteServerForBuild: viteServerForClientHtmlBuild,
44
+ root: viteConfig.root || process.cwd(),
45
+ _config: {},
46
+ serverMode: mode === 'server',
47
+ });
48
+ routes = htmlPages.routes;
49
+ renderedRoutes = htmlPages.renderedRoutes;
50
+ await viteServerForClientHtmlBuild.close();
51
+ return {
52
+ plugins: viteServerForClientHtmlBuild.config.plugins.filter((p) => p.name),
53
+ build: {
54
+ rollupOptions: {
55
+ input: htmlPages.inputList,
56
+ plugins: [htmlPages.plugin],
57
+ },
58
+ outDir: mode === 'server' ? 'dist/client' : 'dist',
59
+ },
60
+ };
61
+ },
62
+ },
63
+ {
64
+ name: 'vite-plugin-gracile-collect-client-assets-for-server',
65
+ writeBundle(_, bundle) {
66
+ if (mode === 'static')
67
+ return;
68
+ Object.entries(bundle).forEach(([, file]) => {
69
+ if (file.type === 'asset' && file.name)
70
+ clientAssets[file.name] = file.fileName;
71
+ });
72
+ },
73
+ },
74
+ {
75
+ name: 'vite-plugin-gracile-server-build',
76
+ apply: 'build',
77
+ config(viteConfig) {
78
+ root = viteConfig.root || null;
79
+ },
80
+ async closeBundle() {
81
+ if (mode === 'static' || !routes || !renderedRoutes)
82
+ return;
83
+ await build({
84
+ configFile: false,
85
+ root: root || process.cwd(),
86
+ ssr: {
87
+ external: ['@gracile/gracile'],
88
+ },
89
+ build: {
90
+ target: 'esnext',
91
+ ssr: true,
92
+ copyPublicDir: false,
93
+ outDir: 'dist/server',
94
+ ssrEmitAssets: true,
95
+ cssMinify: true,
96
+ cssCodeSplit: true,
97
+ rollupOptions: {
98
+ input: 'entrypoint.js',
99
+ // external: ['@gracile/gracile'],
100
+ // FIXME: ~~MUST import css from client somewhere.~~
101
+ // ~~Hack could be using dynamic imports on client, so asset is picked up~~
102
+ output: {
103
+ entryFileNames: '[name].js',
104
+ // assetFileNames: 'assets/[name].[ext]',
105
+ // NOTE: Useful for, e.g., link tag with `?url`
106
+ assetFileNames: (chunkInfo) => {
107
+ if (chunkInfo.name) {
108
+ // (chunkInfo);
109
+ const fileName = clientAssets[chunkInfo.name];
110
+ if (fileName)
111
+ return fileName;
112
+ // NOTE: When not imported at all from client
113
+ return `assets/${chunkInfo.name.replace(/\.(.*)$/, '')}-[hash].[ext]`;
114
+ }
115
+ // throw new Error(`Not client asset`);
116
+ return 'assets/[name]-[hash].[ext]';
117
+ },
118
+ chunkFileNames: 'chunk/[name].js',
119
+ },
120
+ },
121
+ },
122
+ plugins: [
123
+ virtualRoutes({
124
+ routes,
125
+ renderedRoutes,
126
+ }),
127
+ {
128
+ name: 'vite-plugin-gracile-entry',
129
+ resolveId(id) {
130
+ if (id === 'entrypoint.js') {
131
+ return id;
132
+ }
133
+ return null;
134
+ },
135
+ load(id) {
136
+ if (id === 'entrypoint.js' && routes && renderedRoutes) {
137
+ return `
138
+ import { routeAssets, routeImports, routes } from 'gracile:routes';
139
+ import { createGracileMiddleware } from '@gracile/gracile/plugin';
140
+
141
+ // ({ routeAssets, routeImports, routes })
142
+
143
+ export const handler = createGracileMiddleware({
144
+ root: process.cwd(),
145
+ routes,
146
+ routeImports,
147
+ routeAssets,
148
+ serverMode: true,
149
+ });
150
+ `;
151
+ }
152
+ return null;
153
+ },
154
+ },
155
+ {
156
+ name: 'gracile-move-server-assets',
157
+ async writeBundle(_, bundle) {
158
+ const cwd = root || process.cwd();
159
+ await Promise.all(Object.entries(bundle).map(async ([file]) => {
160
+ if (file.startsWith('assets/') === false)
161
+ return;
162
+ await rename(join(cwd, `/dist/server/${file}`), join(cwd, `/dist/client/${file}`));
163
+ }));
164
+ // NOTE: Disabled for now, because it conflict with test's folder comparer
165
+ await rm(join(cwd, `/dist/server/assets`), {
166
+ recursive: true,
167
+ }).catch(() => null);
168
+ },
169
+ },
170
+ ],
171
+ });
172
+ },
173
+ },
174
+ ];
175
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"route-template.d.ts","sourceRoot":"","sources":["../../src/render/route-template.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAG1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,KAAK,CAAC,MAAM,oBAAoB,CAAC;AAa7C,eAAO,MAAM,iBAAiB,oDACoB,CAAC;AAGnD,eAAO,MAAM,kBAAkB,mCAAmC,CAAC;AAEnE,eAAO,MAAM,UAAU,gDAA6C,CAAC;AAErE,eAAO,MAAM,gBAAgB,QACkC,CAAC;AAEhE,eAAO,MAAM,cAAc,QAA2B,CAAC;AAEvD,MAAM,MAAM,YAAY,GAAG;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7D,wBAAsB,mBAAmB,CAAC,EACzC,OAAO,EACP,IAAI,EACJ,IAAI,EACJ,UAAU,EACV,YAAY,EACZ,WAAW,EAEX,UAAU,GACV,EAAE;IACF,OAAO,EAAE,OAAO,GAAG,CAAC,CAAC,aAAa,CAAC;IACnC,IAAI,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IACjC,IAAI,EAAE,KAAK,GAAG,OAAO,CAAC;IACtB,UAAU,EAAE,UAAU,CAAC;IACvB,YAAY,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;IACxC,WAAW,CAAC,EAAE,CAAC,CAAC,YAAY,GAAG,SAAS,CAAC;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACjC,GAAG,OAAO,CAAC;IAAE,MAAM,EAAE,IAAI,GAAG,QAAQ,CAAA;CAAE,CAAC,CAgJvC"}
1
+ {"version":3,"file":"route-template.d.ts","sourceRoot":"","sources":["../../src/render/route-template.ts"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path)) {
67
67
  return html `
68
68
  <link rel="stylesheet" href="/${path}" />
69
69
  <!-- -->
@@ -89,19 +89,32 @@ serverMode, }) {
89
89
  .replace('</head>', `${routeAssetsString}\n</head>`);
90
90
  // MARK: Base document
91
91
  const baseDocHtml = vite && mode === 'dev'
92
- ? await vite.transformIndexHtml(routeInfos.pathname, baseDocRenderedWithAssets)
92
+ ? await vite.transformIndexHtml(
93
+ // HACK: Sometimes, we need to invalidate for server asset url
94
+ // imports to work. So we keep this hack around just in case.
95
+ // Maybe it's linked to the way hashed assets are invalidating
96
+ // the html proxy module…
97
+ // `${routeInfos.pathname}?r=${Math.random()}`,
98
+ routeInfos.pathname, baseDocRenderedWithAssets)
93
99
  : baseDocRenderedWithAssets;
94
100
  const index = baseDocHtml.indexOf(SSR_OUTLET_MARKER);
95
101
  const baseDocRenderStreamPre = Readable.from(baseDocHtml.substring(0, index));
96
102
  const baseDocRenderStreamPost = Readable.from(baseDocHtml.substring(index + SSR_OUTLET_MARKER.length + 1));
97
103
  // MARK: Page
98
104
  // Skipped with server mode in production build
99
- if ((serverMode === false && routeInfos.routeModule.template) ||
100
- //
101
- (serverMode &&
102
- routeInfos.routeModule.template &&
103
- (mode !== 'build' || routeInfos.routeModule.prerender === true))) {
104
- const routeOutput = await Promise.resolve(routeInfos.routeModule.template?.(context));
105
+ if (routeInfos.routeModule.template &&
106
+ (serverMode === false ||
107
+ //
108
+ (serverMode &&
109
+ (mode !== 'build' || routeInfos.routeModule.prerender === true)))) {
110
+ const routeOutput = await Promise.resolve(routeInfos.routeModule.template(context));
111
+ // NOTE: Explicitely unset template (maybe a bad idea as a feature. We'll see)
112
+ // if (routeOutput === null || routeOutput === undefined) {
113
+ // const output = Readable.from(
114
+ // concatStreams(baseDocRenderStreamPre, baseDocRenderStreamPost),
115
+ // );
116
+ // return { output };
117
+ // }
105
118
  if (isLitTemplate(routeOutput) === false)
106
119
  throw Error(`Wrong template result for page template ${routeInfos.foundRoute.filePath}.`);
107
120
  const renderStream = Readable.from(renderLitSsr(routeOutput));
@@ -1 +1 @@
1
- {"version":3,"file":"collect.d.ts","sourceRoot":"","sources":["../../src/routes/collect.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,KAAK,CAAC,MAAM,YAAY,CAAC;AA4DrC,wBAAsB,aAAa,CAClC,IAAI,EAAE,MAAM,GACV,OAAO,CAAC,CAAC,CAAC,cAAc,CAAC,CAkF3B"}
1
+ {"version":3,"file":"collect.d.ts","sourceRoot":"","sources":["../../src/routes/collect.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,KAAK,CAAC,MAAM,YAAY,CAAC;AA4DrC,wBAAsB,aAAa,CAClC,IAAI,EAAE,MAAM,GAEV,OAAO,CAAC,CAAC,CAAC,cAAc,CAAC,CA8F3B"}
@@ -1,16 +1,15 @@
1
- import path, { join, relative } from 'node:path';
1
+ import { join } from 'node:path';
2
2
  import { logger } from '@gracile/internal-utils/logger';
3
3
  import * as paths from '@gracile/internal-utils/paths';
4
- import fastGlob from 'fast-glob';
4
+ import { fdir as Fdir } from 'fdir';
5
5
  import c from 'picocolors';
6
6
  import { URLPattern } from 'urlpattern-polyfill/urlpattern';
7
+ import { createFilter } from 'vite';
7
8
  // import type { ViteDevServer } from 'vite';
8
9
  import { prepareSortableRoutes, routeComparator } from './comparator.js';
9
10
  import { REGEXES } from './load-module.js';
10
- function extractRoutePatterns(absoluteFilePath) {
11
- const routePathname = path
12
- .relative('src/routes', paths.relativeToProject(absoluteFilePath))
13
- .replace(/\.[j|t]s$/, '');
11
+ function extractRoutePatterns(routeFilePath) {
12
+ const routePathname = routeFilePath.replace(/\.[j|t]s$/, '');
14
13
  let pathParts = routePathname.split(process.platform === 'win32' ? '\\' : '/');
15
14
  const last = pathParts.at(-1);
16
15
  if (typeof last === 'undefined')
@@ -23,8 +22,9 @@ function extractRoutePatterns(absoluteFilePath) {
23
22
  pathParts.pop();
24
23
  if (pathParts.length === 1 && pathParts.at(0) === 'index')
25
24
  pathParts = [];
26
- if (pathParts.length === 1 && pathParts.at(0) === '404')
27
- pathParts = ['__404'];
25
+ // NOTE: Disabled for now, but might be useful later
26
+ // if (pathParts.length === 1 && pathParts.at(0) === '404')
27
+ // pathParts = ['__404'];
28
28
  let hasParams = false;
29
29
  const pathRelNorm = pathParts.map((pathEntry) => {
30
30
  let entry = pathEntry;
@@ -51,26 +51,37 @@ function extractRoutePatterns(absoluteFilePath) {
51
51
  const routes = new Map();
52
52
  export async function collectRoutes(root /* vite: ViteDevServer */) {
53
53
  routes.clear();
54
- const serverEntrypoints = await fastGlob([
55
- 'src/routes/**/*.{js,ts}',
56
- '!**/src/routes/**/*.client.{js,ts}',
57
- '!**/src/routes/**/*.document.{js,ts}',
58
- '!**/src/routes/**/_*/**',
59
- '!**/src/routes/**/_*',
60
- ], { ignore: [], cwd: root, absolute: true });
54
+ const routesFolder = 'src/routes';
55
+ const routesFolderAbsolute = join(root, routesFolder);
56
+ // relative(routesFolderAbsolute, file);
57
+ const allFilesInRoutes = await new Fdir()
58
+ .withRelativePaths()
59
+ .crawl(routesFolderAbsolute)
60
+ .withPromise();
61
+ // console.log({ allFilesInRoutes });
62
+ const serverEntrypointsFilter = createFilter(['**/*.{js,ts}'], [
63
+ //
64
+ '**/*.client.{js,ts}',
65
+ '**/*.document.{js,ts}',
66
+ '**/_*/**',
67
+ '**/_*',
68
+ '**/.*',
69
+ ]);
70
+ const serverEntrypoints = allFilesInRoutes.filter((f) => serverEntrypointsFilter(f));
61
71
  // MARK: Routes priority order
72
+ // TODO: `prepareSortableRoutes` and `routeComparator` in same function `sortRoutes`
62
73
  const serverEntrypointsSorted = prepareSortableRoutes(serverEntrypoints)
63
74
  .sort((a, b) => routeComparator(a, b))
64
75
  .map((r) => r.route);
65
- const serverPageClientAssets = await fastGlob([
66
- //
67
- 'src/routes/**/*.{css,scss}',
68
- 'src/routes/**/*.client.{js,ts}',
69
- ], { ignore: [], cwd: root, absolute: true });
76
+ const serverPageClientAssetsFilter = createFilter([
77
+ '**/*.client.{js,ts}',
78
+ '**/*.{css,scss,sass,less,styl,stylus}',
79
+ ]);
80
+ const serverPageClientAssets = allFilesInRoutes.filter((f) => serverPageClientAssetsFilter(f));
70
81
  logger.info(`\n${c.underline(`Found ${c.bold('routes')}`)}:\n` +
71
82
  `${c.dim('- ')}${serverEntrypointsSorted
72
83
  .map((f) => {
73
- const pathParts = relative(join(root, 'src/routes'), f).split('/');
84
+ const pathParts = f.split('/');
74
85
  return pathParts
75
86
  .map((part, index) => {
76
87
  if (part.match(/\[\./))
@@ -87,10 +98,11 @@ export async function collectRoutes(root /* vite: ViteDevServer */) {
87
98
  })
88
99
  .join(c.dim('\n- '))}\n`);
89
100
  // MARK: Associate
90
- serverEntrypointsSorted.forEach((filePath) => {
91
- const routeWithPatterns = extractRoutePatterns(filePath);
101
+ serverEntrypointsSorted.forEach((routePath) => {
102
+ const filePath = join(routesFolder, routePath);
103
+ const routeWithPatterns = extractRoutePatterns(routePath);
92
104
  routes.set(routeWithPatterns.patternString, {
93
- filePath: paths.relativeToProject(filePath),
105
+ filePath,
94
106
  pattern: routeWithPatterns.pattern,
95
107
  hasParams: routeWithPatterns.hasParams,
96
108
  pageAssets: [],
@@ -98,15 +110,12 @@ export async function collectRoutes(root /* vite: ViteDevServer */) {
98
110
  // prerender: null,
99
111
  });
100
112
  });
101
- serverPageClientAssets.forEach((filePath) => {
113
+ serverPageClientAssets.forEach((routePath) => {
102
114
  // NOTE: Exact extension needed client side by Vite.
103
- const assetPathWithExt = paths.relativeToProject(filePath);
104
- const associatedRoutePath = assetPathWithExt.replace(/\.(.*)$/,
105
- // FIXME: Don't need this anymore?
106
- (_a, b) => `.${String(b)}`);
115
+ const assetPathWithExt = join(routesFolder, routePath);
107
116
  routes.forEach((route) => {
108
117
  if (paths.removeAllExt(route.filePath) ===
109
- paths.removeAllExt(associatedRoutePath))
118
+ paths.removeAllExt(assetPathWithExt))
110
119
  route.pageAssets.push(assetPathWithExt);
111
120
  });
112
121
  });
@@ -16,7 +16,7 @@ function matchRouteFromUrl(url, routes) {
16
16
  }
17
17
  if (!match || !foundRoute)
18
18
  throw new Error(`No route matching for ${url}`, { cause: 404 });
19
- const params = match.pathname?.groups;
19
+ const params = Object.freeze({ ...match.pathname.groups });
20
20
  return { match, foundRoute, params, pathname };
21
21
  }
22
22
  function extractStaticPaths(options) {
@@ -15,7 +15,6 @@ export declare const RequestMethod: {
15
15
  };
16
16
  export type ModuleOptions = {
17
17
  staticPaths?: StaticPathsGeneric;
18
- locals?: (locals: any) => any;
19
18
  handler?: HandlerGeneric;
20
19
  prerender?: boolean | undefined;
21
20
  document?: DocumentTemplate<RouteContextGeneric>;
@@ -24,15 +23,15 @@ export type ModuleOptions = {
24
23
  export declare class RouteModule {
25
24
  #private;
26
25
  get staticPaths(): StaticPathsGeneric | undefined;
27
- get locals(): ((locals: any) => any) | undefined;
28
- get handler(): Handler<object | Response | undefined, any> | Partial<Record<MethodHtml, Handler<object | Response | undefined, any>> & Record<MethodNonHtml, Handler<Response, any>>> | undefined;
26
+ get locals(): {};
27
+ get handler(): Handler<object | Response | undefined> | Partial<Record<MethodHtml, Handler<object | Response | undefined>> & Record<MethodNonHtml, Handler<Response>>> | undefined;
29
28
  get document(): DocumentTemplate<RouteContextGeneric> | undefined;
30
29
  get prerender(): boolean | undefined;
31
30
  get template(): ((context: RouteContextGeneric) => RouteTemplateResult) | undefined;
32
31
  constructor(options: ModuleOptions);
33
32
  }
34
33
  export type Params = Record<string, string | undefined>;
35
- export type Handler<Data extends HandlerData | HandlerDataHtml = never, Locals = any> = (context: {
34
+ export type Handler<Data extends HandlerData | HandlerDataHtml = never> = (context: {
36
35
  url: URL;
37
36
  /**
38
37
  * Parameters from dynamic route.
@@ -41,7 +40,7 @@ export type Handler<Data extends HandlerData | HandlerDataHtml = never, Locals =
41
40
  */
42
41
  params: Params;
43
42
  request: Request;
44
- locals?: Locals;
43
+ locals: App.Locals;
45
44
  /**
46
45
  * Let you mutate the downstream **page** response.
47
46
  *
@@ -1 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Paths;
16
15
  get staticPaths() {
@@ -43,7 +42,7 @@ export class RouteModule {
43
42
  typeof options.handler === 'function') &&
44
43
  options.handler)
45
44
  this.#handler = options.handler;
46
- this.#locals = options.locals;
45
+ this.#locals = {};
47
46
  if (typeof options.template === 'function')
48
47
  this.#template = options.template;
49
48
  if (typeof options.document === 'function')
@@ -1,5 +1,6 @@
1
1
  export declare const IP_LOCALHOST = "127.0.0.1";
2
2
  export declare const IP_EXPOSED = "0.0.0.0";
3
3
  export declare const RANDOM_PORT = 0;
4
- export declare const PUBLIC_DIR: "public" | "./dist/client";
4
+ export declare const PUBLIC_DIR = "public";
5
+ export declare const CLIENT_DIST_DIR = "./dist/client";
5
6
  //# sourceMappingURL=env.d.ts.map
@@ -1 +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"}
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;AAK7B,eAAO,MAAM,UAAU,WAAW,CAAC;AACnC,eAAO,MAAM,eAAe,kBAAkB,CAAC"}
@@ -1,6 +1,8 @@
1
1
  export const IP_LOCALHOST = '127.0.0.1';
2
2
  export const IP_EXPOSED = '0.0.0.0';
3
3
  export const RANDOM_PORT = 0;
4
- export const PUBLIC_DIR = import.meta.env?.DEV
5
- ? 'public'
6
- : './dist/client';
4
+ // export const PUBLIC_DIR = import.meta.env?.DEV
5
+ // ? ('public' as const)
6
+ // : ('./dist/client' as const);
7
+ export const PUBLIC_DIR = 'public';
8
+ export const CLIENT_DIST_DIR = './dist/client';
@@ -8,7 +8,7 @@ type NextFunction = (error?: unknown) => void | Promise<void>;
8
8
  * 1. Async.
9
9
  * 2. Can return a `ServerResponse`
10
10
  */
11
- export type ConnectLikeAsyncMiddleware = (req: IncomingMessage, res: ServerResponse, next: NextFunction) => Promise<void | NextFunction | ServerResponse> | (void | NextFunction | ServerResponse);
11
+ export type ConnectLikeAsyncMiddleware = (req: IncomingMessage, res: ServerResponse, next: NextFunction, locals?: unknown) => Promise<void | NextFunction | ServerResponse> | (void | NextFunction | ServerResponse);
12
12
  export declare function createGracileMiddleware({ vite, routes, routeImports, routeAssets, root, serverMode, }: {
13
13
  vite?: ViteDevServer | undefined;
14
14
  routes: R.RoutesManifest;
@@ -1 +1 @@
1
- {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/server/request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAMjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAS1C,OAAO,KAAK,KAAK,CAAC,MAAM,oBAAoB,CAAC;AAE7C,KAAK,YAAY,GAAG,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,MAAM,0BAA0B,GAAG,CACxC,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,cAAc,EACnB,IAAI,EAAE,YAAY,KAEjB,OAAO,CAAC,IAAI,GAAG,YAAY,GAAG,cAAc,CAAC,GAE5C,CAAC,IAAI,GAAG,YAAY,GAAG,cAAc,CAAC,CAAC;AAM1C,wBAAgB,uBAAuB,CAAC,EACvC,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,CA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