@devframes/vite 0.9.9 → 0.9.10

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/hub.d.mts CHANGED
@@ -58,7 +58,9 @@ interface ViteDevframeHubOptions {
58
58
  */
59
59
  auth?: InitHubOptions['auth'];
60
60
  /**
61
- * Expose the aggregate MCP endpoint at `<base>__mcp`.
61
+ * Expose the aggregate MCP endpoint at `<base>__mcp`. Defaults to `'auto'`
62
+ * (mount once any mounted devframe exposes an agent surface); `true`
63
+ * forces it on, `false` off.
62
64
  */
63
65
  mcp?: InitHubOptions['mcp'];
64
66
  /** Publish this hub in the global instance registry. Default: off. */
@@ -79,6 +81,17 @@ interface ViteDevframeHubOptions {
79
81
  * @default false
80
82
  */
81
83
  quiet?: boolean;
84
+ /**
85
+ * Also bake the hub into `vite build` output: `buildHub` writes the whole
86
+ * static hub subtree (each devframe's SPA, the RPC dump, `embedded.js`, …)
87
+ * into `<outDir><base>`, and the UI's `embedded.js` script tag is injected
88
+ * into the built HTML, so the deployed app ships working devtools against
89
+ * a `static` backend (baked reads, no live server). Off by default: a
90
+ * production bundle only carries devtools when the host opts in.
91
+ *
92
+ * @default false
93
+ */
94
+ build?: boolean;
82
95
  }
83
96
  /**
84
97
  * Mount a whole **devframes-hub** (many integrations under one namespace,
package/dist/hub.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  import process from "node:process";
2
+ import { resolve } from "pathe";
2
3
  import { Server } from "node:http";
3
4
  import { DEVFRAMES_HUB_BASE, normalizeHubBase } from "@devframes/hub/constants";
4
5
  import { initHub } from "@devframes/hub/initiate";
@@ -29,14 +30,20 @@ function viteDevframeHub(options = {}) {
29
30
  let viteConfig;
30
31
  let instance;
31
32
  let embeddedSrc;
33
+ let buildUi;
32
34
  const teardown = async () => {
33
35
  const previous = instance;
34
36
  instance = void 0;
35
37
  await previous?.close().catch(() => {});
36
38
  };
39
+ const resolveUi = async () => options.ui === false ? void 0 : options.ui ?? await loadDefaultUi();
37
40
  return {
38
41
  name: "devframes:hub",
39
- apply: "serve",
42
+ /**
43
+ * Dev middleware by default; a production bundle only carries the hub
44
+ * when the host opts into the static build.
45
+ */
46
+ apply: (_, env) => env.command === "serve" || options.build === true,
40
47
  configResolved(config) {
41
48
  viteConfig = config;
42
49
  },
@@ -44,7 +51,7 @@ function viteDevframeHub(options = {}) {
44
51
  if (!options.quiet) recommendViteDevtools();
45
52
  await teardown();
46
53
  const cwd = options.cwd ?? viteConfig?.root ?? process.cwd();
47
- const ui = options.ui === false ? void 0 : options.ui ?? await loadDefaultUi();
54
+ const ui = await resolveUi();
48
55
  const devframes = attachClientScripts(options.devframes, options.clientScripts);
49
56
  const httpServer = server.httpServer instanceof Server ? server.httpServer : void 0;
50
57
  const hub = initHub({
@@ -91,6 +98,11 @@ function viteDevframeHub(options = {}) {
91
98
  teardown();
92
99
  });
93
100
  },
101
+ async buildStart() {
102
+ if (viteConfig?.command !== "build" || !options.build) return;
103
+ buildUi = await resolveUi();
104
+ embeddedSrc = buildUi?.embedded ? `${base}embedded.js` : void 0;
105
+ },
94
106
  transformIndexHtml() {
95
107
  if (!embeddedSrc) return;
96
108
  return [{
@@ -104,6 +116,24 @@ function viteDevframeHub(options = {}) {
104
116
  },
105
117
  async closeBundle() {
106
118
  await teardown();
119
+ if (viteConfig?.command !== "build" || !options.build) return;
120
+ const cwd = options.cwd ?? viteConfig.root;
121
+ const { buildHub } = await import("@devframes/hub/build");
122
+ await buildHub({
123
+ base,
124
+ cwd,
125
+ outDir: resolve(viteConfig.root, viteConfig.build.outDir, base.slice(1)),
126
+ devframes: attachClientScripts(options.devframes, options.clientScripts) ?? [],
127
+ ...buildUi ? { ui: buildUi } : {},
128
+ ...pickDefined(options, [
129
+ "renderers",
130
+ "rpcDeclarations",
131
+ "getStorageDir",
132
+ "name",
133
+ "version",
134
+ "configure"
135
+ ])
136
+ });
107
137
  }
108
138
  };
109
139
  }
package/dist/single.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { IncomingMessage, ServerResponse } from "node:http";
2
2
  import { Plugin } from "vite";
3
- import { DevframeDefinition, McpRouteOptions } from "devframe";
3
+ import { DevframeDefinition, McpSetting } from "devframe";
4
4
  import { DevframeAuthHandler } from "devframe/node/auth";
5
5
  //#region src/single.d.ts
6
6
  /**
@@ -88,9 +88,10 @@ interface DevframeViteBridgeOptions {
88
88
  * Expose the bridge's route-based MCP server (Streamable-HTTP) at
89
89
  * `<base>__mcp` (on the Vite app's own origin) and advertise it in the
90
90
  * bridge's `__connection.json`. Overrides `def.cli?.mcp`, `undefined`
91
- * falls through to it, `false` disables the route regardless.
91
+ * falls through to it, then to the `'auto'` default (mount once the agent
92
+ * surface is non-empty); `false` disables the route regardless.
92
93
  */
93
- mcp?: boolean | McpRouteOptions;
94
+ mcp?: McpSetting;
94
95
  }
95
96
  /**
96
97
  * Bridge a devframe's RPC + WebSocket backend into an existing Vite dev
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@devframes/vite",
3
3
  "type": "module",
4
- "version": "0.9.9",
4
+ "version": "0.9.10",
5
5
  "description": "Vite plugin for mounting a devframe inside any Vite-based host (Astro, SolidStart, Nuxt, plain Vite apps).",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -30,9 +30,9 @@
30
30
  "dist"
31
31
  ],
32
32
  "peerDependencies": {
33
- "@devframes/hub": "0.9.9",
34
- "@devframes/hub-ui": "0.9.9",
35
- "devframe": "0.9.9",
33
+ "@devframes/hub": "0.9.10",
34
+ "@devframes/hub-ui": "0.9.10",
35
+ "devframe": "0.9.10",
36
36
  "vite": "^7.0.0 || ^8.0.0"
37
37
  },
38
38
  "peerDependenciesMeta": {
@@ -50,11 +50,11 @@
50
50
  "pathe": "^2.0.3"
51
51
  },
52
52
  "devDependencies": {
53
- "@devframes/hub": "0.9.9",
54
- "@devframes/hub-ui": "0.9.9",
53
+ "@devframes/hub": "0.9.10",
54
+ "@devframes/hub-ui": "0.9.10",
55
55
  "@modelcontextprotocol/client": "^2.0.0",
56
56
  "@types/node": "^26.4.0",
57
- "devframe": "0.9.9",
57
+ "devframe": "0.9.10",
58
58
  "get-port-please": "^3.2.0",
59
59
  "tsdown": "^0.22.14",
60
60
  "vite": "^8.2.2",