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
The UI mounts as usual — the first request for each file is streamed from a CDN and written to a local cache; subsequent requests are served from disk.
64
64
65
+
The definition's [`importMetaUrl`](./devframe-definition#resolving-against-the-plugins-own-dependencies) supplies the resolution base, so a remote source needs only its `package` and `version`. A per-source `resolveFrom` overrides that base for one source, and an explicit `resolveFrom: null` opts a source out of the installed-copy lookup entirely.
66
+
65
67
### How assets resolve
66
68
67
69
For each request the source resolves in order:
68
70
69
-
1.**Locally installed package** — resolved from `resolveFrom` (`import.meta.url`). If `@acme/my-tool-assets` is installed next to your tool, it's served directly with no network. This is the offline path.
71
+
1.**Locally installed package** — resolved from `resolveFrom`, which defaults to the definition's `importMetaUrl`. If `@acme/my-tool-assets` is installed next to your tool, it's served directly with no network. This is the offline path.
70
72
2.**On-disk cache** — files already fetched, under the project's storage directory.
71
73
3.**CDN back-proxy** — [jsDelivr](https://www.jsdelivr.com/) by default, mirroring npm. Each file streams to the browser and is cached on the way past.
72
74
@@ -78,7 +80,7 @@ Exact-version URLs are immutable, so a cached file never goes stale.
78
80
|-------|---------|
79
81
|`package`| npm package holding the built assets. |
80
82
|`version`| Exact version to serve — usually your tool's own `pkg.version`. |
81
-
|`resolveFrom`|`import.meta.url` of the declaring module; enables the zero-network path from a locally installed copy. Omit to skip straight to cache + CDN. |
83
+
|`resolveFrom`|Resolution base for the zero-network path from a locally installed copy. Defaults to the definition's `importMetaUrl`; set it to override that for one source, or to `null` to skip straight to cache + CDN. |
82
84
|`path`| Subpath inside the package the assets live under. Defaults to `dist`. |
83
85
|`provider`|`'jsdelivr'` (default), `'unpkg'`, or a custom provider for an internal mirror. |
84
86
|`offline`|`true` serves only from a local install or the cache — never the network. |
@@ -109,7 +111,6 @@ A custom provider supplies the file URL, and optionally a file listing (used for
The assets package is an ordinary npm package that ships the built UI under `path` (default `dist`) and exposes its `package.json` so `resolveFrom` can locate it:
123
+
The assets package is an ordinary npm package that ships the built UI under `path` (default `dist`) and exposes its `package.json` so the resolver can locate it:
Copy file name to clipboardExpand all lines: docs/guide/devframe-definition.md
+33Lines changed: 33 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,7 @@ export default defineDevframe({
17
17
name: 'My Devframe',
18
18
version: '1.0.0',
19
19
packageName: 'my-devframe',
20
+
importMetaUrl: import.meta.url,
20
21
homepage: 'https://github.com/me/my-devframe',
21
22
description: 'A one-line summary of what the tool does.',
22
23
icon: 'ph:gauge-duotone',
@@ -45,6 +46,7 @@ export default defineDevframe({
45
46
|`name`|`string`|**Required.** Display name shown in the dock and agent manifests. |
46
47
|`version`|`string`|**Required.** Semver of the tool, surfaced in hub UIs and diagnostics. |
47
48
|`packageName`|`string`|**Required.** npm package name the devframe ships in (e.g. `@scope/my-tool`). |
49
+
|`importMetaUrl`|`string`|**Recommended.** Always pass `import.meta.url`. The resolution base for the tool's own dependency graph: it becomes the default `resolveFrom` for any [remote assets](./client-assets) the devframe hosts, and the base the host resolves declared [services](./services#wire-services) from — so a plugin ships an assets or service package as its own dependency instead of asking users to install it. See [Resolving against the plugin's own dependencies](#resolving-against-the-plugins-own-dependencies). |
48
50
|`homepage`|`string`|**Required.** Project homepage or documentation URL. |
49
51
|`description`|`string`|**Required.** One-line summary of what the tool does. |
50
52
|`icon`|`string \| { light, dark }`| Optional Iconify name or URL; supports light/dark pairs. |
The default import with a `with { type: 'json' }` attribute resolves under both bundlers and Node's native TypeScript execution. Bundlers also support the destructured `import { version } from '../package.json'` form when the devframe is always bundled before it runs.
77
80
81
+
### Resolving against the plugin's own dependencies
82
+
83
+
A devframe often ships companion packages — a separate `--assets` package holding its built SPA, or a service package it consumes. `importMetaUrl` lets the host resolve those against the plugin's **own** installed dependencies rather than the consuming app's, so the plugin declares them as its dependencies and users install nothing extra.
For a remote assets source, `importMetaUrl` is the default `resolveFrom`; a per-source `resolveFrom` still wins, and an explicit `resolveFrom: null` opts out of the installed-copy lookup. See [Client Assets](./client-assets) and [Cross-Plugin Services](./services#wire-services) for the full resolution order.
110
+
78
111
### Runtime flags
79
112
80
113
The `ctx.mode` field is either `'dev'` or `'build'`. Use it to gate work that should only run in one runtime:
Copy file name to clipboardExpand all lines: docs/guide/services.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -103,14 +103,15 @@ Two declaration merges make it fully typed for consumers: the fully-qualified RP
103
103
104
104
### Installing
105
105
106
-
A host with the factory at hand installs explicitly; a plugin declares what it consumes on its definition and the adapter resolves the package **against the plugin's own dependencies**:
106
+
A host with the factory at hand installs explicitly; a plugin declares what it consumes on its definition and the adapter resolves the package **against the plugin's own dependencies** — the base for that resolution is the definition's [`importMetaUrl`](./devframe-definition#resolving-against-the-plugins-own-dependencies), so a plugin ships a service package as its own dependency and users install nothing extra:
0 commit comments