@guren/server 2.10.0 → 2.11.0

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 (91) hide show
  1. package/dist/DocsViewerServiceProvider-qFCaeiUv.js +77 -0
  2. package/dist/Hash-CzrwKeDp.js +133 -0
  3. package/dist/HttpException-BkS3euNG.js +161 -0
  4. package/dist/Job-BVT813DO.js +441 -0
  5. package/dist/McpServiceProvider-BoAN-UcD.js +367 -0
  6. package/dist/MessageSigner-Bd25ZJAV.js +93 -0
  7. package/dist/Random-DbIJ22KQ.js +191 -0
  8. package/dist/address-D0Iq-XIH.js +20 -0
  9. package/dist/auth/index.js +2 -122
  10. package/dist/auth-C7sVmYgc.js +1954 -0
  11. package/dist/authorization/index.js +2 -38
  12. package/dist/authorization-Dbcuc5ZK.js +610 -0
  13. package/dist/broadcasting/index.js +2 -26
  14. package/dist/broadcasting-Dw-FhyjN.js +1055 -0
  15. package/dist/cache/index.js +2 -17
  16. package/dist/cache/types.d.ts +4 -4
  17. package/dist/cache-BYnZf2FR.js +812 -0
  18. package/dist/client-Dd7vLcqp.js +27 -0
  19. package/dist/console/Output.d.ts +18 -18
  20. package/dist/encryption/index.js +5 -96
  21. package/dist/encryption-fOWQaKqX.js +250 -0
  22. package/dist/endpoint-D-20PiHY.js +46 -0
  23. package/dist/endpoint-D6GIqOpe.js +31 -0
  24. package/dist/errors-quJOkkCn.js +81 -0
  25. package/dist/events/index.js +2 -28
  26. package/dist/events-aIH_bWRx.js +410 -0
  27. package/dist/health/index.js +2 -24
  28. package/dist/health-VWdWXRwh.js +345 -0
  29. package/dist/hot-disposables-WsTX2ySN.js +281 -0
  30. package/dist/hot-reload/testing.d.ts +1 -1
  31. package/dist/http/resources/Resource.d.ts +23 -3
  32. package/dist/i18n/index.js +2 -30
  33. package/dist/i18n-mcWi7LCd.js +617 -0
  34. package/dist/index.js +7515 -7276
  35. package/dist/lambda/index.js +114 -71
  36. package/dist/logging/index.js +2 -24
  37. package/dist/logging-CPaRMuPP.js +518 -0
  38. package/dist/loopback-guard-D0Kc7-xc.js +224 -0
  39. package/dist/mail/index.js +2 -27
  40. package/dist/mail-DfEfSQEr.js +699 -0
  41. package/dist/mcp/index.js +2 -10
  42. package/dist/notifications/index.js +2 -33
  43. package/dist/notifications-BGqmUNZ8.js +759 -0
  44. package/dist/queue/index.js +3 -42
  45. package/dist/queue-CXrRK85G.js +948 -0
  46. package/dist/redis/index.js +672 -642
  47. package/dist/rolldown-runtime-8H4AJuhK.js +14 -0
  48. package/dist/runtime/index.js +472 -616
  49. package/dist/scheduling/index.js +2 -29
  50. package/dist/scheduling-CPiEdtQd.js +839 -0
  51. package/dist/storage/index.js +2 -15
  52. package/dist/storage-tWHMv2H_.js +841 -0
  53. package/dist/support/expiry.js +69 -12
  54. package/dist/trim-slashes-ZJ_VsY5s.js +25 -0
  55. package/dist/vite/index.js +118 -181
  56. package/dist/vite/plugin.d.ts +1 -1
  57. package/dist/vite-dev-server-BSJkduhZ.js +131 -0
  58. package/package.json +6 -5
  59. package/dist/DocsViewerServiceProvider-RUYDFBMW.js +0 -75
  60. package/dist/McpServiceProvider-SL7DUZ4G.js +0 -8
  61. package/dist/chunk-2SC566CD.js +0 -376
  62. package/dist/chunk-2V3YID4H.js +0 -20
  63. package/dist/chunk-3KV5X2FL.js +0 -31
  64. package/dist/chunk-63SKW5PS.js +0 -457
  65. package/dist/chunk-6J6B5KOB.js +0 -425
  66. package/dist/chunk-A5JJ7XTH.js +0 -24
  67. package/dist/chunk-AZOYI43J.js +0 -18
  68. package/dist/chunk-B5E5VBDI.js +0 -115
  69. package/dist/chunk-DAQKYKLH.js +0 -182
  70. package/dist/chunk-DRNPVBAA.js +0 -1002
  71. package/dist/chunk-EI5GYMAT.js +0 -853
  72. package/dist/chunk-H3B23O6T.js +0 -271
  73. package/dist/chunk-HPET6XY5.js +0 -853
  74. package/dist/chunk-HR2KZ3WL.js +0 -616
  75. package/dist/chunk-IOTWFHZU.js +0 -558
  76. package/dist/chunk-K6CUBJX6.js +0 -642
  77. package/dist/chunk-KTNJG7R7.js +0 -911
  78. package/dist/chunk-LAJQCSSF.js +0 -355
  79. package/dist/chunk-LHR6OHI7.js +0 -189
  80. package/dist/chunk-N7PLD7MB.js +0 -729
  81. package/dist/chunk-Q2P6YLRR.js +0 -24
  82. package/dist/chunk-QQKTH5KX.js +0 -114
  83. package/dist/chunk-SFQP6O52.js +0 -126
  84. package/dist/chunk-SQR7277M.js +0 -911
  85. package/dist/chunk-T2FFUU6J.js +0 -484
  86. package/dist/chunk-TVV5YNEC.js +0 -1842
  87. package/dist/chunk-UY3AZSYL.js +0 -14
  88. package/dist/chunk-V4DNC2ER.js +0 -114
  89. package/dist/chunk-VSA3QY5Q.js +0 -274
  90. package/dist/chunk-YSOJKAAU.js +0 -427
  91. package/dist/errors-PUNHAFL2.js +0 -34
