devframe 0.1.21 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -18
- package/dist/{_shared-iZy45oG3.mjs → _shared-BrKv3CYt.mjs} +5 -5
- package/dist/adapters/build.d.mts +5 -5
- package/dist/adapters/build.mjs +13 -12
- package/dist/adapters/cli.d.mts +4 -4
- package/dist/adapters/cli.mjs +5 -5
- package/dist/adapters/dev.d.mts +21 -12
- package/dist/adapters/dev.mjs +1 -1
- package/dist/adapters/embedded.d.mts +5 -5
- package/dist/adapters/embedded.mjs +2 -2
- package/dist/adapters/mcp.d.mts +3 -3
- package/dist/adapters/mcp.mjs +5 -5
- package/dist/chunk-e9Ob2GDo.mjs +26 -0
- package/dist/client/index.d.mts +8 -5
- package/dist/client/index.mjs +12 -12
- package/dist/colors-DS7k8ljB.mjs +123 -0
- package/dist/{context-BJ4r2SmR.mjs → context-BBi2IQDm.mjs} +19 -37
- package/dist/{context-internal-saIAfNVw.d.mts → context-DRa0wGsC.d.mts} +2 -2
- package/dist/{dev-CdAy400a.mjs → dev-CewNNE2R.mjs} +24 -28
- package/dist/{devtool-CNvLs2_Y.d.mts → devframe-R5Ex5K5L.d.mts} +41 -66
- package/dist/{diagnostics-DxPnRoXO.mjs → diagnostics-Cg9ycFIM.mjs} +7 -2
- package/dist/hash-CIBte1yS.mjs +263 -0
- package/dist/helpers/vite.d.mts +65 -0
- package/dist/helpers/vite.mjs +94 -0
- package/dist/{human-id-BLoGo_e5.mjs → human-id-adtUWQLr.mjs} +12 -3
- package/dist/{index-CuLRIMto.d.mts → index-DB2Ie0Or.d.mts} +2 -3
- package/dist/index.d.mts +4 -5
- package/dist/index.mjs +2 -5
- package/dist/launch-editor-CX_n_0SS.mjs +581 -0
- package/dist/node/auth.d.mts +44 -0
- package/dist/node/auth.mjs +55 -0
- package/dist/node/index.d.mts +13 -55
- package/dist/node/index.mjs +6 -62
- package/dist/node/internal.d.mts +16 -0
- package/dist/node/internal.mjs +50 -0
- package/dist/{open-Dede_w9r.mjs → open-B2ah1IKK.mjs} +38 -24
- package/dist/recipes/open-helpers.d.mts +4 -9
- package/dist/recipes/open-helpers.mjs +7 -12
- package/dist/revoke-DIMz1r7-.mjs +35 -0
- package/dist/rpc/index.d.mts +3 -3
- package/dist/rpc/index.mjs +4 -4
- package/dist/rpc/transports/ws-client.d.mts +1 -1
- package/dist/rpc/transports/ws-client.mjs +2 -1
- package/dist/rpc/transports/ws-server.d.mts +1 -1
- package/dist/rpc/transports/ws-server.mjs +2 -1
- package/dist/{rpc-INbWfHoX.mjs → rpc-DAzoVCR0.mjs} +5 -4
- package/dist/{serialization-DwKi05Pn.mjs → serialization-CwO31axa.mjs} +1 -2
- package/dist/{server-CBsxXIH5.mjs → server-DOk4grlJ.mjs} +4 -4
- package/dist/{server-BAqOajx_.d.mts → server-DzKz023G.d.mts} +8 -7
- package/dist/shared-state-q9-1EOSX.mjs +928 -0
- package/dist/{static-dump-D5VH8Iqk.mjs → static-dump-C67bCuse.mjs} +1 -1
- package/dist/{context-internal-Dx_NoSv1.mjs → storage-CNvfBGQ5.mjs} +5 -87
- package/dist/structured-clone-CD2l4fI3.mjs +221 -0
- package/dist/types/index.d.mts +4 -4
- package/dist/types/index.mjs +3 -3
- package/dist/utils/colors.d.mts +28 -0
- package/dist/utils/colors.mjs +2 -0
- package/dist/utils/events.d.mts +1 -1
- package/dist/utils/hash.d.mts +7 -0
- package/dist/utils/hash.mjs +2 -0
- package/dist/utils/human-id.d.mts +6 -8
- package/dist/utils/human-id.mjs +1 -2
- package/dist/utils/launch-editor.d.mts +13 -0
- package/dist/utils/launch-editor.mjs +2 -0
- package/dist/utils/open.d.mts +16 -0
- package/dist/utils/open.mjs +2 -0
- package/dist/utils/serve-static.d.mts +40 -0
- package/dist/utils/serve-static.mjs +173 -0
- package/dist/utils/shared-state.d.mts +1 -1
- package/dist/utils/shared-state.mjs +1 -35
- package/dist/utils/streaming-channel.d.mts +1 -1
- package/dist/utils/structured-clone.d.mts +21 -0
- package/dist/utils/structured-clone.mjs +2 -0
- package/dist/utils/when.d.mts +33 -50
- package/dist/utils/when.mjs +21 -3
- package/dist/{ws-client-CjPuPFbA.d.mts → ws-client-Bavoya6-.d.mts} +1 -1
- package/dist/{ws-server-C7LnhOHi.d.mts → ws-server-DjvlwLuM.d.mts} +1 -1
- package/package.json +38 -18
- package/skills/devframe/SKILL.md +64 -39
- package/skills/devframe/templates/{counter-devtool.ts → counter-devframe.ts} +4 -4
- package/skills/devframe/templates/{spa-devtool.ts → spa-devframe.ts} +5 -5
- package/skills/devframe/templates/vite-client.ts +2 -2
- package/dist/adapters/vite.d.mts +0 -33
- package/dist/adapters/vite.mjs +0 -32
- package/dist/internal/index.d.mts +0 -16
- package/dist/internal/index.mjs +0 -3
- package/dist/utils/state.d.mts +0 -50
- package/dist/utils/state.mjs +0 -26
- package/dist/{define-Bb4zh-Dc.mjs → define-CW9gLnyG.mjs} +0 -0
- package/dist/{host-h3-9jeHcltx.mjs → host-h3-Dz8YnFgu.mjs} +1 -1
- /package/dist/{transports-DSV5_5QM.mjs → transports-BnCs4rj9.mjs} +0 -0
- /package/dist/{types-C5OVe4AC.d.mts → types-4rdUEi2R.d.mts} +0 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { r as __toESM, t as __commonJSMin } from "./chunk-e9Ob2GDo.mjs";
|
|
2
|
+
//#endregion
|
|
3
|
+
//#region ../../node_modules/.pnpm/ansis@4.3.0/node_modules/ansis/index.mjs
|
|
4
|
+
var import_ansis = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
5
|
+
let e, r, { defineProperty: t, setPrototypeOf: n, create: l, keys: o } = Object, i = "", { round: s, max: f } = Math, u = (e) => {
|
|
6
|
+
let r = /([a-f\d]{3,6})/i.exec(e)?.[1], t = r?.length, n = parseInt(6 ^ t ? 3 ^ t ? "0" : r[0] + r[0] + r[1] + r[1] + r[2] + r[2] : r, 16);
|
|
7
|
+
return [
|
|
8
|
+
n >> 16 & 255,
|
|
9
|
+
n >> 8 & 255,
|
|
10
|
+
255 & n
|
|
11
|
+
];
|
|
12
|
+
}, a = (e, r, t) => e ^ r || r ^ t ? 16 + 36 * s(e / 51) + 6 * s(r / 51) + s(t / 51) : 8 > e ? 16 : e > 248 ? 231 : s(24 * (e - 8) / 247) + 232, c = (e) => {
|
|
13
|
+
let r, t, n, l, o;
|
|
14
|
+
return 8 > e ? 30 + e : 16 > e ? 82 + e : (232 > e ? (o = (e -= 16) % 36, r = (e / 36 | 0) / 5, t = (o / 6 | 0) / 5, n = o % 6 / 5) : r = t = n = (10 * (e - 232) + 8) / 255, l = 2 * f(r, t, n), l ? 30 + (s(n) << 2 | s(t) << 1 | s(r)) + (2 ^ l ? 0 : 60) : 30);
|
|
15
|
+
}, g = {
|
|
16
|
+
open: i,
|
|
17
|
+
close: i
|
|
18
|
+
}, b = 39, d = 49, p = {}, $ = ({ p: e }, { open: t = "", close: l = "", f: o }) => {
|
|
19
|
+
let s = (e, ...r) => {
|
|
20
|
+
if (!e) {
|
|
21
|
+
if (t && t === l) return t;
|
|
22
|
+
if ((e ?? i) === i) return i;
|
|
23
|
+
}
|
|
24
|
+
let n, f = s.p, u = f.o, a = f.c, c = o ? o(e, ...r) : e.raw ? String.raw({ raw: e }, ...r) : i + e;
|
|
25
|
+
if (c.includes("\x1B")) for (; f; f = f.p) {
|
|
26
|
+
let { t: e, l: r } = f, t = r.length, l = i, o = 0;
|
|
27
|
+
if (t) for (; ~(n = c.indexOf(r, o)); o = n + t) l += c.slice(o, n) + e;
|
|
28
|
+
c = l + c.slice(o);
|
|
29
|
+
}
|
|
30
|
+
return u + (c.includes("\n") ? c.replace(/(\r?\n)/g, a + "$1" + u) : c) + a;
|
|
31
|
+
}, f = t, u = l;
|
|
32
|
+
return e && (f = e.o + t, u = l + e.c), n(s, r), s.p = {
|
|
33
|
+
t,
|
|
34
|
+
l,
|
|
35
|
+
o: s.open = f,
|
|
36
|
+
c: s.close = u,
|
|
37
|
+
p: e
|
|
38
|
+
}, s;
|
|
39
|
+
};
|
|
40
|
+
const h = new function s(f = globalThis) {
|
|
41
|
+
let h, y, m = "number" == typeof f ? f : ((r) => {
|
|
42
|
+
let t = r.process ?? {}, n = t.argv ?? [], l = t.env ?? {}, i = 0;
|
|
43
|
+
try {
|
|
44
|
+
i = ((r, t, n) => (e = t.TERM, {
|
|
45
|
+
"24bit": 3,
|
|
46
|
+
truecolor: 3,
|
|
47
|
+
ansi256: 2,
|
|
48
|
+
ansi: 1
|
|
49
|
+
}[t.COLORTERM] || (t.CI ? /,GITHUB/.test(n) ? 3 : 1 : (t.PM2_HOME || /edge/.test(t.NEXT_RUNTIME) || r.stdout?.isTTY) && "dumb" !== e ? "win32" === r.platform ? 3 : /-256/.test(e) ? 2 : 1 : 0)))(t, l, "," + o(l).join(","));
|
|
50
|
+
} catch (e) {
|
|
51
|
+
l = {};
|
|
52
|
+
}
|
|
53
|
+
let s, f = i || 1, u = "FORCE_COLOR", a = {
|
|
54
|
+
false: 0,
|
|
55
|
+
0: 0,
|
|
56
|
+
1: 1,
|
|
57
|
+
2: 2,
|
|
58
|
+
3: 3
|
|
59
|
+
}[l[u]] ?? f, c = -1;
|
|
60
|
+
for (s of n) /^--color=?(true|always)?$/.test(s) && (c = f), /^--(no-color|color=(false|never))$/.test(s) && (c = 0);
|
|
61
|
+
return r.window?.chrome ? 3 : u in l ? a : ~c ? c : l.NO_COLOR ? 0 : i;
|
|
62
|
+
})(f), w = {
|
|
63
|
+
Ansis: s,
|
|
64
|
+
level: m,
|
|
65
|
+
isSupported: () => v,
|
|
66
|
+
strip: (e) => e.replace(/[][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, i),
|
|
67
|
+
extend(e) {
|
|
68
|
+
for (let r in e) {
|
|
69
|
+
let t = e[r], n = (typeof t)[0];
|
|
70
|
+
"s" === n && (O(B(r), I(...u(t))), t = H(...u(t))), O(r, t, "f" === n);
|
|
71
|
+
}
|
|
72
|
+
return n(w, r = l({}, p)), w;
|
|
73
|
+
}
|
|
74
|
+
}, O = (e, r, n) => {
|
|
75
|
+
p[e] = { get() {
|
|
76
|
+
let l = n ? (...e) => $(this, r(...e)) : $(this, r);
|
|
77
|
+
return t(this, e, { value: l }), l;
|
|
78
|
+
} };
|
|
79
|
+
}, v = m > 0, _ = (e, r) => v ? {
|
|
80
|
+
open: `[${e}m`,
|
|
81
|
+
close: `[${r}m`
|
|
82
|
+
} : g, k = (e) => (r) => e(...u(r)), x = (e, r) => (t, n, l) => _(`${e}8;2;${t};${n};${l}`, r), R = (e) => (r, t, n) => e(a(r, t, n)), A = (e, r) => (t, n, l) => _(c(a(t, n, l)) + e, r), B = (e) => "bg" + e[0].toUpperCase() + e.slice(1), C = "Bright", H = x(3, b), I = x(4, d), P = (e) => _("38;5;" + e, b), S = (e) => _("48;5;" + e, d);
|
|
83
|
+
return 2 === m ? (H = R(P), I = R(S)) : 1 === m && (H = A(0, b), I = A(10, d), P = (e) => _(c(e), b), S = (e) => _(c(e) + 10, d)), y = {
|
|
84
|
+
fg: P,
|
|
85
|
+
bg: S,
|
|
86
|
+
rgb: H,
|
|
87
|
+
bgRgb: I,
|
|
88
|
+
hex: k(H),
|
|
89
|
+
bgHex: k(I),
|
|
90
|
+
visible: g,
|
|
91
|
+
reset: _(0, 0),
|
|
92
|
+
bold: _(1, 22),
|
|
93
|
+
dim: _(2, 22),
|
|
94
|
+
italic: _(3, 23),
|
|
95
|
+
underline: _(4, 24),
|
|
96
|
+
inverse: _(7, 27),
|
|
97
|
+
hidden: _(8, 28),
|
|
98
|
+
strikethrough: _(9, 29),
|
|
99
|
+
link: { f: (e, r = e) => v ? `]8;;${e}${r}]8;;` : r != e ? `${r} (${e})` : e }
|
|
100
|
+
}, "gray,black,red,green,yellow,blue,magenta,cyan,white".split(",").map(((e, r) => {
|
|
101
|
+
h = B(e), r ? (y[e + C] = _(89 + r, b), y[h + C] = _(99 + r, d)) : r = 61, y[e] = _(29 + r, b), y[h] = _(39 + r, d);
|
|
102
|
+
})), w.extend(y);
|
|
103
|
+
}();
|
|
104
|
+
module.exports = h.default = h;
|
|
105
|
+
})))(), 1);
|
|
106
|
+
var ansis_default = import_ansis.default;
|
|
107
|
+
const { Ansis, fg, bg, rgb, bgRgb, hex, bgHex, reset, inverse, hidden, visible, link, bold, dim, italic, underline, strikethrough, black, red, green, yellow, blue, magenta, cyan, white, gray, redBright, greenBright, yellowBright, blueBright, magentaBright, cyanBright, whiteBright, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, bgGray, bgRedBright, bgGreenBright, bgYellowBright, bgBlueBright, bgMagentaBright, bgCyanBright, bgWhiteBright } = import_ansis.default;
|
|
108
|
+
//#endregion
|
|
109
|
+
//#region src/utils/colors.ts
|
|
110
|
+
const colors = {
|
|
111
|
+
blue: ansis_default.blue,
|
|
112
|
+
cyan: ansis_default.cyan,
|
|
113
|
+
gray: ansis_default.gray,
|
|
114
|
+
green: ansis_default.green,
|
|
115
|
+
red: ansis_default.red,
|
|
116
|
+
yellow: ansis_default.yellow,
|
|
117
|
+
bold: ansis_default.bold,
|
|
118
|
+
dim: ansis_default.dim,
|
|
119
|
+
reset: ansis_default.reset,
|
|
120
|
+
underline: ansis_default.underline
|
|
121
|
+
};
|
|
122
|
+
//#endregion
|
|
123
|
+
export { colors as t };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { o as RpcFunctionsCollectorBase } from "./rpc-
|
|
2
|
-
import {
|
|
1
|
+
import { o as RpcFunctionsCollectorBase } from "./rpc-DAzoVCR0.mjs";
|
|
2
|
+
import { r as diagnostics } from "./serialization-CwO31axa.mjs";
|
|
3
3
|
import { defineRpcFunction } from "./index.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { t as colors$1 } from "./colors-DS7k8ljB.mjs";
|
|
5
|
+
import { n as logger, t as diagnostics$1 } from "./diagnostics-Cg9ycFIM.mjs";
|
|
5
6
|
import { createEventEmitter } from "./utils/events.mjs";
|
|
6
|
-
import { createSharedState } from "./
|
|
7
|
+
import { t as createSharedState } from "./shared-state-q9-1EOSX.mjs";
|
|
7
8
|
import { createStreamReader, createStreamSink } from "./utils/streaming-channel.mjs";
|
|
8
9
|
import { consoleReporter, createLogger, defineDiagnostics } from "logs-sdk";
|
|
9
|
-
import c from "ansis";
|
|
10
10
|
import { ansiFormatter } from "logs-sdk/formatters/ansi";
|
|
11
11
|
import { isatty } from "node:tty";
|
|
12
12
|
import { formatWithOptions, inspect } from "node:util";
|
|
@@ -14,13 +14,14 @@ import { existsSync } from "node:fs";
|
|
|
14
14
|
//#region src/node/host-agent.ts
|
|
15
15
|
/**
|
|
16
16
|
* Framework-neutral host aggregating the agent-exposed surface of a
|
|
17
|
-
*
|
|
17
|
+
* devframe. Auto-discovers RPC functions with an `agent` field from
|
|
18
18
|
* `ctx.rpc.definitions`, and accepts plugin-registered tools /
|
|
19
19
|
* resources via `registerTool` / `registerResource`.
|
|
20
20
|
*
|
|
21
21
|
* @experimental
|
|
22
22
|
*/
|
|
23
23
|
var DevToolsAgentHost = class {
|
|
24
|
+
context;
|
|
24
25
|
events = createEventEmitter();
|
|
25
26
|
tools = /* @__PURE__ */ new Map();
|
|
26
27
|
resources = /* @__PURE__ */ new Map();
|
|
@@ -185,6 +186,7 @@ function hasPositionalKeys(obj) {
|
|
|
185
186
|
//#endregion
|
|
186
187
|
//#region src/node/host-diagnostics.ts
|
|
187
188
|
var DevToolsDiagnosticsHost = class {
|
|
189
|
+
context;
|
|
188
190
|
_definitions = [];
|
|
189
191
|
_logger;
|
|
190
192
|
defineDiagnostics = defineDiagnostics;
|
|
@@ -204,13 +206,13 @@ var DevToolsDiagnosticsHost = class {
|
|
|
204
206
|
_rebuild() {
|
|
205
207
|
this._logger = createLogger({
|
|
206
208
|
diagnostics: this._definitions,
|
|
207
|
-
formatter: ansiFormatter(
|
|
209
|
+
formatter: ansiFormatter(colors$1),
|
|
208
210
|
reporters: consoleReporter
|
|
209
211
|
});
|
|
210
212
|
}
|
|
211
213
|
};
|
|
212
214
|
//#endregion
|
|
213
|
-
//#region
|
|
215
|
+
//#region ../../node_modules/.pnpm/obug@2.1.1/node_modules/obug/dist/core.js
|
|
214
216
|
function coerce(value) {
|
|
215
217
|
if (value instanceof Error) return value.stack || value.message;
|
|
216
218
|
return value;
|
|
@@ -323,7 +325,7 @@ function enabled(name) {
|
|
|
323
325
|
return false;
|
|
324
326
|
}
|
|
325
327
|
//#endregion
|
|
326
|
-
//#region
|
|
328
|
+
//#region ../../node_modules/.pnpm/obug@2.1.1/node_modules/obug/dist/node.js
|
|
327
329
|
const colors = process.stderr.getColorDepth && process.stderr.getColorDepth() > 2 ? [
|
|
328
330
|
20,
|
|
329
331
|
21,
|
|
@@ -921,6 +923,7 @@ var RpcFunctionsHost = class extends RpcFunctionsCollectorBase {
|
|
|
921
923
|
//#endregion
|
|
922
924
|
//#region src/node/host-views.ts
|
|
923
925
|
var DevToolsViewHost = class {
|
|
926
|
+
context;
|
|
924
927
|
/**
|
|
925
928
|
* @internal
|
|
926
929
|
*/
|
|
@@ -996,13 +999,12 @@ const BUILTIN_AGENT_RPC = [
|
|
|
996
999
|
//#endregion
|
|
997
1000
|
//#region src/node/context.ts
|
|
998
1001
|
/**
|
|
999
|
-
* Framework-
|
|
1000
|
-
* host, view (HTTP file-serving) host, diagnostics, and
|
|
1001
|
-
* subsystems
|
|
1002
|
-
*
|
|
1003
|
-
*
|
|
1004
|
-
*
|
|
1005
|
-
* hub.
|
|
1002
|
+
* Framework- and build-tool-agnostic core of the DevTools node context.
|
|
1003
|
+
* Wires the RPC host, view (HTTP file-serving) host, diagnostics, and
|
|
1004
|
+
* agent subsystems. Host adapters can wrap this to augment `ctx` with
|
|
1005
|
+
* extra surfaces — for example, `@vitejs/devtools-kit`'s
|
|
1006
|
+
* `createKitContext` attaches `docks`, `terminals`, `messages`,
|
|
1007
|
+
* `commands`, and `createJsonRenderer` when mounted into Vite DevTools.
|
|
1006
1008
|
*/
|
|
1007
1009
|
async function createHostContext(options) {
|
|
1008
1010
|
const { cwd, workspaceRoot = cwd, mode, host, builtinRpcDeclarations = [] } = options;
|
|
@@ -1014,8 +1016,7 @@ async function createHostContext(options) {
|
|
|
1014
1016
|
rpc: void 0,
|
|
1015
1017
|
views: void 0,
|
|
1016
1018
|
diagnostics: void 0,
|
|
1017
|
-
agent: void 0
|
|
1018
|
-
createJsonRenderer: void 0
|
|
1019
|
+
agent: void 0
|
|
1019
1020
|
};
|
|
1020
1021
|
const rpcHost = new RpcFunctionsHost(context);
|
|
1021
1022
|
const viewsHost = new DevToolsViewHost(context);
|
|
@@ -1024,25 +1025,6 @@ async function createHostContext(options) {
|
|
|
1024
1025
|
context.views = viewsHost;
|
|
1025
1026
|
context.diagnostics = diagnosticsHost;
|
|
1026
1027
|
context.agent = new DevToolsAgentHost(context);
|
|
1027
|
-
let jrCounter = 0;
|
|
1028
|
-
context.createJsonRenderer = (initialSpec) => {
|
|
1029
|
-
const stateKey = `devframe:json-render:${jrCounter++}`;
|
|
1030
|
-
const statePromise = rpcHost.sharedState.get(stateKey, { initialValue: initialSpec });
|
|
1031
|
-
return {
|
|
1032
|
-
_stateKey: stateKey,
|
|
1033
|
-
async updateSpec(spec) {
|
|
1034
|
-
(await statePromise).mutate(() => spec);
|
|
1035
|
-
},
|
|
1036
|
-
async updateState(newState) {
|
|
1037
|
-
(await statePromise).mutate((draft) => {
|
|
1038
|
-
draft.state = {
|
|
1039
|
-
...draft.state,
|
|
1040
|
-
...newState
|
|
1041
|
-
};
|
|
1042
|
-
});
|
|
1043
|
-
}
|
|
1044
|
-
};
|
|
1045
|
-
};
|
|
1046
1028
|
for (const fn of BUILTIN_AGENT_RPC) rpcHost.register(fn);
|
|
1047
1029
|
for (const fn of builtinRpcDeclarations) rpcHost.register(fn);
|
|
1048
1030
|
return context;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as SharedState, d as DevToolsNodeContext } from "./
|
|
1
|
+
import { P as SharedState, d as DevToolsNodeContext } from "./devframe-R5Ex5K5L.mjs";
|
|
2
2
|
|
|
3
|
-
//#region src/node/context
|
|
3
|
+
//#region src/node/internal/context.d.ts
|
|
4
4
|
interface InternalAnonymousAuthStorage {
|
|
5
5
|
trusted: Record<string, {
|
|
6
6
|
authToken: string;
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { t as createHostContext } from "./context-
|
|
2
|
-
import { t as createH3DevToolsHost } from "./host-h3-
|
|
3
|
-
import { t as startHttpAndWs } from "./server-
|
|
1
|
+
import { t as createHostContext } from "./context-BBi2IQDm.mjs";
|
|
2
|
+
import { t as createH3DevToolsHost } from "./host-h3-Dz8YnFgu.mjs";
|
|
3
|
+
import { t as startHttpAndWs } from "./server-DOk4grlJ.mjs";
|
|
4
4
|
import { DEVTOOLS_CONNECTION_META_FILENAME } from "./constants.mjs";
|
|
5
|
-
import { n as resolveBasePath, t as normalizeBasePath } from "./_shared-
|
|
6
|
-
import {
|
|
5
|
+
import { n as resolveBasePath, t as normalizeBasePath } from "./_shared-BrKv3CYt.mjs";
|
|
6
|
+
import { t as open } from "./open-B2ah1IKK.mjs";
|
|
7
|
+
import { mountStaticHandler } from "./utils/serve-static.mjs";
|
|
7
8
|
import { networkInterfaces } from "node:os";
|
|
8
9
|
import process$1 from "node:process";
|
|
9
|
-
import {
|
|
10
|
+
import { resolve } from "pathe";
|
|
11
|
+
import { H3 } from "h3";
|
|
10
12
|
import { createServer } from "node:net";
|
|
11
|
-
|
|
12
|
-
//#region ../../../node_modules/.pnpm/get-port-please@3.2.0/node_modules/get-port-please/dist/index.mjs
|
|
13
|
+
//#region ../../node_modules/.pnpm/get-port-please@3.2.0/node_modules/get-port-please/dist/index.mjs
|
|
13
14
|
const unsafePorts = /* @__PURE__ */ new Set([
|
|
14
15
|
1,
|
|
15
16
|
7,
|
|
@@ -245,9 +246,15 @@ async function resolveDevServerPort(def, options = {}) {
|
|
|
245
246
|
return getPort(portOptions);
|
|
246
247
|
}
|
|
247
248
|
/**
|
|
248
|
-
* Start a devframe dev server for a {@link
|
|
249
|
-
* h3 + WebSocket RPC + the author's SPA mounted at the
|
|
250
|
-
* path.
|
|
249
|
+
* Start a devframe dev server for a {@link DevframeDefinition} —
|
|
250
|
+
* h3 + WebSocket RPC + (optionally) the author's SPA mounted at the
|
|
251
|
+
* resolved base path.
|
|
252
|
+
*
|
|
253
|
+
* When `distDir` is omitted (and `def.cli?.distDir` is unset) the
|
|
254
|
+
* server runs in **bridge mode**: only `__connection.json` and the WS
|
|
255
|
+
* endpoint are mounted, with no SPA mount. The SPA is expected to be
|
|
256
|
+
* hosted elsewhere (e.g. by a parent Vite/Nuxt dev server) — see
|
|
257
|
+
* `viteDevBridge({ devMiddleware })`.
|
|
251
258
|
*
|
|
252
259
|
* Returns the underlying {@link StartedServer} handle so callers can
|
|
253
260
|
* close it gracefully (SIGINT, hot-reload, test teardown).
|
|
@@ -258,20 +265,16 @@ async function resolveDevServerPort(def, options = {}) {
|
|
|
258
265
|
*/
|
|
259
266
|
async function createDevServer(def, options = {}) {
|
|
260
267
|
const distDir = options.distDir ?? def.cli?.distDir;
|
|
261
|
-
if (!distDir) throw new Error(`[devframe] createDevServer: no distDir for "${def.id}". Set \`cli.distDir\` on the definition or pass it as an option.`);
|
|
262
268
|
const host = options.host ?? def.cli?.host ?? "localhost";
|
|
263
269
|
const port = options.port ?? await resolveDevServerPort(def, { host });
|
|
264
270
|
const flags = options.flags ?? {};
|
|
265
271
|
const basePath = options.basePath ? normalizeBasePath(options.basePath) : resolveBasePath(def, "standalone");
|
|
266
|
-
const app = options.app ??
|
|
272
|
+
const app = options.app ?? new H3();
|
|
267
273
|
const h3Host = createH3DevToolsHost({
|
|
268
274
|
origin: `http://${host}:${port}`,
|
|
269
275
|
appName: def.id,
|
|
270
276
|
mount: (base, dir) => {
|
|
271
|
-
app
|
|
272
|
-
dev: true,
|
|
273
|
-
single: true
|
|
274
|
-
})));
|
|
277
|
+
mountStaticHandler(app, base, dir);
|
|
275
278
|
}
|
|
276
279
|
});
|
|
277
280
|
const ctx = await createHostContext({
|
|
@@ -282,17 +285,11 @@ async function createDevServer(def, options = {}) {
|
|
|
282
285
|
const setupInfo = { flags };
|
|
283
286
|
await def.setup(ctx, setupInfo);
|
|
284
287
|
const connectionMetaPath = `${basePath}${DEVTOOLS_CONNECTION_META_FILENAME}`;
|
|
285
|
-
app.use(connectionMetaPath,
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
backend: "websocket",
|
|
289
|
-
websocket: port
|
|
290
|
-
}));
|
|
288
|
+
app.use(connectionMetaPath, () => ({
|
|
289
|
+
backend: "websocket",
|
|
290
|
+
websocket: port
|
|
291
291
|
}));
|
|
292
|
-
app
|
|
293
|
-
dev: true,
|
|
294
|
-
single: true
|
|
295
|
-
})));
|
|
292
|
+
if (distDir) mountStaticHandler(app, basePath, resolve(distDir));
|
|
296
293
|
return startHttpAndWs({
|
|
297
294
|
context: ctx,
|
|
298
295
|
host,
|
|
@@ -312,7 +309,6 @@ async function maybeOpenBrowser(def, flags, origin, override) {
|
|
|
312
309
|
if (resolved === void 0 || resolved === false) return;
|
|
313
310
|
const target = typeof resolved === "string" ? resolveOpenTarget(origin, resolved) : origin;
|
|
314
311
|
try {
|
|
315
|
-
const { default: open } = await import("./open-Dede_w9r.mjs");
|
|
316
312
|
await open(target);
|
|
317
313
|
} catch {}
|
|
318
314
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as DevToolsNodeRpcSessionMeta } from "./ws-server-
|
|
1
|
+
import { f as RpcFunctionsCollectorBase } from "./index-DB2Ie0Or.mjs";
|
|
2
|
+
import { t as DevToolsNodeRpcSessionMeta } from "./ws-server-DjvlwLuM.mjs";
|
|
3
3
|
import { Logger, createLogger, defineDiagnostics } from "logs-sdk";
|
|
4
4
|
import { BirpcReturn } from "birpc";
|
|
5
|
-
import { Objectish, Patch, Patch as SharedStatePatch } from "immer";
|
|
6
5
|
import { CAC } from "cac";
|
|
7
6
|
import { GenericSchema, InferOutput } from "valibot";
|
|
8
7
|
|
|
@@ -25,7 +24,7 @@ type CliFlagsSchema = Record<string, GenericSchema>;
|
|
|
25
24
|
* config: v.optional(v.string()),
|
|
26
25
|
* })
|
|
27
26
|
*
|
|
28
|
-
*
|
|
27
|
+
* defineDevframe({
|
|
29
28
|
* cli: { flags: appFlags },
|
|
30
29
|
* setup(ctx, info) {
|
|
31
30
|
* const flags = info.flags as InferCliFlags<typeof appFlags>
|
|
@@ -387,35 +386,6 @@ interface DevToolsHost {
|
|
|
387
386
|
getStorageDir: (scope: 'workspace' | 'global') => string;
|
|
388
387
|
}
|
|
389
388
|
//#endregion
|
|
390
|
-
//#region src/types/json-render.d.ts
|
|
391
|
-
interface JsonRenderElement {
|
|
392
|
-
type: string;
|
|
393
|
-
props?: Record<string, unknown>;
|
|
394
|
-
children?: string[];
|
|
395
|
-
/** json-render event bindings (e.g. `{ press: { action: "my:action" } }`) */
|
|
396
|
-
on?: Record<string, unknown>;
|
|
397
|
-
/** json-render visibility condition */
|
|
398
|
-
visible?: unknown;
|
|
399
|
-
/** json-render repeat binding */
|
|
400
|
-
repeat?: unknown;
|
|
401
|
-
/** Allow additional json-render element fields */
|
|
402
|
-
[key: string]: unknown;
|
|
403
|
-
}
|
|
404
|
-
interface JsonRenderSpec {
|
|
405
|
-
root: string;
|
|
406
|
-
elements: Record<string, JsonRenderElement>;
|
|
407
|
-
/** Initial client-side state model for $state/$bindState expressions */
|
|
408
|
-
state?: Record<string, unknown>;
|
|
409
|
-
}
|
|
410
|
-
interface JsonRenderer {
|
|
411
|
-
/** Replace the entire spec */
|
|
412
|
-
updateSpec: (spec: JsonRenderSpec) => void | Promise<void>;
|
|
413
|
-
/** Update json-render state values (shallow merge into spec.state) */
|
|
414
|
-
updateState: (state: Record<string, unknown>) => void | Promise<void>;
|
|
415
|
-
/** Internal: shared state key used by the client to subscribe */
|
|
416
|
-
readonly _stateKey: string;
|
|
417
|
-
}
|
|
418
|
-
//#endregion
|
|
419
389
|
//#region src/types/rpc-augments.d.ts
|
|
420
390
|
/**
|
|
421
391
|
* To be extended
|
|
@@ -557,6 +527,15 @@ type ImmutableArray<T> = ReadonlyArray<Immutable<T>>;
|
|
|
557
527
|
type ImmutableMap<K, V> = ReadonlyMap<Immutable<K>, Immutable<V>>;
|
|
558
528
|
type ImmutableSet<T> = ReadonlySet<Immutable<T>>;
|
|
559
529
|
type ImmutableObject<T> = { readonly [K in keyof T]: Immutable<T[K]> };
|
|
530
|
+
/**
|
|
531
|
+
* Serializable patch describing a single mutation to a `SharedState`.
|
|
532
|
+
* Structurally compatible with JSON-Patch and is safe to send over RPC.
|
|
533
|
+
*/
|
|
534
|
+
interface SharedStatePatch {
|
|
535
|
+
op: 'add' | 'remove' | 'replace';
|
|
536
|
+
path: readonly (string | number)[];
|
|
537
|
+
value?: unknown;
|
|
538
|
+
}
|
|
560
539
|
/**
|
|
561
540
|
* State host that is immutable by default with explicit mutate.
|
|
562
541
|
*/
|
|
@@ -576,14 +555,14 @@ interface SharedState<T> {
|
|
|
576
555
|
/**
|
|
577
556
|
* Apply patches to the state.
|
|
578
557
|
*/
|
|
579
|
-
patch: (patches:
|
|
558
|
+
patch: (patches: SharedStatePatch[], syncId?: string) => void;
|
|
580
559
|
/**
|
|
581
560
|
* Sync IDs that have been applied to the state.
|
|
582
561
|
*/
|
|
583
562
|
syncIds: Set<string>;
|
|
584
563
|
}
|
|
585
564
|
interface SharedStateEvents<T> {
|
|
586
|
-
updated: (fullState: T, patches:
|
|
565
|
+
updated: (fullState: T, patches: SharedStatePatch[] | undefined, syncId: string) => void;
|
|
587
566
|
}
|
|
588
567
|
interface SharedStateOptions<T> {
|
|
589
568
|
/**
|
|
@@ -597,7 +576,7 @@ interface SharedStateOptions<T> {
|
|
|
597
576
|
*/
|
|
598
577
|
enablePatches?: boolean;
|
|
599
578
|
}
|
|
600
|
-
declare function createSharedState<T extends
|
|
579
|
+
declare function createSharedState<T extends object>(options: SharedStateOptions<T>): SharedState<T>;
|
|
601
580
|
//#endregion
|
|
602
581
|
//#region src/utils/streaming-channel.d.ts
|
|
603
582
|
/**
|
|
@@ -887,11 +866,11 @@ interface DevToolsCapabilities {
|
|
|
887
866
|
views?: boolean;
|
|
888
867
|
}
|
|
889
868
|
/**
|
|
890
|
-
* Framework-
|
|
891
|
-
* view-host (HTTP file-serving).
|
|
892
|
-
*
|
|
893
|
-
*
|
|
894
|
-
*
|
|
869
|
+
* Framework- and build-tool-agnostic node context — RPC + diagnostics +
|
|
870
|
+
* agent + the view-host (HTTP file-serving). Host adapters can wrap this
|
|
871
|
+
* to add their own surfaces; for example, `@vitejs/devtools-kit`'s
|
|
872
|
+
* `createKitContext` adds `docks`, `terminals`, `messages`, and
|
|
873
|
+
* `commands` when mounted into Vite DevTools.
|
|
895
874
|
*/
|
|
896
875
|
interface DevToolsNodeContext {
|
|
897
876
|
readonly workspaceRoot: string;
|
|
@@ -929,10 +908,6 @@ interface DevToolsNodeContext {
|
|
|
929
908
|
* @experimental
|
|
930
909
|
*/
|
|
931
910
|
agent: DevToolsAgentHost;
|
|
932
|
-
/**
|
|
933
|
-
* Create a JsonRenderer handle for building json-render powered UIs.
|
|
934
|
-
*/
|
|
935
|
-
createJsonRenderer: (spec: JsonRenderSpec) => JsonRenderer;
|
|
936
911
|
}
|
|
937
912
|
interface ConnectionMeta {
|
|
938
913
|
backend: 'websocket' | 'static';
|
|
@@ -948,17 +923,17 @@ interface ConnectionMeta {
|
|
|
948
923
|
jsonSerializableMethods?: string[];
|
|
949
924
|
}
|
|
950
925
|
//#endregion
|
|
951
|
-
//#region src/types/
|
|
952
|
-
type
|
|
926
|
+
//#region src/types/devframe.d.ts
|
|
927
|
+
type DevframeRuntime = 'cli' | 'build' | 'spa' | 'vite' | 'embedded';
|
|
953
928
|
/**
|
|
954
|
-
* Classification of how a
|
|
955
|
-
* (`vite`, `
|
|
956
|
-
*
|
|
929
|
+
* Classification of how a devframe is being deployed. Hosted adapters
|
|
930
|
+
* (`vite`, `embedded`) share their origin with a host app and must
|
|
931
|
+
* namespace their mount path under `/__<id>/`. Standalone adapters
|
|
957
932
|
* (`cli`, `spa`, `build`) own the origin and default to `/`.
|
|
958
933
|
*/
|
|
959
|
-
type
|
|
960
|
-
interface
|
|
961
|
-
/** Binary name; default: the
|
|
934
|
+
type DevframeDeploymentKind = 'standalone' | 'hosted';
|
|
935
|
+
interface DevframeCliOptions {
|
|
936
|
+
/** Binary name; default: the devframe's `id`. */
|
|
962
937
|
command?: string;
|
|
963
938
|
/** Preferred port for the dev server (default 9999). */
|
|
964
939
|
port?: number;
|
|
@@ -983,7 +958,7 @@ interface DevtoolCliOptions {
|
|
|
983
958
|
* `devtools.clientAuth` today.
|
|
984
959
|
*/
|
|
985
960
|
auth?: boolean;
|
|
986
|
-
/** Author's SPA dist directory (served as the
|
|
961
|
+
/** Author's SPA dist directory (served as the devframe's UI). */
|
|
987
962
|
distDir?: string;
|
|
988
963
|
/**
|
|
989
964
|
* Capability-side CAC hook. Called with the CAC instance after the
|
|
@@ -1009,7 +984,7 @@ interface DevtoolCliOptions {
|
|
|
1009
984
|
* config: v.optional(v.string()),
|
|
1010
985
|
* })
|
|
1011
986
|
*
|
|
1012
|
-
*
|
|
987
|
+
* defineDevframe({
|
|
1013
988
|
* cli: { flags: appFlags },
|
|
1014
989
|
* setup(ctx, info) {
|
|
1015
990
|
* const flags = info.flags as InferCliFlags<typeof appFlags>
|
|
@@ -1019,7 +994,7 @@ interface DevtoolCliOptions {
|
|
|
1019
994
|
*/
|
|
1020
995
|
flags?: CliFlagsSchema;
|
|
1021
996
|
}
|
|
1022
|
-
interface
|
|
997
|
+
interface DevframeSpaOptions {
|
|
1023
998
|
base?: string;
|
|
1024
999
|
/**
|
|
1025
1000
|
* How the deployed SPA loads its data.
|
|
@@ -1029,7 +1004,7 @@ interface DevtoolSpaOptions {
|
|
|
1029
1004
|
*/
|
|
1030
1005
|
loader?: 'query' | 'upload' | 'none';
|
|
1031
1006
|
}
|
|
1032
|
-
interface
|
|
1007
|
+
interface DevframeBrowserContext {
|
|
1033
1008
|
/**
|
|
1034
1009
|
* The connected RPC client (may be write-disabled in static/spa modes).
|
|
1035
1010
|
*/
|
|
@@ -1040,11 +1015,11 @@ interface DevtoolBrowserContext {
|
|
|
1040
1015
|
* populate the fields that make sense for their deployment. In
|
|
1041
1016
|
* particular, `createCli` fills `flags` with the parsed CAC bag.
|
|
1042
1017
|
*/
|
|
1043
|
-
interface
|
|
1018
|
+
interface DevframeSetupInfo {
|
|
1044
1019
|
/** Parsed CLI flags, populated by the CLI adapter. */
|
|
1045
1020
|
flags?: Record<string, unknown>;
|
|
1046
1021
|
}
|
|
1047
|
-
interface
|
|
1022
|
+
interface DevframeDefinition {
|
|
1048
1023
|
id: string;
|
|
1049
1024
|
name: string;
|
|
1050
1025
|
icon?: string | {
|
|
@@ -1055,7 +1030,7 @@ interface DevtoolDefinition {
|
|
|
1055
1030
|
/**
|
|
1056
1031
|
* Mount path override. Defaults depend on the adapter:
|
|
1057
1032
|
* `/` for standalone (`cli` / `spa` / `build`), `/__<id>/` for hosted
|
|
1058
|
-
* (`vite` / `
|
|
1033
|
+
* (`vite` / `embedded`).
|
|
1059
1034
|
*/
|
|
1060
1035
|
basePath?: string;
|
|
1061
1036
|
capabilities?: {
|
|
@@ -1064,12 +1039,12 @@ interface DevtoolDefinition {
|
|
|
1064
1039
|
spa?: boolean | Record<string, boolean>;
|
|
1065
1040
|
};
|
|
1066
1041
|
/** Server-side setup — the primary entrypoint. Runs in every runtime. */
|
|
1067
|
-
setup: (ctx: DevToolsNodeContext, info?:
|
|
1042
|
+
setup: (ctx: DevToolsNodeContext, info?: DevframeSetupInfo) => void | Promise<void>;
|
|
1068
1043
|
/** Browser-only setup for the SPA adapter (bundled into the client). */
|
|
1069
|
-
setupBrowser?: (ctx:
|
|
1070
|
-
cli?:
|
|
1071
|
-
spa?:
|
|
1044
|
+
setupBrowser?: (ctx: DevframeBrowserContext) => void | Promise<void>;
|
|
1045
|
+
cli?: DevframeCliOptions;
|
|
1046
|
+
spa?: DevframeSpaOptions;
|
|
1072
1047
|
}
|
|
1073
|
-
declare function
|
|
1048
|
+
declare function defineDevframe(d: DevframeDefinition): DevframeDefinition;
|
|
1074
1049
|
//#endregion
|
|
1075
|
-
export {
|
|
1050
|
+
export { AgentResourceContent as $, ImmutableArray as A, EntriesToObject as B, StreamErrorPayload as C, createStreamReader as D, StreamSinkEvents as E, SharedStateEvents as F, DevToolsRpcSharedStates as G, Thenable as H, SharedStateOptions as I, DevToolsDiagnosticsHost as J, DevToolsHost as K, SharedStatePatch as L, ImmutableObject as M, ImmutableSet as N, createStreamSink as O, SharedState as P, AgentResource as Q, createSharedState as R, CreateStreamSinkOptions as S, StreamSink as T, DevToolsRpcClientFunctions as U, PartialWithoutId as V, DevToolsRpcServerFunctions as W, AgentHandle as X, DevToolsDiagnosticsLogger as Y, AgentManifest as Z, RpcStreamingChannel as _, DevframeRuntime as a, EventEmitter as at, BufferedChunk as b, defineDevframe as c, CliFlagsSchema as ct, DevToolsNodeContext as d, parseCliFlags as dt, AgentResourceInput as et, DevToolsNodeRpcSession as f, RpcSharedStateHost as g, RpcSharedStateGetOptions as h, DevframeDeploymentKind as i, DevToolsAgentHostEvents as it, ImmutableMap as j, Immutable as k, ConnectionMeta as l, InferCliFlags as lt, RpcFunctionsHost as m, DevframeCliOptions as n, AgentToolInput as nt, DevframeSetupInfo as o, EventUnsubscribe as ot, RpcBroadcastOptions as p, DevToolsDiagnosticsDefinition as q, DevframeDefinition as r, DevToolsAgentHost as rt, DevframeSpaOptions as s, EventsMap as st, DevframeBrowserContext as t, AgentTool as tt, DevToolsCapabilities as u, defineCliFlags as ut, RpcStreamingChannelOptions as v, StreamReader as w, CreateStreamReaderOptions as x, RpcStreamingHost as y, DevToolsViewHost as z };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { t as colors } from "./colors-DS7k8ljB.mjs";
|
|
1
2
|
import { consoleReporter, createLogger, defineDiagnostics } from "logs-sdk";
|
|
2
|
-
import c from "ansis";
|
|
3
3
|
import { ansiFormatter } from "logs-sdk/formatters/ansi";
|
|
4
4
|
//#region src/node/diagnostics.ts
|
|
5
5
|
const diagnostics = defineDiagnostics({
|
|
@@ -39,12 +39,17 @@ const diagnostics = defineDiagnostics({
|
|
|
39
39
|
DF0032: {
|
|
40
40
|
message: (p) => `Streaming channel "${p.channel}" is already registered.`,
|
|
41
41
|
hint: "Each channel name must be unique within a context. Pick a different name or reuse the existing channel handle."
|
|
42
|
+
},
|
|
43
|
+
DF0033: {
|
|
44
|
+
message: (p) => `Failed to start dev RPC bridge for "${p.id}": ${p.reason}`,
|
|
45
|
+
hint: "Verify the bridge port is free and the devframe setup function does not throw. Pin a port via `cli.port` / `cli.portRange` on the definition, or via `devMiddleware.port` on `viteDevBridge`.",
|
|
46
|
+
level: "warn"
|
|
42
47
|
}
|
|
43
48
|
}
|
|
44
49
|
});
|
|
45
50
|
const logger = createLogger({
|
|
46
51
|
diagnostics: [diagnostics],
|
|
47
|
-
formatter: ansiFormatter(
|
|
52
|
+
formatter: ansiFormatter(colors),
|
|
48
53
|
reporters: consoleReporter
|
|
49
54
|
});
|
|
50
55
|
//#endregion
|