1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = void 0;
|
7 |
|
8 | function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
|
9 |
|
10 | function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
|
11 |
|
12 | function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
13 |
|
14 | function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
15 |
|
16 | var _default = function _default(allPossibleValues, resolvedScope) {
|
17 | var result = {};
|
18 |
|
19 | var addToScope = function addToScope(key, value) {
|
20 | if (result[key]) {
|
21 | throw new Error("Scope resolve malfunction for reference - ".concat(key));
|
22 | }
|
23 |
|
24 | result[key] = value;
|
25 | };
|
26 |
|
27 | Object.entries(resolvedScope).forEach(function (_ref) {
|
28 | var _ref2 = _slicedToArray(_ref, 2),
|
29 | modulePath = _ref2[0],
|
30 | imports = _ref2[1];
|
31 |
|
32 | var possibleValue = allPossibleValues[modulePath];
|
33 |
|
34 | if (possibleValue) {
|
35 |
|
36 | if (possibleValue.ImportDefault && imports.ImportDefault) {
|
37 | addToScope(imports.ImportDefault, possibleValue.ImportDefault);
|
38 | }
|
39 |
|
40 | if (possibleValue.Import) {
|
41 |
|
42 | if (imports.ImportNamespace) {
|
43 | addToScope(imports.ImportNamespace, possibleValue.Import);
|
44 | }
|
45 |
|
46 |
|
47 | if (imports.Import) {
|
48 | Object.entries(imports.Import).forEach(function (_ref3) {
|
49 | var _ref4 = _slicedToArray(_ref3, 2),
|
50 | imported = _ref4[0],
|
51 | importedAs = _ref4[1];
|
52 |
|
53 | if (possibleValue.Import[imported]) {
|
54 | addToScope(importedAs, possibleValue.Import[imported]);
|
55 | }
|
56 | });
|
57 | }
|
58 | }
|
59 | }
|
60 | });
|
61 | return result;
|
62 | };
|
63 |
|
64 | exports.default = _default;
|
65 |
|
\ | No newline at end of file |