devframe 0.4.1 → 0.5.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.
- package/README.md +1 -1
- package/dist/adapters/build.d.mts +2 -2
- package/dist/adapters/build.mjs +9 -9
- package/dist/adapters/cli.d.mts +1 -1
- package/dist/adapters/cli.mjs +1 -1
- package/dist/adapters/dev.d.mts +2 -2
- package/dist/adapters/dev.mjs +1 -1
- package/dist/adapters/embedded.d.mts +2 -2
- package/dist/adapters/mcp.d.mts +1 -1
- package/dist/adapters/mcp.mjs +3 -3
- package/dist/client/index.d.mts +28 -28
- package/dist/client/index.mjs +27 -23
- package/dist/constants.d.mts +10 -10
- package/dist/constants.mjs +10 -10
- package/dist/{context-C9oW88gr.d.mts → context-DTRcO_UH.d.mts} +6 -6
- package/dist/{storage-CZVTPKsw.mjs → context-DaKmhhHY.mjs} +48 -3
- package/dist/{dev-C2wjXjGB.mjs → dev-Cv43GfqM.mjs} +5 -5
- package/dist/{devframe-K4IxpM4a.d.mts → devframe-BuR6n9ZD.d.mts} +44 -44
- package/dist/{dump-B1wd4u68.mjs → dump-9lKIJTLh.mjs} +15 -11
- package/dist/helpers/vite.d.mts +1 -1
- package/dist/helpers/vite.mjs +4 -4
- package/dist/{host-h3-Div5Vp8R.mjs → host-h3-Dgpgr1Ul.mjs} +16 -16
- package/dist/{index-CBSBvT9K.d.mts → index-C7M1hnvL.d.mts} +2 -2
- package/dist/{index-BhtRKN7X.d.mts → index-DH2sBIwd.d.mts} +1 -1
- package/dist/index.d.mts +5 -5
- package/dist/node/auth.d.mts +5 -5
- package/dist/node/auth.mjs +1 -1
- package/dist/node/{internal.d.mts → hub-internals.d.mts} +3 -3
- package/dist/node/hub-internals.mjs +3 -0
- package/dist/node/index.d.mts +34 -34
- package/dist/node/index.mjs +4 -4
- package/dist/recipes/open-helpers.d.mts +5 -5
- package/dist/{human-id-Dq-qgtES.mjs → revoke-CL0LSAN9.mjs} +35 -35
- package/dist/rpc/dump.d.mts +1 -1
- package/dist/rpc/dump.mjs +1 -1
- package/dist/rpc/index.d.mts +2 -2
- package/dist/rpc/index.mjs +1 -1
- package/dist/rpc/transports/ws-client.d.mts +1 -1
- package/dist/rpc/transports/ws-client.mjs +1 -1
- package/dist/rpc/transports/ws-server.d.mts +2 -2
- package/dist/{server-BO8IDVsJ.mjs → server-BBaBJaUL.mjs} +12 -5
- package/dist/{server-KzCqriO9.d.mts → server-wHlpcdZ9.d.mts} +3 -3
- package/dist/{shared-state-CasqoUba.mjs → shared-state-BlBNYziY.mjs} +1 -1
- package/dist/types/index.d.mts +4 -4
- package/dist/{types-dNW3UmMl.d.mts → types-BkkQ0Txg.d.mts} +4 -4
- package/dist/utils/events.d.mts +1 -1
- package/dist/utils/shared-state.d.mts +1 -1
- package/dist/utils/streaming-channel.d.mts +1 -1
- package/dist/{ws-client-BZptK_Mf.d.mts → ws-client-CVYX9niP.d.mts} +1 -1
- package/dist/{ws-server-CTeMCO1r.d.mts → ws-server-C1LjmRnp.d.mts} +5 -5
- package/package.json +5 -5
- package/skills/devframe/SKILL.md +82 -5
- package/dist/node/internal.mjs +0 -49
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
[![JSDocs][jsdocs-src]][jsdocs-href]
|
|
7
7
|
[![License][license-src]][license-href]
|
|
8
8
|
|
|
9
|
-
Framework-neutral foundation for building generic
|
|
9
|
+
Framework-neutral foundation for building generic devframes.
|
|
10
10
|
|
|
11
11
|
Documentation: [https://devfra.me/](https://devfra.me/).
|
|
12
12
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as DevframeDefinition } from "../devframe-
|
|
1
|
+
import { r as DevframeDefinition } from "../devframe-BuR6n9ZD.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/adapters/build.d.ts
|
|
4
4
|
interface CreateBuildOptions {
|
|
@@ -30,7 +30,7 @@ interface CreateBuildOptions {
|
|
|
30
30
|
* - When `def.spa` is configured, also write `<outDir>/spa-loader.json`
|
|
31
31
|
* describing the SPA's data-loader mode (`'query'` / `'upload'` /
|
|
32
32
|
* `'none'`). The output is mount-path agnostic — the same bundle
|
|
33
|
-
* works at `/`, `/
|
|
33
|
+
* works at `/`, `/devframe/`, or any base, no rewriting required.
|
|
34
34
|
*/
|
|
35
35
|
declare function createBuild(d: DevframeDefinition, options?: CreateBuildOptions): Promise<void>;
|
|
36
36
|
//#endregion
|
package/dist/adapters/build.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { t as collectStaticRpcDump } from "../dump-
|
|
1
|
+
import { t as collectStaticRpcDump } from "../dump-9lKIJTLh.mjs";
|
|
2
2
|
import { n as colors } from "../diagnostics-reporter-CBBZwoMv.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { DEVFRAME_CONNECTION_META_FILENAME, DEVFRAME_RPC_DUMP_DIRNAME, DEVFRAME_RPC_DUMP_MANIFEST_FILENAME } from "../constants.mjs";
|
|
4
4
|
import { n as strictJsonStringify } from "../serialization-BD_qXGjd.mjs";
|
|
5
5
|
import { n as structuredCloneStringify } from "../structured-clone-jegjz0hM.mjs";
|
|
6
|
-
import { n as createHostContext, t as
|
|
6
|
+
import { n as createHostContext, t as createH3DevframeHost } from "../host-h3-Dgpgr1Ul.mjs";
|
|
7
7
|
import { n as resolveBasePath } from "../_shared-CUFqO4kJ.mjs";
|
|
8
8
|
import { existsSync } from "node:fs";
|
|
9
9
|
import process from "node:process";
|
|
@@ -21,7 +21,7 @@ import fs$1 from "node:fs/promises";
|
|
|
21
21
|
* - When `def.spa` is configured, also write `<outDir>/spa-loader.json`
|
|
22
22
|
* describing the SPA's data-loader mode (`'query'` / `'upload'` /
|
|
23
23
|
* `'none'`). The output is mount-path agnostic — the same bundle
|
|
24
|
-
* works at `/`, `/
|
|
24
|
+
* works at `/`, `/devframe/`, or any base, no rewriting required.
|
|
25
25
|
*/
|
|
26
26
|
async function createBuild(d, options = {}) {
|
|
27
27
|
const outDir = resolve(options.outDir ?? "dist-static");
|
|
@@ -34,20 +34,20 @@ async function createBuild(d, options = {}) {
|
|
|
34
34
|
const ctx = await createHostContext({
|
|
35
35
|
cwd: process.cwd(),
|
|
36
36
|
mode: "build",
|
|
37
|
-
host:
|
|
37
|
+
host: createH3DevframeHost({
|
|
38
38
|
origin: "http://localhost",
|
|
39
39
|
appName: d.id
|
|
40
40
|
})
|
|
41
41
|
});
|
|
42
42
|
await d.setup(ctx);
|
|
43
|
-
await fs$1.mkdir(resolve(outDir,
|
|
43
|
+
await fs$1.mkdir(resolve(outDir, DEVFRAME_RPC_DUMP_DIRNAME), { recursive: true });
|
|
44
44
|
const jsonSerializableMethods = [];
|
|
45
45
|
for (const def of ctx.rpc.definitions.values()) if (def.jsonSerializable === true) jsonSerializableMethods.push(def.name);
|
|
46
|
-
await fs$1.writeFile(resolve(outDir,
|
|
46
|
+
await fs$1.writeFile(resolve(outDir, DEVFRAME_CONNECTION_META_FILENAME), JSON.stringify({
|
|
47
47
|
backend: "static",
|
|
48
48
|
jsonSerializableMethods
|
|
49
49
|
}, null, 2), "utf-8");
|
|
50
|
-
console.log(colors.cyan`[devframe] writing RPC dump to ${resolve(outDir,
|
|
50
|
+
console.log(colors.cyan`[devframe] writing RPC dump to ${resolve(outDir, DEVFRAME_RPC_DUMP_MANIFEST_FILENAME)}`);
|
|
51
51
|
const dump = await collectStaticRpcDump(ctx.rpc.definitions.values(), ctx);
|
|
52
52
|
const indent = options.pretty ? 2 : void 0;
|
|
53
53
|
for (const [filepath, file] of Object.entries(dump.files)) {
|
|
@@ -56,7 +56,7 @@ async function createBuild(d, options = {}) {
|
|
|
56
56
|
const text = file.serialization === "structured-clone" ? structuredCloneStringify(file.data) : strictJsonStringify(file.data, file.fnName);
|
|
57
57
|
await fs$1.writeFile(fullpath, file.serialization === "json" && indent != null ? JSON.stringify(JSON.parse(text), null, indent) : text, "utf-8");
|
|
58
58
|
}
|
|
59
|
-
await fs$1.writeFile(resolve(outDir,
|
|
59
|
+
await fs$1.writeFile(resolve(outDir, DEVFRAME_RPC_DUMP_MANIFEST_FILENAME), JSON.stringify(dump.manifest, null, 2), "utf-8");
|
|
60
60
|
if (d.spa) {
|
|
61
61
|
const base = options.base ?? resolveBasePath(d, "standalone");
|
|
62
62
|
const spaLoader = {
|
package/dist/adapters/cli.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { dt as defineCliFlags, ft as parseCliFlags, lt as CliFlagsSchema, r as DevframeDefinition, ut as InferCliFlags } from "../devframe-
|
|
1
|
+
import { dt as defineCliFlags, ft as parseCliFlags, lt as CliFlagsSchema, r as DevframeDefinition, ut as InferCliFlags } from "../devframe-BuR6n9ZD.mjs";
|
|
2
2
|
import { CAC } from "cac";
|
|
3
3
|
import { H3 } from "h3";
|
|
4
4
|
|
package/dist/adapters/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as colors } from "../diagnostics-reporter-CBBZwoMv.mjs";
|
|
2
2
|
import { createBuild } from "./build.mjs";
|
|
3
|
-
import { n as resolveDevServerPort, t as createDevServer } from "../dev-
|
|
3
|
+
import { n as resolveDevServerPort, t as createDevServer } from "../dev-Cv43GfqM.mjs";
|
|
4
4
|
import process from "node:process";
|
|
5
5
|
import cac from "cac";
|
|
6
6
|
import { safeParse } from "valibot";
|
package/dist/adapters/dev.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as DevframeDefinition } from "../devframe-
|
|
2
|
-
import { n as StartedServer } from "../server-
|
|
1
|
+
import { r as DevframeDefinition } from "../devframe-BuR6n9ZD.mjs";
|
|
2
|
+
import { n as StartedServer } from "../server-wHlpcdZ9.mjs";
|
|
3
3
|
import { H3 } from "h3";
|
|
4
4
|
|
|
5
5
|
//#region src/adapters/dev.d.ts
|
package/dist/adapters/dev.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as resolveDevServerPort, t as createDevServer } from "../dev-
|
|
1
|
+
import { n as resolveDevServerPort, t as createDevServer } from "../dev-Cv43GfqM.mjs";
|
|
2
2
|
export { createDevServer, resolveDevServerPort };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { d as
|
|
1
|
+
import { d as DevframeNodeContext, r as DevframeDefinition } from "../devframe-BuR6n9ZD.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/adapters/embedded.d.ts
|
|
4
4
|
interface CreateEmbeddedOptions {
|
|
5
5
|
/** Target context the devframe is registered into. Required. */
|
|
6
|
-
ctx:
|
|
6
|
+
ctx: DevframeNodeContext;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
9
|
* Register a devframe into an already-running devframe/Kit context at
|
package/dist/adapters/mcp.d.mts
CHANGED
package/dist/adapters/mcp.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as diagnostics } from "../shared-state-
|
|
2
|
-
import { n as createHostContext } from "../host-h3-
|
|
1
|
+
import { i as diagnostics } from "../shared-state-BlBNYziY.mjs";
|
|
2
|
+
import { n as createHostContext } from "../host-h3-Dgpgr1Ul.mjs";
|
|
3
3
|
import { homedir } from "node:os";
|
|
4
4
|
import process from "node:process";
|
|
5
5
|
import { join } from "pathe";
|
|
@@ -195,7 +195,7 @@ async function createMcpServer(definition, options = {}) {
|
|
|
195
195
|
host: {
|
|
196
196
|
mountStatic: () => {},
|
|
197
197
|
resolveOrigin: () => "mcp://devframe",
|
|
198
|
-
getStorageDir: (scope) => scope === "workspace" ? join(process.cwd(), `node_modules/.${definition.id}/
|
|
198
|
+
getStorageDir: (scope) => scope === "workspace" ? join(process.cwd(), `node_modules/.${definition.id}/devframe`) : join(homedir(), `.${definition.id}/devframe`)
|
|
199
199
|
}
|
|
200
200
|
});
|
|
201
201
|
await definition.setup(ctx);
|
package/dist/client/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { T as StreamSink, U as
|
|
2
|
-
import { C as RpcFunctionsCollector } from "../types-
|
|
3
|
-
import { C as RpcCacheManager, w as RpcCacheOptions } from "../index-
|
|
4
|
-
import { t as WsRpcChannelOptions } from "../ws-client-
|
|
1
|
+
import { T as StreamSink, U as DevframeRpcClientFunctions, W as DevframeRpcServerFunctions, g as RpcSharedStateHost, l as ConnectionMeta, ot as EventEmitter, w as StreamReader } from "../devframe-BuR6n9ZD.mjs";
|
|
2
|
+
import { C as RpcFunctionsCollector } from "../types-BkkQ0Txg.mjs";
|
|
3
|
+
import { C as RpcCacheManager, w as RpcCacheOptions } from "../index-C7M1hnvL.mjs";
|
|
4
|
+
import { t as WsRpcChannelOptions } from "../ws-client-CVYX9niP.mjs";
|
|
5
5
|
import { BirpcOptions, BirpcReturn } from "birpc";
|
|
6
6
|
|
|
7
7
|
//#region src/client/rpc-streaming.d.ts
|
|
@@ -32,20 +32,20 @@ interface RpcStreamingClientHost {
|
|
|
32
32
|
* registers the two `:chunk` / `:end` event handlers once, then per-stream
|
|
33
33
|
* state lives in a `Map<streamKey, StreamReader>`.
|
|
34
34
|
*/
|
|
35
|
-
declare function createRpcStreamingClientHost(rpc:
|
|
35
|
+
declare function createRpcStreamingClientHost(rpc: DevframeRpcClient): RpcStreamingClientHost;
|
|
36
36
|
//#endregion
|
|
37
37
|
//#region src/client/rpc.d.ts
|
|
38
|
-
interface
|
|
38
|
+
interface DevframeRpcContext {
|
|
39
39
|
/**
|
|
40
40
|
* The RPC client to interact with the server
|
|
41
41
|
*/
|
|
42
|
-
readonly rpc:
|
|
42
|
+
readonly rpc: DevframeRpcClient;
|
|
43
43
|
}
|
|
44
|
-
type
|
|
44
|
+
type DevframeClientRpcHost = RpcFunctionsCollector<DevframeRpcClientFunctions, DevframeRpcContext>;
|
|
45
45
|
interface RpcClientEvents {
|
|
46
46
|
'rpc:is-trusted:updated': (isTrusted: boolean) => void;
|
|
47
47
|
}
|
|
48
|
-
interface
|
|
48
|
+
interface DevframeRpcClientOptions {
|
|
49
49
|
connectionMeta?: ConnectionMeta;
|
|
50
50
|
baseURL?: string | string[];
|
|
51
51
|
/**
|
|
@@ -53,13 +53,13 @@ interface DevToolsRpcClientOptions {
|
|
|
53
53
|
*/
|
|
54
54
|
authToken?: string;
|
|
55
55
|
wsOptions?: Partial<WsRpcChannelOptions>;
|
|
56
|
-
rpcOptions?: Partial<BirpcOptions<
|
|
56
|
+
rpcOptions?: Partial<BirpcOptions<DevframeRpcServerFunctions, DevframeRpcClientFunctions, boolean>>;
|
|
57
57
|
cacheOptions?: boolean | Partial<RpcCacheOptions>;
|
|
58
58
|
}
|
|
59
|
-
type
|
|
60
|
-
type
|
|
61
|
-
type
|
|
62
|
-
interface
|
|
59
|
+
type DevframeRpcClientCall = BirpcReturn<DevframeRpcServerFunctions, DevframeRpcClientFunctions>['$call'];
|
|
60
|
+
type DevframeRpcClientCallEvent = BirpcReturn<DevframeRpcServerFunctions, DevframeRpcClientFunctions>['$callEvent'];
|
|
61
|
+
type DevframeRpcClientCallOptional = BirpcReturn<DevframeRpcServerFunctions, DevframeRpcClientFunctions>['$callOptional'];
|
|
62
|
+
interface DevframeRpcClient {
|
|
63
63
|
/**
|
|
64
64
|
* The events of the client
|
|
65
65
|
*/
|
|
@@ -92,19 +92,19 @@ interface DevToolsRpcClient {
|
|
|
92
92
|
/**
|
|
93
93
|
* Call a RPC function on the server
|
|
94
94
|
*/
|
|
95
|
-
call:
|
|
95
|
+
call: DevframeRpcClientCall;
|
|
96
96
|
/**
|
|
97
97
|
* Call a RPC event on the server, and does not expect a response
|
|
98
98
|
*/
|
|
99
|
-
callEvent:
|
|
99
|
+
callEvent: DevframeRpcClientCallEvent;
|
|
100
100
|
/**
|
|
101
101
|
* Call a RPC optional function on the server
|
|
102
102
|
*/
|
|
103
|
-
callOptional:
|
|
103
|
+
callOptional: DevframeRpcClientCallOptional;
|
|
104
104
|
/**
|
|
105
105
|
* The client RPC host
|
|
106
106
|
*/
|
|
107
|
-
client:
|
|
107
|
+
client: DevframeClientRpcHost;
|
|
108
108
|
/**
|
|
109
109
|
* The shared state host
|
|
110
110
|
*/
|
|
@@ -120,18 +120,18 @@ interface DevToolsRpcClient {
|
|
|
120
120
|
*/
|
|
121
121
|
cacheManager: RpcCacheManager;
|
|
122
122
|
}
|
|
123
|
-
interface
|
|
123
|
+
interface DevframeRpcClientMode {
|
|
124
124
|
readonly isTrusted: boolean;
|
|
125
|
-
ensureTrusted:
|
|
126
|
-
requestTrust:
|
|
127
|
-
requestTrustWithToken:
|
|
128
|
-
call:
|
|
129
|
-
callEvent:
|
|
130
|
-
callOptional:
|
|
125
|
+
ensureTrusted: DevframeRpcClient['ensureTrusted'];
|
|
126
|
+
requestTrust: DevframeRpcClient['requestTrust'];
|
|
127
|
+
requestTrustWithToken: DevframeRpcClient['requestTrustWithToken'];
|
|
128
|
+
call: DevframeRpcClient['call'];
|
|
129
|
+
callEvent: DevframeRpcClient['callEvent'];
|
|
130
|
+
callOptional: DevframeRpcClient['callOptional'];
|
|
131
131
|
}
|
|
132
|
-
declare function
|
|
132
|
+
declare function getDevframeRpcClient(options?: DevframeRpcClientOptions): Promise<DevframeRpcClient>;
|
|
133
133
|
//#endregion
|
|
134
134
|
//#region src/client/index.d.ts
|
|
135
|
-
declare const connectDevframe: typeof
|
|
135
|
+
declare const connectDevframe: typeof getDevframeRpcClient;
|
|
136
136
|
//#endregion
|
|
137
|
-
export {
|
|
137
|
+
export { DevframeClientRpcHost, DevframeRpcClient, DevframeRpcClientCall, DevframeRpcClientCallEvent, DevframeRpcClientCallOptional, DevframeRpcClientMode, DevframeRpcClientOptions, DevframeRpcContext, RpcClientEvents, RpcStreamingClientHost, StreamingSubscribeOptions, connectDevframe, createRpcStreamingClientHost, getDevframeRpcClient };
|
package/dist/client/index.mjs
CHANGED
|
@@ -10,8 +10,8 @@ import { defineDiagnostics } from "nostics";
|
|
|
10
10
|
import { ansiFormatter } from "nostics/formatters/ansi";
|
|
11
11
|
import { createBirpc } from "birpc";
|
|
12
12
|
//#region src/constants.ts
|
|
13
|
-
const
|
|
14
|
-
const
|
|
13
|
+
const DEVFRAME_CONNECTION_META_FILENAME = "__connection.json";
|
|
14
|
+
const DEVFRAME_RPC_DUMP_MANIFEST_FILENAME = "__rpc-dump/index.json";
|
|
15
15
|
//#endregion
|
|
16
16
|
//#region src/utils/diagnostics-reporter.ts
|
|
17
17
|
const formatAnsi = ansiFormatter(colors);
|
|
@@ -71,14 +71,18 @@ function isPlainErrorShape(value) {
|
|
|
71
71
|
//#endregion
|
|
72
72
|
//#region src/rpc/handler.ts
|
|
73
73
|
async function getRpcResolvedSetupResult(definition, context) {
|
|
74
|
-
if (definition.__resolved) return definition.__resolved;
|
|
75
74
|
if (!definition.setup) return {};
|
|
76
|
-
|
|
77
|
-
definition.
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
75
|
+
if (typeof context === "object" && context !== null) {
|
|
76
|
+
definition.__cache ??= /* @__PURE__ */ new WeakMap();
|
|
77
|
+
let promise = definition.__cache.get(context);
|
|
78
|
+
if (!promise) {
|
|
79
|
+
promise = Promise.resolve(definition.setup(context));
|
|
80
|
+
definition.__cache.set(context, promise);
|
|
81
|
+
}
|
|
82
|
+
return await promise;
|
|
83
|
+
}
|
|
84
|
+
definition.__promise ??= Promise.resolve(definition.setup(context));
|
|
85
|
+
return await definition.__promise;
|
|
82
86
|
}
|
|
83
87
|
async function getRpcHandler(definition, context) {
|
|
84
88
|
if (definition.handler) return definition.handler;
|
|
@@ -378,10 +382,10 @@ function createStaticRpcCaller(manifest, fetchJson) {
|
|
|
378
382
|
return await queryRecordCache.get(path);
|
|
379
383
|
}
|
|
380
384
|
async function call(functionName, args) {
|
|
381
|
-
if (!(functionName in manifest)) throw new Error(`[
|
|
385
|
+
if (!(functionName in manifest)) throw new Error(`[devframe-rpc] Function "${functionName}" not found in dump store`);
|
|
382
386
|
const entry = manifest[functionName];
|
|
383
387
|
if (isStaticEntry(entry)) {
|
|
384
|
-
if (args.length > 0) throw new Error(`[
|
|
388
|
+
if (args.length > 0) throw new Error(`[devframe-rpc] No dump match for "${functionName}" with args: ${JSON.stringify(args)}`);
|
|
385
389
|
return await loadStatic(entry);
|
|
386
390
|
}
|
|
387
391
|
if (isQueryEntry(entry)) {
|
|
@@ -389,10 +393,10 @@ function createStaticRpcCaller(manifest, fetchJson) {
|
|
|
389
393
|
const recordPath = entry.records[argsHash];
|
|
390
394
|
if (recordPath) return resolveRecordOutput(await loadQueryRecord(recordPath, entry.serialization));
|
|
391
395
|
if (entry.fallback) return resolveRecordOutput(await loadQueryRecord(entry.fallback, entry.serialization));
|
|
392
|
-
throw new Error(`[
|
|
396
|
+
throw new Error(`[devframe-rpc] No dump match for "${functionName}" with args: ${JSON.stringify(args)}`);
|
|
393
397
|
}
|
|
394
398
|
if (args.length === 0) return entry;
|
|
395
|
-
throw new Error(`[
|
|
399
|
+
throw new Error(`[devframe-rpc] No dump match for "${functionName}" with args: ${JSON.stringify(args)}`);
|
|
396
400
|
}
|
|
397
401
|
return {
|
|
398
402
|
call: async (functionName, args) => await call(functionName, args),
|
|
@@ -406,7 +410,7 @@ function createStaticRpcCaller(manifest, fetchJson) {
|
|
|
406
410
|
//#endregion
|
|
407
411
|
//#region src/client/rpc-static.ts
|
|
408
412
|
async function createStaticRpcClientMode(options) {
|
|
409
|
-
const staticCaller = createStaticRpcCaller(await options.fetchJsonFromBases(
|
|
413
|
+
const staticCaller = createStaticRpcCaller(await options.fetchJsonFromBases(DEVFRAME_RPC_DUMP_MANIFEST_FILENAME), options.fetchJsonFromBases);
|
|
410
414
|
return {
|
|
411
415
|
isTrusted: true,
|
|
412
416
|
requestTrust: async () => true,
|
|
@@ -539,7 +543,7 @@ const EMPTY_DEFS = /* @__PURE__ */ new Map();
|
|
|
539
543
|
*/
|
|
540
544
|
function createWsRpcChannel(options) {
|
|
541
545
|
let url = options.url;
|
|
542
|
-
if (options.authToken) url = `${url}?
|
|
546
|
+
if (options.authToken) url = `${url}?devframe_auth_token=${encodeURIComponent(options.authToken)}`;
|
|
543
547
|
const ws = new WebSocket(url);
|
|
544
548
|
const { onConnected = NOOP, onError = NOOP, onDisconnected = NOOP, definitions = EMPTY_DEFS } = options;
|
|
545
549
|
ws.addEventListener("open", (e) => {
|
|
@@ -1789,7 +1793,7 @@ function createWsRpcClientMode(options) {
|
|
|
1789
1793
|
info.os.version,
|
|
1790
1794
|
info.device.type
|
|
1791
1795
|
].filter((i) => i).join(" ");
|
|
1792
|
-
const result = await serverRpc.$call("
|
|
1796
|
+
const result = await serverRpc.$call("devframe:anonymous:auth", {
|
|
1793
1797
|
authToken: token,
|
|
1794
1798
|
ua,
|
|
1795
1799
|
origin: location.origin
|
|
@@ -1835,8 +1839,8 @@ function createWsRpcClientMode(options) {
|
|
|
1835
1839
|
}
|
|
1836
1840
|
//#endregion
|
|
1837
1841
|
//#region src/client/rpc.ts
|
|
1838
|
-
const CONNECTION_META_KEY = "
|
|
1839
|
-
const CONNECTION_AUTH_TOKEN_KEY = "
|
|
1842
|
+
const CONNECTION_META_KEY = "__DEVFRAME_CONNECTION_META__";
|
|
1843
|
+
const CONNECTION_AUTH_TOKEN_KEY = "__DEVFRAME_CONNECTION_AUTH_TOKEN__";
|
|
1840
1844
|
function getConnectionAuthTokenFromWindows(userAuthToken) {
|
|
1841
1845
|
const getters = [
|
|
1842
1846
|
() => userAuthToken,
|
|
@@ -1866,7 +1870,7 @@ function findConnectionMetaFromWindows() {
|
|
|
1866
1870
|
if (value) return value;
|
|
1867
1871
|
} catch {}
|
|
1868
1872
|
}
|
|
1869
|
-
async function
|
|
1873
|
+
async function getDevframeRpcClient(options = {}) {
|
|
1870
1874
|
const { baseURL = "./", rpcOptions = {}, cacheOptions = false } = options;
|
|
1871
1875
|
const events = createEventEmitter();
|
|
1872
1876
|
const bases = Array.isArray(baseURL) ? baseURL : [baseURL];
|
|
@@ -1883,7 +1887,7 @@ async function getDevToolsRpcClient(options = {}) {
|
|
|
1883
1887
|
if (!connectionMeta) {
|
|
1884
1888
|
const errors = [];
|
|
1885
1889
|
for (const base of bases) try {
|
|
1886
|
-
connectionMeta = await fetch(resolveBasePath(base,
|
|
1890
|
+
connectionMeta = await fetch(resolveBasePath(base, DEVFRAME_CONNECTION_META_FILENAME)).then((r) => r.json());
|
|
1887
1891
|
resolvedBaseURL = base;
|
|
1888
1892
|
globalThis[CONNECTION_META_KEY] = connectionMeta;
|
|
1889
1893
|
break;
|
|
@@ -1959,7 +1963,7 @@ async function getDevToolsRpcClient(options = {}) {
|
|
|
1959
1963
|
context.rpc = rpc;
|
|
1960
1964
|
mode.requestTrust();
|
|
1961
1965
|
try {
|
|
1962
|
-
const bc = new BroadcastChannel("
|
|
1966
|
+
const bc = new BroadcastChannel("devframe-auth");
|
|
1963
1967
|
bc.onmessage = (event) => {
|
|
1964
1968
|
if (event.data?.type === "auth-update" && event.data.authToken) rpc.requestTrustWithToken(event.data.authToken);
|
|
1965
1969
|
};
|
|
@@ -1968,6 +1972,6 @@ async function getDevToolsRpcClient(options = {}) {
|
|
|
1968
1972
|
}
|
|
1969
1973
|
//#endregion
|
|
1970
1974
|
//#region src/client/index.ts
|
|
1971
|
-
const connectDevframe =
|
|
1975
|
+
const connectDevframe = getDevframeRpcClient;
|
|
1972
1976
|
//#endregion
|
|
1973
|
-
export { connectDevframe, createRpcStreamingClientHost,
|
|
1977
|
+
export { connectDevframe, createRpcStreamingClientHost, getDevframeRpcClient };
|
package/dist/constants.d.mts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
//#region src/constants.d.ts
|
|
2
|
-
declare const
|
|
3
|
-
declare const
|
|
4
|
-
declare const
|
|
5
|
-
declare const
|
|
6
|
-
declare const
|
|
7
|
-
declare const
|
|
8
|
-
declare const
|
|
9
|
-
declare const
|
|
2
|
+
declare const DEVFRAME_MOUNT_PATH = "/__devframe/";
|
|
3
|
+
declare const DEVFRAME_MOUNT_PATH_NO_TRAILING_SLASH = "/__devframe";
|
|
4
|
+
declare const DEVFRAME_DIRNAME = "__devframe";
|
|
5
|
+
declare const DEVFRAME_CONNECTION_META_FILENAME = "__connection.json";
|
|
6
|
+
declare const DEVFRAME_RPC_DUMP_MANIFEST_FILENAME = "__rpc-dump/index.json";
|
|
7
|
+
declare const DEVFRAME_DOCK_IMPORTS_FILENAME = "__client-imports.js";
|
|
8
|
+
declare const DEVFRAME_DOCK_IMPORTS_VIRTUAL_ID = "/__devframe-client-imports.js";
|
|
9
|
+
declare const DEVFRAME_RPC_DUMP_DIRNAME = "__rpc-dump";
|
|
10
10
|
/**
|
|
11
11
|
* URL fragment / query parameter name carrying the remote dock
|
|
12
12
|
* connection descriptor (defined as `RemoteConnectionInfo` in
|
|
13
13
|
* `@vitejs/devtools-kit`) injected into remote-UI iframe dock URLs.
|
|
14
14
|
*/
|
|
15
|
-
declare const REMOTE_CONNECTION_KEY = "
|
|
15
|
+
declare const REMOTE_CONNECTION_KEY = "devframe-remote-connection";
|
|
16
16
|
//#endregion
|
|
17
|
-
export {
|
|
17
|
+
export { DEVFRAME_CONNECTION_META_FILENAME, DEVFRAME_DIRNAME, DEVFRAME_DOCK_IMPORTS_FILENAME, DEVFRAME_DOCK_IMPORTS_VIRTUAL_ID, DEVFRAME_MOUNT_PATH, DEVFRAME_MOUNT_PATH_NO_TRAILING_SLASH, DEVFRAME_RPC_DUMP_DIRNAME, DEVFRAME_RPC_DUMP_MANIFEST_FILENAME, REMOTE_CONNECTION_KEY };
|
package/dist/constants.mjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
//#region src/constants.ts
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
2
|
+
const DEVFRAME_MOUNT_PATH = "/__devframe/";
|
|
3
|
+
const DEVFRAME_MOUNT_PATH_NO_TRAILING_SLASH = "/__devframe";
|
|
4
|
+
const DEVFRAME_DIRNAME = "__devframe";
|
|
5
|
+
const DEVFRAME_CONNECTION_META_FILENAME = "__connection.json";
|
|
6
|
+
const DEVFRAME_RPC_DUMP_MANIFEST_FILENAME = "__rpc-dump/index.json";
|
|
7
|
+
const DEVFRAME_DOCK_IMPORTS_FILENAME = "__client-imports.js";
|
|
8
|
+
const DEVFRAME_DOCK_IMPORTS_VIRTUAL_ID = "/__devframe-client-imports.js";
|
|
9
|
+
const DEVFRAME_RPC_DUMP_DIRNAME = "__rpc-dump";
|
|
10
10
|
/**
|
|
11
11
|
* URL fragment / query parameter name carrying the remote dock
|
|
12
12
|
* connection descriptor (defined as `RemoteConnectionInfo` in
|
|
13
13
|
* `@vitejs/devtools-kit`) injected into remote-UI iframe dock URLs.
|
|
14
14
|
*/
|
|
15
|
-
const REMOTE_CONNECTION_KEY = "
|
|
15
|
+
const REMOTE_CONNECTION_KEY = "devframe-remote-connection";
|
|
16
16
|
//#endregion
|
|
17
|
-
export {
|
|
17
|
+
export { DEVFRAME_CONNECTION_META_FILENAME, DEVFRAME_DIRNAME, DEVFRAME_DOCK_IMPORTS_FILENAME, DEVFRAME_DOCK_IMPORTS_VIRTUAL_ID, DEVFRAME_MOUNT_PATH, DEVFRAME_MOUNT_PATH_NO_TRAILING_SLASH, DEVFRAME_RPC_DUMP_DIRNAME, DEVFRAME_RPC_DUMP_MANIFEST_FILENAME, REMOTE_CONNECTION_KEY };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as SharedState, d as
|
|
1
|
+
import { P as SharedState, d as DevframeNodeContext } from "./devframe-BuR6n9ZD.mjs";
|
|
2
2
|
|
|
3
|
-
//#region src/node/
|
|
3
|
+
//#region src/node/hub-internals/context.d.ts
|
|
4
4
|
interface InternalAnonymousAuthStorage {
|
|
5
5
|
trusted: Record<string, {
|
|
6
6
|
authToken: string;
|
|
@@ -15,7 +15,7 @@ interface RemoteTokenRecord {
|
|
|
15
15
|
origin: string;
|
|
16
16
|
originLock: boolean;
|
|
17
17
|
}
|
|
18
|
-
interface
|
|
18
|
+
interface DevframeInternalContext {
|
|
19
19
|
storage: {
|
|
20
20
|
auth: SharedState<InternalAnonymousAuthStorage>;
|
|
21
21
|
};
|
|
@@ -45,7 +45,7 @@ interface DevToolsInternalContext {
|
|
|
45
45
|
/** Full `ws://` or `wss://` URL with host and port. */url: string;
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
|
-
declare const internalContextMap: WeakMap<
|
|
49
|
-
declare function getInternalContext(context:
|
|
48
|
+
declare const internalContextMap: WeakMap<DevframeNodeContext, DevframeInternalContext>;
|
|
49
|
+
declare function getInternalContext(context: DevframeNodeContext): DevframeInternalContext;
|
|
50
50
|
//#endregion
|
|
51
|
-
export { internalContextMap as a, getInternalContext as i, InternalAnonymousAuthStorage as n, RemoteTokenRecord as r,
|
|
51
|
+
export { internalContextMap as a, getInternalContext as i, InternalAnonymousAuthStorage as n, RemoteTokenRecord as r, DevframeInternalContext as t };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { i as diagnostics, t as createSharedState } from "./shared-state-
|
|
1
|
+
import { i as diagnostics, t as createSharedState } from "./shared-state-BlBNYziY.mjs";
|
|
2
|
+
import { n as revokeAuthToken, r as humanId, t as revokeActiveConnectionsForToken } from "./revoke-CL0LSAN9.mjs";
|
|
2
3
|
import fs from "node:fs";
|
|
3
|
-
import { dirname } from "pathe";
|
|
4
|
+
import { dirname, join } from "pathe";
|
|
4
5
|
//#region ../../node_modules/.pnpm/perfect-debounce@2.1.0/node_modules/perfect-debounce/dist/index.mjs
|
|
5
6
|
const DEBOUNCE_DEFAULTS = { trailing: true };
|
|
6
7
|
/**
|
|
@@ -116,4 +117,48 @@ function createStorage(options) {
|
|
|
116
117
|
return state;
|
|
117
118
|
}
|
|
118
119
|
//#endregion
|
|
119
|
-
|
|
120
|
+
//#region src/node/hub-internals/context.ts
|
|
121
|
+
const internalContextMap = /* @__PURE__ */ new WeakMap();
|
|
122
|
+
function getInternalContext(context) {
|
|
123
|
+
if (!internalContextMap.has(context)) {
|
|
124
|
+
const storage = createStorage({
|
|
125
|
+
filepath: join(context.host.getStorageDir("global"), "auth.json"),
|
|
126
|
+
initialValue: { trusted: {} }
|
|
127
|
+
});
|
|
128
|
+
const remoteTokens = /* @__PURE__ */ new Map();
|
|
129
|
+
function revokeRemoteToken(token) {
|
|
130
|
+
if (!remoteTokens.delete(token)) return;
|
|
131
|
+
revokeActiveConnectionsForToken(context, token);
|
|
132
|
+
}
|
|
133
|
+
const internalContext = {
|
|
134
|
+
storage: { auth: storage },
|
|
135
|
+
revokeAuthToken: (token) => revokeAuthToken(context, storage, token),
|
|
136
|
+
remoteTokens,
|
|
137
|
+
allocateRemoteToken(dockId, origin, originLock) {
|
|
138
|
+
const token = humanId();
|
|
139
|
+
remoteTokens.set(token, {
|
|
140
|
+
dockId,
|
|
141
|
+
origin,
|
|
142
|
+
originLock
|
|
143
|
+
});
|
|
144
|
+
return token;
|
|
145
|
+
},
|
|
146
|
+
revokeRemoteToken,
|
|
147
|
+
revokeRemoteTokensForDock(dockId) {
|
|
148
|
+
const tokensToRevoke = [];
|
|
149
|
+
for (const [token, record] of remoteTokens) if (record.dockId === dockId) tokensToRevoke.push(token);
|
|
150
|
+
for (const token of tokensToRevoke) revokeRemoteToken(token);
|
|
151
|
+
},
|
|
152
|
+
isRemoteTokenTrusted(token, requestOrigin) {
|
|
153
|
+
const record = remoteTokens.get(token);
|
|
154
|
+
if (!record) return false;
|
|
155
|
+
if (!record.originLock) return true;
|
|
156
|
+
return !!requestOrigin && record.origin === requestOrigin;
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
internalContextMap.set(context, internalContext);
|
|
160
|
+
}
|
|
161
|
+
return internalContextMap.get(context);
|
|
162
|
+
}
|
|
163
|
+
//#endregion
|
|
164
|
+
export { internalContextMap as n, createStorage as r, getInternalContext as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as createHostContext, t as
|
|
3
|
-
import { t as startHttpAndWs } from "./server-
|
|
1
|
+
import { DEVFRAME_CONNECTION_META_FILENAME } from "./constants.mjs";
|
|
2
|
+
import { n as createHostContext, t as createH3DevframeHost } from "./host-h3-Dgpgr1Ul.mjs";
|
|
3
|
+
import { t as startHttpAndWs } from "./server-BBaBJaUL.mjs";
|
|
4
4
|
import { n as resolveBasePath, t as normalizeBasePath } from "./_shared-CUFqO4kJ.mjs";
|
|
5
5
|
import { t as open } from "./open-DiQn6zCH.mjs";
|
|
6
6
|
import { mountStaticHandler } from "./utils/serve-static.mjs";
|
|
@@ -269,7 +269,7 @@ async function createDevServer(def, options = {}) {
|
|
|
269
269
|
const flags = options.flags ?? {};
|
|
270
270
|
const basePath = options.basePath ? normalizeBasePath(options.basePath) : resolveBasePath(def, "standalone");
|
|
271
271
|
const app = options.app ?? new H3();
|
|
272
|
-
const h3Host =
|
|
272
|
+
const h3Host = createH3DevframeHost({
|
|
273
273
|
origin: `http://${host}:${port}`,
|
|
274
274
|
appName: def.id,
|
|
275
275
|
mount: (base, dir) => {
|
|
@@ -283,7 +283,7 @@ async function createDevServer(def, options = {}) {
|
|
|
283
283
|
});
|
|
284
284
|
const setupInfo = { flags };
|
|
285
285
|
await def.setup(ctx, setupInfo);
|
|
286
|
-
const connectionMetaPath = `${basePath}${
|
|
286
|
+
const connectionMetaPath = `${basePath}${DEVFRAME_CONNECTION_META_FILENAME}`;
|
|
287
287
|
app.use(connectionMetaPath, () => ({
|
|
288
288
|
backend: "websocket",
|
|
289
289
|
websocket: port
|