refactor(superdoc): widen provider fields to CollaborationProvider (SD-2828)#3101
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 13ff0a9ab1
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…erts, accurate comments)
…type Reviewer flagged that widening Document.provider to CollaborationProvider allows providers without disconnect/destroy methods (Liveblocks-style adapters), so destroy() would throw under such providers. Use double optional chain to guard both the provider and its method.
CollaborationProvider.disconnect and .destroy are optional, so cleanup
must guard the method, not just the provider. Adds a regression test
covering a minimal { on, off } provider — the shape Liveblocks-style
adapters use.
|
🎉 This PR is included in @superdoc-dev/mcp v0.3.0-next.37 The release is available on GitHub release |
|
🎉 This PR is included in vscode-ext v2.3.0-next.81 |
|
🎉 This PR is included in @superdoc-dev/react v1.2.0-next.79 The release is available on GitHub release |
|
🎉 This PR is included in superdoc-cli v0.8.0-next.55 The release is available on GitHub release |
|
🎉 This PR is included in superdoc v1.30.0-next.38 The release is available on GitHub release |
|
🎉 This PR is included in superdoc-sdk v1.8.0-next.40 |
|
🎉 This PR is included in superdoc-cli v0.9.0 The release is available on GitHub release |
|
🎉 This PR is included in superdoc v1.32.0 The release is available on GitHub release |
|
🎉 This PR is included in @superdoc-dev/mcp v0.4.0 The release is available on GitHub release |
|
🎉 This PR is included in @superdoc-dev/react v1.3.0 The release is available on GitHub release |
|
🎉 This PR is included in vscode-ext v2.4.0 |
|
🎉 This PR is included in superdoc-sdk v1.9.0 |
SD-2828 closeout step 1/3+. Widens public provider fields from
HocuspocusProvidertoCollaborationProviderto match the runtime, which stores whatever provider the consumer passed viaConfig.modules.collaboration.provider(Hocuspocus, Liveblocks-Yjs, Tiptap-Collab, or any conforming adapter).Public type change (consumer-observable):
Why: the previous typedef was Hocuspocus-specific. Non-Hocuspocus consumers (Liveblocks, Tiptap, custom adapters) saw
superdoc.provider.Xtyped against Hocuspocus members that don't exist on their actual provider — a typedef that lied about the runtime. The runtime has always accepted anyCollaborationProviderper theConfig.modules.collaboration.providertypedef.Migration: consumers calling Hocuspocus-specific members on these fields (e.g.
superdoc.provider?.configuration,doc.provider?.subscribedToBroadcastChannel) need to narrow first. The typicalif (provider)truthy pattern is unchanged.Regression net: new fixture
tests/consumer-typecheck/src/provider-collaboration-provider.tspins the contract. AssertsSuperDoc.provider,Document.provider, and a hand-rolled minimalCollaborationProviderall typecheck. Two matrix scenarios added (bundler + node16), bothmustPass.Closes 2 of 3 originally-flagged provider errors in
SuperDoc.js. The third (attachCollaborationcall site, line ~815) is a separate concern — super-editor'sattachCollaborationparameter expects an augmentedCollaborationProvider & { awareness?; disconnect? }shape. That's an internal call-site issue, not a public-contract gap; tracked separately.Verified:
pnpm --filter superdoc check:jsdoc→ 3 gated files clean.pnpm --filter superdoc build:es→ no FAIL-level findings.node tests/consumer-typecheck/typecheck-matrix.mjs→ 37 passed (35 existing + 2 new), 0 failed.pnpm exec vitest run src/core/SuperDoc.test.js→ 78 passed.Must stay the same: runtime behavior. The provider stored in
superdoc.provideranddoc.provideris the same value the consumer passed; only the public typedef widens to match.Review: confirm emitted
dist/superdoc/src/core/SuperDoc.d.tsshowsprovider: CollaborationProvider | undefinedanddist/superdoc/src/core/types/index.d.tsshowsDocument.provider?: CollaborationProvider.Next SD-2828 closeout PRs (per audit): SearchMatch publicization, ExportParams
fieldsHighlightColor: string | null. ToolbarConfig triage to follow.