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.
@@ -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
  *
@@ -1,8 +1,21 @@
1
1
  import { Equal } from '..';
2
+ function countMap(arr) {
3
+ const map = new Map();
4
+ arr.forEach((item) => {
5
+ map.set(item, (map.get(item) || 0) + 1);
6
+ });
7
+ return map;
8
+ }
2
9
  export default function array_is_includes(arr1, arr2) {
3
10
  const smallArr = arr1.length <= arr2.length ? arr1 : arr2;
4
11
  const largeArr = arr1.length > arr2.length ? arr1 : arr2;
5
- return smallArr.every((item) => {
6
- return !!largeArr.find((i) => Equal.ValEqual(item, i));
7
- });
12
+ const smallArrMap = countMap(smallArr);
13
+ const largeArrMap = countMap(largeArr);
14
+ for (const [key, count] of smallArrMap.entries()) {
15
+ const largekey = [...largeArrMap.keys()].find((item) => Equal.ValEqual(item, key));
16
+ if (!largekey || (largekey && largeArrMap.get(largekey) !== count)) {
17
+ return false;
18
+ }
19
+ }
20
+ return true;
8
21
  }
@@ -1,8 +1,15 @@
1
- interface PDFOption {
1
+ interface RenderOption {
2
2
  pdfUrl: string;
3
3
  containerId: string;
4
4
  startPageNum?: number;
5
5
  endPageNum?: number;
6
+ pixelRatio?: number;
7
+ scale?: number;
6
8
  }
7
- export default function renderPDF({ pdfUrl, containerId, startPageNum, endPageNum }: PDFOption): Promise<void>;
8
- export {};
9
+ declare function getNumPages(pdfUrl: string): Promise<number>;
10
+ declare function render({ pdfUrl, containerId, startPageNum, endPageNum, pixelRatio, scale }: RenderOption): Promise<void>;
11
+ declare const RenderPDF: {
12
+ render: typeof render;
13
+ getNumPages: typeof getNumPages;
14
+ };
15
+ export default RenderPDF;
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { GlobalWorkerOptions, getDocument } from 'pdfjs-dist/legacy/build/pdf.js';
11
11
  GlobalWorkerOptions.workerSrc = 'https://cdn.bootcss.com/pdf.js/2.13.216/pdf.worker.js';
12
+ const PDFMap = new Map();
12
13
  function clear(containerId) {
13
14
  const container = document.getElementById(containerId);
14
15
  const pages = document.querySelectorAll(`[id^="${containerId}-page-"]`);
@@ -16,7 +17,7 @@ function clear(containerId) {
16
17
  container === null || container === void 0 ? void 0 : container.removeChild(item);
17
18
  });
18
19
  }
