devframe 0.9.0-beta.8 → 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.
Files changed (77) hide show
  1. package/dist/{_shared-QkI6ljJS.d.mts → _shared-BPmX9fqK.d.mts} +1 -1
  2. package/dist/_shared-CbZ_yhbz.mjs +68 -0
  3. package/dist/adapters/build.d.mts +2 -2
  4. package/dist/adapters/build.mjs +6 -6
  5. package/dist/adapters/cac.d.mts +1 -1
  6. package/dist/adapters/cac.mjs +3 -3
  7. package/dist/adapters/dev.d.mts +4 -4
  8. package/dist/adapters/dev.mjs +2 -2
  9. package/dist/adapters/embedded.d.mts +1 -1
  10. package/dist/adapters/initiate.d.mts +3 -3
  11. package/dist/adapters/initiate.mjs +1 -1
  12. package/dist/adapters/mcp.d.mts +1 -1
  13. package/dist/adapters/mcp.mjs +1 -1
  14. package/dist/cli/main.mjs +3 -3
  15. package/dist/client/index.d.mts +1 -1
  16. package/dist/client/index.mjs +22 -4
  17. package/dist/constants.d.mts +10 -1
  18. package/dist/constants.mjs +10 -1
  19. package/dist/{context-CQkRTbAc.d.mts → context-B3YUu_95.d.mts} +1 -1
  20. package/dist/{context-D0HD0F7C.mjs → context-CEe4PBz1.mjs} +7 -300
  21. package/dist/{context-D0jErmlx.mjs → context-xdynGSLP.mjs} +1 -1
  22. package/dist/{dev-QEuT8SOF.mjs → dev--rAPzbvO.mjs} +6 -6
  23. package/dist/{devframe-Cfx6doi4.d.mts → devframe-DJMg0WLe.d.mts} +7 -16
  24. package/dist/{diagnostics-hwjXp_UV.mjs → diagnostics-CD8nlgll.mjs} +1 -3
  25. package/dist/{diagnostics-DEuH3P5O.mjs → diagnostics-DOQPnQmX.mjs} +1 -3
  26. package/dist/{_shared-CKZPvSrN.mjs → dist-eNI9qM_I.mjs} +1 -67
  27. package/dist/{host-agent-C5HjzfBz.mjs → host-agent-xLCSe65D.mjs} +1 -1
  28. package/dist/{http-CVwj7b4g.mjs → http-DYpK0cUi.mjs} +4 -4
  29. package/dist/{index-MYi1SZVL.d.mts → index-CB-fSUyn.d.mts} +2 -2
  30. package/dist/index.d.mts +4 -3
  31. package/dist/{instance-registry-M2p-z6xE.mjs → instance-registry-WvQkt42E.mjs} +1 -1
  32. package/dist/{instance-shell-DJ8s-MFw.mjs → instance-shell-CMFyszWJ.mjs} +5 -5
  33. package/dist/{instance-shell-D_UA0Idz.d.mts → instance-shell-CljiKq1c.d.mts} +2 -2
  34. package/dist/internal/index.d.mts +8 -16
  35. package/dist/internal/index.mjs +7 -7
  36. package/dist/node/auth.d.mts +2 -2
  37. package/dist/node/hub-internals.d.mts +2 -2
  38. package/dist/node/hub-internals.mjs +2 -2
  39. package/dist/node/index.d.mts +1 -1
  40. package/dist/node/index.mjs +2 -2
  41. package/dist/nostics-CzECRXpE.mjs +59 -0
  42. package/dist/nostics-SPGDgHEP.d.mts +33 -0
  43. package/dist/recipes/common-rpc-functions.d.mts +1 -1
  44. package/dist/recipes/interactive-auth.d.mts +2 -2
  45. package/dist/recipes/interactive-auth.mjs +2 -2
  46. package/dist/{remote-assets-DclsYyoL.d.mts → remote-assets-Bg4gCUZ_.d.mts} +19 -2
  47. package/dist/remote-assets-nTTxY2MU.mjs +636 -0
  48. package/dist/rpc/dump.mjs +1 -1
  49. package/dist/rpc/index.mjs +3 -3
  50. package/dist/rpc/transports/sse-client.mjs +1 -1
  51. package/dist/rpc/transports/sse-server.mjs +2 -2
  52. package/dist/rpc/transports/ws-bun.d.mts +1 -1
  53. package/dist/rpc/transports/ws-bun.mjs +1 -1
  54. package/dist/rpc/transports/ws-client.mjs +1 -1
  55. package/dist/rpc/transports/ws-server.mjs +1 -1
  56. package/dist/{rpc-core-C8JQ3p7A.d.mts → rpc-core-Cc4lucI0.d.mts} +2 -2
  57. package/dist/{rpc-core-IhcWl_xn.mjs → rpc-core-DMTe-hLo.mjs} +1 -1
  58. package/dist/{serialization-BHY8M5NQ.mjs → serialization-BGzEwAdr.mjs} +1 -1
  59. package/dist/{static-CvjkO8QE.mjs → static-BPZ1_OPA.mjs} +2 -2
  60. package/dist/{storage-BVuipbGS.mjs → storage-CYye7P7L.mjs} +1 -1
  61. package/dist/types/index.d.mts +4 -3
  62. package/dist/utils/events.d.mts +1 -1
  63. package/dist/utils/get-port.d.mts +17 -0
  64. package/dist/utils/get-port.mjs +2 -0
  65. package/dist/utils/nostics.d.mts +2 -0
  66. package/dist/utils/nostics.mjs +2 -0
  67. package/dist/utils/remote-assets.d.mts +1 -1
  68. package/dist/utils/remote-assets.mjs +1 -308
  69. package/dist/utils/serve-static.d.mts +1 -1
  70. package/dist/utils/serve-static.mjs +16 -0
  71. package/dist/utils/shared-state.d.mts +1 -1
  72. package/dist/utils/streaming-channel.d.mts +1 -1
  73. package/dist/{validation-BiuDXTKW.mjs → validation-CpXFB6Dz.mjs} +1 -1
  74. package/dist/{wire-codec-9VhIKnyp.mjs → wire-codec-0K-o5MYW.mjs} +1 -3
  75. package/dist/{ws-server-Bk1hOG3X.mjs → ws-server-BdSLrhxE.mjs} +1 -1
  76. package/package.json +3 -1
  77. package/dist/diagnostics-reporter-CsIG85Q5.mjs +0 -38