@@ -1,12 +1,69 @@
1
- import {
2
- isExpired,
3
- isOptionalExpiryPast,
4
- toDate,
5
- toOptionalExpiry
6
- } from "../chunk-3KV5X2FL.js";
7
- export {
8
- isExpired,
9
- isOptionalExpiryPast,
10
- toDate,
11
- toOptionalExpiry
12
- };
1
+ //#region src/support/expiry.ts
2
+ /**
3
+ * Expiry coercion and the one predicate that decides whether a stored expiry
4
+ * has passed.
5
+ *
6
+ * This is the single copy. `packages/core/src/store-utils.ts` re-exports
7
+ * `toDate`/`isExpired`/`toOptionalExpiry` from here through the
8
+ * `@guren/server/support/expiry` subpath, so the database-backed stores and
9
+ * the Redis ones decide expiry with the same code. It lives in this package
10
+ * because `@guren/core` depends on `@guren/server` and not the other way
11
+ * around — core is unreachable from here without a dependency cycle.
12
+ *
13
+ * Not part of the public API: the subpath exists for that re-export, and
14
+ * neither package's index exposes these.
15
+ */
16
+ /**
17
+ * Coerce a stored timestamp, rejecting anything unparseable.
18
+ *
19
+ * Accepts every shape a driver or a Redis value can hand back: Date, number,
20
+ * bigint (MySQL / postgres.js BIGINT), digit-only strings as epoch
21
+ * milliseconds, and ISO strings. A Date wrapping garbage is a parse failure,
22
+ * not a value — `new Date(garbage)` yields an Invalid Date whose comparisons
23
+ * are all false, which is exactly how a corrupt expiry reads as "not past".
24
+ */
25
+ function toDate(value) {
26
+ const date = coerceDate(value);
27
+ return date !== null && !Number.isNaN(date.getTime()) ? date : null;
28
+ }
29
+ function coerceDate(value) {
30
+ if (value == null) return null;
31
+ if (value instanceof Date) return value;
32
+ if (typeof value === "number" || typeof value === "bigint") return new Date(Number(value));
33
+ if (typeof value === "string") return new Date(/^\d+$/.test(value) ? Number(value) : value);
34
+ return null;
35
+ }
36
+ /**
37
+ * Whether an expiry that is required to be present has passed.
38
+ *
39
+ * Missing or unparseable counts as expired, so a malformed record can never be
40
+ * accepted indefinitely. Use for sessions and OAuth state, whose writers always
41
+ * supply an expiry.
42
+ */
43
+ function isExpired(value, now = Date.now()) {
44
+ const date = toDate(value);
45
+ return date === null || date.getTime() <= now;
46
+ }
47
+ /**
48
+ * Whether an expiry that is allowed to be absent has passed.
49
+ *
50
+ * Absent means "never expires" and is never past. Present-but-unparseable is a
51
+ * malformed record and counts as expired — collapsing the two is the fail-open
52
+ * this exists to close. Use at the point of comparison, so the check holds for
53
+ * every store implementation including ones this package never sees.
54
+ */
55
+ function isOptionalExpiryPast(value, now = Date.now()) {
56
+ if (value == null) return false;
57
+ return isExpired(value, now);
58
+ }
59
+ /**
60
+ * Coerce an expiry that is allowed to be absent into a value callers can
61
+ * compare directly: absent stays null, present-but-unparseable degrades to a
62
+ * long-past date rather than to null, which would read as "never expires".
63
+ */
64
+ function toOptionalExpiry(value) {
65
+ if (value == null) return null;
66
+ return toDate(value) ?? /* @__PURE__ */ new Date(0);
67
+ }
68
+ //#endregion
69
+ export { isExpired, isOptionalExpiryPast, toDate, toOptionalExpiry };
@@ -0,0 +1,25 @@
1
+ //#region src/support/trim-slashes.ts
2
+ /**
3
+ * Slash-trimming without regex: patterns like `/\/+$/` backtrack
4
+ * quadratically on adversarial input (long slash runs mid-string), and
5
+ * several call sites here feed request-derived paths.
6
+ *
7
+ * Twins live in `@guren/cli` (`src/utils.ts`, `trimSlashes`) and
8
+ * `@guren/plugin-cloudflare` (`src/storage/R2Driver.ts`, both functions);
9
+ * neither package can import this module, so the lines are duplicated by
10
+ * convention.
11
+ */
12
+ function trimTrailingSlashes(value) {
13
+ let end = value.length;
14
+ while (end > 0 && value[end - 1] === "/") end--;
15
+ return value.slice(0, end);
16
+ }
17
+ function trimSlashes(value) {
18
+ let start = 0;
19
+ let end = value.length;
20
+ while (start < end && value[start] === "/") start++;
21
+ while (end > start && value[end - 1] === "/") end--;
22
+ return value.slice(start, end);
23
+ }
24
+ //#endregion
25
+ export { trimTrailingSlashes as n, trimSlashes as t };
@@ -1,208 +1,145 @@
1
- // src/vite/plugin.ts
2
- import path from "path";
3
- var defaultOptions = {
4
- appAlias: "@",
5
- appDir: ".",
6
- resourcesAlias: "@resources",
7
- resourcesDir: "resources/js",
8
- entry: "resources/js/app.tsx",
9
- ssrEntry: "resources/js/ssr.tsx",
10
- outDir: "public/assets",
11
- ssrOutDir: ".guren/ssr",
12
- devPort: 5173,
13
- previewPort: 4173,
14
- entryFileNames: "[name]-[hash].js",
15
- chunkFileNames: "[name]-[hash].js",
16
- assetFileNames: "[name]-[hash][extname]"
1
+ import path from "node:path";
2
+ //#region src/vite/plugin.ts
3
+ const defaultOptions = {
4
+ appAlias: "@",
5
+ appDir: ".",
6
+ resourcesAlias: "@resources",
7
+ resourcesDir: "resources/js",
8
+ entry: "resources/js/app.tsx",
9
+ ssrEntry: "resources/js/ssr.tsx",
10
+ outDir: "public/assets",
11
+ ssrOutDir: ".guren/ssr",
12
+ devPort: 5173,
13
+ previewPort: 4173,
14
+ entryFileNames: "[name]-[hash].js",
15
+ chunkFileNames: "[name]-[hash].js",
16
+ assetFileNames: "[name]-[hash][extname]"
17
17
  };
18
18
  function gurenVitePlugin(options = {}) {
19
- const resolved = { ...defaultOptions, ...options };
20
- return {
21
- name: "guren:vite-config",
22
- enforce: "pre",
23
- config(config, env) {
24
- ensureDefaults(config, resolved, env);
25
- }
26
- };
19
+ const resolved = {
20
+ ...defaultOptions,
21
+ ...options
22
+ };
23
+ return {
24
+ name: "guren:vite-config",
25
+ enforce: "pre",
26
+ config(config, env) {
27
+ ensureDefaults(config, resolved, env);
28
+ }
29
+ };
27
30
  }
28
31
  function ensureDefaults(config, options, env) {
29
- const root = resolveRoot(config.root);
30
- ensureAliases(config, options, root);
31
- ensureServer(config, options);
32
- ensurePreview(config, options);
33
- ensureBuild(config, options, root, env);
32
+ const root = resolveRoot(config.root);
33
+ ensureAliases(config, options, root);
34
+ ensureServer(config, options);
35
+ ensurePreview(config, options);
36
+ ensureBuild(config, options, root, env);
34
37
  }
35
38
  function ensureAliases(config, options, root) {
36
- config.resolve ??= {};
37
- const alias = toAliasArray(config.resolve.alias);
38
- maybePushAlias(alias, options.appAlias, path.resolve(root, options.appDir));
39
- maybePushAlias(alias, options.resourcesAlias, path.resolve(root, options.resourcesDir));
40
- config.resolve.alias = alias;
39
+ config.resolve ??= {};
40
+ const alias = toAliasArray(config.resolve.alias);
41
+ maybePushAlias(alias, options.appAlias, path.resolve(root, options.appDir));
42
+ maybePushAlias(alias, options.resourcesAlias, path.resolve(root, options.resourcesDir));
43
+ config.resolve.alias = alias;
41
44
  }
42
45
  function ensureServer(config, options) {
43
- config.server ??= {};
44
- if (config.server.port === void 0) {
45
- config.server.port = options.devPort;
46
- }
46
+ config.server ??= {};
47
+ if (config.server.port === void 0) config.server.port = options.devPort;
47
48
  }
48
49
  function ensurePreview(config, options) {
49
- config.preview ??= {};
50
- if (config.preview.host === void 0) {
51
- config.preview.host = true;
52
- }
53
- if (config.preview.port === void 0) {
54
- config.preview.port = options.previewPort;
55
- }
50
+ config.preview ??= {};
51
+ if (config.preview.host === void 0) config.preview.host = true;
52
+ if (config.preview.port === void 0) config.preview.port = options.previewPort;
56
53
  }
57
54
  function ensureBuild(config, options, root, env) {
58
- config.build ??= {};
59
- const isSsrBuild = Boolean(env?.ssrBuild ?? env?.isSsrBuild);
60
- const isServeCommand = env?.command === "serve";
61
- if (config.build.emptyOutDir === void 0) {
62
- config.build.emptyOutDir = true;
63
- }
64
- if (isSsrBuild) {
65
- config.ssr ??= {};
66
- if (config.ssr.noExternal === void 0) {
67
- config.ssr.noExternal = true;
68
- }
69
- if (config.build.outDir === void 0) {
70
- config.build.outDir = options.ssrOutDir;
71
- }
72
- if (config.build.manifest === void 0) {
73
- config.build.manifest = true;
74
- }
75
- if (config.build.ssr === void 0) {
76
- config.build.ssr = path.resolve(root, options.ssrEntry);
77
- }
78
- config.build.rollupOptions ??= {};
79
- config.build.rollupOptions.input = path.resolve(root, options.ssrEntry);
80
- } else {
81
- if (config.build.outDir === void 0) {
82
- config.build.outDir = options.outDir;
83
- }
84
- if (config.build.manifest === void 0) {
85
- config.build.manifest = true;
86
- }
87
- if (config.build.ssrManifest === void 0) {
88
- config.build.ssrManifest = true;
89
- }
90
- if (!isServeCommand && config.base === void 0) {
91
- const derivedBase = deriveHttpBaseFromOutDir(options.outDir);
92
- if (derivedBase) {
93
- config.base = derivedBase;
94
- }
95
- }
96
- const buildOutDir = resolveBuildOutputDirectory(root, config.build.outDir);
97
- const rootPublicDir = path.resolve(root, "public");
98
- if (buildOutDir.startsWith(rootPublicDir)) {
99
- if (config.build.copyPublicDir === void 0) {
100
- config.build.copyPublicDir = false;
101
- }
102
- if (config.publicDir === void 0) {
103
- config.publicDir = false;
104
- }
105
- }
106
- }
107
- config.build.rollupOptions ??= {};
108
- if (!isSsrBuild && config.build.rollupOptions.input === void 0) {
109
- config.build.rollupOptions.input = path.resolve(root, options.entry);
110
- }
111
- const output = normalizeRollupOutput(config.build.rollupOptions.output);
112
- if (output.entryFileNames === void 0) {
113
- output.entryFileNames = options.entryFileNames;
114
- }
115
- if (output.chunkFileNames === void 0) {
116
- output.chunkFileNames = options.chunkFileNames;
117
- }
118
- if (output.assetFileNames === void 0) {
119
- output.assetFileNames = options.assetFileNames;
120
- }
121
- if (!isSsrBuild && output.manualChunks === void 0) {
122
- output.manualChunks = createDefaultManualChunks(root);
123
- }
124
- config.build.rollupOptions.output = output;
55
+ config.build ??= {};
56
+ const isSsrBuild = Boolean(env?.ssrBuild ?? env?.isSsrBuild);
57
+ const isServeCommand = env?.command === "serve";
58
+ if (config.build.emptyOutDir === void 0) config.build.emptyOutDir = true;
59
+ if (isSsrBuild) {
60
+ config.ssr ??= {};
61
+ if (config.ssr.noExternal === void 0) config.ssr.noExternal = true;
62
+ if (config.build.outDir === void 0) config.build.outDir = options.ssrOutDir;
63
+ if (config.build.manifest === void 0) config.build.manifest = true;
64
+ if (config.build.ssr === void 0) config.build.ssr = path.resolve(root, options.ssrEntry);
65
+ config.build.rollupOptions ??= {};
66
+ config.build.rollupOptions.input = path.resolve(root, options.ssrEntry);
67
+ } else {
68
+ if (config.build.outDir === void 0) config.build.outDir = options.outDir;
69
+ if (config.build.manifest === void 0) config.build.manifest = true;
70
+ if (config.build.ssrManifest === void 0) config.build.ssrManifest = true;
71
+ if (!isServeCommand && config.base === void 0) {
72
+ const derivedBase = deriveHttpBaseFromOutDir(options.outDir);
73
+ if (derivedBase) config.base = derivedBase;
74
+ }
75
+ const buildOutDir = resolveBuildOutputDirectory(root, config.build.outDir);
76
+ const rootPublicDir = path.resolve(root, "public");
77
+ if (buildOutDir.startsWith(rootPublicDir)) {
78
+ if (config.build.copyPublicDir === void 0) config.build.copyPublicDir = false;
79
+ if (config.publicDir === void 0) config.publicDir = false;
80
+ }
81
+ }
82
+ config.build.rollupOptions ??= {};
83
+ if (!isSsrBuild && config.build.rollupOptions.input === void 0) config.build.rollupOptions.input = path.resolve(root, options.entry);
84
+ const output = normalizeRollupOutput(config.build.rollupOptions.output);
85
+ if (output.entryFileNames === void 0) output.entryFileNames = options.entryFileNames;
86
+ if (output.chunkFileNames === void 0) output.chunkFileNames = options.chunkFileNames;
87
+ if (output.assetFileNames === void 0) output.assetFileNames = options.assetFileNames;
88
+ if (!isSsrBuild && output.manualChunks === void 0) output.manualChunks = createDefaultManualChunks(root);
89
+ config.build.rollupOptions.output = output;
125
90
  }
126
91
  function createDefaultManualChunks(root) {
127
- const normalizedRoot = root.replace(/\\/gu, "/");
128
- return (id) => {
129
- const normalizedId = id.replace(/\\/gu, "/");
130
- if (normalizedId.includes("/packages/inertia-client/")) {
131
- return "inertia-vendor";
132
- }
133
- if (normalizedId.includes("/packages/core/") || normalizedId.includes("/packages/server/") || normalizedId.includes("/packages/orm/")) {
134
- return "framework-vendor";
135
- }
136
- if (!normalizedId.includes("/node_modules/")) {
137
- if (normalizedId.startsWith(normalizedRoot)) {
138
- return void 0;
139
- }
140
- if (normalizedId.includes("/packages/")) {
141
- return "framework-vendor";
142
- }
143
- return void 0;
144
- }
145
- if (/[\\/]node_modules[\\/](react|react-dom|scheduler)[\\/]/u.test(normalizedId)) {
146
- return "react-vendor";
147
- }
148
- if (/[\\/]node_modules[\\/]@inertiajs[\\/]/u.test(normalizedId) || /[\\/]node_modules[\\/](axios|qs|lodash-es|lodash)[\\/]/u.test(normalizedId)) {
149
- return "inertia-vendor";
150
- }
151
- if (/[\\/]node_modules[\\/](@guren|hono)[\\/]/u.test(normalizedId)) {
152
- return "framework-vendor";
153
- }
154
- return "vendor";
155
- };
92
+ const normalizedRoot = root.replace(/\\/gu, "/");
93
+ return (id) => {
94
+ const normalizedId = id.replace(/\\/gu, "/");
95
+ if (normalizedId.includes("/packages/inertia-client/")) return "inertia-vendor";
96
+ if (normalizedId.includes("/packages/core/") || normalizedId.includes("/packages/server/") || normalizedId.includes("/packages/orm/")) return "framework-vendor";
97
+ if (!normalizedId.includes("/node_modules/")) {
98
+ if (normalizedId.startsWith(normalizedRoot)) return;
99
+ if (normalizedId.includes("/packages/")) return "framework-vendor";
100
+ return;
101
+ }
102
+ if (/[\\/]node_modules[\\/](react|react-dom|scheduler)[\\/]/u.test(normalizedId)) return "react-vendor";
103
+ if (/[\\/]node_modules[\\/]@inertiajs[\\/]/u.test(normalizedId) || /[\\/]node_modules[\\/](axios|qs|lodash-es|lodash)[\\/]/u.test(normalizedId)) return "inertia-vendor";
104
+ if (/[\\/]node_modules[\\/](@guren|hono)[\\/]/u.test(normalizedId)) return "framework-vendor";
105
+ return "vendor";
106
+ };
156
107
  }
157
108
  function resolveBuildOutputDirectory(root, outDir) {
158
- return path.isAbsolute(outDir) ? outDir : path.resolve(root, outDir);
109
+ return path.isAbsolute(outDir) ? outDir : path.resolve(root, outDir);
159
110
  }
160
111
  function deriveHttpBaseFromOutDir(outDir) {
161
- const normalized = outDir.replace(/\\/gu, "/").replace(/^\.\//u, "");
162
- if (normalized === "public") {
163
- return "/public/";
164
- }
165
- if (normalized.startsWith("public/")) {
166
- const remainder = normalized.slice("public/".length);
167
- const suffix = remainder.length > 0 ? `${remainder.replace(/\/$/u, "")}/` : "";
168
- return `/public/${suffix}`;
169
- }
170
- return void 0;
112
+ const normalized = outDir.replace(/\\/gu, "/").replace(/^\.\//u, "");
113
+ if (normalized === "public") return "/public/";
114
+ if (normalized.startsWith("public/")) {
115
+ const remainder = normalized.slice(7);
116
+ return `/public/${remainder.length > 0 ? `${remainder.replace(/\/$/u, "")}/` : ""}`;
117
+ }
171
118
  }
172
119
  function resolveRoot(root) {
173
- if (!root) {
174
- return process.cwd();
175
- }
176
- return path.isAbsolute(root) ? root : path.resolve(process.cwd(), root);
120
+ if (!root) return process.cwd();
121
+ return path.isAbsolute(root) ? root : path.resolve(process.cwd(), root);
177
122
  }
178
123
  function toAliasArray(alias) {
179
- if (Array.isArray(alias)) {
180
- return alias.slice();
181
- }
182
- if (alias && typeof alias === "object") {
183
- return Object.entries(alias).map(([find, replacement]) => ({
184
- find,
185
- replacement
186
- }));
187
- }
188
- return [];
124
+ if (Array.isArray(alias)) return alias.slice();
125
+ if (alias && typeof alias === "object") return Object.entries(alias).map(([find, replacement]) => ({
126
+ find,
127
+ replacement
128
+ }));
129
+ return [];
189
130
  }
190
131
  function maybePushAlias(alias, find, replacement) {
191
- const alreadyDefined = alias.some((entry) => entry.find === find);
192
- if (!alreadyDefined) {
193
- alias.push({ find, replacement });
194
- }
132
+ if (!alias.some((entry) => entry.find === find)) alias.push({
133
+ find,
134
+ replacement
135
+ });
195
136
  }
196
137
  function normalizeRollupOutput(output) {
197
- if (Array.isArray(output)) {
198
- if (output.length === 0) {
199
- return {};
200
- }
201
- return output[0];
202
- }
203
- return output ?? {};
138
+ if (Array.isArray(output)) {
139
+ if (output.length === 0) return {};
140
+ return output[0];
141
+ }
142
+ return output ?? {};
204
143
  }
205
- export {
206
- gurenVitePlugin as default,
207
- gurenVitePlugin
208
- };
144
+ //#endregion
145
+ export { gurenVitePlugin as default, gurenVitePlugin };
@@ -28,7 +28,7 @@ export interface GurenVitePluginOptions {
28
28
  }
29
29
  export declare function gurenVitePlugin(options?: GurenVitePluginOptions): {
30
30
  name: string;
31
- enforce: "pre";
31
+ enforce: 'pre';
32
32
  config(config: Record<string, any>, env: Record<string, any>): void;
33
33
  };
34
34
  export default gurenVitePlugin;
@@ -0,0 +1,131 @@
1
+ import chalk from "chalk";
2
+ import figlet from "figlet";
3
+ import standard from "figlet/importable-fonts/Standard.js";
4
+ //#region src/support/import-map.ts
5
+ /**
6
+ * Parses an import map JSON string into a record of module specifiers.
7
+ * Empty, null, and undefined entries are ignored so callers can safely
8
+ * merge optional overrides without additional filtering.
9
+ */
10
+ function parseImportMap(value, options = {}) {
11
+ if (!value) return {};
12
+ try {
13
+ const parsed = JSON.parse(value);
14
+ const result = {};
15
+ for (const [key, entry] of Object.entries(parsed)) if (typeof entry === "string" && entry.length > 0) result[key] = entry;
16
+ return result;
17
+ } catch (error) {
18
+ const label = options.context ?? "import map";
19
+ console.warn(`Failed to parse ${label}. Expected JSON object.`, error);
20
+ return {};
21
+ }
22
+ }
23
+ //#endregion
24
+ //#region src/support/inertia-defaults.ts
25
+ /**
26
+ * The stylesheet *source* path the dev asset configuration falls back to.
27
+ *
28
+ * Lives in a leaf module because two sides read it and must agree: the dev
29
+ * configuration in `http/inertia-assets.ts` publishes it into
30
+ * `GUREN_INERTIA_STYLES`, and the document renderer in
31
+ * `mvc/inertia/InertiaEngine.ts` drops exactly this path again when a dev
32
+ * server owns the script entry (the compiled CSS then arrives through the
33
+ * module graph). Importing either of those modules from the other would drag
34
+ * runtime-specific dependencies across the Workers/Lambda boundary or create
35
+ * an import cycle.
36
+ */
37
+ const DEFAULT_DEV_STYLES_ENTRY = "/resources/css/app.css";
38
+ //#endregion
39
+ //#region package.json
40
+ var version = "2.11.0";
41
+ //#endregion
42
+ //#region src/http/dev-banner.ts
43
+ figlet.parseFont("Standard", standard);
44
+ function generateAsciiArt(text) {
45
+ try {
46
+ return figlet.textSync(text, {
47
+ font: "Standard",
48
+ horizontalLayout: "default",
49
+ verticalLayout: "default"
50
+ });
51
+ } catch (error) {
52
+ console.error("Failed to generate FIGlet banner, falling back to plain text:", error);
53
+ return text.toUpperCase();
54
+ }
55
+ }
56
+ const GUREN_ASCII_ART = chalk.redBright.bold(generateAsciiArt("GUREN"));
57
+ const GUREN_VERSION = version;
58
+ /**
59
+ * A wildcard bind answers on every interface but is not itself dialable on
60
+ * every platform.
61
+ *
62
+ * Lives here rather than beside its other caller because the banner and
63
+ * `Application.listen()`'s returned address are two renderings of one fact,
64
+ * and a platform caveat added to only one of them is the drift this replaces.
65
+ */
66
+ function isWildcardHost(hostname) {
67
+ return hostname === "0.0.0.0" || hostname === "::";
68
+ }
69
+ /** `host:port`, bracketing an IPv6 literal so the result is dialable. */
70
+ function formatHostPort(hostname, port) {
71
+ return `${hostname.includes(":") ? `[${hostname}]` : hostname}:${port}`;
72
+ }
73
+ function logDevServerBanner({ hostname, port, assetsUrl = "http://localhost:5173" }) {
74
+ const localUrl = `http://localhost:${port}`;
75
+ const boundUrl = `http://${formatHostPort(hostname, port)}`;
76
+ const boundLabel = isWildcardHost(hostname) ? " (all interfaces)" : "";
77
+ const header = [
78
+ GUREN_ASCII_ART,
79
+ chalk.magentaBright.bold(`Guren v${GUREN_VERSION} ignites — burning bright like a crimson lotus.`),
80
+ ""
81
+ ];
82
+ const detail = (label, value) => `${chalk.magentaBright(" •")} ${chalk.bold(label.padEnd(14))}: ${chalk.cyanBright(value)}`;
83
+ const banner = [
84
+ ...header,
85
+ detail("App URL", localUrl),
86
+ detail("Bound address", `${boundUrl}${boundLabel}`),
87
+ detail("Asset server", `${assetsUrl} (Vite)`),
88
+ "",
89
+ chalk.yellowBright("Press Ctrl+C to douse the flames."),
90
+ ""
91
+ ].join("\n");
92
+ console.log(banner);
93
+ }
94
+ //#endregion
95
+ //#region src/http/vite-dev-server.ts
96
+ /**
97
+ * Build the inline config the managed dev server starts with.
98
+ *
99
+ * `server.host` is only set when the caller asked for one. Left undefined it
100
+ * is dropped during Vite's config merge, so the project's own `vite.config.ts`
101
+ * decides, falling back to Vite's localhost-only default.
102
+ */
103
+ function resolveViteDevServerConfig(options = {}) {
104
+ const { root = process.cwd(), config = {}, host, port } = options;
105
+ return {
106
+ clearScreen: false,
107
+ ...config,
108
+ root: config.root ?? root,
109
+ server: {
110
+ host,
111
+ port,
112
+ ...config.server ?? {}
113
+ }
114
+ };
115
+ }
116
+ async function startViteDevServer(options = {}) {
117
+ const { host, port } = options;
118
+ const { createServer } = await import("vite");
119
+ const server = await createServer(resolveViteDevServerConfig(options));
120
+ await server.listen();
121
+ const resolved = server.resolvedUrls;
122
+ const localUrls = resolved?.local?.length ? resolved.local : [`http://${typeof host === "string" ? host : "localhost"}:${server.config.server.port ?? port ?? 5173}`];
123
+ const networkUrls = resolved?.network ?? [];
124
+ return {
125
+ server,
126
+ localUrl: localUrls[0],
127
+ networkUrls
128
+ };
129
+ }
130
+ //#endregion
131
+ export { logDevServerBanner as a, isWildcardHost as i, GUREN_ASCII_ART as n, DEFAULT_DEV_STYLES_ENTRY as o, formatHostPort as r, parseImportMap as s, startViteDevServer as t };
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@guren/server",
3
- "version": "2.10.0",
3
+ "version": "2.11.0",
4
4
  "type": "module",
5
+ "sideEffects": false,
5
6
  "license": "MIT",
6
7
  "repository": {
7
8
  "type": "git",
@@ -107,13 +108,13 @@
107
108
  }
108
109
  },
109
110
  "scripts": {
110
- "build": "tsup && tsc -p tsconfig.build.json && bun ../../scripts/fix-dts-extensions.ts dist",
111
+ "build": "bun --bun tsdown && tsc -p tsconfig.build.json && bun ../../scripts/fix-dts-extensions.ts dist",
111
112
  "dev": "bun --watch src/index.ts",
112
113
  "typecheck": "tsc --noEmit",
113
114
  "test": "bun test"
114
115
  },
115
116
  "dependencies": {
116
- "@guren/orm": "^2.6.0",
117
+ "@guren/orm": "^2.6.1",
117
118
  "@modelcontextprotocol/sdk": "^1.30.0",
118
119
  "chalk": "^5.3.0",
119
120
  "consola": "^3.4.2",
@@ -147,8 +148,8 @@
147
148
  "@types/ioredis": "^5.0.0",
148
149
  "@types/node": "^20.14.10",
149
150
  "@types/nodemailer": "^8.0.1",
150
- "tsup": "^8.5.0",
151
- "typescript": "^5.4.0",
151
+ "tsdown": "^0.22.14",
152
+ "typescript": "^7.0.2",
152
153
  "vite": "^8.0.0"
153
154
  }
154
155
  }