devframe 0.9.0-beta.9 → 0.9.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.
@@ -0,0 +1,68 @@
1
+ import "./constants.mjs";
2
+ import { n as getPort } from "./dist-eNI9qM_I.mjs";
3
+ import { cleanDoubleSlashes, withLeadingSlash, withTrailingSlash, withoutLeadingSlash } from "ufo";
4
+ //#region src/adapters/_shared.ts
5
+ const DEFAULT_PORT = 9999;
6
+ /**
7
+ * Resolve the mount base path for a devframe's SPA. Hosted adapters
8
+ * (`vite`, `embedded`) default to `/__<id>/` so they don't collide
9
+ * with the host app; standalone adapters (`cli`, `build`)
10
+ * default to `/` because they own the origin.
11
+ *
12
+ * The devframe author can override with `basePath` on the definition.
13
+ */
14
+ function resolveBasePath(def, kind) {
15
+ if (def.basePath) return normalizeBasePath(def.basePath);
16
+ return kind === "standalone" ? "/" : `/__${def.id}/`;
17
+ }
18
+ function normalizeBasePath(base) {
19
+ return cleanDoubleSlashes(withTrailingSlash(withLeadingSlash(base)));
20
+ }
21
+ /**
22
+ * Resolve the listening port for `createDevServer` (and `createHandler`'s
23
+ * side-car tiers), honoring the definition's `cli.port` / `cli.portRange` /
24
+ * `cli.random` settings. Exposed separately so authors who run their own
25
+ * argv parsing can resolve a port up-front (to print it, log it, etc.)
26
+ * before starting the server.
27
+ */
28
+ async function resolveDevServerPort(def, options = {}) {
29
+ const host = options.host ?? def.cli?.host ?? "localhost";
30
+ const portOptions = {
31
+ port: options.defaultPort ?? def.cli?.port ?? DEFAULT_PORT,
32
+ host
33
+ };
34
+ if (def.cli?.portRange) portOptions.portRange = def.cli.portRange;
35
+ if (def.cli?.random) portOptions.random = def.cli.random;
36
+ return getPort(portOptions);
37
+ }
38
+ /**
39
+ * Normalize the `cli.mcp` / `mcp` option (`boolean | McpRouteOptions`) into
40
+ * concrete options, or `undefined` when the MCP route is disabled.
41
+ */
42
+ function resolveMcpConfig(mcp) {
43
+ if (!mcp) return void 0;
44
+ return mcp === true ? {} : mcp;
45
+ }
46
+ /**
47
+ * Resolve the `mcp` entry a `__connection.json` should advertise for a dev
48
+ * server started with the given `mcp` option (falling back to `def.cli?.mcp`,
49
+ * exactly like `createDevServer`), or `undefined` when the route is
50
+ * disabled.
51
+ *
52
+ * Hosted bridges that hand-roll their connection meta pass the side-car
53
+ * `port`: the advertised path becomes absolute (the side-car mounts at `/`)
54
+ * and the client dials `<page-host>:<port><path>`. Without `port` the path
55
+ * stays relative, resolved against `__connection.json`'s own location (the
56
+ * same-server default).
57
+ */
58
+ function resolveMcpConnectionMeta(def, mcp, port) {
59
+ const config = resolveMcpConfig(mcp ?? def.cli?.mcp);
60
+ if (!config) return void 0;
61
+ const route = withoutLeadingSlash(config.path ?? "__mcp");
62
+ return port != null ? {
63
+ path: withLeadingSlash(route),
64
+ port
65
+ } : { path: route };
66
+ }
67
+ //#endregion
68
+ export { resolveMcpConnectionMeta as i, resolveBasePath as n, resolveDevServerPort as r, normalizeBasePath as t };
@@ -1,7 +1,7 @@
1
1
  import { s as colors } from "../nostics-CzECRXpE.mjs";
