Skip to content

Commit a55f3d5

Browse files
committed
fix: deprecate resolveClientAssets exports from /define, which was never meant to be public
1 parent c36ac2f commit a55f3d5

12 files changed

Lines changed: 35 additions & 12 deletions

File tree

‎packages/devframe/src/adapters/build.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import { colors as c } from 'devframe/utils/colors'
99
import { resolveStaticAssetsSource } from 'devframe/utils/remote-assets'
1010
import { structuredCloneStringify } from 'devframe/utils/structured-clone'
1111
import { dirname, resolve } from 'pathe'
12+
import { resolveClientAssets } from '../client-assets'
1213
import {
1314
DEVFRAME_CONNECTION_META_FILENAME,
1415
DEVFRAME_RPC_DUMP_DIRNAME,
1516
DEVFRAME_RPC_DUMP_MANIFEST_FILENAME,
1617
} from '../constants'
17-
import { resolveClientAssets } from '../define'
1818
import { createHostContext } from '../node/context'
1919
import { diagnostics } from '../node/diagnostics'
2020
import { createH3DevframeHost } from '../node/host-h3'

‎packages/devframe/src/adapters/initiate.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import { mountStaticHandler } from 'devframe/utils/serve-static'
1414
import { H3 } from 'h3'
1515
import { resolve } from 'pathe'
1616
import { joinURL } from 'ufo'
17+
import { resolveClientAssets } from '../client-assets'
1718
import { DEVFRAME_CONNECTION_META_FILENAME } from '../constants'
18-
import { resolveClientAssets } from '../define'
1919
import { createHostContext } from '../node/context'
2020
import { diagnostics } from '../node/diagnostics'
2121
import { createH3DevframeHost } from '../node/host-h3'
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import type { DevframeDefinition, StaticAssetsSource } from 'devframe/types'
2+
3+
/**
4+
* Resolve a definition's client assets source — the built SPA served as its
5+
* UI. Prefers the top-level {@link DevframeDefinition.clientAssets} and falls
6+
* back to the deprecated `cli.distDir`, so both the new and legacy shapes
7+
* resolve. Returns `undefined` when neither is set (bridge mode — the SPA is
8+
* hosted elsewhere).
9+
*
10+
* Internal: exposed to first-party integrations via `devframe/internal`, not
11+
* part of the stable public API.
12+
*/
13+
export function resolveClientAssets(d: DevframeDefinition): StaticAssetsSource | undefined {
14+
return d.clientAssets ?? d.cli?.distDir
15+
}

‎packages/devframe/src/define.ts‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { DevframeDefinition, DevframeNodeContext, StaticAssetsSource } from 'devframe/types'
22
import { createDefineWrapperWithContext } from 'devframe/rpc'
3+
import { resolveClientAssets as resolveClientAssetsInternal } from './client-assets'
34

45
export const defineRpcFunction = createDefineWrapperWithContext<DevframeNodeContext>()
56

@@ -12,12 +13,10 @@ export function defineDevframe(d: DevframeDefinition): DevframeDefinition {
1213
}
1314

1415
/**
15-
* Resolve a definition's client assets source — the built SPA served as its
16-
* UI. Prefers the top-level {@link DevframeDefinition.clientAssets} and falls
17-
* back to the deprecated {@link DevframeCliOptions.distDir}, so both the new
18-
* and legacy shapes resolve. Returns `undefined` when neither is set (bridge
19-
* mode — the SPA is hosted elsewhere).
16+
* @deprecated Read {@link DevframeDefinition.clientAssets} from the definition
17+
* directly. This helper is internal machinery that was never meant to be part
18+
* of the public API and is scheduled for removal.
2019
*/
2120
export function resolveClientAssets(d: DevframeDefinition): StaticAssetsSource | undefined {
22-
return d.clientAssets ?? d.cli?.distDir
21+
return resolveClientAssetsInternal(d)
2322
}

‎packages/devframe/src/internal/index.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,16 @@
2929
// - `resolveBasePath` / `normalizeBasePath` — the mount-base resolution
3030
// `initDevframe` itself uses; a bridge (`@devframes/vite`) that mounts a
3131
// devframe onto a host it doesn't own reuses the exact same defaulting.
32+
// - `resolveClientAssets` — the definition → static-assets-source
33+
// resolution every UI-serving adapter uses (`clientAssets`, falling back to
34+
// the legacy `cli.distDir`), so a bridge that serves a devframe's SPA itself
35+
// (`@devframes/vite`, `@devframes/next`, the hub's `ctx.install`) resolves it
36+
// identically.
3237
// - `diagnostics` — devframe core's structured diagnostics instance
3338
// (`DF00xx`), so a first-party integration built outside this package can
3439
// report against the same registered codes instead of minting its own.
3540
export { normalizeBasePath, resolveBasePath } from '../adapters/_shared'
41+
export { resolveClientAssets } from '../client-assets'
3642
export { coerceAgentPositionalArgs } from '../node/agent-args'
3743
export type { AgentArgsFallback } from '../node/agent-args'
3844
export { diagnostics } from '../node/diagnostics'

‎packages/hub/src/node/install-devframe.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { DevframeDefinition } from 'devframe/types'
22
import type { ClientScriptEntry, DevframeViewIframe } from '../types/docks'
33
import type { DevframeHubContext } from './context'
44
import { existsSync } from 'node:fs'
5-
import { resolveClientAssets } from 'devframe'
5+
import { resolveClientAssets } from 'devframe/internal'
66
import { resolveBasePath } from 'devframe/node/hub-internals'
77
import { basename, dirname, isAbsolute, resolve } from 'pathe'
88
import { joinURL, withTrailingSlash } from 'ufo'

‎packages/next/src/handler.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import type { InitDevframeOptions } from 'devframe/initiate'
33
import { homedir } from 'node:os'
44
import { join } from 'node:path'
55
import process from 'node:process'
6-
import { resolveClientAssets } from 'devframe'
76
import { initDevframe } from 'devframe/initiate'
7+
import { resolveClientAssets } from 'devframe/internal'
88

99
export interface CreateDevframeNextHandlerOptions {
1010
/**

‎packages/vite/src/single.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ import type { DevframeAuthHandler } from 'devframe/node/auth'
44
import type { IncomingMessage, Server as NodeHttpServer, ServerResponse } from 'node:http'
55
import type { Plugin } from 'vite'
66
import process from 'node:process'
7-
import { resolveClientAssets } from 'devframe'
87
import { initDevframe } from 'devframe/initiate'
9-
import { diagnostics, normalizeBasePath, resolveBasePath } from 'devframe/internal'
8+
import { diagnostics, normalizeBasePath, resolveBasePath, resolveClientAssets } from 'devframe/internal'
109
import { resolveStaticAssetsSource } from 'devframe/utils/remote-assets'
1110
import { serveStaticNodeMiddleware } from 'devframe/utils/serve-static'
1211
import { join, resolve } from 'pathe'

‎tests/__snapshots__/tsnapi/devframe/index.snapshot.d.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,7 @@ export type StaticAssetsSource = string | RemoteAssets;
511511

512512
// #region Functions
513513
export declare function defineDevframe(_: DevframeDefinition): DevframeDefinition;
514+
/** @deprecated */
514515
export declare function resolveClientAssets(_: DevframeDefinition): StaticAssetsSource | undefined;
515516
// #endregion
516517

‎tests/__snapshots__/tsnapi/devframe/index.snapshot.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*/
44
// #region Functions
55
export function defineDevframe(_) {}
6+
/** @deprecated */
67
export function resolveClientAssets(_) {}
78
// #endregion
89

0 commit comments

Comments
 (0)