hsu-utils 0.0.17 → 0.0.19

Sign up to get free protection for your applications and to get access to all the features.
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2023 VitaHsu
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2023 VitaHsu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,32 +1,32 @@
1
- # [Hsu Utils](https://github.com/VitaTsui/hsu-utils#hsu-utils)
2
-
3
- ## 前言
4
-
5
- `hsu-utils` 一些前端的工具集
6
-
7
- ## 安装
8
-
9
- ```sh
10
- npm install --save hsu-utils
11
- # 或
12
- yarn add hsu-utils
13
- ```
14
-
15
- ## 功能
16
-
17
- - `console_table` 在控制台打印像 MySql 一样的表格
18
- - `deepCopy` 深拷贝
19
- - `Equal`
20
-
21
- > `ValEqual` 判断值相等,`TypeEqual` 判断类型相同,`ObjEqual` 判断对象相等
22
-
23
- - `Typeof` 获取类型或判断类型
24
-
25
- > string、number、boolean、undefined、function、symbol、bigint、object、array、null、date、formdata、set、map、regexp、arraybuffer、blob
26
-
27
- - `get_string_width` 获取字符串长度
28
- > 根据字体属性进行计算,默认 size 为 12,family 为 微软雅黑
29
- - `loadImage` 异步加载图片
30
- > 确保相同的图片只加载一次
31
- - `renderPDF` 渲染 PDF
32
- - `downloadFile` 下载文件
1
+ # [Hsu Utils](https://github.com/VitaTsui/hsu-utils#hsu-utils)
2
+
3
+ ## 前言
4
+
5
+ `hsu-utils` 一些前端的工具集
6
+
7
+ ## 安装
8
+
9
+ ```sh
10
+ npm install --save hsu-utils
11
+ # 或
12
+ yarn add hsu-utils
13
+ ```
14
+
15
+ ## 功能
16
+
17
+ - `console_table` 在控制台打印像 MySql 一样的表格
18
+ - `deepCopy` 深拷贝
19
+ - `Equal`
20
+
21
+ > `ValEqual` 判断值相等,`TypeEqual` 判断类型相同,`ObjEqual` 判断对象相等
22
+
23
+ - `Typeof` 获取类型或判断类型
24
+
25
+ > string、number、boolean、undefined、function、symbol、bigint、object、array、null、date、formdata、set、map、regexp、arraybuffer、blob
26
+
27
+ - `get_string_width` 获取字符串长度
28
+ > 根据字体属性进行计算,默认 size 为 12,family 为 微软雅黑
29
+ - `loadImage` 异步加载图片
30
+ > 确保相同的图片只加载一次
31
+ - `renderPDF` 渲染 PDF
32
+ - `downloadFile` 下载文件
package/dist/hsu-utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  *
3
- * hsu-utils v0.0.16
3
+ * hsu-utils v0.0.18
4
4
  *
5
5
  * some front-end utils
6
6
  *
