@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.
Files changed (88) hide show
  1. package/index.ts +35 -35
  2. package/package.json +9 -8
  3. package/preload.js +3 -3
  4. package/server.ts +19 -19
  5. package/src/client/deps.ts +13 -7
  6. package/src/client/enhance.ts +98 -98
  7. package/src/client/head.ts +30 -30
  8. package/src/client/index.ts +2 -2
  9. package/src/client/router.ts +445 -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 +98 -79
  36. package/src/rendering/index.ts +455 -372
  37. package/src/rendering/ssrPlugin.ts +69 -69
  38. package/src/routing/manifest-gen.ts +12 -11
  39. package/src/routing/router.ts +109 -109
  40. package/src/routing/scanner.ts +141 -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 +243 -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 +655 -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 +356 -356
  55. package/src/types.ts +4 -4
  56. package/test/client-router.test.ts +37 -31
  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 +615 -579
  67. package/test/routing.test.ts +81 -81
  68. package/test/scanning.test.ts +200 -200
  69. package/test/scope.test.ts +195 -195
  70. package/test/server.test.ts +249 -249
  71. package/test/streaming.test.ts +125 -125
  72. package/test/transform-routes.test.ts +84 -84
  73. package/test/typegen.test.ts +682 -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
@@ -1,66 +1,66 @@
1
- /**
2
- * Parse cookies from a Cookie header string.
3
- */
4
- export function parseCookies(cookieHeader: string): Map<string, string> {
5
- const map = new Map<string, string>();
6
- if (!cookieHeader) return map;
7
- for (const pair of cookieHeader.split(";")) {
8
- const [name, ...rest] = pair.split("=");
9
- if (name) map.set(name.trim(), rest.join("=").trim());
10
- }
11
- return map;
12
- }
13
-
14
- /**
15
- * Build a Set-Cookie header from name, value, and options.
16
- */
17
- export function serializeCookie(
18
- name: string,
19
- value: string,
20
- options?: {
21
- path?: string;
22
- domain?: string;
23
- maxAge?: number;
24
- expires?: Date;
25
- httpOnly?: boolean;
26
- secure?: boolean;
27
- sameSite?: "strict" | "lax" | "none";
28
- },
29
- ): string {
30
- let cookie = `${name}=${encodeURIComponent(value)}`;
31
- if (options?.path) cookie += `; Path=${options.path}`;
32
- if (options?.domain) cookie += `; Domain=${options.domain}`;
33
- if (options?.maxAge != null) cookie += `; Max-Age=${options.maxAge}`;
34
- if (options?.expires) cookie += `; Expires=${options.expires.toUTCString()}`;
35
- if (options?.httpOnly) cookie += "; HttpOnly";
36
- if (options?.secure) cookie += "; Secure";
37
- if (options?.sameSite) cookie += `; SameSite=${options.sameSite}`;
38
- return cookie;
39
- }
40
-
41
- /**
42
- * Create a Cookies helper from a Cookie header string.
43
- */
44
- export function createCookies(
45
- cookieHeader: string,
46
- ): import("./hooks").Cookies & { toHeaders(): string[] } {
47
- const store = parseCookies(cookieHeader);
48
- const pending: string[] = [];
49
-
50
- return {
51
- get(name: string) {
52
- return store.get(name);
53
- },
54
- set(name: string, value: string, options?: any) {
55
- store.set(name, value);
56
- pending.push(serializeCookie(name, value, options));
57
- },
58
- delete(name: string) {
59
- store.delete(name);
60
- pending.push(serializeCookie(name, "", { maxAge: 0 }));
61
- },
62
- toHeaders() {
63
- return pending;
64
- },
65
- };
66
- }
1
+ /**
2
+ * Parse cookies from a Cookie header string.
3
+ */
4
+ export function parseCookies(cookieHeader: string): Map<string, string> {
5
+ const map = new Map<string, string>();
6
+ if (!cookieHeader) return map;
7
+ for (const pair of cookieHeader.split(";")) {
8
+ const [name, ...rest] = pair.split("=");
9
+ if (name) map.set(name.trim(), rest.join("=").trim());
10
+ }
11
+ return map;
12
+ }
13
+
14
+ /**
15
+ * Build a Set-Cookie header from name, value, and options.
16
+ */
17
+ export function serializeCookie(
18
+ name: string,
19
+ value: string,
20
+ options?: {
21
+ path?: string;
22
+ domain?: string;
23
+ maxAge?: number;
24
+ expires?: Date;
25
+ httpOnly?: boolean;
26
+ secure?: boolean;
27
+ sameSite?: "strict" | "lax" | "none";
28
+ },
29
+ ): string {
30
+ let cookie = `${name}=${encodeURIComponent(value)}`;
31
+ if (options?.path) cookie += `; Path=${options.path}`;
32
+ if (options?.domain) cookie += `; Domain=${options.domain}`;
33
+ if (options?.maxAge != null) cookie += `; Max-Age=${options.maxAge}`;
34
+ if (options?.expires) cookie += `; Expires=${options.expires.toUTCString()}`;
35
+ if (options?.httpOnly) cookie += "; HttpOnly";
36
+ if (options?.secure) cookie += "; Secure";
37
+ if (options?.sameSite) cookie += `; SameSite=${options.sameSite}`;
38
+ return cookie;
39
+ }
40
+
41
+ /**
42
+ * Create a Cookies helper from a Cookie header string.
43
+ */
44
+ export function createCookies(
45
+ cookieHeader: string,
46
+ ): import("./hooks").Cookies & { toHeaders(): string[] } {
47
+ const store = parseCookies(cookieHeader);
48
+ const pending: string[] = [];
49
+
50
+ return {
51
+ get(name: string) {
52
+ return store.get(name);
53
+ },
54
+ set(name: string, value: string, options?: any) {
55
+ store.set(name, value);
56
+ pending.push(serializeCookie(name, value, options));
57
+ },
58
+ delete(name: string) {
59
+ store.delete(name);
60
+ pending.push(serializeCookie(name, "", { maxAge: 0 }));
61
+ },
62
+ toHeaders() {
63
+ return pending;
64
+ },
65
+ };
66
+ }