devframe 0.1.21 → 0.2.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 (92) hide show
  1. package/README.md +40 -18
  2. package/dist/{_shared-iZy45oG3.mjs → _shared-BrKv3CYt.mjs} +5 -5
  3. package/dist/adapters/build.d.mts +5 -5
  4. package/dist/adapters/build.mjs +13 -12
  5. package/dist/adapters/cli.d.mts +4 -4
  6. package/dist/adapters/cli.mjs +5 -5
  7. package/dist/adapters/dev.d.mts +21 -12
  8. package/dist/adapters/dev.mjs +1 -1
  9. package/dist/adapters/embedded.d.mts +5 -5
  10. package/dist/adapters/embedded.mjs +2 -2
  11. package/dist/adapters/mcp.d.mts +3 -3
  12. package/dist/adapters/mcp.mjs +5 -5
  13. package/dist/chunk-e9Ob2GDo.mjs +26 -0
  14. package/dist/client/index.d.mts +8 -5
  15. package/dist/client/index.mjs +12 -12
  16. package/dist/colors-DS7k8ljB.mjs +123 -0
  17. package/dist/{context-BJ4r2SmR.mjs → context-BBi2IQDm.mjs} +19 -37
  18. package/dist/{context-internal-saIAfNVw.d.mts → context-DRa0wGsC.d.mts} +2 -2
  19. package/dist/{dev-CdAy400a.mjs → dev-CewNNE2R.mjs} +24 -28
  20. package/dist/{devtool-CNvLs2_Y.d.mts → devframe-R5Ex5K5L.d.mts} +41 -66
  21. package/dist/{diagnostics-DxPnRoXO.mjs → diagnostics-Cg9ycFIM.mjs} +7 -2
  22. package/dist/hash-CIBte1yS.mjs +263 -0
  23. package/dist/helpers/vite.d.mts +65 -0
  24. package/dist/helpers/vite.mjs +94 -0
  25. package/dist/{human-id-BLoGo_e5.mjs → human-id-adtUWQLr.mjs} +12 -3
  26. package/dist/{index-CuLRIMto.d.mts → index-DB2Ie0Or.d.mts} +2 -3
  27. package/dist/index.d.mts +4 -5
  28. package/dist/index.mjs +2 -5
  29. package/dist/launch-editor-CX_n_0SS.mjs +581 -0
  30. package/dist/node/auth.d.mts +44 -0
  31. package/dist/node/auth.mjs +55 -0
  32. package/dist/node/index.d.mts +13 -55
  33. package/dist/node/index.mjs +6 -62
  34. package/dist/node/internal.d.mts +16 -0
  35. package/dist/node/internal.mjs +50 -0
  36. package/dist/{open-Dede_w9r.mjs → open-B2ah1IKK.mjs} +38 -24
  37. package/dist/recipes/open-helpers.d.mts +4 -9
  38. package/dist/recipes/open-helpers.mjs +7 -12
  39. package/dist/revoke-DIMz1r7-.mjs +35 -0
  40. package/dist/rpc/index.d.mts +3 -3
  41. package/dist/rpc/index.mjs +4 -4
  42. package/dist/rpc/transports/ws-client.d.mts +1 -1
  43. package/dist/rpc/transports/ws-client.mjs +2 -1
  44. package/dist/rpc/transports/ws-server.d.mts +1 -1
  45. package/dist/rpc/transports/ws-server.mjs +2 -1
  46. package/dist/{rpc-INbWfHoX.mjs → rpc-DAzoVCR0.mjs} +5 -4
  47. package/dist/{serialization-DwKi05Pn.mjs → serialization-CwO31axa.mjs} +1 -2
  48. package/dist/{server-CBsxXIH5.mjs → server-DOk4grlJ.mjs} +4 -4
  49. package/dist/{server-BAqOajx_.d.mts → server-DzKz023G.d.mts} +8 -7
  50. package/dist/shared-state-q9-1EOSX.mjs +928 -0
  51. package/dist/{static-dump-D5VH8Iqk.mjs → static-dump-C67bCuse.mjs} +1 -1
  52. package/dist/{context-internal-Dx_NoSv1.mjs → storage-CNvfBGQ5.mjs} +5 -87
  53. package/dist/structured-clone-CD2l4fI3.mjs +221 -0
  54. package/dist/types/index.d.mts +4 -4
  55. package/dist/types/index.mjs +3 -3
  56. package/dist/utils/colors.d.mts +28 -0
  57. package/dist/utils/colors.mjs +2 -0
  58. package/dist/utils/events.d.mts +1 -1
  59. package/dist/utils/hash.d.mts +7 -0
  60. package/dist/utils/hash.mjs +2 -0
  61. package/dist/utils/human-id.d.mts +6 -8
  62. package/dist/utils/human-id.mjs +1 -2
  63. package/dist/utils/launch-editor.d.mts +13 -0
  64. package/dist/utils/launch-editor.mjs +2 -0
  65. package/dist/utils/open.d.mts +16 -0
  66. package/dist/utils/open.mjs +2 -0
  67. package/dist/utils/serve-static.d.mts +40 -0
  68. package/dist/utils/serve-static.mjs +173 -0
  69. package/dist/utils/shared-state.d.mts +1 -1
  70. package/dist/utils/shared-state.mjs +1 -35
  71. package/dist/utils/streaming-channel.d.mts +1 -1
  72. package/dist/utils/structured-clone.d.mts +21 -0
  73. package/dist/utils/structured-clone.mjs +2 -0
  74. package/dist/utils/when.d.mts +33 -50
  75. package/dist/utils/when.mjs +21 -3
  76. package/dist/{ws-client-CjPuPFbA.d.mts → ws-client-Bavoya6-.d.mts} +1 -1
  77. package/dist/{ws-server-C7LnhOHi.d.mts → ws-server-DjvlwLuM.d.mts} +1 -1
  78. package/package.json +38 -18
  79. package/skills/devframe/SKILL.md +64 -39
  80. package/skills/devframe/templates/{counter-devtool.ts → counter-devframe.ts} +4 -4
  81. package/skills/devframe/templates/{spa-devtool.ts → spa-devframe.ts} +5 -5
  82. package/skills/devframe/templates/vite-client.ts +2 -2
  83. package/dist/adapters/vite.d.mts +0 -33
  84. package/dist/adapters/vite.mjs +0 -32
  85. package/dist/internal/index.d.mts +0 -16
  86. package/dist/internal/index.mjs +0 -3
  87. package/dist/utils/state.d.mts +0 -50
  88. package/dist/utils/state.mjs +0 -26
  89. package/dist/{define-Bb4zh-Dc.mjs → define-CW9gLnyG.mjs} +0 -0
  90. package/dist/{host-h3-9jeHcltx.mjs → host-h3-Dz8YnFgu.mjs} +1 -1
  91. /package/dist/{transports-DSV5_5QM.mjs → transports-BnCs4rj9.mjs} +0 -0
  92. /package/dist/{types-C5OVe4AC.d.mts → types-4rdUEi2R.d.mts} +0 -0