19
- function render(pdf, container, num) {
20
+ function renderPage({ pdf, container, num, pixelRatio = 2, scale = 1 }) {
20
21
  pdf.getPage(num).then((page) => {
21
22
  const pageDiv = document.createElement('div');
22
23
  pageDiv.setAttribute('id', `${container.id}-page-${num}`);
@@ -25,8 +26,7 @@ function render(pdf, container, num) {
25
26
  const canvas = document.createElement('canvas');
26
27
  pageDiv.appendChild(canvas);
27
28
  const ctx = canvas.getContext('2d');
28
- const scale = 1;
29
- const devicePixelRatio = window.devicePixelRatio * 2;
29
+ const devicePixelRatio = window.devicePixelRatio * pixelRatio;
30
30
  const viewport = page.getViewport({ scale: scale * devicePixelRatio });
31
31
  canvas.style.width = '100%';
32
32
  canvas.style.height = '100%';
@@ -39,22 +39,46 @@ function render(pdf, container, num) {
39
39
  page.render(renderContext);
40
40
  });
41
41
  }
42
- export default function renderPDF({ pdfUrl, containerId, startPageNum, endPageNum }) {
42
+ function getNumPages(pdfUrl) {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ let pdf = PDFMap.get(pdfUrl);
45
+ if (!pdf) {
46
+ const loadingTask = getDocument({
47
+ url: pdfUrl,
48
+ cMapUrl: 'https://unpkg.com/browse/pdfjs-dist@2.13.216/cmaps/',
49
+ cMapPacked: true
50
+ });
51
+ pdf = yield loadingTask.promise;
52
+ PDFMap.set(pdfUrl, pdf);
53
+ }
54
+ return pdf.numPages;
55
+ });
56
+ }
57
+ function render({ pdfUrl, containerId, startPageNum, endPageNum, pixelRatio, scale }) {
43
58
  return __awaiter(this, void 0, void 0, function* () {
44
59
  clear(containerId);
45
- const loadingTask = getDocument({
46
- url: pdfUrl,
47
- cMapUrl: 'https://unpkg.com/browse/pdfjs-dist@2.13.216/cmaps/',
48
- cMapPacked: true
49
- });
50
- const pdf = yield loadingTask.promise;
60
+ let pdf = PDFMap.get(pdfUrl);
61
+ if (!pdf) {
62
+ const loadingTask = getDocument({
63
+ url: pdfUrl,
64
+ cMapUrl: 'https://unpkg.com/browse/pdfjs-dist@2.13.216/cmaps/',
65
+ cMapPacked: true
66
+ });
67
+ pdf = yield loadingTask.promise;
68
+ PDFMap.set(pdfUrl, pdf);
69
+ }
51
70
  const container = document.getElementById(containerId);
52
71
  if (!container)
53
72
  return;
54
73
  const start = startPageNum !== null && startPageNum !== void 0 ? startPageNum : 1;
55
74
  const end = endPageNum !== null && endPageNum !== void 0 ? endPageNum : pdf.numPages;
56
75
  for (let i = start; i <= end; i++) {
57
- render(pdf, container, i);
76
+ renderPage({ pdf, container: container, num: i, pixelRatio, scale });
58
77
  }
59
78
  });
60
79
  }
80
+ const RenderPDF = {
81
+ render,
82
+ getNumPages
83
+ };
84
+ export default RenderPDF;
package/es/index.d.ts CHANGED
@@ -5,9 +5,9 @@ import Typeof from './Typeof';
5
5
  import get_string_width from './GetStrWidth';
6
6
  import ConvertNumbers from './ConvertNumbers';
7
7
  import loadImage from './LoadImage';
8
- import renderPDF from './RenderPDF';
8
+ import RenderPDF from './RenderPDF';
9
9
  import downloadFile from './DownloadFile';
10
10
  import array_is_includes from './ArrayIsIncludes';
11
- export { console_table, deepCopy, Equal, Typeof, get_string_width, ConvertNumbers, loadImage, renderPDF, downloadFile, array_is_includes };
11
+ export { console_table, deepCopy, Equal, Typeof, get_string_width, ConvertNumbers, loadImage, RenderPDF, downloadFile, array_is_includes };
12
12
  import { ConsoleData } from './ConsoleTable';
13
13
  export type { ConsoleData };
package/es/index.js CHANGED
@@ -5,7 +5,7 @@ import Typeof from './Typeof';
5
5
  import get_string_width from './GetStrWidth';
6
6
  import ConvertNumbers from './ConvertNumbers';
7
7
  import loadImage from './LoadImage';
8
- import renderPDF from './RenderPDF';
8
+ import RenderPDF from './RenderPDF';
9
9
  import downloadFile from './DownloadFile';
10
10
  import array_is_includes from './ArrayIsIncludes';
11
- export { console_table, deepCopy, Equal, Typeof, get_string_width, ConvertNumbers, loadImage, renderPDF, downloadFile, array_is_includes };
11
+ export { console_table, deepCopy, Equal, Typeof, get_string_width, ConvertNumbers, loadImage, RenderPDF, downloadFile, array_is_includes };
@@ -1,11 +1,76 @@
1
1
  "use strict";
2
+ var __read = (this && this.__read) || function (o, n) {
3
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
4
+ if (!m) return o;
5
+ var i = m.call(o), r, ar = [], e;
6
+ try {
7
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
+ }
9
+ catch (error) { e = { error: error }; }
10
+ finally {
11
+ try {
12
+ if (r && !r.done && (m = i["return"])) m.call(i);
13
+ }
14
+ finally { if (e) throw e.error; }
15
+ }
16
+ return ar;
17
+ };
18
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
19
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
20
+ if (ar || !(i in from)) {
21
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
22
+ ar[i] = from[i];
23
+ }
24
+ }
25
+ return to.concat(ar || Array.prototype.slice.call(from));
26
+ };
27
+ var __values = (this && this.__values) || function(o) {
28
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
29
+ if (m) return m.call(o);
30
+ if (o && typeof o.length === "number") return {
31
+ next: function () {
32
+ if (o && i >= o.length) o = void 0;
33
+ return { value: o && o[i++], done: !o };
34
+ }
35
+ };
36
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
37
+ };
2
38
  Object.defineProperty(exports, "__esModule", { value: true });
