@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.
Files changed (70) hide show
  1. package/ambient.d.ts +6 -0
  2. package/dist/assertions.d.ts +1 -1
  3. package/dist/assertions.d.ts.map +1 -1
  4. package/dist/build/static.d.ts +11 -2
  5. package/dist/build/static.d.ts.map +1 -1
  6. package/dist/build/static.js +28 -15
  7. package/dist/dev/dev.d.ts +5 -2
  8. package/dist/dev/dev.d.ts.map +1 -1
  9. package/dist/dev/dev.js +14 -7
  10. package/dist/dev/server.d.ts +22 -2
  11. package/dist/dev/server.d.ts.map +1 -1
  12. package/dist/dev/server.js +49 -22
  13. package/dist/preview.d.ts +1 -1
  14. package/dist/preview.d.ts.map +1 -1
  15. package/dist/preview.js +3 -0
  16. package/dist/render/route-template.d.ts +14 -3
  17. package/dist/render/route-template.d.ts.map +1 -1
  18. package/dist/render/route-template.js +42 -14
  19. package/dist/render/utils.d.ts.map +1 -0
  20. package/dist/routes/collect.d.ts +2 -3
  21. package/dist/routes/collect.d.ts.map +1 -1
  22. package/dist/routes/collect.js +4 -1
  23. package/dist/routes/load-module.d.ts +5 -1
  24. package/dist/routes/load-module.d.ts.map +1 -1
  25. package/dist/routes/load-module.js +13 -4
  26. package/dist/routes/match.d.ts +4 -2
  27. package/dist/routes/match.d.ts.map +1 -1
  28. package/dist/routes/match.js +9 -6
  29. package/dist/routes/route.d.ts +7 -1
  30. package/dist/routes/route.d.ts.map +1 -1
  31. package/dist/routes/route.js +6 -1
  32. package/dist/server/env.d.ts +5 -0
  33. package/dist/server/env.d.ts.map +1 -0
  34. package/dist/server/env.js +6 -0
  35. package/dist/server/request.d.ts +12 -0
  36. package/dist/server/request.d.ts.map +1 -0
  37. package/dist/{dev → server}/request.js +32 -12
  38. package/dist/server/server.d.ts +4 -0
  39. package/dist/server/server.d.ts.map +1 -0
  40. package/dist/server/server.js +26 -0
  41. package/dist/server/utils.d.ts +3 -0
  42. package/dist/server/utils.d.ts.map +1 -0
  43. package/dist/server/utils.js +21 -0
  44. package/dist/tsconfig.tsbuildinfo +1 -1
  45. package/dist/user-config.d.ts +11 -0
  46. package/dist/user-config.d.ts.map +1 -1
  47. package/dist/user-config.js +9 -0
  48. package/dist/vite/build.d.ts.map +1 -1
  49. package/dist/vite/build.js +82 -7
  50. package/dist/vite/config.d.ts +2 -0
  51. package/dist/vite/config.d.ts.map +1 -1
  52. package/dist/vite/config.js +11 -1
  53. package/dist/vite/plugins/build-routes.d.ts +28 -0
  54. package/dist/vite/plugins/build-routes.d.ts.map +1 -0
  55. package/dist/vite/plugins/build-routes.js +98 -0
  56. package/dist/vite/plugins/virtual-routes.d.ts +11 -0
  57. package/dist/vite/plugins/virtual-routes.d.ts.map +1 -0
  58. package/dist/vite/plugins/virtual-routes.js +42 -0
  59. package/dist/vite/server.d.ts +4 -1
  60. package/dist/vite/server.d.ts.map +1 -1
  61. package/dist/vite/server.js +5 -3
  62. package/package.json +11 -12
  63. package/dist/dev/request.d.ts +0 -4
  64. package/dist/dev/request.d.ts.map +0 -1
  65. package/dist/vite/plugins/html-static-pages.d.ts +0 -13
  66. package/dist/vite/plugins/html-static-pages.d.ts.map +0 -1
  67. package/dist/vite/plugins/html-static-pages.js +0 -58
  68. package/dist/vite/utils.d.ts.map +0 -1
  69. /package/dist/{vite → render}/utils.d.ts +0 -0
  70. /package/dist/{vite → render}/utils.js +0 -0
