refactor(superdoc): publicize SearchMatch on the public type contract (SD-2828)#3105
Conversation
β¦ (SD-2828) Promote `SearchMatch` (and its `DocRange` companion) from a private search-extension typedef to the public `superdoc` type contract. Wires `SuperDoc.search()` to `SearchMatch[] | undefined` and `SuperDoc.goToSearchResult()` to `SearchMatch`, so consumers wiring a custom search UI get real types on `id`, `from`, `to`, `text` instead of `Object`. Adds a consumer fixture that destructures the public fields and round-trips a result through `goToSearchResult`, plus strict `Equal<A,B>` type-equality assertions so a future re-narrowing or field strip surfaces as a CI failure.
Codecov Reportβ All modified and coverable lines are covered by tests. π’ Thoughts on this report? Let us know! |
|
π 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 |
Closes out SD-2980's helper typing. The remaining 4 public helpers
exported via `trackChangesHelpers` (under `superdoc/super-editor`) now
carry concrete JSDoc and emit real return shapes instead of
`any` / `any[]`:
- `getLiveInlineMarksInRange({ doc, from, to })` β `PmMark[]`
- `findTrackedMarkBetween({ tr, from, to, markName, attrs?, offset? })`
β `TrackedMarkRange | null`
- `trackedTransaction({ tr, state, user, replacements? })` β `Transaction`
- `getTrackChanges(state, id?)` β `TrackedMarkRange[]`
Reuses the existing `trackChangesHelpers/types.js` from PR B; adds one
new typedef:
- `TrackedMarkRange = { from: number; to: number; mark: PmMark }`
shared by `findTrackedMarkBetween`'s non-null return and
`getTrackChanges`'s array element.
`trackedTransaction.js` notes: the previous JSDoc used the single-blob
`@param {{ ... }} params` form, which does NOT bind to the destructured
arrow signature in vite-plugin-dts emit. Switched to per-property style
(matches PR B's working `findMarkInRangeBySnapshot` pattern). Also
deleted `trackedTransaction.d.ts` β a hand-written shim added in superdoc-dev#3105
that pinned the emit to `(...args: any[]): any` and silently shadowed
the real JSDoc. The shim is NOT in the `check-dts-shadows` allowlist
(only `packages/collaboration-yjs/` is), so deletion aligns with the
SD-2922 policy.
Drains the final 14 of 14 PR C audit findings; `tier-3-helpers` reaches
0 for the first time (total broad audit 171 β 157). The remaining
broad findings live outside SD-2980 scope (`tier-5-other`,
`tier-4-public-contract` for SD-3235). Supported-root strict gate
remains 0.
Consumer fixture `track-changes-helpers-typed.ts` extended with PR C
coverage: each new helper's return type, element members
(`mark.type.name`, `from`, `to`), `Transaction` PM surface
(`.docChanged`, `.steps`), literal-union `replacements`, nullable
state, and `@ts-expect-error` on bad-shape args.
Scope intentionally narrow: no other trackChangesHelpers files touched
(internal step builders untouched), no helper de-dupe, no refactors.
Verified: type-check clean; pnpm test:editor β 13120 pass;
deep-type-audit --pack β 157 findings (was 171); --strict-supported-root
β PASS (0 entries); typecheck-matrix β 79/79.
Promotes `SearchMatch` (and its `DocRange` companion) from a private search-extension typedef to the public `superdoc` type contract. Consumers wiring a custom search UI now get real field types on `id`, `from`, `to`, `text` instead of `Object`.
Why now: this is the next item on the SD-2828 closeout list after the provider widening (#3101). No runtime change.
Review: confirm `SearchMatch` mirrors the source typedef in the search extension (`text`, `from`, `to`, `id`, optional `ranges` and `trackerIds`). The `all-public-types.ts` diff is two regenerated entries from the `--write` step.
Verified: consumer matrix 39/39, check:jsdoc clean, build:es declaration audit clean, SuperDoc.test.js 79/79.