@zag-js/file-utils 0.53.0 → 0.54.0
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/dist/index.js +172 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +137 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,2 +1,173 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
dataURItoBlob: () => dataURItoBlob,
|
|
24
|
+
downloadFile: () => downloadFile,
|
|
25
|
+
getAcceptAttrString: () => getAcceptAttrString,
|
|
26
|
+
getFileDataUrl: () => getFileDataUrl,
|
|
27
|
+
getTotalFileSize: () => getTotalFileSize,
|
|
28
|
+
isFileEqual: () => isFileEqual,
|
|
29
|
+
isMSEdge: () => isMSEdge,
|
|
30
|
+
isValidFileSize: () => isValidFileSize,
|
|
31
|
+
isValidFileType: () => isValidFileType
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(src_exports);
|
|
34
|
+
|
|
35
|
+
// src/data-url-to-blob.ts
|
|
36
|
+
function dataURItoBlob(uri) {
|
|
37
|
+
const binary = atob(uri.split(",")[1]);
|
|
38
|
+
const mimeString = uri.split(",")[0].split(":")[1].split(";")[0];
|
|
39
|
+
const buffer = new ArrayBuffer(binary.length);
|
|
40
|
+
const intArray = new Uint8Array(buffer);
|
|
41
|
+
for (let i = 0; i < binary.length; i++) {
|
|
42
|
+
intArray[i] = binary.charCodeAt(i);
|
|
43
|
+
}
|
|
44
|
+
return new Blob([buffer], { type: mimeString });
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// src/download-file.ts
|
|
48
|
+
function isMSEdge(win) {
|
|
49
|
+
return Boolean(win.navigator && win.navigator.msSaveOrOpenBlob);
|
|
50
|
+
}
|
|
51
|
+
function downloadFile(options) {
|
|
52
|
+
const { file, win, type, name } = options;
|
|
53
|
+
const doc = win.document;
|
|
54
|
+
const obj = typeof file === "string" ? new Blob([file], { type }) : file;
|
|
55
|
+
const fileName = typeof file === "string" ? name : file instanceof File ? file.name : void 0;
|
|
56
|
+
if (isMSEdge(win)) {
|
|
57
|
+
win.navigator.msSaveOrOpenBlob(obj, fileName || "file-download");
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const url = win.URL.createObjectURL(obj);
|
|
61
|
+
const anchor = doc.createElement("a");
|
|
62
|
+
anchor.style.display = "none";
|
|
63
|
+
anchor.href = url;
|
|
64
|
+
anchor.rel = "noopener";
|
|
65
|
+
anchor.download = fileName || "file-download";
|
|
66
|
+
doc.documentElement.appendChild(anchor);
|
|
67
|
+
anchor.click();
|
|
68
|
+
setTimeout(() => {
|
|
69
|
+
win.URL.revokeObjectURL(url);
|
|
70
|
+
anchor.remove();
|
|
71
|
+
}, 0);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// src/get-accept-attr.ts
|
|
75
|
+
function isMIMEType(v) {
|
|
76
|
+
return v === "audio/*" || v === "video/*" || v === "image/*" || v === "text/*" || /\w+\/[-+.\w]+/g.test(v);
|
|
77
|
+
}
|
|
78
|
+
function isExt(v) {
|
|
79
|
+
return /^.*\.[\w]+$/.test(v);
|
|
80
|
+
}
|
|
81
|
+
function getAcceptAttrString(accept) {
|
|
82
|
+
if (!accept)
|
|
83
|
+
return;
|
|
84
|
+
if (typeof accept === "string")
|
|
85
|
+
return accept;
|
|
86
|
+
return Object.entries(accept).reduce((a, [mimeType, ext]) => [...a, mimeType, ...ext], []).filter((v) => isMIMEType(v) || isExt(v)).join(",");
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// src/get-file-data-url.ts
|
|
90
|
+
var getFileDataUrl = async (file) => {
|
|
91
|
+
const reader = new FileReader();
|
|
92
|
+
return new Promise((resolve, reject) => {
|
|
93
|
+
reader.onerror = () => {
|
|
94
|
+
reader.abort();
|
|
95
|
+
reject(new Error("There was an error reading a file"));
|
|
96
|
+
};
|
|
97
|
+
reader.onloadend = () => {
|
|
98
|
+
const { result } = reader;
|
|
99
|
+
if (result instanceof ArrayBuffer) {
|
|
100
|
+
reject(new Error("Expected DataURL as string from Blob/File, got ArrayBuffer"));
|
|
101
|
+
} else {
|
|
102
|
+
resolve(result || void 0);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
reader.readAsDataURL(file);
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// src/get-total-file-size.ts
|
|
110
|
+
var getTotalFileSize = (files) => {
|
|
111
|
+
return files.reduce((acc, file) => acc + file.size, 0);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
// src/is-file-equal.ts
|
|
115
|
+
var isFileEqual = (file1, file2) => {
|
|
116
|
+
return file1.name === file2.name && file1.size === file2.size && file1.type === file2.type;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
// src/is-valid-file-size.ts
|
|
120
|
+
var isDefined = (v) => v !== void 0 && v !== null;
|
|
121
|
+
function isValidFileSize(file, minSize, maxSize) {
|
|
122
|
+
if (isDefined(file.size)) {
|
|
123
|
+
if (isDefined(minSize) && isDefined(maxSize)) {
|
|
124
|
+
if (file.size > maxSize)
|
|
125
|
+
return [false, "FILE_TOO_LARGE"];
|
|
126
|
+
if (file.size < minSize)
|
|
127
|
+
return [false, "FILE_TOO_SMALL"];
|
|
128
|
+
} else if (isDefined(minSize) && file.size < minSize) {
|
|
129
|
+
return [false, "FILE_TOO_SMALL"];
|
|
130
|
+
} else if (isDefined(maxSize) && file.size > maxSize) {
|
|
131
|
+
return [false, "FILE_TOO_LARGE"];
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return [true, null];
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// src/is-valid-file-type.ts
|
|
138
|
+
function isFileAccepted(file, accept) {
|
|
139
|
+
if (file && accept) {
|
|
140
|
+
const types = Array.isArray(accept) ? accept : accept.split(",");
|
|
141
|
+
const fileName = file.name || "";
|
|
142
|
+
const mimeType = (file.type || "").toLowerCase();
|
|
143
|
+
const baseMimeType = mimeType.replace(/\/.*$/, "");
|
|
144
|
+
return types.some((type) => {
|
|
145
|
+
const validType = type.trim().toLowerCase();
|
|
146
|
+
if (validType.charAt(0) === ".") {
|
|
147
|
+
return fileName.toLowerCase().endsWith(validType);
|
|
148
|
+
}
|
|
149
|
+
if (validType.endsWith("/*")) {
|
|
150
|
+
return baseMimeType === validType.replace(/\/.*$/, "");
|
|
151
|
+
}
|
|
152
|
+
return mimeType === validType;
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
function isValidFileType(file, accept) {
|
|
158
|
+
const isAcceptable = file.type === "application/x-moz-file" || isFileAccepted(file, accept);
|
|
159
|
+
return [isAcceptable, isAcceptable ? null : "FILE_INVALID_TYPE"];
|
|
160
|
+
}
|
|
161
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
162
|
+
0 && (module.exports = {
|
|
163
|
+
dataURItoBlob,
|
|
164
|
+
downloadFile,
|
|
165
|
+
getAcceptAttrString,
|
|
166
|
+
getFileDataUrl,
|
|
167
|
+
getTotalFileSize,
|
|
168
|
+
isFileEqual,
|
|
169
|
+
isMSEdge,
|
|
170
|
+
isValidFileSize,
|
|
171
|
+
isValidFileType
|
|
172
|
+
});
|
|
2
173
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/data-url-to-blob.ts","../src/download-file.ts","../src/get-accept-attr.ts","../src/get-file-data-url.ts","../src/get-total-file-size.ts","../src/is-file-equal.ts","../src/is-valid-file-size.ts","../src/is-valid-file-type.ts"],"sourcesContent":["export * from \"./data-url-to-blob\"\nexport * from \"./download-file\"\nexport * from \"./get-accept-attr\"\nexport * from \"./get-file-data-url\"\nexport * from \"./get-total-file-size\"\nexport * from \"./is-file-equal\"\nexport * from \"./is-valid-file-size\"\nexport * from \"./is-valid-file-type\"\nexport type * from \"./types.ts\"\n","export function dataURItoBlob(uri: string): Blob {\n const binary = atob(uri.split(\",\")[1])\n\n // separate out the mime component\n const mimeString = uri.split(\",\")[0].split(\":\")[1].split(\";\")[0]\n\n // write the bytes of the string to an ArrayBuffer\n const buffer = new ArrayBuffer(binary.length)\n\n // create a view into the buffer\n const intArray = new Uint8Array(buffer)\n\n for (let i = 0; i < binary.length; i++) {\n intArray[i] = binary.charCodeAt(i)\n }\n\n return new Blob([buffer], { type: mimeString })\n}\n","export function isMSEdge(win: Window): win is Window & { navigator: { msSaveOrOpenBlob: Function } } {\n // @ts-ignore\n return Boolean(win.navigator && win.navigator.msSaveOrOpenBlob)\n}\n\ninterface DownloadFileOptions {\n /**\n * The name of the file\n */\n name?: string\n /**\n * The MIME type of the file\n */\n type?: string\n /**\n * The file contents\n */\n file: File | Blob | string\n /**\n * The window environment\n */\n win: typeof window\n}\n\nexport function downloadFile(options: DownloadFileOptions) {\n const { file, win, type, name } = options\n\n const doc = win.document\n\n const obj = typeof file === \"string\" ? new Blob([file], { type }) : file\n const fileName = typeof file === \"string\" ? name : file instanceof File ? file.name : undefined\n\n if (isMSEdge(win)) {\n win.navigator.msSaveOrOpenBlob(obj, fileName || \"file-download\")\n return\n }\n\n const url = win.URL.createObjectURL(obj)\n\n const anchor = doc.createElement(\"a\")\n anchor.style.display = \"none\"\n anchor.href = url\n anchor.rel = \"noopener\"\n anchor.download = fileName || \"file-download\"\n\n doc.documentElement.appendChild(anchor)\n anchor.click()\n\n setTimeout(() => {\n win.URL.revokeObjectURL(url)\n anchor.remove()\n }, 0)\n}\n","function isMIMEType(v: string) {\n return v === \"audio/*\" || v === \"video/*\" || v === \"image/*\" || v === \"text/*\" || /\\w+\\/[-+.\\w]+/g.test(v)\n}\n\nfunction isExt(v: string) {\n return /^.*\\.[\\w]+$/.test(v)\n}\n\nexport function getAcceptAttrString(accept: Record<string, string[]> | string | undefined) {\n if (!accept) return\n if (typeof accept === \"string\") return accept\n return Object.entries(accept)\n .reduce((a, [mimeType, ext]) => [...a, mimeType, ...ext], [] as string[])\n .filter((v) => isMIMEType(v) || isExt(v))\n .join(\",\")\n}\n","export const getFileDataUrl = async (file: File | Blob) => {\n const reader = new FileReader()\n return new Promise<string | undefined>((resolve, reject) => {\n reader.onerror = () => {\n reader.abort()\n reject(new Error(\"There was an error reading a file\"))\n }\n\n reader.onloadend = () => {\n const { result } = reader\n if (result instanceof ArrayBuffer) {\n reject(new Error(\"Expected DataURL as string from Blob/File, got ArrayBuffer\"))\n } else {\n resolve(result || undefined)\n }\n }\n\n reader.readAsDataURL(file)\n })\n}\n","export const getTotalFileSize = (files: File[]) => {\n return files.reduce((acc, file) => acc + file.size, 0)\n}\n","export const isFileEqual = (file1: File, file2: File) => {\n return file1.name === file2.name && file1.size === file2.size && file1.type === file2.type\n}\n","import type { FileError } from \"./types\"\n\nconst isDefined = <T>(v: T | undefined): v is T => v !== undefined && v !== null\n\nexport function isValidFileSize(file: File, minSize?: number, maxSize?: number): [boolean, FileError | null] {\n if (isDefined(file.size)) {\n if (isDefined(minSize) && isDefined(maxSize)) {\n if (file.size > maxSize) return [false, \"FILE_TOO_LARGE\"]\n if (file.size < minSize) return [false, \"FILE_TOO_SMALL\"]\n } else if (isDefined(minSize) && file.size < minSize) {\n return [false, \"FILE_TOO_SMALL\"]\n } else if (isDefined(maxSize) && file.size > maxSize) {\n return [false, \"FILE_TOO_LARGE\"]\n }\n }\n return [true, null]\n}\n","import type { FileError } from \"./types\"\n\nfunction isFileAccepted(file: File | null, accept: string[] | string | undefined) {\n if (file && accept) {\n const types = Array.isArray(accept) ? accept : accept.split(\",\")\n\n const fileName = file.name || \"\"\n const mimeType = (file.type || \"\").toLowerCase()\n const baseMimeType = mimeType.replace(/\\/.*$/, \"\")\n\n return types.some((type) => {\n const validType = type.trim().toLowerCase()\n\n if (validType.charAt(0) === \".\") {\n return fileName.toLowerCase().endsWith(validType)\n }\n\n if (validType.endsWith(\"/*\")) {\n return baseMimeType === validType.replace(/\\/.*$/, \"\")\n }\n\n return mimeType === validType\n })\n }\n return true\n}\n\nexport function isValidFileType(file: File, accept: string | undefined): [boolean, FileError | null] {\n const isAcceptable = file.type === \"application/x-moz-file\" || isFileAccepted(file, accept)\n return [isAcceptable, isAcceptable ? null : \"FILE_INVALID_TYPE\"]\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/data-url-to-blob.ts","../src/download-file.ts","../src/get-accept-attr.ts","../src/get-file-data-url.ts","../src/get-total-file-size.ts","../src/is-file-equal.ts","../src/is-valid-file-size.ts","../src/is-valid-file-type.ts"],"sourcesContent":["export * from \"./data-url-to-blob\"\nexport * from \"./download-file\"\nexport * from \"./get-accept-attr\"\nexport * from \"./get-file-data-url\"\nexport * from \"./get-total-file-size\"\nexport * from \"./is-file-equal\"\nexport * from \"./is-valid-file-size\"\nexport * from \"./is-valid-file-type\"\nexport type * from \"./types.ts\"\n","export function dataURItoBlob(uri: string): Blob {\n const binary = atob(uri.split(\",\")[1])\n\n // separate out the mime component\n const mimeString = uri.split(\",\")[0].split(\":\")[1].split(\";\")[0]\n\n // write the bytes of the string to an ArrayBuffer\n const buffer = new ArrayBuffer(binary.length)\n\n // create a view into the buffer\n const intArray = new Uint8Array(buffer)\n\n for (let i = 0; i < binary.length; i++) {\n intArray[i] = binary.charCodeAt(i)\n }\n\n return new Blob([buffer], { type: mimeString })\n}\n","export function isMSEdge(win: Window): win is Window & { navigator: { msSaveOrOpenBlob: Function } } {\n // @ts-ignore\n return Boolean(win.navigator && win.navigator.msSaveOrOpenBlob)\n}\n\ninterface DownloadFileOptions {\n /**\n * The name of the file\n */\n name?: string\n /**\n * The MIME type of the file\n */\n type?: string\n /**\n * The file contents\n */\n file: File | Blob | string\n /**\n * The window environment\n */\n win: typeof window\n}\n\nexport function downloadFile(options: DownloadFileOptions) {\n const { file, win, type, name } = options\n\n const doc = win.document\n\n const obj = typeof file === \"string\" ? new Blob([file], { type }) : file\n const fileName = typeof file === \"string\" ? name : file instanceof File ? file.name : undefined\n\n if (isMSEdge(win)) {\n win.navigator.msSaveOrOpenBlob(obj, fileName || \"file-download\")\n return\n }\n\n const url = win.URL.createObjectURL(obj)\n\n const anchor = doc.createElement(\"a\")\n anchor.style.display = \"none\"\n anchor.href = url\n anchor.rel = \"noopener\"\n anchor.download = fileName || \"file-download\"\n\n doc.documentElement.appendChild(anchor)\n anchor.click()\n\n setTimeout(() => {\n win.URL.revokeObjectURL(url)\n anchor.remove()\n }, 0)\n}\n","function isMIMEType(v: string) {\n return v === \"audio/*\" || v === \"video/*\" || v === \"image/*\" || v === \"text/*\" || /\\w+\\/[-+.\\w]+/g.test(v)\n}\n\nfunction isExt(v: string) {\n return /^.*\\.[\\w]+$/.test(v)\n}\n\nexport function getAcceptAttrString(accept: Record<string, string[]> | string | undefined) {\n if (!accept) return\n if (typeof accept === \"string\") return accept\n return Object.entries(accept)\n .reduce((a, [mimeType, ext]) => [...a, mimeType, ...ext], [] as string[])\n .filter((v) => isMIMEType(v) || isExt(v))\n .join(\",\")\n}\n","export const getFileDataUrl = async (file: File | Blob) => {\n const reader = new FileReader()\n return new Promise<string | undefined>((resolve, reject) => {\n reader.onerror = () => {\n reader.abort()\n reject(new Error(\"There was an error reading a file\"))\n }\n\n reader.onloadend = () => {\n const { result } = reader\n if (result instanceof ArrayBuffer) {\n reject(new Error(\"Expected DataURL as string from Blob/File, got ArrayBuffer\"))\n } else {\n resolve(result || undefined)\n }\n }\n\n reader.readAsDataURL(file)\n })\n}\n","export const getTotalFileSize = (files: File[]) => {\n return files.reduce((acc, file) => acc + file.size, 0)\n}\n","export const isFileEqual = (file1: File, file2: File) => {\n return file1.name === file2.name && file1.size === file2.size && file1.type === file2.type\n}\n","import type { FileError } from \"./types\"\n\nconst isDefined = <T>(v: T | undefined): v is T => v !== undefined && v !== null\n\nexport function isValidFileSize(file: File, minSize?: number, maxSize?: number): [boolean, FileError | null] {\n if (isDefined(file.size)) {\n if (isDefined(minSize) && isDefined(maxSize)) {\n if (file.size > maxSize) return [false, \"FILE_TOO_LARGE\"]\n if (file.size < minSize) return [false, \"FILE_TOO_SMALL\"]\n } else if (isDefined(minSize) && file.size < minSize) {\n return [false, \"FILE_TOO_SMALL\"]\n } else if (isDefined(maxSize) && file.size > maxSize) {\n return [false, \"FILE_TOO_LARGE\"]\n }\n }\n return [true, null]\n}\n","import type { FileError } from \"./types\"\n\nfunction isFileAccepted(file: File | null, accept: string[] | string | undefined) {\n if (file && accept) {\n const types = Array.isArray(accept) ? accept : accept.split(\",\")\n\n const fileName = file.name || \"\"\n const mimeType = (file.type || \"\").toLowerCase()\n const baseMimeType = mimeType.replace(/\\/.*$/, \"\")\n\n return types.some((type) => {\n const validType = type.trim().toLowerCase()\n\n if (validType.charAt(0) === \".\") {\n return fileName.toLowerCase().endsWith(validType)\n }\n\n if (validType.endsWith(\"/*\")) {\n return baseMimeType === validType.replace(/\\/.*$/, \"\")\n }\n\n return mimeType === validType\n })\n }\n return true\n}\n\nexport function isValidFileType(file: File, accept: string | undefined): [boolean, FileError | null] {\n const isAcceptable = file.type === \"application/x-moz-file\" || isFileAccepted(file, accept)\n return [isAcceptable, isAcceptable ? null : \"FILE_INVALID_TYPE\"]\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,SAAS,cAAc,KAAmB;AAC/C,QAAM,SAAS,KAAK,IAAI,MAAM,GAAG,EAAE,CAAC,CAAC;AAGrC,QAAM,aAAa,IAAI,MAAM,GAAG,EAAE,CAAC,EAAE,MAAM,GAAG,EAAE,CAAC,EAAE,MAAM,GAAG,EAAE,CAAC;AAG/D,QAAM,SAAS,IAAI,YAAY,OAAO,MAAM;AAG5C,QAAM,WAAW,IAAI,WAAW,MAAM;AAEtC,WAAS,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;AACtC,aAAS,CAAC,IAAI,OAAO,WAAW,CAAC;AAAA,EACnC;AAEA,SAAO,IAAI,KAAK,CAAC,MAAM,GAAG,EAAE,MAAM,WAAW,CAAC;AAChD;;;ACjBO,SAAS,SAAS,KAA4E;AAEnG,SAAO,QAAQ,IAAI,aAAa,IAAI,UAAU,gBAAgB;AAChE;AAqBO,SAAS,aAAa,SAA8B;AACzD,QAAM,EAAE,MAAM,KAAK,MAAM,KAAK,IAAI;AAElC,QAAM,MAAM,IAAI;AAEhB,QAAM,MAAM,OAAO,SAAS,WAAW,IAAI,KAAK,CAAC,IAAI,GAAG,EAAE,KAAK,CAAC,IAAI;AACpE,QAAM,WAAW,OAAO,SAAS,WAAW,OAAO,gBAAgB,OAAO,KAAK,OAAO;AAEtF,MAAI,SAAS,GAAG,GAAG;AACjB,QAAI,UAAU,iBAAiB,KAAK,YAAY,eAAe;AAC/D;AAAA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G;AAC5B,eAAO,iBAAiB,UAAU,QAAQ,SAAS,EAAE;AAAA,MACvD;AAEA,aAAO,aAAa;AAAA,IACtB,CAAC;AAAA,EACH;AACA,SAAO;AACT;AAEO,SAAS,gBAAgB,MAAY,QAAyD;AACnG,QAAM,eAAe,KAAK,SAAS,4BAA4B,eAAe,MAAM,MAAM;AAC1F,SAAO,CAAC,cAAc,eAAe,OAAO,mBAAmB;AACjE;","names":[]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,138 @@
|
|
|
1
|
-
|
|
1
|
+
// src/data-url-to-blob.ts
|
|
2
|
+
function dataURItoBlob(uri) {
|
|
3
|
+
const binary = atob(uri.split(",")[1]);
|
|
4
|
+
const mimeString = uri.split(",")[0].split(":")[1].split(";")[0];
|
|
5
|
+
const buffer = new ArrayBuffer(binary.length);
|
|
6
|
+
const intArray = new Uint8Array(buffer);
|
|
7
|
+
for (let i = 0; i < binary.length; i++) {
|
|
8
|
+
intArray[i] = binary.charCodeAt(i);
|
|
9
|
+
}
|
|
10
|
+
return new Blob([buffer], { type: mimeString });
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// src/download-file.ts
|
|
14
|
+
function isMSEdge(win) {
|
|
15
|
+
return Boolean(win.navigator && win.navigator.msSaveOrOpenBlob);
|
|
16
|
+
}
|
|
17
|
+
function downloadFile(options) {
|
|
18
|
+
const { file, win, type, name } = options;
|
|
19
|
+
const doc = win.document;
|
|
20
|
+
const obj = typeof file === "string" ? new Blob([file], { type }) : file;
|
|
21
|
+
const fileName = typeof file === "string" ? name : file instanceof File ? file.name : void 0;
|
|
22
|
+
if (isMSEdge(win)) {
|
|
23
|
+
win.navigator.msSaveOrOpenBlob(obj, fileName || "file-download");
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const url = win.URL.createObjectURL(obj);
|
|
27
|
+
const anchor = doc.createElement("a");
|
|
28
|
+
anchor.style.display = "none";
|
|
29
|
+
anchor.href = url;
|
|
30
|
+
anchor.rel = "noopener";
|
|
31
|
+
anchor.download = fileName || "file-download";
|
|
32
|
+
doc.documentElement.appendChild(anchor);
|
|
33
|
+
anchor.click();
|
|
34
|
+
setTimeout(() => {
|
|
35
|
+
win.URL.revokeObjectURL(url);
|
|
36
|
+
anchor.remove();
|
|
37
|
+
}, 0);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// src/get-accept-attr.ts
|
|
41
|
+
function isMIMEType(v) {
|
|
42
|
+
return v === "audio/*" || v === "video/*" || v === "image/*" || v === "text/*" || /\w+\/[-+.\w]+/g.test(v);
|
|
43
|
+
}
|
|
44
|
+
function isExt(v) {
|
|
45
|
+
return /^.*\.[\w]+$/.test(v);
|
|
46
|
+
}
|
|
47
|
+
function getAcceptAttrString(accept) {
|
|
48
|
+
if (!accept)
|
|
49
|
+
return;
|
|
50
|
+
if (typeof accept === "string")
|
|
51
|
+
return accept;
|
|
52
|
+
return Object.entries(accept).reduce((a, [mimeType, ext]) => [...a, mimeType, ...ext], []).filter((v) => isMIMEType(v) || isExt(v)).join(",");
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// src/get-file-data-url.ts
|
|
56
|
+
var getFileDataUrl = async (file) => {
|
|
57
|
+
const reader = new FileReader();
|
|
58
|
+
return new Promise((resolve, reject) => {
|
|
59
|
+
reader.onerror = () => {
|
|
60
|
+
reader.abort();
|
|
61
|
+
reject(new Error("There was an error reading a file"));
|
|
62
|
+
};
|
|
63
|
+
reader.onloadend = () => {
|
|
64
|
+
const { result } = reader;
|
|
65
|
+
if (result instanceof ArrayBuffer) {
|
|
66
|
+
reject(new Error("Expected DataURL as string from Blob/File, got ArrayBuffer"));
|
|
67
|
+
} else {
|
|
68
|
+
resolve(result || void 0);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
reader.readAsDataURL(file);
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
// src/get-total-file-size.ts
|
|
76
|
+
var getTotalFileSize = (files) => {
|
|
77
|
+
return files.reduce((acc, file) => acc + file.size, 0);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// src/is-file-equal.ts
|
|
81
|
+
var isFileEqual = (file1, file2) => {
|
|
82
|
+
return file1.name === file2.name && file1.size === file2.size && file1.type === file2.type;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// src/is-valid-file-size.ts
|
|
86
|
+
var isDefined = (v) => v !== void 0 && v !== null;
|
|
87
|
+
function isValidFileSize(file, minSize, maxSize) {
|
|
88
|
+
if (isDefined(file.size)) {
|
|
89
|
+
if (isDefined(minSize) && isDefined(maxSize)) {
|
|
90
|
+
if (file.size > maxSize)
|
|
91
|
+
return [false, "FILE_TOO_LARGE"];
|
|
92
|
+
if (file.size < minSize)
|
|
93
|
+
return [false, "FILE_TOO_SMALL"];
|
|
94
|
+
} else if (isDefined(minSize) && file.size < minSize) {
|
|
95
|
+
return [false, "FILE_TOO_SMALL"];
|
|
96
|
+
} else if (isDefined(maxSize) && file.size > maxSize) {
|
|
97
|
+
return [false, "FILE_TOO_LARGE"];
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return [true, null];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// src/is-valid-file-type.ts
|
|
104
|
+
function isFileAccepted(file, accept) {
|
|
105
|
+
if (file && accept) {
|
|
106
|
+
const types = Array.isArray(accept) ? accept : accept.split(",");
|
|
107
|
+
const fileName = file.name || "";
|
|
108
|
+
const mimeType = (file.type || "").toLowerCase();
|
|
109
|
+
const baseMimeType = mimeType.replace(/\/.*$/, "");
|
|
110
|
+
return types.some((type) => {
|
|
111
|
+
const validType = type.trim().toLowerCase();
|
|
112
|
+
if (validType.charAt(0) === ".") {
|
|
113
|
+
return fileName.toLowerCase().endsWith(validType);
|
|
114
|
+
}
|
|
115
|
+
if (validType.endsWith("/*")) {
|
|
116
|
+
return baseMimeType === validType.replace(/\/.*$/, "");
|
|
117
|
+
}
|
|
118
|
+
return mimeType === validType;
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
function isValidFileType(file, accept) {
|
|
124
|
+
const isAcceptable = file.type === "application/x-moz-file" || isFileAccepted(file, accept);
|
|
125
|
+
return [isAcceptable, isAcceptable ? null : "FILE_INVALID_TYPE"];
|
|
126
|
+
}
|
|
127
|
+
export {
|
|
128
|
+
dataURItoBlob,
|
|
129
|
+
downloadFile,
|
|
130
|
+
getAcceptAttrString,
|
|
131
|
+
getFileDataUrl,
|
|
132
|
+
getTotalFileSize,
|
|
133
|
+
isFileEqual,
|
|
134
|
+
isMSEdge,
|
|
135
|
+
isValidFileSize,
|
|
136
|
+
isValidFileType
|
|
137
|
+
};
|
|
2
138
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/data-url-to-blob.ts","../src/download-file.ts","../src/get-accept-attr.ts","../src/get-file-data-url.ts","../src/get-total-file-size.ts","../src/is-file-equal.ts","../src/is-valid-file-size.ts","../src/is-valid-file-type.ts"],"sourcesContent":["export function dataURItoBlob(uri: string): Blob {\n const binary = atob(uri.split(\",\")[1])\n\n // separate out the mime component\n const mimeString = uri.split(\",\")[0].split(\":\")[1].split(\";\")[0]\n\n // write the bytes of the string to an ArrayBuffer\n const buffer = new ArrayBuffer(binary.length)\n\n // create a view into the buffer\n const intArray = new Uint8Array(buffer)\n\n for (let i = 0; i < binary.length; i++) {\n intArray[i] = binary.charCodeAt(i)\n }\n\n return new Blob([buffer], { type: mimeString })\n}\n","export function isMSEdge(win: Window): win is Window & { navigator: { msSaveOrOpenBlob: Function } } {\n // @ts-ignore\n return Boolean(win.navigator && win.navigator.msSaveOrOpenBlob)\n}\n\ninterface DownloadFileOptions {\n /**\n * The name of the file\n */\n name?: string\n /**\n * The MIME type of the file\n */\n type?: string\n /**\n * The file contents\n */\n file: File | Blob | string\n /**\n * The window environment\n */\n win: typeof window\n}\n\nexport function downloadFile(options: DownloadFileOptions) {\n const { file, win, type, name } = options\n\n const doc = win.document\n\n const obj = typeof file === \"string\" ? new Blob([file], { type }) : file\n const fileName = typeof file === \"string\" ? name : file instanceof File ? file.name : undefined\n\n if (isMSEdge(win)) {\n win.navigator.msSaveOrOpenBlob(obj, fileName || \"file-download\")\n return\n }\n\n const url = win.URL.createObjectURL(obj)\n\n const anchor = doc.createElement(\"a\")\n anchor.style.display = \"none\"\n anchor.href = url\n anchor.rel = \"noopener\"\n anchor.download = fileName || \"file-download\"\n\n doc.documentElement.appendChild(anchor)\n anchor.click()\n\n setTimeout(() => {\n win.URL.revokeObjectURL(url)\n anchor.remove()\n }, 0)\n}\n","function isMIMEType(v: string) {\n return v === \"audio/*\" || v === \"video/*\" || v === \"image/*\" || v === \"text/*\" || /\\w+\\/[-+.\\w]+/g.test(v)\n}\n\nfunction isExt(v: string) {\n return /^.*\\.[\\w]+$/.test(v)\n}\n\nexport function getAcceptAttrString(accept: Record<string, string[]> | string | undefined) {\n if (!accept) return\n if (typeof accept === \"string\") return accept\n return Object.entries(accept)\n .reduce((a, [mimeType, ext]) => [...a, mimeType, ...ext], [] as string[])\n .filter((v) => isMIMEType(v) || isExt(v))\n .join(\",\")\n}\n","export const getFileDataUrl = async (file: File | Blob) => {\n const reader = new FileReader()\n return new Promise<string | undefined>((resolve, reject) => {\n reader.onerror = () => {\n reader.abort()\n reject(new Error(\"There was an error reading a file\"))\n }\n\n reader.onloadend = () => {\n const { result } = reader\n if (result instanceof ArrayBuffer) {\n reject(new Error(\"Expected DataURL as string from Blob/File, got ArrayBuffer\"))\n } else {\n resolve(result || undefined)\n }\n }\n\n reader.readAsDataURL(file)\n })\n}\n","export const getTotalFileSize = (files: File[]) => {\n return files.reduce((acc, file) => acc + file.size, 0)\n}\n","export const isFileEqual = (file1: File, file2: File) => {\n return file1.name === file2.name && file1.size === file2.size && file1.type === file2.type\n}\n","import type { FileError } from \"./types\"\n\nconst isDefined = <T>(v: T | undefined): v is T => v !== undefined && v !== null\n\nexport function isValidFileSize(file: File, minSize?: number, maxSize?: number): [boolean, FileError | null] {\n if (isDefined(file.size)) {\n if (isDefined(minSize) && isDefined(maxSize)) {\n if (file.size > maxSize) return [false, \"FILE_TOO_LARGE\"]\n if (file.size < minSize) return [false, \"FILE_TOO_SMALL\"]\n } else if (isDefined(minSize) && file.size < minSize) {\n return [false, \"FILE_TOO_SMALL\"]\n } else if (isDefined(maxSize) && file.size > maxSize) {\n return [false, \"FILE_TOO_LARGE\"]\n }\n }\n return [true, null]\n}\n","import type { FileError } from \"./types\"\n\nfunction isFileAccepted(file: File | null, accept: string[] | string | undefined) {\n if (file && accept) {\n const types = Array.isArray(accept) ? accept : accept.split(\",\")\n\n const fileName = file.name || \"\"\n const mimeType = (file.type || \"\").toLowerCase()\n const baseMimeType = mimeType.replace(/\\/.*$/, \"\")\n\n return types.some((type) => {\n const validType = type.trim().toLowerCase()\n\n if (validType.charAt(0) === \".\") {\n return fileName.toLowerCase().endsWith(validType)\n }\n\n if (validType.endsWith(\"/*\")) {\n return baseMimeType === validType.replace(/\\/.*$/, \"\")\n }\n\n return mimeType === validType\n })\n }\n return true\n}\n\nexport function isValidFileType(file: File, accept: string | undefined): [boolean, FileError | null] {\n const isAcceptable = file.type === \"application/x-moz-file\" || isFileAccepted(file, accept)\n return [isAcceptable, isAcceptable ? null : \"FILE_INVALID_TYPE\"]\n}\n"],"mappings":"AAAO,SAAS,cAAc,
|
|
1
|
+
{"version":3,"sources":["../src/data-url-to-blob.ts","../src/download-file.ts","../src/get-accept-attr.ts","../src/get-file-data-url.ts","../src/get-total-file-size.ts","../src/is-file-equal.ts","../src/is-valid-file-size.ts","../src/is-valid-file-type.ts"],"sourcesContent":["export function dataURItoBlob(uri: string): Blob {\n const binary = atob(uri.split(\",\")[1])\n\n // separate out the mime component\n const mimeString = uri.split(\",\")[0].split(\":\")[1].split(\";\")[0]\n\n // write the bytes of the string to an ArrayBuffer\n const buffer = new ArrayBuffer(binary.length)\n\n // create a view into the buffer\n const intArray = new Uint8Array(buffer)\n\n for (let i = 0; i < binary.length; i++) {\n intArray[i] = binary.charCodeAt(i)\n }\n\n return new Blob([buffer], { type: mimeString })\n}\n","export function isMSEdge(win: Window): win is Window & { navigator: { msSaveOrOpenBlob: Function } } {\n // @ts-ignore\n return Boolean(win.navigator && win.navigator.msSaveOrOpenBlob)\n}\n\ninterface DownloadFileOptions {\n /**\n * The name of the file\n */\n name?: string\n /**\n * The MIME type of the file\n */\n type?: string\n /**\n * The file contents\n */\n file: File | Blob | string\n /**\n * The window environment\n */\n win: typeof window\n}\n\nexport function downloadFile(options: DownloadFileOptions) {\n const { file, win, type, name } = options\n\n const doc = win.document\n\n const obj = typeof file === \"string\" ? new Blob([file], { type }) : file\n const fileName = typeof file === \"string\" ? name : file instanceof File ? file.name : undefined\n\n if (isMSEdge(win)) {\n win.navigator.msSaveOrOpenBlob(obj, fileName || \"file-download\")\n return\n }\n\n const url = win.URL.createObjectURL(obj)\n\n const anchor = doc.createElement(\"a\")\n anchor.style.display = \"none\"\n anchor.href = url\n anchor.rel = \"noopener\"\n anchor.download = fileName || \"file-download\"\n\n doc.documentElement.appendChild(anchor)\n anchor.click()\n\n setTimeout(() => {\n win.URL.revokeObjectURL(url)\n anchor.remove()\n }, 0)\n}\n","function isMIMEType(v: string) {\n return v === \"audio/*\" || v === \"video/*\" || v === \"image/*\" || v === \"text/*\" || /\\w+\\/[-+.\\w]+/g.test(v)\n}\n\nfunction isExt(v: string) {\n return /^.*\\.[\\w]+$/.test(v)\n}\n\nexport function getAcceptAttrString(accept: Record<string, string[]> | string | undefined) {\n if (!accept) return\n if (typeof accept === \"string\") return accept\n return Object.entries(accept)\n .reduce((a, [mimeType, ext]) => [...a, mimeType, ...ext], [] as string[])\n .filter((v) => isMIMEType(v) || isExt(v))\n .join(\",\")\n}\n","export const getFileDataUrl = async (file: File | Blob) => {\n const reader = new FileReader()\n return new Promise<string | undefined>((resolve, reject) => {\n reader.onerror = () => {\n reader.abort()\n reject(new Error(\"There was an error reading a file\"))\n }\n\n reader.onloadend = () => {\n const { result } = reader\n if (result instanceof ArrayBuffer) {\n reject(new Error(\"Expected DataURL as string from Blob/File, got ArrayBuffer\"))\n } else {\n resolve(result || undefined)\n }\n }\n\n reader.readAsDataURL(file)\n })\n}\n","export const getTotalFileSize = (files: File[]) => {\n return files.reduce((acc, file) => acc + file.size, 0)\n}\n","export const isFileEqual = (file1: File, file2: File) => {\n return file1.name === file2.name && file1.size === file2.size && file1.type === file2.type\n}\n","import type { FileError } from \"./types\"\n\nconst isDefined = <T>(v: T | undefined): v is T => v !== undefined && v !== null\n\nexport function isValidFileSize(file: File, minSize?: number, maxSize?: number): [boolean, FileError | null] {\n if (isDefined(file.size)) {\n if (isDefined(minSize) && isDefined(maxSize)) {\n if (file.size > maxSize) return [false, \"FILE_TOO_LARGE\"]\n if (file.size < minSize) return [false, \"FILE_TOO_SMALL\"]\n } else if (isDefined(minSize) && file.size < minSize) {\n return [false, \"FILE_TOO_SMALL\"]\n } else if (isDefined(maxSize) && file.size > maxSize) {\n return [false, \"FILE_TOO_LARGE\"]\n }\n }\n return [true, null]\n}\n","import type { FileError } from \"./types\"\n\nfunction isFileAccepted(file: File | null, accept: string[] | string | undefined) {\n if (file && accept) {\n const types = Array.isArray(accept) ? accept : accept.split(\",\")\n\n const fileName = file.name || \"\"\n const mimeType = (file.type || \"\").toLowerCase()\n const baseMimeType = mimeType.replace(/\\/.*$/, \"\")\n\n return types.some((type) => {\n const validType = type.trim().toLowerCase()\n\n if (validType.charAt(0) === \".\") {\n return fileName.toLowerCase().endsWith(validType)\n }\n\n if (validType.endsWith(\"/*\")) {\n return baseMimeType === validType.replace(/\\/.*$/, \"\")\n }\n\n return mimeType === validType\n })\n }\n return true\n}\n\nexport function isValidFileType(file: File, accept: string | undefined): [boolean, FileError | null] {\n const isAcceptable = file.type === \"application/x-moz-file\" || isFileAccepted(file, accept)\n return [isAcceptable, isAcceptable ? null : \"FILE_INV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
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/file-utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.54.0",
|
|
4
4
|
"description": "JS File API utilities",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"clean-package": "../../../clean-package.config.json",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@zag-js/i18n-utils": "0.
|
|
27
|
+
"@zag-js/i18n-utils": "0.54.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"clean-package": "2.2.0"
|