@volter/world-console 3.0.7 → 3.0.9
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/client/console.tsx +21 -13
- package/dist/client/console.bundle.js +13 -13
- package/dist/client/console.tsx +21 -13
- package/dist/client/main.bundle.js +69 -69
- package/package.json +3 -3
package/dist/client/console.tsx
CHANGED
|
@@ -1752,7 +1752,7 @@ function Thumb({ url, title }: { url: string; title: string }): React.JSX.Elemen
|
|
|
1752
1752
|
* was the moment before the first of them beside how it is now. "Before" is a read-only copy of the World as of then (a
|
|
1753
1753
|
* branch the World makes for an hour, removed when this closes), its site read at the copy's own address. */
|
|
1754
1754
|
function Compare({ name, token, frame, onClose, reads }: { name: string; token: string; frame: BoardFrame; onClose: () => void; /** the board's reads so far: its changes are read again with each */ reads: number }): React.JSX.Element {
|
|
1755
|
-
const [before, setBefore] = useState<{ state: 'opening' } | { state: 'ok'; url: string; at: string
|
|
1755
|
+
const [before, setBefore] = useState<{ state: 'opening' } | { state: 'ok'; url: string; at: string } | { state: 'none'; why: string }>({ state: 'opening' });
|
|
1756
1756
|
// its changes, read for this comparison alone
|
|
1757
1757
|
const listed = useDoor<{ total: number; acts: BoardAct[] }>(token, `/-/${name}/board/changes?frame=${encodeURIComponent(frameKey(frame))}`, reads);
|
|
1758
1758
|
useEffect(() => {
|
|
@@ -1768,16 +1768,26 @@ function Compare({ name, token, frame, onClose, reads }: { name: string; token:
|
|
|
1768
1768
|
const b = (await r.json()) as { name: string; origin?: string; readToken?: string };
|
|
1769
1769
|
made = b.name;
|
|
1770
1770
|
if (closed) { void door(token, `/-/${name}/branches/${b.name}`, { method: 'DELETE' }).catch(() => null); return; }
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1771
|
+
// a site at the copy's own address; a vendor's page on the copy's own content plane, opened through this World's
|
|
1772
|
+
// branch door (a one-time read pass): framed beside this World's page, never running on this World's origin
|
|
1773
|
+
if ('site' in shown) {
|
|
1774
|
+
const o = httpOrigin(b.origin);
|
|
1775
|
+
if (!o) { setBefore({ state: 'none', why: 'This World shows sites only at its own local address.' }); return; }
|
|
1776
|
+
const u = new URL(frame.url); setBefore({ state: 'ok', url: `${o.protocol}//${u.hostname}.${o.host}${u.pathname}${u.search}`, at }); return;
|
|
1777
|
+
}
|
|
1778
|
+
const beside = `${WORLDS}/-/${name}/branches/${b.name}/pages?${new URLSearchParams({ land: `/${b.name}/${frame.vendor}${shown.screen}` }).toString()}`;
|
|
1779
|
+
// the door answers a navigation with the copy's address; a host that shows no content plane says so instead
|
|
1780
|
+
const asked = await fetch(beside, { credentials: 'same-origin', redirect: 'manual' }).catch(() => null);
|
|
1781
|
+
if (closed) return;
|
|
1782
|
+
if (asked?.type !== 'opaqueredirect') { setBefore({ state: 'none', why: `This World does not show its copy's pages${asked ? `: ${await failure(asked)}` : ''}.` }); return; }
|
|
1783
|
+
setBefore({ state: 'ok', url: beside, at });
|
|
1779
1784
|
})(), 500);
|
|
1780
|
-
|
|
1785
|
+
// the copy goes with the comparison, and with the page: a reload or a closed tab runs no cleanup of its own
|
|
1786
|
+
const drop = (): void => { if (made) void door(token, `/-/${name}/branches/${made}`, { method: 'DELETE', keepalive: true }).catch(() => null); made = null; };
|
|
1787
|
+
// a page kept for back and forward keeps its copy: it may be shown again
|
|
1788
|
+
const left = (e: PageTransitionEvent): void => { if (!e.persisted) drop(); };
|
|
1789
|
+
window.addEventListener('pagehide', left);
|
|
1790
|
+
return () => { closed = true; clearTimeout(wait); window.removeEventListener('pagehide', left); drop(); };
|
|
1781
1791
|
}, [name, token, frame.vendor, frame.id, frame.since]);
|
|
1782
1792
|
const now = frameUrl(name, frame);
|
|
1783
1793
|
return (
|
|
@@ -1790,9 +1800,7 @@ function Compare({ name, token, frame, onClose, reads }: { name: string; token:
|
|
|
1790
1800
|
<div className="compare-sides">
|
|
1791
1801
|
<figure>
|
|
1792
1802
|
<figcaption>Before{before.state === 'ok' ? ` · as of ${when(before.at)}` : ''}</figcaption>
|
|
1793
|
-
{before.state === 'ok' ?
|
|
1794
|
-
? <p className="mode compare-note"><a href={before.url} target="_blank" rel="noopener noreferrer">Open {frame.title} as it was →</a><br />A read-only copy of the World, kept while this comparison is open.</p>
|
|
1795
|
-
: <Thumb url={before.url} title={`${frame.title} before`} />) : before.state === 'opening' ? <p className="mode compare-note" role="status">Opening the World as it was…</p> : <p className="mode compare-note">{before.why}</p>}
|
|
1803
|
+
{before.state === 'ok' ? <Thumb url={before.url} title={`${frame.title} before`} /> : before.state === 'opening' ? <p className="mode compare-note" role="status">Opening the World as it was…</p> : <p className="mode compare-note">{before.why}</p>}
|
|
1796
1804
|
</figure>
|
|
1797
1805
|
<figure>
|
|
1798
1806
|
<figcaption>Now</figcaption>
|