Skip to content

Commit 338b3b6

Browse files
committed
chore: update
1 parent c94c198 commit 338b3b6

6 files changed

Lines changed: 27 additions & 10 deletions

File tree

‎packages/devframe/src/utils/remote-assets.test.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { AddressInfo } from 'node:net'
22
import type { MockInstance } from 'vitest'
33
import type { RemoteAssets, RemoteAssetsErrorMessage, RemoteAssetsStore } from '../types/remote-assets'
4-
import { existsSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync } from 'node:fs'
4+
import { existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, writeFileSync } from 'node:fs'
55
import { createServer } from 'node:http'
66
import { tmpdir } from 'node:os'
77
import { join } from 'node:path'
@@ -12,8 +12,11 @@ import { DEVFRAME_REMOTE_ASSETS_ERROR_MESSAGE_TYPE } from '../constants'
1212
import { resolveStaticAssetsSource } from './remote-assets'
1313
import { serveStaticHandler } from './serve-static'
1414

15+
// `realpathSync` because module resolution reports realpaths, while the system
16+
// temp dir is a symlink on macOS (`/var` → `/private/var`) — a path built from
17+
// the raw `mkdtempSync` result would never match a resolved one.
1518
function makeTmp(): string {
16-
return mkdtempSync(join(tmpdir(), 'devframe-remote-assets-'))
19+
return realpathSync(mkdtempSync(join(tmpdir(), 'devframe-remote-assets-')))
1720
}
1821

1922
/** A fake CDN over a flat `filePath -> contents` map, answering the jsDelivr listing API + per-file URLs. */

‎packages/hub-ui/src/client/state/context.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ export async function createDocksContext(
276276
selectedDockId.value = entry.id
277277
sessionStore.value.open = true
278278
// Only an iframe dock owns an address-bar route; ViewIframe keeps
279-
// `session.route` current for it. Clear it for anything else so a stale
279+
// `session.selectedDockRoute` current for it. Clear it for anything else so a stale
280280
// route from a previous iframe isn't persisted against a non-iframe dock.
281281
if (entry.type !== 'iframe')
282282
sessionStore.value.selectedDockRoute = null
@@ -607,7 +607,7 @@ export async function createDocksContext(
607607
// revocation clears the selection), so the durable intent captured in
608608
// `restoreIntent` is re-applied here after the handshake — re-running the
609609
// dock's setup script and re-opening the panel on the dock the developer left
610-
// open. `switchEntry` reads `session.route` back through `consumeBootRoute`
610+
// open. `switchEntry` reads `session.selectedDockRoute` back through `consumeBootRoute`
611611
// when the restored iframe boots.
612612
const applyRestore = (): void => {
613613
if (restoreIntent.open && restoreIntent.selectedDockId != null)

‎packages/hub-ui/src/client/state/docks.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export function DEFAULT_DOCK_PANEL_STORE(): DockPanelStorage {
1818
}
1919

2020
/**
21-
* The per-tab session UI state seed — `open`/`selectedId`/`route`. Persisted to
21+
* The per-tab session UI state seed — `open`/`selectedDockId`/`selectedDockRoute`. Persisted to
2222
* `sessionStorage` by the embedded and standalone bootstraps so a reload (and
2323
* the RPC auth handshake that follows one) restores the panel to the dock and
2424
* route the developer left open. Distinct from {@link DEFAULT_DOCK_PANEL_STORE}
@@ -27,7 +27,7 @@ export function DEFAULT_DOCK_PANEL_STORE(): DockPanelStorage {
2727
export function DEFAULT_DOCK_SESSION_STORE(): DockSessionStorage {
2828
return {
2929
open: false,
30-
selectedId: null,
30+
selectedDockId: null,
3131
selectedDockRoute: null,
3232
}
3333
}

‎packages/hub/src/client/host.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ export async function createDevframeClientHost(
333333
if (selectedId && !entryToStateMap.has(selectedId)) {
334334
selectedId = null
335335
panel.session.selectedDockId = null
336+
panel.session.selectedDockRoute = null
336337
}
337338
}
338339

@@ -344,6 +345,14 @@ export async function createDevframeClientHost(
344345
set selectedId(id: string | null) {
345346
void switchEntry(id)
346347
},
348+
// A mirror of the session field, so a persisting host reads and writes the
349+
// selected iframe's route through the same context every viewer uses.
350+
get selectedRoute() {
351+
return panel.session.selectedDockRoute
352+
},
353+
set selectedRoute(route: string | null) {
354+
panel.session.selectedDockRoute = route
355+
},
347356
get selected() {
348357
return (selectedId && entryToStateMap.get(selectedId)?.entryMeta) || null
349358
},
@@ -398,6 +407,10 @@ export async function createDevframeClientHost(
398407
// Mirror onto the session context so a persisting host and the when-clause
399408
// context see the current selection.
400409
panel.session.selectedDockId = next
410+
// Only an iframe dock owns an address-bar route, so drop the remembered one
411+
// for anything else rather than leaving it attached to the new selection.
412+
if (next === null || entryToStateMap.get(next)?.entryMeta.type !== 'iframe')
413+
panel.session.selectedDockRoute = null
401414
if (previous)
402415
entryToStateMap.get(previous)?.events.emit('entry:deactivated')
403416
if (next)

‎tests/__snapshots__/tsnapi/@devframes/hub/client.snapshot.d.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export interface DocksContext extends DevframeRpcContext {
9292
}
9393
export interface DocksEntriesContext {
9494
selectedId: string | null;
95+
selectedRoute: string | null;
9596
readonly selected: DevframeDockEntry | null;
9697
entries: DevframeDockEntry[];
9798
entryToStateMap: Map<string, DockEntryState>;
@@ -106,8 +107,8 @@ export interface DocksEntriesContext {
106107
}
107108
export interface DockSessionStorage {
108109
open: boolean;
109-
selectedId: string | null;
110-
route: string | null;
110+
selectedDockId: string | null;
111+
selectedDockRoute: string | null;
111112
}
112113
export interface DocksPanelContext {
113114
store: DockPanelStorage;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* Generated by tsnapi — public API snapshot of `devframe/utils/remote-assets`
33
*/
4-
// #region Functions
5-
export function resolveStaticAssetsSource(_, _) {}
4+
// #region Other
5+
export { resolveStaticAssetsSource }
66
// #endregion

0 commit comments

Comments
 (0)