@@ -0,0 +1,28 @@
1
+ import { type ViteDevServer } from 'vite';
2
+ import type { GracileConfig } from '../../user-config.js';
3
+ export declare const buildRoutes: ({ viteServerForBuild, root, _config, serverMode, }: {
4
+ viteServerForBuild: ViteDevServer;
5
+ root: string;
6
+ _config: GracileConfig;
7
+ serverMode?: boolean;
8
+ }) => Promise<{
9
+ routes: import("../../routes/route.js").RoutesManifest;
10
+ renderedRoutes: import("../../build/static.js").RenderedRouteDefinition[];
11
+ inputList: string[];
12
+ plugin: ({
13
+ name: string;
14
+ apply: "build";
15
+ enforce: "pre";
16
+ resolveId(this: import("rollup").PluginContext, id: string): string | null;
17
+ load(this: import("rollup").PluginContext, id: string): string | null;
18
+ generateBundle?: never;
19
+ } | {
20
+ name: string;
21
+ enforce: "post";
22
+ generateBundle(this: import("rollup").PluginContext, _: import("rollup").NormalizedOutputOptions, bundle: import("rollup").OutputBundle): void;
23
+ apply?: never;
24
+ resolveId?: never;
25
+ load?: never;
26
+ })[];
27
+ }>;
28
+ //# sourceMappingURL=build-routes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-routes.d.ts","sourceRoot":"","sources":["../../../src/vite/plugins/build-routes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,aAAa,EAAE,MAAM,MAAM,CAAC;AAOvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,eAAO,MAAM,WAAW,uDAKrB;IACF,kBAAkB,EAAE,aAAa,CAAC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,aAAa,CAAC;IACvB,UAAU,CAAC,EAAE,OAAO,CAAC;CACrB;;;;;;;;;;;;;;;;;;;EA2GA,CAAC"}
@@ -0,0 +1,98 @@
1
+ import {} from 'vite';
2
+ import { renderRoutes } from '../../build/static.js';
3
+ import { REGEX_TAG_LINK, REGEX_TAG_SCRIPT, } from '../../render/route-template.js';
4
+ export const buildRoutes = async ({ viteServerForBuild, root, _config, serverMode = false, }) => {
5
+ const { renderedRoutes, routes } = await renderRoutes({
6
+ vite: viteServerForBuild,
7
+ serverMode,
8
+ root,
9
+ });
10
+ const inputList = renderedRoutes.map((input) => input.name);
11
+ return {
12
+ routes,
13
+ renderedRoutes,
14
+ inputList,
15
+ plugin: [
16
+ {
17
+ name: 'gracile-html-routes',
18
+ apply: 'build',
19
+ enforce: 'pre',
20
+ // config() {
21
+ // return {
22
+ // build: { rollupOptions: { input: inputList } },
23
+ // };
24
+ // },
25
+ // NOTE: NOT WORKING. Must be done in the config, before.
26
+ // config: {
27
+ // order: 'pre',
28
+ // handler(config) {
29
+ // if (config.build?.rollupOptions) {
30
+ // // eslint-disable-next-line no-param-reassign
31
+ // }
32
+ // // eslint-disable-next-line no-param-reassign
33
+ // config.build ||= {};
34
+ // // eslint-disable-next-line no-param-reassign
35
+ // config.build.rollupOptions ||= {};
36
+ // // eslint-disable-next-line no-param-reassign
37
+ // config.build.rollupOptions.input = inputList;
38
+ // return {
39
+ // build: { rollupOptions: { input: inputList } },
40
+ // };
41
+ // // return
42
+ // },
43
+ // },
44
+ resolveId(id) {
45
+ if (id.endsWith('.html')) {
46
+ const input = renderedRoutes.find((i) => i.name === id);
47
+ return input ? input.absoluteId : null;
48
+ }
49
+ return null;
50
+ },
51
+ load(id) {
52
+ if (id.endsWith('.html')) {
53
+ const content = renderedRoutes.find((i) => i.absoluteId === id)?.html;
54
+ if (content)
55
+ return content;
56
+ }
57
+ return null;
58
+ },
59
+ },
60
+ {
61
+ name: 'gracile-collect-handler-assets',
62
+ enforce: 'post',
63
+ generateBundle(_, bundle) {
64
+ if (serverMode === false)
65
+ return;
66
+ // eslint-disable-next-line no-restricted-syntax, guard-for-in
67
+ for (const fileKey in bundle) {
68
+ const file = bundle[fileKey];
69
+ if (fileKey.endsWith('.html') && file && 'source' in file) {
70
+ const source = file.source.toString();
71
+ const collectedAssets = [
72
+ ...[...source.matchAll(REGEX_TAG_SCRIPT)]
73
+ .map((v) => v[0])
74
+ // NOTE: Too brittle
75
+ .filter((v) => v.includes(`type="module"`)),
76
+ ...[...source.matchAll(REGEX_TAG_LINK)]
77
+ .map((v) => v[0])
78
+ // NOTE: Too brittle
79
+ .filter((v) => /rel="(stylesheet|modulepreload)"/.test(v)),
80
+ ].join('\n');
81
+ // NOTE: Not used (for now?)
82
+ // file.source = alteredContent;
83
+ const route = renderedRoutes.find((r) => {
84
+ return r.name === fileKey;
85
+ });
86
+ if (route) {
87
+ route.handlerAssets = collectedAssets;
88
+ }
89
+ if (route?.savePrerender !== true)
90
+ // eslint-disable-next-line no-param-reassign, @typescript-eslint/no-dynamic-delete
91
+ delete bundle[fileKey];
92
+ }
93
+ }
94
+ },
95
+ },
96
+ ],
97
+ };
98
+ };
@@ -0,0 +1,11 @@
1
+ import type { RenderedRouteDefinition } from '../../build/static.js';
2
+ import type { RoutesManifest } from '../../routes/route.js';
3
+ export declare function virtualRoutes({ routes, renderedRoutes, }: {
4
+ routes: RoutesManifest;
5
+ renderedRoutes: RenderedRouteDefinition[];
6
+ }): {
7
+ name: string;
8
+ resolveId(this: import("rollup").PluginContext, id: string): "\0gracile:routes" | null;
9
+ load(this: import("rollup").PluginContext, id: string): string | null;
10
+ }[];
11
+ //# sourceMappingURL=virtual-routes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"virtual-routes.d.ts","sourceRoot":"","sources":["../../../src/vite/plugins/virtual-routes.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,wBAAgB,aAAa,CAAC,EAE7B,MAAM,EACN,cAAc,GACd,EAAE;IAEF,MAAM,EAAE,cAAc,CAAC;IACvB,cAAc,EAAE,uBAAuB,EAAE,CAAC;CAC1C;;;;IAkDA"}
@@ -0,0 +1,42 @@
1
+ export function virtualRoutes({
2
+ // root,
3
+ routes, renderedRoutes, }) {
4
+ const virtualModuleId = 'gracile:routes';
5
+ const resolvedVirtualModuleId = `\0${virtualModuleId}`;
6
+ return [
7
+ {
8
+ name: 'gracile-server-routes',
9
+ resolveId(id) {
10
+ if (id === virtualModuleId) {
11
+ return resolvedVirtualModuleId;
12
+ }
13
+ return null;
14
+ },
15
+ load(id) {
16
+ if (id === resolvedVirtualModuleId) {
17
+ return `
18
+ const routes = new Map(${JSON.stringify([...routes], null, 2)})
19
+
20
+ const routeImports = new Map(
21
+ [
22
+ ${[...routes]
23
+ .map(([pattern, route]) => `['${pattern}', () => import('/${route.filePath}')],`)
24
+ .join('\n ')}
25
+ ]
26
+ );
27
+
28
+ const routeAssets = new Map(${JSON.stringify([
29
+ ...renderedRoutes.map((r) => [
30
+ `/${r.name.replace(/index\.html$/, '')}`,
31
+ r.handlerAssets,
32
+ ]),
33
+ ], null, 2)});
34
+
35
+ export { routes, routeImports, routeAssets };
36
+ `;
37
+ }
38
+ return null;
39
+ },
40
+ },
41
+ ];
42
+ }
@@ -1,3 +1,6 @@
1
- export declare function createViteServer(root: string, mode: 'dev' | 'build'): Promise<import("vite").ViteDevServer>;
1
+ export declare function createViteServer(root: string, mode: 'dev' | 'build'): Promise<{
2
+ vite: import("vite").ViteDevServer;
3
+ gracileConfig: import("../user-config.js").GracileConfig | null;
4
+ }>;
2
5
  export declare function vitePreview(port?: number, expose?: boolean | undefined): Promise<void>;
