halo-fe 1.0.16 → 1.0.17

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,20 +1,24 @@
1
1
  import ICdn from "./ICdn";
2
+ import { ITask } from "../tasks";
2
3
  /**
3
4
  * CDN抽象基类
4
5
  */
5
6
  declare abstract class Cdn implements ICdn {
6
7
  abstract type: string;
7
- abstract open(conn: string): Promise<void>;
8
+ /**
9
+ * 任务实例,用于控制并发
10
+ */
11
+ task: ITask;
12
+ open(conn: string): Promise<void>;
8
13
  abstract getCrypto(): Promise<any>;
9
14
  abstract getECharts(): Promise<any>;
10
15
  abstract getElementPlus(): Promise<any>;
11
16
  abstract getFortAwesome(): Promise<any>;
12
- abstract getMonacoPath(): string;
13
- abstract getMonaco(): Promise<any>;
14
- abstract getQuill(): Promise<any>;
17
+ getMonaco(baseUrl?: string): Promise<any>;
18
+ getQuill(basePath?: string): Promise<any>;
15
19
  abstract getWeiXin(): Promise<any>;
16
20
  abstract getXlsx(): Promise<any>;
17
- loadFilesAsync(path: string, files: string[]): Promise<void>;
21
+ loadFilesAsync(path: string, files: string[], handler?: () => void): Promise<void>;
18
22
  loadAsync(path: string | string[]): Promise<HTMLElement[]>;
19
23
  /**
20
24
  * 异步加载脚本/样式内容,把内容处理为行内html
@@ -24,6 +28,6 @@ declare abstract class Cdn implements ICdn {
24
28
  /**
25
29
  * 通过注入DOM标签异步加载脚本或样式表,已防重
26
30
  */
27
- loadResourceAsync: (url: string | string[]) => Promise<HTMLElement[]>;
31
+ loadResourceAsync: (url: string | string[], handler?: () => void) => Promise<HTMLElement[]>;
28
32
  }
29
33
  export default Cdn;
