@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
|
|
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,
|
|
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
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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":"
|
|
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 =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
};
|