@postrun/react 2.10.0 → 2.12.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.js CHANGED
@@ -1,13 +1,11 @@
1
1
  "use client";
2
2
  import { createContext, memo, useMemo, useState, useEffect, Fragment as Fragment$1, useRef, useLayoutEffect, useCallback, createElement, useContext, useId } from 'react';
3
3
  import { useInfiniteQuery, useQuery, useMutation, QueryClient } from '@tanstack/react-query';
4
- import { xPollDurationLabel, linkedinPollDurationLabel, 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, audiencePrivacyOptions, audienceUnselected, tiktokPrivacyLabel, parsePrivacyLevel, TIKTOK_AUDIENCE_REQUIRED_HINT, captionMaxFor, 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, PostrunError } from '@postrun/js';
5
- export { TIKTOK_CAPTION_MAX, captionMaxFor } from '@postrun/js';
4
+ import { xPollDurationLabel, linkedinPollDurationLabel, 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, audiencePrivacyOptions, audienceUnselected, tiktokPrivacyLabel, parsePrivacyLevel, TIKTOK_AUDIENCE_REQUIRED_HINT, captionMaxFor, 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, uploadToTarget, PostrunError } from '@postrun/js';
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';
8
8
  import pLimit from 'p-limit';
9
- import pRetry, { AbortError } from 'p-retry';
10
- import axios, { isAxiosError } from 'axios';
11
9
  import { enrichTweet, TweetContainer, TweetHeader, TweetInReplyTo, TweetBody, TweetMedia, QuotedTweet } from 'react-tweet';
12
10
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
13
11
  import { FiMessageCircle, FiRepeat, FiHeart, FiBarChart2, FiShare, FiGlobe, FiUsers, FiThumbsUp, FiMessageSquare, FiSend, FiBookmark, FiMoreHorizontal, FiFileText } from 'react-icons/fi';
@@ -572,46 +570,6 @@ function Connect({
572
570
  });
573
571
  return children(api);
574
572
  }
575
- var UploadError = class extends Error {
576
- status;
577
- constructor(status, message) {
578
- super(message);
579
- this.name = "UploadError";
580
- this.status = status;
581
- }
582
- };
583
- async function uploadBytes(target, file, options = {}) {
584
- const { onProgress, signal } = options;
585
- try {
586
- await axios.request({
587
- method: target.method,
588
- url: target.url,
589
- data: file,
590
- headers: target.headers,
591
- signal,
592
- onUploadProgress: (event) => {
593
- if (event.total) {
594
- onProgress?.(event.loaded / event.total);
595
- }
596
- }
597
- });
598
- onProgress?.(1);
599
- } catch (error) {
600
- if (signal?.aborted) {
601
- throw error;
602
- }
603
- if (isAxiosError(error)) {
604
- const status = error.response?.status ?? 0;
605
- throw new UploadError(
606
- status,
607
- status ? `Upload failed (HTTP ${status}).` : "Upload failed: network error."
608
- );
609
- }
610
- throw error;
611
- }
612
- }
613
-
614
- // src/media.ts
615
573
  var MEDIA_POLL_INTERVAL_MS = 1500;
616
574
  var MEDIA_POLL_TIMEOUT_MS = 30 * 60 * 1e3;
617
575
  async function pollUntilSettled(client, id, signal, onTick) {
@@ -645,23 +603,10 @@ async function runUpload(client, file, options, signal, callbacks) {
645
603
  }
646
604
  })).data;
647
605
  if (created.upload) {
648
- const target = created.upload;
649
- await pRetry(
650
- async () => {
651
- try {
652
- await uploadBytes(target, file, {
653
- onProgress: callbacks.onProgress,
654
- signal
655
- });
656
- } catch (uploadError) {
657
- if (uploadError instanceof UploadError && uploadError.status >= 400 && uploadError.status < 500) {
658
- throw new AbortError(uploadError);
659
- }
660
- throw uploadError;
661
- }
662
- },
663
- { retries: 3, signal }
664
- );
606
+ await uploadToTarget(file, created.upload, {
607
+ onProgress: callbacks.onProgress,
608
+ signal
609
+ });
665
610
  }
666
611
  callbacks.onProcessing();
667
612
  return pollUntilSettled(client, created.id, signal, callbacks.onPoll);
@@ -3382,6 +3327,6 @@ var postButtonStyle = {
3382
3327
  transition: "opacity 160ms ease"
3383
3328
  };
3384
3329
 
3385
- export { ArticleCard, AudienceSelect, CommercialDisclosure, Connect, Declaration, DocumentCard, InstagramPostPreview, InteractionToggles, LinkedInPostPreview, Poll, PostrunProvider, ReelPreview, TikTokCaptionField, TikTokPostPreview, TikTokPublishPanel, UploadError, XPoll, XPostPreview, connectionKeys, mediaKeys, postKeys, profileKeys, tiktokKeys, toPreviewMedia, useCalendar, useConnect, useConnection, useConnections, useCreatePost, useCreateProfile, useDeleteMedia, useDeletePost, useDeleteProfile, useDisconnect, useDiscoverableAccounts, useInfiniteList, useMedia, useMediaInfinite, useMediaList, useMediaUpload, usePost, usePostrun, usePosts, usePostsInfinite, useProfile, useProfiles, useProfilesInfinite, useSelectAccount, useTikTokCreatorInfo, useUpdateMedia, useUpdatePost, useUpdateProfile, useValidatePost };
3330
+ export { ArticleCard, AudienceSelect, CommercialDisclosure, Connect, Declaration, DocumentCard, InstagramPostPreview, InteractionToggles, LinkedInPostPreview, Poll, PostrunProvider, ReelPreview, TikTokCaptionField, TikTokPostPreview, TikTokPublishPanel, XPoll, XPostPreview, connectionKeys, mediaKeys, postKeys, profileKeys, tiktokKeys, toPreviewMedia, useCalendar, useConnect, useConnection, useConnections, useCreatePost, useCreateProfile, useDeleteMedia, useDeletePost, useDeleteProfile, useDisconnect, useDiscoverableAccounts, useInfiniteList, useMedia, useMediaInfinite, useMediaList, useMediaUpload, usePost, usePostrun, usePosts, usePostsInfinite, useProfile, useProfiles, useProfilesInfinite, useSelectAccount, useTikTokCreatorInfo, useUpdateMedia, useUpdatePost, useUpdateProfile, useValidatePost };
3386
3331
  //# sourceMappingURL=index.js.map
3387
3332
  //# sourceMappingURL=index.js.map