@ibiz-template/core 0.0.1-beta.1 → 0.0.1-beta.17

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 (83) hide show
  1. package/dist/system/index.system.js +1 -1
  2. package/out/command/command-register.d.ts +66 -0
  3. package/out/command/command-register.d.ts.map +1 -0
  4. package/out/command/command-register.js +113 -0
  5. package/out/command/command.d.ts +54 -0
  6. package/out/command/command.d.ts.map +1 -0
  7. package/out/command/command.js +71 -0
  8. package/out/command/index.d.ts +10 -0
  9. package/out/command/index.d.ts.map +1 -0
  10. package/out/command/index.js +9 -0
  11. package/out/command/interface/command/command-option.d.ts +23 -0
  12. package/out/command/interface/command/command-option.d.ts.map +1 -0
  13. package/out/command/interface/command/command-option.js +1 -0
  14. package/out/command/interface/command/command.d.ts +74 -0
  15. package/out/command/interface/command/command.d.ts.map +1 -0
  16. package/out/command/interface/command/command.js +1 -0
  17. package/out/command/interface/disposable/disposable.d.ts +4 -0
  18. package/out/command/interface/disposable/disposable.d.ts.map +1 -0
  19. package/out/command/interface/disposable/disposable.js +1 -0
  20. package/out/command/interface/index.d.ts +4 -0
  21. package/out/command/interface/index.d.ts.map +1 -0
  22. package/out/command/interface/index.js +1 -0
  23. package/out/command/utils/index.d.ts +3 -0
  24. package/out/command/utils/index.d.ts.map +1 -0
  25. package/out/command/utils/index.js +2 -0
  26. package/out/command/utils/linked-list.d.ts +16 -0
  27. package/out/command/utils/linked-list.d.ts.map +1 -0
  28. package/out/command/utils/linked-list.js +120 -0
  29. package/out/command/utils/util.d.ts +27 -0
  30. package/out/command/utils/util.d.ts.map +1 -0
  31. package/out/command/utils/util.js +77 -0
  32. package/out/context/index.d.ts +24 -0
  33. package/out/context/index.d.ts.map +1 -1
  34. package/out/context/index.js +24 -1
  35. package/out/error/http-error/http-error.d.ts.map +1 -1
  36. package/out/error/http-error/http-error.js +0 -4
  37. package/out/ibizsys.d.ts +9 -0
  38. package/out/ibizsys.d.ts.map +1 -1
  39. package/out/ibizsys.js +9 -0
  40. package/out/index.d.ts +1 -0
  41. package/out/index.d.ts.map +1 -1
  42. package/out/index.js +1 -0
  43. package/out/interface/click-outside/click-outside.d.ts +1 -1
  44. package/out/interface/click-outside/click-outside.d.ts.map +1 -1
  45. package/out/utils/download-file/download-file.d.ts +10 -0
  46. package/out/utils/download-file/download-file.d.ts.map +1 -1
  47. package/out/utils/download-file/download-file.js +20 -0
  48. package/out/utils/index.d.ts +3 -0
  49. package/out/utils/index.d.ts.map +1 -1
  50. package/out/utils/index.js +3 -0
  51. package/out/utils/sync/count-latch.d.ts +60 -0
  52. package/out/utils/sync/count-latch.d.ts.map +1 -0
  53. package/out/utils/sync/count-latch.js +93 -0
  54. package/out/utils/sync/index.d.ts +2 -0
  55. package/out/utils/sync/index.d.ts.map +1 -0
  56. package/out/utils/sync/index.js +1 -0
  57. package/out/utils/upload/select-file.d.ts +53 -0
  58. package/out/utils/upload/select-file.d.ts.map +1 -0
  59. package/out/utils/upload/select-file.js +47 -0
  60. package/out/utils/upload/upload-file.d.ts +46 -0
  61. package/out/utils/upload/upload-file.d.ts.map +1 -0
  62. package/out/utils/upload/upload-file.js +150 -0
  63. package/package.json +3 -3
  64. package/src/command/command-register.ts +135 -0
  65. package/src/command/command.ts +79 -0
  66. package/src/command/index.ts +11 -0
  67. package/src/command/interface/command/command-option.ts +22 -0
  68. package/src/command/interface/command/command.ts +86 -0
  69. package/src/command/interface/disposable/disposable.ts +3 -0
  70. package/src/command/interface/index.ts +9 -0
  71. package/src/command/utils/index.ts +2 -0
  72. package/src/command/utils/linked-list.ts +136 -0
  73. package/src/command/utils/util.ts +95 -0
  74. package/src/context/index.ts +45 -1
  75. package/src/error/http-error/http-error.ts +0 -4
  76. package/src/ibizsys.ts +10 -0
  77. package/src/index.ts +1 -0
  78. package/src/utils/download-file/download-file.ts +21 -0
  79. package/src/utils/index.ts +3 -0
  80. package/src/utils/sync/count-latch.ts +99 -0
  81. package/src/utils/sync/index.ts +1 -0
  82. package/src/utils/upload/select-file.ts +86 -0
  83. package/src/utils/upload/upload-file.ts +206 -0
