@sigil-dev/grimoire 0.9.2 → 0.9.4

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 (88) hide show
  1. package/index.ts +37 -35
  2. package/package.json +9 -12
  3. package/preload.js +3 -3
  4. package/server.ts +19 -19
  5. package/src/client/deps.ts +31 -8
  6. package/src/client/enhance.ts +102 -98
  7. package/src/client/head.ts +30 -30
  8. package/src/client/index.ts +5 -5
  9. package/src/client/router.ts +529 -371
  10. package/src/client/scope.ts +22 -22
  11. package/src/dev/compile-module.ts +163 -163
  12. package/src/dev/effect-registry.ts +23 -23
  13. package/src/dev/graph.ts +114 -114
  14. package/src/dev/hmr-client.ts +185 -185
  15. package/src/dev/loader.ts +47 -47
  16. package/src/dev/paths.ts +14 -14
  17. package/src/dev/runtime-bundle.ts +52 -52
  18. package/src/dev/watcher.ts +47 -46
  19. package/src/env/dynamic-private.ts +19 -19
  20. package/src/env/dynamic-public.ts +22 -22
  21. package/src/env/index.ts +25 -25
  22. package/src/env/plugin.ts +19 -19
  23. package/src/env/private.ts +5 -5
  24. package/src/env/public.ts +7 -7
  25. package/src/env/typegen.ts +61 -61
  26. package/src/headers.ts +114 -114
  27. package/src/integrations/vite.ts +73 -73
  28. package/src/logger/index.ts +4 -4
  29. package/src/logger/instance.ts +6 -6
  30. package/src/logger/logger.ts +113 -113
  31. package/src/logger/request-middleware.ts +24 -24
  32. package/src/logger/transports.ts +117 -117
  33. package/src/logger/types.ts +39 -39
  34. package/src/rendering/head.ts +47 -47
  35. package/src/rendering/hydrate.ts +146 -119
  36. package/src/rendering/index.ts +573 -372
  37. package/src/rendering/ssrPlugin.ts +69 -69
  38. package/src/routing/manifest-gen.ts +55 -42
  39. package/src/routing/router.ts +135 -109
  40. package/src/routing/scanner.ts +187 -141
  41. package/src/routing/transform-routes.ts +102 -102
  42. package/src/sentinels/error.ts +52 -52
  43. package/src/sentinels/fail.ts +41 -41
  44. package/src/sentinels/redirect.ts +35 -35
  45. package/src/server/build.ts +255 -219
  46. package/src/server/context.ts +10 -10
  47. package/src/server/cookie-utils.ts +66 -66
  48. package/src/server/coordinator.ts +364 -356
  49. package/src/server/hooks.ts +114 -114
  50. package/src/server/index.ts +677 -658
  51. package/src/server/interactive.ts +56 -56
  52. package/src/server/plugins.ts +121 -120
  53. package/src/server/worker.ts +58 -58
  54. package/src/typegen/index.ts +389 -356
  55. package/src/types.ts +8 -4
  56. package/test/client-router.test.ts +295 -35
  57. package/test/context.test.ts +52 -52
  58. package/test/env.test.ts +70 -70
  59. package/test/exports.test.ts +37 -37
  60. package/test/fail.test.ts +46 -46
  61. package/test/headers.test.ts +100 -100
  62. package/test/hydration.test.ts +119 -119
  63. package/test/middleware.test.ts +223 -223
  64. package/test/preload.ts +5 -5
  65. package/test/redirect-error.test.ts +112 -112
  66. package/test/rendering.test.ts +728 -579
  67. package/test/routing.test.ts +194 -81
  68. package/test/scanning.test.ts +254 -200
  69. package/test/scope.test.ts +195 -195
  70. package/test/server.test.ts +354 -249
  71. package/test/streaming.test.ts +242 -125
  72. package/test/transform-routes.test.ts +87 -84
  73. package/test/typegen.test.ts +697 -682
  74. package/tsconfig.json +10 -10
  75. package/.grimoire/_routes.dom.js +0 -8
  76. package/.grimoire/_routes.hydrate.js +0 -8
  77. package/.grimoire/tsconfig.generated.json +0 -11
  78. package/.grimoire/types/ambient.d.ts +0 -59
  79. package/.grimoire/types/api/hello/$types.d.ts +0 -50
  80. package/.grimoire/types/api/items/$types.d.ts +0 -50
  81. package/.grimoire/types/echo/$types.d.ts +0 -50
  82. package/.grimoire/types/env-private.d.ts +0 -5
  83. package/.grimoire/types/env-public.d.ts +0 -5
  84. package/.grimoire/types/mixed/$types.d.ts +0 -50
  85. package/.grimoire/types/params/[docId]/$types.d.ts +0 -52
  86. package/.grimoire/types/reject/$types.d.ts +0 -50
  87. package/public/__grimoire__/hydrate.js +0 -585
  88. package/public/__grimoire__/index.js +0 -490