3
6
  //# sourceMappingURL=server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/vite/server.ts"],"names":[],"mappings":"AAKA,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,GAAG,OAAO,yCAQzE;AAED,wBAAsB,WAAW,CACX,IAAI,SAAO,EAChC,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,iBAQ5B"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/vite/server.ts"],"names":[],"mappings":"AAKA,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,GAAG,OAAO;;;GAWzE;AAED,wBAAsB,WAAW,CAGhC,IAAI,SAAO,EACX,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,iBAQ5B"}
@@ -2,14 +2,16 @@ import { createServer, preview } from 'vite';
2
2
  import { getConfigs } from './config.js';
3
3
  // NOTE: Can be used for dev. and for assisting build
4
4
  export async function createViteServer(root, mode) {
5
- const { finalCommonConfigVite } = await getConfigs(root, mode);
5
+ const { finalCommonConfigVite, userConfigGracile } = await getConfigs(root, mode);
6
6
  const vite = await createServer(finalCommonConfigVite);
7
7
  // TODO: print url even if in middleware mode
8
8
  // if (mode === 'dev') vite.printUrls();
9
- return vite;
9
+ return { vite, gracileConfig: userConfigGracile };
10
10
  }
11
11
  export async function vitePreview(
12
- /* _root: string, */ port = 9091, expose) {
12
+ /* _root: string, */
13
+ //
14
+ port = 9091, expose) {
13
15
  const previewer = await preview({
14
16
  appType: 'mpa',
15
17
  preview: { port, host: expose || false },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gracile/engine",
3
- "version": "0.0.4-next.3+de03482",
4
- "description": "A thin, full-stack, web framework",
3
+ "version": "0.0.4-next.34+b2b6452",
4
+ "description": "A thin, full-stack, web framework.\nPowered by Vite and Lit SSR.",
5
5
  "keywords": [
6
6
  "full-stack",
7
7
  "meta-framework",
@@ -31,6 +31,11 @@
31
31
  "./*": "./dist/*.js",
32
32
  "./ambient": {
33
33
  "types": "./ambient.d.ts"
34
+ },
35
+ "./server": {
36
+ "types": "./dist/dev/server.js",
37
+ "development": "./dist/dev/server.js",
38
+ "default": "./dist/server/server.js"
34
39
  }
35
40
  },
36
41
  "files": [
@@ -39,10 +44,10 @@
39
44
  ],
40
45
  "dependencies": {
41
46
  "@gracile/client": "^0.0.3",
42
- "@gracile/internal-utils": "^0.0.4-next.3+de03482",
47
+ "@gracile/internal-utils": "^0.0.3",
43
48
  "@whatwg-node/server": "^0.9.25",
44
49
  "esm-env": "^1.0.0",
45
- "express": "^4.19.2",
50
+ "express": "4.x.x",
46
51
  "fast-glob": "^3.3.2",
47
52
  "picocolors": "^1.0.0",
48
53
  "urlpattern-polyfill": "^10.0.0",
@@ -51,18 +56,12 @@
51
56
  "peerDependencies": {
52
57
  "@lit-labs/ssr": "3.x",
53
58
  "@lit-labs/ssr-client": "1.x",
54
- "lit": "3.x",
55
- "sass": "^1.x.x"
59
+ "lit": "3.x"
56
60
  },
57
61
  "publishConfig": {
58
62
  "access": "public",
59
63
  "provenance": true
60
64
  },
61
- "peerDependenciesMeta": {
62
- "sass": {
63
- "optional": true
64
- }
65
- },
66
65
  "// disabledDeps": {
67
66
  "rollup-plugin-typescript2": "^0.36.0",
68
67
  "@types/compression": "^1.7.5",
@@ -80,5 +79,5 @@
80
79
  "vite-plugin-standard-css-modules": "^0.0.10",
81
80
  "vite-plugin-web-components-hmr-local": "link:../../../../../__forks/vite-plugin-web-components-hmr/packages/dev-server-hmr"
82
81
  },
83
- "gitHead": "de03482a22df4d131c7baa2c2f439c9a92597629"
82
+ "gitHead": "b2b645252bbaf46a657d7e6002e0a6a54af00f81"
84
83
  }
@@ -1,4 +0,0 @@
1
- import type { NextFunction, Request as ExpressRequest, Response as ExpressResponse } from 'express';
2
- import type { ViteDevServer } from 'vite';
3
- export declare function createDevRequestHandler(vite: ViteDevServer): (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => Promise<void | ExpressResponse<any, Record<string, any>>>;
4
- //# sourceMappingURL=request.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/dev/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;AAc1C,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,aAAa,SAEpD,cAAc,OACd,eAAe,QACd,YAAY,+DA+LnB"}
@@ -1,13 +0,0 @@
1
- import { type ViteDevServer } from 'vite';
2
- import type { GracileConfig } from '../../user-config.js';
3
- export declare const htmlStaticPages: (viteServerForBuild: ViteDevServer, root: string, _config: GracileConfig) => Promise<{
4
- inputList: string[];
5
- plugin: {
6
- name: string;
7
- apply: "build";
8
- enforce: "pre";
9
- resolveId(this: import("rollup").PluginContext, id: string): string | null;
10
- load(this: import("rollup").PluginContext, id: string): string | null;
11
- }[];
12
- }>;
13
- //# sourceMappingURL=html-static-pages.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"html-static-pages.d.ts","sourceRoot":"","sources":["../../../src/vite/plugins/html-static-pages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,aAAa,EAAE,MAAM,MAAM,CAAC;AAGvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,eAAO,MAAM,eAAe,uBACP,aAAa,QAC3B,MAAM,WACH,aAAa;;;;;;;;;EA8DtB,CAAC"}
@@ -1,58 +0,0 @@
1
- import {} from 'vite';
2
- import { renderRoutes } from '../../build/static.js';
3
- export const htmlStaticPages = async (viteServerForBuild, root, _config) => {
4
- const inputs = await renderRoutes(viteServerForBuild, root);
5
- const inputList = inputs.map((input) => input.name);
6
- return {
7
- inputList,
8
- plugin: [
9
- {
10
- name: 'gracile-html-inputs',
11
- apply: 'build',
12
- enforce: 'pre',
13
- // config() {
14
- // return {
15
- // build: { rollupOptions: { input: inputList } },
16
- // };
17
- // },
18
- // NOTE WORKING. Must be done in the config, before.
19
- // config: {
20
- // order: 'pre',
21
- // handler(config) {
22
- // if (config.build?.rollupOptions) {
23
- // // eslint-disable-next-line no-param-reassign
24
- // }
25
- // // eslint-disable-next-line no-param-reassign
26
- // config.build ||= {};
27
- // // eslint-disable-next-line no-param-reassign
28
- // config.build.rollupOptions ||= {};
29
- // // eslint-disable-next-line no-param-reassign
30
- // config.build.rollupOptions.input = inputList;
31
- // return {
32
- // build: { rollupOptions: { input: inputList } },
33
- // };
34
- // // return
35
- // },
36
- // },
37
- resolveId(id) {
38
- if (id.endsWith('.html')) {
39
- // console.log({ id });
40
- const input = inputs.find((i) => i.name === id);
41
- return input ? input.absoluteId : null;
42
- }
43
- return null;
44
- },
45
- load(id) {
46
- if (id.endsWith('.html')) {
47
- const content = inputs.find((i) => i.absoluteId === id)?.html;
48
- if (content) {
49
- // console.log({ content });
50
- return content;
51
- }
52
- }
53
- return null;
54
- },
55
- },
56
- ],
57
- };
58
- };
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/vite/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,KAAK,sBAAsB,EAC3B,MAAM,eAAe,CAAC;AAGvB,wBAAsB,iBAAiB,CAAC,QAAQ,EAAE,sBAAsB,mBAEvE"}
File without changes
File without changes