diff --git a/plugin-sdk/package.json b/plugin-sdk/package.json index 4f09dab33..29848d74a 100644 --- a/plugin-sdk/package.json +++ b/plugin-sdk/package.json @@ -1,6 +1,6 @@ { "name": "trek-plugin-sdk", - "version": "1.4.0", + "version": "1.4.1", "description": "SDK for building TREK plugins: types, definePlugin, a mock host, manifest validation, and the create-trek-plugin / trek-plugin CLIs.", "type": "module", "license": "MIT", diff --git a/plugin-sdk/src/cli/dev.ts b/plugin-sdk/src/cli/dev.ts index bd329306a..3e8c8fee7 100644 --- a/plugin-sdk/src/cli/dev.ts +++ b/plugin-sdk/src/cli/dev.ts @@ -360,9 +360,15 @@ export async function runDev(dir: string, opts: { port?: number } = {}): Promise return send(200, preview(id, String(manifest.type)), 'text/html; charset=utf-8'); } - // Static plugin UI at /ui (page/widget client bundle) + // Static plugin UI at /ui (page/widget client bundle). The iframe loads + // `/ui/index.html` (not bare `/ui`) so relative asset URLs — `./assets/x.js` + // from a multi-file Vite/React build with `base: './'` — resolve to + // `/ui/assets/x.js`, exactly as the real host resolves them against + // `/plugin-frame//index.html`. A bare `/ui` document would resolve them + // against the origin root (`/assets/x.js`) and 404. Bare `/ui` and `/ui/` both + // still serve index.html for direct navigation. if (url.pathname === '/ui' || url.pathname.startsWith('/ui/')) { - const relFile = url.pathname === '/ui' ? 'index.html' : url.pathname.slice('/ui/'.length); + const relFile = url.pathname === '/ui' ? 'index.html' : (url.pathname.slice('/ui/'.length) || 'index.html'); const file = path.join(abs, 'client', relFile); if (!file.startsWith(path.join(abs, 'client'))) return send(403, 'forbidden'); if (!fs.existsSync(file) || !fs.statSync(file).isFile()) return send(404, 'not found — build your client/ bundle'); @@ -510,7 +516,7 @@ iframe{width:100%;border:0;background:transparent;min-height:120px;display:block -
+

The frame runs sandboxed at an opaque origin, exactly like TREK — trek.invoke() is proxied to your /api routes as the dev user.