package/tsconfig.json CHANGED
@@ -1,10 +1,10 @@
1
- {
2
- "compilerOptions": {
3
- "module": "Preserve",
4
- "moduleResolution": "bundler",
5
- "lib": ["ESNext", "DOM"],
6
- "target": "ESNext",
7
- "allowImportingTsExtensions": true,
8
- "noEmit": true
9
- }
10
- }
1
+ {
2
+ "compilerOptions": {
3
+ "module": "Preserve",
4
+ "moduleResolution": "bundler",
5
+ "lib": ["ESNext", "DOM"],
6
+ "target": "ESNext",
7
+ "allowImportingTsExtensions": true,
8
+ "noEmit": true
9
+ }
10
+ }
@@ -1,8 +0,0 @@
1
-
2
-
3
- export const routes = {
4
-
5
- };
6
- export const layouts = [
7
-
8
- ];
@@ -1,8 +0,0 @@
1
-
2
-
3
- export const routes = {
4
-
5
- };
6
- export const layouts = [
7
-
8
- ];
@@ -1,11 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "rootDirs": [
4
- "..",
5
- "./types"
6
- ]
7
- },
8
- "include": [
9
- "types/**/*.d.ts"
10
- ]
11
- }
@@ -1,59 +0,0 @@
1
- // Auto-generated by @sigil-dev/grimoire — do not edit
2
-
3
- declare namespace App {
4
- // Extend this interface in your app's src/app.d.ts to add typed locals
5
- interface Locals extends Record<string, unknown> {}
6
- }
7
-
8
- // Available in all route files without import.
9
- // Params default to Record<string,string>; for per-route typed params import from './$types'.
10
- // Note: using these globals widens return types — PageData loses concrete keys.
11
- // For precise data inference annotate load() with PageServerLoad from './$types'.
12
-
13
- type PageServerLoad<
14
- P extends Record<string, string> = Record<string, string>
15
- > = (ctx: {
16
- params: P;
17
- request: Request;
18
- url: URL;
19
- locals: App.Locals;
20
- }) => Record<string, unknown> | Promise<Record<string, unknown>>;
21
-
22
- type LayoutServerLoad<
23
- P extends Record<string, string> = Record<string, string>
24
- > = (ctx: {
25
- params: P;
26
- request: Request;
27
- url: URL;
28
- locals: App.Locals;
29
- }) => Record<string, unknown> | Promise<Record<string, unknown>>;
30
-
31
- type RequestHandler<
32
- P extends Record<string, string> = Record<string, string>
33
- > = (ctx: {
34
- params: P;
35
- request: Request;
36
- url: URL;
37
- locals: App.Locals;
38
- }) => Response | Promise<Response>;
39
-
40
- type PageProps<
41
- D extends Record<string, unknown> = Record<string, unknown>,
42
- P extends Record<string, string> = Record<string, string>
43
- > = { data: D; params: P };
44
-
45
- type LayoutProps<
46
- D extends Record<string, unknown> = Record<string, unknown>,
47
- P extends Record<string, string> = Record<string, string>
48
- > = { data: D; params: P; children?: unknown };
49
-
50
- type ErrorProps = { status: number; message: string };
51
-
52
- type UpgradeContext<
53
- P extends Record<string, string> = Record<string, string>
54
- > = {
55
- params: P;
56
- request: Request;
57
- url: URL;
58
- locals: App.Locals;
59
- };
@@ -1,50 +0,0 @@
1
- // Auto-generated by @sigil-dev/grimoire — do not edit
2
-
3
- export type Params = {};
4
-
5
- export type PageData = Record<string, never>;
6
- export type PageProps = { data: PageData; params: Params };
7
- export type PageServerLoad = never;
8
- export type Actions = Record<string, never>;
9
-
10
- export type LayoutData = Record<string, never>;
11
- export type LayoutProps = { data: LayoutData; params: Params; children?: unknown };
12
- export type LayoutServerLoad = (ctx: {
13
- params: Params;
14
- request: Request;
15
- url: URL;
16
- locals: App.Locals;
17
- }) => Record<string, unknown> | Promise<Record<string, unknown>>;
18
-
19
- type _SRV = typeof import("C:/Users/Cane1712/AppData/Local/Temp/grimoire-server-1780769083225/api/hello/+server.js");
20
- type _HttpMethods = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
21
- type _ServerKeys = Extract<keyof _SRV, _HttpMethods>;
22
- export type ServerHandlers = {
23
- [K in _ServerKeys]: (ctx: {
24
- params: Params;
25
- request: Request;
26
- url: URL;
27
- locals: App.Locals;
28
- }) => Response | Promise<Response>;
29
- };
30
-
31
- export type UpgradeContext = {
32
- request: Request;
33
- params: Params;
34
- url: URL;
35
- locals: App.Locals;
36
- };
37
-
38
- type _UpgradeReturn = "upgrade" extends keyof _SRV
39
- ? _SRV["upgrade"] extends (...args: any[]) => any
40
- ? Awaited<ReturnType<_SRV["upgrade"]>>
41
- : {}
42
- : {};
43
- export type WsData = { params: Params } & Omit<_UpgradeReturn, "__handler">;
44
-
45
- export type WebSocketHandler = {
46
- open?(ws: ServerWebSocket<WsData>): void | Promise<void>;
47
- message?(ws: ServerWebSocket<WsData>, data: string | Buffer): void | Promise<void>;
48
- close?(ws: ServerWebSocket<WsData>, code: number, reason?: string): void | Promise<void>;
49
- drain?(ws: ServerWebSocket<WsData>): void | Promise<void>;
50
- };
@@ -1,50 +0,0 @@
1
- // Auto-generated by @sigil-dev/grimoire — do not edit
2
-
3
- export type Params = {};
4
-
5
- export type PageData = Record<string, never>;
6
- export type PageProps = { data: PageData; params: Params };
7
- export type PageServerLoad = never;
8
- export type Actions = Record<string, never>;
9
-
10
- export type LayoutData = Record<string, never>;
11
- export type LayoutProps = { data: LayoutData; params: Params; children?: unknown };
12
- export type LayoutServerLoad = (ctx: {
13
- params: Params;
14
- request: Request;
15
- url: URL;
16
- locals: App.Locals;
17
- }) => Record<string, unknown> | Promise<Record<string, unknown>>;
18
-
19
- type _SRV = typeof import("C:/Users/Cane1712/AppData/Local/Temp/grimoire-server-1780769083225/api/items/+server.js");
20
- type _HttpMethods = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
21
- type _ServerKeys = Extract<keyof _SRV, _HttpMethods>;
22
- export type ServerHandlers = {
23
- [K in _ServerKeys]: (ctx: {
24
- params: Params;
25
- request: Request;
26
- url: URL;
27
- locals: App.Locals;
28
- }) => Response | Promise<Response>;
29
- };
30
-
31
- export type UpgradeContext = {
32
- request: Request;
33
- params: Params;
34
- url: URL;
35
- locals: App.Locals;
36
- };
37
-
38
- type _UpgradeReturn = "upgrade" extends keyof _SRV
39
- ? _SRV["upgrade"] extends (...args: any[]) => any
40
- ? Awaited<ReturnType<_SRV["upgrade"]>>
41
- : {}
42
- : {};
43
- export type WsData = { params: Params } & Omit<_UpgradeReturn, "__handler">;
44
-
45
- export type WebSocketHandler = {
46
- open?(ws: ServerWebSocket<WsData>): void | Promise<void>;
47
- message?(ws: ServerWebSocket<WsData>, data: string | Buffer): void | Promise<void>;
48
- close?(ws: ServerWebSocket<WsData>, code: number, reason?: string): void | Promise<void>;
49
- drain?(ws: ServerWebSocket<WsData>): void | Promise<void>;
50
- };
@@ -1,50 +0,0 @@
1
- // Auto-generated by @sigil-dev/grimoire — do not edit
2
-
3
- export type Params = {};
4
-
5
- export type PageData = Record<string, never>;
6
- export type PageProps = { data: PageData; params: Params };
7
- export type PageServerLoad = never;
8
- export type Actions = Record<string, never>;
9
-
10
- export type LayoutData = Record<string, never>;
11
- export type LayoutProps = { data: LayoutData; params: Params; children?: unknown };
12
- export type LayoutServerLoad = (ctx: {
13
- params: Params;
14
- request: Request;
15
- url: URL;
16
- locals: App.Locals;
17
- }) => Record<string, unknown> | Promise<Record<string, unknown>>;
18
-
19
- type _SRV = typeof import("C:/Users/Cane1712/AppData/Local/Temp/grimoire-ws-1780769083320/echo/+server.js");
20
- type _HttpMethods = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
21
- type _ServerKeys = Extract<keyof _SRV, _HttpMethods>;
22
- export type ServerHandlers = {
23
- [K in _ServerKeys]: (ctx: {
24
- params: Params;
25
- request: Request;
26
- url: URL;
27
- locals: App.Locals;
28
- }) => Response | Promise<Response>;
29
- };
30
-
31
- export type UpgradeContext = {
32
- request: Request;
33
- params: Params;
34
- url: URL;
35
- locals: App.Locals;
36
- };
37
-
38
- type _UpgradeReturn = "upgrade" extends keyof _SRV
39
- ? _SRV["upgrade"] extends (...args: any[]) => any
40
- ? Awaited<ReturnType<_SRV["upgrade"]>>
41
- : {}
42
- : {};
43
- export type WsData = { params: Params } & Omit<_UpgradeReturn, "__handler">;
44
-
45
- export type WebSocketHandler = {
46
- open?(ws: ServerWebSocket<WsData>): void | Promise<void>;
47
- message?(ws: ServerWebSocket<WsData>, data: string | Buffer): void | Promise<void>;
48
- close?(ws: ServerWebSocket<WsData>, code: number, reason?: string): void | Promise<void>;
49
- drain?(ws: ServerWebSocket<WsData>): void | Promise<void>;
50
- };
@@ -1,5 +0,0 @@
1
- // Auto-generated by Grimoire. Do not edit.
2
- declare module "$env/static/private" {
3
-
4
- export {};
5
- }
@@ -1,5 +0,0 @@
1
- // Auto-generated by Grimoire. Do not edit.
2
- declare module "$env/static/public" {
3
-
4
- export {};
5
- }
@@ -1,50 +0,0 @@
1
- // Auto-generated by @sigil-dev/grimoire — do not edit
2
-
3
- export type Params = {};
4
-
5
- export type PageData = Record<string, never>;
6
- export type PageProps = { data: PageData; params: Params };
7
- export type PageServerLoad = never;
8
- export type Actions = Record<string, never>;
9
-
10
- export type LayoutData = Record<string, never>;
11
- export type LayoutProps = { data: LayoutData; params: Params; children?: unknown };
12
- export type LayoutServerLoad = (ctx: {
13
- params: Params;
14
- request: Request;
15
- url: URL;
16
- locals: App.Locals;
17
- }) => Record<string, unknown> | Promise<Record<string, unknown>>;
18
-
19
- type _SRV = typeof import("C:/Users/Cane1712/AppData/Local/Temp/grimoire-ws-1780769083320/mixed/+server.js");
20
- type _HttpMethods = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
21
- type _ServerKeys = Extract<keyof _SRV, _HttpMethods>;
22
- export type ServerHandlers = {
23
- [K in _ServerKeys]: (ctx: {
24
- params: Params;
25
- request: Request;
26
- url: URL;
27
- locals: App.Locals;
28
- }) => Response | Promise<Response>;
29
- };
30
-
31
- export type UpgradeContext = {
32
- request: Request;
33
- params: Params;
34
- url: URL;
35
- locals: App.Locals;
36
- };
37
-
38
- type _UpgradeReturn = "upgrade" extends keyof _SRV
39
- ? _SRV["upgrade"] extends (...args: any[]) => any
40
- ? Awaited<ReturnType<_SRV["upgrade"]>>
41
- : {}
42
- : {};
43
- export type WsData = { params: Params } & Omit<_UpgradeReturn, "__handler">;
44
-
45
- export type WebSocketHandler = {
46
- open?(ws: ServerWebSocket<WsData>): void | Promise<void>;
47
- message?(ws: ServerWebSocket<WsData>, data: string | Buffer): void | Promise<void>;
48
- close?(ws: ServerWebSocket<WsData>, code: number, reason?: string): void | Promise<void>;
49
- drain?(ws: ServerWebSocket<WsData>): void | Promise<void>;
50
- };
@@ -1,52 +0,0 @@
1
- // Auto-generated by @sigil-dev/grimoire — do not edit
2
-
3
- export type Params = {
4
- docId: string;
5
- };
6
-
7
- export type PageData = Record<string, never>;
8
- export type PageProps = { data: PageData; params: Params };
9
- export type PageServerLoad = never;
10
- export type Actions = Record<string, never>;
11
-
12
- export type LayoutData = Record<string, never>;
13
- export type LayoutProps = { data: LayoutData; params: Params; children?: unknown };
14
- export type LayoutServerLoad = (ctx: {
15
- params: Params;
16
- request: Request;
17
- url: URL;
18
- locals: App.Locals;
19
- }) => Record<string, unknown> | Promise<Record<string, unknown>>;
20
-
21
- type _SRV = typeof import("C:/Users/Cane1712/AppData/Local/Temp/grimoire-ws-1780769083320/params/[docId]/+server.js");
22
- type _HttpMethods = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
23
- type _ServerKeys = Extract<keyof _SRV, _HttpMethods>;
24
- export type ServerHandlers = {
25
- [K in _ServerKeys]: (ctx: {
26
- params: Params;
27
- request: Request;
28
- url: URL;
29
- locals: App.Locals;
30
- }) => Response | Promise<Response>;
31
- };
32
-
33
- export type UpgradeContext = {
34
- request: Request;
35
- params: Params;
36
- url: URL;
37
- locals: App.Locals;
38
- };
39
-
40
- type _UpgradeReturn = "upgrade" extends keyof _SRV
41
- ? _SRV["upgrade"] extends (...args: any[]) => any
42
- ? Awaited<ReturnType<_SRV["upgrade"]>>
43
- : {}
44
- : {};
45
- export type WsData = { params: Params } & Omit<_UpgradeReturn, "__handler">;
46
-
47
- export type WebSocketHandler = {
48
- open?(ws: ServerWebSocket<WsData>): void | Promise<void>;
49
- message?(ws: ServerWebSocket<WsData>, data: string | Buffer): void | Promise<void>;
50
- close?(ws: ServerWebSocket<WsData>, code: number, reason?: string): void | Promise<void>;
51
- drain?(ws: ServerWebSocket<WsData>): void | Promise<void>;
52
- };
@@ -1,50 +0,0 @@
1
- // Auto-generated by @sigil-dev/grimoire — do not edit
2
-
3
- export type Params = {};
4
-
5
- export type PageData = Record<string, never>;
6
- export type PageProps = { data: PageData; params: Params };
7
- export type PageServerLoad = never;
8
- export type Actions = Record<string, never>;
9
-
10
- export type LayoutData = Record<string, never>;
11
- export type LayoutProps = { data: LayoutData; params: Params; children?: unknown };
12
- export type LayoutServerLoad = (ctx: {
13
- params: Params;
14
- request: Request;
15
- url: URL;
16
- locals: App.Locals;
17
- }) => Record<string, unknown> | Promise<Record<string, unknown>>;
18
-
19
- type _SRV = typeof import("C:/Users/Cane1712/AppData/Local/Temp/grimoire-ws-1780769083320/reject/+server.js");
20
- type _HttpMethods = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
21
- type _ServerKeys = Extract<keyof _SRV, _HttpMethods>;
22
- export type ServerHandlers = {
23
- [K in _ServerKeys]: (ctx: {
24
- params: Params;
25
- request: Request;
26
- url: URL;
27
- locals: App.Locals;
28
- }) => Response | Promise<Response>;
29
- };
30
-
31
- export type UpgradeContext = {
32
- request: Request;
33
- params: Params;
34
- url: URL;
35
- locals: App.Locals;
36
- };
37
-
38
- type _UpgradeReturn = "upgrade" extends keyof _SRV
39
- ? _SRV["upgrade"] extends (...args: any[]) => any
40
- ? Awaited<ReturnType<_SRV["upgrade"]>>
41
- : {}
42
- : {};
43
- export type WsData = { params: Params } & Omit<_UpgradeReturn, "__handler">;
44
-
45
- export type WebSocketHandler = {
46
- open?(ws: ServerWebSocket<WsData>): void | Promise<void>;
47
- message?(ws: ServerWebSocket<WsData>, data: string | Buffer): void | Promise<void>;
48
- close?(ws: ServerWebSocket<WsData>, code: number, reason?: string): void | Promise<void>;
49
- drain?(ws: ServerWebSocket<WsData>): void | Promise<void>;
50
- };