@@ -62,10 +62,10 @@ eval("/**\n * @licstart The following is the entire license notice for the\n * J
62
62
  /*!****************************************!*\
63
63
  !*** ./tools/ArrayIsIncludes/index.ts ***!
64
64
  \****************************************/
65
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
65
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
66
66
 
67
67
  "use strict";
68
- eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar __1 = __webpack_require__(/*! .. */ \"./tools/index.ts\");\nfunction array_is_includes(arr1, arr2) {\n var smallArr = arr1.length <= arr2.length ? arr1 : arr2;\n var largeArr = arr1.length > arr2.length ? arr1 : arr2;\n return smallArr.every(function (item) {\n return !!largeArr.find(function (i) { return __1.Equal.ValEqual(item, i); });\n });\n}\nexports[\"default\"] = array_is_includes;\n\n\n//# sourceURL=webpack://hsu-utils/./tools/ArrayIsIncludes/index.ts?");
68
+ eval("\nvar __read = (this && this.__read) || function (o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n};\nvar __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n if (ar || !(i in from)) {\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n ar[i] = from[i];\n }\n }\n return to.concat(ar || Array.prototype.slice.call(from));\n};\nvar __values = (this && this.__values) || function(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar __1 = __webpack_require__(/*! .. */ \"./tools/index.ts\");\nfunction countMap(arr) {\n var map = new Map();\n arr.forEach(function (item) {\n map.set(item, (map.get(item) || 0) + 1);\n });\n return map;\n}\nfunction array_is_includes(arr1, arr2) {\n var e_1, _a;\n var smallArr = arr1.length <= arr2.length ? arr1 : arr2;\n var largeArr = arr1.length > arr2.length ? arr1 : arr2;\n var smallArrMap = countMap(smallArr);\n var largeArrMap = countMap(largeArr);\n var _loop_1 = function (key, count) {\n var largekey = __spreadArray([], __read(largeArrMap.keys()), false).find(function (item) { return __1.Equal.ValEqual(item, key); });\n if (!largekey || (largekey && largeArrMap.get(largekey) !== count)) {\n return { value: false };\n }\n };\n try {\n for (var _b = __values(smallArrMap.entries()), _c = _b.next(); !_c.done; _c = _b.next()) {\n var _d = __read(_c.value, 2), key = _d[0], count = _d[1];\n var state_1 = _loop_1(key, count);\n if (typeof state_1 === \"object\")\n return state_1.value;\n }\n }\n catch (e_1_1) { e_1 = { error: e_1_1 }; }\n finally {\n try {\n if (_c && !_c.done && (_a = _b.return)) _a.call(_b);\n }\n finally { if (e_1) throw e_1.error; }\n }\n return true;\n}\nexports[\"default\"] = array_is_includes;\n\n\n//# sourceURL=webpack://hsu-utils/./tools/ArrayIsIncludes/index.ts?");
69
69
 
70
70
  /***/ }),
71
71
 
@@ -73,10 +73,10 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar
73
73
  /*!*************************************!*\
74
74
  !*** ./tools/ConsoleTable/index.ts ***!
75
75
  \*************************************/
