@elice/material-shared-utils 1.230328.0 → 1.230418.1
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/cjs/_virtual/_rollupPluginBabelHelpers.js +424 -0
- package/cjs/components/MaterialIntlProvider.js +14 -10
- package/cjs/hooks/useCallbackProp.js +3 -3
- package/cjs/index.js +2 -2
- package/cjs/material-config/MaterialConfigContext.js +2 -2
- package/cjs/material-config/MaterialConfigProvider.js +32 -21
- package/cjs/material-config/useMaterialConfig.js +2 -4
- package/cjs/material-config/useMaterialConfigApiClientUpdate.js +8 -7
- package/cjs/material-config/utils.js +0 -1
- package/cjs/material-fetch/useMaterialFetch.d.ts +2 -0
- package/cjs/material-fetch/useMaterialFetch.js +3 -4
- package/cjs/material-fetch/useMaterialFetchRaw.d.ts +2 -1
- package/cjs/material-fetch/useMaterialFetchRaw.js +79 -64
- package/cjs/material-hoc/withMaterial.js +13 -17
- package/es/_virtual/_rollupPluginBabelHelpers.js +410 -0
- package/es/components/MaterialIntlProvider.js +11 -9
- package/es/hooks/useCallbackProp.js +3 -3
- package/es/material-config/MaterialConfigContext.js +2 -2
- package/es/material-config/MaterialConfigProvider.js +29 -20
- package/es/material-config/useMaterialConfig.js +2 -4
- package/es/material-config/useMaterialConfigApiClientUpdate.js +8 -7
- package/es/material-config/utils.js +0 -1
- package/es/material-fetch/useMaterialFetch.d.ts +2 -0
- package/es/material-fetch/useMaterialFetch.js +3 -4
- package/es/material-fetch/useMaterialFetchRaw.d.ts +2 -1
- package/es/material-fetch/useMaterialFetchRaw.js +79 -64
- package/es/material-hoc/withMaterial.js +11 -15
- package/package.json +7 -7
|
@@ -9,13 +9,14 @@ export interface FetchKeyMap {
|
|
|
9
9
|
[enums.LectureMaterialType.PDF]: 'materialPdf';
|
|
10
10
|
[enums.LectureMaterialType.Exercise]: 'materialExercise';
|
|
11
11
|
[enums.LectureMaterialType.Quiz]: 'materialQuiz';
|
|
12
|
-
[enums.LectureMaterialType.
|
|
12
|
+
[enums.LectureMaterialType.LegacyRunbox]: 'materialLegacyRunbox';
|
|
13
13
|
[enums.LectureMaterialType.VideoFile]: 'materialVideoFile';
|
|
14
14
|
[enums.LectureMaterialType.Live]: 'materialLive';
|
|
15
15
|
[enums.LectureMaterialType.Assignment]: 'materialAssignment';
|
|
16
16
|
[enums.LectureMaterialType.LMSPublicContent]: 'materialLmsPublicContent';
|
|
17
17
|
[enums.LectureMaterialType.External]: 'materialExternal';
|
|
18
18
|
[enums.LectureMaterialType.Survey]: 'materialSurvey';
|
|
19
|
+
[enums.LectureMaterialType.Runbox]: 'materialRunbox';
|
|
19
20
|
}
|
|
20
21
|
/**
|
|
21
22
|
* Init api client and fetch material for contaner.
|
|
@@ -2,28 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var _rollupPluginBabelHelpers = require('../_virtual/_rollupPluginBabelHelpers.js');
|
|
5
6
|
var React = require('react');
|
|
6
7
|
var apiClient = require('@elice/api-client');
|
|
7
8
|
var types = require('@elice/types');
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
[types.enums.LectureMaterialType.Video]: 'materialVideo',
|
|
13
|
-
[types.enums.LectureMaterialType.PDF]: 'materialPdf',
|
|
14
|
-
[types.enums.LectureMaterialType.Exercise]: 'materialExercise',
|
|
15
|
-
[types.enums.LectureMaterialType.Quiz]: 'materialQuiz',
|
|
16
|
-
[types.enums.LectureMaterialType.Runbox]: 'materialRunbox',
|
|
17
|
-
[types.enums.LectureMaterialType.VideoFile]: 'materialVideoFile',
|
|
18
|
-
[types.enums.LectureMaterialType.Live]: 'materialLive',
|
|
19
|
-
[types.enums.LectureMaterialType.Assignment]: 'materialAssignment',
|
|
20
|
-
[types.enums.LectureMaterialType.LMSPublicContent]: 'materialLmsPublicContent',
|
|
21
|
-
[types.enums.LectureMaterialType.External]: 'materialExternal',
|
|
22
|
-
[types.enums.LectureMaterialType.Survey]: 'materialSurvey'
|
|
23
|
-
}); //
|
|
10
|
+
var _Object$freeze;
|
|
11
|
+
var MATERIAL_FETCH_KEY_MAP = Object.freeze((_Object$freeze = {}, _rollupPluginBabelHelpers.defineProperty(_Object$freeze, types.enums.LectureMaterialType.Nothing, 'materialNothing'), _rollupPluginBabelHelpers.defineProperty(_Object$freeze, types.enums.LectureMaterialType.Note, 'materialNote'), _rollupPluginBabelHelpers.defineProperty(_Object$freeze, types.enums.LectureMaterialType.Video, 'materialVideo'), _rollupPluginBabelHelpers.defineProperty(_Object$freeze, types.enums.LectureMaterialType.PDF, 'materialPdf'), _rollupPluginBabelHelpers.defineProperty(_Object$freeze, types.enums.LectureMaterialType.Exercise, 'materialExercise'), _rollupPluginBabelHelpers.defineProperty(_Object$freeze, types.enums.LectureMaterialType.Quiz, 'materialQuiz'), _rollupPluginBabelHelpers.defineProperty(_Object$freeze, types.enums.LectureMaterialType.LegacyRunbox, 'materialLegacyRunbox'), _rollupPluginBabelHelpers.defineProperty(_Object$freeze, types.enums.LectureMaterialType.VideoFile, 'materialVideoFile'), _rollupPluginBabelHelpers.defineProperty(_Object$freeze, types.enums.LectureMaterialType.Live, 'materialLive'), _rollupPluginBabelHelpers.defineProperty(_Object$freeze, types.enums.LectureMaterialType.Assignment, 'materialAssignment'), _rollupPluginBabelHelpers.defineProperty(_Object$freeze, types.enums.LectureMaterialType.LMSPublicContent, 'materialLmsPublicContent'), _rollupPluginBabelHelpers.defineProperty(_Object$freeze, types.enums.LectureMaterialType.External, 'materialExternal'), _rollupPluginBabelHelpers.defineProperty(_Object$freeze, types.enums.LectureMaterialType.Survey, 'materialSurvey'), _rollupPluginBabelHelpers.defineProperty(_Object$freeze, types.enums.LectureMaterialType.Runbox, 'materialRunbox'), _Object$freeze));
|
|
12
|
+
//
|
|
24
13
|
//
|
|
25
14
|
//
|
|
26
|
-
|
|
27
15
|
/**
|
|
28
16
|
* Init api client and fetch material for contaner.
|
|
29
17
|
*
|
|
@@ -42,66 +30,93 @@ const MATERIAL_FETCH_KEY_MAP = Object.freeze({
|
|
|
42
30
|
* isReady // boolean
|
|
43
31
|
* );
|
|
44
32
|
*/
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
33
|
+
var useMaterialFetchRaw = function useMaterialFetchRaw(materialType, materialFetchFn) {
|
|
34
|
+
var isReady = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
35
|
+
var _return = React.useRef({});
|
|
36
|
+
var materialKey = MATERIAL_FETCH_KEY_MAP[materialType];
|
|
37
|
+
var _createEmptyFetchRes = function _createEmptyFetchRes() {
|
|
38
|
+
var _ref;
|
|
39
|
+
return _ref = {}, _rollupPluginBabelHelpers.defineProperty(_ref, materialKey, null), _rollupPluginBabelHelpers.defineProperty(_ref, "materialLecturePage", null), _ref;
|
|
40
|
+
};
|
|
41
|
+
var _useState = React.useState(_createEmptyFetchRes),
|
|
42
|
+
_useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
|
|
43
|
+
matFetchRes = _useState2[0],
|
|
44
|
+
setMatFetchRes = _useState2[1];
|
|
45
|
+
var _useState3 = React.useState('idle'),
|
|
46
|
+
_useState4 = _rollupPluginBabelHelpers.slicedToArray(_useState3, 2),
|
|
47
|
+
matFetchStatus = _useState4[0],
|
|
48
|
+
setMatFetchStatus = _useState4[1];
|
|
58
49
|
/**
|
|
59
50
|
* fetch material and lecture page
|
|
60
51
|
*/
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
52
|
+
var fetch = React.useCallback( /*#__PURE__*/function () {
|
|
53
|
+
var _ref2 = _rollupPluginBabelHelpers.asyncToGenerator( /*#__PURE__*/_rollupPluginBabelHelpers.regeneratorRuntime().mark(function _callee(signal) {
|
|
54
|
+
return _rollupPluginBabelHelpers.regeneratorRuntime().wrap(function _callee$(_context) {
|
|
55
|
+
while (1) switch (_context.prev = _context.next) {
|
|
56
|
+
case 0:
|
|
57
|
+
setMatFetchStatus('pending');
|
|
58
|
+
return _context.abrupt("return", materialFetchFn(signal).then(function (resMaterialGet) {
|
|
59
|
+
return resMaterialGet[materialKey];
|
|
60
|
+
}).then(function (material) {
|
|
61
|
+
return Promise.all([material, apiClient.getOrgLecturePageResolve({
|
|
62
|
+
materialId: material.id,
|
|
63
|
+
materialType: materialType
|
|
64
|
+
}, {
|
|
65
|
+
signal: signal
|
|
66
|
+
}).then(function (resLecturePageResolve) {
|
|
67
|
+
return apiClient.getOrgLecturePageGet({
|
|
68
|
+
lecturePageId: resLecturePageResolve.lecturePageId
|
|
69
|
+
}, {
|
|
70
|
+
signal: signal
|
|
71
|
+
});
|
|
72
|
+
}).then(function (resLecturePageGet) {
|
|
73
|
+
return resLecturePageGet.lecturePage;
|
|
74
|
+
})]);
|
|
75
|
+
}).then(function (_ref3) {
|
|
76
|
+
var _setMatFetchRes;
|
|
77
|
+
var _ref4 = _rollupPluginBabelHelpers.slicedToArray(_ref3, 2),
|
|
78
|
+
material = _ref4[0],
|
|
79
|
+
materialLecturePage = _ref4[1];
|
|
80
|
+
setMatFetchRes((_setMatFetchRes = {}, _rollupPluginBabelHelpers.defineProperty(_setMatFetchRes, materialKey, material), _rollupPluginBabelHelpers.defineProperty(_setMatFetchRes, "materialLecturePage", materialLecturePage), _setMatFetchRes));
|
|
81
|
+
setMatFetchStatus('resolved');
|
|
82
|
+
}).catch(function (err) {
|
|
83
|
+
if (err.name !== 'AbortError') {
|
|
84
|
+
setMatFetchRes(_createEmptyFetchRes);
|
|
85
|
+
setMatFetchStatus('rejected');
|
|
86
|
+
}
|
|
87
|
+
}));
|
|
88
|
+
case 2:
|
|
89
|
+
case "end":
|
|
90
|
+
return _context.stop();
|
|
91
|
+
}
|
|
92
|
+
}, _callee);
|
|
93
|
+
}));
|
|
94
|
+
return function (_x) {
|
|
95
|
+
return _ref2.apply(this, arguments);
|
|
96
|
+
};
|
|
97
|
+
}(),
|
|
98
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
99
|
+
[materialKey, materialFetchFn]);
|
|
100
|
+
//
|
|
87
101
|
// emit `fetch` when `isReady` is changed
|
|
88
102
|
//
|
|
89
|
-
|
|
90
|
-
React.useEffect(() => {
|
|
103
|
+
React.useEffect(function () {
|
|
91
104
|
if (!isReady) {
|
|
92
105
|
return;
|
|
93
106
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
107
|
+
var abortCtrl = new AbortController();
|
|
108
|
+
fetch(abortCtrl.signal).catch(function () {
|
|
109
|
+
return void 0;
|
|
110
|
+
});
|
|
111
|
+
return function () {
|
|
98
112
|
abortCtrl.abort();
|
|
99
113
|
};
|
|
100
|
-
},
|
|
101
|
-
|
|
114
|
+
},
|
|
115
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
116
|
+
[isReady, fetch]);
|
|
117
|
+
//
|
|
102
118
|
//
|
|
103
119
|
//
|
|
104
|
-
|
|
105
120
|
_return.current[materialKey] = matFetchRes[materialKey];
|
|
106
121
|
_return.current.materialLecturePage = matFetchRes.materialLecturePage;
|
|
107
122
|
_return.current.status = matFetchStatus;
|
|
@@ -15,7 +15,7 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
15
15
|
|
|
16
16
|
//
|
|
17
17
|
//
|
|
18
|
-
|
|
18
|
+
//
|
|
19
19
|
/**
|
|
20
20
|
* HOC for material components.
|
|
21
21
|
*
|
|
@@ -23,13 +23,12 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
23
23
|
* - `<RecoilRoot />`
|
|
24
24
|
* - `<IntlProvider />`
|
|
25
25
|
*/
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return props
|
|
26
|
+
var withMaterial = function withMaterial(Component, eliceApiClientConfigInit) {
|
|
27
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
28
|
+
return function (props) {
|
|
29
29
|
var _a;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
var isReady = useMaterialConfigApiClientUpdate.useMaterialConfigApiClientUpdate(eliceApiClientConfigInit);
|
|
31
|
+
// do not render component, if material config is not ready
|
|
33
32
|
if (!isReady) {
|
|
34
33
|
return React__default["default"].createElement(blocks.Flex, {
|
|
35
34
|
justify: "center",
|
|
@@ -40,10 +39,9 @@ const withMaterial = (Component, eliceApiClientConfigInit, options = {}) => {
|
|
|
40
39
|
size: "small"
|
|
41
40
|
}));
|
|
42
41
|
}
|
|
43
|
-
|
|
44
42
|
return React__default["default"].createElement(recoil.RecoilRoot, {
|
|
45
43
|
override: (_a = options.overrideRecoilScope) !== null && _a !== void 0 ? _a : false
|
|
46
|
-
}, React__default["default"].createElement(MaterialIntlProvider, {
|
|
44
|
+
}, React__default["default"].createElement(MaterialIntlProvider["default"], {
|
|
47
45
|
locale: props.locale,
|
|
48
46
|
phrases: options.phrases
|
|
49
47
|
}, React__default["default"].createElement(Component, Object.assign({}, props))));
|
|
@@ -56,13 +54,12 @@ const withMaterial = (Component, eliceApiClientConfigInit, options = {}) => {
|
|
|
56
54
|
* - `<RecoilRoot />`
|
|
57
55
|
* - `<IntlProvider />`
|
|
58
56
|
*/
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return React.forwardRef((props, ref)
|
|
57
|
+
var withForwardRefMaterial = function withForwardRefMaterial(Component, eliceApiClientConfigInit) {
|
|
58
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
59
|
+
return React.forwardRef(function (props, ref) {
|
|
62
60
|
var _a;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
var isReady = useMaterialConfigApiClientUpdate.useMaterialConfigApiClientUpdate(eliceApiClientConfigInit);
|
|
62
|
+
// do not render component, if material config is not ready
|
|
66
63
|
if (!isReady) {
|
|
67
64
|
return React__default["default"].createElement(blocks.Flex, {
|
|
68
65
|
justify: "center",
|
|
@@ -73,10 +70,9 @@ const withForwardRefMaterial = (Component, eliceApiClientConfigInit, options = {
|
|
|
73
70
|
size: "small"
|
|
74
71
|
}));
|
|
75
72
|
}
|
|
76
|
-
|
|
77
73
|
return React__default["default"].createElement(recoil.RecoilRoot, {
|
|
78
74
|
override: (_a = options.overrideRecoilScope) !== null && _a !== void 0 ? _a : false
|
|
79
|
-
}, React__default["default"].createElement(MaterialIntlProvider, {
|
|
75
|
+
}, React__default["default"].createElement(MaterialIntlProvider["default"], {
|
|
80
76
|
locale: props.locale,
|
|
81
77
|
phrases: options.phrases
|
|
82
78
|
}, React__default["default"].createElement(Component, Object.assign({}, props, {
|
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
function _iterableToArrayLimit(arr, i) {
|
|
2
|
+
var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
|
|
3
|
+
if (null != _i) {
|
|
4
|
+
var _s,
|
|
5
|
+
_e,
|
|
6
|
+
_x,
|
|
7
|
+
_r,
|
|
8
|
+
_arr = [],
|
|
9
|
+
_n = !0,
|
|
10
|
+
_d = !1;
|
|
11
|
+
try {
|
|
12
|
+
if (_x = (_i = _i.call(arr)).next, 0 === i) {
|
|
13
|
+
if (Object(_i) !== _i) return;
|
|
14
|
+
_n = !1;
|
|
15
|
+
} else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
|
|
16
|
+
} catch (err) {
|
|
17
|
+
_d = !0, _e = err;
|
|
18
|
+
} finally {
|
|
19
|
+
try {
|
|
20
|
+
if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;
|
|
21
|
+
} finally {
|
|
22
|
+
if (_d) throw _e;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return _arr;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function _regeneratorRuntime() {
|
|
29
|
+
_regeneratorRuntime = function () {
|
|
30
|
+
return exports;
|
|
31
|
+
};
|
|
32
|
+
var exports = {},
|
|
33
|
+
Op = Object.prototype,
|
|
34
|
+
hasOwn = Op.hasOwnProperty,
|
|
35
|
+
defineProperty = Object.defineProperty || function (obj, key, desc) {
|
|
36
|
+
obj[key] = desc.value;
|
|
37
|
+
},
|
|
38
|
+
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
|
39
|
+
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
|
40
|
+
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
|
41
|
+
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
42
|
+
function define(obj, key, value) {
|
|
43
|
+
return Object.defineProperty(obj, key, {
|
|
44
|
+
value: value,
|
|
45
|
+
enumerable: !0,
|
|
46
|
+
configurable: !0,
|
|
47
|
+
writable: !0
|
|
48
|
+
}), obj[key];
|
|
49
|
+
}
|
|
50
|
+
try {
|
|
51
|
+
define({}, "");
|
|
52
|
+
} catch (err) {
|
|
53
|
+
define = function (obj, key, value) {
|
|
54
|
+
return obj[key] = value;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
58
|
+
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
|
59
|
+
generator = Object.create(protoGenerator.prototype),
|
|
60
|
+
context = new Context(tryLocsList || []);
|
|
61
|
+
return defineProperty(generator, "_invoke", {
|
|
62
|
+
value: makeInvokeMethod(innerFn, self, context)
|
|
63
|
+
}), generator;
|
|
64
|
+
}
|
|
65
|
+
function tryCatch(fn, obj, arg) {
|
|
66
|
+
try {
|
|
67
|
+
return {
|
|
68
|
+
type: "normal",
|
|
69
|
+
arg: fn.call(obj, arg)
|
|
70
|
+
};
|
|
71
|
+
} catch (err) {
|
|
72
|
+
return {
|
|
73
|
+
type: "throw",
|
|
74
|
+
arg: err
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.wrap = wrap;
|
|
79
|
+
var ContinueSentinel = {};
|
|
80
|
+
function Generator() {}
|
|
81
|
+
function GeneratorFunction() {}
|
|
82
|
+
function GeneratorFunctionPrototype() {}
|
|
83
|
+
var IteratorPrototype = {};
|
|
84
|
+
define(IteratorPrototype, iteratorSymbol, function () {
|
|
85
|
+
return this;
|
|
86
|
+
});
|
|
87
|
+
var getProto = Object.getPrototypeOf,
|
|
88
|
+
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
89
|
+
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
|
90
|
+
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
91
|
+
function defineIteratorMethods(prototype) {
|
|
92
|
+
["next", "throw", "return"].forEach(function (method) {
|
|
93
|
+
define(prototype, method, function (arg) {
|
|
94
|
+
return this._invoke(method, arg);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
function AsyncIterator(generator, PromiseImpl) {
|
|
99
|
+
function invoke(method, arg, resolve, reject) {
|
|
100
|
+
var record = tryCatch(generator[method], generator, arg);
|
|
101
|
+
if ("throw" !== record.type) {
|
|
102
|
+
var result = record.arg,
|
|
103
|
+
value = result.value;
|
|
104
|
+
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
105
|
+
invoke("next", value, resolve, reject);
|
|
106
|
+
}, function (err) {
|
|
107
|
+
invoke("throw", err, resolve, reject);
|
|
108
|
+
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
109
|
+
result.value = unwrapped, resolve(result);
|
|
110
|
+
}, function (error) {
|
|
111
|
+
return invoke("throw", error, resolve, reject);
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
reject(record.arg);
|
|
115
|
+
}
|
|
116
|
+
var previousPromise;
|
|
117
|
+
defineProperty(this, "_invoke", {
|
|
118
|
+
value: function (method, arg) {
|
|
119
|
+
function callInvokeWithMethodAndArg() {
|
|
120
|
+
return new PromiseImpl(function (resolve, reject) {
|
|
121
|
+
invoke(method, arg, resolve, reject);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
function makeInvokeMethod(innerFn, self, context) {
|
|
129
|
+
var state = "suspendedStart";
|
|
130
|
+
return function (method, arg) {
|
|
131
|
+
if ("executing" === state) throw new Error("Generator is already running");
|
|
132
|
+
if ("completed" === state) {
|
|
133
|
+
if ("throw" === method) throw arg;
|
|
134
|
+
return doneResult();
|
|
135
|
+
}
|
|
136
|
+
for (context.method = method, context.arg = arg;;) {
|
|
137
|
+
var delegate = context.delegate;
|
|
138
|
+
if (delegate) {
|
|
139
|
+
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
140
|
+
if (delegateResult) {
|
|
141
|
+
if (delegateResult === ContinueSentinel) continue;
|
|
142
|
+
return delegateResult;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
|
146
|
+
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
|
147
|
+
context.dispatchException(context.arg);
|
|
148
|
+
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
149
|
+
state = "executing";
|
|
150
|
+
var record = tryCatch(innerFn, self, context);
|
|
151
|
+
if ("normal" === record.type) {
|
|
152
|
+
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
|
153
|
+
return {
|
|
154
|
+
value: record.arg,
|
|
155
|
+
done: context.done
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
function maybeInvokeDelegate(delegate, context) {
|
|
163
|
+
var methodName = context.method,
|
|
164
|
+
method = delegate.iterator[methodName];
|
|
165
|
+
if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
|
|
166
|
+
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
167
|
+
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
168
|
+
var info = record.arg;
|
|
169
|
+
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
|
|
170
|
+
}
|
|
171
|
+
function pushTryEntry(locs) {
|
|
172
|
+
var entry = {
|
|
173
|
+
tryLoc: locs[0]
|
|
174
|
+
};
|
|
175
|
+
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
|
176
|
+
}
|
|
177
|
+
function resetTryEntry(entry) {
|
|
178
|
+
var record = entry.completion || {};
|
|
179
|
+
record.type = "normal", delete record.arg, entry.completion = record;
|
|
180
|
+
}
|
|
181
|
+
function Context(tryLocsList) {
|
|
182
|
+
this.tryEntries = [{
|
|
183
|
+
tryLoc: "root"
|
|
184
|
+
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
|
185
|
+
}
|
|
186
|
+
function values(iterable) {
|
|
187
|
+
if (iterable) {
|
|
188
|
+
var iteratorMethod = iterable[iteratorSymbol];
|
|
189
|
+
if (iteratorMethod) return iteratorMethod.call(iterable);
|
|
190
|
+
if ("function" == typeof iterable.next) return iterable;
|
|
191
|
+
if (!isNaN(iterable.length)) {
|
|
192
|
+
var i = -1,
|
|
193
|
+
next = function next() {
|
|
194
|
+
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
|
195
|
+
return next.value = undefined, next.done = !0, next;
|
|
196
|
+
};
|
|
197
|
+
return next.next = next;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return {
|
|
201
|
+
next: doneResult
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
function doneResult() {
|
|
205
|
+
return {
|
|
206
|
+
value: undefined,
|
|
207
|
+
done: !0
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
|
|
211
|
+
value: GeneratorFunctionPrototype,
|
|
212
|
+
configurable: !0
|
|
213
|
+
}), defineProperty(GeneratorFunctionPrototype, "constructor", {
|
|
214
|
+
value: GeneratorFunction,
|
|
215
|
+
configurable: !0
|
|
216
|
+
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
|
217
|
+
var ctor = "function" == typeof genFun && genFun.constructor;
|
|
218
|
+
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
|
219
|
+
}, exports.mark = function (genFun) {
|
|
220
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
|
|
221
|
+
}, exports.awrap = function (arg) {
|
|
222
|
+
return {
|
|
223
|
+
__await: arg
|
|
224
|
+
};
|
|
225
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
226
|
+
return this;
|
|
227
|
+
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
228
|
+
void 0 === PromiseImpl && (PromiseImpl = Promise);
|
|
229
|
+
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
230
|
+
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
|
|
231
|
+
return result.done ? result.value : iter.next();
|
|
232
|
+
});
|
|
233
|
+
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
|
|
234
|
+
return this;
|
|
235
|
+
}), define(Gp, "toString", function () {
|
|
236
|
+
return "[object Generator]";
|
|
237
|
+
}), exports.keys = function (val) {
|
|
238
|
+
var object = Object(val),
|
|
239
|
+
keys = [];
|
|
240
|
+
for (var key in object) keys.push(key);
|
|
241
|
+
return keys.reverse(), function next() {
|
|
242
|
+
for (; keys.length;) {
|
|
243
|
+
var key = keys.pop();
|
|
244
|
+
if (key in object) return next.value = key, next.done = !1, next;
|
|
245
|
+
}
|
|
246
|
+
return next.done = !0, next;
|
|
247
|
+
};
|
|
248
|
+
}, exports.values = values, Context.prototype = {
|
|
249
|
+
constructor: Context,
|
|
250
|
+
reset: function (skipTempReset) {
|
|
251
|
+
if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
|
|
252
|
+
},
|
|
253
|
+
stop: function () {
|
|
254
|
+
this.done = !0;
|
|
255
|
+
var rootRecord = this.tryEntries[0].completion;
|
|
256
|
+
if ("throw" === rootRecord.type) throw rootRecord.arg;
|
|
257
|
+
return this.rval;
|
|
258
|
+
},
|
|
259
|
+
dispatchException: function (exception) {
|
|
260
|
+
if (this.done) throw exception;
|
|
261
|
+
var context = this;
|
|
262
|
+
function handle(loc, caught) {
|
|
263
|
+
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
|
264
|
+
}
|
|
265
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
266
|
+
var entry = this.tryEntries[i],
|
|
267
|
+
record = entry.completion;
|
|
268
|
+
if ("root" === entry.tryLoc) return handle("end");
|
|
269
|
+
if (entry.tryLoc <= this.prev) {
|
|
270
|
+
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
|
271
|
+
hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
272
|
+
if (hasCatch && hasFinally) {
|
|
273
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
274
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
275
|
+
} else if (hasCatch) {
|
|
276
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
277
|
+
} else {
|
|
278
|
+
if (!hasFinally) throw new Error("try statement without catch or finally");
|
|
279
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
abrupt: function (type, arg) {
|
|
285
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
286
|
+
var entry = this.tryEntries[i];
|
|
287
|
+
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
288
|
+
var finallyEntry = entry;
|
|
289
|
+
break;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
|
|
293
|
+
var record = finallyEntry ? finallyEntry.completion : {};
|
|
294
|
+
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
|
|
295
|
+
},
|
|
296
|
+
complete: function (record, afterLoc) {
|
|
297
|
+
if ("throw" === record.type) throw record.arg;
|
|
298
|
+
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
|
|
299
|
+
},
|
|
300
|
+
finish: function (finallyLoc) {
|
|
301
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
302
|
+
var entry = this.tryEntries[i];
|
|
303
|
+
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
|
|
304
|
+
}
|
|
305
|
+
},
|
|
306
|
+
catch: function (tryLoc) {
|
|
307
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
308
|
+
var entry = this.tryEntries[i];
|
|
309
|
+
if (entry.tryLoc === tryLoc) {
|
|
310
|
+
var record = entry.completion;
|
|
311
|
+
if ("throw" === record.type) {
|
|
312
|
+
var thrown = record.arg;
|
|
313
|
+
resetTryEntry(entry);
|
|
314
|
+
}
|
|
315
|
+
return thrown;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
throw new Error("illegal catch attempt");
|
|
319
|
+
},
|
|
320
|
+
delegateYield: function (iterable, resultName, nextLoc) {
|
|
321
|
+
return this.delegate = {
|
|
322
|
+
iterator: values(iterable),
|
|
323
|
+
resultName: resultName,
|
|
324
|
+
nextLoc: nextLoc
|
|
325
|
+
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
|
|
326
|
+
}
|
|
327
|
+
}, exports;
|
|
328
|
+
}
|
|
329
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
330
|
+
try {
|
|
331
|
+
var info = gen[key](arg);
|
|
332
|
+
var value = info.value;
|
|
333
|
+
} catch (error) {
|
|
334
|
+
reject(error);
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
if (info.done) {
|
|
338
|
+
resolve(value);
|
|
339
|
+
} else {
|
|
340
|
+
Promise.resolve(value).then(_next, _throw);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
function _asyncToGenerator(fn) {
|
|
344
|
+
return function () {
|
|
345
|
+
var self = this,
|
|
346
|
+
args = arguments;
|
|
347
|
+
return new Promise(function (resolve, reject) {
|
|
348
|
+
var gen = fn.apply(self, args);
|
|
349
|
+
function _next(value) {
|
|
350
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
351
|
+
}
|
|
352
|
+
function _throw(err) {
|
|
353
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
354
|
+
}
|
|
355
|
+
_next(undefined);
|
|
356
|
+
});
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
function _defineProperty(obj, key, value) {
|
|
360
|
+
key = _toPropertyKey(key);
|
|
361
|
+
if (key in obj) {
|
|
362
|
+
Object.defineProperty(obj, key, {
|
|
363
|
+
value: value,
|
|
364
|
+
enumerable: true,
|
|
365
|
+
configurable: true,
|
|
366
|
+
writable: true
|
|
367
|
+
});
|
|
368
|
+
} else {
|
|
369
|
+
obj[key] = value;
|
|
370
|
+
}
|
|
371
|
+
return obj;
|
|
372
|
+
}
|
|
373
|
+
function _slicedToArray(arr, i) {
|
|
374
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
375
|
+
}
|
|
376
|
+
function _arrayWithHoles(arr) {
|
|
377
|
+
if (Array.isArray(arr)) return arr;
|
|
378
|
+
}
|
|
379
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
380
|
+
if (!o) return;
|
|
381
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
382
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
383
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
384
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
385
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
386
|
+
}
|
|
387
|
+
function _arrayLikeToArray(arr, len) {
|
|
388
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
389
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
390
|
+
return arr2;
|
|
391
|
+
}
|
|
392
|
+
function _nonIterableRest() {
|
|
393
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
394
|
+
}
|
|
395
|
+
function _toPrimitive(input, hint) {
|
|
396
|
+
if (typeof input !== "object" || input === null) return input;
|
|
397
|
+
var prim = input[Symbol.toPrimitive];
|
|
398
|
+
if (prim !== undefined) {
|
|
399
|
+
var res = prim.call(input, hint || "default");
|
|
400
|
+
if (typeof res !== "object") return res;
|
|
401
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
402
|
+
}
|
|
403
|
+
return (hint === "string" ? String : Number)(input);
|
|
404
|
+
}
|
|
405
|
+
function _toPropertyKey(arg) {
|
|
406
|
+
var key = _toPrimitive(arg, "string");
|
|
407
|
+
return typeof key === "symbol" ? key : String(key);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
export { _arrayLikeToArray as arrayLikeToArray, _arrayWithHoles as arrayWithHoles, _asyncToGenerator as asyncToGenerator, _defineProperty as defineProperty, _iterableToArrayLimit as iterableToArrayLimit, _nonIterableRest as nonIterableRest, _regeneratorRuntime as regeneratorRuntime, _slicedToArray as slicedToArray, _toPrimitive as toPrimitive, _toPropertyKey as toPropertyKey, _unsupportedIterableToArray as unsupportedIterableToArray };
|