liu
3 天以前 104db2c4423867a7fa4f41343213f45985ae3110
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/**
 * 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;
}