2
- import { r as resolveDevServerPort } from "../_shared-CKZPvSrN.mjs";
2
+ import { r as resolveDevServerPort } from "../_shared-CbZ_yhbz.mjs";
3
3
  import { createBuild } from "./build.mjs";
4
- import { t as createDevServer } from "../dev-Chvlqs7I.mjs";
4
+ import { t as createDevServer } from "../dev--rAPzbvO.mjs";
5
5
  import process from "node:process";
6
6
  import cac$1 from "cac";
7
7
  //#region src/adapters/flags.ts
@@ -1,3 +1,3 @@
1
- import { i as resolveMcpConnectionMeta, r as resolveDevServerPort } from "../_shared-CKZPvSrN.mjs";
2
- import { t as createDevServer } from "../dev-Chvlqs7I.mjs";
1
+ import { i as resolveMcpConnectionMeta, r as resolveDevServerPort } from "../_shared-CbZ_yhbz.mjs";
2
+ import { t as createDevServer } from "../dev--rAPzbvO.mjs";
3
3
  export { createDevServer, resolveDevServerPort, resolveMcpConnectionMeta };
@@ -1,2 +1,2 @@
1
- import { n as getInstanceInternals, r as initDevframe } from "../dev-Chvlqs7I.mjs";
1
+ import { n as getInstanceInternals, r as initDevframe } from "../dev--rAPzbvO.mjs";
2
2
  export { getInstanceInternals, initDevframe };
@@ -1,2 +1,2 @@
1
- import { i as createMcpServer, n as mountMcpHttp, r as createMcpFetchHandler } from "../http-8Kpkap4_.mjs";
1
+ import { i as createMcpServer, n as mountMcpHttp, r as createMcpFetchHandler } from "../http-DYpK0cUi.mjs";
2
2
  export { createMcpFetchHandler, createMcpServer, mountMcpHttp };
@@ -722,7 +722,6 @@ const EMPTY_WIRE_DEFS = /* @__PURE__ */ new Map();
722
722
  * don't collide across connections.
723
723
  *
724
724
  * @internal
725
- * implementations; not part of the stable public API.
726
725
  */
