@reticlehq/vite-plugin 3.7.0 → 3.8.1

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.
@@ -14,3 +14,5 @@ export interface AnnounceIo {
14
14
  * throw inside a signal handler does not degrade, it takes the shutdown with it.
15
15
  */
16
16
  export declare function announceDevServer(entry: DevServerEntry, home?: string, io?: AnnounceIo): () => void;
17
+ /** The URL to announce: the dev proxy's when one runs this server, else the one Vite reports. */
18
+ export declare function announcedUrl(env: Readonly<Record<string, string | undefined>>, reported: string | undefined, port: number): string;
package/dist/announce.js CHANGED
@@ -58,3 +58,16 @@ export function announceDevServer(entry, home = stateHome(), io = nodeIo) {
58
58
  }
59
59
  };
60
60
  }
61
+ /**
62
+ * The environment variable a dev proxy sets to the URL the app is served on. portless runs each app,
63
+ * and each git worktree of it, at `https://<branch>.<app>.localhost`, while the dev server listens on
64
+ * a port of its own. The page's origin is the proxy URL, so that is what the daemon must match.
65
+ */
66
+ const DEV_PROXY_URL_ENV = 'PORTLESS_URL';
67
+ /** The URL to announce: the dev proxy's when one runs this server, else the one Vite reports. */
68
+ export function announcedUrl(env, reported, port) {
69
+ const proxied = env[DEV_PROXY_URL_ENV];
70
+ if (proxied !== undefined && proxied.length > 0)
71
+ return proxied;
72
+ return reported ?? `http://localhost:${String(port)}/`;
73
+ }