@nrwl/angular 15.1.0-beta.2 → 15.1.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 +1 -1
- package/module-federation/index.d.ts +1 -0
- package/module-federation/index.js +3 -1
- package/module-federation/index.js.map +1 -1
- package/package.json +9 -9
- package/src/utils/mf/utils.d.ts +13 -0
- package/src/utils/mf/utils.js +56 -0
- package/src/utils/mf/utils.js.map +1 -0
- package/src/utils/mf/with-module-federation-ssr.d.ts +2 -0
- package/src/utils/mf/with-module-federation-ssr.js +45 -0
- package/src/utils/mf/with-module-federation-ssr.js.map +1 -0
- package/src/utils/mf/with-module-federation.js +2 -43
- package/src/utils/mf/with-module-federation.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
# [15.1.0
|
|
6
|
+
# [15.1.0](https://github.com/nrwl/nx/compare/15.0.7...15.1.0) (2022-11-15)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @nrwl/angular
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.withModuleFederation = void 0;
|
|
3
|
+
exports.withModuleFederationForSSR = exports.withModuleFederation = void 0;
|
|
4
4
|
var with_module_federation_1 = require("../src/utils/mf/with-module-federation");
|
|
5
5
|
Object.defineProperty(exports, "withModuleFederation", { enumerable: true, get: function () { return with_module_federation_1.withModuleFederation; } });
|
|
6
|
+
var with_module_federation_ssr_1 = require("../src/utils/mf/with-module-federation-ssr");
|
|
7
|
+
Object.defineProperty(exports, "withModuleFederationForSSR", { enumerable: true, get: function () { return with_module_federation_ssr_1.withModuleFederationForSSR; } });
|
|
6
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/angular/module-federation/index.ts"],"names":[],"mappings":";;;AAAA,iFAA8E;AAArE,8HAAA,oBAAoB,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/angular/module-federation/index.ts"],"names":[],"mappings":";;;AAAA,iFAA8E;AAArE,8HAAA,oBAAoB,OAAA;AAC7B,yFAAwF;AAA/E,wIAAA,0BAA0B,OAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nrwl/angular",
|
|
3
|
-
"version": "15.1.0
|
|
3
|
+
"version": "15.1.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Nx Plugin for Angular contains executors, generators, and utilities for managing Angular applications and libraries within an Nx workspace. It provides: \n\n- Integration with libraries such as Storybook, Jest, ESLint, Tailwind CSS, Cypress, Karma, and Protractor. \n\n- Generators to help scaffold code quickly (like: Micro Frontends, Libraries, both internal to your codebase and publishable to npm) \n\n- Upgrading AngularJS applications \n\n- Single Component Application Modules (SCAMs) \n\n- NgRx helpers. \n\n- Utilities for automatic workspace refactoring.",
|
|
6
6
|
"repository": {
|
|
@@ -67,13 +67,13 @@
|
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
69
|
"@angular-devkit/schematics": "~14.2.0",
|
|
70
|
-
"@nrwl/cypress": "15.1.0
|
|
71
|
-
"@nrwl/devkit": "15.1.0
|
|
72
|
-
"@nrwl/jest": "15.1.0
|
|
73
|
-
"@nrwl/linter": "15.1.0
|
|
74
|
-
"@nrwl/storybook": "15.1.0
|
|
75
|
-
"@nrwl/webpack": "15.1.0
|
|
76
|
-
"@nrwl/workspace": "15.1.0
|
|
70
|
+
"@nrwl/cypress": "15.1.0",
|
|
71
|
+
"@nrwl/devkit": "15.1.0",
|
|
72
|
+
"@nrwl/jest": "15.1.0",
|
|
73
|
+
"@nrwl/linter": "15.1.0",
|
|
74
|
+
"@nrwl/storybook": "15.1.0",
|
|
75
|
+
"@nrwl/webpack": "15.1.0",
|
|
76
|
+
"@nrwl/workspace": "15.1.0",
|
|
77
77
|
"@phenomnomnominal/tsquery": "4.1.1",
|
|
78
78
|
"@schematics/angular": "~14.2.0",
|
|
79
79
|
"chalk": "4.1.0",
|
|
@@ -99,5 +99,5 @@
|
|
|
99
99
|
"fesm2015": "fesm2015/nrwl-angular.mjs",
|
|
100
100
|
"typings": "index.d.ts",
|
|
101
101
|
"sideEffects": false,
|
|
102
|
-
"gitHead": "
|
|
102
|
+
"gitHead": "c2d4bf5fc8119abc00c16f96fd6b25b9385f894e"
|
|
103
103
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ModuleFederationConfig, SharedLibraryConfig } from '@nrwl/devkit';
|
|
2
|
+
export declare function applyDefaultEagerPackages(sharedConfig: Record<string, SharedLibraryConfig>): void;
|
|
3
|
+
export declare const DEFAULT_NPM_PACKAGES_TO_AVOID: string[];
|
|
4
|
+
export declare const DEFAULT_ANGULAR_PACKAGES_TO_SHARE: string[];
|
|
5
|
+
export declare function getModuleFederationConfig(mfConfig: ModuleFederationConfig, determineRemoteUrl: (remote: string) => string, options?: {
|
|
6
|
+
isServer: boolean;
|
|
7
|
+
}): Promise<{
|
|
8
|
+
sharedLibraries: import("@nrwl/devkit").SharedWorkspaceLibraryConfig;
|
|
9
|
+
sharedDependencies: {
|
|
10
|
+
[x: string]: SharedLibraryConfig;
|
|
11
|
+
};
|
|
12
|
+
mappedRemotes: Record<string, string>;
|
|
13
|
+
}>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getModuleFederationConfig = exports.DEFAULT_ANGULAR_PACKAGES_TO_SHARE = exports.DEFAULT_NPM_PACKAGES_TO_AVOID = exports.applyDefaultEagerPackages = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const devkit_1 = require("@nrwl/devkit");
|
|
6
|
+
function applyDefaultEagerPackages(sharedConfig) {
|
|
7
|
+
const DEFAULT_PACKAGES_TO_LOAD_EAGERLY = [
|
|
8
|
+
'@angular/localize',
|
|
9
|
+
'@angular/localize/init',
|
|
10
|
+
];
|
|
11
|
+
for (const pkg of DEFAULT_PACKAGES_TO_LOAD_EAGERLY) {
|
|
12
|
+
if (!sharedConfig[pkg]) {
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
sharedConfig[pkg] = Object.assign(Object.assign({}, sharedConfig[pkg]), { eager: true });
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.applyDefaultEagerPackages = applyDefaultEagerPackages;
|
|
19
|
+
exports.DEFAULT_NPM_PACKAGES_TO_AVOID = ['zone.js', '@nrwl/angular/mf'];
|
|
20
|
+
exports.DEFAULT_ANGULAR_PACKAGES_TO_SHARE = [
|
|
21
|
+
'@angular/animations',
|
|
22
|
+
'@angular/common',
|
|
23
|
+
];
|
|
24
|
+
function getModuleFederationConfig(mfConfig, determineRemoteUrl, options = { isServer: false }) {
|
|
25
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
let projectGraph;
|
|
27
|
+
try {
|
|
28
|
+
projectGraph = (0, devkit_1.readCachedProjectGraph)();
|
|
29
|
+
}
|
|
30
|
+
catch (e) {
|
|
31
|
+
projectGraph = yield (0, devkit_1.createProjectGraphAsync)();
|
|
32
|
+
}
|
|
33
|
+
const dependencies = (0, devkit_1.getDependentPackagesForProject)(projectGraph, mfConfig.name);
|
|
34
|
+
const sharedLibraries = (0, devkit_1.shareWorkspaceLibraries)(dependencies.workspaceLibraries);
|
|
35
|
+
const npmPackages = (0, devkit_1.sharePackages)(Array.from(new Set([
|
|
36
|
+
...exports.DEFAULT_ANGULAR_PACKAGES_TO_SHARE,
|
|
37
|
+
...dependencies.npmPackages.filter((pkg) => !exports.DEFAULT_NPM_PACKAGES_TO_AVOID.includes(pkg)),
|
|
38
|
+
])));
|
|
39
|
+
exports.DEFAULT_NPM_PACKAGES_TO_AVOID.forEach((pkgName) => {
|
|
40
|
+
if (pkgName in npmPackages) {
|
|
41
|
+
delete npmPackages[pkgName];
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
const sharedDependencies = Object.assign(Object.assign({}, sharedLibraries.getLibraries()), npmPackages);
|
|
45
|
+
applyDefaultEagerPackages(sharedDependencies);
|
|
46
|
+
(0, devkit_1.applySharedFunction)(sharedDependencies, mfConfig.shared);
|
|
47
|
+
(0, devkit_1.applyAdditionalShared)(sharedDependencies, mfConfig.additionalShared, projectGraph);
|
|
48
|
+
const mapRemotesFunction = options.isServer ? devkit_1.mapRemotesForSSR : devkit_1.mapRemotes;
|
|
49
|
+
const mappedRemotes = !mfConfig.remotes || mfConfig.remotes.length === 0
|
|
50
|
+
? {}
|
|
51
|
+
: mapRemotesFunction(mfConfig.remotes, 'mjs', determineRemoteUrl);
|
|
52
|
+
return { sharedLibraries, sharedDependencies, mappedRemotes };
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
exports.getModuleFederationConfig = getModuleFederationConfig;
|
|
56
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../packages/angular/src/utils/mf/utils.ts"],"names":[],"mappings":";;;;AAAA,yCAasB;AAEtB,SAAgB,yBAAyB,CACvC,YAAiD;IAEjD,MAAM,gCAAgC,GAAG;QACvC,mBAAmB;QACnB,wBAAwB;KACzB,CAAC;IACF,KAAK,MAAM,GAAG,IAAI,gCAAgC,EAAE;QAClD,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE;YACtB,SAAS;SACV;QAED,YAAY,CAAC,GAAG,CAAC,mCAAQ,YAAY,CAAC,GAAG,CAAC,KAAE,KAAK,EAAE,IAAI,GAAE,CAAC;KAC3D;AACH,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,EAClB,QAAQ,CAAC,gBAAgB,EACzB,YAAY,CACb,CAAC;QAEF,MAAM,kBAAkB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,yBAAgB,CAAC,CAAC,CAAC,mBAAU,CAAC;QAC5E,MAAM,aAAa,GACjB,CAAC,QAAQ,CAAC,OAAO,IAAI,QAAQ,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC;YAChD,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,kBAAkB,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,EAAE,kBAAkB,CAAC,CAAC;QACtE,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,aAAa,EAAE,CAAC;IAChE,CAAC;CAAA;AAxDD,8DAwDC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withModuleFederationForSSR = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const project_graph_1 = require("nx/src/project-graph/project-graph");
|
|
6
|
+
const utils_1 = require("./utils");
|
|
7
|
+
function determineRemoteUrl(remote) {
|
|
8
|
+
const remoteProjectConfiguration = (0, project_graph_1.readCachedProjectConfiguration)(remote);
|
|
9
|
+
let publicHost = '';
|
|
10
|
+
try {
|
|
11
|
+
publicHost = remoteProjectConfiguration.targets.serve.options.publicHost;
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
throw new Error(`Cannot automatically determine URL of remote (${remote}). Looked for property "publicHost" in the project's "serve" target.\n
|
|
15
|
+
You can also use the tuple syntax in your webpack config to configure your remotes. e.g. \`remotes: [['remote1', 'http://localhost:4201']]\``);
|
|
16
|
+
}
|
|
17
|
+
return `${publicHost.endsWith('/') ? publicHost.slice(0, -1) : publicHost}/server/remoteEntry.js`;
|
|
18
|
+
}
|
|
19
|
+
function withModuleFederationForSSR(options) {
|
|
20
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
const { sharedLibraries, sharedDependencies, mappedRemotes } = yield (0, utils_1.getModuleFederationConfig)(options, determineRemoteUrl, {
|
|
22
|
+
isServer: true,
|
|
23
|
+
});
|
|
24
|
+
return (config) => {
|
|
25
|
+
var _a, _b, _c, _d, _e, _f;
|
|
26
|
+
return (Object.assign(Object.assign({}, (config !== null && config !== void 0 ? config : {})), { target: false, output: Object.assign(Object.assign({}, ((_a = config.output) !== null && _a !== void 0 ? _a : {})), { uniqueName: options.name }), optimization: Object.assign(Object.assign({}, ((_b = config.optimization) !== null && _b !== void 0 ? _b : {})), { runtimeChunk: false }), resolve: Object.assign(Object.assign({}, ((_c = config.resolve) !== null && _c !== void 0 ? _c : {})), { alias: Object.assign(Object.assign({}, ((_e = (_d = config.resolve) === null || _d === void 0 ? void 0 : _d.alias) !== null && _e !== void 0 ? _e : {})), sharedLibraries.getAliases()) }), plugins: [
|
|
27
|
+
...((_f = config.plugins) !== null && _f !== void 0 ? _f : []),
|
|
28
|
+
new (require('@module-federation/node').UniversalFederationPlugin)({
|
|
29
|
+
name: options.name,
|
|
30
|
+
filename: 'remoteEntry.js',
|
|
31
|
+
exposes: options.exposes,
|
|
32
|
+
remotes: mappedRemotes,
|
|
33
|
+
shared: Object.assign({}, sharedDependencies),
|
|
34
|
+
library: {
|
|
35
|
+
type: 'commonjs-module',
|
|
36
|
+
},
|
|
37
|
+
isServer: true,
|
|
38
|
+
}, {}),
|
|
39
|
+
sharedLibraries.getReplacementPlugin(),
|
|
40
|
+
] }));
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
exports.withModuleFederationForSSR = withModuleFederationForSSR;
|
|
45
|
+
//# sourceMappingURL=with-module-federation-ssr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with-module-federation-ssr.js","sourceRoot":"","sources":["../../../../../../packages/angular/src/utils/mf/with-module-federation-ssr.ts"],"names":[],"mappings":";;;;AAAA,sE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AAE,MAGnC,OAAO,EAAE;oBACP,GAAG,CAAC,MAAA,MAAM,CAAC,OAAO,mCAAI,EAAE,CAAC;oBACzB,IAAI,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC,yBAAyB,CAAC,CAChE;wBACE,IAAI,EAAE,OAAO,CAAC,IAAI;wBAClB,QAAQ,EAAE,gBAAgB;wBAC1B,OAAO,EAAE,OAAO,CAAC,OAAO;wBACxB,OAAO,EAAE,aAAa;wBACtB,MAAM,oBACD,kBAAkB,CACtB;wBACD,OAAO,EAAE;4BACP,IAAI,EAAE,iBAAiB;yBACxB;wBACD,QAAQ,EAAE,IAAI;qBACf,EACD,EAAE,CACH;oBACD,eAAe,CAAC,oBAAoB,EAAE;iBACvC,IACD,CAAA;SAAA,CAAC;IACL,CAAC;CAAA;AA/CD,gEA+CC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.withModuleFederation = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const utils_1 = require("./utils");
|
|
6
6
|
const project_graph_1 = require("nx/src/project-graph/project-graph");
|
|
7
7
|
const ModuleFederationPlugin = require("webpack/lib/container/ModuleFederationPlugin");
|
|
8
8
|
function determineRemoteUrl(remote) {
|
|
@@ -17,50 +17,9 @@ function determineRemoteUrl(remote) {
|
|
|
17
17
|
}
|
|
18
18
|
return `${publicHost.endsWith('/') ? publicHost.slice(0, -1) : publicHost}/remoteEntry.mjs`;
|
|
19
19
|
}
|
|
20
|
-
function applyDefaultEagerPackages(sharedConfig) {
|
|
21
|
-
const DEFAULT_PACKAGES_TO_LOAD_EAGERLY = [
|
|
22
|
-
'@angular/localize',
|
|
23
|
-
'@angular/localize/init',
|
|
24
|
-
];
|
|
25
|
-
for (const pkg of DEFAULT_PACKAGES_TO_LOAD_EAGERLY) {
|
|
26
|
-
if (!sharedConfig[pkg]) {
|
|
27
|
-
continue;
|
|
28
|
-
}
|
|
29
|
-
sharedConfig[pkg] = Object.assign(Object.assign({}, sharedConfig[pkg]), { eager: true });
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
20
|
function withModuleFederation(options) {
|
|
33
21
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
34
|
-
const
|
|
35
|
-
const DEFAULT_ANGULAR_PACKAGES_TO_SHARE = [
|
|
36
|
-
'@angular/animations',
|
|
37
|
-
'@angular/common',
|
|
38
|
-
];
|
|
39
|
-
let projectGraph;
|
|
40
|
-
try {
|
|
41
|
-
projectGraph = (0, devkit_1.readCachedProjectGraph)();
|
|
42
|
-
}
|
|
43
|
-
catch (e) {
|
|
44
|
-
projectGraph = yield (0, devkit_1.createProjectGraphAsync)();
|
|
45
|
-
}
|
|
46
|
-
const dependencies = (0, devkit_1.getDependentPackagesForProject)(projectGraph, options.name);
|
|
47
|
-
const sharedLibraries = (0, devkit_1.shareWorkspaceLibraries)(dependencies.workspaceLibraries);
|
|
48
|
-
const npmPackages = (0, devkit_1.sharePackages)(Array.from(new Set([
|
|
49
|
-
...DEFAULT_ANGULAR_PACKAGES_TO_SHARE,
|
|
50
|
-
...dependencies.npmPackages.filter((pkg) => !DEFAULT_NPM_PACKAGES_TO_AVOID.includes(pkg)),
|
|
51
|
-
])));
|
|
52
|
-
DEFAULT_NPM_PACKAGES_TO_AVOID.forEach((pkgName) => {
|
|
53
|
-
if (pkgName in npmPackages) {
|
|
54
|
-
delete npmPackages[pkgName];
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
const sharedDependencies = Object.assign(Object.assign({}, sharedLibraries.getLibraries()), npmPackages);
|
|
58
|
-
applyDefaultEagerPackages(sharedDependencies);
|
|
59
|
-
(0, devkit_1.applySharedFunction)(sharedDependencies, options.shared);
|
|
60
|
-
(0, devkit_1.applyAdditionalShared)(sharedDependencies, options.additionalShared, projectGraph);
|
|
61
|
-
const mappedRemotes = !options.remotes || options.remotes.length === 0
|
|
62
|
-
? {}
|
|
63
|
-
: (0, devkit_1.mapRemotes)(options.remotes, 'mjs', determineRemoteUrl);
|
|
22
|
+
const { sharedLibraries, sharedDependencies, mappedRemotes } = yield (0, utils_1.getModuleFederationConfig)(options, determineRemoteUrl);
|
|
64
23
|
return (config) => {
|
|
65
24
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
66
25
|
return (Object.assign(Object.assign({}, (config !== null && config !== void 0 ? config : {})), { output: Object.assign(Object.assign({}, ((_a = config.output) !== null && _a !== void 0 ? _a : {})), { uniqueName: options.name, publicPath: 'auto' }), optimization: Object.assign(Object.assign({}, ((_b = config.optimization) !== null && _b !== void 0 ? _b : {})), { runtimeChunk: false }), resolve: Object.assign(Object.assign({}, ((_c = config.resolve) !== null && _c !== void 0 ? _c : {})), { alias: Object.assign(Object.assign({}, ((_e = (_d = config.resolve) === null || _d === void 0 ? void 0 : _d.alias) !== null && _e !== void 0 ? _e : {})), sharedLibraries.getAliases()) }), experiments: Object.assign(Object.assign({}, ((_f = config.experiments) !== null && _f !== void 0 ? _f : {})), { outputModule: true }), plugins: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with-module-federation.js","sourceRoot":"","sources":["../../../../../../packages/angular/src/utils/mf/with-module-federation.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"with-module-federation.js","sourceRoot":"","sources":["../../../../../../packages/angular/src/utils/mf/with-module-federation.ts"],"names":[],"mappings":";;;;AACA,mCAAoD;AACpD,sEAAoF;AACpF,uFAAwF;AAExF,SAAS,kBAAkB,CAAC,MAAc;IACxC,MAAM,0BAA0B,GAAG,IAAA,8CAA8B,EAAC,MAAM,CAAC,CAAC;IAC1E,IAAI,UAAU,GAAG,EAAE,CAAC;IACpB,IAAI;QACF,UAAU,GAAG,0BAA0B,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC;KAC1E;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,IAAI,KAAK,CACb,iDAAi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