76
- /***/ ((__unused_webpack_module, exports) => {
76
+ /***/ (function(__unused_webpack_module, exports) {
77
77
 
78
78
  "use strict";
79
- eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar NODE = '+';\nvar EDGE = '-';\nvar HIGH = '|';\nvar SPACE = ' ';\nvar EMPTY = '';\nfunction get_string_width(str) {\n var width = 0;\n for (var _i = 0, str_1 = str; _i < str_1.length; _i++) {\n var char = str_1[_i];\n width += char.charCodeAt(0) < 128 && char.charCodeAt(0) >= 0 ? 1 : 2;\n }\n return width;\n}\nfunction get_egde(width) {\n var edge = '';\n for (var i = 0; i <= width; i++) {\n edge += EDGE;\n }\n return edge;\n}\nfunction get_edge(widths, no_line_break) {\n if (no_line_break === void 0) { no_line_break = false; }\n var col_num = widths.length;\n var border = '';\n widths.forEach(function (width, col) {\n border += NODE + get_egde(width + 1);\n if (col === col_num - 1) {\n border += NODE + (no_line_break ? EMPTY : '\\n');\n }\n else {\n border += EMPTY;\n }\n });\n return border;\n}\nfunction get_space(width) {\n var space = '';\n for (var i = 0; i <= width; i++) {\n space += SPACE;\n }\n return space;\n}\nfunction wirte_data(widths, data) {\n var col_num = widths.length;\n var content = '';\n widths.forEach(function (width, col) {\n var col_data = data[col];\n var _content = '';\n if (!isNaN(+col_data)) {\n _content += get_space(width - get_string_width(col_data.toString())) + col_data + SPACE;\n }\n else {\n _content += SPACE + (col_data !== null && col_data !== void 0 ? col_data : '') + get_space(width - get_string_width((col_data !== null && col_data !== void 0 ? col_data : '').toString()));\n }\n content += HIGH + _content;\n if (col === col_num - 1) {\n content += HIGH + '\\n';\n }\n else {\n content += EMPTY;\n }\n });\n return content;\n}\nfunction get_max_widths(data) {\n var max_widths = Object.keys(data[0]).map(function (v) { return +v; });\n for (var _i = 0, data_1 = data; _i < data_1.length; _i++) {\n var row_data = data_1[_i];\n row_data.forEach(function (col_data, idx) {\n var width = get_string_width(col_data.toString());\n max_widths[idx] = Math.max(width, max_widths[idx]);\n });\n }\n return max_widths;\n}\nfunction console_table(data, callBack) {\n var row_num = data.length;\n var max_widths = get_max_widths(data);\n var table = '';\n data.forEach(function (row_data, row) {\n if (row <= 1) {\n table += get_edge(max_widths);\n }\n table += wirte_data(max_widths, row_data);\n if (row === row_num - 1) {\n table += get_edge(max_widths, true);\n }\n });\n console.log(table);\n if (callBack) {\n callBack(table);\n }\n}\nexports[\"default\"] = console_table;\n\n\n//# sourceURL=webpack://hsu-utils/./tools/ConsoleTable/index.ts?");
79
+ eval("\nvar __values = (this && this.__values) || function(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar NODE = '+';\nvar EDGE = '-';\nvar HIGH = '|';\nvar SPACE = ' ';\nvar EMPTY = '';\nfunction get_string_width(str) {\n var e_1, _a;\n var width = 0;\n try {\n for (var str_1 = __values(str), str_1_1 = str_1.next(); !str_1_1.done; str_1_1 = str_1.next()) {\n var char = str_1_1.value;\n width += char.charCodeAt(0) < 128 && char.charCodeAt(0) >= 0 ? 1 : 2;\n }\n }\n catch (e_1_1) { e_1 = { error: e_1_1 }; }\n finally {\n try {\n if (str_1_1 && !str_1_1.done && (_a = str_1.return)) _a.call(str_1);\n }\n finally { if (e_1) throw e_1.error; }\n }\n return width;\n}\nfunction get_egde(width) {\n var edge = '';\n for (var i = 0; i <= width; i++) {\n edge += EDGE;\n }\n return edge;\n}\nfunction get_edge(widths, no_line_break) {\n if (no_line_break === void 0) { no_line_break = false; }\n var col_num = widths.length;\n var border = '';\n widths.forEach(function (width, col) {\n border += NODE + get_egde(width + 1);\n if (col === col_num - 1) {\n border += NODE + (no_line_break ? EMPTY : '\\n');\n }\n else {\n border += EMPTY;\n }\n });\n return border;\n}\nfunction get_space(width) {\n var space = '';\n for (var i = 0; i <= width; i++) {\n space += SPACE;\n }\n return space;\n}\nfunction wirte_data(widths, data) {\n var col_num = widths.length;\n var content = '';\n widths.forEach(function (width, col) {\n var col_data = data[col];\n var _content = '';\n if (!isNaN(+col_data)) {\n _content += get_space(width - get_string_width(col_data.toString())) + col_data + SPACE;\n }\n else {\n _content += SPACE + (col_data !== null && col_data !== void 0 ? col_data : '') + get_space(width - get_string_width((col_data !== null && col_data !== void 0 ? col_data : '').toString()));\n }\n content += HIGH + _content;\n if (col === col_num - 1) {\n content += HIGH + '\\n';\n }\n else {\n content += EMPTY;\n }\n });\n return content;\n}\nfunction get_max_widths(data) {\n var e_2, _a;\n var max_widths = Object.keys(data[0]).map(function (v) { return +v; });\n try {\n for (var data_1 = __values(data), data_1_1 = data_1.next(); !data_1_1.done; data_1_1 = data_1.next()) {\n var row_data = data_1_1.value;\n row_data.forEach(function (col_data, idx) {\n var width = get_string_width(col_data.toString());\n max_widths[idx] = Math.max(width, max_widths[idx]);\n });\n }\n }\n catch (e_2_1) { e_2 = { error: e_2_1 }; }\n finally {\n try {\n if (data_1_1 && !data_1_1.done && (_a = data_1.return)) _a.call(data_1);\n }\n finally { if (e_2) throw e_2.error; }\n }\n return max_widths;\n}\nfunction console_table(data, callBack) {\n var row_num = data.length;\n var max_widths = get_max_widths(data);\n var table = '';\n data.forEach(function (row_data, row) {\n if (row <= 1) {\n table += get_edge(max_widths);\n }\n table += wirte_data(max_widths, row_data);\n if (row === row_num - 1) {\n table += get_edge(max_widths, true);\n }\n });\n console.log(table);\n if (callBack) {\n callBack(table);\n }\n}\nexports[\"default\"] = console_table;\n\n\n//# sourceURL=webpack://hsu-utils/./tools/ConsoleTable/index.ts?");
80
80
 
81
81
  /***/ }),
82
82
 
@@ -153,7 +153,7 @@ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _argument
153
153
  /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
154
154
 
155
155
  "use strict";
156
- eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n 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;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar pdf_js_1 = __webpack_require__(/*! pdfjs-dist/legacy/build/pdf.js */ \"./node_modules/pdfjs-dist/legacy/build/pdf.js\");\npdf_js_1.GlobalWorkerOptions.workerSrc = 'https://cdn.bootcss.com/pdf.js/2.13.216/pdf.worker.js';\nfunction clear(containerId) {\n var container = document.getElementById(containerId);\n var pages = document.querySelectorAll(\"[id^=\\\"\".concat(containerId, \"-page-\\\"]\"));\n pages === null || pages === void 0 ? void 0 : pages.forEach(function (item) {\n container === null || container === void 0 ? void 0 : container.removeChild(item);\n });\n}\nfunction render(pdf, container, num) {\n pdf.getPage(num).then(function (page) {\n var pageDiv = document.createElement('div');\n pageDiv.setAttribute('id', \"\".concat(container.id, \"-page-\").concat(num));\n pageDiv.setAttribute('style', 'position: relative; ');\n container.appendChild(pageDiv);\n var canvas = document.createElement('canvas');\n pageDiv.appendChild(canvas);\n var ctx = canvas.getContext('2d');\n var scale = 1;\n var devicePixelRatio = window.devicePixelRatio * 2;\n var viewport = page.getViewport({ scale: scale * devicePixelRatio });\n canvas.style.width = '100%';\n canvas.style.height = '100%';\n canvas.width = viewport.width;\n canvas.height = viewport.height;\n var renderContext = {\n canvasContext: ctx,\n viewport: viewport\n };\n page.render(renderContext);\n });\n}\nfunction renderPDF(_a) {\n var pdfUrl = _a.pdfUrl, containerId = _a.containerId, startPageNum = _a.startPageNum, endPageNum = _a.endPageNum;\n return __awaiter(this, void 0, void 0, function () {\n var loadingTask, pdf, container, start, end, i;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n clear(containerId);\n loadingTask = (0, pdf_js_1.getDocument)({\n url: pdfUrl,\n cMapUrl: 'https://unpkg.com/browse/pdfjs-dist@2.13.216/cmaps/',\n cMapPacked: true\n });\n return [4, loadingTask.promise];\n case 1:\n pdf = _b.sent();\n container = document.getElementById(containerId);\n if (!container)\n return [2];\n start = startPageNum !== null && startPageNum !== void 0 ? startPageNum : 1;\n end = endPageNum !== null && endPageNum !== void 0 ? endPageNum : pdf.numPages;\n for (i = start; i <= end; i++) {\n render(pdf, container, i);\n }\n return [2];\n }\n });\n });\n}\nexports[\"default\"] = renderPDF;\n\n\n//# sourceURL=webpack://hsu-utils/./tools/RenderPDF/index.ts?");
156
+ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n 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;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar pdf_js_1 = __webpack_require__(/*! pdfjs-dist/legacy/build/pdf.js */ \"./node_modules/pdfjs-dist/legacy/build/pdf.js\");\npdf_js_1.GlobalWorkerOptions.workerSrc = 'https://cdn.bootcss.com/pdf.js/2.13.216/pdf.worker.js';\nvar PDFMap = new Map();\nfunction clear(containerId) {\n var container = document.getElementById(containerId);\n var pages = document.querySelectorAll(\"[id^=\\\"\".concat(containerId, \"-page-\\\"]\"));\n pages === null || pages === void 0 ? void 0 : pages.forEach(function (item) {\n container === null || container === void 0 ? void 0 : container.removeChild(item);\n });\n}\nfunction renderPage(_a) {\n var pdf = _a.pdf, container = _a.container, num = _a.num, _b = _a.pixelRatio, pixelRatio = _b === void 0 ? 2 : _b, _c = _a.scale, scale = _c === void 0 ? 1 : _c;\n pdf.getPage(num).then(function (page) {\n var pageDiv = document.createElement('div');\n pageDiv.setAttribute('id', \"\".concat(container.id, \"-page-\").concat(num));\n pageDiv.setAttribute('style', 'position: relative; ');\n container.appendChild(pageDiv);\n var canvas = document.createElement('canvas');\n pageDiv.appendChild(canvas);\n var ctx = canvas.getContext('2d');\n var devicePixelRatio = window.devicePixelRatio * pixelRatio;\n var viewport = page.getViewport({ scale: scale * devicePixelRatio });\n canvas.style.width = '100%';\n canvas.style.height = '100%';\n canvas.width = viewport.width;\n canvas.height = viewport.height;\n var renderContext = {\n canvasContext: ctx,\n viewport: viewport\n };\n page.render(renderContext);\n });\n}\nfunction getNumPages(pdfUrl) {\n return __awaiter(this, void 0, void 0, function () {\n var pdf, loadingTask;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n pdf = PDFMap.get(pdfUrl);\n if (!!pdf) return [3, 2];\n loadingTask = (0, pdf_js_1.getDocument)({\n url: pdfUrl,\n cMapUrl: 'https://unpkg.com/browse/pdfjs-dist@2.13.216/cmaps/',\n cMapPacked: true\n });\n return [4, loadingTask.promise];\n case 1:\n pdf = _a.sent();\n PDFMap.set(pdfUrl, pdf);\n _a.label = 2;\n case 2: return [2, pdf.numPages];\n }\n });\n });\n}\nfunction render(_a) {\n var pdfUrl = _a.pdfUrl, containerId = _a.containerId, startPageNum = _a.startPageNum, endPageNum = _a.endPageNum, pixelRatio = _a.pixelRatio, scale = _a.scale;\n return __awaiter(this, void 0, void 0, function () {\n var pdf, loadingTask, container, start, end, i;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n clear(containerId);\n pdf = PDFMap.get(pdfUrl);\n if (!!pdf) return [3, 2];\n loadingTask = (0, pdf_js_1.getDocument)({\n url: pdfUrl,\n cMapUrl: 'https://unpkg.com/browse/pdfjs-dist@2.13.216/cmaps/',\n cMapPacked: true\n });\n return [4, loadingTask.promise];\n case 1:\n pdf = _b.sent();\n PDFMap.set(pdfUrl, pdf);\n _b.label = 2;\n case 2:\n container = document.getElementById(containerId);\n if (!container)\n return [2];\n start = startPageNum !== null && startPageNum !== void 0 ? startPageNum : 1;\n end = endPageNum !== null && endPageNum !== void 0 ? endPageNum : pdf.numPages;\n for (i = start; i <= end; i++) {\n renderPage({ pdf: pdf, container: container, num: i, pixelRatio: pixelRatio, scale: scale });\n }\n return [2];\n }\n });\n });\n}\nvar RenderPDF = {\n render: render,\n getNumPages: getNumPages\n};\nexports[\"default\"] = RenderPDF;\n\n\n//# sourceURL=webpack://hsu-utils/./tools/RenderPDF/index.ts?");
157
157
 
158
158
  /***/ }),
