@guren/server 2.35.0 → 2.36.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.
- package/dist/{DocsViewerServiceProvider-BVPZjwQp.js → DocsViewerServiceProvider-DzrxQoYh.js} +15 -4
- package/dist/Event-COT3f5Xd.js +28 -0
- package/dist/{McpServiceProvider-CXOokGax.js → McpServiceProvider-BOeQyt7u.js} +2 -0
- package/dist/PrivateChannel-1krGz028.js +187 -0
- package/dist/{Resource-y-7zzZSB.js → Resource-PhnO_wNO.js} +113 -12
- package/dist/agent/derive.d.ts +23 -1
- package/dist/agent/dispatch.d.ts +12 -1
- package/dist/agent/pipeline.d.ts +6 -0
- package/dist/agent/public.d.ts +1 -1
- package/dist/agent/public.js +1 -1
- package/dist/{api-token-1-INqeVU.js → api-token-Cs1myxf6.js} +15 -1
- package/dist/auth/index.js +2 -2
- package/dist/{auth-CO9MlQNE.js → auth-DYWBlmpS.js} +1 -1
- package/dist/broadcasting/BroadcastManager.d.ts +19 -5
- package/dist/broadcasting/event-target.d.ts +9 -0
- package/dist/broadcasting/index.d.ts +3 -1
- package/dist/broadcasting/index.js +3 -2
- package/dist/broadcasting/sender-envelope.d.ts +26 -0
- package/dist/broadcasting/types.d.ts +27 -2
- package/dist/{broadcasting-D04a3R02.js → broadcasting-Bh6QoMpy.js} +50 -95
- package/dist/{contained-path-BkNSBljW.js → contained-path-DOVauNQC.js} +1 -22
- package/dist/{dev-banner-BUrHz-LF.js → dev-banner-DGxB3HGY.js} +3 -3
- package/dist/{dispatch-ENWpBxbE.js → dispatch-CDNqcB3Q.js} +51 -12
- package/dist/events/index.js +2 -1
- package/dist/{events-B6gfJkCH.js → events-DW197Nur.js} +2 -28
- package/dist/http/vite-dev-server.d.ts +18 -1
- package/dist/http/vite-manifest.d.ts +4 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.js +109 -22
- package/dist/internal/agent-principal.d.ts +8 -0
- package/dist/internal/testing.d.ts +1 -0
- package/dist/internal/testing.js +2 -2
- package/dist/mcp/index.js +1 -1
- package/dist/mvc/Router.d.ts +13 -0
- package/dist/mvc/inertia/InertiaEngine.d.ts +3 -0
- package/dist/mvc/inertia/props.d.ts +54 -3
- package/dist/runtime/index.js +5 -3
- package/dist/storage/index.js +1 -1
- package/dist/{storage-YPbsV9ju.js → storage-ziIKgHON.js} +2 -1
- package/dist/trim-slashes-BLY9hKAa.js +22 -0
- package/dist/vite/index.d.ts +2 -0
- package/dist/vite/index.js +283 -1
- package/dist/vite/mcp-app.d.ts +59 -0
- package/dist/vite/plugin.d.ts +12 -0
- package/dist/{vite-manifest-DO0pU1vm.js → vite-dev-server-Ag90otai.js} +25 -114
- package/dist/vite-manifest-BdXRybeq.js +129 -0
- package/package.json +1 -1
- package/dist/host-port-t6wQFaRu.js +0 -15
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { n as trimTrailingSlashes } from "./trim-slashes-BLY9hKAa.js";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
4
|
+
//#region src/http/host-port.ts
|
|
5
|
+
/**
|
|
6
|
+
* A wildcard bind answers on every interface but is not itself dialable on
|
|
7
|
+
* every platform. The dev banner and `Application.listen()`'s returned address
|
|
8
|
+
* both render this fact.
|
|
9
|
+
*/
|
|
10
|
+
function isWildcardHost(hostname) {
|
|
11
|
+
return hostname === "0.0.0.0" || hostname === "::";
|
|
12
|
+
}
|
|
13
|
+
/** `host:port`, bracketing an IPv6 literal so the result is dialable. */
|
|
14
|
+
function formatHostPort(hostname, port) {
|
|
15
|
+
return `${hostname.includes(":") ? `[${hostname}]` : hostname}:${port}`;
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/http/vite-manifest.ts
|
|
19
|
+
/**
|
|
20
|
+
* The one rule for how Vite build output is found and addressed, shared by the
|
|
21
|
+
* Inertia asset wiring (`inertia-assets.ts`) and `viteAsset()` (`vite-assets.ts`,
|
|
22
|
+
* RFC 0014) so the two cannot drift: what counts as a manifest, where one may
|
|
23
|
+
* live, which URL prefix serves the hashed files, and what "the dev server is
|
|
24
|
+
* on" means.
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* Where `configureInertiaAssets` serves hashed build output from. The deploy
|
|
28
|
+
* builds restate it as `CLIENT_ASSETS_URL_PREFIX` in @guren/core's
|
|
29
|
+
* internal/deploy-build.ts; tests/http/vite-manifest.test.ts pins the two equal.
|
|
30
|
+
*/
|
|
31
|
+
const PUBLIC_ASSETS_URL_PREFIX = "/public/assets/";
|
|
32
|
+
/**
|
|
33
|
+
* The Vite default the framework assumes when no dev-server URL is set. Not
|
|
34
|
+
* `GUREN_VITE_PORT`: a managed start publishes the URL Vite bound instead.
|
|
35
|
+
*/
|
|
36
|
+
const DEFAULT_DEV_SERVER_URL = "http://localhost:5173";
|
|
37
|
+
/**
|
|
38
|
+
* Production for *asset* purposes: `NODE_ENV` says so and no dev server is
|
|
39
|
+
* configured — a configured dev server means dev asset serving even when
|
|
40
|
+
* `NODE_ENV` is `production` (E2E runs do exactly this).
|
|
41
|
+
*/
|
|
42
|
+
function isViteProduction(devServerUrl = process.env.VITE_DEV_SERVER_URL) {
|
|
43
|
+
return process.env.NODE_ENV === "production" && typeof devServerUrl !== "string";
|
|
44
|
+
}
|
|
45
|
+
function normalizeDevServerUrl(value) {
|
|
46
|
+
if (!value) return value;
|
|
47
|
+
const trimmed = value.trim();
|
|
48
|
+
if (!trimmed) return trimmed;
|
|
49
|
+
const stripped = trimTrailingSlashes(trimmed);
|
|
50
|
+
return stripped.length > 0 ? stripped : "/";
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Candidate client-manifest locations, `.vite/manifest.json` first: Vite >= 5
|
|
54
|
+
* writes it there, so a flat `manifest.json` is likely a stale leftover. The
|
|
55
|
+
* deploy plugins order the same pair through `@guren/core`'s deploy-build
|
|
56
|
+
* helpers and must agree, or an app with both layouts resolves different asset
|
|
57
|
+
* versions after a serverless deploy; `tests/http/vite-manifest.test.ts` pins it.
|
|
58
|
+
*/
|
|
59
|
+
function clientManifestCandidates(baseDir) {
|
|
60
|
+
const root = baseDir ?? process.cwd();
|
|
61
|
+
return [resolve(root, "public/assets/.vite/manifest.json"), resolve(root, "public/assets/manifest.json")];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* `__path__` label for an injected manifest, so "entry not in the manifest"
|
|
65
|
+
* errors name the real source rather than a path that was never read.
|
|
66
|
+
*/
|
|
67
|
+
const INJECTED_CLIENT_MANIFEST_SOURCE = "GUREN_VITE_MANIFEST (injected by the deploy build)";
|
|
68
|
+
const INJECTED_MANIFEST_HINT = "It must hold the Vite client manifest text (deploy plugins inject it at build time), not a path.";
|
|
69
|
+
/**
|
|
70
|
+
* Attach one of the manifest's bookkeeping fields. `enumerable: false` is the
|
|
71
|
+
* invariant: a stamped field must never leak into `Object.keys` or a
|
|
72
|
+
* re-serialization of the manifest.
|
|
73
|
+
*/
|
|
74
|
+
function defineHidden(manifest, key, value) {
|
|
75
|
+
Object.defineProperty(manifest, key, {
|
|
76
|
+
value,
|
|
77
|
+
enumerable: false
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The client manifest a deploy build injected for runtimes that do not ship
|
|
82
|
+
* `public/assets/manifest.json`: `GUREN_VITE_MANIFEST` holds the manifest *JSON
|
|
83
|
+
* text*, not a path. Fails loudly on a value that is set but not a manifest,
|
|
84
|
+
* because falling through to the filesystem would end in "run `bunx vite build`"
|
|
85
|
+
* — a diagnosis pointing away from the variable that is actually broken.
|
|
86
|
+
*/
|
|
87
|
+
function injectedClientManifest() {
|
|
88
|
+
const raw = process.env.GUREN_VITE_MANIFEST;
|
|
89
|
+
if (typeof raw !== "string" || raw.length === 0) return;
|
|
90
|
+
let parsed;
|
|
91
|
+
try {
|
|
92
|
+
parsed = JSON.parse(raw);
|
|
93
|
+
} catch (error) {
|
|
94
|
+
throw new Error(`GUREN_VITE_MANIFEST is set but is not valid JSON. ${INJECTED_MANIFEST_HINT}`, { cause: error });
|
|
95
|
+
}
|
|
96
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) throw new Error(`GUREN_VITE_MANIFEST is set but does not hold a manifest object. ${INJECTED_MANIFEST_HINT}`);
|
|
97
|
+
const manifest = parsed;
|
|
98
|
+
defineHidden(manifest, "__path__", INJECTED_CLIENT_MANIFEST_SOURCE);
|
|
99
|
+
return manifest;
|
|
100
|
+
}
|
|
101
|
+
function loadViteManifest(candidatePaths, label, options = {}) {
|
|
102
|
+
const warnOnMissing = options.warnOnMissing ?? true;
|
|
103
|
+
const command = label === "SSR" ? "bunx vite build --ssr" : "bunx vite build";
|
|
104
|
+
for (const manifestPath of candidatePaths) try {
|
|
105
|
+
const raw = readFileSync(manifestPath, "utf8");
|
|
106
|
+
const manifest = JSON.parse(raw);
|
|
107
|
+
defineHidden(manifest, "__path__", manifestPath);
|
|
108
|
+
if (options.includeRaw) defineHidden(manifest, "__raw__", raw);
|
|
109
|
+
return manifest;
|
|
110
|
+
} catch (error) {
|
|
111
|
+
if (error.code !== "ENOENT") {
|
|
112
|
+
console.warn(`Unable to load ${label} Vite manifest at ${manifestPath}.`, error);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (warnOnMissing && candidatePaths.length) console.warn(`Unable to load ${label} Vite manifest. Checked paths:\n${candidatePaths.map((p) => ` - ${p}`).join("\n")}\nRun \`${command}\` before starting in production.`);
|
|
117
|
+
}
|
|
118
|
+
function getManifestFile(entry) {
|
|
119
|
+
if (!entry) return;
|
|
120
|
+
if (Array.isArray(entry)) return entry[0];
|
|
121
|
+
if (typeof entry === "string") return entry;
|
|
122
|
+
if ("file" in entry && typeof entry.file === "string") return entry.file;
|
|
123
|
+
}
|
|
124
|
+
function getManifestCss(entry) {
|
|
125
|
+
if (!entry || Array.isArray(entry) || typeof entry === "string") return;
|
|
126
|
+
return entry.css;
|
|
127
|
+
}
|
|
128
|
+
//#endregion
|
|
129
|
+
export { getManifestCss as a, isViteProduction as c, formatHostPort as d, isWildcardHost as f, clientManifestCandidates as i, loadViteManifest as l, INJECTED_CLIENT_MANIFEST_SOURCE as n, getManifestFile as o, PUBLIC_ASSETS_URL_PREFIX as r, injectedClientManifest as s, DEFAULT_DEV_SERVER_URL as t, normalizeDevServerUrl as u };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guren/server",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.36.0",
|
|
4
4
|
"description": "HTTP layer of the Guren framework, on Hono: routing, controllers, middleware, auth, sessions, queues and the AWS Lambda adapter. Applications import it through @guren/core.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"guren",
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
//#region src/http/host-port.ts
|
|
2
|
-
/**
|
|
3
|
-
* A wildcard bind answers on every interface but is not itself dialable on
|
|
4
|
-
* every platform. The dev banner and `Application.listen()`'s returned address
|
|
5
|
-
* both render this fact.
|
|
6
|
-
*/
|
|
7
|
-
function isWildcardHost(hostname) {
|
|
8
|
-
return hostname === "0.0.0.0" || hostname === "::";
|
|
9
|
-
}
|
|
10
|
-
/** `host:port`, bracketing an IPv6 literal so the result is dialable. */
|
|
11
|
-
function formatHostPort(hostname, port) {
|
|
12
|
-
return `${hostname.includes(":") ? `[${hostname}]` : hostname}:${port}`;
|
|
13
|
-
}
|
|
14
|
-
//#endregion
|
|
15
|
-
export { isWildcardHost as n, formatHostPort as t };
|