@solidxai/core-ui 0.1.8-beta.0 → 0.1.8-beta.1

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.
@@ -1,2 +1,2 @@
1
- export declare const downloadMediaFile: (fileUrl: string, fileName: string) => Promise<void>;
1
+ export declare const downloadMediaFile: (fileUrl: string, fileName?: string) => void;
2
2
  //# sourceMappingURL=downloadMediaFile.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"downloadMediaFile.d.ts","sourceRoot":"","sources":["../../src/helpers/downloadMediaFile.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,iBAAiB,YAAmB,MAAM,YAAY,MAAM,kBAkBxE,CAAC"}
1
+ {"version":3,"file":"downloadMediaFile.d.ts","sourceRoot":"","sources":["../../src/helpers/downloadMediaFile.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,iBAAiB,YAAa,MAAM,aAAa,MAAM,SAQnE,CAAC"}
@@ -1,68 +1,10 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
1
+ export var downloadMediaFile = function (fileUrl, fileName) {
2
+ var link = document.createElement("a");
3
+ link.href = fileUrl;
4
+ link.download = fileName || "";
5
+ link.target = "_blank";
6
+ document.body.appendChild(link);
7
+ link.click();
8
+ document.body.removeChild(link);
9
9
  };
10
- var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
- function verb(n) { return function (v) { return step([n, v]); }; }
14
- function step(op) {
15
- if (f) throw new TypeError("Generator is already executing.");
16
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
- if (y = 0, t) op = [op[0] & 2, t.value];
19
- switch (op[0]) {
20
- case 0: case 1: t = op; break;
21
- case 4: _.label++; return { value: op[1], done: false };
22
- case 5: _.label++; y = op[1]; op = [0]; continue;
23
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
- default:
25
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
- if (t[2]) _.ops.pop();
30
- _.trys.pop(); continue;
31
- }
32
- op = body.call(thisArg, _);
33
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
- }
36
- };
37
- import { ERROR_MESSAGES } from "../constants/error-messages";
38
- import { env } from "../adapters/env";
39
- export var downloadMediaFile = function (fileUrl, fileName) { return __awaiter(void 0, void 0, void 0, function () {
40
- var response, blob, link, error_1;
41
- return __generator(this, function (_a) {
42
- switch (_a.label) {
43
- case 0:
44
- _a.trys.push([0, 3, , 4]);
45
- return [4 /*yield*/, fetch("".concat(env("NEXT_PUBLIC_BACKEND_API_URL"), "/").concat(fileUrl))];
46
- case 1:
47
- response = _a.sent();
48
- return [4 /*yield*/, response.blob()];
49
- case 2:
50
- blob = _a.sent();
51
- link = document.createElement("a");
52
- link.href = URL.createObjectURL(blob);
53
- link.setAttribute("download", fileName || "download");
54
- document.body.appendChild(link);
55
- link.click();
56
- document.body.removeChild(link);
57
- // Clean up the object URL
58
- URL.revokeObjectURL(link.href);
59
- return [3 /*break*/, 4];
60
- case 3:
61
- error_1 = _a.sent();
62
- console.error(ERROR_MESSAGES.DOWNLOAD_FAILED, error_1);
63
- return [3 /*break*/, 4];
64
- case 4: return [2 /*return*/];
65
- }
66
- });
67
- }); };
68
10
  //# sourceMappingURL=downloadMediaFile.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"downloadMediaFile.js","sourceRoot":"","sources":["../../src/helpers/downloadMediaFile.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAEtC,MAAM,CAAC,IAAM,iBAAiB,GAAG,UAAO,OAAe,EAAE,QAAgB;;;;;;gBAEhD,qBAAM,KAAK,CAAC,UAAG,GAAG,CAAC,6BAA6B,CAAC,cAAI,OAAO,CAAE,CAAC,EAAA;;gBAA1E,QAAQ,GAAG,SAA+D;gBACnE,qBAAM,QAAQ,CAAC,IAAI,EAAE,EAAA;;gBAA5B,IAAI,GAAG,SAAqB;gBAE5B,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;gBACzC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;gBACtC,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,QAAQ,IAAI,UAAU,CAAC,CAAC;gBAEtD,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;gBAChC,IAAI,CAAC,KAAK,EAAE,CAAC;gBACb,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;gBAEhC,0BAA0B;gBAC1B,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;;;;gBAE/B,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,eAAe,EAAE,OAAK,CAAC,CAAC;;;;;KAE5D,CAAC","sourcesContent":["import { ERROR_MESSAGES } from \"../constants/error-messages\";\nimport { env } from \"../adapters/env\";\n\nexport const downloadMediaFile = async (fileUrl: string, fileName: string) => {\n try {\n const response = await fetch(`${env(\"NEXT_PUBLIC_BACKEND_API_URL\")}/${fileUrl}`);\n const blob = await response.blob();\n\n const link = document.createElement(\"a\");\n link.href = URL.createObjectURL(blob);\n link.setAttribute(\"download\", fileName || \"download\");\n\n document.body.appendChild(link);\n link.click();\n document.body.removeChild(link);\n\n // Clean up the object URL\n URL.revokeObjectURL(link.href);\n } catch (error) {\n console.error(ERROR_MESSAGES.DOWNLOAD_FAILED, error);\n }\n};\n"]}
