Files
amare/.github/skills/impeccable/scripts/live/frameworks/script-src.mjs
2026-08-01 22:06:48 -03:00

18 lines
699 B
JavaScript

/**
* The one place that builds the `/live.js` URL the browser loads.
*
* Every injection path needs it (the generic script tag, the Nuxt client
* plugin, the SvelteKit root component, the TanStack mount component), and a
* separate module keeps that shared leaf free of import cycles: the framework
* entries import it, and nothing here imports a framework entry.
*/
/**
* When a token is supplied it rides as a `?token=...` query param so the
* server's token-gated /live.js handler authorizes the fetch.
*/
export function buildLiveScriptSrc(port, token) {
const base = 'http://localhost:' + port + '/live.js';
return token ? base + '?token=' + encodeURIComponent(token) : base;
}