@@ -53,6 +53,23 @@ export interface DevframeInternalContext {
5353 /** Full `ws://` or `wss://` URL with host and port. */
5454 url : string
5555 }
56+
57+ /**
58+ * Set {@link DevframeInternalContext.wsEndpoint} and notify subscribers —
59+ * the WS-binding tiers (side-car, shared-server, and the `unbound` tier's
60+ * `attach()`) call this once the socket is bound (or `undefined` once torn
61+ * down) instead of assigning the field directly, so anything that already
62+ * projected the endpoint (a hub's remote-dock URLs, registered before an
63+ * async bind resolves) gets a chance to re-project it.
64+ */
65+ setWsEndpoint : ( endpoint : { url : string } | undefined ) => void
66+ /**
67+ * Subscribe to every {@link DevframeInternalContext.setWsEndpoint} call.
68+ * Returns an unsubscribe function. The hub context uses this to refresh
69+ * the `devframe:docks` shared state so a remote dock registered before the
70+ * WS port resolves still ends up with a live connection URL.
71+ */
72+ onWsEndpointChange : ( cb : ( ) => void ) => ( ) => void
5673}
5774
5875export const internalContextMap = new WeakMap < DevframeNodeContext , DevframeInternalContext > ( )
@@ -66,6 +83,7 @@ export function getInternalContext(context: DevframeNodeContext): DevframeIntern
6683 } ,
6784 } )
6885 const remoteTokens = new Map < string , RemoteTokenRecord > ( )
86+ const wsEndpointListeners = new Set < ( ) => void > ( )
6987
7088 function revokeRemoteToken ( token : string ) : void {
7189 if ( ! remoteTokens . delete ( token ) )
@@ -78,6 +96,14 @@ export function getInternalContext(context: DevframeNodeContext): DevframeIntern
7896 auth : storage ,
7997 } ,
8098 revokeAuthToken : ( token : string ) => revokeAuthToken ( context , storage , token ) ,
99+ setWsEndpoint ( endpoint ) {
100+ internalContext . wsEndpoint = endpoint
101+ for ( const listener of wsEndpointListeners ) listener ( )
102+ } ,
103+ onWsEndpointChange ( cb ) {
104+ wsEndpointListeners . add ( cb )
105+ return ( ) => wsEndpointListeners . delete ( cb )
106+ } ,
81107 remoteTokens,
82108 allocateRemoteToken ( dockId , origin , originLock ) {
83109 const token = randomToken ( )
0 commit comments