@@ -0,0 +1,120 @@
1
+ /* eslint-disable @typescript-eslint/no-non-null-assertion */
2
+ /* eslint-disable no-underscore-dangle */
3
+ /* eslint-disable max-classes-per-file */
4
+ class Node {
5
+ constructor(element) {
6
+ this.element = element;
7
+ this.next = Node.Undefined;
8
+ this.prev = Node.Undefined;
9
+ }
10
+ }
11
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
+ Node.Undefined = new Node(undefined);
13
+ export class LinkedList {
14
+ constructor() {
15
+ this._first = Node.Undefined;
16
+ this._last = Node.Undefined;
17
+ this._size = 0;
18
+ }
19
+ get size() {
20
+ return this._size;
21
+ }
22
+ isEmpty() {
23
+ return this._first === Node.Undefined;
24
+ }
25
+ clear() {
26
+ let node = this._first;
27
+ while (node !== Node.Undefined) {
28
+ const { next } = node;
29
+ node.prev = Node.Undefined;
30
+ node.next = Node.Undefined;
31
+ node = next;
32
+ }
33
+ this._first = Node.Undefined;
34
+ this._last = Node.Undefined;
35
+ this._size = 0;
36
+ }
37
+ unshift(element) {
38
+ return this._insert(element, false);
39
+ }
40
+ push(element) {
41
+ return this._insert(element, true);
42
+ }
43
+ _insert(element, atTheEnd) {
44
+ const newNode = new Node(element);
45
+ if (this._first === Node.Undefined) {
46
+ this._first = newNode;
47
+ this._last = newNode;
48
+ }
49
+ else if (atTheEnd) {
50
+ // push
51
+ const oldLast = this._last;
52
+ this._last = newNode;
53
+ newNode.prev = oldLast;
54
+ oldLast.next = newNode;
55
+ }
56
+ else {
57
+ // unshift
58
+ const oldFirst = this._first;
59
+ this._first = newNode;
60
+ newNode.next = oldFirst;
61
+ oldFirst.prev = newNode;
62
+ }
63
+ this._size += 1;
64
+ let didRemove = false;
65
+ return () => {
66
+ if (!didRemove) {
67
+ didRemove = true;
68
+ this._remove(newNode);
69
+ }
70
+ };
71
+ }
72
+ shift() {
73
+ if (this._first === Node.Undefined) {
74
+ return undefined;
75
+ }
76
+ const res = this._first.element;
77
+ this._remove(this._first);
78
+ return res;
79
+ }
80
+ pop() {
81
+ if (this._last === Node.Undefined) {
82
+ return undefined;
83
+ }
84
+ const res = this._last.element;
85
+ this._remove(this._last);
86
+ return res;
87
+ }
88
+ _remove(node) {
89
+ if (node.prev !== Node.Undefined && node.next !== Node.Undefined) {
90
+ // middle
91
+ const anchor = node.prev;
92
+ anchor.next = node.next;
93
+ node.next.prev = anchor;
94
+ }
95
+ else if (node.prev === Node.Undefined && node.next === Node.Undefined) {
96
+ // only node
97
+ this._first = Node.Undefined;
98
+ this._last = Node.Undefined;
99
+ }
100
+ else if (node.next === Node.Undefined) {
101
+ // last
102
+ this._last = this._last.prev;
103
+ this._last.next = Node.Undefined;
104
+ }
105
+ else if (node.prev === Node.Undefined) {
106
+ // first
107
+ this._first = this._first.next;
108
+ this._first.prev = Node.Undefined;
109
+ }
110
+ // done
111
+ this._size -= 1;
112
+ }
113
+ *[Symbol.iterator]() {
114
+ let node = this._first;
115
+ while (node !== Node.Undefined) {
116
+ yield node.element;
117
+ node = node.next;
118
+ }
119
+ }
120
+ }
@@ -0,0 +1,27 @@
1
+ import { IDisposable } from '../interface';
2
+ export declare function once<T extends Function>(this: unknown, fn: T): T;
3
+ export declare function toDisposable(fn: () => void): IDisposable;
4
+ /**
5
+ * 函数防抖---“立即执行版本” 和 “非立即执行版本” 的组合版本
6
+ *
7
+ * @author chitanda
8
+ * @date 2022-06-29 19:06:15
9
+ * @export
10
+ * @param {((...args: unknown[]) => void | Promise<void>)} func 处理函数
11
+ * @param {number} wait 延迟执行时间(毫秒)
12
+ * @param {boolean} [immediate] 是否立即执行
13
+ * @return {*} {(...args: unknown[]) => void}
14
+ */
15
+ export declare function debounce(func: (...args: unknown[]) => void | Promise<void>, wait: number, immediate?: boolean): (...args: unknown[]) => void;
16
+ /**
17
+ * 节流函数
18
+ *
19
+ * @author chitanda
20
+ * @date 2022-06-29 20:06:38
21
+ * @export
22
+ * @param {((...args: unknown[]) => void | Promise<void>)} fn
23
+ * @param {number} wait
24
+ * @return {*} {(...args: unknown[]) => void}
25
+ */
26
+ export declare function throttle(fn: (...args: unknown[]) => void | Promise<void>, wait: number): (...args: unknown[]) => void;
27
+ //# sourceMappingURL=util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/command/utils/util.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAG3C,wBAAgB,IAAI,CAAC,CAAC,SAAS,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,CAgBhE;AAED,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,WAAW,CAOxD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CACtB,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EAClD,IAAI,EAAE,MAAM,EACZ,SAAS,CAAC,EAAE,OAAO,GAClB,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAqB9B;AAED;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CACtB,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EAChD,IAAI,EAAE,MAAM,GACX,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAU9B"}
@@ -0,0 +1,77 @@
1
+ // eslint-disable-next-line @typescript-eslint/ban-types
2
+ export function once(fn) {
3
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
4
+ const _this = this;
5
+ let didCall = false;
6
+ let result;
7
+ return function () {
8
+ if (didCall) {
9
+ return result;
10
+ }
11
+ didCall = true;
12
+ result = fn.apply(_this, arguments);
13
+ return result;
14
+ };
15
+ }
16
+ export function toDisposable(fn) {
17
+ const self = {
18
+ dispose: once(() => {
19
+ fn();
20
+ }),
21
+ };
22
+ return self;
23
+ }
24
+ /**
25
+ * 函数防抖---“立即执行版本” 和 “非立即执行版本” 的组合版本
26
+ *
27
+ * @author chitanda
28
+ * @date 2022-06-29 19:06:15
29
+ * @export
30
+ * @param {((...args: unknown[]) => void | Promise<void>)} func 处理函数
31
+ * @param {number} wait 延迟执行时间(毫秒)
32
+ * @param {boolean} [immediate] 是否立即执行
33
+ * @return {*} {(...args: unknown[]) => void}
34
+ */
35
+ export function debounce(func, wait, immediate) {
36
+ let timer;
37
+ return function (...args) {
38
+ if (timer) {
39
+ clearTimeout(timer);
40
+ }
41
+ if (immediate) {
42
+ const callNow = !timer;
43
+ timer = setTimeout(() => {
44
+ timer = null;
45
+ }, wait);
46
+ if (callNow) {
47
+ func.apply(this, args);
48
+ }
49
+ }
50
+ else {
51
+ timer = setTimeout(() => {
52
+ func.apply(this, args);
53
+ }, wait);
54
+ }
55
+ };
56
+ }
57
+ /**
58
+ * 节流函数
59
+ *
60
+ * @author chitanda
61
+ * @date 2022-06-29 20:06:38
62
+ * @export
63
+ * @param {((...args: unknown[]) => void | Promise<void>)} fn
64
+ * @param {number} wait
65
+ * @return {*} {(...args: unknown[]) => void}
66
+ */
67
+ export function throttle(fn, wait) {
68
+ let timer = null;
69
+ return function (...args) {
70
+ if (!timer) {
71
+ timer = setTimeout(() => {
72
+ fn.apply(this, args);
73
+ timer = null;
74
+ }, wait);
75
+ }
76
+ };
77
+ }
@@ -8,7 +8,23 @@
8
8
  */
