The plumbing every state hook in this package shares: subscribe to viewer
events, re-read a value when they fire, and feed the result to React through
useSyncExternalStore so it behaves under concurrent rendering.
Two details make this work with object-shaped snapshots, which
useSyncExternalStore otherwise loops on:
the value is recomputed only after a notification, not on every render;
isEqual lets a recomputed-but-unchanged value keep its previous identity,
so React can bail out of the re-render.
The viewer can be null (before PdfViewerSurface mounts, and during
SSR), so getSnapshot must handle that.
The plumbing every state hook in this package shares: subscribe to viewer events, re-read a value when they fire, and feed the result to React through
useSyncExternalStoreso it behaves under concurrent rendering.Two details make this work with object-shaped snapshots, which
useSyncExternalStoreotherwise loops on:isEquallets a recomputed-but-unchanged value keep its previous identity, so React can bail out of the re-render.The viewer can be
null(before PdfViewerSurface mounts, and during SSR), sogetSnapshotmust handle that.