@postrun/react 3.1.0 → 3.3.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 +1 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +46 -45
- package/dist/index.d.ts +46 -45
- package/dist/index.js +2 -22
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createContext, memo, useMemo, useState, Fragment as Fragment$1, useRef, useLayoutEffect, useCallback, useEffect, createElement, useContext, useId } from 'react';
|
|
3
3
|
import { useInfiniteQuery, useQuery, useMutation, useQueries, QueryClient } from '@tanstack/react-query';
|
|
4
|
-
import { xPollDurationLabel, linkedinPollDurationLabel, captionMaxFor, UploadError, TIKTOK_CAPTION_MAX, createPostrunClient, profilesList, profilesGet, profilesCreate, profilesUpdate, profilesDelete, connectionsConnect, connectionsListByProfile, connectionsGet, connectionsListAccounts, connectionsSelect, connectionsDelete, mediaGet, mediaList, mediaUpdate, mediaDelete, postsList, postsGet, postsCreate, buildCreatePost, isPostPlatform, failedVariants, isPublished, postsValidate, postsUpdate, postsDelete, tiktokCreatorInfo, groupAdTree, audiencePrivacyOptions, audienceUnselected, tiktokPrivacyLabel, parsePrivacyLevel, TIKTOK_AUDIENCE_REQUIRED_HINT, commercialLabelNotice, commercialDisclosureIncomplete, setCommercialDisclosure, setBrandKind, TIKTOK_DISCLOSURE_REQUIRED_HINT, TIKTOK_BRANDED_CONTENT_POLICY_URL, TIKTOK_MUSIC_CONFIRMATION_URL, interactionRows, interactionValueKey, toggleInteraction, tiktokOptionsReady, TIKTOK_PROCESSING_NOTICE, brandedContentDeclared, mediaCreate, uploadFile, PostrunError } from '@postrun/js';
|
|
4
|
+
import { xPollDurationLabel, linkedinPollDurationLabel, captionMaxFor, UploadError, TIKTOK_CAPTION_MAX, createPostrunClient, profilesList, profilesGet, profilesCreate, profilesUpdate, profilesDelete, connectionsConnect, connectionsListByProfile, connectionsGet, connectionsListAccounts, connectionsSelect, connectionsDelete, mediaGet, mediaList, mediaUpdate, mediaDelete, postsList, postsGet, postsCreate, buildCreatePost, isPostPlatform, failedVariants, isPublished, postsValidate, postsUpdate, postsDelete, tiktokCreatorInfo, groupAdTree, audiencePrivacyOptions, audienceUnselected, tiktokPrivacyLabel, parsePrivacyLevel, TIKTOK_AUDIENCE_REQUIRED_HINT, commercialLabelNotice, commercialDisclosureIncomplete, setCommercialDisclosure, setBrandKind, TIKTOK_DISCLOSURE_REQUIRED_HINT, TIKTOK_BRANDED_CONTENT_POLICY_URL, TIKTOK_MUSIC_CONFIRMATION_URL, interactionRows, interactionValueKey, toggleInteraction, tiktokOptionsReady, TIKTOK_PROCESSING_NOTICE, brandedContentDeclared, mediaCreate, uploadFile, waitForMedia, PostrunError } from '@postrun/js';
|
|
5
5
|
export { TIKTOK_CAPTION_MAX, UploadError, captionMaxFor } from '@postrun/js';
|
|
6
6
|
import Nango, { AuthError } from '@nangohq/frontend';
|
|
7
7
|
import pWaitFor, { TimeoutError } from 'p-wait-for';
|
|
@@ -652,26 +652,6 @@ function Connect({
|
|
|
652
652
|
});
|
|
653
653
|
return children(api);
|
|
654
654
|
}
|
|
655
|
-
var MEDIA_POLL_INTERVAL_MS = 1500;
|
|
656
|
-
var MEDIA_POLL_TIMEOUT_MS = 30 * 60 * 1e3;
|
|
657
|
-
async function pollUntilSettled(client, id, signal, onTick) {
|
|
658
|
-
let latest;
|
|
659
|
-
await pWaitFor(
|
|
660
|
-
async () => {
|
|
661
|
-
if (signal.aborted) {
|
|
662
|
-
throw new DOMException("Upload aborted", "AbortError");
|
|
663
|
-
}
|
|
664
|
-
latest = (await mediaGet({ client, path: { id } })).data;
|
|
665
|
-
onTick?.(latest);
|
|
666
|
-
return latest.status === "ready" || latest.status === "failed";
|
|
667
|
-
},
|
|
668
|
-
{ interval: MEDIA_POLL_INTERVAL_MS, timeout: MEDIA_POLL_TIMEOUT_MS }
|
|
669
|
-
);
|
|
670
|
-
if (!latest) {
|
|
671
|
-
throw new Error("Media polling returned no result.");
|
|
672
|
-
}
|
|
673
|
-
return latest;
|
|
674
|
-
}
|
|
675
655
|
async function runUpload(client, file, options, signal, callbacks) {
|
|
676
656
|
const created = (await mediaCreate({
|
|
677
657
|
client,
|
|
@@ -694,7 +674,7 @@ async function runUpload(client, file, options, signal, callbacks) {
|
|
|
694
674
|
});
|
|
695
675
|
}
|
|
696
676
|
callbacks.onProcessing();
|
|
697
|
-
return
|
|
677
|
+
return waitForMedia(created.id, { client, signal, onPoll: callbacks.onPoll });
|
|
698
678
|
}
|
|
699
679
|
function toFileArray(files) {
|
|
700
680
|
if (files instanceof File) return [files];
|