@etsoo/shared 1.2.52 → 1.2.55

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.
Files changed (106) hide show
  1. package/.github/workflows/main.yml +6 -5
  2. package/__tests__/ArrayUtils.ts +126 -126
  3. package/__tests__/ColorUtils.ts +24 -24
  4. package/__tests__/ContentDisposition.ts +18 -18
  5. package/__tests__/DataTypes.ts +222 -204
  6. package/__tests__/DateUtils.ts +82 -82
  7. package/__tests__/DomUtils.ts +352 -352
  8. package/__tests__/EHistory.ts +62 -62
  9. package/__tests__/ExtendUtils.ts +40 -40
  10. package/__tests__/Keyboard.ts +14 -14
  11. package/__tests__/NumberUtils.ts +37 -39
  12. package/__tests__/StorageUtils.ts +27 -27
  13. package/__tests__/Utils.ts +361 -363
  14. package/__tests__/tsconfig.json +15 -15
  15. package/lib/cjs/ActionResult.d.ts +1 -1
  16. package/lib/cjs/ActionResult.js +3 -3
  17. package/lib/cjs/ArrayUtils.d.ts +1 -1
  18. package/lib/cjs/ArrayUtils.js +4 -4
  19. package/lib/cjs/ColorUtils.d.ts +1 -1
  20. package/lib/cjs/ColorUtils.js +2 -2
  21. package/lib/cjs/DataTypes.d.ts +6 -6
  22. package/lib/cjs/DataTypes.js +50 -51
  23. package/lib/cjs/DateUtils.d.ts +1 -1
  24. package/lib/cjs/DateUtils.js +27 -28
  25. package/lib/cjs/DomUtils.d.ts +3 -3
  26. package/lib/cjs/DomUtils.js +64 -73
  27. package/lib/cjs/ExtendUtils.d.ts +1 -1
  28. package/lib/cjs/ExtendUtils.js +6 -6
  29. package/lib/cjs/IActionResult.d.ts +1 -1
  30. package/lib/cjs/NumberUtils.d.ts +1 -1
  31. package/lib/cjs/NumberUtils.js +9 -9
  32. package/lib/cjs/StorageUtils.js +2 -2
  33. package/lib/cjs/Utils.d.ts +4 -4
  34. package/lib/cjs/Utils.js +58 -62
  35. package/lib/cjs/index.d.ts +22 -22
  36. package/lib/cjs/storage/WindowStorage.d.ts +1 -1
  37. package/lib/cjs/types/ContentDisposition.d.ts +2 -2
  38. package/lib/cjs/types/ContentDisposition.js +11 -13
  39. package/lib/cjs/types/EColor.js +5 -7
  40. package/lib/cjs/types/EHistory.d.ts +3 -3
  41. package/lib/cjs/types/EHistory.js +4 -4
  42. package/lib/cjs/types/ErrorData.d.ts +1 -1
  43. package/lib/cjs/types/EventClass.js +1 -1
  44. package/lib/mjs/ActionResult.d.ts +1 -1
  45. package/lib/mjs/ActionResult.js +3 -3
  46. package/lib/mjs/ArrayUtils.d.ts +1 -1
  47. package/lib/mjs/ArrayUtils.js +5 -5
  48. package/lib/mjs/ColorUtils.d.ts +1 -1
  49. package/lib/mjs/ColorUtils.js +3 -3
  50. package/lib/mjs/DataTypes.d.ts +6 -6
  51. package/lib/mjs/DataTypes.js +50 -51
  52. package/lib/mjs/DateUtils.d.ts +1 -1
  53. package/lib/mjs/DateUtils.js +27 -28
  54. package/lib/mjs/DomUtils.d.ts +3 -3
  55. package/lib/mjs/DomUtils.js +67 -76
  56. package/lib/mjs/ExtendUtils.d.ts +1 -1
  57. package/lib/mjs/ExtendUtils.js +6 -6
  58. package/lib/mjs/IActionResult.d.ts +1 -1
  59. package/lib/mjs/NumberUtils.d.ts +1 -1
  60. package/lib/mjs/NumberUtils.js +9 -9
  61. package/lib/mjs/StorageUtils.js +4 -4
  62. package/lib/mjs/Utils.d.ts +4 -4
  63. package/lib/mjs/Utils.js +61 -65
  64. package/lib/mjs/index.d.ts +22 -22
  65. package/lib/mjs/index.js +22 -22
  66. package/lib/mjs/storage/WindowStorage.d.ts +1 -1
  67. package/lib/mjs/storage/WindowStorage.js +2 -2
  68. package/lib/mjs/types/ContentDisposition.d.ts +2 -2
  69. package/lib/mjs/types/ContentDisposition.js +12 -14
  70. package/lib/mjs/types/EColor.js +5 -7
  71. package/lib/mjs/types/EHistory.d.ts +3 -3
  72. package/lib/mjs/types/EHistory.js +5 -5
  73. package/lib/mjs/types/ErrorData.d.ts +1 -1
  74. package/lib/mjs/types/EventClass.js +1 -1
  75. package/package.json +61 -63
  76. package/src/ActionResult.ts +23 -23
  77. package/src/ArrayUtils.ts +164 -172
  78. package/src/ColorUtils.ts +80 -82
  79. package/src/DataTypes.ts +745 -754
  80. package/src/DateUtils.ts +266 -268
  81. package/src/DomUtils.ts +806 -831
  82. package/src/ExtendUtils.ts +191 -191
  83. package/src/IActionResult.ts +42 -42
  84. package/src/Keyboard.ts +258 -258
  85. package/src/NumberUtils.ts +135 -135
  86. package/src/StorageUtils.ts +117 -117
  87. package/src/Utils.ts +908 -930
  88. package/src/index.ts +22 -22
  89. package/src/node/Storage.ts +53 -53
  90. package/src/storage/IStorage.ts +62 -62
  91. package/src/storage/WindowStorage.ts +140 -140
  92. package/src/types/ContentDisposition.ts +59 -63
  93. package/src/types/DataError.ts +15 -15
  94. package/src/types/DelayedExecutorType.ts +15 -15
  95. package/src/types/EColor.ts +241 -248
  96. package/src/types/EHistory.ts +151 -151
  97. package/src/types/ErrorData.ts +11 -11
  98. package/src/types/EventClass.ts +220 -220
  99. package/src/types/FormData.ts +25 -25
  100. package/src/types/ParsedPath.ts +5 -5
  101. package/tsconfig.cjs.json +16 -16
  102. package/tsconfig.json +16 -16
  103. package/.eslintignore +0 -3
  104. package/.eslintrc.json +0 -29
  105. package/.prettierignore +0 -5
  106. package/.prettierrc +0 -6
