refactor(web): use the canonical channel entry
Remove the duplicate channel-preview route and move its launcher, owner-link, acceptance and documentation callers to the existing root URL. Query and invitation fragments retain their meaning. App launcher and component preview routes stay separate. Route, session and built-server protocol checks pass.
This commit is contained in:
1 parent
3476723ca0
commit
7a7ff696ca
11 files changed
+28
-35
No files matched your search
@@ -38,10 +38,9 @@ node scripts/build-channel-web.mjs
|
||||
```
|
||||
|
||||
The ignored `build/channel-web/` directory contains the HTML, styles, JavaScript
|
||||
and WASM. This entry mounts the same functional page as `/__channel-preview`,
|
||||
sharing its session, components, theme and language preferences. The
|
||||
and WASM. The
|
||||
[Rust service](../channel-server/README.md#run) can serve this directory directly.
|
||||
A separate web host must serve `index.html` for `/` and `/__channel-preview`,
|
||||
A separate web host must serve `index.html` for `/`,
|
||||
route the existing `/prototype/channel` WebSocket to the domain service on the
|
||||
same origin, and serve WASM as `application/wasm`.
|
||||
Node, Vite and the WASM tools are build dependencies; the deployed App or Server
|
||||
|
||||
@@ -156,7 +156,7 @@ cargo +1.91.0 run --manifest-path prototype/channel-server/Cargo.toml -- owner-l
|
||||
With a packaged Server, run `./piik-server owner-link` (Windows: `.\piik-server.exe owner-link`).
|
||||
Open the printed link in your owner browser profile within 60 seconds. It can be used once.
|
||||
The browser saves the owner credential for later visits. Ordinary users open
|
||||
`http://127.0.0.1:8790/__channel-preview` directly and can create their own rooms.
|
||||
`http://127.0.0.1:8790/` directly and can create their own rooms.
|
||||
Beside a room title, copy its public-room link or, as its owner, a private-room
|
||||
invitation. Private-room admission is handled after joining the site.
|
||||
Separate browser profiles represent separate users; tabs in one profile share a saved user credential but
|
||||
@@ -188,7 +188,7 @@ For a standalone source deployment, build the
|
||||
[same frontend as static assets](../channel-browser/README.md), then set
|
||||
`PIIK_CHANNEL_WEB_DIR` to `build/channel-web/` and `PIIK_CHANNEL_WEB_ORIGIN` to
|
||||
the service's own origin. Rust serves the frontend and existing WebSocket on
|
||||
that listener. `/` and `/__channel-preview` open the frontend; missing assets
|
||||
that listener. `/` opens the frontend. Missing assets
|
||||
and unknown API paths return 404. Vite is only the development server; the
|
||||
deployed frontend requires no Node runtime.
|
||||
|
||||
|
||||
@@ -814,7 +814,7 @@ async function roomOwner(initial, serverRoom) {
|
||||
assert((await sample(0)).captures.some(track => track.kind === "video" && track.state === "live"));
|
||||
assert.equal((await view(0)).state.pairs.find(pair => pair.peerId === viewerSession).id, sharedPair);
|
||||
await progressing(2, serverPicture);
|
||||
await browser(1, "open", `${origin}/__channel-preview`);
|
||||
await browser(1, "open", `${origin}/`);
|
||||
await until("reopened owner restores the saved room", () => view(1), value => value.connection === "connected" &&
|
||||
value.state.channel.rooms.some(entry => entry.id === room && entry.authorized && entry.available !== false));
|
||||
await action(1, `browse(${JSON.stringify(room)})`);
|
||||
@@ -1208,7 +1208,7 @@ async function profileControls(roomId, messageId) {
|
||||
}), value => !value.sessions.some(session => session.userId === member.id && session.online)
|
||||
&& value.profile?.name === name && value.profile.avatar === avatar
|
||||
&& value.message.name === name && value.message.avatar === avatar);
|
||||
await browser(1, "open", `${origin}/__channel-preview#room=${encodeURIComponent(roomId)}`);
|
||||
await browser(1, "open", `${origin}/#room=${encodeURIComponent(roomId)}`);
|
||||
await reenter();
|
||||
if (!await evaluate(0, "document.querySelector('#c3-people')?.checkVisibility() ?? false"))
|
||||
await browser(0, "click", "#c3-companion-trigger");
|
||||
@@ -1452,7 +1452,7 @@ try {
|
||||
}
|
||||
await writeFile(script, probe);
|
||||
}
|
||||
await browser(index, "open", `${origin}/__channel-preview${index === 0 ? `#owner=${encodeURIComponent(ownerKey)}` : ""}`);
|
||||
await browser(index, "open", `${origin}/${index === 0 ? `#owner=${encodeURIComponent(ownerKey)}` : ""}`);
|
||||
}
|
||||
const initial = [];
|
||||
for (const index of active) {
|
||||
|
||||
@@ -41,7 +41,7 @@ const rows = () => sample(`[...document.querySelectorAll('#c3-people .c3-user')]
|
||||
const more = '#c3-people button[aria-label="More people"]';
|
||||
const retry = '#c3-people button[aria-label="Retry"]';
|
||||
try {
|
||||
await browser(0, "open", `${origin}/__channel-preview`);
|
||||
await browser(0, "open", `${origin}/`);
|
||||
await sample("localStorage.setItem('piik:ui-lang', 'en')");
|
||||
await browser(0, "reload");
|
||||
await until("browser joins", () => sample(`${gate}?.snapshot().connection`), value => value === "connected");
|
||||
|
||||
@@ -32,7 +32,7 @@ export async function appRoom({ initial, serverRoom, browser, action, view, eval
|
||||
const assets = resolve(process.env.PIIK_CHANNEL_APP_WEB_DIR ?? "build/channel-web");
|
||||
const executable = resolve(process.env.CHANNEL_APP_EXECUTABLE ??
|
||||
`prototype/channel-server/target/debug/piik-channel-app${process.platform === "win32" ? ".exe" : ""}`);
|
||||
const url = `${origin}/__channel-preview?piik-client-port=${port}#piik-client=1`;
|
||||
const url = `${origin}/?piik-client-port=${port}#piik-client=1`;
|
||||
let app, otherServer, otherWeb, approvalTab, personalTab, log = "";
|
||||
const sourceLayers = [];
|
||||
const start = () => {
|
||||
@@ -501,7 +501,7 @@ export async function appRoom({ initial, serverRoom, browser, action, view, eval
|
||||
await approve(otherOrigin);
|
||||
const firstDomainTab = (await browser(0, "tab")).tabs.find(tab => tab.active).targetId;
|
||||
await browser(0, "tab", "new",
|
||||
`${otherOrigin}/__channel-preview?piik-client-port=${port}#owner=${otherOwner}&piik-client=1`);
|
||||
`${otherOrigin}/?piik-client-port=${port}#owner=${otherOwner}&piik-client=1`);
|
||||
await until("second Site admits its own Browser user", () => view(0), value => value.connection === "connected");
|
||||
await appReady(0);
|
||||
const otherIdentity = (await view(0)).self.id;
|
||||
|
||||
@@ -20,7 +20,7 @@ export function readContract(text) {
|
||||
const fragment = new URLSearchParams(url.hash.slice(1));
|
||||
assert(url.protocol === "https:" && /^[a-z0-9-]+\.trycloudflare\.com$/.test(url.hostname)
|
||||
&& !url.username && !url.password && !url.port && !url.search
|
||||
&& ["/", "/__channel-preview"].includes(url.pathname), "invalid_lab_origin");
|
||||
&& url.pathname === "/", "invalid_lab_origin");
|
||||
assert([...fragment.keys()].every(key => ["invite", "room"].includes(key)), "invalid_room_link_fields");
|
||||
assert(fragment.get("room") === value.roomId, "invitation_room_mismatch");
|
||||
for (const field of ["roomId", "hostSessionId", "sourceSessionId", "publicationId"])
|
||||
|
||||
@@ -152,7 +152,7 @@ async fn main() -> anyhow::Result<std::process::ExitCode> {
|
||||
)?;
|
||||
let operator = owner_link::Listener::bind(&directory)?;
|
||||
println!("Piik Server: http://{bound}");
|
||||
println!("Web interface: {origin}/__channel-preview");
|
||||
println!("Web interface: {origin}/");
|
||||
release::startup_notice();
|
||||
let operator_domain = state.clone();
|
||||
let (stop_server, operator_stopped) = tokio::sync::oneshot::channel();
|
||||
|
||||
@@ -27,7 +27,7 @@ pub async fn request(directory: &Path) -> Result<String> {
|
||||
pub use transport::Listener;
|
||||
|
||||
pub async fn serve(mut listener: Listener, domain: &Domain) -> Result<()> {
|
||||
let target = url::Url::parse(domain.origin())?.join("/__channel-preview")?;
|
||||
let target = url::Url::parse(domain.origin())?.join("/")?;
|
||||
loop {
|
||||
let mut stream = listener.accept().await?;
|
||||
let Ok(ticket) = domain.launch_ticket() else {
|
||||
|
||||
@@ -126,7 +126,6 @@ pub fn frontend(directory: &Path) -> anyhow::Result<Router> {
|
||||
Ok(Router::new()
|
||||
.merge(bundle_routes(directory)?)
|
||||
.route("/", document(index.clone()))
|
||||
.route("/__channel-preview", document(index.clone()))
|
||||
.route("/index.html", document(index.clone()))
|
||||
.fallback_service(static_files(
|
||||
ServeDir::new(directory).append_index_html_on_directories(false),
|
||||
@@ -520,12 +519,7 @@ mod tests {
|
||||
fs::remove_file(directory.join("assets/new.js")).unwrap();
|
||||
fs::write(directory.join("assets/old.js"), "old").unwrap();
|
||||
let mut responses = Vec::new();
|
||||
for path in [
|
||||
"/",
|
||||
"/__channel-preview",
|
||||
"/index.html",
|
||||
"/spa/client/route",
|
||||
] {
|
||||
for path in ["/", "/index.html", "/spa/client/route"] {
|
||||
for modified in [&cached_modified[..], "Thu, 01 Jan 2099 00:00:00 GMT"] {
|
||||
responses.push(request(address, path, Some(modified)).await);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user