devframe 0.9.0-beta.8 → 0.9.0-beta.9
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/{_shared-QkI6ljJS.d.mts → _shared-BPmX9fqK.d.mts} +1 -1
- package/dist/adapters/build.d.mts +2 -2
- package/dist/adapters/build.mjs +6 -6
- package/dist/adapters/cac.d.mts +1 -1
- package/dist/adapters/cac.mjs +2 -2
- package/dist/adapters/dev.d.mts +4 -4
- package/dist/adapters/dev.mjs +1 -1
- package/dist/adapters/embedded.d.mts +1 -1
- package/dist/adapters/initiate.d.mts +3 -3
- package/dist/adapters/initiate.mjs +1 -1
- package/dist/adapters/mcp.d.mts +1 -1
- package/dist/adapters/mcp.mjs +1 -1
- package/dist/cli/main.mjs +3 -3
- package/dist/client/index.d.mts +1 -1
- package/dist/client/index.mjs +22 -3
- package/dist/constants.d.mts +10 -1
- package/dist/constants.mjs +10 -1
- package/dist/{context-CQkRTbAc.d.mts → context-B3YUu_95.d.mts} +1 -1
- package/dist/{context-D0HD0F7C.mjs → context-CEe4PBz1.mjs} +7 -300
- package/dist/{context-D0jErmlx.mjs → context-xdynGSLP.mjs} +1 -1
- package/dist/{dev-QEuT8SOF.mjs → dev-Chvlqs7I.mjs} +5 -5
- package/dist/{devframe-Cfx6doi4.d.mts → devframe-DJMg0WLe.d.mts} +7 -16
- package/dist/{diagnostics-hwjXp_UV.mjs → diagnostics-CD8nlgll.mjs} +1 -3
- package/dist/{diagnostics-DEuH3P5O.mjs → diagnostics-DOQPnQmX.mjs} +1 -3
- package/dist/{host-agent-C5HjzfBz.mjs → host-agent-xLCSe65D.mjs} +1 -1
- package/dist/{http-CVwj7b4g.mjs → http-8Kpkap4_.mjs} +4 -4
- package/dist/{index-MYi1SZVL.d.mts → index-CB-fSUyn.d.mts} +2 -2
- package/dist/index.d.mts +4 -3
- package/dist/{instance-registry-M2p-z6xE.mjs → instance-registry-WvQkt42E.mjs} +1 -1
- package/dist/{instance-shell-D_UA0Idz.d.mts → instance-shell-CljiKq1c.d.mts} +2 -2
- package/dist/{instance-shell-DJ8s-MFw.mjs → instance-shell-XvN5USg4.mjs} +4 -4
- package/dist/internal/index.d.mts +8 -13
- package/dist/internal/index.mjs +6 -6
- package/dist/node/auth.d.mts +2 -2
- package/dist/node/hub-internals.d.mts +2 -2
- package/dist/node/hub-internals.mjs +1 -1
- package/dist/node/index.d.mts +1 -1
- package/dist/node/index.mjs +2 -2
- package/dist/nostics-CzECRXpE.mjs +59 -0
- package/dist/nostics-SPGDgHEP.d.mts +33 -0
- package/dist/recipes/common-rpc-functions.d.mts +1 -1
- package/dist/recipes/interactive-auth.d.mts +2 -2
- package/dist/recipes/interactive-auth.mjs +2 -2
- package/dist/{remote-assets-DclsYyoL.d.mts → remote-assets-Bg4gCUZ_.d.mts} +19 -2
- package/dist/remote-assets-nTTxY2MU.mjs +636 -0
- package/dist/rpc/dump.mjs +1 -1
- package/dist/rpc/index.mjs +3 -3
- package/dist/rpc/transports/sse-client.mjs +1 -1
- package/dist/rpc/transports/sse-server.mjs +2 -2
- package/dist/rpc/transports/ws-bun.d.mts +1 -1
- package/dist/rpc/transports/ws-bun.mjs +1 -1
- package/dist/rpc/transports/ws-client.mjs +1 -1
- package/dist/rpc/transports/ws-server.mjs +1 -1
- package/dist/{rpc-core-C8JQ3p7A.d.mts → rpc-core-Cc4lucI0.d.mts} +2 -2
- package/dist/{rpc-core-IhcWl_xn.mjs → rpc-core-DMTe-hLo.mjs} +1 -1
- package/dist/{serialization-BHY8M5NQ.mjs → serialization-BGzEwAdr.mjs} +1 -1
- package/dist/{static-CvjkO8QE.mjs → static-BPZ1_OPA.mjs} +2 -2
- package/dist/{storage-BVuipbGS.mjs → storage-CYye7P7L.mjs} +1 -1
- package/dist/types/index.d.mts +4 -3
- package/dist/utils/events.d.mts +1 -1
- package/dist/utils/nostics.d.mts +2 -0
- package/dist/utils/nostics.mjs +2 -0
- package/dist/utils/remote-assets.d.mts +1 -1
- package/dist/utils/remote-assets.mjs +1 -308
- package/dist/utils/serve-static.d.mts +1 -1
- package/dist/utils/serve-static.mjs +16 -0
- package/dist/utils/shared-state.d.mts +1 -1
- package/dist/utils/streaming-channel.d.mts +1 -1
- package/dist/{validation-BiuDXTKW.mjs → validation-CpXFB6Dz.mjs} +1 -1
- package/dist/{wire-codec-9VhIKnyp.mjs → wire-codec-GsoRxIsD.mjs} +1 -1
- package/dist/{ws-server-Bk1hOG3X.mjs → ws-server-BiUne4K7.mjs} +1 -1
- package/package.json +2 -1
- package/dist/diagnostics-reporter-CsIG85Q5.mjs +0 -38
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
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-
|
|
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-
|
|
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,5 +1,5 @@
|
|
|
1
|
-
import { n as validateDefinitions, r as getRpcHandler, s as hash } from "./validation-
|
|
2
|
-
import { t as diagnostics } from "./diagnostics-
|
|
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 {
|
package/dist/types/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { A as ScopedServerFunctions, B as
|
|
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 {
|
|
5
|
-
|
|
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 };
|
package/dist/utils/events.d.mts
CHANGED
|
@@ -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
|
|
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
|
|
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 {
|
|
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, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
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
|
|
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
|
|
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-
|
|
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-
|
|
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();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./constants.mjs";
|
|
2
|
-
import { t as createRpcWireCodec } from "./wire-codec-
|
|
2
|
+
import { t as createRpcWireCodec } from "./wire-codec-GsoRxIsD.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.
|
|
4
|
+
"version": "0.9.0-beta.9",
|
|
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",
|
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
"./utils/hash": "./dist/utils/hash.mjs",
|
|
52
52
|
"./utils/launch-editor": "./dist/utils/launch-editor.mjs",
|
|
53
53
|
"./utils/nanoid": "./dist/utils/nanoid.mjs",
|
|
54
|
+
"./utils/nostics": "./dist/utils/nostics.mjs",
|
|
54
55
|
"./utils/open": "./dist/utils/open.mjs",
|
|
55
56
|
"./utils/remote-assets": "./dist/utils/remote-assets.mjs",
|
|
56
57
|
"./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 };
|