@select-org/select-post-builder 1.1.45 → 1.1.46
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.d.ts +28 -28
- package/dist/post-builder.cjs.js +11 -11
- package/dist/post-builder.js +67 -8
- package/package.json +1 -1
package/dist/post-builder.js
CHANGED
|
@@ -3267,6 +3267,59 @@ class FilestoreApi {
|
|
|
3267
3267
|
getFileNameAndExt(n) {
|
|
3268
3268
|
return n.split("/").pop();
|
|
3269
3269
|
}
|
|
3270
|
+
async pollUploadStatus(n, d = 60) {
|
|
3271
|
+
let p = 500;
|
|
3272
|
+
for (let m = 0; m < d; m++) {
|
|
3273
|
+
const y = (await this.api.get(`/api/v2/upload/status/${n}`, {
|
|
3274
|
+
headers: { "Content-Type": "application/json" }
|
|
3275
|
+
})).data?.data;
|
|
3276
|
+
if (!y?.status) throw new Error("Unexpected response from upload status endpoint");
|
|
3277
|
+
if (y.status === "succeeded" && y.result) return y.result;
|
|
3278
|
+
if (y.status === "failed") throw new Error(y.error || "Upload processing failed");
|
|
3279
|
+
await new Promise((b) => setTimeout(b, p)), p = Math.min(p * 1.5, 1e4);
|
|
3280
|
+
}
|
|
3281
|
+
throw new Error("Upload processing timed out");
|
|
3282
|
+
}
|
|
3283
|
+
async uploadChunked(n, d) {
|
|
3284
|
+
if (n.size === 0) throw new Error("Cannot upload an empty file");
|
|
3285
|
+
const p = await this.api.post(
|
|
3286
|
+
"/api/v2/upload/init",
|
|
3287
|
+
{ content_type: n.type, total_bytes: n.size, filename: n.name },
|
|
3288
|
+
{ headers: { "Content-Type": "application/json" } }
|
|
3289
|
+
), { media_id: m, chunk_size: g } = p.data.data;
|
|
3290
|
+
let y = 0, b = 1;
|
|
3291
|
+
for (; y < n.size; ) {
|
|
3292
|
+
const E = Math.min(y + g, n.size), T = n.slice(y, E), C = new FormData();
|
|
3293
|
+
C.append("media_id", m), C.append("chunk_index", String(b)), C.append("chunk", T, n.name), await this.api.post("/api/v2/upload/append", C), y = E, b++, d?.(Math.round(y / n.size * 70));
|
|
3294
|
+
}
|
|
3295
|
+
await this.api.post(
|
|
3296
|
+
"/api/v2/upload/finalize",
|
|
3297
|
+
{ media_id: m, compress: !0, crop_square: !1 },
|
|
3298
|
+
{ headers: { "Content-Type": "application/json" } }
|
|
3299
|
+
);
|
|
3300
|
+
const S = simulatePollingProgress(d, 70, 99);
|
|
3301
|
+
try {
|
|
3302
|
+
const E = await this.pollUploadStatus(m);
|
|
3303
|
+
return S && clearInterval(S), d?.(100), E;
|
|
3304
|
+
} catch (E) {
|
|
3305
|
+
throw S && clearInterval(S), E;
|
|
3306
|
+
}
|
|
3307
|
+
}
|
|
3308
|
+
async uploadVoiceV2(n) {
|
|
3309
|
+
const d = new FormData();
|
|
3310
|
+
d.set("file", n);
|
|
3311
|
+
const m = (await this.api.post("/api/v2/upload/simple", d)).data?.data;
|
|
3312
|
+
if (!m?.media_id) throw new Error("Voice upload failed: no media_id");
|
|
3313
|
+
return this.pollUploadStatus(m.media_id);
|
|
3314
|
+
}
|
|
3315
|
+
}
|
|
3316
|
+
function simulatePollingProgress(u, n, d) {
|
|
3317
|
+
if (!u) return null;
|
|
3318
|
+
let p = n;
|
|
3319
|
+
const m = setInterval(() => {
|
|
3320
|
+
p = Math.min(p + 5, d), u(p), p >= d && clearInterval(m);
|
|
3321
|
+
}, 300);
|
|
3322
|
+
return m;
|
|
3270
3323
|
}
|
|
3271
3324
|
class MFSApi {
|
|
3272
3325
|
url;
|
|
@@ -38676,7 +38729,7 @@ const ImageSearchModal$1 = lazy(
|
|
|
38676
38729
|
try {
|
|
38677
38730
|
const { blob: pe, duration: ve } = await Q();
|
|
38678
38731
|
re(!0);
|
|
38679
|
-
const ye = pe.type.split("/")[1]?.split(";")[0] ?? "webm", Se = new File([pe], `${v4()}.${ye}`), Ee = await L.
|
|
38732
|
+
const ye = pe.type.split("/")[1]?.split(";")[0] ?? "webm", Se = new File([pe], `${v4()}.${ye}`), Ee = await L.uploadVoiceV2(Se);
|
|
38680
38733
|
Ee?.url && y?.({ voiceUrl: Ee.url, voiceTime: ve });
|
|
38681
38734
|
} catch {
|
|
38682
38735
|
} finally {
|
|
@@ -43932,6 +43985,7 @@ const MediaPreviewModal = ({
|
|
|
43932
43985
|
"video",
|
|
43933
43986
|
{
|
|
43934
43987
|
src: u.attrs.src,
|
|
43988
|
+
poster: u.attrs.payload?.sources?.thumbnail?.url,
|
|
43935
43989
|
controls: !0,
|
|
43936
43990
|
className: cn("object-contain w-full h-auto", p && "border-2 border-blue-500"),
|
|
43937
43991
|
onDoubleClick: () => y(!0)
|
|
@@ -47438,7 +47492,7 @@ const isYouTubeUrl = (u) => new RegExp(YOUTUBE_REGEX).test(u.trim()), isSpotifyU
|
|
|
47438
47492
|
];
|
|
47439
47493
|
}
|
|
47440
47494
|
}), uploadFile = async (u) => {
|
|
47441
|
-
const { file: n, api: d, onProgress: p, mediaItemType: m } = u, g = n instanceof File ? n : new File([n], "upload.bin", { type: n.type }), y = await d.
|
|
47495
|
+
const { file: n, api: d, onProgress: p, mediaItemType: m } = u, g = n instanceof File ? n : new File([n], "upload.bin", { type: n.type }), y = await d.uploadChunked(g, p);
|
|
47442
47496
|
return createMediaOption(y, m);
|
|
47443
47497
|
}, uploadUrl = async (u) => {
|
|
47444
47498
|
const n = u?.url, d = u?.api, p = u?.onProgress, m = u?.mediaItemType, g = u?.searchFrom;
|
|
@@ -47566,12 +47620,17 @@ const SmartMediaUpload = Extension.create({
|
|
|
47566
47620
|
const S = this.storage.blobUrls.get(g.uid);
|
|
47567
47621
|
S && (URL.revokeObjectURL(S), this.storage.blobUrls.delete(g.uid));
|
|
47568
47622
|
const E = b?.sources?.original?.url || b?.sources?.thumbnail?.url;
|
|
47569
|
-
if (E
|
|
47570
|
-
|
|
47571
|
-
|
|
47572
|
-
|
|
47573
|
-
|
|
47574
|
-
|
|
47623
|
+
if (E) {
|
|
47624
|
+
const T = b?.imageType ?? "", C = T.startsWith("video/") ? MediaNodeTypes.Video : T.startsWith("audio/") ? MediaNodeTypes.Audio : g.type;
|
|
47625
|
+
n.commands.updateMediaByUid(g.uid, {
|
|
47626
|
+
src: E,
|
|
47627
|
+
type: C,
|
|
47628
|
+
uploading: !1,
|
|
47629
|
+
progress: 100,
|
|
47630
|
+
payload: b
|
|
47631
|
+
});
|
|
47632
|
+
} else n.commands.deleteMediaByUid(g.uid);
|
|
47633
|
+
if (y.onUploadComplete?.(g.uid, E), E) {
|
|
47575
47634
|
const { sessionId: T, editorType: C } = this.storage.getAnalyticsContext(n);
|
|
47576
47635
|
if (T && C) {
|
|
47577
47636
|
const A = getAnalyticsStore();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@select-org/select-post-builder",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.46",
|
|
4
4
|
"description": "A reusable, extensible Post Builder widget for the Select platform and beyond.",
|
|
5
5
|
"main": "./dist/post-builder.cjs.js",
|
|
6
6
|
"module": "./dist/post-builder.js",
|