@@ -1,6 +1,6 @@
1
- import { J as DevframeRpcServerFunctions, g as DevframeNodeContext, q as DevframeRpcClientFunctions, u as DevframeAuthHandler, z as DevframeNodeRpcSession } from "./devframe-Cfx6doi4.mjs";
1
+ import { K as DevframeRpcClientFunctions, R as DevframeNodeRpcSession, g as DevframeNodeContext, q as DevframeRpcServerFunctions, u as DevframeAuthHandler } from "./devframe-DJMg0WLe.mjs";
2
2
  import { d as DevframeRpcConnection, u as DevframeNodeRpcSessionMeta } from "./ws-server-D1d3QM9f.mjs";
3
- import "./index-MYi1SZVL.mjs";
3
+ import "./index-CB-fSUyn.mjs";
4
4
  import { BirpcGroup, EventOptions } from "birpc";
5
5
  //#region src/node/rpc-core.d.ts
6
6
  interface CreateContextRpcServerOptions {
@@ -1,6 +1,6 @@
1
1
  import { n as __exportAll } from "./rolldown-runtime-JspESFgx.mjs";
2
2
  import { createRpcServer } from "./rpc/server.mjs";
3
- import { t as diagnostics } from "./diagnostics-DEuH3P5O.mjs";
3
+ import { t as diagnostics } from "./diagnostics-DOQPnQmX.mjs";
4
4
  import { AsyncLocalStorage } from "node:async_hooks";
5
5
  //#region src/node/rpc-core.ts
6
6
  var rpc_core_exports = /* @__PURE__ */ __exportAll({ createContextRpcServer: () => createContextRpcServer });
@@ -1,4 +1,4 @@
1
- import { t as diagnostics } from "./diagnostics-hwjXp_UV.mjs";
1
+ import { t as diagnostics } from "./diagnostics-CD8nlgll.mjs";
2
2
  //#region src/rpc/serialization.ts
3
3
  /**
4
4
  * Wire format used by the live RPC transports (WebSocket and SSE).
@@ -1,5 +1,5 @@
1
- import { n as validateDefinitions, r as getRpcHandler, s as hash } from "./validation-BiuDXTKW.mjs";
2
- import { t as diagnostics } from "./diagnostics-hwjXp_UV.mjs";
1
+ import { n as validateDefinitions, r as getRpcHandler, s as hash } from "./validation-CpXFB6Dz.mjs";
2
+ import { t as diagnostics } from "./diagnostics-CD8nlgll.mjs";
3
3
  import { DEVFRAME_RPC_DUMP_DIRNAME } from "./constants.mjs";
4
4
  //#region ../../node_modules/.pnpm/yocto-queue@1.2.2/node_modules/yocto-queue/index.js
5
5
  var Node = class {
@@ -1,4 +1,4 @@
1
- import { t as diagnostics } from "./diagnostics-DEuH3P5O.mjs";
1
+ import { t as diagnostics } from "./diagnostics-DOQPnQmX.mjs";
2
2
  import { createSharedState } from "devframe/utils/shared-state";
3
3
  import fs from "node:fs";
4
4
  import { dirname } from "pathe";
@@ -1,5 +1,6 @@
1
- import { A as ScopedServerFunctions, B as RpcBroadcastOptions, C as DevframeScopedStreamingHost, Ct as AgentToolProviderHandle, D as ScopedBroadcastOptions, Dt as EventUnsubscribe, E as DevframeSettingsStore, Et as EventEmitter, F as DevframeStorageScope, G as RpcStreamingChannelOptions, H as RpcSharedStateGetOptions, I as DevframeDefineDiagnosticsOptions, J as DevframeRpcServerFunctions, K as RpcStreamingHost, L as DevframeDiagnosticsHost, M as SettingsForNamespace, N as DevframeViewHost, O as ScopedClientFunctions, Ot as EventsMap, P as DevframeHost, R as DevframeDiagnosticsLogger, S as DevframeScopedNodeRpc, St as AgentToolProvider, T as DevframeSettingsRegistry, Tt as DevframeAgentHostEvents, U as RpcSharedStateHost, V as RpcFunctionsHost, W as RpcStreamingChannel, Y as DevframeRpcSharedStates, _ as DevframeServiceId, _t as AgentResource, a as DevframeDuplicationStrategy, b as DevframeServicesRegistry, bt as AgentTool, c as DevframeWsOptions, d as ConnectionMeta, f as ConnectionMetaSse, g as DevframeNodeContext, gt as AgentManifest, h as DevframeConnectionConfigsRegistry, ht as AgentHandle, i as DevframeDockDefaults, j as ScopedSharedStates, k as ScopedRpcFn, l as McpRouteOptions, m as DevframeCapabilities, n as DevframeDefinition, o as DevframeSetupInfo, p as ConnectionMetaWebsocket, q as DevframeRpcClientFunctions, r as DevframeDeploymentKind, s as DevframeSseOptions, t as DevframeCliOptions, v as DevframeServiceOf, vt as AgentResourceContent, w as DevframeSettings, wt as DevframeAgentHost, x as DevframeScopedNodeContext, xt as AgentToolInput, y as DevframeServicesHost, yt as AgentResourceInput, z as DevframeNodeRpcSession } from "../devframe-Cfx6doi4.mjs";
1
+ import { A as ScopedServerFunctions, B as RpcFunctionsHost, C as DevframeScopedStreamingHost, Ct as DevframeAgentHost, D as ScopedBroadcastOptions, Dt as EventsMap, E as DevframeSettingsStore, Et as EventUnsubscribe, F as DevframeStorageScope, G as RpcStreamingHost, H as RpcSharedStateHost, I as DevframeDiagnosticsHost, J as DevframeRpcSharedStates, K as DevframeRpcClientFunctions, L as DevframeDiagnosticsLogger, M as SettingsForNamespace, N as DevframeViewHost, O as ScopedClientFunctions, P as DevframeHost, R as DevframeNodeRpcSession, S as DevframeScopedNodeRpc, St as AgentToolProviderHandle, T as DevframeSettingsRegistry, Tt as EventEmitter, U as RpcStreamingChannel, V as RpcSharedStateGetOptions, W as RpcStreamingChannelOptions, _ as DevframeServiceId, _t as AgentResourceContent, a as DevframeDuplicationStrategy, b as DevframeServicesRegistry, bt as AgentToolInput, c as DevframeWsOptions, d as ConnectionMeta, f as ConnectionMetaSse, g as DevframeNodeContext, gt as AgentResource, h as DevframeConnectionConfigsRegistry, ht as AgentManifest, i as DevframeDockDefaults, j as ScopedSharedStates, k as ScopedRpcFn, l as McpRouteOptions, m as DevframeCapabilities, mt as AgentHandle, n as DevframeDefinition, o as DevframeSetupInfo, p as ConnectionMetaWebsocket, q as DevframeRpcServerFunctions, r as DevframeDeploymentKind, s as DevframeSseOptions, t as DevframeCliOptions, v as DevframeServiceOf, vt as AgentResourceInput, w as DevframeSettings, wt as DevframeAgentHostEvents, x as DevframeScopedNodeContext, xt as AgentToolProvider, y as DevframeServicesHost, yt as AgentTool, z as RpcBroadcastOptions } from "../devframe-DJMg0WLe.mjs";
2
2
  import { g as RpcFunctionAgentOptions } from "../types-Djq7CBXh.mjs";
3
3
  import { d as DevframeRpcConnection, f as DevframeRpcConnectionRequest, p as DevframeRpcTransportKind, u as DevframeNodeRpcSessionMeta } from "../ws-server-D1d3QM9f.mjs";
4
- import { a as StaticAssetsSource, i as RemoteAssetsStore, n as RemoteAssetsProvider, r as RemoteAssetsProviderCustom, t as RemoteAssets } from "../remote-assets-DclsYyoL.mjs";
5
- export { AgentHandle, AgentManifest, AgentResource, AgentResourceContent, AgentResourceInput, AgentTool, AgentToolInput, AgentToolProvider, AgentToolProviderHandle, ConnectionMeta, ConnectionMetaSse, ConnectionMetaWebsocket, DevframeAgentHost, DevframeAgentHostEvents, DevframeCapabilities, DevframeCliOptions, DevframeConnectionConfigsRegistry, DevframeDefineDiagnosticsOptions, DevframeDefinition, DevframeDeploymentKind, DevframeDiagnosticsHost, DevframeDiagnosticsLogger, DevframeDockDefaults, DevframeDuplicationStrategy, DevframeHost, DevframeNodeContext, DevframeNodeRpcSession, type DevframeNodeRpcSessionMeta, DevframeRpcClientFunctions, type DevframeRpcConnection, type DevframeRpcConnectionRequest, DevframeRpcServerFunctions, DevframeRpcSharedStates, type DevframeRpcTransportKind, DevframeScopedNodeContext, DevframeScopedNodeRpc, DevframeScopedStreamingHost, DevframeServiceId, DevframeServiceOf, DevframeServicesHost, DevframeServicesRegistry, DevframeSettings, DevframeSettingsRegistry, DevframeSettingsStore, DevframeSetupInfo, DevframeSseOptions, DevframeStorageScope, DevframeViewHost, DevframeWsOptions, EventEmitter, EventUnsubscribe, EventsMap, McpRouteOptions, RemoteAssets, RemoteAssetsProvider, RemoteAssetsProviderCustom, RemoteAssetsStore, RpcBroadcastOptions, type RpcFunctionAgentOptions, RpcFunctionsHost, RpcSharedStateGetOptions, RpcSharedStateHost, RpcStreamingChannel, RpcStreamingChannelOptions, RpcStreamingHost, ScopedBroadcastOptions, ScopedClientFunctions, ScopedRpcFn, ScopedServerFunctions, ScopedSharedStates, SettingsForNamespace, StaticAssetsSource };
4
+ import { i as DevframeDefineDiagnosticsOptions } from "../nostics-SPGDgHEP.mjs";
5
+ import { a as RemoteAssetsStore, i as RemoteAssetsProviderCustom, n as RemoteAssetsErrorMessage, o as StaticAssetsSource, r as RemoteAssetsProvider, t as RemoteAssets } from "../remote-assets-Bg4gCUZ_.mjs";
6
+ export { AgentHandle, AgentManifest, AgentResource, AgentResourceContent, AgentResourceInput, AgentTool, AgentToolInput, AgentToolProvider, AgentToolProviderHandle, ConnectionMeta, ConnectionMetaSse, ConnectionMetaWebsocket, DevframeAgentHost, DevframeAgentHostEvents, DevframeCapabilities, DevframeCliOptions, DevframeConnectionConfigsRegistry, type DevframeDefineDiagnosticsOptions, DevframeDefinition, DevframeDeploymentKind, DevframeDiagnosticsHost, DevframeDiagnosticsLogger, DevframeDockDefaults, DevframeDuplicationStrategy, DevframeHost, DevframeNodeContext, DevframeNodeRpcSession, type DevframeNodeRpcSessionMeta, DevframeRpcClientFunctions, type DevframeRpcConnection, type DevframeRpcConnectionRequest, DevframeRpcServerFunctions, DevframeRpcSharedStates, type DevframeRpcTransportKind, DevframeScopedNodeContext, DevframeScopedNodeRpc, DevframeScopedStreamingHost, DevframeServiceId, DevframeServiceOf, DevframeServicesHost, DevframeServicesRegistry, DevframeSettings, DevframeSettingsRegistry, DevframeSettingsStore, DevframeSetupInfo, DevframeSseOptions, DevframeStorageScope, DevframeViewHost, DevframeWsOptions, EventEmitter, EventUnsubscribe, EventsMap, McpRouteOptions, RemoteAssets, RemoteAssetsErrorMessage, RemoteAssetsProvider, RemoteAssetsProviderCustom, RemoteAssetsStore, RpcBroadcastOptions, type RpcFunctionAgentOptions, RpcFunctionsHost, RpcSharedStateGetOptions, RpcSharedStateHost, RpcStreamingChannel, RpcStreamingChannelOptions, RpcStreamingHost, ScopedBroadcastOptions, ScopedClientFunctions, ScopedRpcFn, ScopedServerFunctions, ScopedSharedStates, SettingsForNamespace, StaticAssetsSource };
@@ -1,4 +1,4 @@
1
- import { Et as EventEmitter, Ot as EventsMap } from "../devframe-Cfx6doi4.mjs";
1
+ import { Dt as EventsMap, Tt as EventEmitter } from "../devframe-DJMg0WLe.mjs";
2
2
  //#region src/utils/events.d.ts
3
3
  /**
4
4
  * Create event emitter.
@@ -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 };
@@ -0,0 +1,2 @@
1
+ import { a as Diagnostic, c as DiagnosticHandle, d as Diagnostics, f as ansiFormatter, g as formatDiagnostic, h as defineProdDiagnostics, i as DevframeDefineDiagnosticsOptions, l as DiagnosticInit, m as defineDiagnostics, n as ConsoleMethod, o as DiagnosticCallParams, p as createConsoleReporter, r as ConsoleReporterOptions, s as DiagnosticDefinition, t as AnyDiagnosticReporter, u as DiagnosticReporter } from "../nostics-SPGDgHEP.mjs";
2
+ export { type AnyDiagnosticReporter, type ConsoleMethod, type ConsoleReporterOptions, DevframeDefineDiagnosticsOptions, type Diagnostic, type DiagnosticCallParams, type DiagnosticDefinition, type DiagnosticHandle, type DiagnosticInit, type DiagnosticReporter, type Diagnostics, ansiFormatter, createConsoleReporter, defineDiagnostics, defineProdDiagnostics, formatDiagnostic };
@@ -0,0 +1,2 @@
1
+ import { a as defineProdDiagnostics, i as defineDiagnostics, n as ansiFormatter, o as formatDiagnostic, r as createConsoleReporter, t as Diagnostic } from "../nostics-CzECRXpE.mjs";
2
+ export { Diagnostic, ansiFormatter, createConsoleReporter, defineDiagnostics, defineProdDiagnostics, formatDiagnostic };
@@ -1,4 +1,4 @@
1
- import { a as StaticAssetsSource, i as RemoteAssetsStore } from "../remote-assets-DclsYyoL.mjs";
1
+ import { a as RemoteAssetsStore, o as StaticAssetsSource } from "../remote-assets-Bg4gCUZ_.mjs";
2
2
  //#region src/utils/remote-assets.d.ts
3
3
  /**
4
4
  * Normalize a {@link StaticAssetsSource} into something servable: a local
@@ -1,309 +1,2 @@
1
- import { t as diagnostics } from "../diagnostics-DEuH3P5O.mjs";
2
- import { createRequire } from "node:module";
3
- import { createReadStream, existsSync } from "node:fs";
4
- import { Buffer } from "node:buffer";
5
- import { mkdir, readFile, rename, rm, stat, writeFile } from "node:fs/promises";
6
- import { Readable } from "node:stream";
7
- import { lookup } from "mrmime";
8
- import { dirname, extname, join, normalize, sep } from "pathe";
9
- //#region src/utils/remote-assets.ts
10
- const MANIFEST_FILENAME = ".manifest.json";
11
- /** Flatten a jsDelivr (`name`/`files`) or unpkg (`path`/`files`) file tree. */
12
- function flattenTree(nodes, style) {
13
- const out = [];
14
- const walk = (list, prefix) => {
15
- for (const node of list) if (style === "path") if (node.type === "file") out.push((node.path ?? "").replace(/^\//, ""));
16
- else walk(node.files ?? [], "");
17
- else if (node.type === "file") out.push(prefix + (node.name ?? ""));
18
- else if (node.files) walk(node.files, `${prefix}${node.name}/`);
19
- };
20
- walk(nodes, "");
21
- return out;
22
- }
23
- const providers = {
24
- jsdelivr: {
25
- fileUrl: (pkg, version, filePath) => `https://cdn.jsdelivr.net/npm/${pkg}@${version}/${filePath}`,
26
- listFiles: async (pkg, version, fetchImpl) => {
27
- const res = await fetchImpl(`https://data.jsdelivr.com/v1/packages/npm/${pkg}@${version}`);
28
- if (!res.ok) throw new Error(`HTTP ${res.status} from data.jsdelivr.com`);
29
- return flattenTree((await res.json()).files ?? [], "name");
30
- }
31
- },
32
- unpkg: {
33
- fileUrl: (pkg, version, filePath) => `https://unpkg.com/${pkg}@${version}/${filePath}`,
34
- listFiles: async (pkg, version, fetchImpl) => {
35
- const res = await fetchImpl(`https://unpkg.com/${pkg}@${version}/?meta`);
36
- if (!res.ok) throw new Error(`HTTP ${res.status} from unpkg.com`);
37
- return flattenTree([await res.json()], "path");
38
- }
39
- }
40
- };
41
- function resolveProvider(assets) {
42
- const p = assets.provider ?? "jsdelivr";
43
- return typeof p === "string" ? {
44
- provider: providers[p],
45
- name: p
46
- } : {
47
- provider: p,
48
- name: "custom"
49
- };
50
- }
51
- /**
52
- * Resolve a locally installed copy of `assets.package` from
53
- * `assets.resolveFrom`'s dependency graph and return its assets directory,
54
- * or `undefined` when the package (or directory) is absent. A different
55
- * installed version warns (`DF0062`); a different major throws (`DF0061`).
56
- */
57
- function resolveInstalled(assets) {
58
- if (!assets.resolveFrom) return void 0;
59
- let pkgJsonPath;
60
- let installed;
61
- try {
62
- const requireFrom = createRequire(assets.resolveFrom);
63
- pkgJsonPath = requireFrom.resolve(`${assets.package}/package.json`);
64
- installed = requireFrom(`${assets.package}/package.json`).version;
65
- } catch {
66
- return;
67
- }
68
- if (typeof installed !== "string") return void 0;
69
- if (installed !== assets.version) {
70
- const major = (v) => v.trim().split(".")[0] ?? v;
71
- if (major(installed) !== major(assets.version)) throw diagnostics.DF0061({
72
- package: assets.package,
73
- required: assets.version,
74
- installed
75
- });
76
- diagnostics.DF0062({
77
- package: assets.package,
78
- required: assets.version,
79
- installed
80
- });
81
- }
82
- const dir = join(dirname(pkgJsonPath), assets.path ?? "dist");
83
- return existsSync(dir) ? dir : void 0;
84
- }
85
- function contentTypeFor(filePath) {
86
- const type = lookup(filePath);
87
- if (!type) return "application/octet-stream";
88
- return type === "text/html" ? "text/html; charset=utf-8" : type;
89
- }
90
- /** Clean a request path into a safe package-relative POSIX path, or `null` if it escapes root. */
91
- function cleanRequestPath(urlPath) {
92
- let cleaned;
93
- try {
94
- cleaned = decodeURIComponent(urlPath || "/");
95
- } catch {
96
- return null;
97
- }
98
- cleaned = cleaned.replace(/[?#].*$/, "").replace(/^\/+|\/+$/g, "");
99
- const normalized = normalize(cleaned);
100
- if (normalized === ".." || normalized.startsWith(`..${sep}`) || normalized.startsWith("/")) return null;
101
- return normalized === "." ? "" : normalized;
102
- }
103
- /** Candidate files for a request, in order: direct hit, index, `.html`, SPA fallback. */
104
- function candidatePaths(prefix, cleaned) {
105
- const candidates = [];
106
- if (cleaned) candidates.push(prefix + cleaned);
107
- candidates.push(`${prefix}${cleaned ? `${cleaned}/` : ""}index.html`);
108
- if (cleaned && !extname(cleaned)) candidates.push(`${prefix + cleaned}.html`);
109
- if (!/\.[a-z0-9]+$/i.test(cleaned) && !candidates.includes(`${prefix}index.html`)) candidates.push(`${prefix}index.html`);
110
- return candidates;
111
- }
112
- function createStore(assets, cacheDir) {
113
- const normalized = {
114
- ...assets,
115
- path: assets.path ?? "dist"
116
- };
117
- const { provider, name: providerName } = resolveProvider(assets);
118
- const fetchImpl = assets.fetch ?? globalThis.fetch;
119
- const prefix = `${normalized.path}/`;
120
- let manifestPromise;
121
- let manifestReported = false;
122
- async function loadManifest() {
123
- const manifestFile = join(cacheDir, MANIFEST_FILENAME);
124
- try {
125
- return new Set(JSON.parse(await readFile(manifestFile, "utf8")));
126
- } catch {}
127
- if (assets.offline || !provider.listFiles) return null;
128
- try {
129
- const files = await provider.listFiles(normalized.package, normalized.version, fetchImpl);
130
- await mkdir(cacheDir, { recursive: true });
131
- await writeFile(manifestFile, JSON.stringify(files), "utf8").catch(() => {});
132
- return new Set(files);
133
- } catch (error) {
134
- if (!manifestReported) {
135
- manifestReported = true;
136
- diagnostics.DF0059({
137
- package: normalized.package,
138
- version: normalized.version,
139
- provider: providerName,
140
- reason: errText(error),
141
- cause: error
142
- });
143
- }
144
- return null;
145
- }
146
- }
147
- async function serveCached(filePath) {
148
- const abs = join(cacheDir, filePath);
149
- let size;
150
- try {
151
- const s = await stat(abs);
152
- if (!s.isFile()) return null;
153
- size = s.size;
154
- } catch {
155
- return null;
156
- }
157
- return new Response(Readable.toWeb(createReadStream(abs)), { headers: {
158
- "Content-Type": contentTypeFor(filePath),
159
- "Content-Length": String(size),
160
- "Cache-Control": "no-store"
161
- } });
162
- }
163
- /** Persist `body` to the cache at `filePath` (tmp + rename); failures warn (`DF0063`). */
164
- async function persist(filePath, body) {
165
- const target = join(cacheDir, filePath);
166
- const tmp = `${target}.${Math.random().toString(36).slice(2)}.tmp`;
167
- try {
168
- await mkdir(dirname(target), { recursive: true });
169
- await writeFile(tmp, Buffer.from(await new Response(body).arrayBuffer()));
170
- await rename(tmp, target);
171
- } catch (error) {
172
- await rm(tmp, { force: true }).catch(() => {});
173
- diagnostics.DF0063({
174
- filepath: target,
175
- reason: errText(error),
176
- cause: error
177
- });
178
- }
179
- }
180
- /** Fetch `filePath` through the provider: `null` on 404, a `Response` on 200, throws (`DF0060`) otherwise. */
181
- async function serveRemote(filePath) {
182
- const url = provider.fileUrl(normalized.package, normalized.version, filePath);
183
- let res;
184
- try {
185
- res = await fetchImpl(url);
186
- } catch (error) {
187
- throw diagnostics.DF0060({
188
- url,
189
- package: normalized.package,
190
- reason: errText(error),
191
- cause: error
192
- });
193
- }
194
- if (res.status === 404) {
195
- await res.body?.cancel().catch(() => {});
196
- return null;
197
- }
198
- if (!res.ok || !res.body) {
199
- await res.body?.cancel().catch(() => {});
200
- throw diagnostics.DF0060({
201
- url,
202
- package: normalized.package,
203
- reason: `HTTP ${res.status}`
204
- });
205
- }
206
- const [toClient, toCache] = res.body.tee();
207
- persist(filePath, toCache);
208
- const length = res.headers.get("content-length");
209
- return new Response(toClient, { headers: {
210
- "Content-Type": contentTypeFor(filePath),
211
- "Cache-Control": "no-store",
212
- ...length ? { "Content-Length": length } : {}
213
- } });
214
- }
215
- async function serve(urlPath) {
216
- const cleaned = cleanRequestPath(urlPath);
217
- if (cleaned === null) return null;
218
- const candidates = candidatePaths(prefix, cleaned);
219
- manifestPromise ??= loadManifest();
220
- const manifest = await manifestPromise;
221
- if (manifest) {
222
- const filePath = candidates.find((c) => manifest.has(c));
223
- if (!filePath) return null;
224
- return await serveCached(filePath) ?? (assets.offline ? Promise.reject(diagnostics.DF0060({
225
- url: filePath,
226
- package: normalized.package,
227
- reason: "offline: true and the file is not in the cache"
228
- })) : serveRemote(filePath));
229
- }
230
- for (const candidate of candidates) {
231
- const cached = await serveCached(candidate);
232
- if (cached) return cached;
233
- }
234
- if (assets.offline) return null;
235
- for (const candidate of candidates) {
236
- const remote = await serveRemote(candidate);
237
- if (remote) return remote;
238
- }
239
- return null;
240
- }
241
- async function materialize(targetDir) {
242
- const fail = (reason, cause) => {
243
- throw diagnostics.DF0064({
244
- package: normalized.package,
245
- version: normalized.version,
246
- reason,
247
- cause
248
- });
249
- };
250
- if (!provider.listFiles) fail("the configured provider has no file listing (`listFiles`)");
251
- let files;
252
- try {
253
- files = await provider.listFiles(normalized.package, normalized.version, fetchImpl);
254
- } catch (error) {
255
- return fail(errText(error), error);
256
- }
257
- for (const filePath of files.filter((f) => f.startsWith(prefix))) {
258
- const target = join(targetDir, filePath.slice(prefix.length));
259
- const url = provider.fileUrl(normalized.package, normalized.version, filePath);
260
- let res;
261
- try {
262
- res = await fetchImpl(url);
263
- if (!res.ok) throw new Error(`HTTP ${res.status}`);
264
- } catch (error) {
265
- return fail(`failed to download ${filePath}: ${errText(error)}`, error);
266
- }
267
- await mkdir(dirname(target), { recursive: true });
268
- await writeFile(target, Buffer.from(await res.arrayBuffer()));
269
- }
270
- }
271
- return {
272
- assets: normalized,
273
- serve,
274
- materialize
275
- };
276
- }
277
- function errText(error) {
278
- return error instanceof Error ? error.message : String(error);
279
- }
280
- const PACKAGE_NAME_RE = /^(?:@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/;
281
- const VERSION_RE = /^\d+\.\d+\.\d+(?:-[a-z0-9-]+(?:\.[a-z0-9-]+)*)?(?:\+[a-z0-9-]+(?:\.[a-z0-9-]+)*)?$/i;
282
- /** Reject a {@link RemoteAssets} with an unsafe package name or version (`DF0065`). */
283
- function assertValidRemoteAssets(assets) {
284
- if (assets.package.length > 214 || !PACKAGE_NAME_RE.test(assets.package)) throw diagnostics.DF0065({
285
- field: "package",
286
- value: assets.package
287
- });
288
- if (!VERSION_RE.test(assets.version)) throw diagnostics.DF0065({
289
- field: "version",
290
- value: assets.version
291
- });
292
- }
293
- /**
294
- * Normalize a {@link StaticAssetsSource} into something servable: a local
295
- * directory (strings pass through; a remote source short-circuits to a
296
- * locally installed copy of its package when present) or a caching
297
- * {@link RemoteAssetsStore} back-proxy. Remote caches live under
298
- * `<projectStorageDir>/.remote-assets/<package>@<version>/`.
299
- *
300
- * A remote source's `package`/`version` are validated first (`DF0065`) — both
301
- * are interpolated into CDN URLs and the cache path.
302
- */
303
- function resolveStaticAssetsSource(source, projectStorageDir) {
304
- if (typeof source === "string") return source;
305
- assertValidRemoteAssets(source);
306
- return resolveInstalled(source) ?? createStore(source, join(projectStorageDir, ".remote-assets", `${source.package.replace(/\//g, "+")}@${source.version}`));
307
- }
308
- //#endregion
1
+ import { t as resolveStaticAssetsSource } from "../remote-assets-nTTxY2MU.mjs";
309
2
  export { resolveStaticAssetsSource };
@@ -1,4 +1,4 @@
1
- import { i as RemoteAssetsStore } from "../remote-assets-DclsYyoL.mjs";
1
+ import { a as RemoteAssetsStore } from "../remote-assets-Bg4gCUZ_.mjs";
2
2
  import { IncomingMessage, ServerResponse } from "node:http";
3
3
  import { EventHandler, H3 } from "h3";
4
4
  //#region src/utils/serve-static.d.ts
@@ -1,3 +1,4 @@
1
+ import { DEVFRAME_REMOTE_ASSETS_ERROR_MESSAGE_TYPE } from "../constants.mjs";
1
2
  import { createReadStream } from "node:fs";
2
3
  import { stat } from "node:fs/promises";
3
4
  import { Readable } from "node:stream";
@@ -220,11 +221,22 @@ function serveStaticNodeMiddleware(source, options) {
220
221
  /**
221
222
  * Minimal, dependency-free HTML shown when a remote-assets request cannot
222
223
  * be satisfied (no installed package, no cache, provider unreachable).
224
+ *
225
+ * The page stands on its own when a devframe is opened directly, and
226
+ * announces itself over `postMessage` when it loads inside a viewer's iframe
227
+ * ({@link DEVFRAME_REMOTE_ASSETS_ERROR_MESSAGE_TYPE}) so the viewer can show
228
+ * the same failure in its own UI instead.
223
229
  */
224
230
  function remoteErrorPage(pkg, version, reason) {
225
231
  const esc = (s) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
226
232
  const name = esc(pkg);
227
233
  const ver = esc(version);
234
+ const payload = JSON.stringify({
235
+ type: DEVFRAME_REMOTE_ASSETS_ERROR_MESSAGE_TYPE,
236
+ package: pkg,
237
+ version,
238
+ reason
239
+ }).replace(/</g, "\\u003c");
228
240
  return `<!doctype html>
229
241
  <html lang="en">
230
242
  <head>
@@ -254,6 +266,10 @@ function remoteErrorPage(pkg, version, reason) {
254
266
  <button onclick="location.reload()">Retry</button>
255
267
  <p class="muted">devframe remote assets</p>
256
268
  </main>
269
+ <script>
270
+ if (window.parent !== window)
271
+ window.parent.postMessage(${payload}, '*')
272
+ <\/script>
257
273
  </body>
258
274
  </html>
259
275
  `;
@@ -1,2 +1,2 @@
1
- import { at as Immutable, ct as ImmutableObject, dt as SharedStateEvents, ft as SharedStateOptions, lt as ImmutableSet, mt as createSharedState, ot as ImmutableArray, pt as SharedStatePatch, st as ImmutableMap, ut as SharedState } from "../devframe-Cfx6doi4.mjs";
1
+ import { at as ImmutableArray, ct as ImmutableSet, dt as SharedStateOptions, ft as SharedStatePatch, it as Immutable, lt as SharedState, ot as ImmutableMap, pt as createSharedState, st as ImmutableObject, ut as SharedStateEvents } from "../devframe-DJMg0WLe.mjs";
2
2
  export { Immutable, ImmutableArray, ImmutableMap, ImmutableObject, ImmutableSet, SharedState, SharedStateEvents, SharedStateOptions, SharedStatePatch, createSharedState };
@@ -1,2 +1,2 @@
1
- import { $ as StreamErrorPayload, Q as CreateStreamSinkOptions, X as BufferedChunk, Z as CreateStreamReaderOptions, et as StreamReader, it as createStreamSink, nt as StreamSinkEvents, rt as createStreamReader, tt as StreamSink } from "../devframe-Cfx6doi4.mjs";
1
+ import { $ as StreamReader, Q as StreamErrorPayload, X as CreateStreamReaderOptions, Y as BufferedChunk, Z as CreateStreamSinkOptions, et as StreamSink, nt as createStreamReader, rt as createStreamSink, tt as StreamSinkEvents } from "../devframe-DJMg0WLe.mjs";
2
2
  export { BufferedChunk, CreateStreamReaderOptions, CreateStreamSinkOptions, StreamErrorPayload, StreamReader, StreamSink, StreamSinkEvents, createStreamReader, createStreamSink };
@@ -1,4 +1,4 @@
1
- import { t as diagnostics } from "./diagnostics-hwjXp_UV.mjs";
1
+ import { t as diagnostics } from "./diagnostics-CD8nlgll.mjs";
2
2
  import { createHash } from "node:crypto";
3
3
  //#region ../../node_modules/.pnpm/ohash@2.0.11/node_modules/ohash/dist/shared/ohash.D__AXeF1.mjs
4
4
  function serialize(o) {
@@ -1,4 +1,4 @@
1
- import { n as strictJsonStringify } from "./serialization-BHY8M5NQ.mjs";
1
+ import { n as strictJsonStringify } from "./serialization-BGzEwAdr.mjs";
2
2
  import { n as structuredCloneStringify, t as structuredCloneParse } from "./structured-clone-CbAV5rFI.mjs";
3
3
  //#region src/rpc/wire-codec.ts
4
4
  const EMPTY_WIRE_DEFS = /* @__PURE__ */ new Map();
@@ -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-9VhIKnyp.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.8",
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,9 +48,11 @@
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",
55
+ "./utils/nostics": "./dist/utils/nostics.mjs",
54
56
  "./utils/open": "./dist/utils/open.mjs",
55
57
  "./utils/remote-assets": "./dist/utils/remote-assets.mjs",
56
58
  "./utils/simple-schema": "./dist/utils/simple-schema.mjs",
@@ -1,38 +0,0 @@
1
- import { ansiFormatter } from "nostics/formatters/ansi";
2
- //#region src/utils/colors.ts
3
- function makeColor(open, close) {
4
- const o = `\x1B[${open}m`;
5
- const c = `\x1B[${close}m`;
6
- return ((arg, ...values) => {
7
- if (Array.isArray(arg) && "raw" in arg) {
8
- const strings = arg;
9
- let out = "";
10
- for (let i = 0; i < strings.length; i++) {
11
- out += strings[i];
12
- if (i < values.length) out += String(values[i]);
13
- }
14
- return `${o}${out}${c}`;
15
- }
16
- return `${o}${String(arg)}${c}`;
17
- });
18
- }
19
- const colors = {
20
- blue: makeColor(34, 39),
21
- cyan: makeColor(36, 39),
22
- gray: makeColor(90, 39),
23
- green: makeColor(32, 39),
24
- red: makeColor(31, 39),
25
- yellow: makeColor(33, 39),
26
- bold: makeColor(1, 22),
27
- dim: makeColor(2, 22),
28
- reset: makeColor(0, 0),
29
- underline: makeColor(4, 24)
30
- };
31
- //#endregion
32
- //#region src/utils/diagnostics-reporter.ts
33
- const formatAnsi = ansiFormatter(colors);
34
- function devframeReporter(d, { method = "warn" } = {}) {
35
- console[method](formatAnsi(d));
36
- }
37
- //#endregion
38
- export { colors as n, devframeReporter as t };