wtt-connect 0.2.55 → 0.2.56
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/package.json +1 -1
- package/src/main.js +3 -11
- package/src/runner.js +1 -1
package/package.json
CHANGED
package/src/main.js
CHANGED
|
@@ -149,7 +149,8 @@ Commands:
|
|
|
149
149
|
Alias for upload-artifact
|
|
150
150
|
preview-port --port <port> [--topic-id <id>] [--snapshot-dir <dir>]
|
|
151
151
|
Create a Cloud Sandbox live preview URL; snapshots are opt-in
|
|
152
|
-
cleanup-previews
|
|
152
|
+
cleanup-previews [--keep-last <n>]
|
|
153
|
+
Stop preview servers previously registered by this agent
|
|
153
154
|
help Show this help
|
|
154
155
|
`);
|
|
155
156
|
}
|
|
@@ -160,11 +161,7 @@ async function previewPort(config, argv) {
|
|
|
160
161
|
throw new Error('preview-port requires --port <1024-65535>, excluding 3000');
|
|
161
162
|
}
|
|
162
163
|
await assertLocalPreviewPort(port, Number(argv.portCheckTimeout || argv.timeout || 5000));
|
|
163
|
-
const
|
|
164
|
-
const cleanup = cleanupOldPreviews(config, {
|
|
165
|
-
currentPort: port,
|
|
166
|
-
keepLast: Math.max(0, keepLast - 1),
|
|
167
|
-
});
|
|
164
|
+
const cleanup = { stopped: [], kept: readPreviewRegistry(config).map((entry) => ({ port: Number(entry.port), url: entry.url || '' })) };
|
|
168
165
|
const preview = await createSandboxPreviewFromOutbox(config, port, {
|
|
169
166
|
name: String(argv.previewName || argv.title || '').trim(),
|
|
170
167
|
token: String(argv.previewToken || '').trim(),
|
|
@@ -280,11 +277,6 @@ async function cleanupPreviewsCommand(config, argv) {
|
|
|
280
277
|
console.log(JSON.stringify({ ok: true, cleanup }, null, 2));
|
|
281
278
|
}
|
|
282
279
|
|
|
283
|
-
function previewKeepLast(config, argv = {}) {
|
|
284
|
-
if (Number.isFinite(Number(argv.keepLast))) return Math.max(0, Number(argv.keepLast));
|
|
285
|
-
return Math.max(0, Number(config.previewKeepLast ?? 3) || 0);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
280
|
function cleanupOldPreviews(config, { currentPort = 0, keepLast = 0 } = {}) {
|
|
289
281
|
const registry = readPreviewRegistry(config);
|
|
290
282
|
const entries = registry
|
package/src/runner.js
CHANGED
|
@@ -943,7 +943,7 @@ function renderCloudSandboxStorageInstruction(config, topicId = '') {
|
|
|
943
943
|
'- For Vite use `npm run dev -- --host 0.0.0.0 --port <port>`; for Next use `next dev -H 0.0.0.0 -p <port>`; for Python use `python3 -m http.server <port> --bind 0.0.0.0`.',
|
|
944
944
|
'- Before publishing a preview URL, verify the server is reachable from the Cloudflare preview network with `curl -fsS http://10.0.0.1:<port>/ >/dev/null`.',
|
|
945
945
|
'- If that curl fails, fix or restart the web server first. Never publish a preview URL for a dead or localhost-only port.',
|
|
946
|
-
'- `wtt-connect preview-port`
|
|
946
|
+
'- `wtt-connect preview-port` must not stop older preview servers. WTT Web closes a live preview only when the user clicks the preview card X, or when `wtt-connect cleanup-previews` is explicitly requested.',
|
|
947
947
|
'- Do not pass `--snapshot-dir` for normal live previews. Live Cloud Sandbox previews should render as inline WTT preview cards, not as ordinary index.html/document artifacts.',
|
|
948
948
|
'- If the user explicitly asks for a persistent static artifact or downloadable HTML, publish that separately with `wtt-connect upload-artifact --dir <dir> --title "Short Title"` instead of mixing it with the live preview URL.',
|
|
949
949
|
'- If you start a web server in the sandbox and the user should preview it, call the Cloudflare Sandbox outbound Worker directly with curl and include the returned `preview_url` in your reply as `[preview_url:Short Title](<preview_url>)`.',
|