@@ -0,0 +1,263 @@
1
+ //#region ../../node_modules/.pnpm/ohash@2.0.11/node_modules/ohash/dist/shared/ohash.D__AXeF1.mjs
2
+ function serialize(o) {
3
+ return typeof o == "string" ? `'${o}'` : new c().serialize(o);
4
+ }
5
+ const c = /* @__PURE__ */ function() {
6
+ class o {
7
+ #t = /* @__PURE__ */ new Map();
8
+ compare(t, r) {
9
+ const e = typeof t, n = typeof r;
10
+ return e === "string" && n === "string" ? t.localeCompare(r) : e === "number" && n === "number" ? t - r : String.prototype.localeCompare.call(this.serialize(t, true), this.serialize(r, true));
11
+ }
12
+ serialize(t, r) {
13
+ if (t === null) return "null";
14
+ switch (typeof t) {
15
+ case "string": return r ? t : `'${t}'`;
16
+ case "bigint": return `${t}n`;
17
+ case "object": return this.$object(t);
18
+ case "function": return this.$function(t);
19
+ }
20
+ return String(t);
21
+ }
22
+ serializeObject(t) {
23
+ const r = Object.prototype.toString.call(t);
24
+ if (r !== "[object Object]") return this.serializeBuiltInType(r.length < 10 ? `unknown:${r}` : r.slice(8, -1), t);
25
+ const e = t.constructor, n = e === Object || e === void 0 ? "" : e.name;
26
+ if (n !== "" && globalThis[n] === e) return this.serializeBuiltInType(n, t);
27
+ if (typeof t.toJSON == "function") {
28
+ const i = t.toJSON();
29
+ return n + (i !== null && typeof i == "object" ? this.$object(i) : `(${this.serialize(i)})`);
30
+ }
31
+ return this.serializeObjectEntries(n, Object.entries(t));
32
+ }
33
+ serializeBuiltInType(t, r) {
34
+ const e = this["$" + t];
35
+ if (e) return e.call(this, r);
36
+ if (typeof r?.entries == "function") return this.serializeObjectEntries(t, r.entries());
37
+ throw new Error(`Cannot serialize ${t}`);
38
+ }
39
+ serializeObjectEntries(t, r) {
40
+ const e = Array.from(r).sort((i, a) => this.compare(i[0], a[0]));
41
+ let n = `${t}{`;
42
+ for (let i = 0; i < e.length; i++) {
43
+ const [a, l] = e[i];
44
+ n += `${this.serialize(a, true)}:${this.serialize(l)}`, i < e.length - 1 && (n += ",");
45
+ }
46
+ return n + "}";
47
+ }
48
+ $object(t) {
49
+ let r = this.#t.get(t);
50
+ return r === void 0 && (this.#t.set(t, `#${this.#t.size}`), r = this.serializeObject(t), this.#t.set(t, r)), r;
51
+ }
52
+ $function(t) {
53
+ const r = Function.prototype.toString.call(t);
54
+ return r.slice(-15) === "[native code] }" ? `${t.name || ""}()[native]` : `${t.name}(${t.length})${r.replace(/\s*\n\s*/g, "")}`;
55
+ }
56
+ $Array(t) {
57
+ let r = "[";
58
+ for (let e = 0; e < t.length; e++) r += this.serialize(t[e]), e < t.length - 1 && (r += ",");
59
+ return r + "]";
60
+ }
61
+ $Date(t) {
62
+ try {
63
+ return `Date(${t.toISOString()})`;
64
+ } catch {
65
+ return "Date(null)";
66
+ }
67
+ }
68
+ $ArrayBuffer(t) {
69
+ return `ArrayBuffer[${new Uint8Array(t).join(",")}]`;
70
+ }
71
+ $Set(t) {
72
+ return `Set${this.$Array(Array.from(t).sort((r, e) => this.compare(r, e)))}`;
73
+ }
74
+ $Map(t) {
75
+ return this.serializeObjectEntries("Map", t.entries());
76
+ }
77
+ }
78
+ for (const s of [
79
+ "Error",
80
+ "RegExp",
81
+ "URL"
82
+ ]) o.prototype["$" + s] = function(t) {
83
+ return `${s}(${t})`;
84
+ };
85
+ for (const s of [
86
+ "Int8Array",
87
+ "Uint8Array",
88
+ "Uint8ClampedArray",
89
+ "Int16Array",
90
+ "Uint16Array",
91
+ "Int32Array",
92
+ "Uint32Array",
93
+ "Float32Array",
94
+ "Float64Array"
95
+ ]) o.prototype["$" + s] = function(t) {
96
+ return `${s}[${t.join(",")}]`;
97
+ };
98
+ for (const s of ["BigInt64Array", "BigUint64Array"]) o.prototype["$" + s] = function(t) {
99
+ return `${s}[${t.join("n,")}${t.length > 0 ? "n" : ""}]`;
100
+ };
101
+ return o;
102
+ }();
103
+ //#endregion
104
+ //#region ../../node_modules/.pnpm/ohash@2.0.11/node_modules/ohash/dist/crypto/js/index.mjs
105
+ const z = [
106
+ 1779033703,
107
+ -1150833019,
108
+ 1013904242,
109
+ -1521486534,
110
+ 1359893119,
111
+ -1694144372,
112
+ 528734635,
113
+ 1541459225
114
+ ], R = [
115
+ 1116352408,
116
+ 1899447441,
117
+ -1245643825,
118
+ -373957723,
119
+ 961987163,
120
+ 1508970993,
121
+ -1841331548,
122
+ -1424204075,
123
+ -670586216,
124
+ 310598401,
125
+ 607225278,
126
+ 1426881987,
127
+ 1925078388,
128
+ -2132889090,
129
+ -1680079193,
130
+ -1046744716,
131
+ -459576895,
132
+ -272742522,
133
+ 264347078,
134
+ 604807628,
135
+ 770255983,
136
+ 1249150122,
137
+ 1555081692,
138
+ 1996064986,
139
+ -1740746414,
140
+ -1473132947,
141
+ -1341970488,
142
+ -1084653625,
143
+ -958395405,
144
+ -710438585,
145
+ 113926993,
146
+ 338241895,
147
+ 666307205,
148
+ 773529912,
149
+ 1294757372,
150
+ 1396182291,
151
+ 1695183700,
152
+ 1986661051,
153
+ -2117940946,
154
+ -1838011259,
155
+ -1564481375,
156
+ -1474664885,
157
+ -1035236496,
158
+ -949202525,
159
+ -778901479,
160
+ -694614492,
161
+ -200395387,
162
+ 275423344,
163
+ 430227734,
164
+ 506948616,
165
+ 659060556,
166
+ 883997877,
167
+ 958139571,
168
+ 1322822218,
169
+ 1537002063,
170
+ 1747873779,
171
+ 1955562222,
172
+ 2024104815,
173
+ -2067236844,
174
+ -1933114872,
175
+ -1866530822,
176
+ -1538233109,
177
+ -1090935817,
178
+ -965641998
179
+ ], S = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", r = [];
180
+ var k = class {
181
+ _data = new l();
182
+ _hash = new l([...z]);
183
+ _nDataBytes = 0;
184
+ _minBufferSize = 0;
185
+ finalize(e) {
186
+ e && this._append(e);
187
+ const s = this._nDataBytes * 8, t = this._data.sigBytes * 8;
188
+ return this._data.words[t >>> 5] |= 128 << 24 - t % 32, this._data.words[(t + 64 >>> 9 << 4) + 14] = Math.floor(s / 4294967296), this._data.words[(t + 64 >>> 9 << 4) + 15] = s, this._data.sigBytes = this._data.words.length * 4, this._process(), this._hash;
189
+ }
190
+ _doProcessBlock(e, s) {
191
+ const t = this._hash.words;
192
+ let i = t[0], o = t[1], a = t[2], c = t[3], h = t[4], g = t[5], f = t[6], y = t[7];
193
+ for (let n = 0; n < 64; n++) {
194
+ if (n < 16) r[n] = e[s + n] | 0;
195
+ else {
196
+ const d = r[n - 15], j = (d << 25 | d >>> 7) ^ (d << 14 | d >>> 18) ^ d >>> 3, B = r[n - 2], x = (B << 15 | B >>> 17) ^ (B << 13 | B >>> 19) ^ B >>> 10;
197
+ r[n] = j + r[n - 7] + x + r[n - 16];
198
+ }
199
+ const m = h & g ^ ~h & f, p = i & o ^ i & a ^ o & a, u = (i << 30 | i >>> 2) ^ (i << 19 | i >>> 13) ^ (i << 10 | i >>> 22), b = (h << 26 | h >>> 6) ^ (h << 21 | h >>> 11) ^ (h << 7 | h >>> 25), w = y + b + m + R[n] + r[n], M = u + p;
200
+ y = f, f = g, g = h, h = c + w | 0, c = a, a = o, o = i, i = w + M | 0;
201
+ }
202
+ t[0] = t[0] + i | 0, t[1] = t[1] + o | 0, t[2] = t[2] + a | 0, t[3] = t[3] + c | 0, t[4] = t[4] + h | 0, t[5] = t[5] + g | 0, t[6] = t[6] + f | 0, t[7] = t[7] + y | 0;
203
+ }
204
+ _append(e) {
205
+ typeof e == "string" && (e = l.fromUtf8(e)), this._data.concat(e), this._nDataBytes += e.sigBytes;
206
+ }
207
+ _process(e) {
208
+ let s, t = this._data.sigBytes / 64;
209
+ e ? t = Math.ceil(t) : t = Math.max((t | 0) - this._minBufferSize, 0);
210
+ const i = t * 16, o = Math.min(i * 4, this._data.sigBytes);
211
+ if (i) {
212
+ for (let a = 0; a < i; a += 16) this._doProcessBlock(this._data.words, a);
213
+ s = this._data.words.splice(0, i), this._data.sigBytes -= o;
214
+ }
215
+ return new l(s, o);
216
+ }
217
+ };
218
+ var l = class l {
219
+ words;
220
+ sigBytes;
221
+ constructor(e, s) {
222
+ e = this.words = e || [], this.sigBytes = s === void 0 ? e.length * 4 : s;
223
+ }
224
+ static fromUtf8(e) {
225
+ const s = unescape(encodeURIComponent(e)), t = s.length, i = [];
226
+ for (let o = 0; o < t; o++) i[o >>> 2] |= (s.charCodeAt(o) & 255) << 24 - o % 4 * 8;
227
+ return new l(i, t);
228
+ }
229
+ toBase64() {
230
+ const e = [];
231
+ for (let s = 0; s < this.sigBytes; s += 3) {
232
+ const t = this.words[s >>> 2] >>> 24 - s % 4 * 8 & 255, i = this.words[s + 1 >>> 2] >>> 24 - (s + 1) % 4 * 8 & 255, o = this.words[s + 2 >>> 2] >>> 24 - (s + 2) % 4 * 8 & 255, a = t << 16 | i << 8 | o;
233
+ for (let c = 0; c < 4 && s * 8 + c * 6 < this.sigBytes * 8; c++) e.push(S.charAt(a >>> 6 * (3 - c) & 63));
234
+ }
235
+ return e.join("");
236
+ }
237
+ concat(e) {
238
+ if (this.words[this.sigBytes >>> 2] &= 4294967295 << 32 - this.sigBytes % 4 * 8, this.words.length = Math.ceil(this.sigBytes / 4), this.sigBytes % 4) for (let s = 0; s < e.sigBytes; s++) {
239
+ const t = e.words[s >>> 2] >>> 24 - s % 4 * 8 & 255;
240
+ this.words[this.sigBytes + s >>> 2] |= t << 24 - (this.sigBytes + s) % 4 * 8;
241
+ }
242
+ else for (let s = 0; s < e.sigBytes; s += 4) this.words[this.sigBytes + s >>> 2] = e.words[s >>> 2];
243
+ this.sigBytes += e.sigBytes;
244
+ }
245
+ };
246
+ function digest(_) {
247
+ return new k().finalize(_).toBase64();
248
+ }
249
+ //#endregion
250
+ //#region ../../node_modules/.pnpm/ohash@2.0.11/node_modules/ohash/dist/index.mjs
251
+ function hash$1(input) {
252
+ return digest(serialize(input));
253
+ }
254
+ //#endregion
255
+ //#region src/utils/hash.ts
256
+ /**
257
+ * Stable, deterministic hash of any structured-cloneable value.
258
+ */
259
+ function hash(value) {
260
+ return hash$1(value);
261
+ }
262
+ //#endregion
263
+ export { hash as t };
@@ -0,0 +1,65 @@
1
+ import { r as DevframeDefinition } from "../devframe-R5Ex5K5L.mjs";
2
+
3
+ //#region src/helpers/vite.d.ts
4
+ interface ViteDevBridgeOptions {
5
+ /**
6
+ * Mount base. Defaults to `def.basePath ?? '/__<id>/'` for this hosted
7
+ * adapter — the devframe shares the origin with the host Vite app.
8
+ *
9
+ * Relative spellings like `'./'` (common for base-agnostic Nuxt builds)
10
+ * are normalized to absolute paths so they compose with Vite's connect
11
+ * router.
12
+ */
13
+ base?: string;
14
+ /**
15
+ * Dev-time middleware mode. When set, the host app owns the SPA and
16
+ * devframe spins up a separate RPC + WS server on a resolved port,
17
+ * registering Vite middleware at `<base>__connection.json` so the
18
+ * host-served SPA can discover the WS endpoint.
19
+ *
20
+ * - `false` (default) — static-mount the SPA at `base` with SPA
21
+ * fallback. No RPC server is started.
22
+ * - `true` — bridge mode with all defaults (port from
23
+ * {@link resolveDevServerPort}, host from `def.cli?.host`).
24
+ * - object — bridge mode with explicit overrides.
25
+ */
26
+ devMiddleware?: boolean | {
27
+ /** Override the bridge port. Default: {@link resolveDevServerPort}. */port?: number; /** Override the bridge bind host. Default: `def.cli?.host ?? 'localhost'`. */
28
+ host?: string; /** Flag bag forwarded to `def.setup(ctx, { flags })`. */
29
+ flags?: Record<string, unknown>;
30
+ };
31
+ }
32
+ interface DevframeVitePlugin {
33
+ name: string;
34
+ apply: 'serve';
35
+ configureServer: (server: {
36
+ middlewares: {
37
+ use: (path: string, handler: any) => void;
38
+ };
39
+ httpServer?: {
40
+ once: (event: 'close', cb: () => void) => void;
41
+ } | null;
42
+ }) => void | Promise<void>;
43
+ closeBundle?: () => void | Promise<void>;
44
+ }
45
+ /**
46
+ * Bridge a devframe into an existing Vite dev server. Returns a Vite
47
+ * plugin with two modes, picked via `options.devMiddleware`:
48
+ *
49
+ * - **static-mount mode** (default) — mounts `def.cli.distDir` at
50
+ * `options.base` with SPA fallback enabled. No RPC server is started.
51
+ *
52
+ * - **bridge mode** (`devMiddleware: true | {…}`) — skips the static
53
+ * mount; the host app owns the SPA. Devframe starts a separate
54
+ * RPC + WS dev server (via {@link createDevServer} in bridge mode)
55
+ * and registers Vite middleware at `<base>__connection.json` so the
56
+ * host-served SPA can discover the WS endpoint via
57
+ * {@link connectDevframe}.
58
+ *
59
+ * Use bridge mode when integrating with frameworks that own the SPA
60
+ * (Nuxt, Astro, SolidStart, plain Vite apps). For the all-in-one
61
+ * `dev` / `build` / `mcp` shell, reach for {@link createCli} instead.
62
+ */
63
+ declare function viteDevBridge(d: DevframeDefinition, options?: ViteDevBridgeOptions): DevframeVitePlugin;
64
+ //#endregion
65
+ export { DevframeVitePlugin, ViteDevBridgeOptions, viteDevBridge };
@@ -0,0 +1,94 @@
1
+ import { n as logger } from "../diagnostics-Cg9ycFIM.mjs";
2
+ import { DEVTOOLS_CONNECTION_META_FILENAME } from "../constants.mjs";
3
+ import { n as resolveBasePath } from "../_shared-BrKv3CYt.mjs";
4
+ import { serveStaticNodeMiddleware } from "../utils/serve-static.mjs";
5
+ import { n as resolveDevServerPort, t as createDevServer } from "../dev-CewNNE2R.mjs";
6
+ import { resolve } from "pathe";
7
+ //#region src/helpers/vite.ts
8
+ /**
9
+ * Bridge a devframe into an existing Vite dev server. Returns a Vite
10
+ * plugin with two modes, picked via `options.devMiddleware`:
11
+ *
12
+ * - **static-mount mode** (default) — mounts `def.cli.distDir` at
13
+ * `options.base` with SPA fallback enabled. No RPC server is started.
14
+ *
15
+ * - **bridge mode** (`devMiddleware: true | {…}`) — skips the static
16
+ * mount; the host app owns the SPA. Devframe starts a separate
17
+ * RPC + WS dev server (via {@link createDevServer} in bridge mode)
18
+ * and registers Vite middleware at `<base>__connection.json` so the
19
+ * host-served SPA can discover the WS endpoint via
20
+ * {@link connectDevframe}.
21
+ *
22
+ * Use bridge mode when integrating with frameworks that own the SPA
23
+ * (Nuxt, Astro, SolidStart, plain Vite apps). For the all-in-one
24
+ * `dev` / `build` / `mcp` shell, reach for {@link createCli} instead.
25
+ */
26
+ function viteDevBridge(d, options = {}) {
27
+ const base = normalizeMountBase(options.base ?? resolveBasePath(d, "hosted"));
28
+ if (!options.devMiddleware) {
29
+ const distDir = d.cli?.distDir;
30
+ return {
31
+ name: `devframe:${d.id}`,
32
+ apply: "serve",
33
+ configureServer(server) {
34
+ if (!distDir) return;
35
+ server.middlewares.use(base, serveStaticNodeMiddleware(resolve(distDir)));
36
+ }
37
+ };
38
+ }
39
+ const mw = options.devMiddleware === true ? {} : options.devMiddleware;
40
+ let started;
41
+ return {
42
+ name: `devframe:${d.id}`,
43
+ apply: "serve",
44
+ async configureServer(server) {
45
+ await started?.close().catch(() => {});
46
+ started = void 0;
47
+ let port;
48
+ try {
49
+ port = mw.port ?? await resolveDevServerPort(d, { host: mw.host });
50
+ started = await createDevServer(d, {
51
+ host: mw.host,
52
+ port,
53
+ flags: mw.flags,
54
+ openBrowser: false
55
+ });
56
+ } catch (e) {
57
+ logger.DF0033({
58
+ id: d.id,
59
+ reason: String(e)
60
+ }, { cause: e }).log();
61
+ return;
62
+ }
63
+ const metaPath = `${base}${DEVTOOLS_CONNECTION_META_FILENAME}`;
64
+ server.middlewares.use(metaPath, (_req, res) => {
65
+ res.setHeader("Content-Type", "application/json");
66
+ res.end(JSON.stringify({
67
+ backend: "websocket",
68
+ websocket: port
69
+ }));
70
+ });
71
+ server.httpServer?.once("close", () => {
72
+ started?.close().catch(() => {});
73
+ });
74
+ },
75
+ async closeBundle() {
76
+ await started?.close().catch(() => {});
77
+ started = void 0;
78
+ }
79
+ };
80
+ }
81
+ /**
82
+ * Make `base` safe for `server.middlewares.use(path, …)`. Vite's connect
83
+ * router matches by absolute URL prefix, so relative spellings like
84
+ * `'./'` (commonly used for base-agnostic Nuxt builds) need to be
85
+ * converted to `/` first.
86
+ */
87
+ function normalizeMountBase(base) {
88
+ let out = base.replace(/^\.\/?/, "/");
89
+ if (!out.startsWith("/")) out = `/${out}`;
90
+ if (!out.endsWith("/")) out = `${out}/`;
91
+ return out.replace(/\/+/g, "/");
92
+ }
93
+ //#endregion
94
+ export { viteDevBridge };
@@ -1,5 +1,4 @@
1
- //#region \0rolldown/runtime.js
2
- var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
1
+ import { t as __commonJSMin } from "./chunk-e9Ob2GDo.mjs";
3
2
  //#endregion
4
3
  //#region src/utils/human-id.ts
5
4
  var import_dist = (/* @__PURE__ */ __commonJSMin(((exports) => {
@@ -839,5 +838,15 @@ var import_dist = (/* @__PURE__ */ __commonJSMin(((exports) => {
839
838
  exports.minLength = minLength;
840
839
  exports.default = humanId;
841
840
  })))();
841
+ /**
842
+ * Generate a human-readable, lowercase, dash-separated random ID
843
+ * (e.g. `bright-orange-tiger`).
844
+ */
845
+ function humanId() {
846
+ return (0, import_dist.humanId)({
847
+ separator: "-",
848
+ capitalize: false
849
+ });
850
+ }
842
851
  //#endregion
843
- export { import_dist as t };
852
+ export { humanId as t };
@@ -1,5 +1,4 @@
1
- import { C as RpcReturnSchema, S as RpcFunctionsCollector, b as RpcFunctionSetupResult, c as RpcDumpClientOptions, g as RpcFunctionDefinitionAny, h as RpcFunctionDefinition, i as RpcArgsSchema, l as RpcDumpCollectionOptions, n as BirpcReturn, o as RpcDefinitionsToFunctions, p as RpcDumpStore, x as RpcFunctionType } from "./types-C5OVe4AC.mjs";
2
- import { deserialize as structuredCloneDeserialize, parse as structuredCloneParse, serialize as structuredCloneSerialize, stringify as structuredCloneStringify } from "structured-clone-es";
1
+ import { C as RpcReturnSchema, S as RpcFunctionsCollector, b as RpcFunctionSetupResult, c as RpcDumpClientOptions, g as RpcFunctionDefinitionAny, h as RpcFunctionDefinition, i as RpcArgsSchema, l as RpcDumpCollectionOptions, n as BirpcReturn, o as RpcDefinitionsToFunctions, p as RpcDumpStore, x as RpcFunctionType } from "./types-4rdUEi2R.mjs";
3
2
 
4
3
  //#region src/rpc/cache.d.ts
5
4
  interface RpcCacheOptions {
@@ -137,4 +136,4 @@ declare function validateDefinitions(definitions: readonly RpcFunctionDefinition
137
136
  */
138
137
  declare function validateDefinition(definition: RpcFunctionDefinitionAny): void;
139
138
  //#endregion
140
- export { RpcCacheManager as _, structuredCloneDeserialize as a, structuredCloneStringify as c, createClientFromDump as d, dumpFunctions as f, RpcFunctionsCollectorBase as g, defineRpcFunction as h, strictJsonStringify as i, getRpcHandler as l, createDefineWrapperWithContext as m, validateDefinitions as n, structuredCloneParse as o, getDefinitionsWithDumps as p, STRUCTURED_CLONE_PREFIX as r, structuredCloneSerialize as s, validateDefinition as t, getRpcResolvedSetupResult as u, RpcCacheOptions as v };
139
+ export { getRpcHandler as a, dumpFunctions as c, defineRpcFunction as d, RpcFunctionsCollectorBase as f, strictJsonStringify as i, getDefinitionsWithDumps as l, RpcCacheOptions as m, validateDefinitions as n, getRpcResolvedSetupResult as o, RpcCacheManager as p, STRUCTURED_CLONE_PREFIX as r, createClientFromDump as s, validateDefinition as t, createDefineWrapperWithContext as u };
package/dist/index.d.mts CHANGED
@@ -1,9 +1,8 @@
1
- import { $ as AgentHandle, B as EntriesToObject, G as DevToolsRpcSharedStates, H as Thenable, J as JsonRenderer, K as JsonRenderElement, Q as DevToolsDiagnosticsLogger, U as DevToolsRpcClientFunctions, V as PartialWithoutId, W as DevToolsRpcServerFunctions, X as DevToolsDiagnosticsDefinition, Y as DevToolsHost, Z as DevToolsDiagnosticsHost, _ as RpcStreamingChannel, a as DevtoolRuntime, at as AgentToolInput, c as defineDevtool, ct as EventEmitter, d as DevToolsNodeContext, et as AgentManifest, f as DevToolsNodeRpcSession, g as RpcSharedStateHost, h as RpcSharedStateGetOptions, i as DevtoolDeploymentKind, it as AgentTool, l as ConnectionMeta, lt as EventUnsubscribe, m as RpcFunctionsHost, n as DevtoolCliOptions, nt as AgentResourceContent, o as DevtoolSetupInfo, ot as DevToolsAgentHost, p as RpcBroadcastOptions, q as JsonRenderSpec, r as DevtoolDefinition, rt as AgentResourceInput, s as DevtoolSpaOptions, st as DevToolsAgentHostEvents, t as DevtoolBrowserContext, tt as AgentResource, u as DevToolsCapabilities, ut as EventsMap, v as RpcStreamingChannelOptions, y as RpcStreamingHost, z as DevToolsViewHost } from "./devtool-CNvLs2_Y.mjs";
2
- import { C as RpcReturnSchema, h as RpcFunctionDefinition, i as RpcArgsSchema, m as RpcFunctionAgentOptions, x as RpcFunctionType } from "./types-C5OVe4AC.mjs";
3
- import { t as DevToolsNodeRpcSessionMeta } from "./ws-server-C7LnhOHi.mjs";
1
+ import { $ as AgentResourceContent, B as EntriesToObject, G as DevToolsRpcSharedStates, H as Thenable, J as DevToolsDiagnosticsHost, K as DevToolsHost, Q as AgentResource, U as DevToolsRpcClientFunctions, V as PartialWithoutId, W as DevToolsRpcServerFunctions, X as AgentHandle, Y as DevToolsDiagnosticsLogger, Z as AgentManifest, _ as RpcStreamingChannel, a as DevframeRuntime, at as EventEmitter, c as defineDevframe, d as DevToolsNodeContext, et as AgentResourceInput, f as DevToolsNodeRpcSession, g as RpcSharedStateHost, h as RpcSharedStateGetOptions, i as DevframeDeploymentKind, it as DevToolsAgentHostEvents, l as ConnectionMeta, m as RpcFunctionsHost, n as DevframeCliOptions, nt as AgentToolInput, o as DevframeSetupInfo, ot as EventUnsubscribe, p as RpcBroadcastOptions, q as DevToolsDiagnosticsDefinition, r as DevframeDefinition, rt as DevToolsAgentHost, s as DevframeSpaOptions, st as EventsMap, t as DevframeBrowserContext, tt as AgentTool, u as DevToolsCapabilities, v as RpcStreamingChannelOptions, y as RpcStreamingHost, z as DevToolsViewHost } from "./devframe-R5Ex5K5L.mjs";
2
+ import { C as RpcReturnSchema, h as RpcFunctionDefinition, i as RpcArgsSchema, m as RpcFunctionAgentOptions, x as RpcFunctionType } from "./types-4rdUEi2R.mjs";
3
+ import { t as DevToolsNodeRpcSessionMeta } from "./ws-server-DjvlwLuM.mjs";
4
4
 
5
5
  //#region src/define.d.ts
6
6
  declare const defineRpcFunction: <NAME extends string, TYPE extends RpcFunctionType, ARGS extends any[], RETURN = void, const AS extends RpcArgsSchema | undefined = undefined, const RS extends RpcReturnSchema | undefined = undefined>(definition: RpcFunctionDefinition<NAME, TYPE, ARGS, RETURN, AS, RS, DevToolsNodeContext>) => RpcFunctionDefinition<NAME, TYPE, ARGS, RETURN, AS, RS, DevToolsNodeContext>;
7
- declare function defineJsonRenderSpec(spec: JsonRenderSpec): JsonRenderSpec;
8
7
  //#endregion
9
- export { AgentHandle, AgentManifest, AgentResource, AgentResourceContent, AgentResourceInput, AgentTool, AgentToolInput, ConnectionMeta, DevToolsAgentHost, DevToolsAgentHostEvents, DevToolsCapabilities, DevToolsDiagnosticsDefinition, DevToolsDiagnosticsHost, DevToolsDiagnosticsLogger, DevToolsHost, DevToolsNodeContext, DevToolsNodeRpcSession, DevToolsNodeRpcSessionMeta, DevToolsRpcClientFunctions, DevToolsRpcServerFunctions, DevToolsRpcSharedStates, DevToolsViewHost, DevtoolBrowserContext, DevtoolCliOptions, DevtoolDefinition, DevtoolDeploymentKind, DevtoolRuntime, DevtoolSetupInfo, DevtoolSpaOptions, EntriesToObject, EventEmitter, EventUnsubscribe, EventsMap, JsonRenderElement, JsonRenderSpec, JsonRenderer, PartialWithoutId, RpcBroadcastOptions, RpcFunctionAgentOptions, RpcFunctionsHost, RpcSharedStateGetOptions, RpcSharedStateHost, RpcStreamingChannel, RpcStreamingChannelOptions, RpcStreamingHost, Thenable, defineDevtool, defineJsonRenderSpec, defineRpcFunction };
8
+ export { AgentHandle, AgentManifest, AgentResource, AgentResourceContent, AgentResourceInput, AgentTool, AgentToolInput, ConnectionMeta, DevToolsAgentHost, DevToolsAgentHostEvents, DevToolsCapabilities, DevToolsDiagnosticsDefinition, DevToolsDiagnosticsHost, DevToolsDiagnosticsLogger, DevToolsHost, DevToolsNodeContext, DevToolsNodeRpcSession, DevToolsNodeRpcSessionMeta, DevToolsRpcClientFunctions, DevToolsRpcServerFunctions, DevToolsRpcSharedStates, DevToolsViewHost, DevframeBrowserContext, DevframeCliOptions, DevframeDefinition, DevframeDeploymentKind, DevframeRuntime, DevframeSetupInfo, DevframeSpaOptions, EntriesToObject, EventEmitter, EventUnsubscribe, EventsMap, PartialWithoutId, RpcBroadcastOptions, RpcFunctionAgentOptions, RpcFunctionsHost, RpcSharedStateGetOptions, RpcSharedStateHost, RpcStreamingChannel, RpcStreamingChannelOptions, RpcStreamingHost, Thenable, defineDevframe, defineRpcFunction };
package/dist/index.mjs CHANGED
@@ -1,8 +1,5 @@
1
- import { t as createDefineWrapperWithContext } from "./define-Bb4zh-Dc.mjs";
1
+ import { t as createDefineWrapperWithContext } from "./define-CW9gLnyG.mjs";
2
2
  //#region src/define.ts
3
3
  const defineRpcFunction = createDefineWrapperWithContext();
4
- function defineJsonRenderSpec(spec) {
5
- return spec;
6
- }
7
4
  //#endregion
8
- export { defineJsonRenderSpec, defineRpcFunction };
5
+ export { defineRpcFunction };