@postrun/react 3.1.0 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -679,26 +679,6 @@ function Connect({
679
679
  });
680
680
  return children(api);
681
681
  }
682
- var MEDIA_POLL_INTERVAL_MS = 1500;
683
- var MEDIA_POLL_TIMEOUT_MS = 30 * 60 * 1e3;
684
- async function pollUntilSettled(client, id, signal, onTick) {
685
- let latest;
686
- await pWaitFor__default.default(
687
- async () => {
688
- if (signal.aborted) {
689
- throw new DOMException("Upload aborted", "AbortError");
690
- }
691
- latest = (await js.mediaGet({ client, path: { id } })).data;
692
- onTick?.(latest);
693
- return latest.status === "ready" || latest.status === "failed";
694
- },
695
- { interval: MEDIA_POLL_INTERVAL_MS, timeout: MEDIA_POLL_TIMEOUT_MS }
696
- );
697
- if (!latest) {
698
- throw new Error("Media polling returned no result.");
699
- }
700
- return latest;
701
- }
702
682
  async function runUpload(client, file, options, signal, callbacks) {
703
683
  const created = (await js.mediaCreate({
704
684
  client,
@@ -721,7 +701,7 @@ async function runUpload(client, file, options, signal, callbacks) {
721
701
  });
722
702
  }
723
703
  callbacks.onProcessing();
724
- return pollUntilSettled(client, created.id, signal, callbacks.onPoll);
704
+ return js.waitForMedia(created.id, { client, signal, onPoll: callbacks.onPoll });
725
705
  }
726
706
  function toFileArray(files) {
727
707
  if (files instanceof File) return [files];