3
39
  var __1 = require("..");
40
+ function countMap(arr) {
41
+ var map = new Map();
42
+ arr.forEach(function (item) {
43
+ map.set(item, (map.get(item) || 0) + 1);
44
+ });
45
+ return map;
46
+ }
4
47
  function array_is_includes(arr1, arr2) {
48
+ var e_1, _a;
5
49
  var smallArr = arr1.length <= arr2.length ? arr1 : arr2;
6
50
  var largeArr = arr1.length > arr2.length ? arr1 : arr2;
7
- return smallArr.every(function (item) {
8
- return !!largeArr.find(function (i) { return __1.Equal.ValEqual(item, i); });
9
- });
51
+ var smallArrMap = countMap(smallArr);
52
+ var largeArrMap = countMap(largeArr);
53
+ var _loop_1 = function (key, count) {
54
+ var largekey = __spreadArray([], __read(largeArrMap.keys()), false).find(function (item) { return __1.Equal.ValEqual(item, key); });
55
+ if (!largekey || (largekey && largeArrMap.get(largekey) !== count)) {
56
+ return { value: false };
57
+ }
58
+ };
59
+ try {
60
+ for (var _b = __values(smallArrMap.entries()), _c = _b.next(); !_c.done; _c = _b.next()) {
61
+ var _d = __read(_c.value, 2), key = _d[0], count = _d[1];
62
+ var state_1 = _loop_1(key, count);
63
+ if (typeof state_1 === "object")
64
+ return state_1.value;
65
+ }
66
+ }
67
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
68
+ finally {
69
+ try {
70
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
71
+ }
72
+ finally { if (e_1) throw e_1.error; }
73
+ }
74
+ return true;
10
75
  }
11
76
  exports.default = array_is_includes;
@@ -1,4 +1,15 @@
1
1
  "use strict";
2
+ var __values = (this && this.__values) || function(o) {
3
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
4
+ if (m) return m.call(o);
5
+ if (o && typeof o.length === "number") return {
6
+ next: function () {
7
+ if (o && i >= o.length) o = void 0;
8
+ return { value: o && o[i++], done: !o };
9
+ }
10
+ };
11
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
12
+ };
2
13
  Object.defineProperty(exports, "__esModule", { value: true });
3
14
  var NODE = '+';
4
15
  var EDGE = '-';
@@ -6,10 +17,20 @@ var HIGH = '|';
6
17
  var SPACE = ' ';
7
18
  var EMPTY = '';
