Skip to content

refactor(web): rebuild web-embed-pdf on @simplepdf/embed, WebMCP on by default, PDF links in any case - #51

Merged
bendersej merged 8 commits into
mainfrom
P074-02-web-embed-on-core
Sep 28, 2026
Merged

bendersej merged 8 commits into
mainfrom
P074-02-web-embed-on-core

Conversation

@bendersej

@bendersej bendersej commented Sep 26, 2026 •

Copy link
Copy Markdown
Member

Background

@simplepdf/web-embed-pdf is loaded unpinned from unpkg by customer sites, so a publish reaches every site at once. It re-implemented what @simplepdf/embed already owns: the editor URL, loading the document (host fetch, then the ?open fallback) and the postMessage bridge. This PR rebuilds it on createEmbed. window.simplePDF, the script-tag attributes and the modal stay unchanged.

Changes

  • The editor URL, document loading and the bridge come from createEmbed; the modal markup and CSS are kept byte for byte.
  • WebMCP, on by default: while the editor is open, an in-browser agent on the page finds the editor's tools. webmcp="false" or setConfig({ webMCP: { enabled: false } }) turns it off. Every call goes through the editor's usual permissions.
  • PDF links open in SimplePDF whatever the extension case, query string or fragment (Consent.PDF, form.pdf?ver=2, guide.pdf#page=3); links already detected keep opening.
  • One shared fixture of link cases (web/src/__tests__/fixtures/pdf-link-cases.json) drives the unit test.
  • Japanese and Dutch pages get their editor language.
  • A SimplePDF /documents/<id> link opens the stored document directly.
  • A companyIdentifier that cannot form an editor address (a URL, spaces, dots, underscores) logs an error and opens nothing. An identifier with no account behind it opens the editor, which shows its own error page.
  • Every href 1.8.4 accepted still works (relative, data:, blob:), and so does an uppercase companyIdentifier.
  • The build stays a single UMD file (the Chrome extension evaluates dist/index.js).
  • One minor changeset (1.9.0).

Notes

  • A browser test suite (in the internal repo) was written first against the published 1.8.4, then passed unchanged on this rewrite. Every assertion is proven by a deliberate regression that fails it.
  • Bundle: 10.5 KB → 35.6 KB minified, 4.1 → 11.7 KB gzip (the core, including its WebMCP module, which UMD cannot split out).
  • Size cap: web adds none. It inherits the 50 MB host-fetch cap every published @simplepdf/embed already ships (React 1.11+ has it today); above it, the document goes to the editor by URL.

@bendersej bendersej changed the title refactor(web): rebuild web-embed-pdf on @simplepdf/embed, WebMCP opt-in, PDF links in any case refactor(web): rebuild web-embed-pdf on @simplepdf/embed, WebMCP on by default, PDF links in any case Sep 28, 2026
@bendersej
bendersej force-pushed the P074-02-web-embed-on-core branch from a8a3941 to b72f50a Compare September 28, 2026 09:15
@bendersej
bendersej merged commit 3afba3b into main Sep 28, 2026
4 checks passed
@bendersej
bendersej deleted the P074-02-web-embed-on-core branch September 28, 2026 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant