@simplysm/core-browser 14.0.48 → 14.0.50
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/README.md
CHANGED
|
@@ -149,7 +149,7 @@ htmlElement.scrollIntoViewIfNeeded(
|
|
|
149
149
|
export function downloadBlob(blob: Blob, fileName: string): void
|
|
150
150
|
```
|
|
151
151
|
|
|
152
|
-
Blob을 파일로 다운로드한다. `<a>` 태그를 생성하여 클릭하는 방식이다. Object URL은 1초 후 자동 해제된다.
|
|
152
|
+
Blob을 파일로 다운로드한다. `<a>` 태그를 생성하여 클릭하는 방식이다. Object URL은 1초 후 자동 해제된다. `fileName`의 파일시스템 금지 문자(`/ \ : * ? " < > |`), 제어문자, Windows 예약어(CON, PRN 등)는 자동 제거되며, 제거 후 빈 문자열이 되면 `download`로 대체된다.
|
|
153
153
|
|
|
154
154
|
#### `DownloadProgress`
|
|
155
155
|
|
package/dist/utils/download.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../src/utils/download.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../src/utils/download.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAU/D"}
|
package/dist/utils/download.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
+
import sanitize from "sanitize-filename";
|
|
1
2
|
/**
|
|
2
3
|
* Blob을 파일로 다운로드
|
|
3
4
|
*
|
|
4
5
|
* @param blob - 다운로드할 Blob 객체
|
|
5
|
-
* @param fileName - 저장할 파일명
|
|
6
|
+
* @param fileName - 저장할 파일명 (파일시스템 금지 문자·예약어는 자동 제거)
|
|
6
7
|
*/
|
|
7
8
|
export function downloadBlob(blob, fileName) {
|
|
8
9
|
const url = URL.createObjectURL(blob);
|
|
9
10
|
try {
|
|
10
11
|
const link = document.createElement("a");
|
|
11
12
|
link.href = url;
|
|
12
|
-
link.download = fileName;
|
|
13
|
+
link.download = sanitize(fileName) || "download";
|
|
13
14
|
link.click();
|
|
14
15
|
}
|
|
15
16
|
finally {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download.js","sourceRoot":"","sources":["../../src/utils/download.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,IAAU,EAAE,QAAgB;IACvD,MAAM,GAAG,GAAG,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACtC,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;QACzC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"download.js","sourceRoot":"","sources":["../../src/utils/download.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,IAAU,EAAE,QAAgB;IACvD,MAAM,GAAG,GAAG,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACtC,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;QACzC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC,IAAI,UAAU,CAAC;QACjD,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;YAAS,CAAC;QACT,UAAU,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC;IACnD,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simplysm/core-browser",
|
|
3
|
-
"version": "14.0.
|
|
3
|
+
"version": "14.0.50",
|
|
4
4
|
"description": "심플리즘 패키지 - 코어 (browser)",
|
|
5
5
|
"author": "심플리즘",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
"./dist/index.js"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
+
"sanitize-filename": "^1.6.4",
|
|
28
29
|
"tabbable": "^6.4.0",
|
|
29
|
-
"@simplysm/core-common": "14.0.
|
|
30
|
+
"@simplysm/core-common": "14.0.50"
|
|
30
31
|
}
|
|
31
32
|
}
|
package/src/utils/download.ts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
+
import sanitize from "sanitize-filename";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Blob을 파일로 다운로드
|
|
3
5
|
*
|
|
4
6
|
* @param blob - 다운로드할 Blob 객체
|
|
5
|
-
* @param fileName - 저장할 파일명
|
|
7
|
+
* @param fileName - 저장할 파일명 (파일시스템 금지 문자·예약어는 자동 제거)
|
|
6
8
|
*/
|
|
7
9
|
export function downloadBlob(blob: Blob, fileName: string): void {
|
|
8
10
|
const url = URL.createObjectURL(blob);
|
|
9
11
|
try {
|
|
10
12
|
const link = document.createElement("a");
|
|
11
13
|
link.href = url;
|
|
12
|
-
link.download = fileName;
|
|
14
|
+
link.download = sanitize(fileName) || "download";
|
|
13
15
|
link.click();
|
|
14
16
|
} finally {
|
|
15
17
|
setTimeout(() => URL.revokeObjectURL(url), 1000);
|