Files
hyperframes/packages/core/src/runtime/assetUrl.ts
Miguel Ángel b8dd023a97 feat(core): a composition's script can load its own files with __hyperframes.assetUrl (#4434)
* feat(core): a composition's script can load its own files with __hyperframes.assetUrl

* test(core): a template composition inside a mounted file resolves assets from that file

* docs: assetUrl is for paths beside the composition, not project-root paths

* docs: say assetUrl misses a project-root path
2026-09-24 21:13:27 -04:00

9 lines
397 B
TypeScript

/**
* Resolves a path the calling composition wrote relative to its own file. At the top level, and
* for a composition opened on its own, that file is the page. Inside a mounted sub-composition
* the scoped wrapper (compiler/compositionScoping.ts) replaces this with one bound to that file.
*/
export function assetUrl(path: string): string {
return new URL(path, document.baseURI).href;
}