package/lib/mjs/Utils.js CHANGED
@@ -1,24 +1,24 @@
1
- import { DataTypes } from './DataTypes';
2
- import isEqual from 'lodash.isequal';
3
- import { DateUtils } from './DateUtils';
1
+ import { DataTypes } from "./DataTypes";
2
+ import isEqual from "lodash.isequal";
3
+ import { DateUtils } from "./DateUtils";
4
4
  String.prototype.addUrlParam = function (name, value, arrayFormat) {
5
5
  return this.addUrlParams({ [name]: value }, arrayFormat);
6
6
  };
7
7
  String.prototype.addUrlParams = function (data, arrayFormat) {
8
- if (typeof data === 'string') {
8
+ if (typeof data === "string") {
9
9
  let url = this;
10
- if (url.includes('?')) {
11
- url += '&';
10
+ if (url.includes("?")) {
11
+ url += "&";
12
12
  }
13
13
  else {
14
- if (!url.endsWith('/'))
15
- url = url + '/';
16
- url += '?';
14
+ if (!url.endsWith("/"))
15
+ url = url + "/";
16
+ url += "?";
17
17
  }
18
18
  return url + data;
19
19
  }
20
20
  // Simple check
21
- if (typeof URL === 'undefined' || !this.includes('://')) {
21
+ if (typeof URL === "undefined" || !this.includes("://")) {
22
22
  const params = Object.entries(data)
23
23
  .map(([key, value]) => {
24
24
  let v;
@@ -26,21 +26,21 @@ String.prototype.addUrlParams = function (data, arrayFormat) {
26
26
  if (arrayFormat == null || arrayFormat === false) {
27
27
  return value
28
28
  .map((item) => `${key}=${encodeURIComponent(`${item}`)}`)
29
- .join('&');
29
+ .join("&");
30
30
  }
31
31
  else {
32
- v = value.join(arrayFormat ? ',' : arrayFormat);
32
+ v = value.join(arrayFormat ? "," : arrayFormat);
33
33
  }
34
34
  }
35
35
  else if (value instanceof Date) {
36
36
  v = value.toJSON();
37
37
  }
38
38
  else {
39
- v = value == null ? '' : `${value}`;
39
+ v = value == null ? "" : `${value}`;
40
40
  }
41
41
  return `${key}=${encodeURIComponent(v)}`;
42
42
  })
43
- .join('&');
43
+ .join("&");
44
44
  return this.addUrlParams(params);
45
45
  }
46
46
  else {
@@ -53,14 +53,14 @@ String.prototype.addUrlParams = function (data, arrayFormat) {
53
53
  });
54
54
  }
55
55
  else {
56
- urlObj.searchParams.append(key, value.join(arrayFormat ? ',' : arrayFormat));
56
+ urlObj.searchParams.append(key, value.join(arrayFormat ? "," : arrayFormat));
57
57
  }
58
58
  }
59
59
  else if (value instanceof Date) {
60
60
  urlObj.searchParams.append(key, value.toJSON());
61
61
  }
62
62
  else {
63
- urlObj.searchParams.append(key, `${value == null ? '' : value}`);
63
+ urlObj.searchParams.append(key, `${value == null ? "" : value}`);
64
64
  }
65
65
  });
