@volter/world-console 3.0.8 → 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 +14 -19
- package/dist/client/console.bundle.js +13 -13
- package/dist/client/console.tsx +14 -19
- package/dist/client/main.bundle.js +65 -65
- package/package.json +3 -3
package/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,22 +1768,19 @@ 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
|
-
|
|
1779
|
-
|
|
1780
|
-
const
|
|
1781
|
-
// the copy's own answer may be a 404 page (an account not there yet); the door's refusals are not
|
|
1782
|
-
const here = await fetch(beside, { method: 'HEAD', credentials: 'same-origin' }).then((r) => ![401, 403, 501, 503].includes(r.status), () => false);
|
|
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);
|
|
1783
1781
|
if (closed) return;
|
|
1784
|
-
if (
|
|
1785
|
-
|
|
1786
|
-
setBefore({ state: 'ok', url: `${o.origin}/-/${b.name}/session/hand-off#${new URLSearchParams({ token: b.readToken, land: `/${b.name}/${frame.vendor}${shown.screen}` }).toString()}`, at, opens: true });
|
|
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 });
|
|
1787
1784
|
})(), 500);
|
|
1788
1785
|
// the copy goes with the comparison, and with the page: a reload or a closed tab runs no cleanup of its own
|
|
1789
1786
|
const drop = (): void => { if (made) void door(token, `/-/${name}/branches/${made}`, { method: 'DELETE', keepalive: true }).catch(() => null); made = null; };
|
|
@@ -1803,9 +1800,7 @@ function Compare({ name, token, frame, onClose, reads }: { name: string; token:
|
|
|
1803
1800
|
<div className="compare-sides">
|
|
1804
1801
|
<figure>
|
|
1805
1802
|
<figcaption>Before{before.state === 'ok' ? ` · as of ${when(before.at)}` : ''}</figcaption>
|
|
1806
|
-
{before.state === 'ok' ?
|
|
1807
|
-
? <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>
|
|
1808
|
-
: <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>}
|
|
1809
1804
|
</figure>
|
|
1810
1805
|
<figure>
|
|
1811
1806
|
<figcaption>Now</figcaption>
|