159
159
 
@@ -175,7 +175,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nfunc
175
175
  /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
176
176
 
177
177
  "use strict";
178
- eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.array_is_includes = exports.downloadFile = exports.renderPDF = exports.loadImage = exports.ConvertNumbers = exports.get_string_width = exports.Typeof = exports.Equal = exports.deepCopy = exports.console_table = void 0;\nvar ConsoleTable_1 = __importDefault(__webpack_require__(/*! ./ConsoleTable */ \"./tools/ConsoleTable/index.ts\"));\nexports.console_table = ConsoleTable_1.default;\nvar DeepCopy_1 = __importDefault(__webpack_require__(/*! ./DeepCopy */ \"./tools/DeepCopy/index.ts\"));\nexports.deepCopy = DeepCopy_1.default;\nvar Equal_1 = __importDefault(__webpack_require__(/*! ./Equal */ \"./tools/Equal/index.ts\"));\nexports.Equal = Equal_1.default;\nvar Typeof_1 = __importDefault(__webpack_require__(/*! ./Typeof */ \"./tools/Typeof/index.ts\"));\nexports.Typeof = Typeof_1.default;\nvar GetStrWidth_1 = __importDefault(__webpack_require__(/*! ./GetStrWidth */ \"./tools/GetStrWidth/index.ts\"));\nexports.get_string_width = GetStrWidth_1.default;\nvar ConvertNumbers_1 = __importDefault(__webpack_require__(/*! ./ConvertNumbers */ \"./tools/ConvertNumbers/index.ts\"));\nexports.ConvertNumbers = ConvertNumbers_1.default;\nvar LoadImage_1 = __importDefault(__webpack_require__(/*! ./LoadImage */ \"./tools/LoadImage/index.ts\"));\nexports.loadImage = LoadImage_1.default;\nvar RenderPDF_1 = __importDefault(__webpack_require__(/*! ./RenderPDF */ \"./tools/RenderPDF/index.ts\"));\nexports.renderPDF = RenderPDF_1.default;\nvar DownloadFile_1 = __importDefault(__webpack_require__(/*! ./DownloadFile */ \"./tools/DownloadFile/index.ts\"));\nexports.downloadFile = DownloadFile_1.default;\nvar ArrayIsIncludes_1 = __importDefault(__webpack_require__(/*! ./ArrayIsIncludes */ \"./tools/ArrayIsIncludes/index.ts\"));\nexports.array_is_includes = ArrayIsIncludes_1.default;\n\n\n//# sourceURL=webpack://hsu-utils/./tools/index.ts?");
178
+ eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.array_is_includes = exports.downloadFile = exports.RenderPDF = exports.loadImage = exports.ConvertNumbers = exports.get_string_width = exports.Typeof = exports.Equal = exports.deepCopy = exports.console_table = void 0;\nvar ConsoleTable_1 = __importDefault(__webpack_require__(/*! ./ConsoleTable */ \"./tools/ConsoleTable/index.ts\"));\nexports.console_table = ConsoleTable_1.default;\nvar DeepCopy_1 = __importDefault(__webpack_require__(/*! ./DeepCopy */ \"./tools/DeepCopy/index.ts\"));\nexports.deepCopy = DeepCopy_1.default;\nvar Equal_1 = __importDefault(__webpack_require__(/*! ./Equal */ \"./tools/Equal/index.ts\"));\nexports.Equal = Equal_1.default;\nvar Typeof_1 = __importDefault(__webpack_require__(/*! ./Typeof */ \"./tools/Typeof/index.ts\"));\nexports.Typeof = Typeof_1.default;\nvar GetStrWidth_1 = __importDefault(__webpack_require__(/*! ./GetStrWidth */ \"./tools/GetStrWidth/index.ts\"));\nexports.get_string_width = GetStrWidth_1.default;\nvar ConvertNumbers_1 = __importDefault(__webpack_require__(/*! ./ConvertNumbers */ \"./tools/ConvertNumbers/index.ts\"));\nexports.ConvertNumbers = ConvertNumbers_1.default;\nvar LoadImage_1 = __importDefault(__webpack_require__(/*! ./LoadImage */ \"./tools/LoadImage/index.ts\"));\nexports.loadImage = LoadImage_1.default;\nvar RenderPDF_1 = __importDefault(__webpack_require__(/*! ./RenderPDF */ \"./tools/RenderPDF/index.ts\"));\nexports.RenderPDF = RenderPDF_1.default;\nvar DownloadFile_1 = __importDefault(__webpack_require__(/*! ./DownloadFile */ \"./tools/DownloadFile/index.ts\"));\nexports.downloadFile = DownloadFile_1.default;\nvar ArrayIsIncludes_1 = __importDefault(__webpack_require__(/*! ./ArrayIsIncludes */ \"./tools/ArrayIsIncludes/index.ts\"));\nexports.array_is_includes = ArrayIsIncludes_1.default;\n\n\n//# sourceURL=webpack://hsu-utils/./tools/index.ts?");
179
179
 
180
180
  /***/ }),
181
181