ext-apps/examples
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Olivier Chafik bb4e5c57f3
Cache full PDF bodies from servers without Range support (#411)
* fix(pdf-server): handle HTTP 200 fallback in remote range requests

When a remote server ignores the Range header and returns HTTP 200
with the full body, readPdfRange previously passed the entire file
(potentially 10MB+) through as a single chunk. This bypassed the
512KB limit because:

1. The error check `!response.ok && status !== 206` short-circuits
   on 200 (ok is true), so the full body is read via arrayBuffer()
2. No Content-Range header on a 200 response leaves totalBytes at 0
3. hasMore becomes `offset + fullSize < 0` = false, so the client
   stops after one oversized message

Fix: detect HTTP 200, cache the full body in memory (to avoid
re-downloading on every subsequent chunk request), then slice to the
requested range. The 512KB per-message limit is now enforced for all
remote URLs regardless of Range request support.

* Add session-based PDF caching with timeout cleanup and size limits

- Add dual timeout strategy for cache cleanup:
  - 10s inactivity timeout (resets on each access)
  - 60s max lifetime (absolute timeout from creation)
- Add 50MB max size limit with both Content-Length and actual size checks
- Add unit tests for caching behavior including:
  - Cache on HTTP 200 response (no range support)
  - No cache on HTTP 206 response (range supported)
  - Slice cached data for subsequent range requests
  - Reject PDFs exceeding size limits
- Export getCacheSize() and clearCache() for testing

* refactor(pdf-server): make PDF cache session-local via factory pattern

- Replace module-level global cache with createPdfCache() factory
- Each server instance now gets its own isolated cache
- Export PdfCache interface for type-safe usage
- Update tests to use per-test cache instances
- Add test verifying cache isolation between sessions

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-30 20:24:18 +00:00
..
basic-host chore: bump to 1.0.1 - fix npm reference for ext-apps dependency in examples + update zod to 4.x (#368) 2026-01-26 21:55:15 +00:00
basic-server-preact Improve example CSS files to better demonstrate host style integration 2026-01-30 09:32:26 -06:00
basic-server-react Improve example CSS files to better demonstrate host style integration 2026-01-30 09:32:26 -06:00
basic-server-solid Improve example CSS files to better demonstrate host style integration 2026-01-30 09:32:26 -06:00
basic-server-svelte Improve example CSS files to better demonstrate host style integration 2026-01-30 09:32:26 -06:00
basic-server-vanillajs Improve example CSS files to better demonstrate host style integration 2026-01-30 09:32:26 -06:00
basic-server-vue Improve example CSS files to better demonstrate host style integration 2026-01-30 09:32:26 -06:00
budget-allocator-server chore: bump to 1.0.1 - fix npm reference for ext-apps dependency in examples + update zod to 4.x (#368) 2026-01-26 21:55:15 +00:00
cohort-heatmap-server chore: bump to 1.0.1 - fix npm reference for ext-apps dependency in examples + update zod to 4.x (#368) 2026-01-26 21:55:15 +00:00
customer-segmentation-server chore: bump to 1.0.1 - fix npm reference for ext-apps dependency in examples + update zod to 4.x (#368) 2026-01-26 21:55:15 +00:00
debug-server chore: bump to 1.0.1 - fix npm reference for ext-apps dependency in examples + update zod to 4.x (#368) 2026-01-26 21:55:15 +00:00
integration-server Improve example CSS files to better demonstrate host style integration 2026-01-30 09:32:26 -06:00
map-server chore: bump to 1.0.1 - fix npm reference for ext-apps dependency in examples + update zod to 4.x (#368) 2026-01-26 21:55:15 +00:00
pdf-server Cache full PDF bodies from servers without Range support (#411) 2026-01-30 20:24:18 +00:00
qr-server chore: bump to 1.0.1 - fix npm reference for ext-apps dependency in examples + update zod to 4.x (#368) 2026-01-26 21:55:15 +00:00
quickstart chore: bump to 1.0.1 - fix npm reference for ext-apps dependency in examples + update zod to 4.x (#368) 2026-01-26 21:55:15 +00:00
say-server chore: bump to 1.0.1 - fix npm reference for ext-apps dependency in examples + update zod to 4.x (#368) 2026-01-26 21:55:15 +00:00
scenario-modeler-server chore: bump to 1.0.1 - fix npm reference for ext-apps dependency in examples + update zod to 4.x (#368) 2026-01-26 21:55:15 +00:00
shadertoy-server Use escaped newlines in ShaderToy README JSON examples 2026-01-27 11:37:40 -06:00
sheet-music-server chore: bump to 1.0.1 - fix npm reference for ext-apps dependency in examples + update zod to 4.x (#368) 2026-01-26 21:55:15 +00:00
system-monitor-server Separate static and dynamic data in system-monitor-server tools 2026-01-28 11:04:35 -06:00
threejs-server chore: bump to 1.0.1 - fix npm reference for ext-apps dependency in examples + update zod to 4.x (#368) 2026-01-26 21:55:15 +00:00
transcript-server chore: bump to 1.0.1 - fix npm reference for ext-apps dependency in examples + update zod to 4.x (#368) 2026-01-26 21:55:15 +00:00
video-resource-server chore: bump to 1.0.1 - fix npm reference for ext-apps dependency in examples + update zod to 4.x (#368) 2026-01-26 21:55:15 +00:00
wiki-explorer-server chore: bump to 1.0.1 - fix npm reference for ext-apps dependency in examples + update zod to 4.x (#368) 2026-01-26 21:55:15 +00:00
run-all.ts add EXAMPLE=folder-name support for tests & basic-host (#292) 2026-01-19 20:16:37 +00:00