Repository navigation
v1.29.0
Minor Changes
-
fc9c4ac: Copy text the server makes after the click.
copy()(andCopyField'svalue) now accepts an async function, such as one that creates a share link:copy(async ({ signal }) => (await fetch(url, { signal })).text()). The write starts during the click with a promise of the text, so it works in Safari, which ends the click at the firstawait; checked in Chromium, Firefox and WebKit. The source receives the copy'sAbortSignal, soreset()or unmounting also cancels the request, and text that arrives after that is never written. It may resolve to text or JSON. A rejected request is aninvalid-payloaderror with the thrown value as itscause; if the write fails after the text arrived,retry()writes it again without asking the server.Type change: while an async source is still producing its text,
CopyingState.payloadisnull, so its type is nowCopyPayload | null. Code that readsstate.payloadduringcopyingneeds a null check; synchronous sources behave exactly as before. Custom adapters can implement the new optionalwriteDeferred(text, context)to start their write before the text arrives; without it, the machine waits for the text and callswrite.useCopygrows by about 0.2 kB.