@modern-js/plugin-garfish 2.14.0 → 2.16.0
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/CHANGELOG.md +27 -0
- package/dist/cjs/cli/index.js +224 -236
- package/dist/cjs/cli/utils.js +24 -48
- package/dist/cjs/deps/index.js +12 -35
- package/dist/cjs/index.js +26 -36
- package/dist/cjs/runtime/index.js +24 -44
- package/dist/cjs/runtime/loadable.js +46 -58
- package/dist/cjs/runtime/plugin.js +86 -82
- package/dist/cjs/runtime/useModuleApps.js +70 -56
- package/dist/cjs/runtime/utils/Context.js +18 -36
- package/dist/cjs/runtime/utils/MApp.js +88 -87
- package/dist/cjs/runtime/utils/apps.js +114 -94
- package/dist/cjs/runtime/utils/setExternal.js +23 -41
- package/dist/cjs/util.js +21 -40
- package/dist/esm/cli/index.js +409 -402
- package/dist/esm/cli/utils.js +25 -26
- package/dist/esm/deps/index.js +1 -2
- package/dist/esm/index.js +1 -2
- package/dist/esm/runtime/index.js +3 -4
- package/dist/esm/runtime/loadable.js +226 -210
- package/dist/esm/runtime/plugin.js +456 -426
- package/dist/esm/runtime/useModuleApps.js +49 -50
- package/dist/esm/runtime/utils/Context.js +1 -1
- package/dist/esm/runtime/utils/MApp.js +337 -316
- package/dist/esm/runtime/utils/apps.js +468 -442
- package/dist/esm/runtime/utils/setExternal.js +9 -9
- package/dist/esm/util.js +4 -5
- package/dist/esm-node/cli/index.js +209 -219
- package/dist/esm-node/cli/utils.js +15 -30
- package/dist/esm-node/deps/index.js +1 -4
- package/dist/esm-node/index.js +1 -4
- package/dist/esm-node/runtime/index.js +3 -10
- package/dist/esm-node/runtime/loadable.js +34 -31
- package/dist/esm-node/runtime/plugin.js +50 -33
- package/dist/esm-node/runtime/useModuleApps.js +12 -19
- package/dist/esm-node/runtime/utils/Context.js +2 -5
- package/dist/esm-node/runtime/utils/MApp.js +61 -40
- package/dist/esm-node/runtime/utils/apps.js +38 -44
- package/dist/esm-node/runtime/utils/setExternal.js +5 -5
- package/dist/esm-node/util.js +4 -9
- package/package.json +15 -12
|
@@ -1,488 +1,514 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
function _array_like_to_array(arr, len) {
|
|
2
|
+
if (len == null || len > arr.length)
|
|
3
|
+
len = arr.length;
|
|
4
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
5
|
+
arr2[i] = arr[i];
|
|
6
|
+
return arr2;
|
|
5
7
|
}
|
|
6
|
-
function
|
|
7
|
-
|
|
8
|
+
function _array_with_holes(arr) {
|
|
9
|
+
if (Array.isArray(arr))
|
|
10
|
+
return arr;
|
|
8
11
|
}
|
|
9
|
-
function
|
|
10
|
-
|
|
12
|
+
function _array_without_holes(arr) {
|
|
13
|
+
if (Array.isArray(arr))
|
|
14
|
+
return _array_like_to_array(arr);
|
|
11
15
|
}
|
|
12
16
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
try {
|
|
18
|
+
var info = gen[key](arg);
|
|
19
|
+
var value = info.value;
|
|
20
|
+
} catch (error) {
|
|
21
|
+
reject(error);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (info.done) {
|
|
25
|
+
resolve(value);
|
|
26
|
+
} else {
|
|
27
|
+
Promise.resolve(value).then(_next, _throw);
|
|
28
|
+
}
|
|
25
29
|
}
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
30
|
+
function _async_to_generator(fn) {
|
|
31
|
+
return function() {
|
|
32
|
+
var self = this, args = arguments;
|
|
33
|
+
return new Promise(function(resolve, reject) {
|
|
34
|
+
var gen = fn.apply(self, args);
|
|
35
|
+
function _next(value) {
|
|
36
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
37
|
+
}
|
|
38
|
+
function _throw(err) {
|
|
39
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
40
|
+
}
|
|
41
|
+
_next(void 0);
|
|
42
|
+
});
|
|
43
|
+
};
|
|
40
44
|
}
|
|
41
|
-
function
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
45
|
+
function _define_property(obj, key, value) {
|
|
46
|
+
if (key in obj) {
|
|
47
|
+
Object.defineProperty(obj, key, {
|
|
48
|
+
value,
|
|
49
|
+
enumerable: true,
|
|
50
|
+
configurable: true,
|
|
51
|
+
writable: true
|
|
52
|
+
});
|
|
53
|
+
} else {
|
|
54
|
+
obj[key] = value;
|
|
55
|
+
}
|
|
56
|
+
return obj;
|
|
53
57
|
}
|
|
54
|
-
function
|
|
55
|
-
|
|
58
|
+
function _iterable_to_array(iter) {
|
|
59
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
|
|
60
|
+
return Array.from(iter);
|
|
56
61
|
}
|
|
57
|
-
function
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
function _iterable_to_array_limit(arr, i) {
|
|
63
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
64
|
+
if (_i == null)
|
|
65
|
+
return;
|
|
66
|
+
var _arr = [];
|
|
67
|
+
var _n = true;
|
|
68
|
+
var _d = false;
|
|
69
|
+
var _s, _e;
|
|
70
|
+
try {
|
|
71
|
+
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
72
|
+
_arr.push(_s.value);
|
|
73
|
+
if (i && _arr.length === i)
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
} catch (err) {
|
|
77
|
+
_d = true;
|
|
78
|
+
_e = err;
|
|
79
|
+
} finally {
|
|
64
80
|
try {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
_d = true;
|
|
71
|
-
_e = err;
|
|
72
|
-
} finally{
|
|
73
|
-
try {
|
|
74
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
75
|
-
} finally{
|
|
76
|
-
if (_d) throw _e;
|
|
77
|
-
}
|
|
81
|
+
if (!_n && _i["return"] != null)
|
|
82
|
+
_i["return"]();
|
|
83
|
+
} finally {
|
|
84
|
+
if (_d)
|
|
85
|
+
throw _e;
|
|
78
86
|
}
|
|
79
|
-
|
|
87
|
+
}
|
|
88
|
+
return _arr;
|
|
80
89
|
}
|
|
81
|
-
function
|
|
82
|
-
|
|
90
|
+
function _non_iterable_rest() {
|
|
91
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
83
92
|
}
|
|
84
|
-
function
|
|
85
|
-
|
|
93
|
+
function _non_iterable_spread() {
|
|
94
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
86
95
|
}
|
|
87
|
-
function
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
ownKeys.forEach(function(key) {
|
|
97
|
-
_defineProperty(target, key, source[key]);
|
|
98
|
-
});
|
|
96
|
+
function _object_spread(target) {
|
|
97
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
98
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
99
|
+
var ownKeys2 = Object.keys(source);
|
|
100
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
101
|
+
ownKeys2 = ownKeys2.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
102
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
103
|
+
}));
|
|
99
104
|
}
|
|
100
|
-
|
|
105
|
+
ownKeys2.forEach(function(key) {
|
|
106
|
+
_define_property(target, key, source[key]);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
return target;
|
|
101
110
|
}
|
|
102
111
|
function ownKeys(object, enumerableOnly) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
keys.push.apply(keys, symbols);
|
|
112
|
+
var keys = Object.keys(object);
|
|
113
|
+
if (Object.getOwnPropertySymbols) {
|
|
114
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
115
|
+
if (enumerableOnly) {
|
|
116
|
+
symbols = symbols.filter(function(sym) {
|
|
117
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
118
|
+
});
|
|
112
119
|
}
|
|
113
|
-
|
|
120
|
+
keys.push.apply(keys, symbols);
|
|
121
|
+
}
|
|
122
|
+
return keys;
|
|
114
123
|
}
|
|
115
|
-
function
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
124
|
+
function _object_spread_props(target, source) {
|
|
125
|
+
source = source != null ? source : {};
|
|
126
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
127
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
128
|
+
} else {
|
|
129
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
130
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
return target;
|
|
125
134
|
}
|
|
126
|
-
function
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
135
|
+
function _object_without_properties(source, excluded) {
|
|
136
|
+
if (source == null)
|
|
137
|
+
return {};
|
|
138
|
+
var target = _object_without_properties_loose(source, excluded);
|
|
139
|
+
var key, i;
|
|
140
|
+
if (Object.getOwnPropertySymbols) {
|
|
141
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
142
|
+
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
143
|
+
key = sourceSymbolKeys[i];
|
|
144
|
+
if (excluded.indexOf(key) >= 0)
|
|
145
|
+
continue;
|
|
146
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key))
|
|
147
|
+
continue;
|
|
148
|
+
target[key] = source[key];
|
|
138
149
|
}
|
|
139
|
-
|
|
150
|
+
}
|
|
151
|
+
return target;
|
|
140
152
|
}
|
|
141
|
-
function
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
153
|
+
function _object_without_properties_loose(source, excluded) {
|
|
154
|
+
if (source == null)
|
|
155
|
+
return {};
|
|
156
|
+
var target = {};
|
|
157
|
+
var sourceKeys = Object.keys(source);
|
|
158
|
+
var key, i;
|
|
159
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
160
|
+
key = sourceKeys[i];
|
|
161
|
+
if (excluded.indexOf(key) >= 0)
|
|
162
|
+
continue;
|
|
163
|
+
target[key] = source[key];
|
|
164
|
+
}
|
|
165
|
+
return target;
|
|
152
166
|
}
|
|
153
|
-
function
|
|
154
|
-
|
|
167
|
+
function _sliced_to_array(arr, i) {
|
|
168
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
155
169
|
}
|
|
156
|
-
function
|
|
157
|
-
|
|
170
|
+
function _to_consumable_array(arr) {
|
|
171
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
158
172
|
}
|
|
159
|
-
function
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
173
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
174
|
+
if (!o)
|
|
175
|
+
return;
|
|
176
|
+
if (typeof o === "string")
|
|
177
|
+
return _array_like_to_array(o, minLen);
|
|
178
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
179
|
+
if (n === "Object" && o.constructor)
|
|
180
|
+
n = o.constructor.name;
|
|
181
|
+
if (n === "Map" || n === "Set")
|
|
182
|
+
return Array.from(n);
|
|
183
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
|
|
184
|
+
return _array_like_to_array(o, minLen);
|
|
166
185
|
}
|
|
167
|
-
var __generator =
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
186
|
+
var __generator = function(thisArg, body) {
|
|
187
|
+
var f, y, t, g, _ = {
|
|
188
|
+
label: 0,
|
|
189
|
+
sent: function() {
|
|
190
|
+
if (t[0] & 1)
|
|
191
|
+
throw t[1];
|
|
192
|
+
return t[1];
|
|
193
|
+
},
|
|
194
|
+
trys: [],
|
|
195
|
+
ops: []
|
|
196
|
+
};
|
|
197
|
+
return g = {
|
|
198
|
+
next: verb(0),
|
|
199
|
+
"throw": verb(1),
|
|
200
|
+
"return": verb(2)
|
|
201
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
202
|
+
return this;
|
|
203
|
+
}), g;
|
|
204
|
+
function verb(n) {
|
|
205
|
+
return function(v) {
|
|
206
|
+
return step([
|
|
207
|
+
n,
|
|
208
|
+
v
|
|
209
|
+
]);
|
|
176
210
|
};
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
break;
|
|
205
|
-
case 4:
|
|
206
|
-
_.label++;
|
|
207
|
-
return {
|
|
208
|
-
value: op[1],
|
|
209
|
-
done: false
|
|
210
|
-
};
|
|
211
|
-
case 5:
|
|
212
|
-
_.label++;
|
|
213
|
-
y = op[1];
|
|
214
|
-
op = [
|
|
215
|
-
0
|
|
216
|
-
];
|
|
217
|
-
continue;
|
|
218
|
-
case 7:
|
|
219
|
-
op = _.ops.pop();
|
|
220
|
-
_.trys.pop();
|
|
221
|
-
continue;
|
|
222
|
-
default:
|
|
223
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
224
|
-
_ = 0;
|
|
225
|
-
continue;
|
|
226
|
-
}
|
|
227
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
228
|
-
_.label = op[1];
|
|
229
|
-
break;
|
|
230
|
-
}
|
|
231
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
232
|
-
_.label = t[1];
|
|
233
|
-
t = op;
|
|
234
|
-
break;
|
|
235
|
-
}
|
|
236
|
-
if (t && _.label < t[2]) {
|
|
237
|
-
_.label = t[2];
|
|
238
|
-
_.ops.push(op);
|
|
239
|
-
break;
|
|
240
|
-
}
|
|
241
|
-
if (t[2]) _.ops.pop();
|
|
242
|
-
_.trys.pop();
|
|
243
|
-
continue;
|
|
244
|
-
}
|
|
245
|
-
op = body.call(thisArg, _);
|
|
246
|
-
} catch (e) {
|
|
211
|
+
}
|
|
212
|
+
function step(op) {
|
|
213
|
+
if (f)
|
|
214
|
+
throw new TypeError("Generator is already executing.");
|
|
215
|
+
while (_)
|
|
216
|
+
try {
|
|
217
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
|
|
218
|
+
return t;
|
|
219
|
+
if (y = 0, t)
|
|
220
|
+
op = [
|
|
221
|
+
op[0] & 2,
|
|
222
|
+
t.value
|
|
223
|
+
];
|
|
224
|
+
switch (op[0]) {
|
|
225
|
+
case 0:
|
|
226
|
+
case 1:
|
|
227
|
+
t = op;
|
|
228
|
+
break;
|
|
229
|
+
case 4:
|
|
230
|
+
_.label++;
|
|
231
|
+
return {
|
|
232
|
+
value: op[1],
|
|
233
|
+
done: false
|
|
234
|
+
};
|
|
235
|
+
case 5:
|
|
236
|
+
_.label++;
|
|
237
|
+
y = op[1];
|
|
247
238
|
op = [
|
|
248
|
-
|
|
249
|
-
e
|
|
239
|
+
0
|
|
250
240
|
];
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
241
|
+
continue;
|
|
242
|
+
case 7:
|
|
243
|
+
op = _.ops.pop();
|
|
244
|
+
_.trys.pop();
|
|
245
|
+
continue;
|
|
246
|
+
default:
|
|
247
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
248
|
+
_ = 0;
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
252
|
+
_.label = op[1];
|
|
253
|
+
break;
|
|
254
|
+
}
|
|
255
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
256
|
+
_.label = t[1];
|
|
257
|
+
t = op;
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
if (t && _.label < t[2]) {
|
|
261
|
+
_.label = t[2];
|
|
262
|
+
_.ops.push(op);
|
|
263
|
+
break;
|
|
264
|
+
}
|
|
265
|
+
if (t[2])
|
|
266
|
+
_.ops.pop();
|
|
267
|
+
_.trys.pop();
|
|
268
|
+
continue;
|
|
254
269
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
270
|
+
op = body.call(thisArg, _);
|
|
271
|
+
} catch (e) {
|
|
272
|
+
op = [
|
|
273
|
+
6,
|
|
274
|
+
e
|
|
275
|
+
];
|
|
276
|
+
y = 0;
|
|
277
|
+
} finally {
|
|
278
|
+
f = t = 0;
|
|
279
|
+
}
|
|
280
|
+
if (op[0] & 5)
|
|
281
|
+
throw op[1];
|
|
282
|
+
return {
|
|
283
|
+
value: op[0] ? op[1] : void 0,
|
|
284
|
+
done: true
|
|
285
|
+
};
|
|
286
|
+
}
|
|
261
287
|
};
|
|
262
|
-
import {
|
|
288
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
263
289
|
import { useContext, useState, useEffect, useRef } from "react";
|
|
264
290
|
import { RuntimeReactContext } from "@modern-js/runtime";
|
|
265
291
|
import Garfish from "garfish";
|
|
266
292
|
import { logger, generateSubAppContainerKey } from "../../util";
|
|
267
293
|
import { Loadable } from "../loadable";
|
|
268
|
-
function pathJoin() {
|
|
269
|
-
|
|
270
|
-
|
|
294
|
+
export function pathJoin() {
|
|
295
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
296
|
+
args[_key] = arguments[_key];
|
|
297
|
+
}
|
|
298
|
+
var res = args.reduce(function(res2, path) {
|
|
299
|
+
var nPath = path;
|
|
300
|
+
if (!nPath || typeof nPath !== "string") {
|
|
301
|
+
return res2;
|
|
271
302
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
nPath = nPath.substring(0, lastIndex);
|
|
283
|
-
}
|
|
284
|
-
return res2 + nPath;
|
|
285
|
-
}, "");
|
|
286
|
-
return res || "/";
|
|
303
|
+
if (nPath[0] !== "/") {
|
|
304
|
+
nPath = "/".concat(nPath);
|
|
305
|
+
}
|
|
306
|
+
var lastIndex = nPath.length - 1;
|
|
307
|
+
if (nPath[lastIndex] === "/") {
|
|
308
|
+
nPath = nPath.substring(0, lastIndex);
|
|
309
|
+
}
|
|
310
|
+
return res2 + nPath;
|
|
311
|
+
}, "");
|
|
312
|
+
return res || "/";
|
|
287
313
|
}
|
|
288
314
|
function getAppInstance(options, appInfo, manifest) {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
315
|
+
var MicroApp = function MicroApp2(props) {
|
|
316
|
+
var _context_router, _context_router_useRouteMatch, _context_router1, _context_router_useMatches, _context_router2, _context_router_useLocation;
|
|
317
|
+
var appRef = useRef(null);
|
|
318
|
+
var domId = generateSubAppContainerKey(appInfo);
|
|
319
|
+
var _useState = _sliced_to_array(useState(), 2), SubModuleComponent = _useState[0], setSubModuleComponent = _useState[1];
|
|
320
|
+
var context = useContext(RuntimeReactContext);
|
|
321
|
+
var match = context === null || context === void 0 ? void 0 : (_context_router = context.router) === null || _context_router === void 0 ? void 0 : (_context_router_useRouteMatch = _context_router.useRouteMatch) === null || _context_router_useRouteMatch === void 0 ? void 0 : _context_router_useRouteMatch.call(_context_router);
|
|
322
|
+
var matchs = context === null || context === void 0 ? void 0 : (_context_router1 = context.router) === null || _context_router1 === void 0 ? void 0 : (_context_router_useMatches = _context_router1.useMatches) === null || _context_router_useMatches === void 0 ? void 0 : _context_router_useMatches.call(_context_router1);
|
|
323
|
+
var location = context === null || context === void 0 ? void 0 : (_context_router2 = context.router) === null || _context_router2 === void 0 ? void 0 : (_context_router_useLocation = _context_router2.useLocation) === null || _context_router_useLocation === void 0 ? void 0 : _context_router_useLocation.call(_context_router2);
|
|
324
|
+
var basename = (options === null || options === void 0 ? void 0 : options.basename) || "/";
|
|
325
|
+
if (matchs && matchs.length > 0) {
|
|
326
|
+
var matchItem = _object_spread({}, matchs[matchs.length - 1]);
|
|
327
|
+
for (var key in matchItem.params) {
|
|
328
|
+
matchItem.pathname = matchItem.pathname.replace(new RegExp("/".concat(matchItem.params[key], "$")), "");
|
|
329
|
+
}
|
|
330
|
+
basename = pathJoin(basename, matchItem.pathname || "/");
|
|
331
|
+
} else if (match) {
|
|
332
|
+
basename = pathJoin(basename, (match === null || match === void 0 ? void 0 : match.path) || "/");
|
|
333
|
+
}
|
|
334
|
+
useEffect(function() {
|
|
335
|
+
if (location && locationHref !== location.pathname && !Garfish.running) {
|
|
336
|
+
locationHref = location.pathname;
|
|
337
|
+
var popStateEvent = new PopStateEvent("popstate");
|
|
338
|
+
popStateEvent.garfish = true;
|
|
339
|
+
dispatchEvent(popStateEvent);
|
|
340
|
+
logger("MicroApp Garfish.loadApp popstate");
|
|
341
|
+
}
|
|
342
|
+
}, [
|
|
343
|
+
location
|
|
344
|
+
]);
|
|
345
|
+
useEffect(function() {
|
|
346
|
+
var setLoadingState = props.setLoadingState, userProps = _object_without_properties(props, [
|
|
347
|
+
"setLoadingState"
|
|
348
|
+
]);
|
|
349
|
+
var loadAppOptions = _object_spread_props(_object_spread({}, appInfo), {
|
|
350
|
+
insulationVariable: _to_consumable_array(appInfo.insulationVariable || []).concat([
|
|
351
|
+
"_SERVER_DATA"
|
|
352
|
+
]),
|
|
353
|
+
domGetter: "#".concat(domId),
|
|
354
|
+
basename,
|
|
355
|
+
cache: true,
|
|
356
|
+
props: _object_spread({}, appInfo.props, userProps),
|
|
357
|
+
customLoader: function(provider) {
|
|
358
|
+
var render = provider.render, destroy = provider.destroy, SubModuleComponent2 = provider.SubModuleComponent, jupiter_submodule_app_key = provider.jupiter_submodule_app_key;
|
|
359
|
+
var componetRenderMode = (manifest === null || manifest === void 0 ? void 0 : manifest.componentRender) && (SubModuleComponent2 || jupiter_submodule_app_key);
|
|
360
|
+
return {
|
|
361
|
+
mount: function() {
|
|
362
|
+
for (var _len = arguments.length, _$props = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
363
|
+
_$props[_key] = arguments[_key];
|
|
364
|
+
}
|
|
365
|
+
if (componetRenderMode) {
|
|
366
|
+
setSubModuleComponent(SubModuleComponent2);
|
|
367
|
+
return void 0;
|
|
368
|
+
} else {
|
|
369
|
+
logger("MicroApp customer render", _$props);
|
|
370
|
+
return render === null || render === void 0 ? void 0 : render.apply(provider, _$props);
|
|
371
|
+
}
|
|
372
|
+
},
|
|
373
|
+
unmount: function unmount() {
|
|
374
|
+
for (var _len = arguments.length, _$props = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
375
|
+
_$props[_key] = arguments[_key];
|
|
376
|
+
}
|
|
377
|
+
if (componetRenderMode) {
|
|
378
|
+
return void 0;
|
|
379
|
+
}
|
|
380
|
+
logger("MicroApp customer destroy", _$props);
|
|
381
|
+
return destroy === null || destroy === void 0 ? void 0 : destroy.apply(provider, _$props);
|
|
303
382
|
}
|
|
304
|
-
|
|
305
|
-
} else if (match) {
|
|
306
|
-
basename = pathJoin(basename, (match === null || match === void 0 ? void 0 : match.path) || "/");
|
|
383
|
+
};
|
|
307
384
|
}
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
if (componetRenderMode) {
|
|
340
|
-
setSubModuleComponent(SubModuleComponent2);
|
|
341
|
-
return void 0;
|
|
342
|
-
} else {
|
|
343
|
-
logger("MicroApp customer render", props2);
|
|
344
|
-
return render === null || render === void 0 ? void 0 : render.apply(provider, props2);
|
|
345
|
-
}
|
|
346
|
-
},
|
|
347
|
-
unmount: function unmount() {
|
|
348
|
-
for(var _len = arguments.length, props2 = new Array(_len), _key = 0; _key < _len; _key++){
|
|
349
|
-
props2[_key] = arguments[_key];
|
|
350
|
-
}
|
|
351
|
-
if (componetRenderMode) {
|
|
352
|
-
return void 0;
|
|
353
|
-
}
|
|
354
|
-
logger("MicroApp customer destroy", props2);
|
|
355
|
-
return destroy === null || destroy === void 0 ? void 0 : destroy.apply(provider, props2);
|
|
356
|
-
}
|
|
357
|
-
};
|
|
385
|
+
});
|
|
386
|
+
setLoadingState({
|
|
387
|
+
isLoading: true,
|
|
388
|
+
error: null
|
|
389
|
+
});
|
|
390
|
+
logger('MicroApp Garfish.loadApp "'.concat(appInfo.name, '"'), {
|
|
391
|
+
loadAppOptions
|
|
392
|
+
});
|
|
393
|
+
function renderApp() {
|
|
394
|
+
return _renderApp.apply(this, arguments);
|
|
395
|
+
}
|
|
396
|
+
function _renderApp() {
|
|
397
|
+
_renderApp = _async_to_generator(function() {
|
|
398
|
+
var appInstance, error;
|
|
399
|
+
return __generator(this, function(_state) {
|
|
400
|
+
switch (_state.label) {
|
|
401
|
+
case 0:
|
|
402
|
+
_state.trys.push([
|
|
403
|
+
0,
|
|
404
|
+
6,
|
|
405
|
+
,
|
|
406
|
+
7
|
|
407
|
+
]);
|
|
408
|
+
return [
|
|
409
|
+
4,
|
|
410
|
+
Garfish.loadApp(appInfo.name, loadAppOptions)
|
|
411
|
+
];
|
|
412
|
+
case 1:
|
|
413
|
+
appInstance = _state.sent();
|
|
414
|
+
if (!appInstance) {
|
|
415
|
+
throw new Error('MicroApp Garfish.loadApp "'.concat(appInfo.name, '" result is null'));
|
|
358
416
|
}
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
case 1:
|
|
387
|
-
appInstance = _state.sent();
|
|
388
|
-
if (!appInstance) {
|
|
389
|
-
throw new Error('MicroApp Garfish.loadApp "'.concat(appInfo.name, '" result is null'));
|
|
390
|
-
}
|
|
391
|
-
appRef.current = appInstance;
|
|
392
|
-
setLoadingState({
|
|
393
|
-
isLoading: false
|
|
394
|
-
});
|
|
395
|
-
if (!(appInstance.mounted && appInstance.appInfo.cache)) return [
|
|
396
|
-
3,
|
|
397
|
-
3
|
|
398
|
-
];
|
|
399
|
-
logger('MicroApp Garfish.loadApp "'.concat(appInfo.name, '" show'), {
|
|
400
|
-
appInfo: appInstance.appInfo,
|
|
401
|
-
appInstance: appInstance
|
|
402
|
-
});
|
|
403
|
-
return [
|
|
404
|
-
4,
|
|
405
|
-
appInstance === null || appInstance === void 0 ? void 0 : appInstance.show()
|
|
406
|
-
];
|
|
407
|
-
case 2:
|
|
408
|
-
_state.sent();
|
|
409
|
-
return [
|
|
410
|
-
3,
|
|
411
|
-
5
|
|
412
|
-
];
|
|
413
|
-
case 3:
|
|
414
|
-
logger('MicroApp Garfish.loadApp "'.concat(appInfo.name, '" mount'), {
|
|
415
|
-
appInfo: appInstance.appInfo,
|
|
416
|
-
appInstance: appInstance
|
|
417
|
-
});
|
|
418
|
-
return [
|
|
419
|
-
4,
|
|
420
|
-
appInstance === null || appInstance === void 0 ? void 0 : appInstance.mount()
|
|
421
|
-
];
|
|
422
|
-
case 4:
|
|
423
|
-
_state.sent();
|
|
424
|
-
_state.label = 5;
|
|
425
|
-
case 5:
|
|
426
|
-
return [
|
|
427
|
-
3,
|
|
428
|
-
7
|
|
429
|
-
];
|
|
430
|
-
case 6:
|
|
431
|
-
error = _state.sent();
|
|
432
|
-
setLoadingState({
|
|
433
|
-
isLoading: true,
|
|
434
|
-
error: error
|
|
435
|
-
});
|
|
436
|
-
return [
|
|
437
|
-
3,
|
|
438
|
-
7
|
|
439
|
-
];
|
|
440
|
-
case 7:
|
|
441
|
-
return [
|
|
442
|
-
2
|
|
443
|
-
];
|
|
444
|
-
}
|
|
445
|
-
});
|
|
417
|
+
appRef.current = appInstance;
|
|
418
|
+
setLoadingState({
|
|
419
|
+
isLoading: false
|
|
420
|
+
});
|
|
421
|
+
if (!(appInstance.mounted && appInstance.appInfo.cache))
|
|
422
|
+
return [
|
|
423
|
+
3,
|
|
424
|
+
3
|
|
425
|
+
];
|
|
426
|
+
logger('MicroApp Garfish.loadApp "'.concat(appInfo.name, '" show'), {
|
|
427
|
+
appInfo: appInstance.appInfo,
|
|
428
|
+
appInstance
|
|
429
|
+
});
|
|
430
|
+
return [
|
|
431
|
+
4,
|
|
432
|
+
appInstance === null || appInstance === void 0 ? void 0 : appInstance.show()
|
|
433
|
+
];
|
|
434
|
+
case 2:
|
|
435
|
+
_state.sent();
|
|
436
|
+
return [
|
|
437
|
+
3,
|
|
438
|
+
5
|
|
439
|
+
];
|
|
440
|
+
case 3:
|
|
441
|
+
logger('MicroApp Garfish.loadApp "'.concat(appInfo.name, '" mount'), {
|
|
442
|
+
appInfo: appInstance.appInfo,
|
|
443
|
+
appInstance
|
|
446
444
|
});
|
|
447
|
-
return
|
|
445
|
+
return [
|
|
446
|
+
4,
|
|
447
|
+
appInstance === null || appInstance === void 0 ? void 0 : appInstance.mount()
|
|
448
|
+
];
|
|
449
|
+
case 4:
|
|
450
|
+
_state.sent();
|
|
451
|
+
_state.label = 5;
|
|
452
|
+
case 5:
|
|
453
|
+
return [
|
|
454
|
+
3,
|
|
455
|
+
7
|
|
456
|
+
];
|
|
457
|
+
case 6:
|
|
458
|
+
error = _state.sent();
|
|
459
|
+
setLoadingState({
|
|
460
|
+
isLoading: true,
|
|
461
|
+
error
|
|
462
|
+
});
|
|
463
|
+
return [
|
|
464
|
+
3,
|
|
465
|
+
7
|
|
466
|
+
];
|
|
467
|
+
case 7:
|
|
468
|
+
return [
|
|
469
|
+
2
|
|
470
|
+
];
|
|
448
471
|
}
|
|
449
|
-
|
|
450
|
-
return function() {
|
|
451
|
-
if (appRef.current) {
|
|
452
|
-
var _appRef_current = appRef.current, appInfo2 = _appRef_current.appInfo;
|
|
453
|
-
if (appInfo2.cache) {
|
|
454
|
-
var _appRef_current1;
|
|
455
|
-
logger('MicroApp Garfish.loadApp "'.concat(appInfo2.name, '" hide'));
|
|
456
|
-
(_appRef_current1 = appRef.current) === null || _appRef_current1 === void 0 ? void 0 : _appRef_current1.hide();
|
|
457
|
-
} else {
|
|
458
|
-
var _appRef_current2;
|
|
459
|
-
logger('MicroApp Garfish.loadApp "'.concat(appInfo2.name, '" unmount'));
|
|
460
|
-
(_appRef_current2 = appRef.current) === null || _appRef_current2 === void 0 ? void 0 : _appRef_current2.unmount();
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
};
|
|
464
|
-
}, []);
|
|
465
|
-
return /* @__PURE__ */ jsx(Fragment, {
|
|
466
|
-
children: /* @__PURE__ */ jsx("div", {
|
|
467
|
-
id: domId,
|
|
468
|
-
children: SubModuleComponent && /* @__PURE__ */ jsx(SubModuleComponent, {})
|
|
469
|
-
})
|
|
472
|
+
});
|
|
470
473
|
});
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
474
|
+
return _renderApp.apply(this, arguments);
|
|
475
|
+
}
|
|
476
|
+
renderApp();
|
|
477
|
+
return function() {
|
|
478
|
+
if (appRef.current) {
|
|
479
|
+
var _$appInfo = appRef.current.appInfo;
|
|
480
|
+
if (_$appInfo.cache) {
|
|
481
|
+
var _appRef_current;
|
|
482
|
+
logger('MicroApp Garfish.loadApp "'.concat(_$appInfo.name, '" hide'));
|
|
483
|
+
(_appRef_current = appRef.current) === null || _appRef_current === void 0 ? void 0 : _appRef_current.hide();
|
|
484
|
+
} else {
|
|
485
|
+
var _appRef_current1;
|
|
486
|
+
logger('MicroApp Garfish.loadApp "'.concat(_$appInfo.name, '" unmount'));
|
|
487
|
+
(_appRef_current1 = appRef.current) === null || _appRef_current1 === void 0 ? void 0 : _appRef_current1.unmount();
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
};
|
|
491
|
+
}, []);
|
|
492
|
+
return /* @__PURE__ */ _jsx(_Fragment, {
|
|
493
|
+
children: /* @__PURE__ */ _jsx("div", {
|
|
494
|
+
id: domId,
|
|
495
|
+
children: SubModuleComponent && /* @__PURE__ */ _jsx(SubModuleComponent, {})
|
|
496
|
+
})
|
|
482
497
|
});
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
498
|
+
};
|
|
499
|
+
var locationHref = "";
|
|
500
|
+
return Loadable(MicroApp)(manifest === null || manifest === void 0 ? void 0 : manifest.loadable);
|
|
501
|
+
}
|
|
502
|
+
export function generateApps(options, manifest) {
|
|
503
|
+
var _options_apps;
|
|
504
|
+
var apps = {};
|
|
505
|
+
(_options_apps = options.apps) === null || _options_apps === void 0 ? void 0 : _options_apps.forEach(function(appInfo) {
|
|
506
|
+
var Component = getAppInstance(options, appInfo, manifest);
|
|
507
|
+
appInfo.Component = Component;
|
|
508
|
+
apps[appInfo.name] = Component;
|
|
509
|
+
});
|
|
510
|
+
return {
|
|
511
|
+
apps,
|
|
512
|
+
appInfoList: options.apps || []
|
|
513
|
+
};
|
|
487
514
|
}
|
|
488
|
-
export { generateApps, pathJoin };
|