8
19
  function get_string_width(str) {
20
+ var e_1, _a;
9
21
  var width = 0;
10
- for (var _i = 0, str_1 = str; _i < str_1.length; _i++) {
11
- var char = str_1[_i];
12
- width += char.charCodeAt(0) < 128 && char.charCodeAt(0) >= 0 ? 1 : 2;
22
+ try {
23
+ for (var str_1 = __values(str), str_1_1 = str_1.next(); !str_1_1.done; str_1_1 = str_1.next()) {
24
+ var char = str_1_1.value;
25
+ width += char.charCodeAt(0) < 128 && char.charCodeAt(0) >= 0 ? 1 : 2;
26
+ }
27
+ }
28
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
29
+ finally {
30
+ try {
31
+ if (str_1_1 && !str_1_1.done && (_a = str_1.return)) _a.call(str_1);
32
+ }
33
+ finally { if (e_1) throw e_1.error; }
13
34
  }
14
35
  return width;
15
36
  }
@@ -65,13 +86,23 @@ function wirte_data(widths, data) {
65
86
  return content;
66
87
  }
67
88
  function get_max_widths(data) {
89
+ var e_2, _a;
68
90
  var max_widths = Object.keys(data[0]).map(function (v) { return +v; });
69
- for (var _i = 0, data_1 = data; _i < data_1.length; _i++) {
70
- var row_data = data_1[_i];
71
- row_data.forEach(function (col_data, idx) {
72
- var width = get_string_width(col_data.toString());
73
- max_widths[idx] = Math.max(width, max_widths[idx]);
74
- });
91
+ try {
92
+ for (var data_1 = __values(data), data_1_1 = data_1.next(); !data_1_1.done; data_1_1 = data_1.next()) {
93
+ var row_data = data_1_1.value;
94
+ row_data.forEach(function (col_data, idx) {
95
+ var width = get_string_width(col_data.toString());
96
+ max_widths[idx] = Math.max(width, max_widths[idx]);
97
+ });
98
+ }
99
+ }
100
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
101
+ finally {
102
+ try {
103
+ if (data_1_1 && !data_1_1.done && (_a = data_1.return)) _a.call(data_1);
104
+ }
105
+ finally { if (e_2) throw e_2.error; }
75
106
  }
76
107
  return max_widths;
77
108
  }
@@ -1,8 +1,15 @@
1
- interface PDFOption {
1
+ interface RenderOption {
2
2
  pdfUrl: string;
3
3
  containerId: string;
4
4
  startPageNum?: number;
5
5
  endPageNum?: number;
6
+ pixelRatio?: number;
7
+ scale?: number;
6
8
  }
7
- export default function renderPDF({ pdfUrl, containerId, startPageNum, endPageNum }: PDFOption): Promise<void>;
8
- export {};
9
+ declare function getNumPages(pdfUrl: string): Promise<number>;
10
+ declare function render({ pdfUrl, containerId, startPageNum, endPageNum, pixelRatio, scale }: RenderOption): Promise<void>;
11
+ declare const RenderPDF: {
12
+ render: typeof render;
13
+ getNumPages: typeof getNumPages;
14
+ };
15
+ export default RenderPDF;
@@ -38,6 +38,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  var pdf_js_1 = require("pdfjs-dist/legacy/build/pdf.js");
40
40
  pdf_js_1.GlobalWorkerOptions.workerSrc = 'https://cdn.bootcss.com/pdf.js/2.13.216/pdf.worker.js';
41
+ var PDFMap = new Map();
41
42
  function clear(containerId) {
42
43
  var container = document.getElementById(containerId);
43
44
  var pages = document.querySelectorAll("[id^=\"".concat(containerId, "-page-\"]"));
@@ -45,7 +46,8 @@ function clear(containerId) {
45
46
  container === null || container === void 0 ? void 0 : container.removeChild(item);
46
47
  });
47
48
  }
48
- function render(pdf, container, num) {
49
+ function renderPage(_a) {
50
+ 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;
49
51
  pdf.getPage(num).then(function (page) {
50
52
  var pageDiv = document.createElement('div');
51
53
  pageDiv.setAttribute('id', "".concat(container.id, "-page-").concat(num));
@@ -54,8 +56,7 @@ function render(pdf, container, num) {
54
56
  var canvas = document.createElement('canvas');
55
57
  pageDiv.appendChild(canvas);
56
58
  var ctx = canvas.getContext('2d');
57
- var scale = 1;
58
- var devicePixelRatio = window.devicePixelRatio * 2;
59
+ var devicePixelRatio = window.devicePixelRatio * pixelRatio;
59
60
  var viewport = page.getViewport({ scale: scale * devicePixelRatio });
60
61
  canvas.style.width = '100%';
61
62
  canvas.style.height = '100%';
@@ -68,14 +69,39 @@ function render(pdf, container, num) {
68
69
  page.render(renderContext);
69
70
  });
70
71
  }
71
- function renderPDF(_a) {
72
- var pdfUrl = _a.pdfUrl, containerId = _a.containerId, startPageNum = _a.startPageNum, endPageNum = _a.endPageNum;
72
+ function getNumPages(pdfUrl) {
73
73
  return __awaiter(this, void 0, void 0, function () {
74
- var loadingTask, pdf, container, start, end, i;
74
+ var pdf, loadingTask;
75
+ return __generator(this, function (_a) {
76
+ switch (_a.label) {
77
+ case 0:
78
+ pdf = PDFMap.get(pdfUrl);
79
+ if (!!pdf) return [3, 2];
80
+ loadingTask = (0, pdf_js_1.getDocument)({
81
+ url: pdfUrl,
82
+ cMapUrl: 'https://unpkg.com/browse/pdfjs-dist@2.13.216/cmaps/',
83
+ cMapPacked: true
84
+ });
85
+ return [4, loadingTask.promise];
86
+ case 1:
87
+ pdf = _a.sent();
88
+ PDFMap.set(pdfUrl, pdf);
89
+ _a.label = 2;
90
+ case 2: return [2, pdf.numPages];
91
+ }
92
+ });
93
+ });
94
+ }
95
+ function render(_a) {
96
+ var pdfUrl = _a.pdfUrl, containerId = _a.containerId, startPageNum = _a.startPageNum, endPageNum = _a.endPageNum, pixelRatio = _a.pixelRatio, scale = _a.scale;
97
+ return __awaiter(this, void 0, void 0, function () {
98
+ var pdf, loadingTask, container, start, end, i;
75
99
  return __generator(this, function (_b) {
76
100
  switch (_b.label) {
77
101
  case 0:
78
102
  clear(containerId);
103
+ pdf = PDFMap.get(pdfUrl);
104
+ if (!!pdf) return [3, 2];
79
105
  loadingTask = (0, pdf_js_1.getDocument)({
80
106
  url: pdfUrl,
81
107
  cMapUrl: 'https://unpkg.com/browse/pdfjs-dist@2.13.216/cmaps/',
@@ -84,17 +110,24 @@ function renderPDF(_a) {
84
110
  return [4, loadingTask.promise];
85
111
  case 1:
86
112
  pdf = _b.sent();
113
+ PDFMap.set(pdfUrl, pdf);
114
+ _b.label = 2;
115
+ case 2:
87
116
  container = document.getElementById(containerId);
88
117
  if (!container)
89
118
  return [2];
90
119
  start = startPageNum !== null && startPageNum !== void 0 ? startPageNum : 1;
91
120
  end = endPageNum !== null && endPageNum !== void 0 ? endPageNum : pdf.numPages;
92
121
  for (i = start; i <= end; i++) {
93
- render(pdf, container, i);
122
+ renderPage({ pdf: pdf, container: container, num: i, pixelRatio: pixelRatio, scale: scale });
94
123
  }
95
124
  return [2];
96
125
  }
97
126
  });
98
127
  });
99
128
  }
100
- exports.default = renderPDF;
129
+ var RenderPDF = {
130
+ render: render,
131
+ getNumPages: getNumPages
132
+ };
133
+ exports.default = RenderPDF;
package/lib/index.d.ts CHANGED
@@ -5,9 +5,9 @@ import Typeof from './Typeof';
5
5
  import get_string_width from './GetStrWidth';
6
6
  import ConvertNumbers from './ConvertNumbers';
7
7
  import loadImage from './LoadImage';
8
- import renderPDF from './RenderPDF';
8
+ import RenderPDF from './RenderPDF';
9
9
  import downloadFile from './DownloadFile';
10
10
  import array_is_includes from './ArrayIsIncludes';
11
- export { console_table, deepCopy, Equal, Typeof, get_string_width, ConvertNumbers, loadImage, renderPDF, downloadFile, array_is_includes };
11
+ export { console_table, deepCopy, Equal, Typeof, get_string_width, ConvertNumbers, loadImage, RenderPDF, downloadFile, array_is_includes };
12
12
  import { ConsoleData } from './ConsoleTable';
13
13
  export type { ConsoleData };
package/lib/index.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.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;
6
+ exports.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;
7
7
  var ConsoleTable_1 = __importDefault(require("./ConsoleTable"));
8
8
  exports.console_table = ConsoleTable_1.default;
9
9
  var DeepCopy_1 = __importDefault(require("./DeepCopy"));
@@ -19,7 +19,7 @@ exports.ConvertNumbers = ConvertNumbers_1.default;
19
19
  var LoadImage_1 = __importDefault(require("./LoadImage"));
20
20
  exports.loadImage = LoadImage_1.default;
21
21
  var RenderPDF_1 = __importDefault(require("./RenderPDF"));
22
- exports.renderPDF = RenderPDF_1.default;
22
+ exports.RenderPDF = RenderPDF_1.default;
23
23
  var DownloadFile_1 = __importDefault(require("./DownloadFile"));
24
24
  exports.downloadFile = DownloadFile_1.default;
25
25
  var ArrayIsIncludes_1 = __importDefault(require("./ArrayIsIncludes"));
package/package.json CHANGED
@@ -1,59 +1,59 @@
1
- {
2
- "name": "hsu-utils",
3
- "version": "0.0.17",
4
- "description": "some front-end utils",
5
- "repository": "git@github.com:VitaTsui/hsu-utils.git",
6
- "author": "VitaHsu <vitahsu7@gmail.com>",
7
- "license": "MIT",
8
- "main": "lib/index.js",
9
- "module": "es/index.js",
10
- "unpkg": "dist/hsu-utils.min.js",
11
- "files": [
12
- "es",
13
- "lib",
14
- "dist",
15
- "package.json",
16
- "README.md",
17
- "LICENSE"
18
- ],
19
- "sideEffects": [
20
- "es/*",
21
- "lib/*",
22
- "dist/*"
23
- ],
24
- "scripts": {
25
- "build": "yarn build:es && yarn build:cjs && rimraf dist && yarn build:umd",
26
- "build:es": "rimraf es && tsc -p build/tsconfig.es.json",
27
- "build:cjs": "rimraf lib && tsc -p build/tsconfig.cjs.json",
28
- "build:umd": "rimraf dist && yarn build:dev && yarn build:prod",
29
- "build:dev": "cross-env NODE_ENV=development webpack --config build/webpack.config.js",
30
- "build:prod": "cross-env NODE_ENV=production webpack --config build/webpack.config.js",
31
- "clear": "rimraf lib && rimraf es && rimraf dist",
32
- "test": "jest",
33
- "publish:patch": "yarn build && yarn publish --new-version patch",
34
- "publish:minor": "yarn build && yarn publish --new-version minor",
35
- "publish:major": "yarn build && yarn publish --new-version major",
36
- "publish:alpha": "yarn build && yarn publish --tag alpha"
37
- },
38
- "devDependencies": {
39
- "@jest/globals": "^29.5.0",
40
- "@testing-library/react-hooks": "^8.0.1",
41
- "@types/jest": "^29.5.2",
42
- "cross-env": "^7.0.3",
43
- "jest": "^29.5.0",
44
- "jest-canvas-mock": "^2.5.2",
45
- "jest-environment-jsdom": "^29.5.0",
46
- "jsdom": "^22.1.0",
47
- "rimraf": "^5.0.1",
48
- "terser-webpack-plugin": "^5.3.0",
49
- "ts-jest": "^29.1.0",
50
- "ts-loader": "^9.2.6",
51
- "ts-node": "^10.9.1",
52
- "typescript": "^5.1.3",
53
- "webpack": "^5.65.0",
54
- "webpack-cli": "^4.9.1"
55
- },
56
- "dependencies": {
57
- "pdfjs-dist": "2.13.216"
58
- }
59
- }
1
+ {
2
+ "name": "hsu-utils",
3
+ "version": "0.0.19",
4
+ "description": "some front-end utils",
5
+ "repository": "git@github.com:VitaTsui/hsu-utils.git",
6
+ "author": "VitaHsu <vitahsu7@gmail.com>",
7
+ "license": "MIT",
8
+ "main": "lib/index.js",
9
+ "module": "es/index.js",
10
+ "unpkg": "dist/hsu-utils.min.js",
11
+ "files": [
12
+ "es",
13
+ "lib",
14
+ "dist",
15
+ "package.json",
16
+ "README.md",
17
+ "LICENSE"
18
+ ],
19
+ "sideEffects": [
20
+ "es/*",
21
+ "lib/*",
22
+ "dist/*"
23
+ ],
24
+ "scripts": {
25
+ "build": "yarn build:es && yarn build:cjs && rimraf dist && yarn build:umd",
26
+ "build:es": "rimraf es && tsc -p build/tsconfig.es.json",
27
+ "build:cjs": "rimraf lib && tsc -p build/tsconfig.cjs.json",
28
+ "build:umd": "rimraf dist && yarn build:dev && yarn build:prod",
29
+ "build:dev": "cross-env NODE_ENV=development webpack --config build/webpack.config.js",
30
+ "build:prod": "cross-env NODE_ENV=production webpack --config build/webpack.config.js",
31
+ "clear": "rimraf lib && rimraf es && rimraf dist",
32
+ "test": "jest",
33
+ "publish:patch": "yarn build && yarn publish --new-version patch",
34
+ "publish:minor": "yarn build && yarn publish --new-version minor",
35
+ "publish:major": "yarn build && yarn publish --new-version major",
36
+ "publish:alpha": "yarn build && yarn publish --tag alpha"
37
+ },
38
+ "devDependencies": {
39
+ "@jest/globals": "^29.5.0",
40
+ "@testing-library/react-hooks": "^8.0.1",
41
+ "@types/jest": "^29.5.2",
42
+ "cross-env": "^7.0.3",
43
+ "jest": "^29.5.0",
44
+ "jest-canvas-mock": "^2.5.2",
45
+ "jest-environment-jsdom": "^29.5.0",
46
+ "jsdom": "^22.1.0",
47
+ "rimraf": "^5.0.1",
48
+ "terser-webpack-plugin": "^5.3.0",
49
+ "ts-jest": "^29.1.0",
50
+ "ts-loader": "^9.2.6",
51
+ "ts-node": "^10.9.1",
52
+ "typescript": "^5.1.3",
53
+ "webpack": "^5.65.0",
54
+ "webpack-cli": "^4.9.1"
55
+ },
56
+ "dependencies": {
57
+ "pdfjs-dist": "2.13.216"
58
+ }
59
+ }