727
726
  function createRpcWireCodec(definitions = EMPTY_WIRE_DEFS) {
728
727
  const pendingRequestMethods = /* @__PURE__ */ new Map();
@@ -2,9 +2,9 @@ import { DEVFRAME_CONNECTION_META_FILENAME } from "./constants.mjs";
2
2
  import { t as diagnostics } from "./diagnostics-DOQPnQmX.mjs";
3
3
  import { t as createHostContext } from "./context-CEe4PBz1.mjs";
4
4
  import { t as resolveStaticAssetsSource } from "./remote-assets-nTTxY2MU.mjs";
5
- import { i as resolveMcpConnectionMeta, n as resolveBasePath, r as resolveDevServerPort, t as normalizeBasePath } from "./_shared-CKZPvSrN.mjs";
5
+ import { i as resolveMcpConnectionMeta, n as resolveBasePath, r as resolveDevServerPort, t as normalizeBasePath } from "./_shared-CbZ_yhbz.mjs";
6
6
  import { t as createH3DevframeHost } from "./host-h3-Crkzm42q.mjs";
7
- import { i as normalizeHttpServerUrl, n as resolveInstanceRegister, t as createInstanceShell } from "./instance-shell-XvN5USg4.mjs";
7
+ import { i as normalizeHttpServerUrl, n as resolveInstanceRegister, t as createInstanceShell } from "./instance-shell-CMFyszWJ.mjs";
8
8
  import { open } from "./utils/open.mjs";
9
9
  import { mountStaticHandler } from "./utils/serve-static.mjs";
10
10
  import { createServer } from "node:http";
@@ -87,7 +87,7 @@ function initDevframe(def, options) {
87
87
  const mcpPath = joinURL(base, mcpMeta.path);
88
88
  let mountMcpHttp;
89
89
  try {
90
- ({mountMcpHttp} = await import("./http-8Kpkap4_.mjs").then((n) => n.t));
90
+ ({mountMcpHttp} = await import("./http-DYpK0cUi.mjs").then((n) => n.t));
91
91
  } catch (error) {
92
92
  const reason = error instanceof Error ? error.message : String(error);
93
93
  throw diagnostics.DF0017({
@@ -1,9 +1,7 @@
1
1
  import { n as __exportAll } from "./rolldown-runtime-JspESFgx.mjs";
2
- import "./constants.mjs";
3
2
  import "node:fs/promises";
4
3
  import { createServer } from "node:net";
5
4
  import { networkInterfaces } from "node:os";
6
- import { cleanDoubleSlashes, withLeadingSlash, withTrailingSlash, withoutLeadingSlash } from "ufo";
7
5
  //#region ../../node_modules/.pnpm/get-port-please@3.2.0/node_modules/get-port-please/dist/index.mjs
8
6
  var dist_exports = /* @__PURE__ */ __exportAll({
9
7
  checkPort: () => checkPort,
@@ -227,68 +225,4 @@ async function checkPort(port, host = process.env.HOST, verbose) {
227
225
  return port;
228
226
  }
229
227
  //#endregion
230
- //#region src/adapters/_shared.ts
231
- const DEFAULT_PORT = 9999;
232
- /**
233
- * Resolve the mount base path for a devframe's SPA. Hosted adapters
234
- * (`vite`, `embedded`) default to `/__<id>/` so they don't collide
235
- * with the host app; standalone adapters (`cli`, `build`)
236
- * default to `/` because they own the origin.
237
- *
238
- * The devframe author can override with `basePath` on the definition.
239
- */
240
- function resolveBasePath(def, kind) {
241
- if (def.basePath) return normalizeBasePath(def.basePath);
242
- return kind === "standalone" ? "/" : `/__${def.id}/`;
243
- }
244
- function normalizeBasePath(base) {
245
- return cleanDoubleSlashes(withTrailingSlash(withLeadingSlash(base)));
246
- }
247
- /**
248
- * Resolve the listening port for `createDevServer` (and `createHandler`'s
249
- * side-car tiers), honoring the definition's `cli.port` / `cli.portRange` /
250
- * `cli.random` settings. Exposed separately so authors who run their own
251
- * argv parsing can resolve a port up-front (to print it, log it, etc.)
252
- * before starting the server.
253
- */
254
- async function resolveDevServerPort(def, options = {}) {
255
- const host = options.host ?? def.cli?.host ?? "localhost";
256
- const portOptions = {
257
- port: options.defaultPort ?? def.cli?.port ?? DEFAULT_PORT,
258
- host
259
- };
260
- if (def.cli?.portRange) portOptions.portRange = def.cli.portRange;
261
- if (def.cli?.random) portOptions.random = def.cli.random;
262
- return getPort(portOptions);
263
- }
264
- /**
265
- * Normalize the `cli.mcp` / `mcp` option (`boolean | McpRouteOptions`) into
266
- * concrete options, or `undefined` when the MCP route is disabled.
267
- */
268
- function resolveMcpConfig(mcp) {
269
- if (!mcp) return void 0;
270
- return mcp === true ? {} : mcp;
271
- }
272
- /**
273
- * Resolve the `mcp` entry a `__connection.json` should advertise for a dev
274
- * server started with the given `mcp` option (falling back to `def.cli?.mcp`,
275
- * exactly like `createDevServer`), or `undefined` when the route is
276
- * disabled.
277
- *
278
- * Hosted bridges that hand-roll their connection meta pass the side-car
279
- * `port`: the advertised path becomes absolute (the side-car mounts at `/`)
280
- * and the client dials `<page-host>:<port><path>`. Without `port` the path
281
- * stays relative, resolved against `__connection.json`'s own location (the
282
- * same-server default).
283
- */
284
- function resolveMcpConnectionMeta(def, mcp, port) {
285
- const config = resolveMcpConfig(mcp ?? def.cli?.mcp);
286
- if (!config) return void 0;
287
- const route = withoutLeadingSlash(config.path ?? "__mcp");
288
- return port != null ? {
289
- path: withLeadingSlash(route),
290
- port
291
- } : { path: route };
292
- }
293
- //#endregion
294
- export { dist_exports as a, resolveMcpConnectionMeta as i, resolveBasePath as n, resolveDevServerPort as r, normalizeBasePath as t };
228
+ export { getPort as n, dist_exports as t };
@@ -1,6 +1,6 @@
1
1
  import { n as __exportAll } from "./rolldown-runtime-JspESFgx.mjs";
2
2
  import { t as Diagnostic } from "./nostics-CzECRXpE.mjs";
3
- import { i as isAllowedOrigin } from "./ws-server-BiUne4K7.mjs";
3
+ import { i as isAllowedOrigin } from "./ws-server-BdSLrhxE.mjs";
4
4
  import { t as diagnostics } from "./diagnostics-DOQPnQmX.mjs";
5
5
  import { t as createHostContext } from "./context-CEe4PBz1.mjs";
6
6
  import { t as toAgentToolName } from "./agent-tool-name-EgfoFO8C.mjs";
@@ -298,7 +298,7 @@ function createInstanceShell(options) {
298
298
  allowedOrigins: options.allowedOrigins
299
299
  });
300
300
  if (ws.port != null) return await start(ws.port);
301
- const { getPort } = await import("./_shared-CKZPvSrN.mjs").then((n) => n.a);
301
+ const { getPort } = await import("./dist-eNI9qM_I.mjs").then((n) => n.t);
302
302
  let lastError;
303
303
  for (let attempt = 0; attempt < 3; attempt++) {
304
304
  const port = attempt === 0 && options.resolveSidecarPort ? await options.resolveSidecarPort(sidecarHost) : await getPort({
@@ -364,7 +364,6 @@ declare function normalizeHttpServerUrl(host: string, port: number | string): st
364
364
  * The per-connection `serialize`/`deserialize` pair for a live RPC wire.
365
365
  *
366
366
  * @internal
367
- * implementations; not part of the stable public API.
368
367
  */
369
368
  interface RpcWireCodec {
370
369
  serialize: (msg: any) => string;
@@ -380,7 +379,6 @@ interface RpcWireCodec {
380
379
  * don't collide across connections.
381
380
  *
382
381
  * @internal
383
- * implementations; not part of the stable public API.
384
382
  */
385
383
  declare function createRpcWireCodec(definitions?: ReadonlyMap<string, Pick<RpcFunctionDefinitionAny, 'jsonSerializable'>>): RpcWireCodec;
386
384
  /**
@@ -390,7 +388,6 @@ declare function createRpcWireCodec(definitions?: ReadonlyMap<string, Pick<RpcFu
390
388
  * handed to birpc proper.
391
389
  *
392
390
  * @internal
393
- * implementations; not part of the stable public API.
394
391
  */
395
392
  declare function peekRpcWireFrame(raw: string): {
396
393
  t?: string;
@@ -1,9 +1,9 @@
1
- import { n as peekRpcWireFrame, t as createRpcWireCodec } from "../wire-codec-GsoRxIsD.mjs";
1
+ import { n as peekRpcWireFrame, t as createRpcWireCodec } from "../wire-codec-0K-o5MYW.mjs";
2
2
  import { t as diagnostics } from "../diagnostics-DOQPnQmX.mjs";
3
3
  import { n as coerceAgentPositionalArgs, t as DevframeAgentHost } from "../host-agent-xLCSe65D.mjs";
4
- import { n as resolveBasePath, t as normalizeBasePath } from "../_shared-CKZPvSrN.mjs";
4
+ import { n as resolveBasePath, t as normalizeBasePath } from "../_shared-CbZ_yhbz.mjs";
5
5
  import { t as createH3DevframeHost } from "../host-h3-Crkzm42q.mjs";
6
6
  import { i as registerDevframeInstance, n as listLiveDevframeInstances } from "../instance-registry-WvQkt42E.mjs";
7
- import { i as normalizeHttpServerUrl, n as resolveInstanceRegister, r as samePath, t as createInstanceShell } from "../instance-shell-XvN5USg4.mjs";
7
+ import { i as normalizeHttpServerUrl, n as resolveInstanceRegister, r as samePath, t as createInstanceShell } from "../instance-shell-CMFyszWJ.mjs";
8
8
  import { t as createContextRpcServer } from "../rpc-core-DMTe-hLo.mjs";
9
9
  export { DevframeAgentHost, coerceAgentPositionalArgs, createContextRpcServer, createH3DevframeHost, createInstanceShell, createRpcWireCodec, diagnostics, listLiveDevframeInstances, normalizeBasePath, normalizeHttpServerUrl, peekRpcWireFrame, registerDevframeInstance, resolveBasePath, resolveInstanceRegister, samePath };
@@ -1,3 +1,3 @@
1
- import { n as resolveBasePath, t as normalizeBasePath } from "../_shared-CKZPvSrN.mjs";
1
+ import { n as resolveBasePath, t as normalizeBasePath } from "../_shared-CbZ_yhbz.mjs";
2
2
  import { n as internalContextMap, t as getInternalContext } from "../context-xdynGSLP.mjs";
3
3
  export { getInternalContext, internalContextMap, normalizeBasePath, resolveBasePath };
@@ -1,5 +1,5 @@
1
1
  import { DEVFRAME_AUTH_TOKEN_QUERY_PARAM, DEVFRAME_SSE_SESSION_HEADER } from "../../constants.mjs";
2
- import { t as createRpcWireCodec } from "../../wire-codec-GsoRxIsD.mjs";
2
+ import { t as createRpcWireCodec } from "../../wire-codec-0K-o5MYW.mjs";
3
3
  //#region src/rpc/transports/sse-client.ts
4
4
  function NOOP() {}
5
5
  /**
@@ -1,6 +1,6 @@
1
1
  import { DEVFRAME_SSE_SESSION_HEADER } from "../../constants.mjs";
2
- import { n as peekRpcWireFrame, t as createRpcWireCodec } from "../../wire-codec-GsoRxIsD.mjs";
3
- import { i as isAllowedOrigin, o as createRpcSessionMeta } from "../../ws-server-BiUne4K7.mjs";
2
+ import { n as peekRpcWireFrame, t as createRpcWireCodec } from "../../wire-codec-0K-o5MYW.mjs";
3
+ import { i as isAllowedOrigin, o as createRpcSessionMeta } from "../../ws-server-BdSLrhxE.mjs";
4
4
  //#region src/rpc/transports/sse-server.ts
5
5
  const SSE_STREAM_HEADERS = {
6
6
  "content-type": "text/event-stream",
@@ -1,4 +1,4 @@
1
- import { i as isAllowedOrigin, r as createWsRpcPeerHooks } from "../../ws-server-BiUne4K7.mjs";
1
+ import { i as isAllowedOrigin, r as createWsRpcPeerHooks } from "../../ws-server-BdSLrhxE.mjs";
2
2
  //#region src/rpc/transports/ws-bun.ts
3
3
  /**
4
4
  * The Bun fetch-upgrade WebSocket tier for `initDevframe` / `initHub` — the
@@ -1,5 +1,5 @@
1
1
  import { DEVFRAME_AUTH_TOKEN_QUERY_PARAM } from "../../constants.mjs";
2
- import { t as createRpcWireCodec } from "../../wire-codec-GsoRxIsD.mjs";
2
+ import { t as createRpcWireCodec } from "../../wire-codec-0K-o5MYW.mjs";
3
3
  //#region src/rpc/transports/ws-client.ts
4
4
  function NOOP() {}
5
5
  const EMPTY_DEFS = /* @__PURE__ */ new Map();
@@ -1,2 +1,2 @@
1
- import { a as isLoopbackHostname, i as isAllowedOrigin, n as createWsOriginRegistry, r as createWsRpcPeerHooks, t as attachWsRpcTransport } from "../../ws-server-BiUne4K7.mjs";
1
+ import { a as isLoopbackHostname, i as isAllowedOrigin, n as createWsOriginRegistry, r as createWsRpcPeerHooks, t as attachWsRpcTransport } from "../../ws-server-BdSLrhxE.mjs";
2
2
  export { attachWsRpcTransport, createWsOriginRegistry, createWsRpcPeerHooks, isAllowedOrigin, isLoopbackHostname };
@@ -0,0 +1,17 @@
1
+ //#region ../../node_modules/.pnpm/get-port-please@3.2.0/node_modules/get-port-please/dist/index.d.mts
2
+ interface GetPortOptions {
3
+ name: string;
4
+ random: boolean;
5
+ port: number;
6
+ ports: number[];
7
+ portRange: [fromInclusive: number, toInclusive: number];
8
+ alternativePortRange: [fromInclusive: number, toInclusive: number];
9
+ host: string;
10
+ verbose?: boolean;
11
+ public?: boolean;
12
+ }
13
+ type GetPortInput = Partial<GetPortOptions> | number | string;
14
+ type PortNumber = number;
15
+ declare function getPort(_userOptions?: GetPortInput): Promise<PortNumber>;
16
+ //#endregion
17
+ export { type GetPortInput, type GetPortOptions, getPort };
@@ -0,0 +1,2 @@
1
+ import { n as getPort } from "../dist-eNI9qM_I.mjs";
2
+ export { getPort };
@@ -12,7 +12,6 @@ const EMPTY_WIRE_DEFS = /* @__PURE__ */ new Map();
12
12
  * don't collide across connections.
13
13
  *
14
14
  * @internal
15
- * implementations; not part of the stable public API.
16
15
  */
17
16
  function createRpcWireCodec(definitions = EMPTY_WIRE_DEFS) {
18
17
  const pendingRequestMethods = /* @__PURE__ */ new Map();
@@ -41,7 +40,6 @@ function createRpcWireCodec(definitions = EMPTY_WIRE_DEFS) {
41
40
  * handed to birpc proper.
42
41
  *
43
42
  * @internal
44
- * implementations; not part of the stable public API.
45
43
  */
46
44
  function peekRpcWireFrame(raw) {
47
45
  try {
@@ -1,5 +1,5 @@
1
1
  import "./constants.mjs";
2
- import { t as createRpcWireCodec } from "./wire-codec-GsoRxIsD.mjs";
2
+ import { t as createRpcWireCodec } from "./wire-codec-0K-o5MYW.mjs";
3
3
  import { n as randomToken, r as timingSafeEqual } from "./crypto-token-XCqTSMg9.mjs";
4
4
  import { createServer } from "node:http";
5
5
  import { createServer as createServer$1 } from "node:https";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "devframe",
3
3
  "type": "module",
4
- "version": "0.9.0-beta.9",
4
+ "version": "0.9.0",
5
5
  "description": "Framework for building one portable devtool integration that runs in any viewer.",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -48,6 +48,7 @@
48
48
  "./utils/colors": "./dist/utils/colors.mjs",
49
49
  "./utils/crypto-token": "./dist/utils/crypto-token.mjs",
50
50
  "./utils/events": "./dist/utils/events.mjs",
51
+ "./utils/get-port": "./dist/utils/get-port.mjs",
51
52
  "./utils/hash": "./dist/utils/hash.mjs",
52
53
  "./utils/launch-editor": "./dist/utils/launch-editor.mjs",
53
54
  "./utils/nanoid": "./dist/utils/nanoid.mjs",