@tradly/asset 1.0.25 → 1.0.26

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.
@@ -298,7 +298,13 @@ var MediaApiService = /*#__PURE__*/function () {
298
298
  name: file.name.replace(/\s/g, "-"),
299
299
  type: file.type
300
300
  };
301
- }); // Prepare headers
301
+ });
302
+ console.log("fileData", {
303
+ files: files,
304
+ fileData: fileData
305
+ });
306
+
307
+ // Prepare headers
302
308
  headers = {
303
309
  "Content-Type": "application/json",
304
310
  "X-Auth-Key": auth_key // Capital X for Tradly API
@@ -394,15 +400,10 @@ var MediaApiService = /*#__PURE__*/function () {
394
400
  break;
395
401
  }
396
402
  _context5.p = 3;
397
- console.log("upload_full_files", upload_full_files);
398
- // Step 1: Get signed URLs from API
399
403
  _context5.n = 4;
400
404
  return this.getS3SignedUrls(upload_full_files, auth_key);
401
405
  case 4:
402
406
  responseFiles = _context5.v;
403
- console.log("responseFiles", responseFiles);
404
-
405
- // Step 2: Upload each file to S3
406
407
  index = 0;
407
408
  case 5:
408
409
  if (!(index < responseFiles.length)) {
@@ -292,7 +292,13 @@ var MediaApiService = /*#__PURE__*/function () {
292
292
  name: file.name.replace(/\s/g, "-"),
293
293
  type: file.type
294
294
  };
295
- }); // Prepare headers
295
+ });
296
+ console.log("fileData", {
297
+ files: files,
298
+ fileData: fileData
299
+ });
300
+
301
+ // Prepare headers
296
302
  headers = {
297
303
  "Content-Type": "application/json",
298
304
  "X-Auth-Key": auth_key // Capital X for Tradly API
@@ -388,15 +394,10 @@ var MediaApiService = /*#__PURE__*/function () {
388
394
  break;
389
395
  }
390
396
  _context5.p = 3;
391
- console.log("upload_full_files", upload_full_files);
392
- // Step 1: Get signed URLs from API
393
397
  _context5.n = 4;
394
398
  return this.getS3SignedUrls(upload_full_files, auth_key);
395
399
  case 4:
396
400
  responseFiles = _context5.v;
397
- console.log("responseFiles", responseFiles);
398
-
399
- // Step 2: Upload each file to S3
400
401
  index = 0;
401
402
  case 5:
402
403
  if (!(index < responseFiles.length)) {
@@ -153,28 +153,108 @@ var FileUpload = function FileUpload(_ref) {
153
153
  }
154
154
 
155
155
  // Extract MIME type (handle different property names)
156
- // Use a helper function to determine MIME type from filename if needed
157
- var getMimeType = function getMimeType(name, fallbackType) {
156
+ // Use a comprehensive helper function to determine MIME type from filename
157
+ var getMimeTypeFromFileName = function getMimeTypeFromFileName(name) {
158
158
  var _name$split$pop;
159
- if (fallbackType) return fallbackType;
160
- var ext = (_name$split$pop = name.split(".").pop()) === null || _name$split$pop === void 0 ? void 0 : _name$split$pop.toLowerCase();
159
+ if (!name) return "application/octet-stream";
160
+ var ext = (_name$split$pop = name.split(".").pop()) === null || _name$split$pop === void 0 ? void 0 : _name$split$pop.toLowerCase().trim();
161
+ if (!ext) return "application/octet-stream";
162
+
163
+ // Comprehensive MIME type mapping
161
164
  var mimeMap = {
165
+ // Images
162
166
  jpg: "image/jpeg",
163
167
  jpeg: "image/jpeg",
164
168
  png: "image/png",
165
169
  gif: "image/gif",
166
170
  webp: "image/webp",
171
+ svg: "image/svg+xml",
172
+ bmp: "image/bmp",
173
+ ico: "image/x-icon",
174
+ heic: "image/heic",
175
+ heif: "image/heif",
176
+ tiff: "image/tiff",
177
+ tif: "image/tiff",
178
+ jfif: "image/jpeg",
179
+ avif: "image/avif",
180
+ // Videos
167
181
  mp4: "video/mp4",
168
182
  mov: "video/quicktime",
169
- mp3: "audio/mpeg"
183
+ avi: "video/x-msvideo",
184
+ wmv: "video/x-ms-wmv",
185
+ flv: "video/x-flv",
186
+ mkv: "video/x-matroska",
187
+ webm: "video/webm",
188
+ mpeg: "video/mpeg",
189
+ mpg: "video/mpeg",
190
+ m4v: "video/x-m4v",
191
+ "3gp": "video/3gpp",
192
+ // Audio
193
+ mp3: "audio/mpeg",
194
+ wav: "audio/wav",
195
+ ogg: "audio/ogg",
196
+ m4a: "audio/mp4",
197
+ aac: "audio/aac",
198
+ flac: "audio/flac",
199
+ // Documents
200
+ pdf: "application/pdf",
201
+ doc: "application/msword",
202
+ docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
203
+ xls: "application/vnd.ms-excel",
204
+ xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
205
+ ppt: "application/vnd.ms-powerpoint",
206
+ pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
207
+ // Archives
208
+ zip: "application/zip",
209
+ rar: "application/rar",
210
+ "7z": "application/x-7z-compressed",
211
+ tar: "application/x-tar",
212
+ gz: "application/gzip",
213
+ // Text
214
+ txt: "text/plain",
215
+ html: "text/html",
216
+ htm: "text/html",
217
+ css: "text/css",
218
+ js: "text/javascript",
219
+ json: "application/json",
220
+ xml: "text/xml",
221
+ php: "application/x-php"
170
222
  };
171
- return mimeMap[ext] || "image/jpeg";
223
+ return mimeMap[ext] || "application/octet-stream";
172
224
  };
173
- var mimeType = pickerResult.mimeType || pickerResult.type || getMimeType(fileName, null);
225
+
226
+ // Get MIME type - prioritize picker result, then filename, then default
227
+ var mimeType = pickerResult.mimeType || pickerResult.type;
228
+
229
+ // Clean up MIME type if it exists but is malformed
230
+ if (mimeType) {
231
+ mimeType = mimeType.trim();
232
+ // If it doesn't have a slash, it's not a valid MIME type format
233
+ if (!mimeType.includes("/")) {
234
+ mimeType = null;
235
+ } else {
236
+ // Normalize: lowercase the type part but keep structure
237
+ // e.g., "IMAGE/JPEG" -> "image/jpeg", "Image/Jpeg" -> "image/jpeg"
238
+ var parts = mimeType.split("/");
239
+ if (parts.length === 2) {
240
+ mimeType = "".concat(parts[0].toLowerCase(), "/").concat(parts[1].toLowerCase());
241
+ }
242
+ }
243
+ }
244
+
245
+ // If MIME type is missing or invalid, detect from filename
246
+ if (!mimeType) {
247
+ mimeType = getMimeTypeFromFileName(fileName);
248
+ }
249
+
250
+ // Final validation - ensure MIME type is properly formatted
251
+ if (!mimeType || !mimeType.includes("/")) {
252
+ mimeType = "application/octet-stream";
253
+ }
174
254
  console.log("mimeType", {
175
- fileName: fileName,
176
- mimeType: mimeType,
177
- pickerResult: pickerResult
255
+ uri: uri,
256
+ name: fileName,
257
+ type: mimeType
178
258
  });
179
259
  return {
180
260
  uri: uri,
@@ -11,13 +11,13 @@ var ITEM_MARGIN = 4; // Match MediaGallery margin
11
11
  // - Item margins: (NUM_COLUMNS - 1) gaps between items
12
12
  // Each gap = 2 * ITEM_MARGIN (left margin of right item + right margin of left item)
13
13
  // Total: (3 - 1) * 2 * 4 = 16px
14
- var CONTAINER_PADDING = 24; // paddingHorizontal md (12 * 2)
14
+ var CONTAINER_PADDING = 14; // paddingHorizontal md (12 * 2)
15
15
  var GRID_PADDING = 4; // padding 2 on each side (2 * 2)
16
16
  var TOTAL_MARGINS = ITEM_MARGIN * (NUM_COLUMNS - 1) * 2; // 4 * 2 * 2 = 16px
17
17
  var ITEM_SIZE = (SCREEN_WIDTH - CONTAINER_PADDING - GRID_PADDING - TOTAL_MARGINS) / NUM_COLUMNS;
18
18
  var ImagesSkeleton = function ImagesSkeleton(_ref) {
19
19
  var _ref$per_page = _ref.per_page,
20
- per_page = _ref$per_page === void 0 ? 30 : _ref$per_page;
20
+ per_page = _ref$per_page === void 0 ? 20 : _ref$per_page;
21
21
  var skeletonData = Array.from({
22
22
  length: per_page
23
23
  }, function (_, i) {
@@ -158,28 +158,108 @@ var FileUpload = function FileUpload(_ref) {
158
158
  }
159
159
 
160
160
  // Extract MIME type (handle different property names)
161
- // Use a helper function to determine MIME type from filename if needed
162
- var getMimeType = function getMimeType(name, fallbackType) {
161
+ // Use a comprehensive helper function to determine MIME type from filename
162
+ var getMimeTypeFromFileName = function getMimeTypeFromFileName(name) {
163
163
  var _name$split$pop;
164
- if (fallbackType) return fallbackType;
165
- var ext = (_name$split$pop = name.split(".").pop()) === null || _name$split$pop === void 0 ? void 0 : _name$split$pop.toLowerCase();
164
+ if (!name) return "application/octet-stream";
165
+ var ext = (_name$split$pop = name.split(".").pop()) === null || _name$split$pop === void 0 ? void 0 : _name$split$pop.toLowerCase().trim();
166
+ if (!ext) return "application/octet-stream";
167
+
168
+ // Comprehensive MIME type mapping
166
169
  var mimeMap = {
170
+ // Images
167
171
  jpg: "image/jpeg",
168
172
  jpeg: "image/jpeg",
169
173
  png: "image/png",
170
174
  gif: "image/gif",
171
175
  webp: "image/webp",
176
+ svg: "image/svg+xml",
177
+ bmp: "image/bmp",
178
+ ico: "image/x-icon",
179
+ heic: "image/heic",
180
+ heif: "image/heif",
181
+ tiff: "image/tiff",
182
+ tif: "image/tiff",
183
+ jfif: "image/jpeg",
184
+ avif: "image/avif",
185
+ // Videos
172
186
  mp4: "video/mp4",
173
187
  mov: "video/quicktime",
174
- mp3: "audio/mpeg"
188
+ avi: "video/x-msvideo",
189
+ wmv: "video/x-ms-wmv",
190
+ flv: "video/x-flv",
191
+ mkv: "video/x-matroska",
192
+ webm: "video/webm",
193
+ mpeg: "video/mpeg",
194
+ mpg: "video/mpeg",
195
+ m4v: "video/x-m4v",
196
+ "3gp": "video/3gpp",
197
+ // Audio
198
+ mp3: "audio/mpeg",
199
+ wav: "audio/wav",
200
+ ogg: "audio/ogg",
201
+ m4a: "audio/mp4",
202
+ aac: "audio/aac",
203
+ flac: "audio/flac",
204
+ // Documents
205
+ pdf: "application/pdf",
206
+ doc: "application/msword",
207
+ docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
208
+ xls: "application/vnd.ms-excel",
209
+ xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
210
+ ppt: "application/vnd.ms-powerpoint",
211
+ pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
212
+ // Archives
213
+ zip: "application/zip",
214
+ rar: "application/rar",
215
+ "7z": "application/x-7z-compressed",
216
+ tar: "application/x-tar",
217
+ gz: "application/gzip",
218
+ // Text
219
+ txt: "text/plain",
220
+ html: "text/html",
221
+ htm: "text/html",
222
+ css: "text/css",
223
+ js: "text/javascript",
224
+ json: "application/json",
225
+ xml: "text/xml",
226
+ php: "application/x-php"
175
227
  };
176
- return mimeMap[ext] || "image/jpeg";
228
+ return mimeMap[ext] || "application/octet-stream";
177
229
  };
178
- var mimeType = pickerResult.mimeType || pickerResult.type || getMimeType(fileName, null);
230
+
231
+ // Get MIME type - prioritize picker result, then filename, then default
232
+ var mimeType = pickerResult.mimeType || pickerResult.type;
233
+
234
+ // Clean up MIME type if it exists but is malformed
235
+ if (mimeType) {
236
+ mimeType = mimeType.trim();
237
+ // If it doesn't have a slash, it's not a valid MIME type format
238
+ if (!mimeType.includes("/")) {
239
+ mimeType = null;
240
+ } else {
241
+ // Normalize: lowercase the type part but keep structure
242
+ // e.g., "IMAGE/JPEG" -> "image/jpeg", "Image/Jpeg" -> "image/jpeg"
243
+ var parts = mimeType.split("/");
244
+ if (parts.length === 2) {
245
+ mimeType = "".concat(parts[0].toLowerCase(), "/").concat(parts[1].toLowerCase());
246
+ }
247
+ }
248
+ }
249
+
250
+ // If MIME type is missing or invalid, detect from filename
251
+ if (!mimeType) {
252
+ mimeType = getMimeTypeFromFileName(fileName);
253
+ }
254
+
255
+ // Final validation - ensure MIME type is properly formatted
256
+ if (!mimeType || !mimeType.includes("/")) {
257
+ mimeType = "application/octet-stream";
258
+ }
179
259
  console.log("mimeType", {
180
- fileName: fileName,
181
- mimeType: mimeType,
182
- pickerResult: pickerResult
260
+ uri: uri,
261
+ name: fileName,
262
+ type: mimeType
183
263
  });
184
264
  return {
185
265
  uri: uri,
@@ -18,13 +18,13 @@ var ITEM_MARGIN = 4; // Match MediaGallery margin
18
18
  // - Item margins: (NUM_COLUMNS - 1) gaps between items
19
19
  // Each gap = 2 * ITEM_MARGIN (left margin of right item + right margin of left item)
20
20
  // Total: (3 - 1) * 2 * 4 = 16px
21
- var CONTAINER_PADDING = 24; // paddingHorizontal md (12 * 2)
21
+ var CONTAINER_PADDING = 14; // paddingHorizontal md (12 * 2)
22
22
  var GRID_PADDING = 4; // padding 2 on each side (2 * 2)
23
23
  var TOTAL_MARGINS = ITEM_MARGIN * (NUM_COLUMNS - 1) * 2; // 4 * 2 * 2 = 16px
24
24
  var ITEM_SIZE = (SCREEN_WIDTH - CONTAINER_PADDING - GRID_PADDING - TOTAL_MARGINS) / NUM_COLUMNS;
25
25
  var ImagesSkeleton = function ImagesSkeleton(_ref) {
26
26
  var _ref$per_page = _ref.per_page,
27
- per_page = _ref$per_page === void 0 ? 30 : _ref$per_page;
27
+ per_page = _ref$per_page === void 0 ? 20 : _ref$per_page;
28
28
  var skeletonData = Array.from({
29
29
  length: per_page
30
30
  }, function (_, i) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tradly/asset",
3
- "version": "1.0.25",
3
+ "version": "1.0.26",
4
4
  "description": "A reusable media gallery component for uploading and selecting images, videos, and files with Tradly authentication",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/esm/index.js",