1
+ {"version":3,"file":"downloadMediaFile.js","sourceRoot":"","sources":["../../src/helpers/downloadMediaFile.tsx"],"names":[],"mappings":"AAGA,MAAM,CAAC,IAAM,iBAAiB,GAAG,UAAC,OAAe,EAAE,QAAiB;IAChE,IAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IACzC,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC;IACpB,IAAI,CAAC,QAAQ,GAAG,QAAQ,IAAI,EAAE,CAAC;IAC/B,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAChC,IAAI,CAAC,KAAK,EAAE,CAAC;IACb,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;AACpC,CAAC,CAAC","sourcesContent":["import { ERROR_MESSAGES } from \"../constants/error-messages\";\nimport { env } from \"../adapters/env\";\n\nexport const downloadMediaFile = (fileUrl: string, fileName?: string) => {\n const link = document.createElement(\"a\");\n link.href = fileUrl;\n link.download = fileName || \"\";\n link.target = \"_blank\";\n document.body.appendChild(link);\n link.click();\n document.body.removeChild(link);\n};\n"]}
@@ -1,22 +1,12 @@
1
1
  import { ERROR_MESSAGES } from "../constants/error-messages";
2
2
  import { env } from "../adapters/env";
3
3
 
4
- export const downloadMediaFile = async (fileUrl: string, fileName: string) => {
5
- try {
6
- const response = await fetch(`${env("NEXT_PUBLIC_BACKEND_API_URL")}/${fileUrl}`);
7
- const blob = await response.blob();
8
-
9
- const link = document.createElement("a");
10
- link.href = URL.createObjectURL(blob);
11
- link.setAttribute("download", fileName || "download");
12
-
13
- document.body.appendChild(link);
14
- link.click();
15
- document.body.removeChild(link);
16
-
17
- // Clean up the object URL
18
- URL.revokeObjectURL(link.href);
19
- } catch (error) {
20
- console.error(ERROR_MESSAGES.DOWNLOAD_FAILED, error);
21
- }
4
+ export const downloadMediaFile = (fileUrl: string, fileName?: string) => {
5
+ const link = document.createElement("a");
6
+ link.href = fileUrl;
7
+ link.download = fileName || "";
8
+ link.target = "_blank";
9
+ document.body.appendChild(link);
10
+ link.click();
11
+ document.body.removeChild(link);
22
12
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidxai/core-ui",
3
- "version": "0.1.8-beta.0",
3
+ "version": "0.1.8-beta.1",
4
4
  "scripts": {
5
5
  "prebuild": "npm run copy-resources && npm run copy-styles",
6
6
  "build": "tsc -p tsconfig.json && tsc-alias -p tsconfig.json",