@kenkaiiii/ggcoder 7.4.1 → 7.6.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/dist/app-sidecar/detached-sessions.d.ts +2 -0
- package/dist/app-sidecar/detached-sessions.js +2 -0
- package/dist/app-sidecar/detached-sessions.js.map +1 -1
- package/dist/app-sidecar/fix-all-checks.d.ts +5 -1
- package/dist/app-sidecar/fix-all-checks.js +22 -7
- package/dist/app-sidecar/fix-all-checks.js.map +1 -1
- package/dist/app-sidecar/fix-all-journal.d.ts +2 -0
- package/dist/app-sidecar/fix-all-journal.js +21 -0
- package/dist/app-sidecar/fix-all-journal.js.map +1 -1
- package/dist/app-sidecar/fix-all-runner.d.ts +2 -0
- package/dist/app-sidecar/fix-all-runner.js +59 -20
- package/dist/app-sidecar/fix-all-runner.js.map +1 -1
- package/dist/app-sidecar/history-routes.js +4 -0
- package/dist/app-sidecar/history-routes.js.map +1 -1
- package/dist/app-sidecar/history.d.ts +2 -0
- package/dist/app-sidecar/history.js.map +1 -1
- package/dist/app-sidecar/live-preview/devices.d.ts +90 -0
- package/dist/app-sidecar/live-preview/devices.js +347 -0
- package/dist/app-sidecar/live-preview/devices.js.map +1 -0
- package/dist/app-sidecar/live-preview/manager.d.ts +46 -0
- package/dist/app-sidecar/live-preview/manager.js +317 -10
- package/dist/app-sidecar/live-preview/manager.js.map +1 -1
- package/dist/app-sidecar/live-preview/mirror.d.ts +64 -0
- package/dist/app-sidecar/live-preview/mirror.js +494 -0
- package/dist/app-sidecar/live-preview/mirror.js.map +1 -0
- package/dist/app-sidecar/live-preview/pages.d.ts +19 -2
- package/dist/app-sidecar/live-preview/pages.js +155 -3
- package/dist/app-sidecar/live-preview/pages.js.map +1 -1
- package/dist/app-sidecar/live-preview/proxy.d.ts +39 -1
- package/dist/app-sidecar/live-preview/proxy.js +259 -1
- package/dist/app-sidecar/live-preview/proxy.js.map +1 -1
- package/dist/app-sidecar/live-preview/refresh.d.ts +73 -0
- package/dist/app-sidecar/live-preview/refresh.js +260 -0
- package/dist/app-sidecar/live-preview/refresh.js.map +1 -0
- package/dist/app-sidecar/live-preview/routes.d.ts +2 -1
- package/dist/app-sidecar/live-preview/routes.js +47 -2
- package/dist/app-sidecar/live-preview/routes.js.map +1 -1
- package/dist/app-sidecar/live-preview/watcher.d.ts +29 -0
- package/dist/app-sidecar/live-preview/watcher.js +187 -0
- package/dist/app-sidecar/live-preview/watcher.js.map +1 -0
- package/dist/app-sidecar/route-context.d.ts +1 -0
- package/dist/app-sidecar/session-types.d.ts +2 -0
- package/dist/app-sidecar/storage-sweep.d.ts +20 -0
- package/dist/app-sidecar/storage-sweep.js +79 -0
- package/dist/app-sidecar/storage-sweep.js.map +1 -0
- package/dist/app-sidecar/upload-prune.d.ts +15 -0
- package/dist/app-sidecar/upload-prune.js +78 -0
- package/dist/app-sidecar/upload-prune.js.map +1 -0
- package/dist/app-sidecar/worktrees.d.ts +29 -0
- package/dist/app-sidecar/worktrees.js +75 -0
- package/dist/app-sidecar/worktrees.js.map +1 -1
- package/dist/app-sidecar.js +80 -6
- package/dist/app-sidecar.js.map +1 -1
- package/dist/cli.js +9 -2
- package/dist/cli.js.map +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
// What the preview does after the project changes. A dev server with hot
|
|
2
|
+
// reload usually updates the page itself; when it doesn't (no hot reload,
|
|
3
|
+
// a static folder, a server-rendered template), GG reloads the page.
|
|
4
|
+
import { spawn } from "node:child_process";
|
|
5
|
+
import { killProcessTree } from "@kenkaiiii/gg-engine/internal/utils/process.js";
|
|
6
|
+
/** How long a hot-reload server gets to react before GG reloads the page itself. */
|
|
7
|
+
export const HMR_GRACE_MS = 2000;
|
|
8
|
+
/** At most one reload per this long. */
|
|
9
|
+
export const RELOAD_MIN_GAP_MS = 1000;
|
|
10
|
+
/**
|
|
11
|
+
* After a change seen at `since`: reload when nothing listens for hot reload,
|
|
12
|
+
* leave it to hot reload once the dev server spoke on its socket, else wait
|
|
13
|
+
* until the grace period runs out and reload.
|
|
14
|
+
*/
|
|
15
|
+
export function decideReload(hmr, since, now, graceMs = HMR_GRACE_MS) {
|
|
16
|
+
if (hmr.sockets === 0)
|
|
17
|
+
return "reload";
|
|
18
|
+
if (hmr.lastBytesAt >= since)
|
|
19
|
+
return "hmr";
|
|
20
|
+
return now - since >= graceMs ? "reload" : "wait";
|
|
21
|
+
}
|
|
22
|
+
export function createHmrOrReload(deps) {
|
|
23
|
+
const now = deps.now ?? Date.now;
|
|
24
|
+
const graceMs = deps.graceMs ?? HMR_GRACE_MS;
|
|
25
|
+
const minGapMs = deps.minGapMs ?? RELOAD_MIN_GAP_MS;
|
|
26
|
+
let lastReloadAt = -Infinity;
|
|
27
|
+
// The oldest change not yet handled: a later one must not hide its missing hot reload.
|
|
28
|
+
let pendingSince = null;
|
|
29
|
+
let timer = null;
|
|
30
|
+
let closed = false;
|
|
31
|
+
const schedule = (ms) => {
|
|
32
|
+
if (timer)
|
|
33
|
+
clearTimeout(timer);
|
|
34
|
+
timer = setTimeout(check, Math.max(0, ms));
|
|
35
|
+
timer.unref?.();
|
|
36
|
+
};
|
|
37
|
+
const check = () => {
|
|
38
|
+
timer = null;
|
|
39
|
+
if (closed || pendingSince === null)
|
|
40
|
+
return;
|
|
41
|
+
const t = now();
|
|
42
|
+
const decision = decideReload(deps.hmr(), pendingSince, t, graceMs);
|
|
43
|
+
if (decision === "hmr") {
|
|
44
|
+
pendingSince = null;
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (decision === "wait") {
|
|
48
|
+
schedule(Math.min(200, pendingSince + graceMs - t));
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const gap = lastReloadAt + minGapMs - t;
|
|
52
|
+
if (gap > 0) {
|
|
53
|
+
schedule(gap);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
pendingSince = null;
|
|
57
|
+
lastReloadAt = t;
|
|
58
|
+
if (deps.reload() > 0)
|
|
59
|
+
deps.onReloaded?.();
|
|
60
|
+
};
|
|
61
|
+
return {
|
|
62
|
+
kind: "hmr-or-reload",
|
|
63
|
+
onChange: (_files, since) => {
|
|
64
|
+
if (closed)
|
|
65
|
+
return;
|
|
66
|
+
pendingSince = pendingSince === null ? since : Math.min(pendingSince, since);
|
|
67
|
+
check();
|
|
68
|
+
},
|
|
69
|
+
close: () => {
|
|
70
|
+
closed = true;
|
|
71
|
+
if (timer)
|
|
72
|
+
clearTimeout(timer);
|
|
73
|
+
timer = null;
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/** Expo/React Native: Metro's Fast Refresh already updates the app. */
|
|
78
|
+
export function createNoRefresh() {
|
|
79
|
+
return { kind: "none", onChange: () => { }, close: () => { } };
|
|
80
|
+
}
|
|
81
|
+
// ── Apps GG rebuilds or re-runs: Flutter, native builds, command-line apps ──
|
|
82
|
+
/** Lines of a failed build shown and told to the agent. */
|
|
83
|
+
export const FAILED_LINES = 20;
|
|
84
|
+
/** How often a pending rebuild checks whether the agent is done writing. */
|
|
85
|
+
export const WRITE_WAIT_MS = 300;
|
|
86
|
+
/** Terminal output reaches the mirror at most this often. */
|
|
87
|
+
const OUTPUT_EVERY_MS = 100;
|
|
88
|
+
/** The last lines of a command's output, without colour codes. */
|
|
89
|
+
export function lastLines(output, n = FAILED_LINES) {
|
|
90
|
+
// eslint-disable-next-line no-control-regex
|
|
91
|
+
const plain = output.replace(/\x1b\[[0-9;?]*[A-Za-z]/g, "").replace(/\r(?!\n)/g, "\n");
|
|
92
|
+
const lines = plain.split(/\r?\n/).filter((l) => l.trim() !== "");
|
|
93
|
+
const tail = lines.slice(-n).join("\n");
|
|
94
|
+
return tail.length > 4000 ? tail.slice(-4000) : tail;
|
|
95
|
+
}
|
|
96
|
+
/** Runs a shell command in its own process group, so cancelling stops all of it. */
|
|
97
|
+
export const spawnCommand = (command, cwd, onOutput) => {
|
|
98
|
+
const child = spawn(command, {
|
|
99
|
+
cwd,
|
|
100
|
+
shell: true,
|
|
101
|
+
detached: process.platform !== "win32",
|
|
102
|
+
windowsHide: true,
|
|
103
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
104
|
+
env: { ...process.env, FORCE_COLOR: "1", CLICOLOR_FORCE: "1" },
|
|
105
|
+
});
|
|
106
|
+
let output = "";
|
|
107
|
+
let cancelled = false;
|
|
108
|
+
const take = (c) => {
|
|
109
|
+
const text = c.toString("utf8");
|
|
110
|
+
output += text;
|
|
111
|
+
if (output.length > 1_000_000)
|
|
112
|
+
output = output.slice(-500_000);
|
|
113
|
+
onOutput(text);
|
|
114
|
+
};
|
|
115
|
+
child.stdout?.on("data", take);
|
|
116
|
+
child.stderr?.on("data", take);
|
|
117
|
+
const done = new Promise((resolve) => {
|
|
118
|
+
child.once("error", (err) => {
|
|
119
|
+
output += `\n${err.message}`;
|
|
120
|
+
resolve({ code: null, output, cancelled });
|
|
121
|
+
});
|
|
122
|
+
child.once("close", (code) => resolve({ code, output, cancelled }));
|
|
123
|
+
});
|
|
124
|
+
return {
|
|
125
|
+
done,
|
|
126
|
+
cancel: () => {
|
|
127
|
+
if (cancelled)
|
|
128
|
+
return;
|
|
129
|
+
cancelled = true;
|
|
130
|
+
if (child.pid && child.exitCode === null)
|
|
131
|
+
killProcessTree(child.pid);
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
/** Flutter: `r` to the background `flutter run` after Dart files change. */
|
|
136
|
+
export function createFlutterRefresh(deps) {
|
|
137
|
+
let closed = false;
|
|
138
|
+
return {
|
|
139
|
+
kind: "flutter",
|
|
140
|
+
onChange: (files) => {
|
|
141
|
+
if (closed || !files.some((f) => f.endsWith(".dart")))
|
|
142
|
+
return;
|
|
143
|
+
void deps.hotReload().then((problem) => {
|
|
144
|
+
if (closed)
|
|
145
|
+
return;
|
|
146
|
+
if (problem)
|
|
147
|
+
deps.onState("failed", problem);
|
|
148
|
+
else
|
|
149
|
+
deps.onState("reloaded");
|
|
150
|
+
}, (err) => {
|
|
151
|
+
if (!closed)
|
|
152
|
+
deps.onState("failed", String(err));
|
|
153
|
+
});
|
|
154
|
+
},
|
|
155
|
+
close: () => {
|
|
156
|
+
closed = true;
|
|
157
|
+
},
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Runs a command after each settled change: one at a time, a newer change
|
|
162
|
+
* cancelling the run in progress and starting over once it has stopped.
|
|
163
|
+
*/
|
|
164
|
+
function createCommandRefresh(kind, deps) {
|
|
165
|
+
const run = deps.spawn ?? spawnCommand;
|
|
166
|
+
let current = null;
|
|
167
|
+
let generation = 0;
|
|
168
|
+
let waiting = null;
|
|
169
|
+
let closed = false;
|
|
170
|
+
const begin = async () => {
|
|
171
|
+
waiting = null;
|
|
172
|
+
if (closed)
|
|
173
|
+
return;
|
|
174
|
+
if (deps.isWriting()) {
|
|
175
|
+
waiting = setTimeout(() => void begin(), WRITE_WAIT_MS);
|
|
176
|
+
waiting.unref?.();
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
const gen = ++generation;
|
|
180
|
+
const previous = current;
|
|
181
|
+
current = null;
|
|
182
|
+
if (previous) {
|
|
183
|
+
previous.cancel();
|
|
184
|
+
await previous.done;
|
|
185
|
+
}
|
|
186
|
+
if (closed || gen !== generation)
|
|
187
|
+
return;
|
|
188
|
+
if (kind === "rebuild")
|
|
189
|
+
deps.onState("rebuilding");
|
|
190
|
+
let output = "";
|
|
191
|
+
let pushTimer = null;
|
|
192
|
+
const push = (running, exitCode) => {
|
|
193
|
+
if (pushTimer)
|
|
194
|
+
clearTimeout(pushTimer);
|
|
195
|
+
pushTimer = null;
|
|
196
|
+
deps.onTerminal?.({ command: deps.command, output, running, exitCode });
|
|
197
|
+
};
|
|
198
|
+
if (deps.onTerminal)
|
|
199
|
+
push(true, null);
|
|
200
|
+
if (kind === "rerun")
|
|
201
|
+
deps.onFresh?.();
|
|
202
|
+
const started = run(deps.command, deps.cwd, (chunk) => {
|
|
203
|
+
output += chunk;
|
|
204
|
+
if (deps.onTerminal && !pushTimer && !closed && gen === generation) {
|
|
205
|
+
pushTimer = setTimeout(() => push(true, null), OUTPUT_EVERY_MS);
|
|
206
|
+
pushTimer.unref?.();
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
current = started;
|
|
210
|
+
const result = await started.done;
|
|
211
|
+
if (pushTimer)
|
|
212
|
+
clearTimeout(pushTimer);
|
|
213
|
+
if (closed || gen !== generation || result.cancelled)
|
|
214
|
+
return;
|
|
215
|
+
current = null;
|
|
216
|
+
if (deps.onTerminal)
|
|
217
|
+
push(false, result.code);
|
|
218
|
+
if (result.code === 0) {
|
|
219
|
+
deps.onState("reloaded");
|
|
220
|
+
if (kind === "rebuild")
|
|
221
|
+
deps.onFresh?.();
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
const why = lastLines(result.output) || `exited with code ${String(result.code)}`;
|
|
225
|
+
deps.onState("failed", why);
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
const kick = () => {
|
|
229
|
+
if (closed)
|
|
230
|
+
return;
|
|
231
|
+
if (waiting)
|
|
232
|
+
clearTimeout(waiting);
|
|
233
|
+
void begin();
|
|
234
|
+
};
|
|
235
|
+
return {
|
|
236
|
+
kind,
|
|
237
|
+
start: kick,
|
|
238
|
+
onChange: kick,
|
|
239
|
+
close: () => {
|
|
240
|
+
closed = true;
|
|
241
|
+
generation++;
|
|
242
|
+
if (waiting)
|
|
243
|
+
clearTimeout(waiting);
|
|
244
|
+
waiting = null;
|
|
245
|
+
current?.cancel();
|
|
246
|
+
current = null;
|
|
247
|
+
},
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
/** Native apps: run the agent's rebuild command after changes settle. */
|
|
251
|
+
export function createRebuild(deps) {
|
|
252
|
+
return createCommandRefresh("rebuild", deps);
|
|
253
|
+
}
|
|
254
|
+
/** Command-line apps: run the command now, and again after each change. */
|
|
255
|
+
export function createRerun(deps) {
|
|
256
|
+
const ctl = createCommandRefresh("rerun", deps);
|
|
257
|
+
ctl.start();
|
|
258
|
+
return ctl;
|
|
259
|
+
}
|
|
260
|
+
//# sourceMappingURL=refresh.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refresh.js","sourceRoot":"","sources":["../../../src/app-sidecar/live-preview/refresh.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,0EAA0E;AAC1E,qEAAqE;AACrE,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;AAIjF,oFAAoF;AACpF,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC;AACjC,wCAAwC;AACxC,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAItC;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAC1B,GAAgB,EAChB,KAAa,EACb,GAAW,EACX,OAAO,GAAG,YAAY;IAEtB,IAAI,GAAG,CAAC,OAAO,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAC;IACvC,IAAI,GAAG,CAAC,WAAW,IAAI,KAAK;QAAE,OAAO,KAAK,CAAC;IAC3C,OAAO,GAAG,GAAG,KAAK,IAAI,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC;AACpD,CAAC;AAoBD,MAAM,UAAU,iBAAiB,CAAC,IAAqB;IACrD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC;IACjC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,YAAY,CAAC;IAC7C,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,iBAAiB,CAAC;IACpD,IAAI,YAAY,GAAG,CAAC,QAAQ,CAAC;IAC7B,uFAAuF;IACvF,IAAI,YAAY,GAAkB,IAAI,CAAC;IACvC,IAAI,KAAK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AC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import http from "node:http";
|
|
2
2
|
import type { SessionContext } from "../session-types.js";
|
|
3
|
+
import { type DeviceTools } from "./devices.js";
|
|
3
4
|
import type { LivePreviewManager } from "./manager.js";
|
|
4
5
|
import { type PathAnswers, type ProjectPages } from "./pages.js";
|
|
5
6
|
/** Asks the dev server for a path: whether it serves it (2xx). Never follows redirects. */
|
|
6
7
|
export declare function pathAnswers(target: URL): PathAnswers;
|
|
7
8
|
export declare function handleLivePreviewRoutes(manager: LivePreviewManager, ctx: SessionContext, req: http.IncomingMessage, res: http.ServerResponse, url: string, method: string, listPages?: (cwd: string, opts?: {
|
|
8
9
|
answers?: PathAnswers;
|
|
9
|
-
}) => Promise<ProjectPages>): boolean;
|
|
10
|
+
}) => Promise<ProjectPages>, detect?: () => Promise<DeviceTools>): boolean;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import http from "node:http";
|
|
5
5
|
import { log } from "@kenkaiiii/gg-core";
|
|
6
6
|
import { daemonJson, daemonReadBody } from "../http.js";
|
|
7
|
+
import { detectTools } from "./devices.js";
|
|
7
8
|
import { listProjectPages } from "./pages.js";
|
|
8
9
|
const PROBE_TIMEOUT_MS = 1500;
|
|
9
10
|
/** Asks the dev server for a path: whether it serves it (2xx). Never follows redirects. */
|
|
@@ -29,7 +30,7 @@ export function pathAnswers(target) {
|
|
|
29
30
|
req.end();
|
|
30
31
|
});
|
|
31
32
|
}
|
|
32
|
-
export function handleLivePreviewRoutes(manager, ctx, req, res, url, method, listPages = listProjectPages) {
|
|
33
|
+
export function handleLivePreviewRoutes(manager, ctx, req, res, url, method, listPages = listProjectPages, detect = detectTools) {
|
|
33
34
|
if (!url.startsWith("/live-preview/"))
|
|
34
35
|
return false;
|
|
35
36
|
if (method === "GET" && url === "/live-preview/status") {
|
|
@@ -39,7 +40,21 @@ export function handleLivePreviewRoutes(manager, ctx, req, res, url, method, lis
|
|
|
39
40
|
if (method === "GET" && url === "/live-preview/pages") {
|
|
40
41
|
// With a server running, its pages are where it actually serves them.
|
|
41
42
|
const target = manager.status(ctx.id).target;
|
|
42
|
-
void listPages(ctx.cwd, target ? { answers: pathAnswers(new URL(target)) } : {})
|
|
43
|
+
void listPages(ctx.cwd, target ? { answers: pathAnswers(new URL(target)) } : {})
|
|
44
|
+
.then(async (pages) => {
|
|
45
|
+
// A phone app: say up front what's missing to show it.
|
|
46
|
+
if (pages.stack.kind !== "mobile")
|
|
47
|
+
return pages;
|
|
48
|
+
const tools = await detect().catch(() => null);
|
|
49
|
+
if (!tools)
|
|
50
|
+
return pages;
|
|
51
|
+
const stack = {
|
|
52
|
+
...pages.stack,
|
|
53
|
+
tools: { ios: tools.simctl, android: tools.adb !== null, idb: tools.idb !== null },
|
|
54
|
+
};
|
|
55
|
+
return { ...pages, stack };
|
|
56
|
+
})
|
|
57
|
+
.then((pages) => daemonJson(res, 200, pages), (err) => daemonJson(res, 500, { error: errorText(err) }));
|
|
43
58
|
return true;
|
|
44
59
|
}
|
|
45
60
|
if (method === "POST" && url === "/live-preview/stop") {
|
|
@@ -71,9 +86,29 @@ export function handleLivePreviewRoutes(manager, ctx, req, res, url, method, lis
|
|
|
71
86
|
daemonJson(res, 400, { error: "inApp must be a boolean" });
|
|
72
87
|
return;
|
|
73
88
|
}
|
|
89
|
+
const serve = stringList(body.serve);
|
|
90
|
+
if (serve === false) {
|
|
91
|
+
daemonJson(res, 400, { error: "serve must be a list of up to 10 folder paths" });
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (body.device !== undefined && typeof body.device !== "boolean") {
|
|
95
|
+
daemonJson(res, 400, { error: "device must be a boolean" });
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
for (const key of ["rebuild", "run"]) {
|
|
99
|
+
const v = body[key];
|
|
100
|
+
if (v !== undefined && v !== null && (typeof v !== "string" || v.length > 2000)) {
|
|
101
|
+
daemonJson(res, 400, { error: `${key} must be a command of up to 2000 characters` });
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
74
105
|
try {
|
|
75
106
|
const status = await manager.start(ctx, {
|
|
76
107
|
...(typeof body.url === "string" ? { url: body.url } : {}),
|
|
108
|
+
...(serve ? { serve } : {}),
|
|
109
|
+
...(body.device === true ? { device: true } : {}),
|
|
110
|
+
...(typeof body.rebuild === "string" ? { rebuild: body.rebuild } : {}),
|
|
111
|
+
...(typeof body.run === "string" ? { run: body.run } : {}),
|
|
77
112
|
...(typeof body.inApp === "boolean" ? { inApp: body.inApp } : {}),
|
|
78
113
|
});
|
|
79
114
|
daemonJson(res, 200, status);
|
|
@@ -88,5 +123,15 @@ export function handleLivePreviewRoutes(manager, ctx, req, res, url, method, lis
|
|
|
88
123
|
daemonJson(res, 404, { error: "not found" });
|
|
89
124
|
return true;
|
|
90
125
|
}
|
|
126
|
+
/** A short list of short, non-empty strings; undefined when absent, false when invalid. */
|
|
127
|
+
function stringList(value, max = 10) {
|
|
128
|
+
if (value === undefined || value === null)
|
|
129
|
+
return undefined;
|
|
130
|
+
if (!Array.isArray(value) || value.length > max)
|
|
131
|
+
return false;
|
|
132
|
+
if (!value.every((v) => typeof v === "string" && v.trim() && v.length <= 500))
|
|
133
|
+
return false;
|
|
134
|
+
return value;
|
|
135
|
+
}
|
|
91
136
|
const errorText = (err) => (err instanceof Error ? err.message : String(err));
|
|
92
137
|
//# sourceMappingURL=routes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../../../src/app-sidecar/live-preview/routes.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,0EAA0E;AAC1E,8EAA8E;AAC9E,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../../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AAI,CAAC,CAAC,MAAM,IAAI,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC;IAC5F,OAAO,KAAiB,CAAC;AAC3B,CAAC;AAED,MAAM,SAAS,GAAG,CAAC,GAAY,EAAU,EAAE,CAAC,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** Folders whose contents never change what the preview shows (or change on every build). */
|
|
2
|
+
export declare const SKIPPED_DIRS: Set<string>;
|
|
3
|
+
/** File types whose change can change what the preview shows. */
|
|
4
|
+
export declare const WATCHED_EXTENSIONS: Set<string>;
|
|
5
|
+
export declare const SETTLE_MS = 200;
|
|
6
|
+
/** Whether a changed path (relative to its watched root) can change the preview. */
|
|
7
|
+
export declare function isWatchedPath(relative: string): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Roots worth their own watcher: a root inside another one is already seen
|
|
10
|
+
* through it, unless it sits under a skipped folder there (a served `build/`).
|
|
11
|
+
*/
|
|
12
|
+
export declare function distinctRoots(roots: readonly string[]): string[];
|
|
13
|
+
export interface ProjectWatcher {
|
|
14
|
+
close: () => void;
|
|
15
|
+
}
|
|
16
|
+
/** Linux watches folder by folder: past this many, the rest go unwatched. */
|
|
17
|
+
export declare const MAX_LINUX_DIRS = 4000;
|
|
18
|
+
export interface WatchProjectOptions {
|
|
19
|
+
settleMs?: number;
|
|
20
|
+
/** Watch folder by folder (the Linux way) on any platform. */
|
|
21
|
+
byFolder?: boolean;
|
|
22
|
+
log?: (message: string, fields?: Record<string, string>) => void;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Calls `onChange` with the changed files (absolute paths) once edits have
|
|
26
|
+
* been quiet for `settleMs`, so a multi-file edit counts as one change.
|
|
27
|
+
* `since` is when the first of them was seen (epoch ms).
|
|
28
|
+
*/
|
|
29
|
+
export declare function watchProject(roots: readonly string[], onChange: (files: string[], since: number) => void, opts?: WatchProjectOptions): ProjectWatcher;
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
// Watches a previewed project for source changes, so the preview can refresh
|
|
2
|
+
// itself. Only source and asset files count: a dev server's own logs, caches
|
|
3
|
+
// and databases change constantly and would otherwise reload the page forever.
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
/** Folders whose contents never change what the preview shows (or change on every build). */
|
|
7
|
+
export const SKIPPED_DIRS = new Set([
|
|
8
|
+
".git",
|
|
9
|
+
"node_modules",
|
|
10
|
+
".gg",
|
|
11
|
+
"target",
|
|
12
|
+
".next",
|
|
13
|
+
".turbo",
|
|
14
|
+
".cache",
|
|
15
|
+
".venv",
|
|
16
|
+
"__pycache__",
|
|
17
|
+
"coverage",
|
|
18
|
+
".svelte-kit",
|
|
19
|
+
".nuxt",
|
|
20
|
+
".vite",
|
|
21
|
+
".parcel-cache",
|
|
22
|
+
".angular",
|
|
23
|
+
".dart_tool",
|
|
24
|
+
".gradle",
|
|
25
|
+
".build",
|
|
26
|
+
"build",
|
|
27
|
+
"DerivedData",
|
|
28
|
+
"Pods",
|
|
29
|
+
]);
|
|
30
|
+
/** File types whose change can change what the preview shows. */
|
|
31
|
+
export const WATCHED_EXTENSIONS = new Set(("html htm css scss sass less styl js jsx mjs cjs ts tsx mts cts vue svelte astro json md mdx " +
|
|
32
|
+
"svg png jpg jpeg gif webp avif ico woff woff2 ttf otf xml yaml yml toml txt " +
|
|
33
|
+
"py rb php erb ejs hbs handlebars liquid njk twig pug jinja j2 ex exs heex eex go rs elm cs cshtml razor " +
|
|
34
|
+
"swift kt kts java dart m mm h c cc cpp hpp xib storyboard plist strings gradle properties qml ui")
|
|
35
|
+
.split(" ")
|
|
36
|
+
.map((e) => `.${e}`));
|
|
37
|
+
export const SETTLE_MS = 200;
|
|
38
|
+
/** Whether a changed path (relative to its watched root) can change the preview. */
|
|
39
|
+
export function isWatchedPath(relative) {
|
|
40
|
+
const parts = relative.split(/[\\/]+/).filter(Boolean);
|
|
41
|
+
if (parts.length === 0)
|
|
42
|
+
return false;
|
|
43
|
+
for (const dir of parts.slice(0, -1))
|
|
44
|
+
if (SKIPPED_DIRS.has(dir))
|
|
45
|
+
return false;
|
|
46
|
+
const name = parts[parts.length - 1];
|
|
47
|
+
return WATCHED_EXTENSIONS.has(path.extname(name).toLowerCase());
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Roots worth their own watcher: a root inside another one is already seen
|
|
51
|
+
* through it, unless it sits under a skipped folder there (a served `build/`).
|
|
52
|
+
*/
|
|
53
|
+
export function distinctRoots(roots) {
|
|
54
|
+
const resolved = [...new Set(roots.map((r) => path.resolve(r)))];
|
|
55
|
+
return resolved.filter((root) => !resolved.some((outer) => {
|
|
56
|
+
if (outer === root)
|
|
57
|
+
return false;
|
|
58
|
+
const rel = path.relative(outer, root);
|
|
59
|
+
if (!rel || rel.startsWith("..") || path.isAbsolute(rel))
|
|
60
|
+
return false;
|
|
61
|
+
return !rel.split(/[\\/]+/).some((d) => SKIPPED_DIRS.has(d));
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
64
|
+
/** Linux watches folder by folder: past this many, the rest go unwatched. */
|
|
65
|
+
export const MAX_LINUX_DIRS = 4000;
|
|
66
|
+
/**
|
|
67
|
+
* Linux's recursive watch adds a watch to every folder, node_modules included,
|
|
68
|
+
* and runs out of inotify watches on big projects. Watch the kept folders
|
|
69
|
+
* one by one instead, adding new ones as they appear.
|
|
70
|
+
*/
|
|
71
|
+
function watchTreeByFolder(root, onPath, onError) {
|
|
72
|
+
const watchers = new Map();
|
|
73
|
+
const add = (dir) => {
|
|
74
|
+
if (watchers.has(dir) || watchers.size >= MAX_LINUX_DIRS)
|
|
75
|
+
return;
|
|
76
|
+
let w;
|
|
77
|
+
try {
|
|
78
|
+
w = fs.watch(dir, { persistent: false }, (_event, name) => {
|
|
79
|
+
if (!name)
|
|
80
|
+
return;
|
|
81
|
+
const full = path.join(dir, name.toString());
|
|
82
|
+
onPath(path.relative(root, full));
|
|
83
|
+
if (!SKIPPED_DIRS.has(name.toString()) && !watchers.has(full)) {
|
|
84
|
+
try {
|
|
85
|
+
if (fs.statSync(full).isDirectory())
|
|
86
|
+
add(full);
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
/* removed again already */
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
catch (err) {
|
|
95
|
+
onError(err);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
w.on("error", () => {
|
|
99
|
+
w.close();
|
|
100
|
+
watchers.delete(dir);
|
|
101
|
+
});
|
|
102
|
+
watchers.set(dir, w);
|
|
103
|
+
let entries;
|
|
104
|
+
try {
|
|
105
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
for (const e of entries)
|
|
111
|
+
if (e.isDirectory() && !SKIPPED_DIRS.has(e.name))
|
|
112
|
+
add(path.join(dir, e.name));
|
|
113
|
+
};
|
|
114
|
+
add(root);
|
|
115
|
+
return { close: () => [...watchers.values()].forEach((w) => w.close()) };
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Calls `onChange` with the changed files (absolute paths) once edits have
|
|
119
|
+
* been quiet for `settleMs`, so a multi-file edit counts as one change.
|
|
120
|
+
* `since` is when the first of them was seen (epoch ms).
|
|
121
|
+
*/
|
|
122
|
+
export function watchProject(roots, onChange, opts = {}) {
|
|
123
|
+
const settleMs = opts.settleMs ?? SETTLE_MS;
|
|
124
|
+
const pending = new Set();
|
|
125
|
+
let since = 0;
|
|
126
|
+
let timer = null;
|
|
127
|
+
let closed = false;
|
|
128
|
+
const watchers = [];
|
|
129
|
+
const flush = () => {
|
|
130
|
+
timer = null;
|
|
131
|
+
if (closed || pending.size === 0)
|
|
132
|
+
return;
|
|
133
|
+
const files = [...pending];
|
|
134
|
+
pending.clear();
|
|
135
|
+
try {
|
|
136
|
+
onChange(files, since);
|
|
137
|
+
}
|
|
138
|
+
catch (err) {
|
|
139
|
+
opts.log?.("live preview change handler failed", { message: String(err) });
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
for (const root of distinctRoots(roots)) {
|
|
143
|
+
const seen = (rel) => {
|
|
144
|
+
if (closed || !isWatchedPath(rel))
|
|
145
|
+
return;
|
|
146
|
+
if (pending.size === 0)
|
|
147
|
+
since = Date.now();
|
|
148
|
+
pending.add(path.join(root, rel));
|
|
149
|
+
if (timer)
|
|
150
|
+
clearTimeout(timer);
|
|
151
|
+
timer = setTimeout(flush, settleMs);
|
|
152
|
+
};
|
|
153
|
+
if (opts.byFolder ?? process.platform === "linux") {
|
|
154
|
+
watchers.push(watchTreeByFolder(root, seen, (err) => opts.log?.("live preview can't watch a folder", { root, message: String(err) })));
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
let watcher;
|
|
158
|
+
try {
|
|
159
|
+
watcher = fs.watch(root, { recursive: true, persistent: false }, (_event, filename) => {
|
|
160
|
+
if (filename)
|
|
161
|
+
seen(filename.toString());
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
catch (err) {
|
|
165
|
+
opts.log?.("live preview can't watch a folder", { root, message: String(err) });
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
// Windows reports EPERM when a watched folder is deleted: stop that one quietly.
|
|
169
|
+
watcher.on("error", (err) => {
|
|
170
|
+
opts.log?.("live preview watcher stopped", { root, message: String(err) });
|
|
171
|
+
watcher.close();
|
|
172
|
+
});
|
|
173
|
+
watchers.push(watcher);
|
|
174
|
+
}
|
|
175
|
+
return {
|
|
176
|
+
close: () => {
|
|
177
|
+
closed = true;
|
|
178
|
+
if (timer)
|
|
179
|
+
clearTimeout(timer);
|
|
180
|
+
timer = null;
|
|
181
|
+
pending.clear();
|
|
182
|
+
for (const w of watchers)
|
|
183
|
+
w.close();
|
|
184
|
+
},
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
//# sourceMappingURL=watcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watcher.js","sourceRoot":"","sources":["../../../src/app-sidecar/live-preview/watcher.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,6EAA6E;AAC7E,+EAA+E;AAC/E,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,6FAA6F;AAC7F,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC;IAClC,MAAM;IACN,cAAc;IACd,KAAK;IACL,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,OAAO;IACP,aAAa;IACb,UAAU;IACV,aAAa;IACb,OAAO;IACP,OAAO;IACP,eAAe;IACf,UAAU;IACV,YAAY;IACZ,SAAS;IACT,QAAQ;IACR,OAAO;IACP,aAAa;IACb,MAAM;CACP,CAAC,CAAC;AAEH,iEAAiE;AACjE,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,GAAG,CACvC,CACE,8FAA8F;IAC9F,8EAA8E;IAC9E,0GAA0G;IAC1G,kGAAkG,CACnG;KACE,KAAK,CAAC,GAAG,CAAC;KACV,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CACvB,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,CAAC;AAE7B,oFAAoF;AACpF,MAAM,UAAU,aAAa,CAAC,QAAgB;IAC5C,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACvD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACrC,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC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AAU,EAAE,KAAK,EAAE,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE;gBACpF,IAAI,QAAQ;oBAAE,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC;YAC1C,CAAC,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,GAAG,EAAE,CAAC,mCAAmC,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAChF,SAAS;QACX,CAAC;QACD,iFAAiF;QACjF,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YAC1B,IAAI,CAAC,GAAG,EAAE,CAAC,8BAA8B,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAC3E,OAAO,CAAC,KAAK,EAAE,CAAC;QAClB,CAAC,CAAC,CAAC;QACH,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;IAED,OAAO;QACL,KAAK,EAAE,GAAG,EAAE;YACV,MAAM,GAAG,IAAI,CAAC;YACd,IAAI,KAAK;gBAAE,YAAY,CAAC,KAAK,CAAC,CAAC;YAC/B,KAAK,GAAG,IAAI,CAAC;YACb,OAAO,CAAC,KAAK,EAAE,CAAC;YAChB,KAAK,MAAM,CAAC,IAAI,QAAQ;gBAAE,CAAC,CAAC,KAAK,EAAE,CAAC;QACtC,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -43,6 +43,8 @@ export interface SessionContext {
|
|
|
43
43
|
* folder, not the goal folder). Absent for contexts without git state.
|
|
44
44
|
*/
|
|
45
45
|
gitDir?: () => string;
|
|
46
|
+
/** The project it belongs to when it works in a GG-made worktree of it, else null. */
|
|
47
|
+
ggWorktreeOf?: () => string | null;
|
|
46
48
|
/** Its Fix all runner (code windows on a project), or null. */
|
|
47
49
|
fixAll?: () => FixAllRunner | null;
|
|
48
50
|
}
|