Files
hyperframes/scripts/package-size-budgets.json
T
James RussoandClaude Opus 5.5 ffb13c3b62 fix(studio-server): load fonts and modules only in the Studio's own preview frames (#7553)
* fix(studio-server): let opaque preview frames load project fonts and module scripts

A preview framed with an opaque origin, such as the Compositions hover
preview, makes its font and module-script loads in CORS mode with
`Origin: null`. Without a CORS grant they failed: the frame fell back to a
system font and module scripts never ran.

The preview asset route now answers those two loads with
`Access-Control-Allow-Origin: null`, `Vary: Origin` and
`X-Content-Type-Options: nosniff`. The grant is chosen by `Sec-Fetch-Dest`,
which the browser sets and page script cannot: `font` for a font file and
`script` for a .js/.mjs file, served with the matching content type. A
page's own `fetch()` is always `empty`, so it still gets no grant and
composition script still cannot read project files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(studio-server): keep opaque-frame grant comments within the package share

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(studio-server): let opaque preview frames load project fonts

Narrow the opaque-frame grant to fonts. Every sandboxed frame sends the
same `Origin: null` and fetch metadata, so a CORS grant for module
scripts could not be limited to frames the Studio itself serves. Module
scripts stay unloaded in the hover preview for now; fonts keep their
grant, and `Sec-Fetch-Dest: script` loads of .js/.mjs get none.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(studio-server): load fonts and modules only in the Studio's own preview frames

A CORS grant to `Origin: null` reaches every sandboxed frame, whichever
page it sits in. The grant now lives on a per-project path instead:
`/projects/:id/preview/~<token>/...` serves exactly what `/preview/...`
serves, and only there do font loads (`Sec-Fetch-Dest: font`, a font file
served as `font/*`) and module-script loads (`script`, a .js/.mjs file
served as `text/javascript`) from an opaque frame get
`Access-Control-Allow-Origin: null`. The plain path gets no grant.

The token is an HMAC-SHA256 of the project id under a random per-server
secret, compared in constant time. The Studio reads it from
`/projects/:id/frame-token`, which refuses cross-site and same-site
requests, and the Compositions hover preview frames its composition at
the token path. Documents served there are re-based under the token and
carry `Referrer-Policy: no-referrer`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore(studio-server): raise the packed size budget for the preview frame tokens

The per-project frame-token path adds server code to the package, and the
packed tarball measured 166941 bytes in CI against a 164800 budget. Set the
budget to the measured size plus about 1% headroom.

— Rames Jusso

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 13:47:32 +00:00

63 lines
1.2 KiB
JSON

{
"@hyperframes/aws-lambda": {
"packed": 78851,
"unpacked": 290508
},
"@hyperframes/cli": {
"packed": 8577627,
"unpacked": 25159107
},
"@hyperframes/core": {
"packed": 1762752,
"unpacked": 4268445
},
"@hyperframes/engine": {
"packed": 490452,
"unpacked": 1620913
},
"@hyperframes/gcp-cloud-run": {
"packed": 49412,
"unpacked": 170124
},
"@hyperframes/inspector": {
"packed": 858046,
"unpacked": 3684092
},
"@hyperframes/lint": {
"packed": 191022,
"unpacked": 737342
},
"@hyperframes/parsers": {
"packed": 203731,
"unpacked": 885314
},
"@hyperframes/player": {
"packed": 157145,
"unpacked": 541601
},
"@hyperframes/producer": {
"packed": 870000,
"unpacked": 3165274
},
"@hyperframes/sdk": {
"packed": 90662,
"unpacked": 325069
},
"@hyperframes/shader-transitions": {
"packed": 212864,
"unpacked": 825937
},
"@hyperframes/share": {
"packed": 148738,
"unpacked": 575775
},
"@hyperframes/studio": {
"packed": 6589635,
"unpacked": 26703858
},
"@hyperframes/studio-server": {
"packed": 168500,
"unpacked": 646000
}
}