66
66
  return urlObj.toString();
@@ -81,14 +81,13 @@ String.prototype.containJapanese = function () {
81
81
  String.prototype.format = function (...parameters) {
82
82
  let template = this;
83
83
  parameters.forEach((value, index) => {
84
- template = template.replace(new RegExp(`\\{${index}\\}`, 'g'), value);
84
+ template = template.replace(new RegExp(`\\{${index}\\}`, "g"), value);
85
85
  });
86
86
  return template;
87
87
  };
88
88
  String.prototype.formatInitial = function (upperCase = false) {
89
89
  const initial = this.charAt(0);
90
- return ((upperCase ? initial.toUpperCase() : initial.toLowerCase()) +
91
- this.slice(1));
90
+ return ((upperCase ? initial.toUpperCase() : initial.toLowerCase()) + this.slice(1));
92
91
  };
93
92
  String.prototype.hideData = function (endChar) {
94
93
  if (this.length === 0)
@@ -101,17 +100,17 @@ String.prototype.hideData = function (endChar) {
101
100
  }
102
101
  var len = this.length;
103
102
  if (len < 4)
104
- return this.substring(0, 1) + '***';
103
+ return this.substring(0, 1) + "***";
105
104
  if (len < 6)
106
- return this.substring(0, 2) + '***';
105
+ return this.substring(0, 2) + "***";
107
106
  if (len < 8)
108
- return this.substring(0, 2) + '***' + this.slice(-2);
107
+ return this.substring(0, 2) + "***" + this.slice(-2);
109
108
  if (len < 12)
110
- return this.substring(0, 3) + '***' + this.slice(-3);
111
- return this.substring(0, 4) + '***' + this.slice(-4);
109
+ return this.substring(0, 3) + "***" + this.slice(-3);
110
+ return this.substring(0, 4) + "***" + this.slice(-4);
112
111
  };
113
112
  String.prototype.hideEmail = function () {
114
- return this.hideData('@');
113
+ return this.hideData("@");
115
114
  };
116
115
  String.prototype.isDigits = function (minLength) {
117
116
  return this.length >= (minLength ?? 0) && /^\d+$/.test(this);
@@ -121,7 +120,7 @@ String.prototype.isEmail = function () {
121
120
  return re.test(this.toLowerCase());
122
121
  };
123
122
  String.prototype.removeNonLetters = function () {
124
- return this.replace(/[^a-zA-Z0-9]/g, '');
123
+ return this.replace(/[^a-zA-Z0-9]/g, "");
125
124
  };
126
125
  /**
127
126
  * Utilities
@@ -137,11 +136,11 @@ export var Utils;
137
136
  */
138
137
  function addBlankItem(options, idField, labelField, blankLabel) {
139
138
  // Avoid duplicate blank items
140
- idField ?? (idField = 'id');
141
- if (options.length === 0 || Reflect.get(options[0], idField) !== '') {
139
+ idField ?? (idField = "id");
140
+ if (options.length === 0 || Reflect.get(options[0], idField) !== "") {
142
141
  const blankItem = {
143
- [idField]: '',
144
- [typeof labelField === 'string' ? labelField : 'label']: blankLabel ?? '---'
142
+ [idField]: "",
143
+ [typeof labelField === "string" ? labelField : "label"]: blankLabel ?? "---"
145
144
  };
146
145
  options.unshift(blankItem);
147
146
  }
@@ -154,9 +153,9 @@ export var Utils;
154
153
  * @returns Number
155
154
  */
156
155
  function charsToNumber(base64Chars) {
157
- const chars = typeof Buffer === 'undefined'
156
+ const chars = typeof Buffer === "undefined"
158
157
  ? [...atob(base64Chars)].map((char) => char.charCodeAt(0))
159
- : [...Buffer.from(base64Chars, 'base64')];
158
+ : [...Buffer.from(base64Chars, "base64")];
160
159
  return chars.reduce((previousValue, currentValue, currentIndex) => {
161
160
  return previousValue + currentValue * Math.pow(128, currentIndex);
162
161
  }, 0);
@@ -194,7 +193,7 @@ export var Utils;
194
193
  return v1 === v2;
195
194
  }
196
195
  // For date, array and object
197
- if (typeof v1 === 'object')
196
+ if (typeof v1 === "object")
198
197
  return isEqual(v1, v2);
199
198
  // 1 and '1' case
200
199
  if (strict === 0)
@@ -254,7 +253,7 @@ export var Utils;
254
253
  * @param ignoreFields Ignore fields
255
254
  * @returns
256
255
  */
257
- function getDataChanges(input, initData, ignoreFields = ['id']) {
256
+ function getDataChanges(input, initData, ignoreFields = ["id"]) {
258
257
  // Changed fields
259
258
  const changes = [];
260
259
  Object.entries(input).forEach(([key, value]) => {
@@ -271,8 +270,7 @@ export var Utils;
271
270
  if (initValue != null) {
272
271
  // Date when meets string
273
272
  if (value instanceof Date) {
274
- if (value.valueOf() ===
275
- DateUtils.parse(initValue)?.valueOf()) {
273
+ if (value.valueOf() === DateUtils.parse(initValue)?.valueOf()) {
276
274
  Reflect.deleteProperty(input, key);
277
275
  return;
278
276
  }
@@ -288,7 +286,7 @@ export var Utils;
288
286
  Reflect.set(input, key, newValue);
289
287
  }
290
288
  // Remove empty property
291
- if (value == null || value === '') {
289
+ if (value == null || value === "") {
292
290
  Reflect.deleteProperty(input, key);
293
291
  }
294
292
  // Hold the key
@@ -304,7 +302,7 @@ export var Utils;
304
302
  * @returns Result
305
303
  */
306
304
  function getNestedValue(data, name) {
307
- const properties = name.split('.');
305
+ const properties = name.split(".");
308
306
  const len = properties.length;
309
307
  if (len === 1) {
310
308
  return Reflect.get(data, name);
@@ -334,7 +332,7 @@ export var Utils;
334
332
  * @returns Result
335
333
  */
336
334
  Utils.getResult = (input, ...args) => {
337
- return typeof input === 'function' ? input(...args) : input;
335
+ return typeof input === "function" ? input(...args) : input;
338
336
  };
339
337
  /**
340
338
  * Get time zone
@@ -342,8 +340,7 @@ export var Utils;
342
340
  */
343
341
  Utils.getTimeZone = () => {
344
342
  // If Intl supported
345
- if (typeof Intl === 'object' &&
346
- typeof Intl.DateTimeFormat === 'function')
343
+ if (typeof Intl === "object" && typeof Intl.DateTimeFormat === "function")
347
344
  return Intl.DateTimeFormat().resolvedOptions().timeZone;
348
345
  };
349
346
  /**
@@ -372,7 +369,7 @@ export var Utils;
372
369
  * @param items Items
373
370
  * @param joinPart Join string
374
371
  */
375
- Utils.joinItems = (items, joinPart = ', ') => items
372
+ Utils.joinItems = (items, joinPart = ", ") => items
376
373
  .reduce((items, item) => {
377
374
  if (item) {
378
375
  const newItem = item.trim();
@@ -386,13 +383,13 @@ export var Utils;
386
383
  * Merge class names
387
384
  * @param classNames Class names
388
385
  */
389
- Utils.mergeClasses = (...classNames) => Utils.joinItems(classNames, ' ');
386
+ Utils.mergeClasses = (...classNames) => Utils.joinItems(classNames, " ");
390
387
  /**
391
388
  * Create a GUID
392
389
  */
393
390
  function newGUID() {
394
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
395
- const r = (Math.random() * 16) | 0, v = c === 'x' ? r : (r & 0x3) | 0x8;
391
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
392
+ const r = (Math.random() * 16) | 0, v = c === "x" ? r : (r & 0x3) | 0x8;
396
393
  return v.toString(16);
397
394
  });
398
395
  }
@@ -409,12 +406,12 @@ export var Utils;
409
406
  codes.push(code);
410
407
  num = (num - code) / 128;
411
408
  }
412
- if (typeof Buffer === 'undefined') {
409
+ if (typeof Buffer === "undefined") {
413
410
  return btoa(String.fromCharCode(...codes));
414
411
  }
415
412
  else {
416
413
  const buffer = Buffer.from(codes);
417
- return buffer.toString('base64');
414
+ return buffer.toString("base64");
418
415
  }
419
416
  }
420
417
  Utils.numberToChars = numberToChars;
@@ -485,13 +482,12 @@ export var Utils;
485
482
  */
486
483
  function parseJsonArray(input, checkValue) {
487
484
  try {
488
- if (!input.startsWith('['))
485
+ if (!input.startsWith("["))
489
486
  input = `[${input}]`;
490
487
  const array = JSON.parse(input);
491
488
  const type = typeof checkValue;
492
489
  if (Array.isArray(array) &&
493
- (checkValue == null ||
494
- !array.some((item) => typeof item !== type))) {
490
+ (checkValue == null || !array.some((item) => typeof item !== type))) {
495
491
  return array;
496
492
  }
497
493
  }
@@ -511,10 +507,10 @@ export var Utils;
511
507
  */
512
508
  function parseString(input, defaultValue) {
513
509
  // Undefined and empty case, return default value
514
- if (input == null || input === '')
510
+ if (input == null || input === "")
515
511
  return defaultValue;
516
512
  // String
517
- if (typeof defaultValue === 'string')
513
+ if (typeof defaultValue === "string")
518
514
  return input;
519
515
  try {
520
516
  // Date
@@ -543,7 +539,7 @@ export var Utils;
543
539
  function removeEmptyValues(input) {
544
540
  Object.keys(input).forEach((key) => {
545
541
  const value = Reflect.get(input, key);
546
- if (value == null || value === '') {
542
+ if (value == null || value === "") {
547
543
  Reflect.deleteProperty(input, key);
548
544
  }
549
545
  });
@@ -564,7 +560,7 @@ export var Utils;
564
560
  * @returns Result
565
561
  */
566
562
  Utils.replaceNullOrEmpty = (input, defaultValue) => {
567
- if (input == null || input.trim() === '')
563
+ if (input == null || input.trim() === "")
568
564
  return defaultValue;
569
565
  return input;
570
566
  };
@@ -592,12 +588,12 @@ export var Utils;
592
588
  * @param firstOnly Only convert the first word to upper case
593
589
  */
594
590
  Utils.snakeNameToWord = (name, firstOnly = false) => {
595
- const items = name.split('_');
591
+ const items = name.split("_");
596
592
  if (firstOnly) {
597
593
  items[0] = items[0].formatInitial(true);
598
- return items.join(' ');
594
+ return items.join(" ");
599
595
  }
600
- return items.map((part) => part.formatInitial(true)).join(' ');
596
+ return items.map((part) => part.formatInitial(true)).join(" ");
601
597
  };
602
598
  function getSortValue(n1, n2) {
603
599
  if (n1 === n2)
@@ -616,7 +612,7 @@ export var Utils;
616
612
  * @param keepNull Keep null value or not
617
613
  */
618
614
  function setNestedValue(data, name, value, keepNull) {
619
- const properties = name.split('.');
615
+ const properties = name.split(".");
620
616
  const len = properties.length;
621
617
  if (len === 1) {
622
618
  if (value == null && keepNull !== true) {
@@ -654,15 +650,15 @@ export var Utils;
654
650
  // Two formats or mixed
655
651
  // /home/user/dir/file.txt
656
652
  // C:\\path\\dir\\file.txt
657
- const lastIndex = Math.max(path.lastIndexOf('/'), path.lastIndexOf('\\'));
658
- let root = '', dir = '', base, ext, name;
653
+ const lastIndex = Math.max(path.lastIndexOf("/"), path.lastIndexOf("\\"));
654
+ let root = "", dir = "", base, ext, name;
659
655
  if (lastIndex === -1) {
660
656
  base = path;
661
657
  }
662
658
  else {
663
659
  base = path.substring(lastIndex + 1);
664
- const index1 = path.indexOf('/');
665
- const index2 = path.indexOf('\\');
660
+ const index1 = path.indexOf("/");
661
+ const index2 = path.indexOf("\\");
666
662
  const index = index1 === -1
667
663
  ? index2
668
664
  : index2 === -1
@@ -670,13 +666,13 @@ export var Utils;
670
666
  : Math.min(index1, index2);
671
667
  root = path.substring(0, index + 1);
672
668
  dir = path.substring(0, lastIndex);
673
- if (dir === '')
669
+ if (dir === "")
674
670
  dir = root;
675
671
  }
676
- const extIndex = base.lastIndexOf('.');
672
+ const extIndex = base.lastIndexOf(".");
677
673
  if (extIndex === -1) {
678
674
  name = base;
679
- ext = '';
675
+ ext = "";
680
676
  }
681
677
  else {
682
678
  name = base.substring(0, extIndex);
@@ -1,22 +1,22 @@
1
- export * from './types/ContentDisposition';
2
- export * from './types/DataError';
3
- export * from './types/DelayedExecutorType';
4
- export * from './types/EColor';
5
- export * from './types/EHistory';
6
- export * from './types/ErrorData';
7
- export * from './types/EventClass';
8
- export * from './types/FormData';
9
- export * from './storage/IStorage';
10
- export * from './storage/WindowStorage';
11
- export * from './ActionResult';
12
- export * from './ArrayUtils';
13
- export * from './DataTypes';
14
- export * from './ColorUtils';
15
- export * from './DateUtils';
16
- export * from './DomUtils';
17
- export * from './ExtendUtils';
18
- export * from './IActionResult';
19
- export * from './Keyboard';
20
- export * from './NumberUtils';
21
- export * from './StorageUtils';
22
- export * from './Utils';
1
+ export * from "./types/ContentDisposition";
2
+ export * from "./types/DataError";
3
+ export * from "./types/DelayedExecutorType";
4
+ export * from "./types/EColor";
5
+ export * from "./types/EHistory";
6
+ export * from "./types/ErrorData";
7
+ export * from "./types/EventClass";
8
+ export * from "./types/FormData";
9
+ export * from "./storage/IStorage";
10
+ export * from "./storage/WindowStorage";
11
+ export * from "./ActionResult";
12
+ export * from "./ArrayUtils";
13
+ export * from "./DataTypes";
14
+ export * from "./ColorUtils";
15
+ export * from "./DateUtils";
16
+ export * from "./DomUtils";
17
+ export * from "./ExtendUtils";
18
+ export * from "./IActionResult";
19
+ export * from "./Keyboard";
20
+ export * from "./NumberUtils";
21
+ export * from "./StorageUtils";
22
+ export * from "./Utils";
package/lib/mjs/index.js CHANGED
@@ -1,22 +1,22 @@
1
- export * from './types/ContentDisposition';
2
- export * from './types/DataError';
3
- export * from './types/DelayedExecutorType';
4
- export * from './types/EColor';
5
- export * from './types/EHistory';
6
- export * from './types/ErrorData';
7
- export * from './types/EventClass';
8
- export * from './types/FormData';
9
- export * from './storage/IStorage';
10
- export * from './storage/WindowStorage';
11
- export * from './ActionResult';
12
- export * from './ArrayUtils';
13
- export * from './DataTypes';
14
- export * from './ColorUtils';
15
- export * from './DateUtils';
16
- export * from './DomUtils';
17
- export * from './ExtendUtils';
18
- export * from './IActionResult';
19
- export * from './Keyboard';
20
- export * from './NumberUtils';
21
- export * from './StorageUtils';
22
- export * from './Utils';
1
+ export * from "./types/ContentDisposition";
2
+ export * from "./types/DataError";
3
+ export * from "./types/DelayedExecutorType";
4
+ export * from "./types/EColor";
5
+ export * from "./types/EHistory";
6
+ export * from "./types/ErrorData";
7
+ export * from "./types/EventClass";
8
+ export * from "./types/FormData";
9
+ export * from "./storage/IStorage";
10
+ export * from "./storage/WindowStorage";
11
+ export * from "./ActionResult";
12
+ export * from "./ArrayUtils";
13
+ export * from "./DataTypes";
14
+ export * from "./ColorUtils";
15
+ export * from "./DateUtils";
16
+ export * from "./DomUtils";
17
+ export * from "./ExtendUtils";
18
+ export * from "./IActionResult";
19
+ export * from "./Keyboard";
20
+ export * from "./NumberUtils";
21
+ export * from "./StorageUtils";
22
+ export * from "./Utils";
@@ -1,4 +1,4 @@
1
- import { IStorage } from './IStorage';
1
+ import { IStorage } from "./IStorage";
2
2
  /**
3
3
  * Window storage
4
4
  * https://developer.mozilla.org/en-US/docs/Web/API/Storage
@@ -1,5 +1,5 @@
1
- import { StorageUtils } from '../StorageUtils';
2
- import { Utils } from '../Utils';
1
+ import { StorageUtils } from "../StorageUtils";
2
+ import { Utils } from "../Utils";
3
3
  /**
4
4
  * Window storage
5
5
  * https://developer.mozilla.org/en-US/docs/Web/API/Storage
@@ -6,8 +6,8 @@ export declare class ContentDisposition {
6
6
  readonly type: string;
7
7
  readonly filename: string;
8
8
  readonly name?: string | undefined;
9
- constructor(type: 'inline' | 'attachment', filename: string);
10
- constructor(type: 'form-data', filename: string, name: string);
9
+ constructor(type: "inline" | "attachment", filename: string);
10
+ constructor(type: "form-data", filename: string, name: string);
11
11
  /**
12
12
  * Format to standard output
13
13
  * @returns Result
@@ -1,4 +1,4 @@
1
- import { Utils } from '../Utils';
1
+ import { Utils } from "../Utils";
2
2
  /**
3
3
  * Content disposition of HTTP
4
4
  * https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition
@@ -17,11 +17,11 @@ export class ContentDisposition {
17
17
  const items = [this.type];
18
18
  if (this.name)
19
19
  items.push(`name="${this.name}"`);
20
- const filename1 = this.filename.replace(/[^a-zA-Z0-9\.-]/g, '_');
20
+ const filename1 = this.filename.replace(/[^a-zA-Z0-9\.-]/g, "_");
21
21
  items.push(`filename="${filename1}"`);
22
22
  if (filename1 != this.filename)
23
23
  items.push(`filename*="UTF-8''${encodeURIComponent(this.filename)}"`);
24
- return items.join('; ');
24
+ return items.join("; ");
25
25
  }
26
26
  /**
27
27
  * Parse header value
@@ -37,7 +37,7 @@ export class ContentDisposition {
37
37
  return undefined;
38
38
  const type = parts[0];
39
39
  let name;
40
- let filename = '';
40
+ let filename = "";
41
41
  for (let i = 1; i < len; i++) {
42
42
  const part = parts[i];
43
43
  let [field, value] = part.split(/\s*=\s*/g);
@@ -45,25 +45,23 @@ export class ContentDisposition {
45
45
  field = field.toLowerCase();
46
46
  // Remove quotes
47
47
  value = Utils.trim(value, '"');
48
- if (field === 'name') {
48
+ if (field === "name") {
49
49
  name = value;
50
50
  }
51
- else if (field === 'filename') {
52
- if (filename === '')
51
+ else if (field === "filename") {
52
+ if (filename === "")
53
53
  filename = value;
54
54
  }
55
- else if (field === 'filename*') {
55
+ else if (field === "filename*") {
56
56
  const pos = value.indexOf("''");
57
57
  filename =
58
- pos == -1
59
- ? value
60
- : decodeURIComponent(value.substring(pos + 2));
58
+ pos == -1 ? value : decodeURIComponent(value.substring(pos + 2));
61
59
  }
62
60
  }
63
- if (type === 'form-data') {
64
- return new ContentDisposition(type, filename, name ?? 'file');
61
+ if (type === "form-data") {
62
+ return new ContentDisposition(type, filename, name ?? "file");
65
63
  }
66
- if (type === 'inline' || type === 'attachment') {
64
+ if (type === "inline" || type === "attachment") {
67
65
  return new ContentDisposition(type, filename);
68
66
  }
69
67
  return undefined;
@@ -48,7 +48,7 @@ export class EColor {
48
48
  * @returns Result
49
49
  */
50
50
  static toHex(num) {
51
- return num.toString(16).padStart(2, '0');
51
+ return num.toString(16).padStart(2, "0");
52
52
  }
53
53
  /**
54
54
  * Parse HTML color to EColor
@@ -61,12 +61,12 @@ export class EColor {
61
61
  return undefined;
62
62
  htmlColor = htmlColor.trim().toUpperCase();
63
63
  // HEX color
64
- if (htmlColor.startsWith('#')) {
64
+ if (htmlColor.startsWith("#")) {
65
65
  htmlColor = htmlColor.substring(1);
66
66
  if (htmlColor.length === 3)
67
67
  htmlColor = Array.from(htmlColor)
68
68
  .map((c) => c + c)
69
- .join('');
69
+ .join("");
70
70
  if (htmlColor.length === 6) {
71
71
  return new EColor(EColor.hexTo(htmlColor.substring(0, 2)), EColor.hexTo(htmlColor.substring(2, 4)), EColor.hexTo(htmlColor.substring(4, 6)));
72
72
  }
@@ -165,9 +165,7 @@ export class EColor {
165
165
  getLuminance() {
166
166
  const a = [this.r, this.g, this.b].map((v) => {
167
167
  v /= 255;
168
- return v <= 0.03928
169
- ? v / 12.92
170
- : Math.pow((v + 0.055) / 1.055, 2.4);
168
+ return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4);
171
169
  });
172
170
  return a[0] * 0.2126 + a[1] * 0.7152 + a[2] * 0.0722;
173
171
  }
@@ -203,7 +201,7 @@ export class EColor {
203
201
  toRGBColor(alpha) {
204
202
  // Decide
205
203
  let includeAlpha, alphaValue = this.alpha;
206
- if (typeof alpha === 'number') {
204
+ if (typeof alpha === "number") {
207
205
  alphaValue = alpha;
208
206
  includeAlpha = true;
209
207
  }
@@ -1,4 +1,4 @@
1
- import { EventBase, EventClass } from './EventClass';
1
+ import { EventBase, EventClass } from "./EventClass";
2
2
  interface EHistoryEventData {
3
3
  /**
4
4
  * Current index
@@ -17,7 +17,7 @@ type EHistoryEventDef = {
17
17
  push: EHistoryEventData;
18
18
  replace: EHistoryEventData;
19
19
  };
20
- type EHistoryEventType = Exclude<keyof EHistoryEventDef, 'navigate'>;
20
+ type EHistoryEventType = Exclude<keyof EHistoryEventDef, "navigate">;
21
21
  /**
22
22
  * ETSOO Extended history event
23
23
  */
@@ -26,7 +26,7 @@ export declare class EHistoryEvent extends EventBase<EHistoryEventType, EHistory
26
26
  /**
27
27
  * ETSOO Extended history navigate event
28
28
  */
29
- export declare class EHistoryNavigateEvent extends EventBase<'navigate', EHistoryNavigateEventData> {
29
+ export declare class EHistoryNavigateEvent extends EventBase<"navigate", EHistoryNavigateEventData> {
30
30
  constructor(target: {}, data: EHistoryNavigateEventData);
31
31
  }
32
32
  /**
@@ -1,4 +1,4 @@
1
- import { EventBase, EventClass } from './EventClass';
1
+ import { EventBase, EventClass } from "./EventClass";
2
2
  /**
3
3
  * ETSOO Extended history event
4
4
  */
@@ -9,7 +9,7 @@ export class EHistoryEvent extends EventBase {
9
9
  */
10
10
  export class EHistoryNavigateEvent extends EventBase {
11
11
  constructor(target, data) {
12
- super(target, 'navigate', data);
12
+ super(target, "navigate", data);
13
13
  }
14
14
  }
15
15
  /**
@@ -63,7 +63,7 @@ export class EHistory extends EventClass {
63
63
  // https://stackoverflow.com/questions/1232040/how-do-i-empty-an-array-in-javascript
64
64
  this.states.length = 0;
65
65
  this._index = -1;
66
- this.trigger(this.createEvent('clear', this._index));
66
+ this.trigger(this.createEvent("clear", this._index));
67
67
  }
68
68
  /**
69
69
  * Create event
@@ -126,7 +126,7 @@ export class EHistory extends EventClass {
126
126
  if (this.length > this.maxDepth) {
127
127
  this.states.shift();
128
128
  }
129
- this.trigger(this.createEvent('push', this._index));
129
+ this.trigger(this.createEvent("push", this._index));
130
130
  }
131
131
  /**
132
132
  * Modifies the current history entry
@@ -136,6 +136,6 @@ export class EHistory extends EventClass {
136
136
  if (this._index === -1)
137
137
  return;
138
138
  this.states[this._index] = state;
139
- this.trigger(this.createEvent('replace', this._index));
139
+ this.trigger(this.createEvent("replace", this._index));
140
140
  }
141
141
  }