Skip to content

Commit 3d473f3

Browse files
authored
feat(devframe): promote cli.distDir to top-level clientAssets (#270)
1 parent edcbbf2 commit 3d473f3

50 files changed

Lines changed: 238 additions & 142 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/adapters/build.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ outline: deep
66

77
Produces a self-contained static deploy of a devframe:
88

9-
1. Copies the author's SPA dist (`cli.distDir` or `options.distDir`) into `<outDir>`.
9+
1. Copies the author's SPA dist (`clientAssets` or `options.distDir`) into `<outDir>`.
1010
2. Runs `setup(ctx)` with `mode: 'build'`.
1111
3. Collects RPC dumps for every `'static'` function and any `'query'` function with `dump.inputs` / `snapshot: true`.
1212
4. Writes `<outDir>/__connection.json` (`{ backend: 'static' }`) and sharded dump files under `<outDir>/__rpc-dump/` — both at the SPA root so the deployed client discovers them via relative paths from `document.baseURI`.
@@ -23,7 +23,7 @@ await createBuild(devframe, {
2323
| Option | Default | Description |
2424
|--------|---------|-------------|
2525
| `outDir` | `dist-static` | Output directory. Cleared on each build. |
26-
| `distDir` | `def.cli?.distDir` | Override the SPA dist directory (a local path or a [remote assets](/guide/client-assets) package, materialized in full at build time). |
26+
| `distDir` | `def.clientAssets` (falls back to deprecated `def.cli?.distDir`) | Override the SPA dist directory (a local path or a [remote assets](/guide/client-assets) package, materialized in full at build time). |
2727
| `pretty` | `false` | Pretty-print dump JSON (larger on disk). |
2828

2929
The resulting directory hosts on any static web server (`serve`, nginx, GitHub Pages, …). The client auto-detects `static` mode by resolving `./__connection.json` against `document.baseURI` and runs in read-only form.

docs/adapters/cac.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { createCac } from 'devframe/adapters/cac'
2121
const devframe = defineDevframe({
2222
id: 'my-devframe',
2323
name: 'My Devframe',
24-
cli: { distDir: './client/dist' },
24+
clientAssets: './client/dist',
2525
setup(ctx) { /* register docks, RPC, etc. */ },
2626
})
2727

@@ -66,9 +66,9 @@ The `cli` property lets the caller add ad-hoc commands and flags right before `p
6666
```ts
6767
defineDevframe({
6868
id: 'my-devframe',
69+
clientAssets: './client/dist', // built SPA served as the UI
6970
cli: {
7071
command: 'my-devframe', // binary name; default: the id
71-
distDir: './client/dist', // required for dev/build
7272
port: 7777, // preferred port
7373
portRange: [7777, 9000], // passed through to get-port-please
7474
random: false, // passed through to get-port-please
@@ -87,7 +87,7 @@ defineDevframe({
8787
})
8888
```
8989

90-
`distDir` is the only required field; everything else has sensible defaults. The `configure` hook runs *before* the `configureCli` option passed to `createCac`, so the final tool author always has the last word on flags.
90+
The top-level [`clientAssets`](/guide/client-assets) supplies the SPA the dev/build commands serve; everything under `cli` has sensible defaults. The `configure` hook runs *before* the `configureCli` option passed to `createCac`, so the final tool author always has the last word on flags.
9191

9292
## Headless logging
9393

docs/adapters/dev.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ process.on('SIGINT', () => handle.close().then(() => process.exit(0)))
2626
| `host` | `def.cli?.host ?? 'localhost'` | Bind host. |
2727
| `port` | resolved via `resolveDevServerPort` | Port to listen on. |
2828
| `flags` | `{}` | Parsed flag bag forwarded to `setup(ctx, { flags })`. |
29-
| `distDir` | `def.cli?.distDir` | Required — throws when neither is set. |
29+
| `distDir` | `def.clientAssets` (falls back to deprecated `def.cli?.distDir`) | SPA dist override. When unset the server runs in bridge mode (meta + WS only). |
3030
| `basePath` | `resolveBasePath(def, 'standalone')` | Mount path override. |
3131
| `app` | fresh h3 app | Pre-configured h3 app to mount onto (custom middleware, auth, extra static assets). |
3232
| `openBrowser` | resolves from `flags.open` / `def.cli?.open` | Explicit on/off override. `false` disables; a string opens that relative path. |

docs/errors/DF0059.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@ A remote-assets source (`{ package, version }` passed where a static mount accep
1616

1717
```ts
1818
defineDevframe({
19-
cli: {
20-
distDir: {
21-
package: '@devframes/plugin-git-client',
22-
version: '1.2.3',
23-
},
19+
clientAssets: {
20+
package: '@devframes/plugin-git-client',
21+
version: '1.2.3',
2422
},
2523
})
2624
```

docs/errors/DF0060.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@ A file of a remote-assets source was requested that is neither in the locally in
1616

1717
```ts
1818
defineDevframe({
19-
cli: {
20-
distDir: {
21-
package: '@devframes/plugin-git-client',
22-
version: '1.2.3',
23-
},
19+
clientAssets: {
20+
package: '@devframes/plugin-git-client',
21+
version: '1.2.3',
2422
},
2523
})
2624
```

docs/errors/DF0061.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@ A remote-assets source found a locally installed copy of its assets package (res
1616

1717
```ts
1818
defineDevframe({
19-
cli: {
20-
distDir: {
21-
package: '@devframes/plugin-git-client',
22-
version: '2.0.0',
23-
resolveFrom: import.meta.url,
24-
},
19+
clientAssets: {
20+
package: '@devframes/plugin-git-client',
21+
version: '2.0.0',
22+
resolveFrom: import.meta.url,
2523
},
2624
})
2725
```

docs/errors/DF0064.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ outline: deep
1010
1111
## Cause
1212

13-
A static build (`createBuild`) with a remote-assets `distDir` needs every asset file up front — the output must be self-contained. Materialization walks the provider's file listing and downloads each file, and one of those steps failed: the provider has no `listFiles` (custom providers may omit it), the listing request failed, or an individual file download errored.
13+
A static build (`createBuild`) with remote-assets `clientAssets` needs every asset file up front — the output must be self-contained. Materialization walks the provider's file listing and downloads each file, and one of those steps failed: the provider has no `listFiles` (custom providers may omit it), the listing request failed, or an individual file download errored.
1414

1515
## Example
1616

docs/errors/DF0065.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@ A remote-assets source's `package` and `version` are interpolated into CDN URLs
1616

1717
```ts
1818
defineDevframe({
19-
cli: {
20-
distDir: {
21-
package: '@devframes/plugin-git-client',
22-
version: '../etc', // ✗ not a semver version
23-
},
19+
clientAssets: {
20+
package: '@devframes/plugin-git-client',
21+
version: '../etc', // ✗ not a semver version
2422
},
2523
})
2624
```
@@ -31,11 +29,9 @@ Use a valid npm package name and an exact version:
3129

3230
```ts
3331
defineDevframe({
34-
cli: {
35-
distDir: {
36-
package: '@devframes/plugin-git-client',
37-
version: '1.2.3',
38-
},
32+
clientAssets: {
33+
package: '@devframes/plugin-git-client',
34+
version: '1.2.3',
3935
},
4036
})
4137
```

docs/errors/DF8106.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ outline: deep
1212

1313
A mounted devframe's SPA loads in an iframe at its own base (e.g. `/__terminals/`) and calls `connectDevframe()`, which fetches `./__connection.json` relative to that base to discover the RPC/WebSocket endpoint. `ctx.install` serves that file at each base by calling the host's `mountConnectionMeta(base)` alongside `mountStatic`.
1414

15-
This diagnostic is reported when a devframe with a servable `cli.distDir` is mounted on a `DevframeHost` that does not implement `mountConnectionMeta`. The SPA's `./__connection.json` fetch then falls through to the host's HTML fallback, so the SPA cannot discover the endpoint and its panel stays empty or stuck loading — previously a silent failure.
15+
This diagnostic is reported when a devframe with servable `clientAssets` is mounted on a `DevframeHost` that does not implement `mountConnectionMeta`. The SPA's `./__connection.json` fetch then falls through to the host's HTML fallback, so the SPA cannot discover the endpoint and its panel stays empty or stuck loading — previously a silent failure.
1616

1717
The SPA can still connect when it shares an origin with the hub UI, by inheriting the connection meta from the parent window. Cross-origin, sandboxed, or directly-opened iframes have no such parent to inherit from.
1818

@@ -35,4 +35,4 @@ A static-snapshot host that bakes `__connection.json` into its served files can
3535

3636
## Source
3737

38-
- [`packages/hub/src/node/install-devframe.ts`](https://github.com/devframes/devframe/blob/main/packages/hub/src/node/install-devframe.ts)`ctx.install()` emits this when a devframe with a servable `distDir` is installed on a host lacking `mountConnectionMeta`.
38+
- [`packages/hub/src/node/install-devframe.ts`](https://github.com/devframes/devframe/blob/main/packages/hub/src/node/install-devframe.ts)`ctx.install()` emits this when a devframe with servable `clientAssets` is installed on a host lacking `mountConnectionMeta`.

docs/examples/json-render.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Package: `json-render` · frontend: **prebuilt `@devframes/json-render-ui/spa`**
2020
- **Action bridge** — the `Refresh` button's `press` action is dispatched as an
2121
RPC call of the same name; the handler bumps a counter and patches state, with
2222
per-action loading and error surfacing.
23-
- **Out-of-box SPA**`createJsonRenderDevframe` points `cli.distDir` at the
23+
- **Out-of-box SPA**`createJsonRenderDevframe` points `clientAssets` at the
2424
prebuilt `@devframes/json-render-ui/spa`, which discovers the view from the
2525
view index and renders it — no client build in the example.
2626
- **Static output**`cli:build` snapshots the spec + state as a read-only

0 commit comments

Comments
 (0)