@sigil-dev/grimoire 0.9.1 → 0.9.3
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/index.ts +35 -35
- package/package.json +9 -8
- package/preload.js +3 -3
- package/server.ts +19 -19
- package/src/client/deps.ts +13 -7
- package/src/client/enhance.ts +98 -98
- package/src/client/head.ts +30 -30
- package/src/client/index.ts +2 -2
- package/src/client/router.ts +445 -371
- package/src/client/scope.ts +22 -22
- package/src/dev/compile-module.ts +163 -163
- package/src/dev/effect-registry.ts +23 -23
- package/src/dev/graph.ts +114 -114
- package/src/dev/hmr-client.ts +185 -185
- package/src/dev/loader.ts +47 -47
- package/src/dev/paths.ts +14 -14
- package/src/dev/runtime-bundle.ts +52 -52
- package/src/dev/watcher.ts +47 -46
- package/src/env/dynamic-private.ts +19 -19
- package/src/env/dynamic-public.ts +22 -22
- package/src/env/index.ts +25 -25
- package/src/env/plugin.ts +19 -19
- package/src/env/private.ts +5 -5
- package/src/env/public.ts +7 -7
- package/src/env/typegen.ts +61 -61
- package/src/headers.ts +114 -114
- package/src/integrations/vite.ts +73 -73
- package/src/logger/index.ts +4 -4
- package/src/logger/instance.ts +6 -6
- package/src/logger/logger.ts +113 -113
- package/src/logger/request-middleware.ts +24 -24
- package/src/logger/transports.ts +117 -117
- package/src/logger/types.ts +39 -39
- package/src/rendering/head.ts +47 -47
- package/src/rendering/hydrate.ts +98 -79
- package/src/rendering/index.ts +455 -372
- package/src/rendering/ssrPlugin.ts +69 -69
- package/src/routing/manifest-gen.ts +12 -11
- package/src/routing/router.ts +109 -109
- package/src/routing/scanner.ts +141 -141
- package/src/routing/transform-routes.ts +102 -102
- package/src/sentinels/error.ts +52 -52
- package/src/sentinels/fail.ts +41 -41
- package/src/sentinels/redirect.ts +35 -35
- package/src/server/build.ts +243 -219
- package/src/server/context.ts +10 -10
- package/src/server/cookie-utils.ts +66 -66
- package/src/server/coordinator.ts +364 -356
- package/src/server/hooks.ts +114 -114
- package/src/server/index.ts +655 -658
- package/src/server/interactive.ts +56 -56
- package/src/server/plugins.ts +121 -120
- package/src/server/worker.ts +58 -58
- package/src/typegen/index.ts +356 -356
- package/src/types.ts +4 -4
- package/test/client-router.test.ts +37 -31
- package/test/context.test.ts +52 -52
- package/test/env.test.ts +70 -70
- package/test/exports.test.ts +37 -37
- package/test/fail.test.ts +46 -46
- package/test/headers.test.ts +100 -100
- package/test/hydration.test.ts +119 -119
- package/test/middleware.test.ts +223 -223
- package/test/preload.ts +5 -5
- package/test/redirect-error.test.ts +112 -112
- package/test/rendering.test.ts +615 -579
- package/test/routing.test.ts +81 -81
- package/test/scanning.test.ts +200 -200
- package/test/scope.test.ts +195 -195
- package/test/server.test.ts +249 -249
- package/test/streaming.test.ts +125 -125
- package/test/transform-routes.test.ts +84 -84
- package/test/typegen.test.ts +682 -682
- package/tsconfig.json +10 -10
- package/.grimoire/_routes.dom.js +0 -8
- package/.grimoire/_routes.hydrate.js +0 -8
- package/.grimoire/tsconfig.generated.json +0 -11
- package/.grimoire/types/ambient.d.ts +0 -59
- package/.grimoire/types/api/hello/$types.d.ts +0 -50
- package/.grimoire/types/api/items/$types.d.ts +0 -50
- package/.grimoire/types/echo/$types.d.ts +0 -50
- package/.grimoire/types/env-private.d.ts +0 -5
- package/.grimoire/types/env-public.d.ts +0 -5
- package/.grimoire/types/mixed/$types.d.ts +0 -50
- package/.grimoire/types/params/[docId]/$types.d.ts +0 -52
- package/.grimoire/types/reject/$types.d.ts +0 -50
- package/public/__grimoire__/hydrate.js +0 -585
- package/public/__grimoire__/index.js +0 -490
package/test/streaming.test.ts
CHANGED
|
@@ -1,125 +1,125 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test";
|
|
2
|
-
import { renderRoute } from "../src/rendering";
|
|
3
|
-
|
|
4
|
-
function makeMatched(path: string, filePath: string, params = {}) {
|
|
5
|
-
return {
|
|
6
|
-
route: { path, params: {}, filePath },
|
|
7
|
-
params,
|
|
8
|
-
layouts: [],
|
|
9
|
-
layoutServers: [],
|
|
10
|
-
} as any;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
describe("Streaming SSR", () => {
|
|
14
|
-
test("returns a ReadableStream response", async () => {
|
|
15
|
-
const matched = makeMatched(
|
|
16
|
-
"/",
|
|
17
|
-
"data:text/javascript,export default (p) => '<div>hello</div>'",
|
|
18
|
-
);
|
|
19
|
-
const res = await renderRoute(matched, new Request("http://localhost/"));
|
|
20
|
-
expect(res.body).toBeInstanceOf(ReadableStream);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
test("stream contains full HTML document", async () => {
|
|
24
|
-
const matched = makeMatched(
|
|
25
|
-
"/test",
|
|
26
|
-
"data:text/javascript,export default (p) => '<p>streaming works</p>'",
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
const res = await renderRoute(
|
|
30
|
-
matched,
|
|
31
|
-
new Request("http://localhost/test"),
|
|
32
|
-
);
|
|
33
|
-
const html = await res.text();
|
|
34
|
-
|
|
35
|
-
expect(html).toContain("<!DOCTYPE html>");
|
|
36
|
-
expect(html).toContain('<meta charset="UTF-8" />');
|
|
37
|
-
expect(html).toContain("streaming works");
|
|
38
|
-
expect(html).toContain("</html>");
|
|
39
|
-
expect(html).toContain("__grimoire_state__");
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
test("stream includes state JSON with route pattern", async () => {
|
|
43
|
-
const matched = makeMatched(
|
|
44
|
-
"/spells/:id",
|
|
45
|
-
"data:text/javascript,export default (p) => '<div>spell</div>'",
|
|
46
|
-
{ id: "fireball" },
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
const res = await renderRoute(
|
|
50
|
-
matched,
|
|
51
|
-
new Request("http://localhost/spells/fireball"),
|
|
52
|
-
);
|
|
53
|
-
const html = await res.text();
|
|
54
|
-
|
|
55
|
-
expect(html).toContain('"pattern":"/spells/:id"');
|
|
56
|
-
expect(html).toContain('"id":"fireball"');
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
test("head script tag comes before head content", async () => {
|
|
60
|
-
const matched = makeMatched(
|
|
61
|
-
"/head-test",
|
|
62
|
-
"data:text/javascript,export default (p) => '<div>head</div>'",
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
const res = await renderRoute(
|
|
66
|
-
matched,
|
|
67
|
-
new Request("http://localhost/head-test"),
|
|
68
|
-
);
|
|
69
|
-
const html = await res.text();
|
|
70
|
-
|
|
71
|
-
const hydrateScript = html.indexOf("hydrate.js");
|
|
72
|
-
const headClosing = html.indexOf("</head>");
|
|
73
|
-
// hydrate.js should be in <head>
|
|
74
|
-
expect(hydrateScript).toBeGreaterThan(-1);
|
|
75
|
-
expect(hydrateScript).toBeLessThan(headClosing);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
test("stream chunks arrive incrementally", async () => {
|
|
79
|
-
const matched = makeMatched(
|
|
80
|
-
"/chunked",
|
|
81
|
-
"data:text/javascript,export default (p) => '<div>chunked</div>'",
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
const res = await renderRoute(
|
|
85
|
-
matched,
|
|
86
|
-
new Request("http://localhost/chunked"),
|
|
87
|
-
);
|
|
88
|
-
const reader = res.body!.getReader();
|
|
89
|
-
const chunks: string[] = [];
|
|
90
|
-
|
|
91
|
-
while (true) {
|
|
92
|
-
const { done, value } = await reader.read();
|
|
93
|
-
if (done) break;
|
|
94
|
-
// Bun ReadableStream returns Uint8Array
|
|
95
|
-
chunks.push(
|
|
96
|
-
typeof value === "string"
|
|
97
|
-
? value
|
|
98
|
-
: new TextDecoder().decode(value.buffer),
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// Should have multiple chunks (at least DOCTYPE + body)
|
|
103
|
-
expect(chunks.length).toBeGreaterThan(1);
|
|
104
|
-
// First chunk should start with DOCTYPE
|
|
105
|
-
expect(chunks[0]).toContain("<!DOCTYPE html>");
|
|
106
|
-
// Last chunk should close the document
|
|
107
|
-
expect(chunks[chunks.length - 1]).toContain("</html>");
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
test("navigation request returns JSON not stream", async () => {
|
|
111
|
-
const matched = makeMatched(
|
|
112
|
-
"/nav",
|
|
113
|
-
"data:text/javascript,export default (p) => '<div>nav</div>'",
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
const req = new Request("http://localhost/nav", {
|
|
117
|
-
headers: { "x-grimoire-navigate": "1" },
|
|
118
|
-
});
|
|
119
|
-
const res = await renderRoute(matched, req);
|
|
120
|
-
const json = await res.json();
|
|
121
|
-
|
|
122
|
-
expect(json.pattern).toBe("/nav");
|
|
123
|
-
expect(json.data).toBeDefined();
|
|
124
|
-
});
|
|
125
|
-
});
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { renderRoute } from "../src/rendering";
|
|
3
|
+
|
|
4
|
+
function makeMatched(path: string, filePath: string, params = {}) {
|
|
5
|
+
return {
|
|
6
|
+
route: { path, params: {}, filePath },
|
|
7
|
+
params,
|
|
8
|
+
layouts: [],
|
|
9
|
+
layoutServers: [],
|
|
10
|
+
} as any;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
describe("Streaming SSR", () => {
|
|
14
|
+
test("returns a ReadableStream response", async () => {
|
|
15
|
+
const matched = makeMatched(
|
|
16
|
+
"/",
|
|
17
|
+
"data:text/javascript,export default (p) => '<div>hello</div>'",
|
|
18
|
+
);
|
|
19
|
+
const res = await renderRoute(matched, new Request("http://localhost/"));
|
|
20
|
+
expect(res.body).toBeInstanceOf(ReadableStream);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test("stream contains full HTML document", async () => {
|
|
24
|
+
const matched = makeMatched(
|
|
25
|
+
"/test",
|
|
26
|
+
"data:text/javascript,export default (p) => '<p>streaming works</p>'",
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const res = await renderRoute(
|
|
30
|
+
matched,
|
|
31
|
+
new Request("http://localhost/test"),
|
|
32
|
+
);
|
|
33
|
+
const html = await res.text();
|
|
34
|
+
|
|
35
|
+
expect(html).toContain("<!DOCTYPE html>");
|
|
36
|
+
expect(html).toContain('<meta charset="UTF-8" />');
|
|
37
|
+
expect(html).toContain("streaming works");
|
|
38
|
+
expect(html).toContain("</html>");
|
|
39
|
+
expect(html).toContain("__grimoire_state__");
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test("stream includes state JSON with route pattern", async () => {
|
|
43
|
+
const matched = makeMatched(
|
|
44
|
+
"/spells/:id",
|
|
45
|
+
"data:text/javascript,export default (p) => '<div>spell</div>'",
|
|
46
|
+
{ id: "fireball" },
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
const res = await renderRoute(
|
|
50
|
+
matched,
|
|
51
|
+
new Request("http://localhost/spells/fireball"),
|
|
52
|
+
);
|
|
53
|
+
const html = await res.text();
|
|
54
|
+
|
|
55
|
+
expect(html).toContain('"pattern":"/spells/:id"');
|
|
56
|
+
expect(html).toContain('"id":"fireball"');
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test("head script tag comes before head content", async () => {
|
|
60
|
+
const matched = makeMatched(
|
|
61
|
+
"/head-test",
|
|
62
|
+
"data:text/javascript,export default (p) => '<div>head</div>'",
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
const res = await renderRoute(
|
|
66
|
+
matched,
|
|
67
|
+
new Request("http://localhost/head-test"),
|
|
68
|
+
);
|
|
69
|
+
const html = await res.text();
|
|
70
|
+
|
|
71
|
+
const hydrateScript = html.indexOf("hydrate.js");
|
|
72
|
+
const headClosing = html.indexOf("</head>");
|
|
73
|
+
// hydrate.js should be in <head>
|
|
74
|
+
expect(hydrateScript).toBeGreaterThan(-1);
|
|
75
|
+
expect(hydrateScript).toBeLessThan(headClosing);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test("stream chunks arrive incrementally", async () => {
|
|
79
|
+
const matched = makeMatched(
|
|
80
|
+
"/chunked",
|
|
81
|
+
"data:text/javascript,export default (p) => '<div>chunked</div>'",
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
const res = await renderRoute(
|
|
85
|
+
matched,
|
|
86
|
+
new Request("http://localhost/chunked"),
|
|
87
|
+
);
|
|
88
|
+
const reader = res.body!.getReader();
|
|
89
|
+
const chunks: string[] = [];
|
|
90
|
+
|
|
91
|
+
while (true) {
|
|
92
|
+
const { done, value } = await reader.read();
|
|
93
|
+
if (done) break;
|
|
94
|
+
// Bun ReadableStream returns Uint8Array
|
|
95
|
+
chunks.push(
|
|
96
|
+
typeof value === "string"
|
|
97
|
+
? value
|
|
98
|
+
: new TextDecoder().decode(value.buffer),
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Should have multiple chunks (at least DOCTYPE + body)
|
|
103
|
+
expect(chunks.length).toBeGreaterThan(1);
|
|
104
|
+
// First chunk should start with DOCTYPE
|
|
105
|
+
expect(chunks[0]).toContain("<!DOCTYPE html>");
|
|
106
|
+
// Last chunk should close the document
|
|
107
|
+
expect(chunks[chunks.length - 1]).toContain("</html>");
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
test("navigation request returns JSON not stream", async () => {
|
|
111
|
+
const matched = makeMatched(
|
|
112
|
+
"/nav",
|
|
113
|
+
"data:text/javascript,export default (p) => '<div>nav</div>'",
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
const req = new Request("http://localhost/nav", {
|
|
117
|
+
headers: { "x-grimoire-navigate": "1" },
|
|
118
|
+
});
|
|
119
|
+
const res = await renderRoute(matched, req);
|
|
120
|
+
const json = await res.json();
|
|
121
|
+
|
|
122
|
+
expect(json.pattern).toBe("/nav");
|
|
123
|
+
expect(json.data).toBeDefined();
|
|
124
|
+
});
|
|
125
|
+
});
|
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test";
|
|
2
|
-
import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
3
|
-
import { tmpdir } from "node:os";
|
|
4
|
-
import { join } from "node:path";
|
|
5
|
-
import type { RouteFile } from "../src/routing/scanner";
|
|
6
|
-
import { transformRoutes } from "../src/routing/transform-routes";
|
|
7
|
-
|
|
8
|
-
describe("transformRoutes", () => {
|
|
9
|
-
test("pre-transforms TypeScript TSX routes to unique JavaScript files", async () => {
|
|
10
|
-
const root = await mkdtemp(join(tmpdir(), "grimoire-transform-"));
|
|
11
|
-
try {
|
|
12
|
-
const routesDir = join(root, "src", "routes");
|
|
13
|
-
const spellDir = join(routesDir, "spells", "[id]");
|
|
14
|
-
const otherDir = join(routesDir, "other");
|
|
15
|
-
const outDir = join(root, ".grimoire", "compiled");
|
|
16
|
-
await mkdir(spellDir, { recursive: true });
|
|
17
|
-
await mkdir(otherDir, { recursive: true });
|
|
18
|
-
await mkdir(outDir, { recursive: true });
|
|
19
|
-
|
|
20
|
-
const spellRoute = join(spellDir, "+page.tsx");
|
|
21
|
-
const otherRoute = join(otherDir, "+page.tsx");
|
|
22
|
-
const spellData = join(spellDir, "data.ts");
|
|
23
|
-
await writeFile(
|
|
24
|
-
spellData,
|
|
25
|
-
`
|
|
26
|
-
export const SPELLS = { fire: "Fire" } as const;
|
|
27
|
-
`,
|
|
28
|
-
);
|
|
29
|
-
await writeFile(
|
|
30
|
-
spellRoute,
|
|
31
|
-
`
|
|
32
|
-
import { SPELLS } from "./data";
|
|
33
|
-
type PageProps = { params: { id: keyof typeof SPELLS } };
|
|
34
|
-
|
|
35
|
-
export default function Page({ params }: PageProps) {
|
|
36
|
-
const n: number = 1;
|
|
37
|
-
return <h1>{SPELLS[params.id] ?? n}</h1>;
|
|
38
|
-
}
|
|
39
|
-
`,
|
|
40
|
-
);
|
|
41
|
-
await writeFile(
|
|
42
|
-
otherRoute,
|
|
43
|
-
`
|
|
44
|
-
export default function Other({ count }: { count: number }) {
|
|
45
|
-
return <p>{count}</p>;
|
|
46
|
-
}
|
|
47
|
-
`,
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
const routes: RouteFile[] = [
|
|
51
|
-
route(spellRoute, "/spells/:id"),
|
|
52
|
-
route(otherRoute, "/other"),
|
|
53
|
-
];
|
|
54
|
-
const files = await transformRoutes(routes, outDir, "dom");
|
|
55
|
-
|
|
56
|
-
const spellOut = files.get(spellRoute);
|
|
57
|
-
const otherOut = files.get(otherRoute);
|
|
58
|
-
expect(spellOut).not.toEqual(otherOut);
|
|
59
|
-
expect(spellOut).toContain(".dom.js");
|
|
60
|
-
expect(otherOut).toContain(".dom.js");
|
|
61
|
-
|
|
62
|
-
const code = await readFile(spellOut!, "utf8");
|
|
63
|
-
expect(code).toContain("export default function Page");
|
|
64
|
-
expect(code).toContain(
|
|
65
|
-
spellData.replace(/\.ts$/, "").replace(/\\/g, "\\\\"),
|
|
66
|
-
);
|
|
67
|
-
expect(code).not.toContain(": number");
|
|
68
|
-
expect(code).not.toContain("keyof typeof");
|
|
69
|
-
expect(code).not.toContain("as const");
|
|
70
|
-
} finally {
|
|
71
|
-
await rm(root, { recursive: true, force: true });
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
function route(filePath: string, path: string): RouteFile {
|
|
77
|
-
return {
|
|
78
|
-
path,
|
|
79
|
-
filePath,
|
|
80
|
-
clientPath: filePath,
|
|
81
|
-
type: "page",
|
|
82
|
-
paramNames: [],
|
|
83
|
-
};
|
|
84
|
-
}
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import type { RouteFile } from "../src/routing/scanner";
|
|
6
|
+
import { transformRoutes } from "../src/routing/transform-routes";
|
|
7
|
+
|
|
8
|
+
describe("transformRoutes", () => {
|
|
9
|
+
test("pre-transforms TypeScript TSX routes to unique JavaScript files", async () => {
|
|
10
|
+
const root = await mkdtemp(join(tmpdir(), "grimoire-transform-"));
|
|
11
|
+
try {
|
|
12
|
+
const routesDir = join(root, "src", "routes");
|
|
13
|
+
const spellDir = join(routesDir, "spells", "[id]");
|
|
14
|
+
const otherDir = join(routesDir, "other");
|
|
15
|
+
const outDir = join(root, ".grimoire", "compiled");
|
|
16
|
+
await mkdir(spellDir, { recursive: true });
|
|
17
|
+
await mkdir(otherDir, { recursive: true });
|
|
18
|
+
await mkdir(outDir, { recursive: true });
|
|
19
|
+
|
|
20
|
+
const spellRoute = join(spellDir, "+page.tsx");
|
|
21
|
+
const otherRoute = join(otherDir, "+page.tsx");
|
|
22
|
+
const spellData = join(spellDir, "data.ts");
|
|
23
|
+
await writeFile(
|
|
24
|
+
spellData,
|
|
25
|
+
`
|
|
26
|
+
export const SPELLS = { fire: "Fire" } as const;
|
|
27
|
+
`,
|
|
28
|
+
);
|
|
29
|
+
await writeFile(
|
|
30
|
+
spellRoute,
|
|
31
|
+
`
|
|
32
|
+
import { SPELLS } from "./data";
|
|
33
|
+
type PageProps = { params: { id: keyof typeof SPELLS } };
|
|
34
|
+
|
|
35
|
+
export default function Page({ params }: PageProps) {
|
|
36
|
+
const n: number = 1;
|
|
37
|
+
return <h1>{SPELLS[params.id] ?? n}</h1>;
|
|
38
|
+
}
|
|
39
|
+
`,
|
|
40
|
+
);
|
|
41
|
+
await writeFile(
|
|
42
|
+
otherRoute,
|
|
43
|
+
`
|
|
44
|
+
export default function Other({ count }: { count: number }) {
|
|
45
|
+
return <p>{count}</p>;
|
|
46
|
+
}
|
|
47
|
+
`,
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
const routes: RouteFile[] = [
|
|
51
|
+
route(spellRoute, "/spells/:id"),
|
|
52
|
+
route(otherRoute, "/other"),
|
|
53
|
+
];
|
|
54
|
+
const files = await transformRoutes(routes, outDir, "dom");
|
|
55
|
+
|
|
56
|
+
const spellOut = files.get(spellRoute);
|
|
57
|
+
const otherOut = files.get(otherRoute);
|
|
58
|
+
expect(spellOut).not.toEqual(otherOut);
|
|
59
|
+
expect(spellOut).toContain(".dom.js");
|
|
60
|
+
expect(otherOut).toContain(".dom.js");
|
|
61
|
+
|
|
62
|
+
const code = await readFile(spellOut!, "utf8");
|
|
63
|
+
expect(code).toContain("export default function Page");
|
|
64
|
+
expect(code).toContain(
|
|
65
|
+
spellData.replace(/\.ts$/, "").replace(/\\/g, "\\\\"),
|
|
66
|
+
);
|
|
67
|
+
expect(code).not.toContain(": number");
|
|
68
|
+
expect(code).not.toContain("keyof typeof");
|
|
69
|
+
expect(code).not.toContain("as const");
|
|
70
|
+
} finally {
|
|
71
|
+
await rm(root, { recursive: true, force: true });
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
function route(filePath: string, path: string): RouteFile {
|
|
77
|
+
return {
|
|
78
|
+
path,
|
|
79
|
+
filePath,
|
|
80
|
+
clientPath: filePath,
|
|
81
|
+
type: "page",
|
|
82
|
+
paramNames: [],
|
|
83
|
+
};
|
|
84
|
+
}
|