@@ -31,10 +31,6 @@ interface ICdn extends IDriver {
31
31
  * 加载Monaco编辑器
32
32
  */
33
33
  getMonaco(): Promise<any>;
34
- /**
35
- * 获取Monaco编辑器路径
36
- */
37
- getMonacoPath(): string;
38
34
  /**
39
35
  * 获取编辑器
40
36
  */
@@ -6,13 +6,11 @@ import Cdn from "../Cdn";
6
6
  */
7
7
  declare class LocalCdn extends Cdn {
8
8
  type: string;
9
- open(conn: string): Promise<void>;
10
9
  getCrypto(): Promise<any>;
11
10
  getECharts(): Promise<any>;
12
11
  getElementPlus(): Promise<any>;
13
12
  getFortAwesome(): Promise<any>;
14
13
  getMonaco(): Promise<any>;
15
- getMonacoPath(): string;
16
14
  getQuill(): Promise<any>;
17
15
  getWeiXin(): Promise<any>;
18
16
  getXlsx(): Promise<any>;
@@ -1,5 +1,4 @@
1
1
  import Cdn from "../Cdn";
2
- import { ITask } from "../../tasks";
3
2
  /**
4
3
  * 三方资源包
5
4
  * https://unpkg.com
@@ -16,18 +15,12 @@ import { ITask } from "../../tasks";
16
15
  */
17
16
  declare class ThirdCdn extends Cdn {
18
17
  type: string;
19
- /**
20
- * 任务实例,用于控制并发
21
- */
22
- task: ITask;
23
18
  staticFileCdn: string;
24
19
  jdCdn: string;
25
- open(conn: string): Promise<void>;
26
20
  getCrypto(): Promise<any>;
27
21
  getECharts(): Promise<any>;
28
22
  getElementPlus(): Promise<any>;
29
23
  getFortAwesome(): Promise<any>;
30
- getMonacoPath(): string;
31
24
  getMonaco(): Promise<any>;
32
25
  getQuill(): Promise<any>;
33
26
  getWeiXin(): Promise<any>;
@@ -3,6 +3,7 @@ import { IDriver, IDispose } from "../types";
3
3
  * 任务接口
4
4
  */
5
5
  interface ITask extends IDriver, IDispose {
6
+ taskLimit: number;
6
7
  /**
7
8
  * 多线程执行任务,会在主线程空闲时按顺序执行
8
9
  */
@@ -13,9 +14,11 @@ interface ITask extends IDriver, IDispose {
13
14
  executeFrequency<T>(entities: T[], frequency: number, threads: number, handler: (chunk: T[], index: number) => Promise<void>): Promise<void>;
14
15
  /**
15
16
  * 按照并发数量控制多个任务执行
17
+ * handler不能直接放置promise,因为promise被传递前的实例化过程就会执行内部方法
18
+ * 场景:通过并发数为1,来控制不通类库,在并发加载时,define函数冲突问题
16
19
  * 注意:是相同时间的并发数控制,不是1s内的并发数控制
17
20
  */
18
- concurrent<T>(handler: Promise<T>, limit: number): Promise<T>;
21
+ concurrent<T>(handler: () => Promise<T>): Promise<T>;
19
22
  /**
20
23
  * 每间隔指定时间执行指定任务
21
24
  */
@@ -4,9 +4,10 @@ import ITask from "./ITask";
4
4
  */
5
5
  declare abstract class Task implements ITask {
6
6
  type: string;
7
+ taskLimit: number;
7
8
  abstract execute<T>(entities: T[], threads: number, handler: (chunk: T[], index: number) => Promise<void>): Promise<void>;
8
9
  abstract executeFrequency<T>(entities: T[], frequency: number, threads: number, handler: (chunk: T[], index: number) => Promise<void>): Promise<void>;
9
- abstract concurrent<T>(handler: Promise<T>, total: number): Promise<T>;
10
+ abstract concurrent<T>(handler: () => Promise<T>): Promise<T>;
10
11
  abstract interval(ms: number, task: () => void): void;
11
12
  abstract dispose(): void;
12
13
  }
@@ -10,14 +10,14 @@ declare class MemoryTask extends Task {
10
10
  /**
11
11
  * 待执行的任务队列
12
12
  */
13
- tasks: Promise<any>[];
13
+ tasks: (() => Promise<any>)[];
14
14
  taskLimit: number;
15
15
  taskExecuting: number;
16
16
  taskResolves: ((value: any) => void)[];
17
17
  /**
18
18
  * 相同时间的并发数控制,不是1s内的并发数控制
19
19
  */
20
- concurrent<T>(handler: Promise<T>, limit: number): Promise<T>;
20
+ concurrent<T>(handler: () => Promise<T>): Promise<T>;
21
21
  /**
22
22
  * 按照并发执行
23
23
  */
@@ -1,5 +1,4 @@
1
- import loader from "@monaco-editor/loader";
2
1
  import type * as Monaco from 'monaco-editor/esm/vs/editor/editor.api';
3
2
  import moment from "moment";
4
3
  import Ref from "./Ref";
5
- export { loader, Monaco, moment, Ref };
4
+ export { Monaco, moment, Ref };
@@ -19,6 +19,6 @@ declare class CreateFeOptions {
19
19
  /**
20
20
  * CDN类型
21
21
  */
22
- cdn: string;
22
+ cdn: 'Local' | "Third";
23
23
  }
24
24
  export default CreateFeOptions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "halo-fe",
3
- "version": "1.0.16",
3
+ "version": "1.0.17",
4
4
  "description": "Halo front end sdk",
5
5
  "scripts": {
6
6
  "halo-fe:tsc": "vue-tsc",
@@ -33,7 +33,6 @@
33
33
  "vue-i18n": "9.13.1"
34
34
  },
35
35
  "dependencies": {
36
- "@monaco-editor/loader": "1.4.0",
37
36
  "clone": "2.1.2",
38
37
  "file-saver": "2.0.5",
39
38
  "liquidjs": "10.16.1",
@@ -1,258 +0,0 @@
1
- import { i as w } from "./state-local-CEworIRt.js";
2
- function O(n, e, r) {
3
- return e in n ? Object.defineProperty(n, e, {
4
- value: r,
5
- enumerable: !0,
6
- configurable: !0,
7
- writable: !0
8
- }) : n[e] = r, n;
9
- }
10
- function d(n, e) {
11
- var r = Object.keys(n);
12
- if (Object.getOwnPropertySymbols) {
13
- var t = Object.getOwnPropertySymbols(n);
14
- e && (t = t.filter(function(o) {
15
- return Object.getOwnPropertyDescriptor(n, o).enumerable;
16
- })), r.push.apply(r, t);
17
- }
18
- return r;
19
- }
20
- function m(n) {
21
- for (var e = 1; e < arguments.length; e++) {
22
- var r = arguments[e] != null ? arguments[e] : {};
23
- e % 2 ? d(Object(r), !0).forEach(function(t) {
24
- O(n, t, r[t]);
25
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(n, Object.getOwnPropertyDescriptors(r)) : d(Object(r)).forEach(function(t) {
26
- Object.defineProperty(n, t, Object.getOwnPropertyDescriptor(r, t));
27
- });
28
- }
29
- return n;
30
- }
31
- function I(n, e) {
32
- if (n == null) return {};
33
- var r = {}, t = Object.keys(n), o, i;
34
- for (i = 0; i < t.length; i++)
35
- o = t[i], !(e.indexOf(o) >= 0) && (r[o] = n[o]);
36
- return r;
37
- }
38
- function S(n, e) {
39
- if (n == null) return {};
40
- var r = I(n, e), t, o;
41
- if (Object.getOwnPropertySymbols) {
42
- var i = Object.getOwnPropertySymbols(n);
43
- for (o = 0; o < i.length; o++)
44
- t = i[o], !(e.indexOf(t) >= 0) && Object.prototype.propertyIsEnumerable.call(n, t) && (r[t] = n[t]);
45
- }
46
- return r;
47
- }
48
- function P(n, e) {
49
- return A(n) || E(n, e) || T(n, e) || C();
50
- }
51
- function A(n) {
52
- if (Array.isArray(n)) return n;
53
- }
54
- function E(n, e) {
55
- if (!(typeof Symbol > "u" || !(Symbol.iterator in Object(n)))) {
56
- var r = [], t = !0, o = !1, i = void 0;
57
- try {
58
- for (var a = n[Symbol.iterator](), u; !(t = (u = a.next()).done) && (r.push(u.value), !(e && r.length === e)); t = !0)
59
- ;
60
- } catch (c) {
61
- o = !0, i = c;
62
- } finally {
63
- try {
64
- !t && a.return != null && a.return();
65
- } finally {
66
- if (o) throw i;
67
- }
68
- }
69
- return r;
70
- }
71
- }
72
- function T(n, e) {
73
- if (n) {
74
- if (typeof n == "string") return v(n, e);
75
- var r = Object.prototype.toString.call(n).slice(8, -1);
76
- if (r === "Object" && n.constructor && (r = n.constructor.name), r === "Map" || r === "Set") return Array.from(n);
77
- if (r === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)) return v(n, e);
78
- }
79
- }
80
- function v(n, e) {
81
- (e == null || e > n.length) && (e = n.length);
82
- for (var r = 0, t = new Array(e); r < e; r++) t[r] = n[r];
83
- return t;
84
- }
85
- function C() {
86
- throw new TypeError(`Invalid attempt to destructure non-iterable instance.
87
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
88
- }
89
- var z = {
90
- paths: {
91
- vs: "https://cdn.jsdelivr.net/npm/monaco-editor@0.43.0/min/vs"
92
- }
93
- };
94
- function D(n) {
95
- return function e() {
96
- for (var r = this, t = arguments.length, o = new Array(t), i = 0; i < t; i++)
97
- o[i] = arguments[i];
98
- return o.length >= n.length ? n.apply(this, o) : function() {
99
- for (var a = arguments.length, u = new Array(a), c = 0; c < a; c++)
100
- u[c] = arguments[c];
101
- return e.apply(r, [].concat(o, u));
102
- };
103
- };
104
- }
105
- function M(n) {
106
- return {}.toString.call(n).includes("Object");
107
- }
108
- function q(n) {
109
- return n || g("configIsRequired"), M(n) || g("configType"), n.urls ? (L(), {
110
- paths: {
111
- vs: n.urls.monacoBase
112
- }
113
- }) : n;
114
- }
115
- function L() {
116
- console.warn(b.deprecation);
117
- }
118
- function $(n, e) {
119
- throw new Error(n[e] || n.default);
120
- }
121
- var b = {
122
- configIsRequired: "the configuration object is required",
123
- configType: "the configuration object should be an object",
124
- default: "an unknown error accured in `@monaco-editor/loader` package",
125
- deprecation: `Deprecation warning!
126
- You are using deprecated way of configuration.
127
-
128
- Instead of using
129
- monaco.config({ urls: { monacoBase: '...' } })
130
- use
131
- monaco.config({ paths: { vs: '...' } })
132
-
133
- For more please check the link https://github.com/suren-atoyan/monaco-loader#config
134
- `
135
- }, g = D($)(b), R = {
136
- config: q
137
- }, _ = function() {
138
- for (var e = arguments.length, r = new Array(e), t = 0; t < e; t++)
139
- r[t] = arguments[t];
140
- return function(o) {
141
- return r.reduceRight(function(i, a) {
142
- return a(i);
143
- }, o);
144
- };
145
- };
146
- function h(n, e) {
147
- return Object.keys(e).forEach(function(r) {
148
- e[r] instanceof Object && n[r] && Object.assign(e[r], h(n[r], e[r]));
149
- }), m(m({}, n), e);
150
- }
151
- var x = {
152
- type: "cancelation",
153
- msg: "operation is manually canceled"
154
- };
155
- function s(n) {
156
- var e = !1, r = new Promise(function(t, o) {
157
- n.then(function(i) {
158
- return e ? o(x) : t(i);
159
- }), n.catch(o);
160
- });
161
- return r.cancel = function() {
162
- return e = !0;
163
- }, r;
164
- }
165
- var W = w.create({
166
- config: z,
167
- isInitialized: !1,
168
- resolve: null,
169
- reject: null,
170
- monaco: null
171
- }), y = P(W, 2), f = y[0], l = y[1];
172
- function B(n) {
173
- var e = R.config(n), r = e.monaco, t = S(e, ["monaco"]);
174
- l(function(o) {
175
- return {
176
- config: h(o.config, t),
177
- monaco: r
178
- };
179
- });
180
- }
181
- function H() {
182
- var n = f(function(e) {
183
- var r = e.monaco, t = e.isInitialized, o = e.resolve;
184
- return {
185
- monaco: r,
186
- isInitialized: t,
187
- resolve: o
188
- };
189
- });
190
- if (!n.isInitialized) {
191
- if (l({
192
- isInitialized: !0
193
- }), n.monaco)
194
- return n.resolve(n.monaco), s(p);
195
- if (window.monaco && window.monaco.editor)
196
- return j(window.monaco), n.resolve(window.monaco), s(p);
197
- _(N, G)(K);
198
- }
199
- return s(p);
200
- }
201
- function N(n) {
202
- return document.body.appendChild(n);
203
- }
204
- function F(n) {
205
- var e = document.createElement("script");
206
- return n && (e.src = n), e;
207
- }
208
- function G(n) {
209
- var e = f(function(t) {
210
- var o = t.config, i = t.reject;
211
- return {
212
- config: o,
213
- reject: i
214
- };
215
- }), r = F("".concat(e.config.paths.vs, "/loader.js"));
216
- return r.onload = function() {
217
- return n();
218
- }, r.onerror = e.reject, r;
219
- }
220
- function K() {
221
- var n = f(function(r) {
222
- var t = r.config, o = r.resolve, i = r.reject;
223
- return {
224
- config: t,
225
- resolve: o,
226
- reject: i
227
- };
228
- }), e = window.require;
229
- e.config(n.config), e(["vs/editor/editor.main"], function(r) {
230
- j(r), n.resolve(r);
231
- }, function(r) {
232
- n.reject(r);
233
- });
234
- }
235
- function j(n) {
236
- f().monaco || l({
237
- monaco: n
238
- });
239
- }
240
- function U() {
241
- return f(function(n) {
242
- var e = n.monaco;
243
- return e;
244
- });
245
- }
246
- var p = new Promise(function(n, e) {
247
- return l({
248
- resolve: n,
249
- reject: e
250
- });
251
- }), J = {
252
- config: B,
253
- init: H,
254
- __getMonacoInstance: U
255
- };
256
- export {
257
- J as l
258
- };
@@ -1,131 +0,0 @@
1
- function O(e, t, n) {
2
- return t in e ? Object.defineProperty(e, t, {
3
- value: n,
4
- enumerable: !0,
5
- configurable: !0,
6
- writable: !0
7
- }) : e[t] = n, e;
8
- }
9
- function g(e, t) {
10
- var n = Object.keys(e);
11
- if (Object.getOwnPropertySymbols) {
12
- var r = Object.getOwnPropertySymbols(e);
13
- t && (r = r.filter(function(i) {
14
- return Object.getOwnPropertyDescriptor(e, i).enumerable;
15
- })), n.push.apply(n, r);
16
- }
17
- return n;
18
- }
19
- function v(e) {
20
- for (var t = 1; t < arguments.length; t++) {
21
- var n = arguments[t] != null ? arguments[t] : {};
22
- t % 2 ? g(Object(n), !0).forEach(function(r) {
23
- O(e, r, n[r]);
24
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : g(Object(n)).forEach(function(r) {
25
- Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(n, r));
26
- });
27
- }
28
- return e;
29
- }
30
- function y() {
31
- for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++)
32
- t[n] = arguments[n];
33
- return function(r) {
34
- return t.reduceRight(function(i, a) {
35
- return a(i);
36
- }, r);
37
- };
38
- }
39
- function c(e) {
40
- return function t() {
41
- for (var n = this, r = arguments.length, i = new Array(r), a = 0; a < r; a++)
42
- i[a] = arguments[a];
43
- return i.length >= e.length ? e.apply(this, i) : function() {
44
- for (var f = arguments.length, s = new Array(f), o = 0; o < f; o++)
45
- s[o] = arguments[o];
46
- return t.apply(n, [].concat(i, s));
47
- };
48
- };
49
- }
50
- function h(e) {
51
- return {}.toString.call(e).includes("Object");
52
- }
53
- function m(e) {
54
- return !Object.keys(e).length;
55
- }
56
- function l(e) {
57
- return typeof e == "function";
58
- }
59
- function j(e, t) {
60
- return Object.prototype.hasOwnProperty.call(e, t);
61
- }
62
- function w(e, t) {
63
- return h(t) || u("changeType"), Object.keys(t).some(function(n) {
64
- return !j(e, n);
65
- }) && u("changeField"), t;
66
- }
67
- function P(e) {
68
- l(e) || u("selectorType");
69
- }
70
- function T(e) {
71
- l(e) || h(e) || u("handlerType"), h(e) && Object.values(e).some(function(t) {
72
- return !l(t);
73
- }) && u("handlersType");
74
- }
75
- function S(e) {
76
- e || u("initialIsRequired"), h(e) || u("initialType"), m(e) && u("initialContent");
77
- }
78
- function E(e, t) {
79
- throw new Error(e[t] || e.default);
80
- }
81
- var D = {
82
- initialIsRequired: "initial state is required",
83
- initialType: "initial state should be an object",
84
- initialContent: "initial state shouldn't be an empty object",
85
- handlerType: "handler should be an object or a function",
86
- handlersType: "all handlers should be a functions",
87
- selectorType: "selector should be a function",
88
- changeType: "provided value of changes should be an object",
89
- changeField: 'it seams you want to change a field in the state which is not specified in the "initial" state',
90
- default: "an unknown error accured in `state-local` package"
91
- }, u = c(E)(D), p = {
92
- changes: w,
93
- selector: P,
94
- handler: T,
95
- initial: S
96
- };
97
- function q(e) {
98
- var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
99
- p.initial(e), p.handler(t);
100
- var n = {
101
- current: e
102
- }, r = c(I)(n, t), i = c(F)(n), a = c(p.changes)(e), f = c(C)(n);
103
- function s() {
104
- var d = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function(b) {
105
- return b;
106
- };
107
- return p.selector(d), d(n.current);
108
- }
109
- function o(d) {
110
- y(r, i, a, f)(d);
111
- }
112
- return [s, o];
113
- }
114
- function C(e, t) {
115
- return l(t) ? t(e.current) : t;
116
- }
117
- function F(e, t) {
118
- return e.current = v(v({}, e.current), t), t;
119
- }
120
- function I(e, t, n) {
121
- return l(t) ? t(e.current) : Object.keys(n).forEach(function(r) {
122
- var i;
123
- return (i = t[r]) === null || i === void 0 ? void 0 : i.call(t, e.current[r]);
124
- }), n;
125
- }
126
- var R = {
127
- create: q
128
- };
129
- export {
130
- R as i
131
- };