Files
zeekay 6c65e3e941 @hanzo/app 0.2.0: the app SDK, renamed from @hanzo/rooms
Every import, the catalog pin and the docs name @hanzo/app and
github.com/hanzoai/app. lib/rooms.ts is lib/app.ts and
components/rooms.tsx is components/app.tsx.
2026-10-22 19:07:20 -07:00

30 lines
1.6 KiB
TypeScript

import { dev } from '@hanzo/app/lib/host'
import { APP } from '@hanzo/app/lib/session'
/**
* Which addresses under /dev leave Dev's page for the builder.
*
* Bare `/dev` is the page a stranger reads (components/dev/DevLanding). Every
* other address the edge serves it at — `/dev/<org>/<repo>`, `/dev/sess_<id>`,
* `/dev/-/<screen>` (lib/edge.ts `APP`) — and bare `/dev` carrying a query from
* before Dev had paths (`?at=`, `?run=`, `?project=`, `?view=`, the console's and
* shared links') is a place in the builder, which a stranger signs in to reach.
*
* A plain module, so the server page can write the script into the export and the
* door (./_door) can ask the same question in the browser: one rule, two readers.
*/
const OLD = '[?&](?:at|run|project|view)(?:[=&]|$)'
/** Whether `where` is a place in the builder rather than Dev's page. */
export const away = (where: { pathname: string; search: string }): boolean =>
where.pathname !== dev() || new RegExp(OLD).test(where.search)
/**
* `away`, as the script the page runs as its landing's first child, before the
* rest of the landing is parsed: it marks the document with `APP` and takes the
* landing off the page, so a reader on their way to sign in to a place, or a
* member whose builder is loading, is never shown the pitch. The rooms' `BOOT`
* beside it does the same for a live session.
*/
export const AWAY = `try{if(location.pathname!=='${dev()}'||/${OLD}/.test(location.search)){document.documentElement.setAttribute('${APP}','');var l=document.currentScript&&document.currentScript.parentElement;if(l&&l.hasAttribute('data-landing'))l.style.display='none'}}catch(_){}`