@owp/core 2.5.5 → 2.5.6
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/configs/theme.d.ts +3 -0
- package/configs/theme.js +1 -0
- package/dist/_virtual/index10.js +2 -2
- package/dist/_virtual/index12.js +2 -2
- package/dist/_virtual/index13.js +2 -2
- package/dist/_virtual/index14.js +2 -2
- package/dist/_virtual/index15.js +2 -2
- package/dist/_virtual/index5.js +2 -2
- package/dist/configs/defaultConfig.js +1 -1
- package/dist/configs/theme.js +28 -0
- package/dist/configs/theme.js.map +1 -0
- package/dist/features/themePreview/components/ThemePreviewColorField.js +279 -208
- package/dist/features/themePreview/components/ThemePreviewColorField.js.map +1 -1
- package/dist/features/themePreview/configs/presets.js +6 -38
- package/dist/features/themePreview/configs/presets.js.map +1 -1
- package/dist/features/themePreview/configs/previewStorage.js +28 -27
- package/dist/features/themePreview/configs/previewStorage.js.map +1 -1
- package/dist/features/themePreview/dialogs/ThemePreviewDialog.js +166 -154
- package/dist/features/themePreview/dialogs/ThemePreviewDialog.js.map +1 -1
- package/dist/features/themePreview/hooks/useThemePreview.js +202 -157
- package/dist/features/themePreview/hooks/useThemePreview.js.map +1 -1
- package/dist/features/themePreview/utils/themePreviewExport.js +276 -67
- package/dist/features/themePreview/utils/themePreviewExport.js.map +1 -1
- package/dist/features/themePreview.js +52 -52
- package/dist/node_modules/.pnpm/jsbarcode@3.12.1/node_modules/jsbarcode/bin/barcodes/CODE128/constants.js +1 -1
- package/dist/node_modules/.pnpm/jsbarcode@3.12.1/node_modules/jsbarcode/bin/barcodes/CODE128/index.js +1 -1
- package/dist/node_modules/.pnpm/jsbarcode@3.12.1/node_modules/jsbarcode/bin/barcodes/CODE39/index.js +1 -1
- package/dist/node_modules/.pnpm/jsbarcode@3.12.1/node_modules/jsbarcode/bin/barcodes/CODE93/constants.js +1 -1
- package/dist/node_modules/.pnpm/jsbarcode@3.12.1/node_modules/jsbarcode/bin/barcodes/CODE93/index.js +1 -1
- package/dist/node_modules/.pnpm/jsbarcode@3.12.1/node_modules/jsbarcode/bin/barcodes/EAN_UPC/index.js +1 -1
- package/dist/node_modules/.pnpm/jsbarcode@3.12.1/node_modules/jsbarcode/bin/barcodes/GenericBarcode/index.js +1 -1
- package/dist/node_modules/.pnpm/jsbarcode@3.12.1/node_modules/jsbarcode/bin/barcodes/ITF/constants.js +1 -1
- package/dist/node_modules/.pnpm/jsbarcode@3.12.1/node_modules/jsbarcode/bin/barcodes/ITF/index.js +1 -1
- package/dist/node_modules/.pnpm/jsbarcode@3.12.1/node_modules/jsbarcode/bin/barcodes/MSI/index.js +1 -1
- package/dist/node_modules/.pnpm/jsbarcode@3.12.1/node_modules/jsbarcode/bin/barcodes/codabar/index.js +1 -1
- package/dist/node_modules/.pnpm/jsbarcode@3.12.1/node_modules/jsbarcode/bin/barcodes/pharmacode/index.js +1 -1
- package/dist/node_modules/.pnpm/jsbarcode@3.12.1/node_modules/jsbarcode/bin/renderers/index.js +1 -1
- package/dist/node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/index.js +1 -1
- package/dist/owp-app.css +1 -1
- package/dist/types/configs/theme/index.d.ts +6 -0
- package/dist/types/features/themePreview/configs/index.d.ts +1 -1
- package/dist/types/features/themePreview/configs/presets.d.ts +0 -1
- package/dist/types/features/themePreview/configs/previewStorage.d.ts +1 -0
- package/dist/types/features/themePreview/hooks/useThemePreview.d.ts +2 -1
- package/dist/types/features/themePreview/utils/index.d.ts +1 -1
- package/dist/types/features/themePreview/utils/themePreviewExport.d.ts +38 -1083
- package/dist/types/utils/zipUtil.d.ts +1 -0
- package/dist/utils/zipUtil.js +38 -36
- package/dist/utils/zipUtil.js.map +1 -1
- package/package.json +2 -1
package/dist/utils/zipUtil.js
CHANGED
|
@@ -1,69 +1,71 @@
|
|
|
1
|
-
var
|
|
2
|
-
var i = (e, t) =>
|
|
3
|
-
import
|
|
4
|
-
import { t as
|
|
5
|
-
import { enqueueSnackbar as
|
|
6
|
-
import { loadJSZip as
|
|
1
|
+
var y = Object.defineProperty;
|
|
2
|
+
var i = (e, t) => y(e, "name", { value: t, configurable: !0 });
|
|
3
|
+
import v from "dayjs";
|
|
4
|
+
import { t as E } from "i18next";
|
|
5
|
+
import { enqueueSnackbar as d } from "notistack";
|
|
6
|
+
import { loadJSZip as m } from "./jszipBrowser.js";
|
|
7
7
|
const l = {
|
|
8
8
|
type: "pdf",
|
|
9
9
|
fileExtension: "application/pdf",
|
|
10
10
|
fileTitle: "archive",
|
|
11
11
|
archiveExtension: "zip",
|
|
12
|
-
appendDatetime: !1
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
appendDatetime: !1,
|
|
13
|
+
preserveFileNames: !1
|
|
14
|
+
}, u = /* @__PURE__ */ i((e) => e.replace(/[.*+?^${}()|[\]\\]/g, "_"), "sanitizeFileName"), f = /* @__PURE__ */ i((e) => {
|
|
15
|
+
d(
|
|
16
|
+
E(`Message.${e}`, {
|
|
16
17
|
defaultValue: e
|
|
17
18
|
}),
|
|
18
19
|
{ variant: "warning" }
|
|
19
20
|
);
|
|
20
|
-
}, "showZipWarning"),
|
|
21
|
+
}, "showZipWarning"), x = /* @__PURE__ */ i((e) => ({
|
|
21
22
|
type: (e == null ? void 0 : e.type) ?? l.type,
|
|
22
23
|
fileExtension: (e == null ? void 0 : e.fileExtension) ?? l.fileExtension,
|
|
23
24
|
fileTitle: (e == null ? void 0 : e.fileTitle) ?? l.fileTitle,
|
|
24
25
|
archiveExtension: (e == null ? void 0 : e.archiveExtension) ?? l.archiveExtension,
|
|
25
|
-
appendDatetime: (e == null ? void 0 : e.appendDatetime) ?? l.appendDatetime
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
appendDatetime: (e == null ? void 0 : e.appendDatetime) ?? l.appendDatetime,
|
|
27
|
+
preserveFileNames: (e == null ? void 0 : e.preserveFileNames) ?? l.preserveFileNames
|
|
28
|
+
}), "normalizeZipOptions"), F = /* @__PURE__ */ i((e, t, r) => `${u(`${e + 1}_${t}`)}.${r}`, "createZipEntryFileName"), Z = /* @__PURE__ */ i((e) => e.replace(/^\.+/, "") || l.archiveExtension, "normalizeArchiveExtension"), w = /* @__PURE__ */ i((e, t, r) => `${u(e)}${t ? `-${v().format("YYYY_MM_DD_HH_mm_ss")}` : ""}.${Z(r)}`, "createArchiveFileName"), h = /* @__PURE__ */ i((e, t) => typeof t == "string" ? e === t : t instanceof RegExp ? t.test(e) : t(e), "isMatchedZipEntry"), N = /* @__PURE__ */ i(async (e) => e instanceof Blob ? e.arrayBuffer() : e, "toZipArrayBuffer"), $ = /* @__PURE__ */ i(async (e, t) => {
|
|
29
|
+
const a = await (await m()).loadAsync(await N(e)), n = Object.values(a.files).find(
|
|
28
30
|
(c) => !c.dir && h(c.name, t)
|
|
29
31
|
);
|
|
30
|
-
return
|
|
32
|
+
return n ? n.async("string") : null;
|
|
31
33
|
}, "readZipEntryText"), A = /* @__PURE__ */ i(async (e, t) => {
|
|
32
|
-
const
|
|
33
|
-
return
|
|
34
|
-
}, "readZipEntryJson"),
|
|
35
|
-
t.forEach(({ blob: a, fileName:
|
|
34
|
+
const r = await $(e, t);
|
|
35
|
+
return r ? JSON.parse(r) : null;
|
|
36
|
+
}, "readZipEntryJson"), _ = /* @__PURE__ */ i((e, t, r) => {
|
|
37
|
+
t.forEach(({ blob: a, fileName: n }, c) => {
|
|
36
38
|
a && e.file(
|
|
37
|
-
|
|
38
|
-
new Blob([a], { type:
|
|
39
|
+
r.preserveFileNames ? n : F(c, n, r.fileExtension),
|
|
40
|
+
r.preserveFileNames ? a : new Blob([a], { type: r.type })
|
|
39
41
|
);
|
|
40
42
|
});
|
|
41
43
|
}, "appendZipFiles"), S = /* @__PURE__ */ i(async (e, t) => {
|
|
42
|
-
const
|
|
43
|
-
if (!
|
|
44
|
-
|
|
44
|
+
const r = x(t);
|
|
45
|
+
if (!r.preserveFileNames && !r.type) {
|
|
46
|
+
f("type 이 선언되지 않았습니다");
|
|
45
47
|
return;
|
|
46
48
|
}
|
|
47
|
-
if (!
|
|
48
|
-
|
|
49
|
+
if (!r.preserveFileNames && !r.fileExtension) {
|
|
50
|
+
f("파일 확장자가 선언되지 않았습니다");
|
|
49
51
|
return;
|
|
50
52
|
}
|
|
51
53
|
if (!e) {
|
|
52
|
-
|
|
54
|
+
f("다운로드할 데이터가 없습니다");
|
|
53
55
|
return;
|
|
54
56
|
}
|
|
55
|
-
const a = await
|
|
56
|
-
|
|
57
|
-
const c = await
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
),
|
|
57
|
+
const a = await m(), n = new a();
|
|
58
|
+
_(n, e, r);
|
|
59
|
+
const c = await n.generateAsync({ type: "blob" }), p = URL.createObjectURL(c), s = document.createElement("a");
|
|
60
|
+
s.href = p, s.download = w(
|
|
61
|
+
r.fileTitle,
|
|
62
|
+
r.appendDatetime,
|
|
63
|
+
r.archiveExtension
|
|
64
|
+
), s.click(), URL.revokeObjectURL(p);
|
|
63
65
|
}, "saveAsZipFile");
|
|
64
66
|
export {
|
|
65
67
|
A as readZipEntryJson,
|
|
66
|
-
|
|
68
|
+
$ as readZipEntryText,
|
|
67
69
|
S as saveAsZipFile
|
|
68
70
|
};
|
|
69
71
|
//# sourceMappingURL=zipUtil.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zipUtil.js","sources":["../../src/utils/zipUtil.ts"],"sourcesContent":["import dayjs from 'dayjs';\nimport { t } from 'i18next';\nimport type JSZip from 'jszip';\nimport { enqueueSnackbar } from 'notistack';\nimport { loadJSZip } from './jszipBrowser';\n\ntype BlobInfoData = {\n blob: Blob;\n fileName: string;\n};\n\nexport interface SaveAsZipFileOptions {\n type?: string;\n fileExtension?: string;\n fileTitle?: string;\n archiveExtension?: string;\n appendDatetime?: boolean;\n}\n\nconst DEFAULT_ZIP_OPTIONS: Required<SaveAsZipFileOptions> = {\n type: 'pdf',\n fileExtension: 'application/pdf',\n fileTitle: 'archive',\n archiveExtension: 'zip',\n appendDatetime: false,\n};\n\n/**\n * 파일명 안전 문자 변환\n * @param fileName 원본 파일명\n */\nconst sanitizeFileName = (fileName: string) => fileName.replace(/[.*+?^${}()|[\\]\\\\]/g, '_');\n\n/**\n * ZIP 경고 메시지 출력\n * @param message 경고 메시지\n */\nconst showZipWarning = (message: string) => {\n enqueueSnackbar(\n t(`Message.${message}`, {\n defaultValue: message,\n }),\n { variant: 'warning' },\n );\n};\n\n/**\n * ZIP 저장 옵션 정규화\n * @param options 저장 옵션\n */\nconst normalizeZipOptions = (options?: SaveAsZipFileOptions) => {\n return {\n type: options?.type ?? DEFAULT_ZIP_OPTIONS.type,\n fileExtension: options?.fileExtension ?? DEFAULT_ZIP_OPTIONS.fileExtension,\n fileTitle: options?.fileTitle ?? DEFAULT_ZIP_OPTIONS.fileTitle,\n archiveExtension: options?.archiveExtension ?? DEFAULT_ZIP_OPTIONS.archiveExtension,\n appendDatetime: options?.appendDatetime ?? DEFAULT_ZIP_OPTIONS.appendDatetime,\n };\n};\n\n/**\n * ZIP 내부 파일명 생성\n * @param index 파일 순서\n * @param fileName 파일명\n * @param fileExtension 파일 확장자\n */\nconst createZipEntryFileName = (index: number, fileName: string, fileExtension: string) => {\n return `${sanitizeFileName(`${index + 1}_${fileName}`)}.${fileExtension}`;\n};\n\n/**\n * ZIP 다운로드 파일명 생성\n * @param fileTitle 파일 제목\n * @param appendDatetime 일시 추가 여부\n */\nconst normalizeArchiveExtension = (archiveExtension: string) => {\n return archiveExtension.replace(/^\\.+/, '') || DEFAULT_ZIP_OPTIONS.archiveExtension;\n};\n\n/**\n * ZIP 다운로드 파일명 생성\n * @param fileTitle 파일 제목\n * @param appendDatetime 일시 추가 여부\n * @param archiveExtension 아카이브 확장자\n */\nconst createArchiveFileName = (\n fileTitle: string,\n appendDatetime: boolean,\n archiveExtension: string,\n) => {\n return `${sanitizeFileName(fileTitle)}${appendDatetime ? `-${dayjs().format('YYYY_MM_DD_HH_mm_ss')}` : ''}.${normalizeArchiveExtension(archiveExtension)}`;\n};\n\n/**\n * ZIP 엔트리 일치 여부 확인\n * @param fileName ZIP 엔트리 파일명\n * @param matcher 엔트리 식별자\n */\nconst isMatchedZipEntry = (\n fileName: string,\n matcher: string | RegExp | ((fileName: string) => boolean),\n) => {\n if (typeof matcher === 'string') {\n return fileName === matcher;\n }\n\n if (matcher instanceof RegExp) {\n return matcher.test(fileName);\n }\n\n return matcher(fileName);\n};\n\n/**\n * ZIP 소스 ArrayBuffer 변환\n * @param source ZIP 소스\n */\nconst toZipArrayBuffer = async (source: Blob | ArrayBuffer) => {\n return source instanceof Blob ? source.arrayBuffer() : source;\n};\n\n/**\n * ZIP 엔트리 텍스트 로드\n * @param source ZIP 소스\n * @param matcher 엔트리 식별자\n */\nexport const readZipEntryText = async (\n source: Blob | ArrayBuffer,\n matcher: string | RegExp | ((fileName: string) => boolean),\n): Promise<string | null> => {\n const JSZip = await loadJSZip();\n const zip = await JSZip.loadAsync(await toZipArrayBuffer(source));\n const zipFile = Object.values(zip.files).find(\n (entry) => !entry.dir && isMatchedZipEntry(entry.name, matcher),\n );\n\n if (!zipFile) {\n return null;\n }\n\n return zipFile.async('string');\n};\n\n/**\n * ZIP 엔트리 JSON 로드\n * @param source ZIP 소스\n * @param matcher 엔트리 식별자\n */\nexport const readZipEntryJson = async <T>(\n source: Blob | ArrayBuffer,\n matcher: string | RegExp | ((fileName: string) => boolean),\n): Promise<T | null> => {\n const text = await readZipEntryText(source, matcher);\n\n if (!text) {\n return null;\n }\n\n return JSON.parse(text) as T;\n};\n\n/**\n * ZIP 파일 데이터 추가\n * @param zip ZIP 인스턴스\n * @param data 파일 데이터 목록\n * @param options ZIP 저장 옵션\n */\nconst appendZipFiles = (\n zip: JSZip,\n data: BlobInfoData[],\n options: Required<SaveAsZipFileOptions>,\n) => {\n data.forEach(({ blob, fileName }, index) => {\n if (!blob) {\n return;\n }\n\n zip.file(\n createZipEntryFileName(index, fileName, options.fileExtension),\n new Blob([blob], { type: options.type }),\n );\n });\n};\n\n/**\n * ZIP 파일 저장\n * @param data 저장할 파일 데이터\n * @param options 저장 옵션\n */\nexport const saveAsZipFile = async (\n data: BlobInfoData[],\n options?: SaveAsZipFileOptions,\n) => {\n const normalizedOptions = normalizeZipOptions(options);\n\n if (!normalizedOptions.type) {\n showZipWarning('type 이 선언되지 않았습니다');\n return;\n }\n\n if (!normalizedOptions.fileExtension) {\n showZipWarning('파일 확장자가 선언되지 않았습니다');\n return;\n }\n\n if (!data) {\n showZipWarning('다운로드할 데이터가 없습니다');\n return;\n }\n\n const JSZip = await loadJSZip();\n const zip = new JSZip();\n appendZipFiles(zip, data, normalizedOptions);\n\n const archiveFiles = await zip.generateAsync({ type: 'blob' });\n const url = URL.createObjectURL(archiveFiles);\n const link = document.createElement('a');\n link.href = url;\n link.download = createArchiveFileName(\n normalizedOptions.fileTitle,\n normalizedOptions.appendDatetime,\n normalizedOptions.archiveExtension,\n );\n link.click();\n URL.revokeObjectURL(url);\n};\n"],"names":["DEFAULT_ZIP_OPTIONS","sanitizeFileName","__name","fileName","showZipWarning","message","enqueueSnackbar","t","normalizeZipOptions","options","createZipEntryFileName","index","fileExtension","normalizeArchiveExtension","archiveExtension","createArchiveFileName","fileTitle","appendDatetime","dayjs","isMatchedZipEntry","matcher","toZipArrayBuffer","source","readZipEntryText","zip","loadJSZip","zipFile","entry","readZipEntryJson","text","appendZipFiles","data","blob","saveAsZipFile","normalizedOptions","JSZip","archiveFiles","url","link"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"zipUtil.js","sources":["../../src/utils/zipUtil.ts"],"sourcesContent":["import dayjs from 'dayjs';\nimport { t } from 'i18next';\nimport type JSZip from 'jszip';\nimport { enqueueSnackbar } from 'notistack';\nimport { loadJSZip } from './jszipBrowser';\n\ntype BlobInfoData = {\n blob: Blob;\n fileName: string;\n};\n\nexport interface SaveAsZipFileOptions {\n type?: string;\n fileExtension?: string;\n fileTitle?: string;\n archiveExtension?: string;\n appendDatetime?: boolean;\n preserveFileNames?: boolean;\n}\n\nconst DEFAULT_ZIP_OPTIONS: Required<SaveAsZipFileOptions> = {\n type: 'pdf',\n fileExtension: 'application/pdf',\n fileTitle: 'archive',\n archiveExtension: 'zip',\n appendDatetime: false,\n preserveFileNames: false,\n};\n\n/**\n * 파일명 안전 문자 변환\n * @param fileName 원본 파일명\n */\nconst sanitizeFileName = (fileName: string) => fileName.replace(/[.*+?^${}()|[\\]\\\\]/g, '_');\n\n/**\n * ZIP 경고 메시지 출력\n * @param message 경고 메시지\n */\nconst showZipWarning = (message: string) => {\n enqueueSnackbar(\n t(`Message.${message}`, {\n defaultValue: message,\n }),\n { variant: 'warning' },\n );\n};\n\n/**\n * ZIP 저장 옵션 정규화\n * @param options 저장 옵션\n */\nconst normalizeZipOptions = (options?: SaveAsZipFileOptions) => {\n return {\n type: options?.type ?? DEFAULT_ZIP_OPTIONS.type,\n fileExtension: options?.fileExtension ?? DEFAULT_ZIP_OPTIONS.fileExtension,\n fileTitle: options?.fileTitle ?? DEFAULT_ZIP_OPTIONS.fileTitle,\n archiveExtension: options?.archiveExtension ?? DEFAULT_ZIP_OPTIONS.archiveExtension,\n appendDatetime: options?.appendDatetime ?? DEFAULT_ZIP_OPTIONS.appendDatetime,\n preserveFileNames: options?.preserveFileNames ?? DEFAULT_ZIP_OPTIONS.preserveFileNames,\n };\n};\n\n/**\n * ZIP 내부 파일명 생성\n * @param index 파일 순서\n * @param fileName 파일명\n * @param fileExtension 파일 확장자\n */\nconst createZipEntryFileName = (index: number, fileName: string, fileExtension: string) => {\n return `${sanitizeFileName(`${index + 1}_${fileName}`)}.${fileExtension}`;\n};\n\n/**\n * ZIP 다운로드 파일명 생성\n * @param fileTitle 파일 제목\n * @param appendDatetime 일시 추가 여부\n */\nconst normalizeArchiveExtension = (archiveExtension: string) => {\n return archiveExtension.replace(/^\\.+/, '') || DEFAULT_ZIP_OPTIONS.archiveExtension;\n};\n\n/**\n * ZIP 다운로드 파일명 생성\n * @param fileTitle 파일 제목\n * @param appendDatetime 일시 추가 여부\n * @param archiveExtension 아카이브 확장자\n */\nconst createArchiveFileName = (\n fileTitle: string,\n appendDatetime: boolean,\n archiveExtension: string,\n) => {\n return `${sanitizeFileName(fileTitle)}${appendDatetime ? `-${dayjs().format('YYYY_MM_DD_HH_mm_ss')}` : ''}.${normalizeArchiveExtension(archiveExtension)}`;\n};\n\n/**\n * ZIP 엔트리 일치 여부 확인\n * @param fileName ZIP 엔트리 파일명\n * @param matcher 엔트리 식별자\n */\nconst isMatchedZipEntry = (\n fileName: string,\n matcher: string | RegExp | ((fileName: string) => boolean),\n) => {\n if (typeof matcher === 'string') {\n return fileName === matcher;\n }\n\n if (matcher instanceof RegExp) {\n return matcher.test(fileName);\n }\n\n return matcher(fileName);\n};\n\n/**\n * ZIP 소스 ArrayBuffer 변환\n * @param source ZIP 소스\n */\nconst toZipArrayBuffer = async (source: Blob | ArrayBuffer) => {\n return source instanceof Blob ? source.arrayBuffer() : source;\n};\n\n/**\n * ZIP 엔트리 텍스트 로드\n * @param source ZIP 소스\n * @param matcher 엔트리 식별자\n */\nexport const readZipEntryText = async (\n source: Blob | ArrayBuffer,\n matcher: string | RegExp | ((fileName: string) => boolean),\n): Promise<string | null> => {\n const JSZip = await loadJSZip();\n const zip = await JSZip.loadAsync(await toZipArrayBuffer(source));\n const zipFile = Object.values(zip.files).find(\n (entry) => !entry.dir && isMatchedZipEntry(entry.name, matcher),\n );\n\n if (!zipFile) {\n return null;\n }\n\n return zipFile.async('string');\n};\n\n/**\n * ZIP 엔트리 JSON 로드\n * @param source ZIP 소스\n * @param matcher 엔트리 식별자\n */\nexport const readZipEntryJson = async <T>(\n source: Blob | ArrayBuffer,\n matcher: string | RegExp | ((fileName: string) => boolean),\n): Promise<T | null> => {\n const text = await readZipEntryText(source, matcher);\n\n if (!text) {\n return null;\n }\n\n return JSON.parse(text) as T;\n};\n\n/**\n * ZIP 파일 데이터 추가\n * @param zip ZIP 인스턴스\n * @param data 파일 데이터 목록\n * @param options ZIP 저장 옵션\n */\nconst appendZipFiles = (\n zip: JSZip,\n data: BlobInfoData[],\n options: Required<SaveAsZipFileOptions>,\n) => {\n data.forEach(({ blob, fileName }, index) => {\n if (!blob) {\n return;\n }\n\n zip.file(\n options.preserveFileNames\n ? fileName\n : createZipEntryFileName(index, fileName, options.fileExtension),\n options.preserveFileNames ? blob : new Blob([blob], { type: options.type }),\n );\n });\n};\n\n/**\n * ZIP 파일 저장\n * @param data 저장할 파일 데이터\n * @param options 저장 옵션\n */\nexport const saveAsZipFile = async (\n data: BlobInfoData[],\n options?: SaveAsZipFileOptions,\n) => {\n const normalizedOptions = normalizeZipOptions(options);\n\n if (!normalizedOptions.preserveFileNames && !normalizedOptions.type) {\n showZipWarning('type 이 선언되지 않았습니다');\n return;\n }\n\n if (!normalizedOptions.preserveFileNames && !normalizedOptions.fileExtension) {\n showZipWarning('파일 확장자가 선언되지 않았습니다');\n return;\n }\n\n if (!data) {\n showZipWarning('다운로드할 데이터가 없습니다');\n return;\n }\n\n const JSZip = await loadJSZip();\n const zip = new JSZip();\n appendZipFiles(zip, data, normalizedOptions);\n\n const archiveFiles = await zip.generateAsync({ type: 'blob' });\n const url = URL.createObjectURL(archiveFiles);\n const link = document.createElement('a');\n link.href = url;\n link.download = createArchiveFileName(\n normalizedOptions.fileTitle,\n normalizedOptions.appendDatetime,\n normalizedOptions.archiveExtension,\n );\n link.click();\n URL.revokeObjectURL(url);\n};\n"],"names":["DEFAULT_ZIP_OPTIONS","sanitizeFileName","__name","fileName","showZipWarning","message","enqueueSnackbar","t","normalizeZipOptions","options","createZipEntryFileName","index","fileExtension","normalizeArchiveExtension","archiveExtension","createArchiveFileName","fileTitle","appendDatetime","dayjs","isMatchedZipEntry","matcher","toZipArrayBuffer","source","readZipEntryText","zip","loadJSZip","zipFile","entry","readZipEntryJson","text","appendZipFiles","data","blob","saveAsZipFile","normalizedOptions","JSZip","archiveFiles","url","link"],"mappings":";;;;;;A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kB,qBAAqB,CAACA,EAAkB,MAAM;AACnE,IAAA9B,EAAe,mBAAmB;AAClC;AAAA,EACF;AAEA,MAAI,CAAC8B,EAAkB,qBAAqB,CAACA,EAAkB,eAAe;AAC5E,IAAA9B,EAAe,oBAAoB;AACnC;AAAA,EACF;AAEA,MAAI,CAAC2B,GAAM;AACT,IAAA3B,EAAe,iBAAiB;AAChC;AAAA,EACF;AAEA,QAAM+B,IAAQ,MAAMV,EAAA,GACdD,IAAM,IAAIW,EAAA;AAChB,EAAAL,EAAeN,GAAKO,GAAMG,CAAiB;AAE3C,QAAME,IAAe,MAAMZ,EAAI,cAAc,EAAE,MAAM,QAAQ,GACvDa,IAAM,IAAI,gBAAgBD,CAAY,GACtCE,IAAO,SAAS,cAAc,GAAG;AACvC,EAAAA,EAAK,OAAOD,GACZC,EAAK,WAAWvB;AAAA,IACdmB,EAAkB;AAAA,IAClBA,EAAkB;AAAA,IAClBA,EAAkB;AAAA,EAAA,GAEpBI,EAAK,MAAA,GACL,IAAI,gBAAgBD,CAAG;AACzB,GApC6B;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owp/core",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "2.5.
|
|
4
|
+
"version": "2.5.6",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -92,6 +92,7 @@
|
|
|
92
92
|
"colors/",
|
|
93
93
|
"colors.d.ts",
|
|
94
94
|
"colors.js",
|
|
95
|
+
"configs/",
|
|
95
96
|
"constants.d.ts",
|
|
96
97
|
"constants.js",
|
|
97
98
|
"contexts.d.ts",
|