@cloud-app-dev/vidc 2.0.0-alpha.17 → 2.0.0-alpha.18

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.
package/.fatherrc.js CHANGED
@@ -1,10 +1,6 @@
1
- import nodePolyfills from 'rollup-plugin-node-polyfills';
2
-
3
1
  export default {
4
2
  target: 'browser',
5
3
  esm: 'babel',
6
- extraRollupPlugins: [nodePolyfills()],
7
- lessInBabelMode: true, // babel 模式下做 less 编译
8
4
  pkgs: [
9
5
  // 组件依赖构建顺序, 例如 a组件依赖于b组件,那么需要先编译 b,在编译a,则 这里可以控制组件编译顺序
10
6
  ],
@@ -15,4 +11,15 @@ export default {
15
11
  ['import', { libraryName: 'ahooks', style: false, camel2DashComponentName: false, libraryDirectory: 'es' }, 'ahooks'],
16
12
  ['import', { libraryName: '@cloud-app-dev/map', style: false, camel2DashComponentName: false, libraryDirectory: 'es' }, 'map-components'],
17
13
  ],
14
+ lessInRollupMode: {
15
+ modifyVars: {
16
+ '@ant-prefix': 'cloudapp',
17
+ },
18
+ },
19
+ lessInBabelMode: {
20
+ // babel 模式下做 less 编译
21
+ modifyVars: {
22
+ '@ant-prefix': 'cloudapp',
23
+ },
24
+ },
18
25
  };
@@ -10,14 +10,10 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
10
10
 
11
11
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
12
 
13
- import { __asyncValues, __awaiter } from "tslib";
14
13
  import React, { useEffect, useState } from 'react';
15
- import { createAsyncIterable } from './utils';
16
- import { nextTick, tryCatch } from '../utils';
14
+ import { createAsyncIterable, runAsyncIterable } from './utils';
17
15
 
18
16
  function LoaderScripts(_ref) {
19
- var _this = this;
20
-
21
17
  var _ref$options = _ref.options,
22
18
  options = _ref$options === void 0 ? [] : _ref$options,
23
19
  children = _ref.children,
@@ -35,90 +31,12 @@ function LoaderScripts(_ref) {
35
31
  return setInitStatus(true);
36
32
  }
37
33
 
38
- var asyncIter = createAsyncIterable(options);
39
- tryCatch(function () {
40
- return __awaiter(_this, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
41
- var e_1, _a, asyncIter_1, asyncIter_1_1, x;
42
-
43
- return regeneratorRuntime.wrap(function _callee$(_context) {
44
- while (1) {
45
- switch (_context.prev = _context.next) {
46
- case 0:
47
- _context.prev = 0;
48
- asyncIter_1 = __asyncValues(asyncIter);
49
-
50
- case 2:
51
- _context.next = 4;
52
- return asyncIter_1.next();
53
-
54
- case 4:
55
- asyncIter_1_1 = _context.sent;
56
-
57
- if (asyncIter_1_1.done) {
58
- _context.next = 10;
59
- break;
60
- }
61
-
62
- x = asyncIter_1_1.value;
63
- console.log('加载完成!', options[x]);
64
-
65
- case 8:
66
- _context.next = 2;
67
- break;
68
-
69
- case 10:
70
- _context.next = 15;
71
- break;
72
-
73
- case 12:
74
- _context.prev = 12;
75
- _context.t0 = _context["catch"](0);
76
- e_1 = {
77
- error: _context.t0
78
- };
79
-
80
- case 15:
81
- _context.prev = 15;
82
- _context.prev = 16;
83
-
84
- if (!(asyncIter_1_1 && !asyncIter_1_1.done && (_a = asyncIter_1.return))) {
85
- _context.next = 20;
86
- break;
87
- }
88
-
89
- _context.next = 20;
90
- return _a.call(asyncIter_1);
91
-
92
- case 20:
93
- _context.prev = 20;
94
-
95
- if (!e_1) {
96
- _context.next = 23;
97
- break;
98
- }
99
-
100
- throw e_1.error;
101
-
102
- case 23:
103
- return _context.finish(20);
104
-
105
- case 24:
106
- return _context.finish(15);
107
-
108
- case 25:
109
- nextTick(function () {
110
- return onLoadEnd ? onLoadEnd().then(function () {
111
- return setInitStatus(true);
112
- }) : setInitStatus(true);
113
- });
114
-
115
- case 26:
116
- case "end":
117
- return _context.stop();
118
- }
119
- }
120
- }, _callee, null, [[0, 12, 15, 25], [16,, 20, 24]]);
121
- }));
34
+ runAsyncIterable(createAsyncIterable(options), function (option) {
35
+ return console.debug('LoaderScript -> Iterable加载完成!', option);
36
+ }, function () {
37
+ return onLoadEnd ? onLoadEnd().then(function () {
38
+ return setInitStatus(true);
39
+ }) : setInitStatus(true);
122
40
  });
123
41
  }, [options]);
