@kaleidal/relikt 0.1.2 → 0.1.3
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/relikt.js +288 -81
- package/package.json +1 -1
package/dist/relikt.js
CHANGED
|
@@ -24893,13 +24893,22 @@ var Shot = object({
|
|
|
24893
24893
|
theme: Theme.optional(),
|
|
24894
24894
|
fullPage: boolean2()
|
|
24895
24895
|
});
|
|
24896
|
+
var Box = {
|
|
24897
|
+
viewport: string2(),
|
|
24898
|
+
x: number2(),
|
|
24899
|
+
y: number2(),
|
|
24900
|
+
width: number2().positive(),
|
|
24901
|
+
height: number2().positive()
|
|
24902
|
+
};
|
|
24903
|
+
var Link = union([object({ ...Box, path: string2() }), object({ ...Box, part: string2() })]);
|
|
24896
24904
|
var Part = object({
|
|
24897
24905
|
id: string2(),
|
|
24898
24906
|
type: _enum(partTypes),
|
|
24899
24907
|
name: string2(),
|
|
24900
24908
|
path: string2().optional(),
|
|
24901
24909
|
capture: array(_enum(captureModes)),
|
|
24902
|
-
shots: array(Shot)
|
|
24910
|
+
shots: array(Shot),
|
|
24911
|
+
links: array(Link).default([])
|
|
24903
24912
|
});
|
|
24904
24913
|
var Flow = object({
|
|
24905
24914
|
file: string2(),
|
|
@@ -25089,6 +25098,9 @@ var authScreen = /sign[\s-]?(in|up)|log[\s-]?in|auth|password/i;
|
|
|
25089
25098
|
function isCoverCandidate(part, shot) {
|
|
25090
25099
|
return part.type !== "dialog" && shot.viewport === "laptop" && shot.theme !== "dark" && !authScreen.test(`${part.name} ${part.path ?? ""}`);
|
|
25091
25100
|
}
|
|
25101
|
+
function partId(name) {
|
|
25102
|
+
return slugify2(name) || "untitled";
|
|
25103
|
+
}
|
|
25092
25104
|
function freeFolder(base) {
|
|
25093
25105
|
if (!existsSync(base))
|
|
25094
25106
|
return base;
|
|
@@ -25107,7 +25119,7 @@ class Exhibit {
|
|
|
25107
25119
|
this.manifest = manifest;
|
|
25108
25120
|
}
|
|
25109
25121
|
static async create(options) {
|
|
25110
|
-
const date = today();
|
|
25122
|
+
const date = options.date ? Manifest.shape.date.parse(options.date) : today();
|
|
25111
25123
|
const label = options.label ?? options.reason;
|
|
25112
25124
|
const dir = freeFolder(join2(exhibitsRoot, slugify2(options.project), exhibitSlug(date, label)));
|
|
25113
25125
|
const manifest = {
|
|
@@ -25153,14 +25165,36 @@ class Exhibit {
|
|
|
25153
25165
|
await rm(full, { force: true });
|
|
25154
25166
|
return full;
|
|
25155
25167
|
}
|
|
25156
|
-
part(
|
|
25157
|
-
|
|
25158
|
-
|
|
25159
|
-
|
|
25160
|
-
|
|
25168
|
+
part(init, retake = false) {
|
|
25169
|
+
const id = partId(init.name);
|
|
25170
|
+
const existing = this.manifest.parts.find((part) => part.id === id);
|
|
25171
|
+
if (existing && !retake) {
|
|
25172
|
+
throw new Error(`"${existing.name}" is already captured. Give this capture its own name, or pass retake to replace its shots.`);
|
|
25161
25173
|
}
|
|
25174
|
+
if (existing)
|
|
25175
|
+
return Object.assign(existing, init);
|
|
25176
|
+
const part = { id, ...init, capture: [], shots: [], links: [] };
|
|
25177
|
+
this.manifest.parts.push(part);
|
|
25162
25178
|
return part;
|
|
25163
25179
|
}
|
|
25180
|
+
freeName(name) {
|
|
25181
|
+
const taken = (candidate) => this.manifest.parts.some((part) => part.id === partId(candidate));
|
|
25182
|
+
let candidate = name;
|
|
25183
|
+
for (let count = 2;taken(candidate); count++)
|
|
25184
|
+
candidate = `${name} ${count}`;
|
|
25185
|
+
return candidate;
|
|
25186
|
+
}
|
|
25187
|
+
linkPages(part, links) {
|
|
25188
|
+
part.links = [...part.links.filter((link) => !("path" in link)), ...links];
|
|
25189
|
+
}
|
|
25190
|
+
linkPart(from, link) {
|
|
25191
|
+
from.links = [...from.links.filter((existing) => !("part" in existing) || existing.part !== link.part), link];
|
|
25192
|
+
}
|
|
25193
|
+
markReplayable(part, replayable) {
|
|
25194
|
+
part.capture = part.capture.filter((mode) => mode !== "replayable");
|
|
25195
|
+
if (replayable)
|
|
25196
|
+
part.capture.unshift("replayable");
|
|
25197
|
+
}
|
|
25164
25198
|
addShot(part, shot) {
|
|
25165
25199
|
part.shots = part.shots.filter((existing) => existing.file !== shot.file);
|
|
25166
25200
|
part.shots.push(shot);
|
|
@@ -25389,12 +25423,14 @@ async function addSourceTarball(exhibit, cwd) {
|
|
|
25389
25423
|
// src/replay/serve.ts
|
|
25390
25424
|
import { createReadStream as createReadStream2, existsSync as existsSync3, statSync } from "node:fs";
|
|
25391
25425
|
import { createServer } from "node:http";
|
|
25426
|
+
import { isIPv6 } from "node:net";
|
|
25392
25427
|
import { extname, join as join4, normalize } from "node:path";
|
|
25393
25428
|
|
|
25394
25429
|
// ../replay-runtime/src/archive.ts
|
|
25395
25430
|
var runtimePrefix = "/__relikt/";
|
|
25396
25431
|
var workerPath = "/relikt-sw.js";
|
|
25397
25432
|
var archivePath = `${runtimePrefix}archive.json`;
|
|
25433
|
+
var notArchivedHeader = "x-relikt-not-archived";
|
|
25398
25434
|
function isRuntimePath(pathname) {
|
|
25399
25435
|
return pathname === workerPath || pathname.startsWith(runtimePrefix);
|
|
25400
25436
|
}
|
|
@@ -25428,7 +25464,7 @@ var types = {
|
|
|
25428
25464
|
".json": "application/json",
|
|
25429
25465
|
".png": "image/png"
|
|
25430
25466
|
};
|
|
25431
|
-
function serveReplay(exhibit, port) {
|
|
25467
|
+
function serveReplay(exhibit, port, address = "127.0.0.1") {
|
|
25432
25468
|
const root = exhibit.path(layout.replay);
|
|
25433
25469
|
if (!existsSync3(join4(root, replayLayout.bootstrap)))
|
|
25434
25470
|
throw new Error("This exhibit has no replay");
|
|
@@ -25444,7 +25480,11 @@ function serveReplay(exhibit, port) {
|
|
|
25444
25480
|
response.writeHead(200, { "content-type": types[extname(file)] ?? "application/octet-stream", "cache-control": "no-cache" });
|
|
25445
25481
|
createReadStream2(file).pipe(response);
|
|
25446
25482
|
});
|
|
25447
|
-
return new Promise((resolve) => server.listen(port,
|
|
25483
|
+
return new Promise((resolve) => server.listen(port, address, () => {
|
|
25484
|
+
const { port: bound } = server.address();
|
|
25485
|
+
const host = isIPv6(address) ? `[${address}]` : "localhost";
|
|
25486
|
+
resolve({ url: `http://${host}:${bound}/`, close: () => server.close() });
|
|
25487
|
+
}));
|
|
25448
25488
|
}
|
|
25449
25489
|
|
|
25450
25490
|
// src/sync/pull.ts
|
|
@@ -25601,6 +25641,7 @@ async function newCommand(project, options) {
|
|
|
25601
25641
|
kind: Kind.parse(options.kind),
|
|
25602
25642
|
reason: Reason.parse(options.reason),
|
|
25603
25643
|
label: options.label,
|
|
25644
|
+
date: options.date,
|
|
25604
25645
|
cwd: process.cwd()
|
|
25605
25646
|
});
|
|
25606
25647
|
console.log(exhibit.dir);
|
|
@@ -25620,7 +25661,7 @@ async function listCommand() {
|
|
|
25620
25661
|
}
|
|
25621
25662
|
}
|
|
25622
25663
|
async function replayCommand(reference, port) {
|
|
25623
|
-
const url = await serveReplay(await openExhibit(reference), port);
|
|
25664
|
+
const { url } = await serveReplay(await openExhibit(reference), port);
|
|
25624
25665
|
console.log(`Replay running at ${url}`);
|
|
25625
25666
|
}
|
|
25626
25667
|
|
|
@@ -25656,9 +25697,10 @@ async function settle2(page, idle = 4000) {
|
|
|
25656
25697
|
await page.waitForLoadState("networkidle", { timeout: idle }).catch(() => {
|
|
25657
25698
|
return;
|
|
25658
25699
|
});
|
|
25659
|
-
await page.evaluate(() =>
|
|
25660
|
-
|
|
25700
|
+
await page.evaluate(() => document.fonts.ready.then(() => {
|
|
25701
|
+
return;
|
|
25661
25702
|
}));
|
|
25703
|
+
await page.waitForTimeout(250);
|
|
25662
25704
|
}
|
|
25663
25705
|
async function sameOriginLinks(page) {
|
|
25664
25706
|
return page.evaluate(() => {
|
|
@@ -25689,8 +25731,8 @@ function electronBinary(executable, cwd) {
|
|
|
25689
25731
|
function defined(env) {
|
|
25690
25732
|
return Object.fromEntries(Object.entries(env).filter((entry) => entry[1] !== undefined));
|
|
25691
25733
|
}
|
|
25692
|
-
function scopeRefs(snapshot,
|
|
25693
|
-
return snapshot.replace(/\[ref=(e\d+)\]/g, `[ref=${
|
|
25734
|
+
function scopeRefs(snapshot, window2) {
|
|
25735
|
+
return snapshot.replace(/\[ref=(e\d+)\]/g, `[ref=${window2}:$1]`);
|
|
25694
25736
|
}
|
|
25695
25737
|
function links() {
|
|
25696
25738
|
const routes = new Map;
|
|
@@ -25735,10 +25777,10 @@ class ElectronApp {
|
|
|
25735
25777
|
await settle2(page);
|
|
25736
25778
|
return new ElectronApp(display, app, page);
|
|
25737
25779
|
}
|
|
25738
|
-
page(
|
|
25739
|
-
const page = this.app.windows()[Number(
|
|
25780
|
+
page(window2) {
|
|
25781
|
+
const page = this.app.windows()[Number(window2) - 1];
|
|
25740
25782
|
if (!page)
|
|
25741
|
-
throw new Error(`There is no window ${
|
|
25783
|
+
throw new Error(`There is no window ${window2}`);
|
|
25742
25784
|
return page;
|
|
25743
25785
|
}
|
|
25744
25786
|
async outline() {
|
|
@@ -25764,13 +25806,13 @@ ${await this.active.ariaSnapshot()}`).digest("hex");
|
|
|
25764
25806
|
async raise(page) {
|
|
25765
25807
|
this.active = page;
|
|
25766
25808
|
const title = await page.title();
|
|
25767
|
-
const
|
|
25768
|
-
if (
|
|
25769
|
-
await this.display.sway.focus(
|
|
25809
|
+
const window2 = (await this.display.sway.windows()).find((candidate) => candidate.title === title);
|
|
25810
|
+
if (window2)
|
|
25811
|
+
await this.display.sway.focus(window2.id);
|
|
25770
25812
|
}
|
|
25771
25813
|
async activate(ref) {
|
|
25772
|
-
const [
|
|
25773
|
-
const page = this.page(
|
|
25814
|
+
const [window2 = "", element] = ref.split(":");
|
|
25815
|
+
const page = this.page(window2);
|
|
25774
25816
|
if (!element)
|
|
25775
25817
|
return this.raise(page);
|
|
25776
25818
|
this.active = page;
|
|
@@ -25779,8 +25821,8 @@ ${await this.active.ariaSnapshot()}`).digest("hex");
|
|
|
25779
25821
|
async type(text, ref) {
|
|
25780
25822
|
if (!ref)
|
|
25781
25823
|
return this.active.keyboard.type(text);
|
|
25782
|
-
const [
|
|
25783
|
-
this.active = this.page(
|
|
25824
|
+
const [window2 = "", element] = ref.split(":");
|
|
25825
|
+
this.active = this.page(window2);
|
|
25784
25826
|
await this.active.locator(`aria-ref=${element}`).fill(text);
|
|
25785
25827
|
}
|
|
25786
25828
|
async press(key) {
|
|
@@ -26193,8 +26235,8 @@ class Atspi {
|
|
|
26193
26235
|
doAction(target, index) {
|
|
26194
26236
|
return this.call(target, action, "DoAction", "i", [index]);
|
|
26195
26237
|
}
|
|
26196
|
-
async contentOrigin(
|
|
26197
|
-
const children2 = (await this.call(
|
|
26238
|
+
async contentOrigin(window2) {
|
|
26239
|
+
const children2 = (await this.call(window2, accessible, "GetChildren")).map(node2);
|
|
26198
26240
|
const boxes = (await Promise.all(children2.map((child) => this.extents(child)))).filter((box) => box.x >= 0 && box.y >= 0 && box.width > 0 && box.height > 0);
|
|
26199
26241
|
if (!boxes.length)
|
|
26200
26242
|
return { x: 0, y: 0 };
|
|
@@ -26317,8 +26359,8 @@ function outline(root) {
|
|
|
26317
26359
|
for (const child of element.children)
|
|
26318
26360
|
visit(child, flatten ? depth : depth + 1, flatten ? owner : element.name);
|
|
26319
26361
|
};
|
|
26320
|
-
for (const
|
|
26321
|
-
visit(
|
|
26362
|
+
for (const window2 of root.children)
|
|
26363
|
+
visit(window2, 0, "");
|
|
26322
26364
|
return lines.join(`
|
|
26323
26365
|
`);
|
|
26324
26366
|
}
|
|
@@ -26400,14 +26442,14 @@ function beforeExit(child, work) {
|
|
|
26400
26442
|
}
|
|
26401
26443
|
async function start(display, atspi, target, theme) {
|
|
26402
26444
|
const known = new Set((await atspi.applications()).map((app) => app.bus));
|
|
26403
|
-
const
|
|
26445
|
+
const window2 = display.sway.nextWindow();
|
|
26404
26446
|
const child = spawn3("sh", ["-c", target.command], {
|
|
26405
26447
|
cwd: target.cwd,
|
|
26406
26448
|
env: { ...display.env, ...target.env, ...themeEnvironment[theme] },
|
|
26407
26449
|
detached: true,
|
|
26408
26450
|
stdio: "ignore"
|
|
26409
26451
|
});
|
|
26410
|
-
await beforeExit(child,
|
|
26452
|
+
await beforeExit(child, window2);
|
|
26411
26453
|
const root = await atspi.newApplication(known, accessibilityDeadline());
|
|
26412
26454
|
await atspi.quiet(quietTime, settleLimit);
|
|
26413
26455
|
return { child, root };
|
|
@@ -26482,16 +26524,16 @@ class NativeApp {
|
|
|
26482
26524
|
await this.click(element);
|
|
26483
26525
|
}
|
|
26484
26526
|
async raise(title) {
|
|
26485
|
-
const
|
|
26486
|
-
if (!
|
|
26527
|
+
const window2 = (await this.display.sway.windows()).find((candidate) => candidate.title === title);
|
|
26528
|
+
if (!window2)
|
|
26487
26529
|
throw new Error(`No window titled "${title}" is open`);
|
|
26488
|
-
await this.display.sway.focus(
|
|
26530
|
+
await this.display.sway.focus(window2.id);
|
|
26489
26531
|
}
|
|
26490
26532
|
async click(element) {
|
|
26491
26533
|
const [windowRef = ""] = element.ref.split(".");
|
|
26492
26534
|
const owner = await this.element(windowRef);
|
|
26493
26535
|
const windows = await this.display.sway.windows();
|
|
26494
|
-
const host = windows.find((
|
|
26536
|
+
const host = windows.find((window2) => window2.title === owner.name) ?? windows.find((window2) => window2.focused);
|
|
26495
26537
|
if (!host)
|
|
26496
26538
|
throw new Error(`Cannot find the window that holds ${element.ref}`);
|
|
26497
26539
|
const origin = await this.atspi.contentOrigin(owner.node);
|
|
@@ -27113,7 +27155,7 @@ class Sway {
|
|
|
27113
27155
|
return workspaces(await this.ipc.tree()).flatMap((workspace) => views([...workspace.nodes, ...workspace.floating_nodes]).map(asWindow));
|
|
27114
27156
|
}
|
|
27115
27157
|
async visibleArea() {
|
|
27116
|
-
return union2((await this.windows()).filter((
|
|
27158
|
+
return union2((await this.windows()).filter((window2) => window2.visible).map((window2) => window2.rect));
|
|
27117
27159
|
}
|
|
27118
27160
|
setOutput(width, height, scale) {
|
|
27119
27161
|
return this.ipc.command(`output * mode --custom ${width * scale}x${height * scale} scale ${scale}`);
|
|
@@ -27233,6 +27275,9 @@ class HiddenDisplay {
|
|
|
27233
27275
|
|
|
27234
27276
|
// src/capture/desktop/session.ts
|
|
27235
27277
|
var home = desktopViewports.laptop;
|
|
27278
|
+
function partInit(options) {
|
|
27279
|
+
return { type: options.type ?? "window", name: options.name, path: options.path };
|
|
27280
|
+
}
|
|
27236
27281
|
async function openApp(display, target) {
|
|
27237
27282
|
await display.setViewport(home);
|
|
27238
27283
|
const app = { command: target.command, cwd: target.cwd, env: target.env ?? {} };
|
|
@@ -27310,16 +27355,13 @@ class DesktopSession {
|
|
|
27310
27355
|
async capture(options) {
|
|
27311
27356
|
if (options.path !== undefined)
|
|
27312
27357
|
await this.app.navigate(options.path);
|
|
27313
|
-
const part = this.part(options);
|
|
27358
|
+
const part = this.exhibit.part(partInit(options), options.retake);
|
|
27314
27359
|
this.journal.push({ action: "capture", options });
|
|
27315
27360
|
await this.shoot(part, options);
|
|
27316
27361
|
this.flow?.parts.push(part.id);
|
|
27317
27362
|
await this.exhibit.save();
|
|
27318
27363
|
return part;
|
|
27319
27364
|
}
|
|
27320
|
-
part(options) {
|
|
27321
|
-
return this.exhibit.part(slugify2(options.name) || "untitled", { type: options.type ?? "window", name: options.name, path: options.path });
|
|
27322
|
-
}
|
|
27323
27365
|
themesNow(requested) {
|
|
27324
27366
|
if (this.replayTheme)
|
|
27325
27367
|
return requested.filter((theme) => theme === this.replayTheme);
|
|
@@ -27418,7 +27460,7 @@ class DesktopSession {
|
|
|
27418
27460
|
await app.relaunch("dark");
|
|
27419
27461
|
for (const [index, step] of steps.entries()) {
|
|
27420
27462
|
if (step.action === "capture") {
|
|
27421
|
-
await this.shoot(this.part(step.options), step.options);
|
|
27463
|
+
await this.shoot(this.exhibit.part(partInit(step.options), true), step.options);
|
|
27422
27464
|
continue;
|
|
27423
27465
|
}
|
|
27424
27466
|
const replayed = await this.interact(step).then(() => true, () => false);
|
|
@@ -27467,7 +27509,7 @@ class Walk {
|
|
|
27467
27509
|
async capture(name, type, path) {
|
|
27468
27510
|
this.captured++;
|
|
27469
27511
|
this.log(`[${this.captured}] ${type} ${name}`);
|
|
27470
|
-
await this.session.capture({ name, type, path });
|
|
27512
|
+
await this.session.capture({ name: this.session.exhibit.freeName(name), type, path });
|
|
27471
27513
|
}
|
|
27472
27514
|
async next(kind) {
|
|
27473
27515
|
if (this.full)
|
|
@@ -27499,11 +27541,11 @@ class Walk {
|
|
|
27499
27541
|
}
|
|
27500
27542
|
}
|
|
27501
27543
|
async windows(discovery) {
|
|
27502
|
-
for (const
|
|
27544
|
+
for (const window2 of discovery.windows) {
|
|
27503
27545
|
if (discovery.windows.length > 1)
|
|
27504
|
-
await this.session.activate(
|
|
27546
|
+
await this.session.activate(window2.ref);
|
|
27505
27547
|
await this.unseen();
|
|
27506
|
-
await this.capture(
|
|
27548
|
+
await this.capture(window2.name || "Main window", "window");
|
|
27507
27549
|
}
|
|
27508
27550
|
}
|
|
27509
27551
|
async routes(discovery) {
|
|
@@ -27571,13 +27613,12 @@ p{margin:0;padding:7px 14px;border-radius:999px;background:rgba(20,20,19,.88);co
|
|
|
27571
27613
|
`;
|
|
27572
27614
|
|
|
27573
27615
|
// ../replay-runtime/dist/sw.js
|
|
27574
|
-
var sw_default = 'var
|
|
27616
|
+
var sw_default = 'var y="/__relikt/";var v="/__relikt/archive.json",w=(e)=>`/__relikt/bodies/${e}`,b=(e)=>`/__relikt/shots/${e}`,d="x-relikt-not-archived",x="relikt:not-archived";function A(e){return e==="/relikt-sw.js"||e.startsWith("/__relikt/")}var L=new Set(["_","t","ts","cb","timestamp","nocache","_t","rand"]);function c(e,t){let i=[...e.searchParams.entries()].filter(([r])=>!t||!L.has(r)).sort(([r],[o])=>r.localeCompare(o)),n=new URLSearchParams(i).toString();return`${e.origin}${e.pathname}${n?`?${n}`:""}`}function l(e,t,i){let n=e.get(t);if(n)n.push(i);else e.set(t,[i])}class p{archive;withBody=new Map;exact=new Map;loose=new Map;path=new Map;served=new Map;origins;shell;constructor(e){this.archive=e;for(let t of e.entries){let i=new URL(t.url),n=t.method.toUpperCase();if(t.requestBody)l(this.withBody,`${n} ${c(i,!1)} ${t.requestBody}`,t);l(this.exact,`${n} ${c(i,!1)}`,t),l(this.loose,`${n} ${c(i,!0)}`,t),l(this.path,`${n} ${i.origin}${i.pathname}`,t)}this.origins=new Set(e.entries.map((t)=>new URL(t.url).origin)),this.shell=this.findShell()}match(e,t,i){let n=e.toUpperCase(),r=[i&&[this.withBody,`${n} ${c(t,!1)} ${i}`],[this.exact,`${n} ${c(t,!1)}`],[this.loose,`${n} ${c(t,!0)}`],[this.path,`${n} ${t.origin}${t.pathname}`]].filter(Boolean);for(let[o,s]of r){let a=o.get(s);if(!a)continue;let h=this.served.get(s)??0;return this.served.set(s,h+1),a[Math.min(h,a.length-1)]}return}fallbackShot(e){return this.archive.fallbacks.find((t)=>t.path===e)?.shot}findShell(){let e=this.archive.entries.filter((i)=>i.method==="GET"&&i.status===200&&new URL(i.url).origin===this.archive.origin&&i.headers.some(([n,r])=>n==="content-type"&&r.includes("text/html")));return new Set(e.map((i)=>i.body)).size===1?e[0]:void 0}}function k(e){return`<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Not archived</title><style>html,body{margin:0;min-height:100%;background:#f3f2ef;color:#5f5e5a;font:13px/1.5 ui-monospace,SFMono-Regular,monospace}\n@media(prefers-color-scheme:dark){html,body{background:#141413;color:#8b8a86}}\nmain{min-height:100vh;display:grid;place-items:center;text-align:center;padding:24px;box-sizing:border-box}\na{color:inherit}\nfigure{margin:0}\nimg{display:block;width:100%;height:auto}\nfigcaption{position:fixed;left:50%;bottom:16px;transform:translateX(-50%);padding:6px 12px;border-radius:999px;background:rgba(20,20,19,.86);color:#f3f2ef}</style></head>\n<body><main><div><p>${S(e)} was not archived.</p><p><a href="javascript:history.back()">Go back</a></p></div></main></body></html>`}function P(e,t){return`<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>${S(e)}</title><style>html,body{margin:0;min-height:100%;background:#f3f2ef;color:#5f5e5a;font:13px/1.5 ui-monospace,SFMono-Regular,monospace}\n@media(prefers-color-scheme:dark){html,body{background:#141413;color:#8b8a86}}\nmain{min-height:100vh;display:grid;place-items:center;text-align:center;padding:24px;box-sizing:border-box}\na{color:inherit}\nfigure{margin:0}\nimg{display:block;width:100%;height:auto}\nfigcaption{position:fixed;left:50%;bottom:16px;transform:translateX(-50%);padding:6px 12px;border-radius:999px;background:rgba(20,20,19,.86);color:#f3f2ef}</style></head>\n<body><figure><img src="${t}" alt=""><figcaption>Screenshot only · <a href="javascript:history.back()">back</a></figcaption></figure></body></html>`}function S(e){return e.replace(/[<>&"]/g,(t)=>`&#${t.charCodeAt(0)};`)}var M=new Set([301,302,303,307,308]),C="relikt-bodies";async function T(e){let t=await caches.open(C),i=new URL(w(e),self.location.origin).href,n=await t.match(i);if(n)return n;let r=await fetch(i);if(r.ok)await t.put(i,r.clone());return r}function j(e,t){let i=new URL(e,t.origin);if(i.origin!==t.origin)return i.href;return new URL(i.pathname+i.search+i.hash,self.location.origin).href}function B(e,t,i){let n=`<script>window.__relikt=${JSON.stringify(t).replace(/</g,"\\\\u003c")};${i}</script>`,r=/<head[^>]*>/i.exec(e);if(r)return e.slice(0,r.index+r[0].length)+n+e.slice(r.index+r[0].length);return n+e}async function g(e,t,i){let n=new Headers(e.headers);if(M.has(e.status)){let o=n.get("location");if(o)return Response.redirect(j(o,t),e.status)}if(!e.body||e.status===204)return new Response(null,{status:e.status,headers:n});let r=await T(e.body);if(!r.ok)return f();if(n.get("content-type")?.includes("text/html")){let{source:o,config:s}=await i();return new Response(B(await r.text(),s,o),{status:e.status,headers:n})}return new Response(r.body,{status:e.status,headers:n})}function f(){return new Response(JSON.stringify({error:"not archived"}),{status:404,headers:{"content-type":"application/json",[d]:"1"}})}function R(e){return new Response(e,{headers:{"content-type":"text/html; charset=utf-8",[d]:"1"}})}var U;function E(){return U??=(async()=>{let[e,t]=await Promise.all([fetch(v).then((r)=>r.json()),fetch(`${y}shim.js`).then((r)=>r.text())]),i=new p(e),n={origin:e.origin,origins:[...i.origins],frozenAt:e.frozenAt,storage:e.storage};return{archive:e,matcher:i,shim:{source:t,config:n}}})(),U}self.addEventListener("install",(e)=>e.waitUntil(E().then(()=>self.skipWaiting())));self.addEventListener("activate",(e)=>e.waitUntil(self.clients.claim()));async function W(e){if(e.method==="GET"||e.method==="HEAD")return;let t=await e.clone().arrayBuffer();if(t.byteLength===0)return;let i=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(i),(n)=>n.toString(16).padStart(2,"0")).join("")}async function z(e,t){(e?await self.clients.get(e):void 0)?.postMessage({type:x,url:t})}async function H(e){let{archive:t,matcher:i,shim:n}=await E(),r=e.request,o=new URL(r.url),s=o.origin===self.location.origin,a=s?new URL(o.pathname+o.search,t.origin):o,h=r.mode==="navigate",u=i.match(r.method,a,await W(r));if(u)return g(u,t,async()=>n);if(h&&s){if(i.shell)return g(i.shell,t,async()=>n);let m=i.fallbackShot(o.pathname);return R(m?P(o.pathname,b(m)):k(o.pathname))}if(r.destination==="")await z(e.clientId,a.href);return f()}self.addEventListener("fetch",(e)=>{let t=new URL(e.request.url);if(t.origin===self.location.origin&&A(t.pathname))return;if(!t.protocol.startsWith("http"))return;e.respondWith(H(e))});\n';
|
|
27575
27617
|
|
|
27576
27618
|
// src/replay/build.ts
|
|
27577
27619
|
var replayRuntimeDir = `${layout.replay}/__relikt`;
|
|
27578
27620
|
var replayBodiesDir = `${replayRuntimeDir}/${replayLayout.bodies}`;
|
|
27579
27621
|
async function writeReplay(exhibit, archive) {
|
|
27580
|
-
const root = exhibit.path(layout.replay);
|
|
27581
27622
|
const runtime = exhibit.path(replayRuntimeDir);
|
|
27582
27623
|
const shots = join14(runtime, "shots");
|
|
27583
27624
|
await rm6(shots, { recursive: true, force: true });
|
|
@@ -27592,14 +27633,7 @@ async function writeReplay(exhibit, archive) {
|
|
|
27592
27633
|
fallbacks.push({ path: new URL(part.path, archive.origin).pathname, shot: name });
|
|
27593
27634
|
}
|
|
27594
27635
|
const complete = { ...archive, fallbacks };
|
|
27595
|
-
await writeFresh(join14(root, replayLayout.bootstrap), bootstrapHtml(archive.start, exhibit.manifest.project));
|
|
27596
|
-
await writeFresh(join14(root, replayLayout.worker), sw_default);
|
|
27597
|
-
await writeFresh(join14(runtime, replayLayout.shim), shim_default);
|
|
27598
27636
|
await writeFresh(join14(runtime, replayLayout.archive), JSON.stringify(complete));
|
|
27599
|
-
for (const part of exhibit.manifest.parts) {
|
|
27600
|
-
if (part.type === "route" && part.path && !part.capture.includes("replayable"))
|
|
27601
|
-
part.capture.unshift("replayable");
|
|
27602
|
-
}
|
|
27603
27637
|
exhibit.manifest.replay = {
|
|
27604
27638
|
root: layout.replay,
|
|
27605
27639
|
start: archive.start,
|
|
@@ -27607,8 +27641,18 @@ async function writeReplay(exhibit, archive) {
|
|
|
27607
27641
|
frozenAt: new Date(archive.frozenAt).toISOString(),
|
|
27608
27642
|
requests: archive.entries.length
|
|
27609
27643
|
};
|
|
27644
|
+
await writeRuntime(exhibit);
|
|
27610
27645
|
await exhibit.save();
|
|
27611
27646
|
}
|
|
27647
|
+
async function writeRuntime(exhibit) {
|
|
27648
|
+
const { replay, project } = exhibit.manifest;
|
|
27649
|
+
if (!replay)
|
|
27650
|
+
return;
|
|
27651
|
+
const root = exhibit.path(layout.replay);
|
|
27652
|
+
await writeFresh(join14(root, replayLayout.bootstrap), bootstrapHtml(replay.start, project));
|
|
27653
|
+
await writeFresh(join14(root, replayLayout.worker), sw_default);
|
|
27654
|
+
await writeFresh(join14(exhibit.path(replayRuntimeDir), replayLayout.shim), shim_default);
|
|
27655
|
+
}
|
|
27612
27656
|
|
|
27613
27657
|
// src/replay/scrub.ts
|
|
27614
27658
|
var placeholder = "relikt-demo";
|
|
@@ -27704,6 +27748,41 @@ function scrubStorage(entries) {
|
|
|
27704
27748
|
return Object.fromEntries(entries.map(({ name, value }) => [name, sensitiveName.test(name) && !/^[{[]/.test(value.trim()) ? placeholder : scrubJsonOrText(value)]));
|
|
27705
27749
|
}
|
|
27706
27750
|
|
|
27751
|
+
// src/capture/web/links.ts
|
|
27752
|
+
async function pageLinks(page, fullPage) {
|
|
27753
|
+
return page.evaluate((fullPage) => {
|
|
27754
|
+
const offsetX = fullPage ? window.scrollX : 0;
|
|
27755
|
+
const offsetY = fullPage ? window.scrollY : 0;
|
|
27756
|
+
const right = fullPage ? document.documentElement.scrollWidth : window.innerWidth;
|
|
27757
|
+
const bottom = fullPage ? document.documentElement.scrollHeight : window.innerHeight;
|
|
27758
|
+
const here = location.pathname + location.search;
|
|
27759
|
+
const links = new Map;
|
|
27760
|
+
for (const anchor of document.querySelectorAll("a[href]")) {
|
|
27761
|
+
const url = new URL(anchor.href, location.href);
|
|
27762
|
+
const path = url.pathname + url.search;
|
|
27763
|
+
if (url.origin !== location.origin || path === here)
|
|
27764
|
+
continue;
|
|
27765
|
+
const rect = anchor.getBoundingClientRect();
|
|
27766
|
+
if (rect.width < 4 || rect.height < 4 || getComputedStyle(anchor).visibility === "hidden")
|
|
27767
|
+
continue;
|
|
27768
|
+
const x = rect.left + offsetX;
|
|
27769
|
+
const y = rect.top + offsetY;
|
|
27770
|
+
if (x < 0 || y < 0 || x + rect.width > right || y + rect.height > bottom)
|
|
27771
|
+
continue;
|
|
27772
|
+
const box = { path, x: Math.round(x), y: Math.round(y), width: Math.round(rect.width), height: Math.round(rect.height) };
|
|
27773
|
+
links.set(`${path} ${box.x} ${box.y}`, box);
|
|
27774
|
+
}
|
|
27775
|
+
return [...links.values()];
|
|
27776
|
+
}, fullPage);
|
|
27777
|
+
}
|
|
27778
|
+
async function elementBox(page, locator, fullPage) {
|
|
27779
|
+
const box = await locator.boundingBox();
|
|
27780
|
+
if (!box || box.width < 1 || box.height < 1)
|
|
27781
|
+
return;
|
|
27782
|
+
const scroll = fullPage ? await page.evaluate(() => ({ x: window.scrollX, y: window.scrollY })) : { x: 0, y: 0 };
|
|
27783
|
+
return { x: Math.round(box.x + scroll.x), y: Math.round(box.y + scroll.y), width: Math.round(box.width), height: Math.round(box.height) };
|
|
27784
|
+
}
|
|
27785
|
+
|
|
27707
27786
|
// src/capture/web/recorder.ts
|
|
27708
27787
|
import { existsSync as existsSync7 } from "node:fs";
|
|
27709
27788
|
import { mkdir as mkdir7, writeFile as writeFile7 } from "node:fs/promises";
|
|
@@ -27731,7 +27810,14 @@ class Recorder {
|
|
|
27731
27810
|
}
|
|
27732
27811
|
async drain() {
|
|
27733
27812
|
await this.settle();
|
|
27734
|
-
|
|
27813
|
+
const previous = new Map;
|
|
27814
|
+
return this.entries.sort((a, b) => a.at - b.at).filter((entry) => {
|
|
27815
|
+
const request = `${entry.method} ${entry.url} ${entry.requestBody ?? ""}`;
|
|
27816
|
+
const response = `${entry.status} ${entry.body ?? ""}`;
|
|
27817
|
+
const repeated = previous.get(request) === response;
|
|
27818
|
+
previous.set(request, response);
|
|
27819
|
+
return !repeated;
|
|
27820
|
+
}).map(({ at: _, ...entry }) => entry);
|
|
27735
27821
|
}
|
|
27736
27822
|
async storeBody(bytes) {
|
|
27737
27823
|
const hash = sha256(bytes);
|
|
@@ -27747,7 +27833,7 @@ class Recorder {
|
|
|
27747
27833
|
if (!url.startsWith("http"))
|
|
27748
27834
|
return;
|
|
27749
27835
|
const response = await request.response();
|
|
27750
|
-
if (!response)
|
|
27836
|
+
if (!response || response.status() === 304)
|
|
27751
27837
|
return;
|
|
27752
27838
|
const at = request.timing().startTime;
|
|
27753
27839
|
const headers = await response.allHeaders();
|
|
@@ -27783,6 +27869,8 @@ class WebSession {
|
|
|
27783
27869
|
start;
|
|
27784
27870
|
startedAt;
|
|
27785
27871
|
flow;
|
|
27872
|
+
shown;
|
|
27873
|
+
opener;
|
|
27786
27874
|
constructor(exhibit, browser, context, page, recorder, origin, start, startedAt) {
|
|
27787
27875
|
this.exhibit = exhibit;
|
|
27788
27876
|
this.browser = browser;
|
|
@@ -27793,7 +27881,7 @@ class WebSession {
|
|
|
27793
27881
|
this.start = start;
|
|
27794
27882
|
this.startedAt = startedAt;
|
|
27795
27883
|
}
|
|
27796
|
-
static async launch(exhibit, url, headed = false) {
|
|
27884
|
+
static async launch(exhibit, url, { headed = false, record = true } = {}) {
|
|
27797
27885
|
const target = new URL(url);
|
|
27798
27886
|
const browser = await chromium.launch({ headless: !headed });
|
|
27799
27887
|
const context = await browser.newContext({
|
|
@@ -27803,8 +27891,8 @@ class WebSession {
|
|
|
27803
27891
|
serviceWorkers: "block",
|
|
27804
27892
|
reducedMotion: "no-preference"
|
|
27805
27893
|
});
|
|
27806
|
-
const recorder = new Recorder(exhibit.path(replayBodiesDir));
|
|
27807
|
-
recorder
|
|
27894
|
+
const recorder = record ? new Recorder(exhibit.path(replayBodiesDir)) : undefined;
|
|
27895
|
+
recorder?.attach(context);
|
|
27808
27896
|
const page = await context.newPage();
|
|
27809
27897
|
const startedAt = Date.now();
|
|
27810
27898
|
await page.goto(target.href);
|
|
@@ -27818,6 +27906,7 @@ class WebSession {
|
|
|
27818
27906
|
return this.page.locator(`aria-ref=${ref}`);
|
|
27819
27907
|
}
|
|
27820
27908
|
async navigate(path) {
|
|
27909
|
+
this.opener = undefined;
|
|
27821
27910
|
await this.page.goto(new URL(path, this.origin).href);
|
|
27822
27911
|
await settle2(this.page);
|
|
27823
27912
|
}
|
|
@@ -27827,15 +27916,36 @@ class WebSession {
|
|
|
27827
27916
|
async afterAction() {
|
|
27828
27917
|
await settle2(this.page, 2500);
|
|
27829
27918
|
}
|
|
27919
|
+
async click(ref) {
|
|
27920
|
+
const target = this.locate(ref);
|
|
27921
|
+
const from = this.opener ? undefined : this.onScreen();
|
|
27922
|
+
const box = from && await elementBox(this.page, target, from.type === "route");
|
|
27923
|
+
if (from && box)
|
|
27924
|
+
this.opener = { from, box };
|
|
27925
|
+
await target.click();
|
|
27926
|
+
await this.afterAction();
|
|
27927
|
+
}
|
|
27928
|
+
onScreen() {
|
|
27929
|
+
const url = this.page.url();
|
|
27930
|
+
if (this.shown?.url === url)
|
|
27931
|
+
return this.shown.part;
|
|
27932
|
+
const { pathname, search } = new URL(url);
|
|
27933
|
+
return this.exhibit.manifest.parts.find((part) => part.type === "route" && (part.path === pathname + search || part.path === pathname));
|
|
27934
|
+
}
|
|
27830
27935
|
async capture(options) {
|
|
27831
27936
|
const type = options.type ?? "route";
|
|
27832
27937
|
if (options.path !== undefined)
|
|
27833
27938
|
await this.navigate(options.path);
|
|
27834
27939
|
const path = type === "route" ? options.path ?? new URL(this.page.url()).pathname : undefined;
|
|
27835
|
-
const
|
|
27836
|
-
const part = this.exhibit.part(id, { type, name: options.name, path });
|
|
27940
|
+
const part = this.exhibit.part({ type, name: options.name, path }, options.retake);
|
|
27837
27941
|
const viewports2 = pickViewports(viewports, options.viewports);
|
|
27838
27942
|
const themes2 = options.themes ?? [...themes];
|
|
27943
|
+
const links = await pageLinks(this.page, type === "route");
|
|
27944
|
+
this.exhibit.linkPages(part, links.map((link) => ({ ...link, viewport: home2.name })));
|
|
27945
|
+
if (options.path === undefined && this.opener && this.opener.from !== part) {
|
|
27946
|
+
this.exhibit.linkPart(this.opener.from, { ...this.opener.box, viewport: home2.name, part: part.id });
|
|
27947
|
+
}
|
|
27948
|
+
this.opener = undefined;
|
|
27839
27949
|
for (const viewport of viewports2) {
|
|
27840
27950
|
await this.page.setViewportSize({ width: viewport.width, height: viewport.height });
|
|
27841
27951
|
let light;
|
|
@@ -27851,7 +27961,7 @@ class WebSession {
|
|
|
27851
27961
|
light = image;
|
|
27852
27962
|
if (theme === "dark" && light?.equals(image))
|
|
27853
27963
|
continue;
|
|
27854
|
-
const file = shotFile(id, viewport.name, theme);
|
|
27964
|
+
const file = shotFile(part.id, viewport.name, theme);
|
|
27855
27965
|
await writeFresh(this.exhibit.path(file), image);
|
|
27856
27966
|
this.exhibit.addShot(part, {
|
|
27857
27967
|
file,
|
|
@@ -27865,7 +27975,8 @@ class WebSession {
|
|
|
27865
27975
|
}
|
|
27866
27976
|
await this.page.setViewportSize({ width: home2.width, height: home2.height });
|
|
27867
27977
|
await this.page.emulateMedia({ colorScheme: "light" });
|
|
27868
|
-
this.
|
|
27978
|
+
this.shown = { part, url: this.page.url() };
|
|
27979
|
+
this.flow?.parts.push(part.id);
|
|
27869
27980
|
await this.exhibit.save();
|
|
27870
27981
|
return part;
|
|
27871
27982
|
}
|
|
@@ -27926,6 +28037,10 @@ class WebSession {
|
|
|
27926
28037
|
async finish() {
|
|
27927
28038
|
if (this.flow)
|
|
27928
28039
|
await this.stopFlow();
|
|
28040
|
+
if (!this.recorder) {
|
|
28041
|
+
await this.browser.close();
|
|
28042
|
+
return;
|
|
28043
|
+
}
|
|
27929
28044
|
const entries = await this.recorder.drain();
|
|
27930
28045
|
const state = await this.context.storageState();
|
|
27931
28046
|
const storage = state.origins.find((origin) => origin.origin === this.origin)?.localStorage ?? [];
|
|
@@ -27979,6 +28094,83 @@ async function recognize(exhibit) {
|
|
|
27979
28094
|
return result;
|
|
27980
28095
|
}
|
|
27981
28096
|
|
|
28097
|
+
// src/replay/verify.ts
|
|
28098
|
+
import { readFile as readFile8 } from "node:fs/promises";
|
|
28099
|
+
import { chromium as chromium2 } from "playwright-core";
|
|
28100
|
+
var { laptop } = viewports;
|
|
28101
|
+
var unfamiliarAddress = "::1";
|
|
28102
|
+
function dataUrl(png) {
|
|
28103
|
+
return `data:image/png;base64,${png.toString("base64")}`;
|
|
28104
|
+
}
|
|
28105
|
+
async function matches(scratch, captured, replayed) {
|
|
28106
|
+
return scratch.evaluate(async ({ captured, replayed, aspect }) => {
|
|
28107
|
+
const width = 24;
|
|
28108
|
+
const tolerance = 16;
|
|
28109
|
+
const height = Math.round(width * aspect);
|
|
28110
|
+
const luminance = async (src) => {
|
|
28111
|
+
const image = new Image;
|
|
28112
|
+
image.src = src;
|
|
28113
|
+
await image.decode();
|
|
28114
|
+
const canvas = new OffscreenCanvas(width, height);
|
|
28115
|
+
const context = canvas.getContext("2d", { willReadFrequently: true });
|
|
28116
|
+
context.drawImage(image, 0, 0, image.naturalWidth, image.naturalWidth * aspect, 0, 0, width, height);
|
|
28117
|
+
const { data } = context.getImageData(0, 0, width, height);
|
|
28118
|
+
const values = new Uint8Array(width * height);
|
|
28119
|
+
for (let index = 0;index < values.length; index++) {
|
|
28120
|
+
values[index] = Math.round(0.299 * data[index * 4] + 0.587 * data[index * 4 + 1] + 0.114 * data[index * 4 + 2]);
|
|
28121
|
+
}
|
|
28122
|
+
return values;
|
|
28123
|
+
};
|
|
28124
|
+
const [expected, actual] = await Promise.all([luminance(captured), luminance(replayed)]);
|
|
28125
|
+
const histogram = new Uint32Array(32);
|
|
28126
|
+
for (const value of expected)
|
|
28127
|
+
histogram[value >> 3]++;
|
|
28128
|
+
const background = histogram.indexOf(Math.max(...histogram)) * 8 + 4;
|
|
28129
|
+
let content = 0;
|
|
28130
|
+
let different = 0;
|
|
28131
|
+
for (let index = 0;index < expected.length; index++) {
|
|
28132
|
+
if (Math.abs(expected[index] - background) > tolerance)
|
|
28133
|
+
content++;
|
|
28134
|
+
if (Math.abs(expected[index] - actual[index]) > tolerance)
|
|
28135
|
+
different++;
|
|
28136
|
+
}
|
|
28137
|
+
return different <= content / 2;
|
|
28138
|
+
}, { captured: dataUrl(captured), replayed: dataUrl(replayed), aspect: laptop.height / laptop.width });
|
|
28139
|
+
}
|
|
28140
|
+
async function verifyReplay(exhibit) {
|
|
28141
|
+
await writeRuntime(exhibit);
|
|
28142
|
+
const routes = exhibit.manifest.parts.flatMap((part) => {
|
|
28143
|
+
const shot = part.shots.find((candidate) => candidate.viewport === laptop.name && candidate.theme !== "dark");
|
|
28144
|
+
return part.type === "route" && part.path && shot ? [{ part, shot }] : [];
|
|
28145
|
+
});
|
|
28146
|
+
if (!routes.length)
|
|
28147
|
+
return [];
|
|
28148
|
+
const server = await serveReplay(exhibit, 0, unfamiliarAddress);
|
|
28149
|
+
const browser = await chromium2.launch();
|
|
28150
|
+
const replayable = [];
|
|
28151
|
+
try {
|
|
28152
|
+
const context = await browser.newContext({ viewport: { width: laptop.width, height: laptop.height }, colorScheme: "light" });
|
|
28153
|
+
const page = await context.newPage();
|
|
28154
|
+
const scratch = await context.newPage();
|
|
28155
|
+
await page.goto(server.url);
|
|
28156
|
+
await page.evaluate(() => navigator.serviceWorker.ready.then(() => true));
|
|
28157
|
+
for (const { part, shot } of routes) {
|
|
28158
|
+
const response = await page.goto(new URL(part.path, server.url).href);
|
|
28159
|
+
await settle2(page);
|
|
28160
|
+
const archived = !response?.headers()[notArchivedHeader];
|
|
28161
|
+
const works = archived && await matches(scratch, await readFile8(exhibit.path(shot.file)), await page.screenshot());
|
|
28162
|
+
exhibit.markReplayable(part, works);
|
|
28163
|
+
if (works)
|
|
28164
|
+
replayable.push(part.id);
|
|
28165
|
+
}
|
|
28166
|
+
} finally {
|
|
28167
|
+
await browser.close();
|
|
28168
|
+
server.close();
|
|
28169
|
+
}
|
|
28170
|
+
await exhibit.save();
|
|
28171
|
+
return replayable;
|
|
28172
|
+
}
|
|
28173
|
+
|
|
27982
28174
|
// src/sync/push.ts
|
|
27983
28175
|
import { createReadStream as createReadStream3 } from "node:fs";
|
|
27984
28176
|
import { open as open3 } from "node:fs/promises";
|
|
@@ -28049,7 +28241,7 @@ async function preserveWeb(exhibit, url) {
|
|
|
28049
28241
|
const routes = await web.discoverRoutes();
|
|
28050
28242
|
for (const [index, path] of routes.entries()) {
|
|
28051
28243
|
console.log(`[${index + 1}/${routes.length}] ${path}`);
|
|
28052
|
-
await web.capture({ name: routeName(path), path });
|
|
28244
|
+
await web.capture({ name: exhibit.freeName(routeName(path)), path });
|
|
28053
28245
|
}
|
|
28054
28246
|
await web.finish();
|
|
28055
28247
|
}
|
|
@@ -28068,7 +28260,14 @@ async function preserveDesktop(exhibit, command, electron) {
|
|
|
28068
28260
|
}
|
|
28069
28261
|
async function preserveCommand(project, options) {
|
|
28070
28262
|
const kind = Kind.parse(options.kind);
|
|
28071
|
-
const exhibit = await Exhibit.create({
|
|
28263
|
+
const exhibit = await Exhibit.create({
|
|
28264
|
+
project,
|
|
28265
|
+
kind,
|
|
28266
|
+
reason: Reason.parse(options.reason),
|
|
28267
|
+
label: options.label,
|
|
28268
|
+
date: options.date,
|
|
28269
|
+
cwd: process.cwd()
|
|
28270
|
+
});
|
|
28072
28271
|
console.log(exhibit.dir);
|
|
28073
28272
|
if (kind === "web") {
|
|
28074
28273
|
if (!options.url)
|
|
@@ -28080,6 +28279,8 @@ async function preserveCommand(project, options) {
|
|
|
28080
28279
|
throw new Error("Pass --command with the command that starts the app");
|
|
28081
28280
|
await preserveDesktop(exhibit, options.command, options.electron);
|
|
28082
28281
|
}
|
|
28282
|
+
if (exhibit.manifest.replay)
|
|
28283
|
+
await verifyReplay(exhibit);
|
|
28083
28284
|
if (await gitRoot(process.cwd()))
|
|
28084
28285
|
await addSourceTarball(exhibit, process.cwd());
|
|
28085
28286
|
if (exhibit.manifest.parts.length)
|
|
@@ -36672,7 +36873,7 @@ class StdioServerTransport {
|
|
|
36672
36873
|
// package.json
|
|
36673
36874
|
var package_default = {
|
|
36674
36875
|
name: "@kaleidal/relikt",
|
|
36675
|
-
version: "0.1.
|
|
36876
|
+
version: "0.1.3",
|
|
36676
36877
|
description: "Preserve software before it is killed or redesigned: screenshots, flows, offline replays and the actual files.",
|
|
36677
36878
|
keywords: [
|
|
36678
36879
|
"archive",
|
|
@@ -36764,7 +36965,8 @@ function registerCaptureTools(server) {
|
|
|
36764
36965
|
type: _enum(partTypes).optional().describe("Defaults to 'route' for websites and 'window' for desktop apps"),
|
|
36765
36966
|
viewports: array(_enum(viewportNames)).optional().describe("Websites: mobile, laptop, wide. Desktop apps: narrow, laptop, wide."),
|
|
36766
36967
|
themes: array(_enum(themes)).optional(),
|
|
36767
|
-
cover: boolean2().optional().describe("Use this part as the exhibit's cover image")
|
|
36968
|
+
cover: boolean2().optional().describe("Use this part as the exhibit's cover image"),
|
|
36969
|
+
retake: boolean2().optional().describe("Replace the shots of the part already captured under this name. Without it, reusing a name is an error.")
|
|
36768
36970
|
}
|
|
36769
36971
|
}, async ({ cover, ...input }) => {
|
|
36770
36972
|
const part = await requireCapturing().capture(input);
|
|
@@ -36883,6 +37085,7 @@ function registerExhibitTools(server) {
|
|
|
36883
37085
|
reason: _enum(reasons),
|
|
36884
37086
|
label: string2().optional().describe("Short label, e.g. 'before v2'. Defaults to the reason."),
|
|
36885
37087
|
title: string2().optional(),
|
|
37088
|
+
date: exports_iso.date().optional().describe("The day this snapshot stands for, as yyyy-mm-dd. Defaults to today; for a project killed earlier, use the date of its last commit."),
|
|
36886
37089
|
cwd: string2().describe("Absolute path of the project's repository")
|
|
36887
37090
|
}
|
|
36888
37091
|
}, async (input) => {
|
|
@@ -36916,7 +37119,7 @@ function registerExhibitTools(server) {
|
|
|
36916
37119
|
return text("notes.md written");
|
|
36917
37120
|
});
|
|
36918
37121
|
server.registerTool("exhibit_finalize", {
|
|
36919
|
-
description: "OCR every screenshot, deduplicate files into the archive's object store and, when signed in, upload the exhibit to relikt.dev.",
|
|
37122
|
+
description: "Check which routes work in the offline replay, OCR every screenshot, deduplicate files into the archive's object store and, when signed in, upload the exhibit to relikt.dev.",
|
|
36920
37123
|
inputSchema: { upload: boolean2().default(true) }
|
|
36921
37124
|
}, async ({ upload }) => {
|
|
36922
37125
|
const exhibit = requireExhibit();
|
|
@@ -36924,13 +37127,15 @@ function registerExhibitTools(server) {
|
|
|
36924
37127
|
throw new Error("A browser session is still running. Call web_finish first.");
|
|
36925
37128
|
if (session.desktop)
|
|
36926
37129
|
throw new Error("A desktop app is still running. Call desktop_finish first.");
|
|
37130
|
+
const replayable = exhibit.manifest.replay ? (await verifyReplay(exhibit)).length : 0;
|
|
36927
37131
|
await recognize(exhibit);
|
|
37132
|
+
const replay = exhibit.manifest.replay ? ` ${replayable} routes work in the replay; the rest show screenshots.` : "";
|
|
36928
37133
|
if (!upload) {
|
|
36929
37134
|
await snapshotFiles(exhibit);
|
|
36930
|
-
return text(`Finalized at ${exhibit.dir}`);
|
|
37135
|
+
return text(`Finalized at ${exhibit.dir}.${replay}`);
|
|
36931
37136
|
}
|
|
36932
37137
|
const result = await push(await Api.connect(), exhibit);
|
|
36933
|
-
return text(`Finalized at ${exhibit.dir} and uploaded to ${result.url}`);
|
|
37138
|
+
return text(`Finalized at ${exhibit.dir} and uploaded to ${result.url}.${replay}`);
|
|
36934
37139
|
});
|
|
36935
37140
|
}
|
|
36936
37141
|
|
|
@@ -36946,11 +37151,12 @@ function registerWebTools(server) {
|
|
|
36946
37151
|
description: "Open the locally running app in a recording browser. Every response is recorded for the replay. Run the app against seeded demo data, never a real account.",
|
|
36947
37152
|
inputSchema: {
|
|
36948
37153
|
url: string2().url().describe("Where the app runs locally, e.g. http://localhost:5173/"),
|
|
36949
|
-
headed: boolean2().default(false)
|
|
37154
|
+
headed: boolean2().default(false),
|
|
37155
|
+
record: boolean2().default(true).describe("Record responses for the offline replay. Turn off to add screens to an exhibit whose replay is already built.")
|
|
36950
37156
|
}
|
|
36951
|
-
}, async ({ url, headed }) => {
|
|
37157
|
+
}, async ({ url, headed, record }) => {
|
|
36952
37158
|
requireIdle();
|
|
36953
|
-
session.web = await WebSession.launch(requireExhibit(), url, headed);
|
|
37159
|
+
session.web = await WebSession.launch(requireExhibit(), url, { headed, record });
|
|
36954
37160
|
return snapshotResult();
|
|
36955
37161
|
});
|
|
36956
37162
|
server.registerTool("web_snapshot", { description: "Accessibility snapshot of the current page with [ref=…] handles." }, snapshotResult);
|
|
@@ -36960,9 +37166,7 @@ function registerWebTools(server) {
|
|
|
36960
37166
|
return snapshotResult();
|
|
36961
37167
|
});
|
|
36962
37168
|
server.registerTool("web_click", { description: "Click an element by its snapshot ref.", inputSchema: { ref: string2() } }, async ({ ref }) => {
|
|
36963
|
-
|
|
36964
|
-
await web.locate(ref).click();
|
|
36965
|
-
await web.afterAction();
|
|
37169
|
+
await requireWeb().click(ref);
|
|
36966
37170
|
return snapshotResult();
|
|
36967
37171
|
});
|
|
36968
37172
|
server.registerTool("web_hover", { description: "Hover an element by its snapshot ref.", inputSchema: { ref: string2() } }, async ({ ref }) => {
|
|
@@ -37004,7 +37208,7 @@ function registerWebTools(server) {
|
|
|
37004
37208
|
await web.finish();
|
|
37005
37209
|
session.web = undefined;
|
|
37006
37210
|
const replay = web.exhibit.manifest.replay;
|
|
37007
|
-
return text(`Replay
|
|
37211
|
+
return text(replay ? `Replay has ${replay.requests} recorded requests` : "Browser closed");
|
|
37008
37212
|
});
|
|
37009
37213
|
}
|
|
37010
37214
|
|
|
@@ -37012,7 +37216,7 @@ function registerWebTools(server) {
|
|
|
37012
37216
|
var instructions = `Relikt preserves software as exhibits: systematic screenshots, flow videos, a clickable offline replay for websites, and the real artifacts, in a plain folder that outlives the project.
|
|
37013
37217
|
|
|
37014
37218
|
To preserve a project:
|
|
37015
|
-
1. exhibit_create with the project's repository as cwd.
|
|
37219
|
+
1. exhibit_create with the project's repository as cwd. If the project was killed or frozen before today, pass the date of its last commit.
|
|
37016
37220
|
2. Run the app locally against seeded demo data (never a real account).
|
|
37017
37221
|
3. Capture every part of it (see below for websites and desktop apps).
|
|
37018
37222
|
4. Record flows for key interactions and anything animated with flow_start / flow_stop.
|
|
@@ -37023,7 +37227,7 @@ To preserve a project:
|
|
|
37023
37227
|
Websites:
|
|
37024
37228
|
- web_start with the app's local URL.
|
|
37025
37229
|
- Build a complete route list: read the router or pages directory in the source, then web_discover_routes, and merge both.
|
|
37026
|
-
- capture every route (path), then every dialog, menu, sheet and empty/error state reachable by interaction (type 'dialog', no path). Sign in through the app's own login screen so it is recorded too.
|
|
37230
|
+
- capture every route (path), then every dialog, menu, sheet and empty/error state reachable by interaction (type 'dialog', no path). Open each one by clicking from the screen it belongs to and capture it right away: that click becomes a clickable spot linking the two screenshots. Sign in through the app's own login screen so it is recorded too.
|
|
37027
37231
|
- Click through everything a visitor would try, so the replay has the responses it needs. Then web_finish.
|
|
37028
37232
|
|
|
37029
37233
|
Desktop apps (GTK, libadwaita, Qt, Flatpak, AppImage, Electron):
|
|
@@ -37061,10 +37265,10 @@ async function serveMcp() {
|
|
|
37061
37265
|
// src/main.ts
|
|
37062
37266
|
var help = `relikt ${version2}
|
|
37063
37267
|
|
|
37064
|
-
relikt preserve <project> --reason <killed|redesign|milestone> [--label <text>] [--no-upload]
|
|
37268
|
+
relikt preserve <project> --reason <killed|redesign|milestone> [--label <text>] [--date <yyyy-mm-dd>] [--no-upload]
|
|
37065
37269
|
[--kind web] --url <local url>
|
|
37066
37270
|
--kind desktop --command <command that starts the app> [--electron]
|
|
37067
|
-
relikt new <project> --kind <kind> --reason <reason> [--label <text>]
|
|
37271
|
+
relikt new <project> --kind <kind> --reason <reason> [--label <text>] [--date <yyyy-mm-dd>]
|
|
37068
37272
|
relikt add <exhibit> <file...> [--target <text>] [--platform <name>] [--arch <name>]
|
|
37069
37273
|
relikt list
|
|
37070
37274
|
relikt replay [exhibit] [--port 4870]
|
|
@@ -37083,6 +37287,7 @@ var { values, positionals } = parseArgs({
|
|
|
37083
37287
|
options: {
|
|
37084
37288
|
reason: { type: "string" },
|
|
37085
37289
|
label: { type: "string" },
|
|
37290
|
+
date: { type: "string" },
|
|
37086
37291
|
kind: { type: "string" },
|
|
37087
37292
|
url: { type: "string" },
|
|
37088
37293
|
command: { type: "string" },
|
|
@@ -37109,6 +37314,7 @@ var commands = {
|
|
|
37109
37314
|
reason: required2(values.reason, "--reason"),
|
|
37110
37315
|
kind: values.kind ?? "web",
|
|
37111
37316
|
label: values.label,
|
|
37317
|
+
date: values.date,
|
|
37112
37318
|
url: values.url,
|
|
37113
37319
|
command: values.command,
|
|
37114
37320
|
electron: values.electron,
|
|
@@ -37117,7 +37323,8 @@ var commands = {
|
|
|
37117
37323
|
new: () => newCommand(required2(rest[0], "<project>"), {
|
|
37118
37324
|
kind: required2(values.kind, "--kind"),
|
|
37119
37325
|
reason: required2(values.reason, "--reason"),
|
|
37120
|
-
label: values.label
|
|
37326
|
+
label: values.label,
|
|
37327
|
+
date: values.date
|
|
37121
37328
|
}),
|
|
37122
37329
|
add: () => addCommand(required2(rest[0], "<exhibit>"), rest.slice(1), values),
|
|
37123
37330
|
list: listCommand,
|