You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(assets): defer raw byte serving to the host, don't self-serve
The managed public/ directory is already served by whatever host the
plugin is mounted into (Vite, Nuxt, any framework serves public/ at /),
so the plugin no longer stands up its own /__…-raw/ route. Each asset's
publicPath is now baseURL + its path (baseURL default '/'), pointing at
the host's own URLs.
- Add baseURL option (where the host serves the dir) and serveStatic
(self-serve, off by default). setupAssets only calls ctx.views.
hostStatic() when serveStatic is set.
- The standalone CLI is its own host, so createAssetsCli() enables
serveStatic (under a dedicated base so it doesn't collide with the SPA).
- Plugin dev server: point Vite's own publicDir at the managed dir so
Vite serves the fixtures at /, and drop the ad-hoc raw-serving
middleware. Gated to 'serve' so fixtures never bake into dist.
- Docs + README + API snapshots updated.
Co-authored-by: opencode <noreply@opencode.ai>
|`dir`|`<cwd>/public`| Directory this devframe manages. |
56
+
|`baseURL`|`/`| URL base the host serves `dir` at — each asset's `publicPath` is `baseURL` + its path. Match a non-root deployment base (e.g. Nuxt's `app.baseURL`). |
55
57
|`write`|`true`| Enable upload, rename, delete, and folder creation from the UI. |
56
58
|`uploadExtensions`| Nuxt DevTools' allow-list | Extensions `upload` accepts, or `'*'` for any. |
59
+
|`serveStatic`|`false`| Serve the directory's bytes from this devframe itself. Left off when mounted into a host that already serves `public/`; the standalone CLI turns it on. |
57
60
|`build`|`false`| Register the `build` CLI subcommand. See [why it's off by default](#static-export) below. |
58
61
62
+
## How previews are served
63
+
64
+
Asset previews (`<img>`, `<video>`, download links) load the files by their **public URL**, and the host the plugin is mounted into serves those files — Vite, Nuxt, and most frameworks already serve their `public/` folder at `/`. The plugin never stands up its own byte-serving route; it just resolves each asset's `publicPath` as `baseURL` + the file's path. Point `baseURL` at wherever the host serves `dir` (the default `/` matches the usual `public/` convention). The standalone CLI (`pnpx @devframes/plugin-assets`) is its own host, so it flips `serveStatic` on and serves the directory under a dedicated base.
65
+
59
66
## RPC surface
60
67
61
68
All functions are namespaced `devframes:plugin:assets:*`:
@@ -77,7 +84,7 @@ All functions are namespaced `devframes:plugin:assets:*`:
77
84
78
85
## Static export
79
86
80
-
Every devframe's `build` CLI subcommand is disabled here by default (`capabilities: { build: false }`). Real byte serving for previews goes through `ctx.views.hostStatic()`, which only mounts real files under a live adapter (`cli` / `vite` / `embedded`) — a static export can never copy those bytes, and every write action is inherently excluded from a static dump. Rather than ship a broken, preview-less, write-less shell of the tool, the `build` command is simply not registered. Pass `{ build: true }` to `createAssetsDevframe()` (and `{ force: true }` if calling `createBuild()` directly) if that degraded export is still useful to you — the file listing itself still bakes into the static RPC dump.
87
+
Every devframe's `build` CLI subcommand is disabled here by default (`capabilities: { build: false }`). A static export has no live host serving the files, and every write action is inherently excluded from a static dump. Rather than ship a broken, preview-less, write-less shell of the tool, the `build` command is simply not registered. Pass `{ build: true }` to `createAssetsDevframe()` (and `{ force: true }` if calling `createBuild()` directly) if that degraded export is still useful to you — the file listing itself still bakes into the static RPC dump.
Copy file name to clipboardExpand all lines: plugins/assets/README.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,8 @@ Browse, preview, upload, rename, and delete the files in a directory — a frame
6
6
pnpx @devframes/plugin-assets
7
7
```
8
8
9
-
Manages `<cwd>/public` by default. The package exports `createAssetsDevframe()` for custom definitions and `assetsVitePlugin()` from `@devframes/plugin-assets/vite` for Vite hosts. Pass `{ dir }` to manage a different directory, or `{ write: false }` (`--read-only` on the standalone CLI) for a browse-only deployment.
9
+
Manages `<cwd>/public` by default. The package exports `createAssetsDevframe()` for custom definitions and `assetsVitePlugin()` from `@devframes/plugin-assets/vite` for Vite hosts. Pass `{ dir }` to manage a different directory, `{ baseURL }` to match where the host serves it, or `{ write: false }` (`--read-only` on the standalone CLI) for a browse-only deployment.
10
+
11
+
Asset previews load files by their public URL, served by the host the plugin is mounted into (Vite/Nuxt/etc. already serve `public/` at `/`) — the plugin doesn't serve the bytes itself. The standalone CLI is its own host, so it serves the directory for you.
10
12
11
13
The standalone server requires devframe's trust handshake by default because it can read, write, and delete real files. The `build` CLI subcommand is disabled by default — see the docs page for why.
0 commit comments