124
42
  return /*#__PURE__*/React.createElement(React.Fragment, null, !initStatus ? Spin : children);
@@ -10,3 +10,5 @@ export declare function createAsyncIterable(options: IOptionsLoader[]): {
10
10
  }>;
11
11
  };
12
12
  };
13
+ export declare function tryCatch(resolveFn: () => Promise<any>, rejectFn?: (e: unknown) => void): Promise<void>;
14
+ export declare function runAsyncIterable(Iterables: any, runtime?: (conf: any) => void, callback?: () => void): void;
@@ -1,3 +1,5 @@
1
+ import _nextTick from "@cloud-app-dev/utils/es/nextTick";
2
+
1
3
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
4
 
3
5
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
@@ -12,7 +14,7 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToAr
12
14
 
13
15
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
14
16
 
15
- import { __awaiter } from "tslib";
17
+ import { __asyncValues, __awaiter } from "tslib";
16
18
  var global = window;
17
19
 
18
20
  if (!global._LOADER_SCRIPT_URL) {
@@ -130,4 +132,116 @@ export function createAsyncIterable(options) {
130
132
  }
131
133
  };
132
134
  });
135
+ }
136
+ export function tryCatch(resolveFn) {
137
+ var rejectFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : console.error;
138
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
139
+ return regeneratorRuntime.wrap(function _callee2$(_context2) {
140
+ while (1) {
141
+ switch (_context2.prev = _context2.next) {
142
+ case 0:
143
+ _context2.prev = 0;
144
+ _context2.next = 3;
145
+ return resolveFn();
146
+
147
+ case 3:
148
+ _context2.next = 8;
149
+ break;
150
+
151
+ case 5:
152
+ _context2.prev = 5;
153
+ _context2.t0 = _context2["catch"](0);
154
+ rejectFn(_context2.t0);
155
+
156
+ case 8:
157
+ case "end":
158
+ return _context2.stop();
159
+ }
160
+ }
161
+ }, _callee2, null, [[0, 5]]);
162
+ }));
163
+ }
164
+ export function runAsyncIterable(Iterables, runtime, callback) {
165
+ var _this = this;
166
+
167
+ tryCatch(function () {
168
+ return __awaiter(_this, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
169
+ var e_1, _a, Iterables_1, Iterables_1_1, x;
170
+
171
+ return regeneratorRuntime.wrap(function _callee3$(_context3) {
172
+ while (1) {
173
+ switch (_context3.prev = _context3.next) {
174
+ case 0:
175
+ _context3.prev = 0;
176
+ Iterables_1 = __asyncValues(Iterables);
177
+
178
+ case 2:
179
+ _context3.next = 4;
180
+ return Iterables_1.next();
181
+
182
+ case 4:
183
+ Iterables_1_1 = _context3.sent;
184
+
185
+ if (Iterables_1_1.done) {
186
+ _context3.next = 10;
187
+ break;
188
+ }
189
+
190
+ x = Iterables_1_1.value;
191
+ runtime && runtime(Iterables[x]);
192
+
193
+ case 8:
194
+ _context3.next = 2;
195
+ break;
196
+
197
+ case 10:
198
+ _context3.next = 15;
199
+ break;
200
+
201
+ case 12:
202
+ _context3.prev = 12;
203
+ _context3.t0 = _context3["catch"](0);
204
+ e_1 = {
205
+ error: _context3.t0
206
+ };
207
+
208
+ case 15:
209
+ _context3.prev = 15;
210
+ _context3.prev = 16;
211
+
212
+ if (!(Iterables_1_1 && !Iterables_1_1.done && (_a = Iterables_1.return))) {
213
+ _context3.next = 20;
214
+ break;
215
+ }
216
+
217
+ _context3.next = 20;
218
+ return _a.call(Iterables_1);
219
+
220
+ case 20:
221
+ _context3.prev = 20;
222
+
223
+ if (!e_1) {
224
+ _context3.next = 23;
225
+ break;
226
+ }
227
+
228
+ throw e_1.error;
229
+
230
+ case 23:
231
+ return _context3.finish(20);
232
+
233
+ case 24:
234
+ return _context3.finish(15);
235
+
236
+ case 25:
237
+ callback && _nextTick(callback);
238
+
239
+ case 26:
240
+ case "end":
241
+ return _context3.stop();
242
+ }
243
+ }
244
+ }, _callee3, null, [[0, 12, 15, 25], [16,, 20, 24]]);
245
+ }));
246
+ });
133
247
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "private": false,
3
3
  "name": "@cloud-app-dev/vidc",
4
4
  "description": "Video Image Data Componennts",
5
- "version": "2.0.0-alpha.17",
5
+ "version": "2.0.0-alpha.18",
6
6
  "scripts": {
7
7
  "start": "dumi dev",
8
8
  "docs:build": "dumi build",