Skip to content

fix(handlers): register the default handlers only when asked - #36

Merged
skjnldsv merged 1 commit into
mainfrom
fix/explicit-default-handlers
Sep 11, 2026
Merged

skjnldsv merged 1 commit into
mainfrom
fix/explicit-default-handlers

Conversation

@skjnldsv

Copy link
Copy Markdown
Contributor

Importing @nextcloud/viewer still registered the image, video and audio handlers as a side effect of lib/index.ts. The server now calls registerDefaultHandlers() from core/src/viewer-init.ts (nextcloud/server#63954), so the import-time call is gone: importing the package registers nothing, the init script does it on every page, and a page the server does not set up (the playground, a standalone host) calls it itself.

Relates to nextcloud/server#63954, review nextcloud/server#63954 (review)

Two copies of the package on one page also stopped warning Handler with id images is already registered. about each other, since only the init script registers now and any later call is a no-op.

Important

Breaking for a consumer that imports the package outside a server page and expected the handlers to be there. Those need one registerDefaultHandlers() call; the README section "Open the viewer programmatically" says so now.

Unit tests cover the entry registering nothing until asked, and the call being idempotent. Playwright ran green on chromium only (12 tests), Firefox is not installed locally.

👾 This pull request was assisted by Claude Code, commits carry an Assisted-by trailer.

Importing the package no longer registers the image, video and audio
handlers. The server does it from its `viewer-init` init script on every
page, and a page the server does not set up calls
`registerDefaultHandlers()` itself, as the playground already did.

With several copies of the package on one page, each copy registering on
import warned "Handler with id X is already registered." about the
others. It also made the entry's side effects invisible from a consumer's
import line, which is what the review on nextcloud/server#63954 asked to
avoid.

Assisted-by: ClaudeCode:claude-opus-5
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
@skjnldsv skjnldsv added status: review Waiting for reviews type: breaking 💥 changes that require a new major version AI assisted labels Sep 11, 2026
@codecov

codecov Bot commented Sep 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.83%. Comparing base (a86decd) to head (8e6af69).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #36      +/-   ##
==========================================
- Coverage   87.84%   87.83%   -0.01%     
==========================================
  Files          36       36              
  Lines        2477     2475       -2     
  Branches      519      519              
==========================================
- Hits         2176     2174       -2     
  Misses        297      297              
  Partials        4        4              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@skjnldsv
skjnldsv merged commit 67ae21c into main Sep 11, 2026
18 checks passed
@skjnldsv
skjnldsv deleted the fix/explicit-default-handlers branch September 11, 2026 14:05
@skjnldsv skjnldsv mentioned this pull request Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI assisted status: review Waiting for reviews type: breaking 💥 changes that require a new major version

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant