@module-federation/utilities 1.1.1 → 1.2.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 +24 -0
- package/package.json +4 -3
- package/src/types/index.d.ts +5 -0
- package/src/utils/common.d.ts +15 -4
- package/src/utils/common.js +115 -37
- package/src/utils/common.js.map +1 -1
- package/src/utils/importRemote.js +7 -6
- package/src/utils/importRemote.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,30 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
# [1.2.0](https://github.com/module-federation/nextjs-mf/compare/utils-1.1.2...utils-1.2.0) (2023-01-31)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **typescript:** throw error when `vue-tsc` is requested and is not available ([#547](https://github.com/module-federation/nextjs-mf/issues/547)) ([c6f7998](https://github.com/module-federation/nextjs-mf/commit/c6f79981f84fd0042447037c1323fa750566ac0d))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* add getModule and getContainer to utilities ([#476](https://github.com/module-federation/nextjs-mf/issues/476)) ([fe381e3](https://github.com/module-federation/nextjs-mf/commit/fe381e33cfb20b3b723daffca2f5c4fb4b843cfb))
|
|
16
|
+
* **typescript:** support vue typescript compiler ([#542](https://github.com/module-federation/nextjs-mf/issues/542)) ([cde5952](https://github.com/module-federation/nextjs-mf/commit/cde5952c42ec19f87c5bc4dddb8d8be6f97c1c55)), closes [#502](https://github.com/module-federation/nextjs-mf/issues/502)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
## [1.1.2](https://github.com/module-federation/nextjs-mf/compare/utils-1.1.1...utils-1.1.2) (2023-01-21)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Bug Fixes
|
|
24
|
+
|
|
25
|
+
* Utilities - Remove module side effect ([#488](https://github.com/module-federation/nextjs-mf/issues/488)) ([3554de7](https://github.com/module-federation/nextjs-mf/commit/3554de7912eaf7b379a6a863677c4b01da0ccf2c)), closes [#487](https://github.com/module-federation/nextjs-mf/issues/487) [#500](https://github.com/module-federation/nextjs-mf/issues/500) [#496](https://github.com/module-federation/nextjs-mf/issues/496) [#495](https://github.com/module-federation/nextjs-mf/issues/495) [#492](https://github.com/module-federation/nextjs-mf/issues/492) [#455](https://github.com/module-federation/nextjs-mf/issues/455) [#491](https://github.com/module-federation/nextjs-mf/issues/491) [#496](https://github.com/module-federation/nextjs-mf/issues/496) [#495](https://github.com/module-federation/nextjs-mf/issues/495)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
5
29
|
## [1.1.1](https://github.com/module-federation/nextjs-mf/compare/utils-1.1.0...utils-1.1.1) (2023-01-11)
|
|
6
30
|
|
|
7
31
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/utilities",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -15,10 +15,11 @@
|
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"react": "18.2.0",
|
|
18
|
-
"next": "13.
|
|
18
|
+
"next": "13.1.6"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
|
-
"webpack": "^5.40.0"
|
|
21
|
+
"webpack": "^5.40.0",
|
|
22
|
+
"next": "13.1.6"
|
|
22
23
|
},
|
|
23
24
|
"dependencies": {
|
|
24
25
|
"tslib": "2.4.0"
|
package/src/types/index.d.ts
CHANGED
|
@@ -58,4 +58,9 @@ export declare type Loader = Extract<RuleSetRule['use'], {
|
|
|
58
58
|
export declare type EventTypes = 'loadStart' | 'loadComplete' | 'loadError';
|
|
59
59
|
declare type NextRoute = string;
|
|
60
60
|
export declare type PageMap = Record<NextRoute, ModulePath>;
|
|
61
|
+
export declare type GetModuleOptions = {
|
|
62
|
+
modulePath: string;
|
|
63
|
+
exportName?: string;
|
|
64
|
+
remoteContainer: string | RemoteData;
|
|
65
|
+
};
|
|
61
66
|
export {};
|
package/src/utils/common.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import type { Remotes,
|
|
1
|
+
import type { Remotes, RuntimeRemote, WebpackRemoteContainer, RemoteData, GetModuleOptions } from '../types';
|
|
2
2
|
export declare const extractUrlAndGlobal: (urlAndGlobal: string) => [string, string];
|
|
3
|
-
export declare const runtimeRemotes: RuntimeRemotesMap;
|
|
4
|
-
export declare const remotes: RuntimeRemotesMap;
|
|
5
3
|
/**
|
|
6
4
|
* Return initialized remote container by remote's key or its runtime remote item data.
|
|
7
5
|
*
|
|
@@ -10,5 +8,18 @@ export declare const remotes: RuntimeRemotesMap;
|
|
|
10
8
|
* or
|
|
11
9
|
* { asyncContainer } - async container is a promise that resolves to the remote container
|
|
12
10
|
*/
|
|
13
|
-
export declare const injectScript: (keyOrRuntimeRemoteItem: string | RuntimeRemote) => Promise<
|
|
11
|
+
export declare const injectScript: (keyOrRuntimeRemoteItem: string | RuntimeRemote) => Promise<WebpackRemoteContainer>;
|
|
14
12
|
export declare const createRuntimeVariables: (remotes: Remotes) => Record<string, string>;
|
|
13
|
+
/**
|
|
14
|
+
* Returns initialized webpack RemoteContainer.
|
|
15
|
+
* If its' script does not loaded - then load & init it firstly.
|
|
16
|
+
*/
|
|
17
|
+
export declare const getContainer: (remoteContainer: string | RemoteData) => Promise<WebpackRemoteContainer | undefined>;
|
|
18
|
+
/**
|
|
19
|
+
* Return remote module from container.
|
|
20
|
+
* If you provide `exportName` it automatically return exact property value from module.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* remote.getModule('./pages/index', 'default')
|
|
24
|
+
*/
|
|
25
|
+
export declare const getModule: ({ remoteContainer, modulePath, exportName, }: GetModuleOptions) => Promise<any>;
|
package/src/utils/common.js
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.
|
|
5
|
-
var
|
|
6
|
-
try {
|
|
7
|
-
// @ts-ignore
|
|
8
|
-
remoteVars = (process.env.REMOTES || {});
|
|
9
|
-
}
|
|
10
|
-
catch (e) {
|
|
11
|
-
console.error('Error parsing REMOTES environment variable', e);
|
|
12
|
-
}
|
|
4
|
+
exports.getModule = exports.getContainer = exports.createRuntimeVariables = exports.injectScript = exports.extractUrlAndGlobal = void 0;
|
|
5
|
+
var tslib_1 = require("tslib");
|
|
13
6
|
// split the @ syntax into url and global
|
|
14
7
|
var extractUrlAndGlobal = function (urlAndGlobal) {
|
|
15
8
|
var index = urlAndGlobal.indexOf('@');
|
|
@@ -19,31 +12,35 @@ var extractUrlAndGlobal = function (urlAndGlobal) {
|
|
|
19
12
|
return [urlAndGlobal.substring(index + 1), urlAndGlobal.substring(0, index)];
|
|
20
13
|
};
|
|
21
14
|
exports.extractUrlAndGlobal = extractUrlAndGlobal;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
15
|
+
var getRuntimeRemotes = function () {
|
|
16
|
+
//@ts-ignore
|
|
17
|
+
var remoteVars = (process.env.REMOTES || {});
|
|
18
|
+
var runtimeRemotes = Object.entries(remoteVars).reduce(function (acc, item) {
|
|
19
|
+
var key = item[0], value = item[1];
|
|
20
|
+
// if its an object with a thenable (eagerly executing function)
|
|
21
|
+
if (typeof value === 'object' && typeof value.then === 'function') {
|
|
22
|
+
acc[key] = { asyncContainer: value };
|
|
23
|
+
}
|
|
24
|
+
// if its a function that must be called (lazily executing function)
|
|
25
|
+
else if (typeof value === 'function') {
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
acc[key] = { asyncContainer: value };
|
|
28
|
+
}
|
|
29
|
+
// if its just a string (global@url)
|
|
30
|
+
else if (typeof value === 'string') {
|
|
31
|
+
var _a = (0, exports.extractUrlAndGlobal)(value), url = _a[0], global_1 = _a[1];
|
|
32
|
+
acc[key] = { global: global_1, url: url };
|
|
33
|
+
}
|
|
34
|
+
// we dont know or currently support this type
|
|
35
|
+
else {
|
|
36
|
+
//@ts-ignore
|
|
37
|
+
console.log('remotes process', process.env.REMOTES);
|
|
38
|
+
throw new Error("[mf] Invalid value received for runtime_remote \"".concat(key, "\""));
|
|
39
|
+
}
|
|
40
|
+
return acc;
|
|
41
|
+
}, {});
|
|
42
|
+
return runtimeRemotes;
|
|
43
|
+
};
|
|
47
44
|
/**
|
|
48
45
|
* Return initialized remote container by remote's key or its runtime remote item data.
|
|
49
46
|
*
|
|
@@ -53,14 +50,18 @@ exports.remotes = exports.runtimeRemotes;
|
|
|
53
50
|
* { asyncContainer } - async container is a promise that resolves to the remote container
|
|
54
51
|
*/
|
|
55
52
|
var injectScript = function (keyOrRuntimeRemoteItem) {
|
|
53
|
+
var runtimeRemotes = getRuntimeRemotes();
|
|
56
54
|
// 1) Load remote container if needed
|
|
57
55
|
var asyncContainer;
|
|
58
56
|
var reference = typeof keyOrRuntimeRemoteItem === 'string'
|
|
59
|
-
?
|
|
57
|
+
? runtimeRemotes[keyOrRuntimeRemoteItem]
|
|
60
58
|
: keyOrRuntimeRemoteItem;
|
|
61
59
|
if (reference.asyncContainer) {
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
asyncContainer =
|
|
61
|
+
typeof reference.asyncContainer.then === 'function'
|
|
62
|
+
? reference.asyncContainer
|
|
63
|
+
: // @ts-ignore
|
|
64
|
+
reference.asyncContainer();
|
|
64
65
|
}
|
|
65
66
|
else {
|
|
66
67
|
// This casting is just to satisfy typescript,
|
|
@@ -154,4 +155,81 @@ var createRuntimeVariables = function (remotes) {
|
|
|
154
155
|
}, {});
|
|
155
156
|
};
|
|
156
157
|
exports.createRuntimeVariables = createRuntimeVariables;
|
|
158
|
+
/**
|
|
159
|
+
* Returns initialized webpack RemoteContainer.
|
|
160
|
+
* If its' script does not loaded - then load & init it firstly.
|
|
161
|
+
*/
|
|
162
|
+
var getContainer = function (remoteContainer) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
163
|
+
var container;
|
|
164
|
+
return tslib_1.__generator(this, function (_a) {
|
|
165
|
+
switch (_a.label) {
|
|
166
|
+
case 0:
|
|
167
|
+
if (!remoteContainer) {
|
|
168
|
+
throw Error("Remote container options is empty");
|
|
169
|
+
}
|
|
170
|
+
if (!(typeof remoteContainer === 'string')) return [3 /*break*/, 1];
|
|
171
|
+
if (window[remoteContainer]) {
|
|
172
|
+
return [2 /*return*/, window[remoteContainer]];
|
|
173
|
+
}
|
|
174
|
+
return [2 /*return*/];
|
|
175
|
+
case 1:
|
|
176
|
+
if (window['uniqueKey']) {
|
|
177
|
+
return [2 /*return*/, window['uniqueKey']];
|
|
178
|
+
}
|
|
179
|
+
return [4 /*yield*/, (0, exports.injectScript)({
|
|
180
|
+
global: remoteContainer.global,
|
|
181
|
+
url: remoteContainer.url,
|
|
182
|
+
})];
|
|
183
|
+
case 2:
|
|
184
|
+
container = _a.sent();
|
|
185
|
+
if (container) {
|
|
186
|
+
return [2 /*return*/, container];
|
|
187
|
+
}
|
|
188
|
+
throw Error("Remote container ".concat(remoteContainer.url, " is empty"));
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
}); };
|
|
192
|
+
exports.getContainer = getContainer;
|
|
193
|
+
/**
|
|
194
|
+
* Return remote module from container.
|
|
195
|
+
* If you provide `exportName` it automatically return exact property value from module.
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* remote.getModule('./pages/index', 'default')
|
|
199
|
+
*/
|
|
200
|
+
var getModule = function (_a) {
|
|
201
|
+
var remoteContainer = _a.remoteContainer, modulePath = _a.modulePath, exportName = _a.exportName;
|
|
202
|
+
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
203
|
+
var container, modFactory, mod, error_1;
|
|
204
|
+
return tslib_1.__generator(this, function (_b) {
|
|
205
|
+
switch (_b.label) {
|
|
206
|
+
case 0: return [4 /*yield*/, (0, exports.getContainer)(remoteContainer)];
|
|
207
|
+
case 1:
|
|
208
|
+
container = _b.sent();
|
|
209
|
+
_b.label = 2;
|
|
210
|
+
case 2:
|
|
211
|
+
_b.trys.push([2, 4, , 5]);
|
|
212
|
+
return [4 /*yield*/, (container === null || container === void 0 ? void 0 : container.get(modulePath))];
|
|
213
|
+
case 3:
|
|
214
|
+
modFactory = _b.sent();
|
|
215
|
+
if (!modFactory)
|
|
216
|
+
return [2 /*return*/, undefined];
|
|
217
|
+
mod = modFactory();
|
|
218
|
+
if (exportName) {
|
|
219
|
+
return [2 /*return*/, mod && typeof mod === 'object' ? mod[exportName] : undefined];
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
return [2 /*return*/, mod];
|
|
223
|
+
}
|
|
224
|
+
return [3 /*break*/, 5];
|
|
225
|
+
case 4:
|
|
226
|
+
error_1 = _b.sent();
|
|
227
|
+
console.log(error_1);
|
|
228
|
+
return [2 /*return*/, undefined];
|
|
229
|
+
case 5: return [2 /*return*/];
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
};
|
|
234
|
+
exports.getModule = getModule;
|
|
157
235
|
//# sourceMappingURL=common.js.map
|
package/src/utils/common.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../../../packages/utilities/src/utils/common.ts"],"names":[],"mappings":";AAAA,sDAAsD
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../../../packages/utilities/src/utils/common.ts"],"names":[],"mappings":";AAAA,sDAAsD;;;;AAmBtD,yCAAyC;AAClC,IAAM,mBAAmB,GAAG,UAAC,YAAoB;IACtD,IAAM,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACxC,IAAI,KAAK,IAAI,CAAC,IAAI,KAAK,KAAK,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;QACnD,MAAM,IAAI,KAAK,CAAC,4BAAoB,YAAY,OAAG,CAAC,CAAC;KACtD;IACD,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC,KAAK,GAAG,CAAC,CAAC,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;AAC/E,CAAC,CAAC;AANW,QAAA,mBAAmB,uBAM9B;AAEF,IAAM,iBAAiB,GAAG;IACxB,YAAY;IACZ,IAAM,UAAU,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,EAAE,CAAe,CAAC;IAE7D,IAAM,cAAc,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,UACvD,GAAG,EACH,IAAI;QAEG,IAAA,GAAG,GAAW,IAAI,GAAf,EAAE,KAAK,GAAI,IAAI,GAAR,CAAS;QAC1B,gEAAgE;QAChE,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,UAAU,EAAE;YACjE,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC;SACtC;QACD,oEAAoE;aAC/D,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE;YACpC,aAAa;YACb,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,c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AY,EAAC,eAAe,CAAC,EAAA;;oBAA/C,SAAS,GAAG,SAAmC;;;;oBAEhC,qBAAM,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,GAAG,CAAC,UAAU,CAAC,CAAA,EAAA;;oBAA7C,UAAU,GAAG,SAAgC;oBACnD,IAAI,CAAC,UAAU;wBAAE,sBAAO,SAAS,EAAC;oBAC5B,GAAG,GAAG,UAAU,EAAE,CAAC;oBACzB,IAAI,UAAU,EAAE;wBACd,sBAAO,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,EAAC;qBACrE;yBAAM;wBACL,sBAAO,GAAG,EAAC;qBACZ;;;;oBAED,OAAO,CAAC,GAAG,CAAC,OAAK,CAAC,CAAC;oBACnB,sBAAO,SAAS,EAAC;;;;;CAEpB,CAAC;AAnBW,QAAA,SAAS,aAmBpB"}
|
|
@@ -68,11 +68,12 @@ var initContainer = function (containerScope) { return tslib_1.__awaiter(void 0,
|
|
|
68
68
|
var importRemote = function (_a) {
|
|
69
69
|
var url = _a.url, scope = _a.scope, module = _a.module, _b = _a.remoteEntryFileName, remoteEntryFileName = _b === void 0 ? REMOTE_ENTRY_FILE : _b, _c = _a.bustRemoteEntryCache, bustRemoteEntryCache = _c === void 0 ? true : _c;
|
|
70
70
|
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
71
|
-
var remoteUrl, _d, moduleFactory, moduleFactory;
|
|
71
|
+
var remoteScope, remoteUrl, _d, moduleFactory, moduleFactory;
|
|
72
72
|
return tslib_1.__generator(this, function (_e) {
|
|
73
73
|
switch (_e.label) {
|
|
74
74
|
case 0:
|
|
75
|
-
|
|
75
|
+
remoteScope = scope;
|
|
76
|
+
if (!!window[remoteScope]) return [3 /*break*/, 6];
|
|
76
77
|
remoteUrl = '';
|
|
77
78
|
if (!(typeof url === 'string')) return [3 /*break*/, 1];
|
|
78
79
|
remoteUrl = url;
|
|
@@ -90,17 +91,17 @@ var importRemote = function (_a) {
|
|
|
90
91
|
case 4:
|
|
91
92
|
// Load the remote and initialize the share scope if it's empty
|
|
92
93
|
_e.sent();
|
|
93
|
-
if (!window[
|
|
94
|
+
if (!window[remoteScope]) {
|
|
94
95
|
throw new Error("Remote loaded successfully but ".concat(scope, " could not be found! Verify that the name is correct in the Webpack configuration!"));
|
|
95
96
|
}
|
|
96
97
|
return [4 /*yield*/, Promise.all([
|
|
97
|
-
initContainer(window[
|
|
98
|
-
window[
|
|
98
|
+
initContainer(window[remoteScope]),
|
|
99
|
+
window[remoteScope].get(module.startsWith('./') ? module : "./".concat(module)),
|
|
99
100
|
])];
|
|
100
101
|
case 5:
|
|
101
102
|
_d = _e.sent(), moduleFactory = _d[1];
|
|
102
103
|
return [2 /*return*/, moduleFactory()];
|
|
103
|
-
case 6: return [4 /*yield*/, window[
|
|
104
|
+
case 6: return [4 /*yield*/, window[remoteScope].get(module.startsWith('./') ? module : "./".concat(module))];
|
|
104
105
|
case 7:
|
|
105
106
|
moduleFactory = _e.sent();
|
|
106
107
|
return [2 /*return*/, moduleFactory()];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"importRemote.js","sourceRoot":"","sources":["../../../../../packages/utilities/src/utils/importRemote.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"importRemote.js","sourceRoot":"","sources":["../../../../../packages/utilities/src/utils/importRemote.ts"],"names":[],"mappings":";;;;AAgBA,IAAM,iBAAiB,GAAG,gBAAgB,CAAC;AAE3C,IAAM,UAAU,GAAG,UACjB,GAA+B,EAC/B,KAAmC,EACnC,oBAAiE;IAEjE,OAAA,IAAI,OAAO,CAAO,UAAC,OAAO,EAAE,MAAM;QAChC,IAAM,SAAS,GAAG,oBAAoB,CAAC,CAAC,CAAC,aAAM,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3E,IAAM,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