9
9
  export declare class IBizContext implements IContext {
10
10
  [key: string | symbol]: any;
11
+ /**
12
+ * 修改的父上下文
13
+ *
14
+ * @author lxm
15
+ * @date 2022-12-08 18:12:16
16
+ * @protected
17
+ * @type {IContext}
18
+ */
11
19
  protected _context: IContext;
20
+ /**
21
+ * 父的上下文源对象
22
+ *
23
+ * @author lxm
24
+ * @date 2022-12-08 18:12:31
25
+ * @type {IBizContext}
26
+ */
27
+ _parent?: IBizContext;
12
28
  /**
13
29
  * Creates an instance of IBizContext.
14
30
  *
@@ -18,5 +34,13 @@ export declare class IBizContext implements IContext {
18
34
  * @param {IBizContext} [parent]
19
35
  */
20
36
  constructor(context?: IContext, parent?: IBizContext);
37
+ /**
38
+ * 返回自身的上下文,独有的和与父有差异的。
39
+ *
40
+ * @author lxm
41
+ * @date 2022-12-08 17:12:26
42
+ * @returns {*} {IContext}
43
+ */
44
+ getOwnContext(): IContext;
21
45
  }
22
46
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/context/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,qBAAa,WAAY,YAAW,QAAQ;IAE1C,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC;IAE5B,SAAS,CAAC,QAAQ,EAAG,QAAQ,CAAC;IAE9B;;;;;;;OAOG;gBAES,OAAO,GAAE,QAAa,EAAE,MAAM,CAAC,EAAE,WAAW;CAmCzD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/context/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,qBAAa,WAAY,YAAW,QAAQ;IAE1C,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC;IAE5B;;;;;;;OAOG;IACH,SAAS,CAAC,QAAQ,EAAG,QAAQ,CAAC;IAE9B;;;;;;OAMG;IACK,OAAO,CAAC,EAAE,WAAW,CAAC;IAE9B;;;;;;;OAOG;gBAES,OAAO,GAAE,QAAa,EAAE,MAAM,CAAC,EAAE,WAAW;IA0CxD;;;;;;OAMG;IACH,aAAa,IAAI,QAAQ;CAa1B"}
@@ -20,7 +20,12 @@ export class IBizContext {
20
20
  if (parent) {
21
21
  // eslint-disable-next-line @typescript-eslint/no-this-alias
22
22
  const self = this;
23
- // 定义私有变量,用于存储父已有上下文,方便覆盖
23
+ // 定义私有变量,存放父上下文源对象
24
+ Object.defineProperty(this, '_parent', {
25
+ enumerable: false,
26
+ value: parent,
27
+ });
28
+ // 定义私有变量,用于存储对父已有上下文的修改。
24
29
  Object.defineProperty(this, '_context', {
25
30
  enumerable: false,
26
31
  value: {},
@@ -52,4 +57,22 @@ export class IBizContext {
52
57
  // 合并给入上下文
53
58
  Object.assign(this, context);
54
59
  }
60
+ /**
61
+ * 返回自身的上下文,独有的和与父有差异的。
62
+ *
63
+ * @author lxm
64
+ * @date 2022-12-08 17:12:26
65
+ * @returns {*} {IContext}
66
+ */
67
+ getOwnContext() {
68
+ const result = {};
69
+ Object.keys(this).forEach(key => {
70
+ // 父没有的,或者修改了父的上下文
71
+ if (!Object.prototype.hasOwnProperty.call(this._parent, key) ||
72
+ Object.prototype.hasOwnProperty.call(this._context, key)) {
73
+ result[key] = this[key];
74
+ }
75
+ });
76
+ return result;
77
+ }
55
78
  }
@@ -1 +1 @@
1
- {"version":3,"file":"http-error.d.ts","sourceRoot":"","sources":["../../../src/error/http-error/http-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAGlD;;;;;;;;GAQG;AACH,qBAAa,SAAU,YAAW,KAAK;IACrC,IAAI,EAAE,MAAM,CAAe;IAE3B,OAAO,EAAE,MAAM,CAAC;IAEhB,MAAM,EAAE,MAAM,CAAC;IAEf,QAAQ,CAAC,EAAE,aAAa,CAAC;gBAEb,GAAG,EAAE,UAAU;CAqB5B"}
1
+ {"version":3,"file":"http-error.d.ts","sourceRoot":"","sources":["../../../src/error/http-error/http-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAElD;;;;;;;;GAQG;AACH,qBAAa,SAAU,YAAW,KAAK;IACrC,IAAI,EAAE,MAAM,CAAe;IAE3B,OAAO,EAAE,MAAM,CAAC;IAEhB,MAAM,EAAE,MAAM,CAAC;IAEf,QAAQ,CAAC,EAAE,aAAa,CAAC;gBAEb,GAAG,EAAE,UAAU;CAkB5B"}
@@ -1,4 +1,3 @@
1
- import { HttpStatusMessageConst } from '../../constant';
2
1
  /**
3
2
  * 请求异常
4
3
  *
@@ -20,9 +19,6 @@ export class HttpError {
20
19
  else {
21
20
  this.message = res.statusText;
22
21
  }
23
- if (!this.message) {
24
- this.message = HttpStatusMessageConst[res.status];
25
- }
26
22
  if (!this.message) {
27
23
  this.message = '网络异常,请稍后重试!';
28
24
  }
package/out/ibizsys.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { CommandController } from './command';
1
2
  import { OrgData } from './interface';
2
3
  import { Logger, Net } from './utils';
3
4
  /**
@@ -31,6 +32,14 @@ export declare class IBizSys {
31
32
  * @type {Net}
32
33
  */
33
34
  net: Net;
35
+ /**
36
+ * 认证服务
37
+ *
38
+ * @author chitanda
39
+ * @date 2022-07-20 10:07:33
40
+ * @type {AuthService}
41
+ */
42
+ commands: CommandController;
34
43
  /**
35
44
  * sass 模式下的中心系统标识
36
45
  *
@@ -1 +1 @@
1
- {"version":3,"file":"ibizsys.d.ts","sourceRoot":"","sources":["../src/ibizsys.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAEtC;;;;;;;GAOG;AACH,qBAAa,OAAO;IAClB;;;;;OAKG;IACH,GAAG,qCAAe;IAElB;;;;;OAKG;IACH,GAAG,oBAAU;IAEb;;;;;;OAMG;IACH,GAAG,EAAE,GAAG,CAAa;IAErB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC;CACjB"}
1
+ {"version":3,"file":"ibizsys.d.ts","sourceRoot":"","sources":["../src/ibizsys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAEtC;;;;;;;GAOG;AACH,qBAAa,OAAO;IAClB;;;;;OAKG;IACH,GAAG,qCAAe;IAElB;;;;;OAKG;IACH,GAAG,oBAAU;IAEb;;;;;;OAMG;IACH,GAAG,EAAE,GAAG,CAAa;IAErB;;;;;;OAMG;IACH,QAAQ,EAAE,iBAAiB,CAA2B;IAEtD;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC;CACjB"}
package/out/ibizsys.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { CommandController } from './command';
1
2
  import { Environment } from './environment/environment';
2
3
  import { Logger, Net } from './utils';
3
4
  /**
@@ -32,5 +33,13 @@ export class IBizSys {
32
33
  * @type {Net}
33
34
  */
34
35
  this.net = new Net();
36
+ /**
37
+ * 认证服务
38
+ *
39
+ * @author chitanda
40
+ * @date 2022-07-20 10:07:33
41
+ * @type {AuthService}
42
+ */
43
+ this.commands = new CommandController();
35
44
  }
36
45
  }
package/out/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import './types';
2
+ export * from './command';
2
3
  export * from './constant';
3
4
  export { IBizContext } from './context';
4
5
  export { Environment } from './environment/environment';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,CAAC;AAEjB,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,CAAC;AAEjB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC"}
package/out/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import './types';
2
+ export * from './command';
2
3
  export * from './constant';
3
4
  export { IBizContext } from './context';
4
5
  export { Environment } from './environment/environment';
@@ -35,7 +35,7 @@ export interface OnClickOutsideOptions {
35
35
  /**
36
36
  * 回调处理函数类型
37
37
  */
38
- export declare type OnClickOutsideHandler = (_evt: PointerEvent | MouseEvent) => void;
38
+ export type OnClickOutsideHandler = (_evt: PointerEvent | MouseEvent) => void;
39
39
  /**
40
40
  * OnClickOutside返回对象类型
41
41
  *
@@ -1 +1 @@
1
- {"version":3,"file":"click-outside.d.ts","sourceRoot":"","sources":["../../../src/interface/click-outside/click-outside.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;IACvB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,oBAAY,qBAAqB,GAAG,CAAC,IAAI,EAAE,YAAY,GAAG,UAAU,KAAK,IAAI,CAAC;AAE9E;;;;;;;GAOG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;;OAKG;IACH,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB;;;;;OAKG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB;;;;;OAKG;IACH,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB"}
1
+ {"version":3,"file":"click-outside.d.ts","sourceRoot":"","sources":["../../../src/interface/click-outside/click-outside.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;IACvB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,IAAI,EAAE,YAAY,GAAG,UAAU,KAAK,IAAI,CAAC;AAE9E;;;;;;;GAOG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;;OAKG;IACH,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB;;;;;OAKG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB;;;;;OAKG;IACH,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB"}
@@ -8,6 +8,16 @@
8
8
  * @returns {*}
9
9
  */
10
10
  export declare function calcMimeByFileName(fileName: string): string;
11
+ /**
12
+ * 判断是否是图片格式
13
+ *
14
+ * @author lxm
15
+ * @date 2022-11-21 13:11:23
16
+ * @export
17
+ * @param {string} fileName
18
+ * @returns {*} {boolean}
19
+ */
20
+ export declare function isImage(fileName: string): boolean;
11
21
  /**
12
22
  * 纯JS触发下载文件
13
23
  *
@@ -1 +1 @@
1
- {"version":3,"file":"download-file.d.ts","sourceRoot":"","sources":["../../../src/utils/download-file/download-file.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,UAgDlD;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,QAmBhE"}
1
+ {"version":3,"file":"download-file.d.ts","sourceRoot":"","sources":["../../../src/utils/download-file/download-file.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,UAmDlD;AAED;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAOjD;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,QAmBhE"}
@@ -51,11 +51,31 @@ export function calcMimeByFileName(fileName) {
51
51
  case '.tar':
52
52
  mime = 'application/x-tar';
53
53
  break;
54
+ case '.xlsx':
55
+ mime = 'application/vnd.ms-excel';
56
+ break;
54
57
  default:
55
58
  mime = '';
56
59
  }
57
60
  return mime;
58
61
  }
62
+ /**
63
+ * 判断是否是图片格式
64
+ *
65
+ * @author lxm
66
+ * @date 2022-11-21 13:11:23
67
+ * @export
68
+ * @param {string} fileName
69
+ * @returns {*} {boolean}
70
+ */
71
+ export function isImage(fileName) {
72
+ const ext = fileName.split('.').pop();
73
+ if (!ext) {
74
+ return false;
75
+ }
76
+ const imageTypes = ['.jpeg', 'jpg', 'gif', 'png', 'bmp', 'svg'];
77
+ return imageTypes.includes(ext);
78
+ }
59
79
  /**
60
80
  * 纯JS触发下载文件
61
81
  *
@@ -10,4 +10,7 @@ export * from './event/event';
10
10
  export * from './click-outside/click-outside';
11
11
  export * from './color/color';
12
12
  export * from './download-file/download-file';
13
+ export * from './upload/select-file';
14
+ export * from './upload/upload-file';
15
+ export * from './sync';
13
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACtD,cAAc,aAAa,CAAC;AAC5B,cAAc,yBAAyB,CAAC;AACxC,cAAc,eAAe,CAAC;AAC9B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,eAAe,CAAC;AAC9B,cAAc,+BAA+B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACtD,cAAc,aAAa,CAAC;AAC5B,cAAc,yBAAyB,CAAC;AACxC,cAAc,eAAe,CAAC;AAC9B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,eAAe,CAAC;AAC9B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,QAAQ,CAAC"}
@@ -10,3 +10,6 @@ export * from './event/event';
10
10
  export * from './click-outside/click-outside';
11
11
  export * from './color/color';
12
12
  export * from './download-file/download-file';
13
+ export * from './upload/select-file';
14
+ export * from './upload/upload-file';
15
+ export * from './sync';
@@ -0,0 +1,60 @@
1
+ /**
2
+ * 计数插销工具类
3
+ *
4
+ * @author lxm
5
+ * @date 2022-11-24 19:11:49
6
+ * @export
7
+ * @class CountLatch
8
+ */
9
+ export declare class CountLatch {
10
+ private promise;
11
+ private resolve;
12
+ /**
13
+ * 计数,当前等待的异步逻辑个数
14
+ *
15
+ * @author lxm
16
+ * @date 2022-11-24 19:11:59
17
+ * @type {number}
18
+ */
19
+ count: number;
20
+ /**
21
+ * 开启promise
22
+ *
23
+ * @author lxm
24
+ * @date 2022-11-24 19:11:32
25
+ * @private
26
+ */
27
+ private startPromise;
28
+ /**
29
+ * 结束promise
30
+ *
31
+ * @author lxm
32
+ * @date 2022-11-24 19:11:44
33
+ * @private
34
+ */
35
+ private endPromise;
36
+ /**
37
+ * 上锁,计数加一
38
+ * 第一次计数,开启异步
39
+ *
40
+ * @author lxm
41
+ * @date 2022-11-24 19:11:27
42
+ */
43
+ lock(): void;
44
+ /**
45
+ * 解锁,计数减一
46
+ * 归零时结束异步
47
+ *
48
+ * @author lxm
49
+ * @date 2022-11-24 19:11:47
50
+ */
51
+ unlock(): void;
52
+ /**
53
+ * 等待,计数归零异步结束
54
+ *
55
+ * @author lxm
56
+ * @date 2022-11-24 19:11:20
57
+ */
58
+ await(): Promise<void>;
59
+ }
60
+ //# sourceMappingURL=count-latch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"count-latch.d.ts","sourceRoot":"","sources":["../../../src/utils/sync/count-latch.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,OAAO,CAA8B;IAE7C,OAAO,CAAC,OAAO,CAAwC;IAEvD;;;;;;OAMG;IACH,KAAK,EAAE,MAAM,CAAK;IAElB;;;;;;OAMG;IACH,OAAO,CAAC,YAAY;IAMpB;;;;;;OAMG;IACH,OAAO,CAAC,UAAU;IAQlB;;;;;;OAMG;IACH,IAAI;IASJ;;;;;;OAMG;IACH,MAAM;IAYN;;;;;OAKG;IACG,KAAK;CAKZ"}
@@ -0,0 +1,93 @@
1
+ import { RuntimeError } from '../../error';
2
+ /**
3
+ * 计数插销工具类
4
+ *
5
+ * @author lxm
6
+ * @date 2022-11-24 19:11:49
7
+ * @export
8
+ * @class CountLatch
9
+ */
10
+ export class CountLatch {
11
+ constructor() {
12
+ this.promise = null;
13
+ this.resolve = null;
14
+ /**
15
+ * 计数,当前等待的异步逻辑个数
16
+ *
17
+ * @author lxm
18
+ * @date 2022-11-24 19:11:59
19
+ * @type {number}
20
+ */
21
+ this.count = 0;
22
+ }
23
+ /**
24
+ * 开启promise
25
+ *
26
+ * @author lxm
27
+ * @date 2022-11-24 19:11:32
28
+ * @private
29
+ */
30
+ startPromise() {
31
+ this.promise = new Promise(resolve => {
32
+ this.resolve = resolve;
33
+ });
34
+ }
35
+ /**
36
+ * 结束promise
37
+ *
38
+ * @author lxm
39
+ * @date 2022-11-24 19:11:44
40
+ * @private
41
+ */
42
+ endPromise() {
43
+ if (this.resolve) {
44
+ this.resolve();
45
+ this.resolve = null;
46
+ this.promise = null;
47
+ }
48
+ }
49
+ /**
50
+ * 上锁,计数加一
51
+ * 第一次计数,开启异步
52
+ *
53
+ * @author lxm
54
+ * @date 2022-11-24 19:11:27
55
+ */
56
+ lock() {
57
+ console.log('lock');
58
+ this.count += 1;
59
+ if (!this.promise) {
60
+ console.log('startPromise');
61
+ this.startPromise();
62
+ }
63
+ }
64
+ /**
65
+ * 解锁,计数减一
66
+ * 归零时结束异步
67
+ *
68
+ * @author lxm
69
+ * @date 2022-11-24 19:11:47
70
+ */
71
+ unlock() {
72
+ if (this.count < 1) {
73
+ throw new RuntimeError('lock和unlock次数不匹配!');
74
+ }
75
+ console.log('unlock');
76
+ this.count -= 1;
77
+ if (this.count === 0) {
78
+ debugger;
79
+ this.endPromise();
80
+ }
81
+ }
82
+ /**
83
+ * 等待,计数归零异步结束
84
+ *
85
+ * @author lxm
86
+ * @date 2022-11-24 19:11:20
87
+ */
88
+ async await() {
89
+ if (this.promise) {
90
+ await this.promise;
91
+ }
92
+ }
93
+ }
@@ -0,0 +1,2 @@
1
+ export { CountLatch } from './count-latch';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/sync/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1 @@
1
+ export { CountLatch } from './count-latch';