@scalemule/sdk 0.0.56 → 0.0.57
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.mts +24 -2
- package/dist/index.d.ts +24 -2
- package/dist/index.js +75 -37
- package/dist/index.mjs +75 -37
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -4687,6 +4687,17 @@ interface TransformResult {
|
|
|
4687
4687
|
height: number;
|
|
4688
4688
|
format: string;
|
|
4689
4689
|
}
|
|
4690
|
+
type PhotoPreset = 'hero' | 'inline' | 'thumbnail' | 'avatar' | 'logo';
|
|
4691
|
+
interface PhotoManifest {
|
|
4692
|
+
file_id: string;
|
|
4693
|
+
photo_id: string;
|
|
4694
|
+
content_type: string;
|
|
4695
|
+
preset: PhotoPreset | 'original';
|
|
4696
|
+
ready: boolean;
|
|
4697
|
+
variants: Record<string, string>;
|
|
4698
|
+
srcset: string | null;
|
|
4699
|
+
default: string | null;
|
|
4700
|
+
}
|
|
4690
4701
|
/** Options for building a transform URL or requesting a transform */
|
|
4691
4702
|
interface TransformOptions {
|
|
4692
4703
|
width?: number;
|
|
@@ -4745,6 +4756,15 @@ declare class PhotoService extends ServiceModule {
|
|
|
4745
4756
|
delete(id: string, options?: RequestOptions): Promise<ApiResponse<{
|
|
4746
4757
|
deleted: boolean;
|
|
4747
4758
|
}>>;
|
|
4759
|
+
getPresets(options?: RequestOptions): Promise<ApiResponse<Record<PhotoPreset, {
|
|
4760
|
+
widths: number[];
|
|
4761
|
+
}>>>;
|
|
4762
|
+
getManifest(id: string, params?: {
|
|
4763
|
+
preset?: PhotoPreset;
|
|
4764
|
+
}, options?: RequestOptions): Promise<ApiResponse<PhotoManifest>>;
|
|
4765
|
+
getPublicManifest(id: string, params?: {
|
|
4766
|
+
preset?: PhotoPreset;
|
|
4767
|
+
}, options?: RequestOptions): Promise<ApiResponse<PhotoManifest>>;
|
|
4748
4768
|
/**
|
|
4749
4769
|
* Build an absolute URL for the on-demand transform endpoint.
|
|
4750
4770
|
*
|
|
@@ -5005,6 +5025,7 @@ interface MediaManifest {
|
|
|
5005
5025
|
file_id: string;
|
|
5006
5026
|
content_type: string;
|
|
5007
5027
|
preset: MediaPreset | 'original';
|
|
5028
|
+
ready?: boolean;
|
|
5008
5029
|
variants: Record<string, string>;
|
|
5009
5030
|
srcset: string | null;
|
|
5010
5031
|
default: string | null;
|
|
@@ -5071,14 +5092,15 @@ declare class MediaService extends ServiceModule {
|
|
|
5071
5092
|
getManifest(fileId: string, options?: MediaManifestOptions, requestOptions?: RequestOptions): Promise<ApiResponse<MediaManifest>>;
|
|
5072
5093
|
buildAsset(file: FileInfo, options?: MediaManifestOptions & {
|
|
5073
5094
|
photoId?: string | null;
|
|
5074
|
-
}): MediaAsset;
|
|
5095
|
+
}, manifest?: MediaManifest | null): MediaAsset;
|
|
5075
5096
|
buildManifest(file: FileInfo, options?: MediaManifestOptions): MediaManifest | null;
|
|
5076
5097
|
private uploadAnonymous;
|
|
5077
5098
|
private uploadImage;
|
|
5078
5099
|
private waitForAnonymousReady;
|
|
5079
5100
|
private fetchInfoBestEffort;
|
|
5101
|
+
private fetchManifest;
|
|
5080
5102
|
private pollPhotoOptimizationComplete;
|
|
5081
|
-
private
|
|
5103
|
+
private waitForAnonymousManifest;
|
|
5082
5104
|
}
|
|
5083
5105
|
|
|
5084
5106
|
type TtsAccessMode = 'owner_private' | 'tenant_shared' | 'public';
|
package/dist/index.d.ts
CHANGED
|
@@ -4687,6 +4687,17 @@ interface TransformResult {
|
|
|
4687
4687
|
height: number;
|
|
4688
4688
|
format: string;
|
|
4689
4689
|
}
|
|
4690
|
+
type PhotoPreset = 'hero' | 'inline' | 'thumbnail' | 'avatar' | 'logo';
|
|
4691
|
+
interface PhotoManifest {
|
|
4692
|
+
file_id: string;
|
|
4693
|
+
photo_id: string;
|
|
4694
|
+
content_type: string;
|
|
4695
|
+
preset: PhotoPreset | 'original';
|
|
4696
|
+
ready: boolean;
|
|
4697
|
+
variants: Record<string, string>;
|
|
4698
|
+
srcset: string | null;
|
|
4699
|
+
default: string | null;
|
|
4700
|
+
}
|
|
4690
4701
|
/** Options for building a transform URL or requesting a transform */
|
|
4691
4702
|
interface TransformOptions {
|
|
4692
4703
|
width?: number;
|
|
@@ -4745,6 +4756,15 @@ declare class PhotoService extends ServiceModule {
|
|
|
4745
4756
|
delete(id: string, options?: RequestOptions): Promise<ApiResponse<{
|
|
4746
4757
|
deleted: boolean;
|
|
4747
4758
|
}>>;
|
|
4759
|
+
getPresets(options?: RequestOptions): Promise<ApiResponse<Record<PhotoPreset, {
|
|
4760
|
+
widths: number[];
|
|
4761
|
+
}>>>;
|
|
4762
|
+
getManifest(id: string, params?: {
|
|
4763
|
+
preset?: PhotoPreset;
|
|
4764
|
+
}, options?: RequestOptions): Promise<ApiResponse<PhotoManifest>>;
|
|
4765
|
+
getPublicManifest(id: string, params?: {
|
|
4766
|
+
preset?: PhotoPreset;
|
|
4767
|
+
}, options?: RequestOptions): Promise<ApiResponse<PhotoManifest>>;
|
|
4748
4768
|
/**
|
|
4749
4769
|
* Build an absolute URL for the on-demand transform endpoint.
|
|
4750
4770
|
*
|
|
@@ -5005,6 +5025,7 @@ interface MediaManifest {
|
|
|
5005
5025
|
file_id: string;
|
|
5006
5026
|
content_type: string;
|
|
5007
5027
|
preset: MediaPreset | 'original';
|
|
5028
|
+
ready?: boolean;
|
|
5008
5029
|
variants: Record<string, string>;
|
|
5009
5030
|
srcset: string | null;
|
|
5010
5031
|
default: string | null;
|
|
@@ -5071,14 +5092,15 @@ declare class MediaService extends ServiceModule {
|
|
|
5071
5092
|
getManifest(fileId: string, options?: MediaManifestOptions, requestOptions?: RequestOptions): Promise<ApiResponse<MediaManifest>>;
|
|
5072
5093
|
buildAsset(file: FileInfo, options?: MediaManifestOptions & {
|
|
5073
5094
|
photoId?: string | null;
|
|
5074
|
-
}): MediaAsset;
|
|
5095
|
+
}, manifest?: MediaManifest | null): MediaAsset;
|
|
5075
5096
|
buildManifest(file: FileInfo, options?: MediaManifestOptions): MediaManifest | null;
|
|
5076
5097
|
private uploadAnonymous;
|
|
5077
5098
|
private uploadImage;
|
|
5078
5099
|
private waitForAnonymousReady;
|
|
5079
5100
|
private fetchInfoBestEffort;
|
|
5101
|
+
private fetchManifest;
|
|
5080
5102
|
private pollPhotoOptimizationComplete;
|
|
5081
|
-
private
|
|
5103
|
+
private waitForAnonymousManifest;
|
|
5082
5104
|
}
|
|
5083
5105
|
|
|
5084
5106
|
type TtsAccessMode = 'owner_private' | 'tenant_shared' | 'public';
|
package/dist/index.js
CHANGED
|
@@ -6566,6 +6566,15 @@ var PhotoService = class extends ServiceModule {
|
|
|
6566
6566
|
async delete(id, options) {
|
|
6567
6567
|
return this.del(`/${id}`, options);
|
|
6568
6568
|
}
|
|
6569
|
+
async getPresets(options) {
|
|
6570
|
+
return this._get("/presets", options);
|
|
6571
|
+
}
|
|
6572
|
+
async getManifest(id, params, options) {
|
|
6573
|
+
return this._get(this.withQuery(`/${id}/manifest`, params), options);
|
|
6574
|
+
}
|
|
6575
|
+
async getPublicManifest(id, params, options) {
|
|
6576
|
+
return this._get(this.withQuery(`/public/${id}/manifest`, params), options);
|
|
6577
|
+
}
|
|
6569
6578
|
/**
|
|
6570
6579
|
* Build an absolute URL for the on-demand transform endpoint.
|
|
6571
6580
|
*
|
|
@@ -7025,13 +7034,14 @@ var MediaService = class extends ServiceModule {
|
|
|
7025
7034
|
return this.get(fileId, void 0, options);
|
|
7026
7035
|
}
|
|
7027
7036
|
async getManifest(fileId, options, requestOptions) {
|
|
7028
|
-
const
|
|
7029
|
-
if (
|
|
7030
|
-
return { data: null, error:
|
|
7037
|
+
const file = await this.storage.getInfo(fileId, requestOptions);
|
|
7038
|
+
if (file.error || !file.data) {
|
|
7039
|
+
return { data: null, error: file.error };
|
|
7031
7040
|
}
|
|
7032
|
-
|
|
7041
|
+
const manifest = await this.fetchManifest(file.data, options, requestOptions);
|
|
7042
|
+
return { data: manifest, error: null };
|
|
7033
7043
|
}
|
|
7034
|
-
buildAsset(file, options) {
|
|
7044
|
+
buildAsset(file, options, manifest) {
|
|
7035
7045
|
const visibility = resolveFileVisibility(file);
|
|
7036
7046
|
const photoId = options?.photoId ?? null;
|
|
7037
7047
|
const originalUrl = visibility === "anonymous_visible" ? file.cdn_url ?? file.url ?? null : file.url ?? file.cdn_url ?? null;
|
|
@@ -7048,7 +7058,7 @@ var MediaService = class extends ServiceModule {
|
|
|
7048
7058
|
created_at: file.created_at,
|
|
7049
7059
|
original_url: originalUrl,
|
|
7050
7060
|
cdn_url: file.cdn_url ?? null,
|
|
7051
|
-
manifest: this.buildManifest(file, options)
|
|
7061
|
+
manifest: manifest ?? this.buildManifest(file, options)
|
|
7052
7062
|
};
|
|
7053
7063
|
}
|
|
7054
7064
|
buildManifest(file, options) {
|
|
@@ -7102,19 +7112,27 @@ var MediaService = class extends ServiceModule {
|
|
|
7102
7112
|
cdn_url: ready.cdnUrl ?? result.data.cdn_url,
|
|
7103
7113
|
scan_status: ready.scanStatus
|
|
7104
7114
|
};
|
|
7105
|
-
|
|
7115
|
+
let manifest = this.buildManifest(fileInfo, {
|
|
7106
7116
|
preset: options?.preset,
|
|
7107
7117
|
customWidths: options?.customWidths
|
|
7108
7118
|
});
|
|
7109
|
-
if (kind === "image" && fileInfo.content_type !== "image/svg+xml" && options?.
|
|
7119
|
+
if (kind === "image" && fileInfo.content_type !== "image/svg+xml" && options?.preset !== "custom") {
|
|
7110
7120
|
emit("optimizing", 100, result.data.id);
|
|
7111
|
-
await this.
|
|
7121
|
+
const persistedManifest = await this.waitForAnonymousManifest(fileInfo.id, options, requestOptions, emit);
|
|
7122
|
+
if (persistedManifest.error) {
|
|
7123
|
+
return { data: null, error: persistedManifest.error };
|
|
7124
|
+
}
|
|
7125
|
+
manifest = persistedManifest.manifest ?? manifest;
|
|
7112
7126
|
}
|
|
7113
|
-
const asset = this.buildAsset(
|
|
7114
|
-
|
|
7115
|
-
|
|
7116
|
-
|
|
7117
|
-
|
|
7127
|
+
const asset = this.buildAsset(
|
|
7128
|
+
fileInfo,
|
|
7129
|
+
{
|
|
7130
|
+
photoId: null,
|
|
7131
|
+
preset: options?.preset,
|
|
7132
|
+
customWidths: options?.customWidths
|
|
7133
|
+
},
|
|
7134
|
+
manifest
|
|
7135
|
+
);
|
|
7118
7136
|
emit("ready", 100, result.data.id);
|
|
7119
7137
|
return {
|
|
7120
7138
|
data: {
|
|
@@ -7250,6 +7268,25 @@ var MediaService = class extends ServiceModule {
|
|
|
7250
7268
|
const result = await this.storage.getInfo(fileId, requestOptions);
|
|
7251
7269
|
return result.error || !result.data ? null : result.data;
|
|
7252
7270
|
}
|
|
7271
|
+
async fetchManifest(file, options, requestOptions) {
|
|
7272
|
+
const kind = detectKind(file.content_type);
|
|
7273
|
+
const visibility = resolveFileVisibility(file);
|
|
7274
|
+
if (kind !== "image" || file.content_type === "image/svg+xml") {
|
|
7275
|
+
return this.buildManifest(file, options);
|
|
7276
|
+
}
|
|
7277
|
+
if (visibility !== "anonymous_visible" || options?.preset === "custom") {
|
|
7278
|
+
return this.buildManifest(file, options);
|
|
7279
|
+
}
|
|
7280
|
+
const persisted = await this.photo.getPublicManifest(
|
|
7281
|
+
file.id,
|
|
7282
|
+
{ preset: options?.preset ?? "inline" },
|
|
7283
|
+
requestOptions
|
|
7284
|
+
);
|
|
7285
|
+
if (persisted.error || !persisted.data) {
|
|
7286
|
+
return this.buildManifest(file, options);
|
|
7287
|
+
}
|
|
7288
|
+
return persisted.data;
|
|
7289
|
+
}
|
|
7253
7290
|
async pollPhotoOptimizationComplete(photoId, requestOptions) {
|
|
7254
7291
|
for (let attempt = 0; attempt < 40; attempt++) {
|
|
7255
7292
|
const result = await this.photo.get(photoId, requestOptions);
|
|
@@ -7261,30 +7298,31 @@ var MediaService = class extends ServiceModule {
|
|
|
7261
7298
|
}
|
|
7262
7299
|
return null;
|
|
7263
7300
|
}
|
|
7264
|
-
async
|
|
7265
|
-
|
|
7266
|
-
|
|
7301
|
+
async waitForAnonymousManifest(fileId, options, requestOptions, emit) {
|
|
7302
|
+
const preset = options?.preset ?? "inline";
|
|
7303
|
+
const delays = [500, 1e3, 1500, 2e3, 2500, 3e3];
|
|
7304
|
+
for (let attempt = 0; attempt < 30; attempt++) {
|
|
7305
|
+
if (options?.signal?.aborted) {
|
|
7306
|
+
return {
|
|
7307
|
+
manifest: null,
|
|
7308
|
+
error: { code: "aborted", message: "Upload aborted", status: 0 }
|
|
7309
|
+
};
|
|
7310
|
+
}
|
|
7311
|
+
const manifest = await this.photo.getPublicManifest(fileId, { preset }, requestOptions);
|
|
7312
|
+
if (!manifest.error && manifest.data && manifest.data.ready) {
|
|
7313
|
+
return { manifest: manifest.data, error: null };
|
|
7314
|
+
}
|
|
7315
|
+
emit("optimizing", Math.min(99, 15 + attempt * 3), fileId);
|
|
7316
|
+
await sleep4(delays[Math.min(attempt, delays.length - 1)] ?? 3e3);
|
|
7267
7317
|
}
|
|
7268
|
-
|
|
7269
|
-
|
|
7270
|
-
|
|
7271
|
-
|
|
7272
|
-
|
|
7273
|
-
|
|
7274
|
-
|
|
7275
|
-
|
|
7276
|
-
Accept: "image/avif,image/webp,image/*,*/*;q=0.8"
|
|
7277
|
-
}
|
|
7278
|
-
});
|
|
7279
|
-
if (!response.ok) {
|
|
7280
|
-
throw new Error(`Prewarm failed with HTTP ${response.status}`);
|
|
7281
|
-
}
|
|
7282
|
-
await response.arrayBuffer();
|
|
7283
|
-
} catch (error) {
|
|
7284
|
-
console.warn("[scalemule-sdk] media prewarm failed", url, error);
|
|
7285
|
-
}
|
|
7286
|
-
})
|
|
7287
|
-
);
|
|
7318
|
+
return {
|
|
7319
|
+
manifest: null,
|
|
7320
|
+
error: {
|
|
7321
|
+
code: "manifest_pending",
|
|
7322
|
+
message: "Photo variants are still being generated. Re-fetch the public manifest once ready flips true.",
|
|
7323
|
+
status: 202
|
|
7324
|
+
}
|
|
7325
|
+
};
|
|
7288
7326
|
}
|
|
7289
7327
|
};
|
|
7290
7328
|
function detectKind(contentType) {
|
package/dist/index.mjs
CHANGED
|
@@ -6190,6 +6190,15 @@ var PhotoService = class extends ServiceModule {
|
|
|
6190
6190
|
async delete(id, options) {
|
|
6191
6191
|
return this.del(`/${id}`, options);
|
|
6192
6192
|
}
|
|
6193
|
+
async getPresets(options) {
|
|
6194
|
+
return this._get("/presets", options);
|
|
6195
|
+
}
|
|
6196
|
+
async getManifest(id, params, options) {
|
|
6197
|
+
return this._get(this.withQuery(`/${id}/manifest`, params), options);
|
|
6198
|
+
}
|
|
6199
|
+
async getPublicManifest(id, params, options) {
|
|
6200
|
+
return this._get(this.withQuery(`/public/${id}/manifest`, params), options);
|
|
6201
|
+
}
|
|
6193
6202
|
/**
|
|
6194
6203
|
* Build an absolute URL for the on-demand transform endpoint.
|
|
6195
6204
|
*
|
|
@@ -6649,13 +6658,14 @@ var MediaService = class extends ServiceModule {
|
|
|
6649
6658
|
return this.get(fileId, void 0, options);
|
|
6650
6659
|
}
|
|
6651
6660
|
async getManifest(fileId, options, requestOptions) {
|
|
6652
|
-
const
|
|
6653
|
-
if (
|
|
6654
|
-
return { data: null, error:
|
|
6661
|
+
const file = await this.storage.getInfo(fileId, requestOptions);
|
|
6662
|
+
if (file.error || !file.data) {
|
|
6663
|
+
return { data: null, error: file.error };
|
|
6655
6664
|
}
|
|
6656
|
-
|
|
6665
|
+
const manifest = await this.fetchManifest(file.data, options, requestOptions);
|
|
6666
|
+
return { data: manifest, error: null };
|
|
6657
6667
|
}
|
|
6658
|
-
buildAsset(file, options) {
|
|
6668
|
+
buildAsset(file, options, manifest) {
|
|
6659
6669
|
const visibility = resolveFileVisibility(file);
|
|
6660
6670
|
const photoId = options?.photoId ?? null;
|
|
6661
6671
|
const originalUrl = visibility === "anonymous_visible" ? file.cdn_url ?? file.url ?? null : file.url ?? file.cdn_url ?? null;
|
|
@@ -6672,7 +6682,7 @@ var MediaService = class extends ServiceModule {
|
|
|
6672
6682
|
created_at: file.created_at,
|
|
6673
6683
|
original_url: originalUrl,
|
|
6674
6684
|
cdn_url: file.cdn_url ?? null,
|
|
6675
|
-
manifest: this.buildManifest(file, options)
|
|
6685
|
+
manifest: manifest ?? this.buildManifest(file, options)
|
|
6676
6686
|
};
|
|
6677
6687
|
}
|
|
6678
6688
|
buildManifest(file, options) {
|
|
@@ -6726,19 +6736,27 @@ var MediaService = class extends ServiceModule {
|
|
|
6726
6736
|
cdn_url: ready.cdnUrl ?? result.data.cdn_url,
|
|
6727
6737
|
scan_status: ready.scanStatus
|
|
6728
6738
|
};
|
|
6729
|
-
|
|
6739
|
+
let manifest = this.buildManifest(fileInfo, {
|
|
6730
6740
|
preset: options?.preset,
|
|
6731
6741
|
customWidths: options?.customWidths
|
|
6732
6742
|
});
|
|
6733
|
-
if (kind === "image" && fileInfo.content_type !== "image/svg+xml" && options?.
|
|
6743
|
+
if (kind === "image" && fileInfo.content_type !== "image/svg+xml" && options?.preset !== "custom") {
|
|
6734
6744
|
emit("optimizing", 100, result.data.id);
|
|
6735
|
-
await this.
|
|
6745
|
+
const persistedManifest = await this.waitForAnonymousManifest(fileInfo.id, options, requestOptions, emit);
|
|
6746
|
+
if (persistedManifest.error) {
|
|
6747
|
+
return { data: null, error: persistedManifest.error };
|
|
6748
|
+
}
|
|
6749
|
+
manifest = persistedManifest.manifest ?? manifest;
|
|
6736
6750
|
}
|
|
6737
|
-
const asset = this.buildAsset(
|
|
6738
|
-
|
|
6739
|
-
|
|
6740
|
-
|
|
6741
|
-
|
|
6751
|
+
const asset = this.buildAsset(
|
|
6752
|
+
fileInfo,
|
|
6753
|
+
{
|
|
6754
|
+
photoId: null,
|
|
6755
|
+
preset: options?.preset,
|
|
6756
|
+
customWidths: options?.customWidths
|
|
6757
|
+
},
|
|
6758
|
+
manifest
|
|
6759
|
+
);
|
|
6742
6760
|
emit("ready", 100, result.data.id);
|
|
6743
6761
|
return {
|
|
6744
6762
|
data: {
|
|
@@ -6874,6 +6892,25 @@ var MediaService = class extends ServiceModule {
|
|
|
6874
6892
|
const result = await this.storage.getInfo(fileId, requestOptions);
|
|
6875
6893
|
return result.error || !result.data ? null : result.data;
|
|
6876
6894
|
}
|
|
6895
|
+
async fetchManifest(file, options, requestOptions) {
|
|
6896
|
+
const kind = detectKind(file.content_type);
|
|
6897
|
+
const visibility = resolveFileVisibility(file);
|
|
6898
|
+
if (kind !== "image" || file.content_type === "image/svg+xml") {
|
|
6899
|
+
return this.buildManifest(file, options);
|
|
6900
|
+
}
|
|
6901
|
+
if (visibility !== "anonymous_visible" || options?.preset === "custom") {
|
|
6902
|
+
return this.buildManifest(file, options);
|
|
6903
|
+
}
|
|
6904
|
+
const persisted = await this.photo.getPublicManifest(
|
|
6905
|
+
file.id,
|
|
6906
|
+
{ preset: options?.preset ?? "inline" },
|
|
6907
|
+
requestOptions
|
|
6908
|
+
);
|
|
6909
|
+
if (persisted.error || !persisted.data) {
|
|
6910
|
+
return this.buildManifest(file, options);
|
|
6911
|
+
}
|
|
6912
|
+
return persisted.data;
|
|
6913
|
+
}
|
|
6877
6914
|
async pollPhotoOptimizationComplete(photoId, requestOptions) {
|
|
6878
6915
|
for (let attempt = 0; attempt < 40; attempt++) {
|
|
6879
6916
|
const result = await this.photo.get(photoId, requestOptions);
|
|
@@ -6885,30 +6922,31 @@ var MediaService = class extends ServiceModule {
|
|
|
6885
6922
|
}
|
|
6886
6923
|
return null;
|
|
6887
6924
|
}
|
|
6888
|
-
async
|
|
6889
|
-
|
|
6890
|
-
|
|
6925
|
+
async waitForAnonymousManifest(fileId, options, requestOptions, emit) {
|
|
6926
|
+
const preset = options?.preset ?? "inline";
|
|
6927
|
+
const delays = [500, 1e3, 1500, 2e3, 2500, 3e3];
|
|
6928
|
+
for (let attempt = 0; attempt < 30; attempt++) {
|
|
6929
|
+
if (options?.signal?.aborted) {
|
|
6930
|
+
return {
|
|
6931
|
+
manifest: null,
|
|
6932
|
+
error: { code: "aborted", message: "Upload aborted", status: 0 }
|
|
6933
|
+
};
|
|
6934
|
+
}
|
|
6935
|
+
const manifest = await this.photo.getPublicManifest(fileId, { preset }, requestOptions);
|
|
6936
|
+
if (!manifest.error && manifest.data && manifest.data.ready) {
|
|
6937
|
+
return { manifest: manifest.data, error: null };
|
|
6938
|
+
}
|
|
6939
|
+
emit("optimizing", Math.min(99, 15 + attempt * 3), fileId);
|
|
6940
|
+
await sleep4(delays[Math.min(attempt, delays.length - 1)] ?? 3e3);
|
|
6891
6941
|
}
|
|
6892
|
-
|
|
6893
|
-
|
|
6894
|
-
|
|
6895
|
-
|
|
6896
|
-
|
|
6897
|
-
|
|
6898
|
-
|
|
6899
|
-
|
|
6900
|
-
Accept: "image/avif,image/webp,image/*,*/*;q=0.8"
|
|
6901
|
-
}
|
|
6902
|
-
});
|
|
6903
|
-
if (!response.ok) {
|
|
6904
|
-
throw new Error(`Prewarm failed with HTTP ${response.status}`);
|
|
6905
|
-
}
|
|
6906
|
-
await response.arrayBuffer();
|
|
6907
|
-
} catch (error) {
|
|
6908
|
-
console.warn("[scalemule-sdk] media prewarm failed", url, error);
|
|
6909
|
-
}
|
|
6910
|
-
})
|
|
6911
|
-
);
|
|
6942
|
+
return {
|
|
6943
|
+
manifest: null,
|
|
6944
|
+
error: {
|
|
6945
|
+
code: "manifest_pending",
|
|
6946
|
+
message: "Photo variants are still being generated. Re-fetch the public manifest once ready flips true.",
|
|
6947
|
+
status: 202
|
|
6948
|
+
}
|
|
6949
|
+
};
|
|
6912
6950
|
}
|
|
6913
6951
|
};
|
|
6914
6952
|
function detectKind(contentType) {
|