@nrwl/workspace 13.0.0-beta.2 → 13.0.0-beta.6
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/package.json +5 -5
- package/src/command-line/dep-graph.js +17 -21
- package/src/command-line/dep-graph.js.map +1 -1
- package/src/command-line/nx-commands.js +25 -2
- package/src/command-line/nx-commands.js.map +1 -1
- package/src/command-line/supported-nx-commands.js +1 -0
- package/src/command-line/supported-nx-commands.js.map +1 -1
- package/src/core/dep-graph/main.es5.js +1 -1
- package/src/core/dep-graph/main.esm.js +1 -1
- package/src/core/dep-graph/polyfills.es5.js +1 -1
- package/src/core/dep-graph/polyfills.esm.js +1 -1
- package/src/core/dep-graph/runtime.es5.js +1 -1
- package/src/core/dep-graph/runtime.esm.js +1 -1
- package/src/core/file-utils.d.ts +2 -10
- package/src/core/file-utils.js +18 -29
- package/src/core/file-utils.js.map +1 -1
- package/src/core/project-graph/build-project-graph.d.ts +0 -11
- package/src/core/project-graph/build-project-graph.js +2 -39
- package/src/core/project-graph/build-project-graph.js.map +1 -1
- package/src/core/project-graph/daemon/cache.d.ts +5 -13
- package/src/core/project-graph/daemon/cache.js +39 -16
- package/src/core/project-graph/daemon/cache.js.map +1 -1
- package/src/core/project-graph/daemon/client/client.js +16 -44
- package/src/core/project-graph/daemon/client/client.js.map +1 -1
- package/src/core/project-graph/daemon/client/exec-is-server-available.d.ts +1 -0
- package/src/core/project-graph/daemon/client/exec-is-server-available.js +13 -0
- package/src/core/project-graph/daemon/client/exec-is-server-available.js.map +1 -0
- package/src/core/project-graph/daemon/client/generate-help-output.d.ts +1 -0
- package/src/core/project-graph/daemon/client/generate-help-output.js +28 -0
- package/src/core/project-graph/daemon/client/generate-help-output.js.map +1 -0
- package/src/core/project-graph/daemon/server/project-graph-incremental-recomputation.d.ts +6 -0
- package/src/core/project-graph/daemon/server/project-graph-incremental-recomputation.js +120 -0
- package/src/core/project-graph/daemon/server/project-graph-incremental-recomputation.js.map +1 -0
- package/src/core/project-graph/daemon/server/server.js +28 -83
- package/src/core/project-graph/daemon/server/server.js.map +1 -1
- package/src/core/project-graph/daemon/server/stop.js +1 -11
- package/src/core/project-graph/daemon/server/stop.js.map +1 -1
- package/src/core/project-graph/daemon/socket-utils.d.ts +6 -0
- package/src/core/project-graph/daemon/socket-utils.js +4 -8
- package/src/core/project-graph/daemon/socket-utils.js.map +1 -1
- package/src/core/project-graph/daemon/tmp-dir.d.ts +7 -0
- package/src/core/project-graph/daemon/tmp-dir.js +59 -0
- package/src/core/project-graph/daemon/tmp-dir.js.map +1 -0
- package/src/core/project-graph/project-graph.js +3 -10
- package/src/core/project-graph/project-graph.js.map +1 -1
- package/src/generators/init/init.js +27 -27
- package/src/generators/init/init.js.map +1 -1
- package/src/utilities/run-webpack.d.ts +3 -2
- package/src/utilities/run-webpack.js +18 -34
- package/src/utilities/run-webpack.js.map +1 -1
- package/src/utils/versions.js +1 -1
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resetAfterError = exports.addUpdatedAndDeletedFiles = exports.getCachedSerializedProjectGraphPromise = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const app_root_1 = require("@nrwl/tao/src/utils/app-root");
|
|
6
|
+
const perf_hooks_1 = require("perf_hooks");
|
|
7
|
+
const file_utils_1 = require("../../../file-utils");
|
|
8
|
+
const file_hasher_1 = require("../../../hasher/file-hasher");
|
|
9
|
+
const git_hasher_1 = require("../../../hasher/git-hasher");
|
|
10
|
+
const logger_1 = require("./logger");
|
|
11
|
+
const build_project_graph_1 = require("../../build-project-graph");
|
|
12
|
+
const workspace_1 = require("@nrwl/tao/src/shared/workspace");
|
|
13
|
+
const nx_deps_cache_1 = require("../../../nx-deps/nx-deps-cache");
|
|
14
|
+
const configName = workspace_1.workspaceConfigName(app_root_1.appRootPath);
|
|
15
|
+
let cachedSerializedProjectGraphPromise;
|
|
16
|
+
let projectFileMapWithFiles;
|
|
17
|
+
let currentProjectGraphCache;
|
|
18
|
+
const collectedUpdatedFiles = new Set();
|
|
19
|
+
const collectedDeletedFiles = new Set();
|
|
20
|
+
let waitPeriod = 100;
|
|
21
|
+
let scheduledTimeoutId;
|
|
22
|
+
function getCachedSerializedProjectGraphPromise() {
|
|
23
|
+
// recomputing it now on demand. we can ignore the scheduled timeout
|
|
24
|
+
if (scheduledTimeoutId) {
|
|
25
|
+
clearTimeout(scheduledTimeoutId);
|
|
26
|
+
}
|
|
27
|
+
// reset the wait time
|
|
28
|
+
waitPeriod = 100;
|
|
29
|
+
if (collectedUpdatedFiles.size == 0 && collectedDeletedFiles.size == 0) {
|
|
30
|
+
if (!cachedSerializedProjectGraphPromise) {
|
|
31
|
+
processCollectedUpdatedAndDeletedFiles(); // this is to create project file map
|
|
32
|
+
cachedSerializedProjectGraphPromise = createAndSerializeProjectGraph();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
processCollectedUpdatedAndDeletedFiles();
|
|
37
|
+
cachedSerializedProjectGraphPromise = createAndSerializeProjectGraph();
|
|
38
|
+
}
|
|
39
|
+
return cachedSerializedProjectGraphPromise;
|
|
40
|
+
}
|
|
41
|
+
exports.getCachedSerializedProjectGraphPromise = getCachedSerializedProjectGraphPromise;
|
|
42
|
+
function addUpdatedAndDeletedFiles(updatedFiles, deletedFiles) {
|
|
43
|
+
for (let f of updatedFiles) {
|
|
44
|
+
collectedDeletedFiles.delete(f);
|
|
45
|
+
collectedUpdatedFiles.add(f);
|
|
46
|
+
}
|
|
47
|
+
for (let f of deletedFiles) {
|
|
48
|
+
collectedUpdatedFiles.delete(f);
|
|
49
|
+
collectedDeletedFiles.add(f);
|
|
50
|
+
}
|
|
51
|
+
if (!scheduledTimeoutId) {
|
|
52
|
+
scheduledTimeoutId = setTimeout(() => {
|
|
53
|
+
scheduledTimeoutId = undefined;
|
|
54
|
+
if (waitPeriod < 4000) {
|
|
55
|
+
waitPeriod = waitPeriod * 2;
|
|
56
|
+
}
|
|
57
|
+
processCollectedUpdatedAndDeletedFiles();
|
|
58
|
+
cachedSerializedProjectGraphPromise = createAndSerializeProjectGraph();
|
|
59
|
+
}, waitPeriod);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.addUpdatedAndDeletedFiles = addUpdatedAndDeletedFiles;
|
|
63
|
+
function processCollectedUpdatedAndDeletedFiles() {
|
|
64
|
+
perf_hooks_1.performance.mark('hash-watched-changes-start');
|
|
65
|
+
const updatedFiles = git_hasher_1.getGitHashForFiles([...collectedUpdatedFiles.values()], app_root_1.appRootPath);
|
|
66
|
+
const deletedFiles = [...collectedDeletedFiles.values()];
|
|
67
|
+
collectedUpdatedFiles.clear();
|
|
68
|
+
collectedDeletedFiles.clear();
|
|
69
|
+
perf_hooks_1.performance.mark('hash-watched-changes-end');
|
|
70
|
+
perf_hooks_1.performance.measure('hash changed files from watcher', 'hash-watched-changes-start', 'hash-watched-changes-end');
|
|
71
|
+
file_hasher_1.defaultFileHasher.incrementalUpdate(updatedFiles, deletedFiles);
|
|
72
|
+
const workspaceJson = file_utils_1.readWorkspaceJson();
|
|
73
|
+
logger_1.serverLogger.nestedLog(`Updated file-hasher based on watched changes, recomputing project graph...`);
|
|
74
|
+
// when workspace.json changes we cannot be sure about the correctness of the project file map
|
|
75
|
+
if (collectedUpdatedFiles.has(configName) ||
|
|
76
|
+
collectedDeletedFiles.has(configName)) {
|
|
77
|
+
projectFileMapWithFiles = file_utils_1.createProjectFileMap(workspaceJson);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
projectFileMapWithFiles = projectFileMapWithFiles
|
|
81
|
+
? file_utils_1.updateProjectFileMap(workspaceJson, projectFileMapWithFiles.projectFileMap, projectFileMapWithFiles.allWorkspaceFiles, updatedFiles, deletedFiles)
|
|
82
|
+
: file_utils_1.createProjectFileMap(workspaceJson);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function createAndSerializeProjectGraph() {
|
|
86
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
87
|
+
try {
|
|
88
|
+
perf_hooks_1.performance.mark('create-project-graph-start');
|
|
89
|
+
const workspaceJson = file_utils_1.readWorkspaceJson();
|
|
90
|
+
const { projectGraph, projectGraphCache } = yield build_project_graph_1.buildProjectGraphUsingProjectFileMap(workspaceJson, projectFileMapWithFiles.projectFileMap, projectFileMapWithFiles.allWorkspaceFiles, currentProjectGraphCache || nx_deps_cache_1.readCache(), true, '4.0');
|
|
91
|
+
currentProjectGraphCache = projectGraphCache;
|
|
92
|
+
perf_hooks_1.performance.mark('create-project-graph-end');
|
|
93
|
+
perf_hooks_1.performance.measure('total execution time for createProjectGraph()', 'create-project-graph-start', 'create-project-graph-end');
|
|
94
|
+
perf_hooks_1.performance.mark('json-stringify-start');
|
|
95
|
+
const serializedProjectGraph = JSON.stringify(projectGraph);
|
|
96
|
+
perf_hooks_1.performance.mark('json-stringify-end');
|
|
97
|
+
perf_hooks_1.performance.measure('serialize graph', 'json-stringify-start', 'json-stringify-end');
|
|
98
|
+
return {
|
|
99
|
+
error: null,
|
|
100
|
+
serializedProjectGraph,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
catch (err) {
|
|
104
|
+
return {
|
|
105
|
+
error: err,
|
|
106
|
+
serializedProjectGraph: null,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
function resetAfterError() {
|
|
112
|
+
cachedSerializedProjectGraphPromise = undefined;
|
|
113
|
+
projectFileMapWithFiles = undefined;
|
|
114
|
+
currentProjectGraphCache = undefined;
|
|
115
|
+
collectedUpdatedFiles.clear();
|
|
116
|
+
collectedDeletedFiles.clear();
|
|
117
|
+
waitPeriod = 100;
|
|
118
|
+
}
|
|
119
|
+
exports.resetAfterError = resetAfterError;
|
|
120
|
+
//# sourceMappingURL=project-graph-incremental-recomputation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-graph-incremental-recomputation.js","sourceRoot":"","sources":["../../../../../../../../packages/workspace/src/core/project-graph/daemon/server/project-graph-incremental-recomputation.ts"],"names":[],"mappings":";;;;AACA,2DAA2D;AAC3D,2CAAyC;AACzC,oDAI6B;AAC7B,6DAAgE;AAChE,2DAAgE;AAChE,qCAAwC;AACxC,mEAAiF;AACjF,8DAAqE;AACrE,kEAA8E;AAE9E,MAAM,UAAU,GAAG,+BAAmB,CAAC,sBAAW,CAAC,CAAC;AACpD,IAAI,mCAGF,CAAC;AACH,IAAI,uBAES,CAAC;AACd,IAAI,wBAAuD,CAAC;AAE5D,MAAM,qBAAqB,GAAG,IAAI,GAAG,EAAU,CAAC;AAChD,MAAM,qBAAqB,GAAG,IAAI,GAAG,EAAU,CAAC;AAChD,IAAI,UAAU,GAAG,GAAG,CAAC;AACrB,IAAI,kBAAkB,CAAC;AAEvB,SAAgB,sCAAsC;IACpD,oEAAoE;IACpE,IAAI,kBAAkB,EAAE;QACtB,YAAY,CAAC,kBAAkB,CAAC,CAAC;KAClC;IAED,sBAAsB;IACtB,UAAU,GAAG,GAAG,CAAC;IAEjB,IAAI,qBAAqB,CAAC,IAAI,IAAI,CAAC,IAAI,qBAAqB,CAAC,IAAI,IAAI,CAAC,EAAE;QACtE,IAAI,CAAC,mCAAmC,EAAE;YACxC,sCAAsC,EAAE,CAAC,CAAC,qCAAqC;YAC/E,mCAAmC,GAAG,8BAA8B,EAAE,CAAC;SACxE;KACF;SAAM;QACL,sCAAsC,EAAE,CAAC;QACzC,mCAAmC,GAAG,8BAA8B,EAAE,CAAC;KACxE;IACD,OAAO,mCAAmC,CAAC;AAC7C,CAAC;AAnBD,wFAmBC;AAED,SAAgB,yBAAyB,CACvC,YAAsB,EACtB,YAAsB;IAEtB,KAAK,IAAI,CAAC,IAAI,YAAY,EAAE;QAC1B,qBAAqB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAChC,qB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,IAAI;aAC7B,CAAC;SACH;IACH,CAAC;CAAA;AAED,SAAgB,eAAe;IAC7B,mCAAmC,GAAG,SAAS,CAAC;IAChD,uBAAuB,GAAG,SAAS,CAAC;IACpC,wBAAwB,GAAG,SAAS,CAAC;IACrC,qBAAqB,CAAC,KAAK,EAAE,CAAC;IAC9B,qBAAqB,CAAC,KAAK,EAAE,CAAC;IAC9B,UAAU,GAAG,GAAG,CAAC;AACnB,CAAC;AAPD,0CAOC"}
|
|
@@ -7,59 +7,11 @@ const app_root_1 = require("@nrwl/tao/src/utils/app-root");
|
|
|
7
7
|
const net_1 = require("net");
|
|
8
8
|
const path_1 = require("path");
|
|
9
9
|
const perf_hooks_1 = require("perf_hooks");
|
|
10
|
-
const file_utils_1 = require("../../../file-utils");
|
|
11
|
-
const file_hasher_1 = require("../../../hasher/file-hasher");
|
|
12
|
-
const git_hasher_1 = require("../../../hasher/git-hasher");
|
|
13
10
|
const socket_utils_1 = require("../socket-utils");
|
|
14
11
|
const logger_1 = require("./logger");
|
|
15
12
|
const shutdown_utils_1 = require("./shutdown-utils");
|
|
16
13
|
const watcher_1 = require("./watcher");
|
|
17
|
-
const
|
|
18
|
-
const workspace_1 = require("@nrwl/tao/src/shared/workspace");
|
|
19
|
-
const nx_deps_cache_1 = require("../../../nx-deps/nx-deps-cache");
|
|
20
|
-
const configName = workspace_1.workspaceConfigName(app_root_1.appRootPath);
|
|
21
|
-
let cachedSerializedProjectGraphPromise;
|
|
22
|
-
let projectFileMapWithFiles;
|
|
23
|
-
let currentProjectGraphCache;
|
|
24
|
-
function createAndSerializeProjectGraph(updatedFiles, deletedFiles, shouldWriteCache) {
|
|
25
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
try {
|
|
27
|
-
perf_hooks_1.performance.mark('create-project-graph-start');
|
|
28
|
-
const workspaceJson = file_utils_1.readWorkspaceJson();
|
|
29
|
-
projectFileMapWithFiles = projectFileMapWithFiles
|
|
30
|
-
? file_utils_1.updateProjectFileMap(workspaceJson, projectFileMapWithFiles.projectFileMap, projectFileMapWithFiles.allWorkspaceFiles, updatedFiles, deletedFiles)
|
|
31
|
-
: file_utils_1.createProjectFileMap(workspaceJson);
|
|
32
|
-
const { projectGraph, projectGraphCache } = yield build_project_graph_1.buildProjectGraphUsingProjectFileMap(workspaceJson, projectFileMapWithFiles.projectFileMap, projectFileMapWithFiles.allWorkspaceFiles, currentProjectGraphCache || nx_deps_cache_1.readCache(), shouldWriteCache, '4.0');
|
|
33
|
-
currentProjectGraphCache = projectGraphCache;
|
|
34
|
-
perf_hooks_1.performance.mark('create-project-graph-end');
|
|
35
|
-
perf_hooks_1.performance.measure('total execution time for createProjectGraph()', 'create-project-graph-start', 'create-project-graph-end');
|
|
36
|
-
perf_hooks_1.performance.mark('json-stringify-start');
|
|
37
|
-
const serializedProjectGraph = JSON.stringify(projectGraph);
|
|
38
|
-
perf_hooks_1.performance.mark('json-stringify-end');
|
|
39
|
-
perf_hooks_1.performance.measure('serialize graph', 'json-stringify-start', 'json-stringify-end');
|
|
40
|
-
return {
|
|
41
|
-
error: null,
|
|
42
|
-
serializedProjectGraph,
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
catch (err) {
|
|
46
|
-
return {
|
|
47
|
-
error: err,
|
|
48
|
-
serializedProjectGraph: null,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
let watcherSubscription;
|
|
54
|
-
initializePerfObserver();
|
|
55
|
-
function initializePerfObserver() {
|
|
56
|
-
const r = new perf_hooks_1.PerformanceObserver((list) => {
|
|
57
|
-
const entry = list.getEntries()[0];
|
|
58
|
-
logger_1.serverLogger.nestedLog(`Time taken for '${entry.name}'`, `${entry.duration}ms`);
|
|
59
|
-
});
|
|
60
|
-
r.observe({ entryTypes: ['measure'], buffered: false });
|
|
61
|
-
return r;
|
|
62
|
-
}
|
|
14
|
+
const project_graph_incremental_recomputation_1 = require("./project-graph-incremental-recomputation");
|
|
63
15
|
function respondToClient(socket, message) {
|
|
64
16
|
socket.write(message, () => {
|
|
65
17
|
// Close the connection once all data has been written so that the client knows when to read it.
|
|
@@ -67,8 +19,17 @@ function respondToClient(socket, message) {
|
|
|
67
19
|
logger_1.serverLogger.nestedLog(`Closed Connection to Client`);
|
|
68
20
|
});
|
|
69
21
|
}
|
|
22
|
+
let watcherSubscription;
|
|
23
|
+
let performanceObserver;
|
|
70
24
|
const server = net_1.createServer((socket) => {
|
|
71
25
|
shutdown_utils_1.resetInactivityTimeout(handleInactivityTimeout);
|
|
26
|
+
if (!performanceObserver) {
|
|
27
|
+
performanceObserver = new perf_hooks_1.PerformanceObserver((list) => {
|
|
28
|
+
const entry = list.getEntries()[0];
|
|
29
|
+
logger_1.serverLogger.nestedLog(`Time taken for '${entry.name}'`, `${entry.duration}ms`);
|
|
30
|
+
});
|
|
31
|
+
performanceObserver.observe({ entryTypes: ['measure'], buffered: false });
|
|
32
|
+
}
|
|
72
33
|
socket.on('data', (data) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
73
34
|
shutdown_utils_1.resetInactivityTimeout(handleInactivityTimeout);
|
|
74
35
|
const payload = data.toString();
|
|
@@ -77,19 +38,16 @@ const server = net_1.createServer((socket) => {
|
|
|
77
38
|
}
|
|
78
39
|
perf_hooks_1.performance.mark('server-connection');
|
|
79
40
|
logger_1.serverLogger.requestLog('Client Request for Project Graph Received');
|
|
80
|
-
|
|
81
|
-
cachedSerializedProjectGraphPromise = createAndSerializeProjectGraph(new Map(), [], true);
|
|
82
|
-
}
|
|
83
|
-
const result = yield cachedSerializedProjectGraphPromise;
|
|
41
|
+
const result = yield project_graph_incremental_recomputation_1.getCachedSerializedProjectGraphPromise();
|
|
84
42
|
if (result.error) {
|
|
85
|
-
|
|
43
|
+
project_graph_incremental_recomputation_1.resetAfterError();
|
|
86
44
|
logger_1.serverLogger.nestedLog(`Error when preparing serialized project graph: ${result.error.message}`);
|
|
87
45
|
respondToClient(socket, socket_utils_1.serializeResult(result.error, result.serializedProjectGraph));
|
|
88
46
|
return;
|
|
89
47
|
}
|
|
90
48
|
const serializedResult = socket_utils_1.serializeResult(result.error, result.serializedProjectGraph);
|
|
91
49
|
if (!serializedResult) {
|
|
92
|
-
|
|
50
|
+
project_graph_incremental_recomputation_1.resetAfterError();
|
|
93
51
|
logger_1.serverLogger.nestedLog(`Error when serializing project graph result`);
|
|
94
52
|
respondToClient(socket, socket_utils_1.serializeResult(new Error('Critical error when serializing server result, check server logs'), null));
|
|
95
53
|
return;
|
|
@@ -164,7 +122,7 @@ function isNxVersionSame(currentNxVersion) {
|
|
|
164
122
|
const handleWorkspaceChanges = (err, changeEvents) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
165
123
|
shutdown_utils_1.resetInactivityTimeout(handleInactivityTimeout);
|
|
166
124
|
if (!isNxVersionSame(resolveCurrentNxVersion())) {
|
|
167
|
-
shutdown_utils_1.handleServerProcessTermination({
|
|
125
|
+
yield shutdown_utils_1.handleServerProcessTermination({
|
|
168
126
|
server,
|
|
169
127
|
watcherSubscription,
|
|
170
128
|
reason: '@nrwl/workspace installation changed',
|
|
@@ -177,36 +135,23 @@ const handleWorkspaceChanges = (err, changeEvents) => tslib_1.__awaiter(void 0,
|
|
|
177
135
|
return;
|
|
178
136
|
}
|
|
179
137
|
logger_1.serverLogger.watcherLog(watcher_1.convertChangeEventsToLogMessage(changeEvents));
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
deletedFiles.push(event.path);
|
|
187
|
-
}
|
|
188
|
-
else {
|
|
189
|
-
filesToHash.push(event.path);
|
|
190
|
-
}
|
|
138
|
+
try {
|
|
139
|
+
const filesToHash = [];
|
|
140
|
+
const deletedFiles = [];
|
|
141
|
+
for (const event of changeEvents) {
|
|
142
|
+
if (event.type === 'delete') {
|
|
143
|
+
deletedFiles.push(event.path);
|
|
191
144
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
perf_hooks_1.performance.mark('hash-watched-changes-end');
|
|
195
|
-
perf_hooks_1.performance.measure('hash changed files from watcher', 'hash-watched-changes-start', 'hash-watched-changes-end');
|
|
196
|
-
file_hasher_1.defaultFileHasher.incrementalUpdate(updatedFiles, deletedFiles);
|
|
197
|
-
logger_1.serverLogger.nestedLog(`Updated file-hasher based on watched changes, recomputing project graph...`);
|
|
198
|
-
// when workspace.json changes we cannot be sure about the correctness of the project file map
|
|
199
|
-
if (updatedFiles.has(configName) ||
|
|
200
|
-
deletedFiles.indexOf(configName) > -1) {
|
|
201
|
-
projectFileMapWithFiles = undefined;
|
|
145
|
+
else {
|
|
146
|
+
filesToHash.push(event.path);
|
|
202
147
|
}
|
|
203
|
-
res(yield createAndSerializeProjectGraph(updatedFiles, deletedFiles, true));
|
|
204
148
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
149
|
+
project_graph_incremental_recomputation_1.addUpdatedAndDeletedFiles(filesToHash, deletedFiles);
|
|
150
|
+
}
|
|
151
|
+
catch (err) {
|
|
152
|
+
logger_1.serverLogger.log(`Unexpected Error`);
|
|
153
|
+
console.error(err);
|
|
154
|
+
}
|
|
210
155
|
});
|
|
211
156
|
function startServer() {
|
|
212
157
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../../../../../../packages/workspace/src/core/project-graph/daemon/server/server.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../../../../../../packages/workspace/src/core/project-graph/daemon/server/server.ts"],"names":[],"mappings":";;;;AAAA,yCAAqD;AACrD,2DAA2D;AAC3D,6BAAmD;AACnD,+BAA4B;AAC5B,2CAA8D;AAC9D,kDAKyB;AACzB,qCAAwC;AACxC,qDAI0B;AAC1B,uCAKmB;AACnB,uGAIm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CAAC,wBAAS,EAAE;YACd,+BAAgB,EAAE,CAAC;SACpB;QACD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC7B,MAAM,CAAC,MAAM,CAAC,kCAAmB,EAAE,GAAS,EAAE;gBAC5C,qBAAY,CAAC,GAAG,CAAC,yBAAyB,kCAAmB,EAAE,CAAC,CAAC;gBAEjE,IAAI,CAAC,mBAAmB,EAAE;oBACxB,mBAAmB,GAAG,MAAM,qCAA2B,CACrD,sBAAsB,CACvB,CAAC;oBACF,qBAAY,CAAC,UAAU,CAAC,iCAAiC,sBAAW,EAAE,CAAC,CAAC;iBACzE;gBAED,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC;YACzB,CAAC,CAAA,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CAAA;AAnBD,kCAmBC;AAED,SAAsB,UAAU;;QAC9B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;gBACnB,IAAI,GAAG,EAAE;oBACP;;;;uBAIG;oBACH,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,uBAAuB,CAAC,EAAE;wBACpD,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;qBACpB;iBACF;gBAED,+BAAgB,EAAE,CAAC;gBACnB,eAAM,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;gBAC1C,OAAO,OAAO,EAAE,CAAC;YACnB,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CAAA;AAnBD,gCAmBC"}
|
|
@@ -7,17 +7,7 @@ const server_1 = require("./server");
|
|
|
7
7
|
(() => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
8
8
|
try {
|
|
9
9
|
yield server_1.stopServer();
|
|
10
|
-
|
|
11
|
-
const cachedDaemonJson = yield cache_1.readDaemonJsonCache();
|
|
12
|
-
if (cachedDaemonJson) {
|
|
13
|
-
if (cachedDaemonJson.backgroundProcessId) {
|
|
14
|
-
try {
|
|
15
|
-
process.kill(cachedDaemonJson.backgroundProcessId);
|
|
16
|
-
}
|
|
17
|
-
catch (_a) { }
|
|
18
|
-
}
|
|
19
|
-
cache_1.deleteDaemonJsonCache();
|
|
20
|
-
}
|
|
10
|
+
yield cache_1.safelyCleanUpExistingProcess();
|
|
21
11
|
}
|
|
22
12
|
catch (err) {
|
|
23
13
|
devkit_1.logger.error(err);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stop.js","sourceRoot":"","sources":["../../../../../../../../packages/workspace/src/core/project-graph/daemon/server/stop.ts"],"names":[],"mappings":";;;AAAA,yCAAsC;AACtC,
|
|
1
|
+
{"version":3,"file":"stop.js","sourceRoot":"","sources":["../../../../../../../../packages/workspace/src/core/project-graph/daemon/server/stop.ts"],"names":[],"mappings":";;;AAAA,yCAAsC;AACtC,oCAAwD;AACxD,qCAAsC;AAEtC,CAAC,GAAS,EAAE;IACV,IAAI;QACF,MAAM,mBAAU,EAAE,CAAC;QACnB,MAAM,oCAA4B,EAAE,CAAC;KACtC;IAAC,OAAO,GAAG,EAAE;QACZ,eAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;KACnB;AACH,CAAC,CAAA,CAAC,EAAE,CAAC"}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { ProjectGraph } from '@nrwl/devkit';
|
|
2
2
|
export declare const isWindows: boolean;
|
|
3
|
+
/**
|
|
4
|
+
* For IPC with the daemon server we use unix sockets or windows named pipes, depending on the user's operating system.
|
|
5
|
+
*
|
|
6
|
+
* See https://nodejs.org/dist/latest-v14.x/docs/api/net.html#net_identifying_paths_for_ipc_connections for a full breakdown
|
|
7
|
+
* of OS differences between Unix domain sockets and named pipes.
|
|
8
|
+
*/
|
|
3
9
|
export declare const FULL_OS_SOCKET_PATH: string;
|
|
4
10
|
export declare function killSocketOrPath(): void;
|
|
5
11
|
export interface ProjectGraphServerResult {
|
|
@@ -1,24 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.deserializeResult = exports.serializeResult = exports.killSocketOrPath = exports.FULL_OS_SOCKET_PATH = exports.isWindows = void 0;
|
|
4
|
-
const app_root_1 = require("@nrwl/tao/src/utils/app-root");
|
|
5
4
|
const fs_1 = require("fs");
|
|
6
5
|
const os_1 = require("os");
|
|
7
6
|
const path_1 = require("path");
|
|
7
|
+
const tmp_dir_1 = require("./tmp-dir");
|
|
8
|
+
exports.isWindows = os_1.platform() === 'win32';
|
|
8
9
|
/**
|
|
9
10
|
* For IPC with the daemon server we use unix sockets or windows named pipes, depending on the user's operating system.
|
|
10
11
|
*
|
|
11
12
|
* See https://nodejs.org/dist/latest-v14.x/docs/api/net.html#net_identifying_paths_for_ipc_connections for a full breakdown
|
|
12
13
|
* of OS differences between Unix domain sockets and named pipes.
|
|
13
|
-
*
|
|
14
|
-
* We currently create the socket/pipe based on a path within the current workspace so that we maintain one unique daemon per
|
|
15
|
-
* workspace to ensure that subtle differences between Nx workspaces cannot cause issues.
|
|
16
14
|
*/
|
|
17
|
-
const workspaceSocketPath = path_1.join(app_root_1.appRootPath, './nx-daemon.sock');
|
|
18
|
-
exports.isWindows = os_1.platform() === 'win32';
|
|
19
15
|
exports.FULL_OS_SOCKET_PATH = exports.isWindows
|
|
20
|
-
? '\\\\.\\pipe\\nx\\' + path_1.resolve(
|
|
21
|
-
: path_1.resolve(
|
|
16
|
+
? '\\\\.\\pipe\\nx\\' + path_1.resolve(tmp_dir_1.DAEMON_SOCKET_PATH)
|
|
17
|
+
: path_1.resolve(tmp_dir_1.DAEMON_SOCKET_PATH);
|
|
22
18
|
function killSocketOrPath() {
|
|
23
19
|
try {
|
|
24
20
|
fs_1.unlinkSync(exports.FULL_OS_SOCKET_PATH);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socket-utils.js","sourceRoot":"","sources":["../../../../../../../packages/workspace/src/core/project-graph/daemon/socket-utils.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"socket-utils.js","sourceRoot":"","sources":["../../../../../../../packages/workspace/src/core/project-graph/daemon/socket-utils.ts"],"names":[],"mappings":";;;AACA,2BAAgC;AAChC,2BAA8B;AAC9B,+BAA+B;AAC/B,uCAA+C;AAElC,QAAA,SAAS,GAAG,aAAQ,EAAE,KAAK,OAAO,CAAC;AAEhD;;;;;GAKG;AACU,QAAA,mBAAmB,GAAG,iBAAS;IAC1C,CAAC,CAAC,mBAAmB,GAAG,cAAO,CAAC,4BAAkB,CAAC;IACnD,CAAC,CAAC,cAAO,CAAC,4BAAkB,CAAC,CAAC;AAEhC,SAAgB,gBAAgB;IAC9B,IAAI;QACF,eAAU,CAAC,2BAAmB,CAAC,CAAC;KACjC;IAAC,WAAM,GAAE;AACZ,CAAC;AAJD,4CAIC;AAOD,2GAA2G;AAC3G,SAAS,cAAc,CAAC,KAAmB;IACzC,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,IAAI,CAAC;KACb;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAAC;AAClE,CAAC;AAED,+FAA+F;AAC/F,SAAgB,eAAe,CAC7B,KAAmB,EACnB,sBAAqC;IAErC,iIAAiI;IACjI,OAAO,cAAc,cAAc,CACjC,KAAK,CACN,qBAAqB,sBAAsB,IAAI,CAAC;AACnD,CAAC;AARD,0CAQC;AAED,2FAA2F;AAC3F,SAAgB,iBAAiB,CAC/B,gBAAwB;IAExB,IAAI;QACF,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QAC5C,IAAI,MAAM,CAAC,KAAK,EAAE;YAChB,MAAM,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC;YACxB,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC;YACnC,GAAG,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC;YAC/B,MAAM,CAAC,KAAK,GAAG,GAAG,CAAC;SACpB;QACD,OAAO,MAAM,CAAC;KACf;IAAC,WAAM;QACN,OAAO;YACL,KAAK,EAAE,IAAI,KAAK,CAAC,6CAA6C,CAAC;YAC/D,YAAY,EAAE,IAAI;SACnB,CAAC;KACH;AACH,CAAC;AAlBD,8CAkBC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* E.g. on a mac the value for this will be something like:
|
|
3
|
+
* /var/folders/zk/9ff5snsj71j2r07qht44w_nr0000gn/T/nx-daemon/{{subDirForCurrentWorkspace}}
|
|
4
|
+
*/
|
|
5
|
+
export declare const DAEMON_DIR_FOR_CURRENT_WORKSPACE: string;
|
|
6
|
+
export declare const DAEMON_OUTPUT_LOG_FILE: string;
|
|
7
|
+
export declare const DAEMON_SOCKET_PATH: string;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DAEMON_SOCKET_PATH = exports.DAEMON_OUTPUT_LOG_FILE = exports.DAEMON_DIR_FOR_CURRENT_WORKSPACE = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Per workspace (to avoid subtle differences and issues), we want to have a deterministic
|
|
6
|
+
* location within the OS's tmp directory where we write log files for background processes
|
|
7
|
+
* and where we create the actual unix socket/named pipe for the daemon.
|
|
8
|
+
*/
|
|
9
|
+
const devkit_1 = require("@nrwl/devkit");
|
|
10
|
+
const app_root_1 = require("@nrwl/tao/src/utils/app-root");
|
|
11
|
+
const fs_extra_1 = require("fs-extra");
|
|
12
|
+
const os_1 = require("os");
|
|
13
|
+
const path_1 = require("path");
|
|
14
|
+
const crypto_1 = require("crypto");
|
|
15
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping
|
|
16
|
+
function escapeRegExp(string) {
|
|
17
|
+
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* As part of deterministically generating a tmp dir for the daemon related outputs to go in,
|
|
21
|
+
* we create a unique name for the current workspace based on the full normalized absolute
|
|
22
|
+
* path to its root directory.
|
|
23
|
+
*/
|
|
24
|
+
function createUniqueNameForCurrentWorkspace() {
|
|
25
|
+
let pathAsName = devkit_1.normalizePath(app_root_1.appRootPath).replace(
|
|
26
|
+
// Replace the occurrences of / in the unix-style normalized path with a -
|
|
27
|
+
new RegExp(escapeRegExp('/'), 'g'), '-');
|
|
28
|
+
if (pathAsName[0] === '-') {
|
|
29
|
+
pathAsName = pathAsName.slice(1);
|
|
30
|
+
}
|
|
31
|
+
return pathAsName;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The unique names generated by createUniqueNameForCurrentWorkspace() can potentially be too long
|
|
35
|
+
* to leverage for the daemon because the character length of unix sockets and named pipes is limited:
|
|
36
|
+
*
|
|
37
|
+
* - Windows: 256 chars (named pipe)
|
|
38
|
+
* - Unix: 108 chars (unix socket)
|
|
39
|
+
* - macOS and BSD: 104 chars (unix socket)
|
|
40
|
+
*
|
|
41
|
+
* We therefore hash them using a fixed length algorithm to be able to limit their length but still
|
|
42
|
+
* have them be unique and deterministic. SHA-1 should be "good enough" for this specific purpose.
|
|
43
|
+
*/
|
|
44
|
+
const subDirForCurrentWorkspace = crypto_1.createHash('sha1')
|
|
45
|
+
.update(createUniqueNameForCurrentWorkspace())
|
|
46
|
+
.digest('hex')
|
|
47
|
+
.slice(0, 32);
|
|
48
|
+
/**
|
|
49
|
+
* E.g. on a mac the value for this will be something like:
|
|
50
|
+
* /var/folders/zk/9ff5snsj71j2r07qht44w_nr0000gn/T/nx-daemon/{{subDirForCurrentWorkspace}}
|
|
51
|
+
*/
|
|
52
|
+
exports.DAEMON_DIR_FOR_CURRENT_WORKSPACE = path_1.join(os_1.tmpdir(), 'nx-daemon', subDirForCurrentWorkspace);
|
|
53
|
+
fs_extra_1.ensureDirSync(exports.DAEMON_DIR_FOR_CURRENT_WORKSPACE);
|
|
54
|
+
exports.DAEMON_OUTPUT_LOG_FILE = path_1.join(exports.DAEMON_DIR_FOR_CURRENT_WORKSPACE, 'server.log');
|
|
55
|
+
fs_extra_1.ensureFileSync(exports.DAEMON_OUTPUT_LOG_FILE);
|
|
56
|
+
exports.DAEMON_SOCKET_PATH = path_1.join(exports.DAEMON_DIR_FOR_CURRENT_WORKSPACE,
|
|
57
|
+
// As per notes above on socket/named pipe length limitations, we keep this intentionally short
|
|
58
|
+
'd.sock');
|
|
59
|
+
//# sourceMappingURL=tmp-dir.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tmp-dir.js","sourceRoot":"","sources":["../../../../../../../packages/workspace/src/core/project-graph/daemon/tmp-dir.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,yCAA6C;AAC7C,2DAA2D;AAC3D,uCAAyD;AACzD,2BAA4B;AAC5B,+BAA4B;AAC5B,mCAAoC;AAEpC,6FAA6F;AAC7F,SAAS,YAAY,CAAC,MAAM;IAC1B,OAAO,MAAM,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC,CAAC,oCAAoC;AAC5F,CAAC;AAED;;;;GAIG;AACH,SAAS,mCAAmC;IAC1C,IAAI,UAAU,GAAG,sBAAa,CAAC,sBAAW,CAAC,CAAC,OAAO;IACjD,0EAA0E;IAC1E,IAAI,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,EAClC,GAAG,CACJ,CAAC;IACF,IAAI,UAAU,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;QACzB,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KAClC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,yBAAyB,GAAG,mBAAU,CAAC,MAAM,CAAC;KACjD,MAAM,CAAC,mCAAmC,EAAE,CAAC;KAC7C,MAAM,CAAC,KAAK,CAAC;KACb,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAEhB;;;GAGG;AACU,QAAA,gCAAgC,GAAG,WAAI,CAClD,WAAM,EAAE,EACR,WAAW,EACX,yBAAyB,CAC1B,CAAC;AACF,wBAAa,CAAC,wCAAgC,CAAC,CAAC;AAEnC,QAAA,sBAAsB,GAAG,WAAI,CACxC,wCAAgC,EAChC,YAAY,CACb,CAAC;AACF,yBAAc,CAAC,8BAAsB,CAAC,CAAC;AAE1B,QAAA,kBAAkB,GAAG,WAAI,CACpC,wCAAgC;AAChC,+FAA+F;AAC/F,QAAQ,CACT,CAAC"}
|
|
@@ -8,7 +8,7 @@ const build_project_graph_1 = require("./build-project-graph");
|
|
|
8
8
|
* Synchronously reads the latest cached copy of the workspace's ProjectGraph.
|
|
9
9
|
* @throws {Error} if there is no cached ProjectGraph to read from
|
|
10
10
|
*/
|
|
11
|
-
function readCachedProjectGraph(projectGraphVersion = '
|
|
11
|
+
function readCachedProjectGraph(projectGraphVersion = '4.0') {
|
|
12
12
|
const projectGraphCache = nx_deps_cache_1.readCache();
|
|
13
13
|
if (!projectGraphCache) {
|
|
14
14
|
throw new Error(`
|
|
@@ -20,21 +20,14 @@ function readCachedProjectGraph(projectGraphVersion = '3.0') {
|
|
|
20
20
|
If you encounter this error as part of running standard \`nx\` commands then please open an issue on https://github.com/nrwl/nx
|
|
21
21
|
`);
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
return {
|
|
24
24
|
version: projectGraphCache.version,
|
|
25
25
|
nodes: projectGraphCache.nodes,
|
|
26
26
|
dependencies: projectGraphCache.dependencies,
|
|
27
27
|
};
|
|
28
|
-
if (projectGraphVersion !== projectGraph.version) {
|
|
29
|
-
projectGraph =
|
|
30
|
-
projectGraphVersion === '3.0'
|
|
31
|
-
? build_project_graph_1.projectGraphCompat4to3(projectGraph)
|
|
32
|
-
: build_project_graph_1.projectGraphMigrate3to4(projectGraph);
|
|
33
|
-
}
|
|
34
|
-
return projectGraph;
|
|
35
28
|
}
|
|
36
29
|
exports.readCachedProjectGraph = readCachedProjectGraph;
|
|
37
|
-
function createProjectGraphAsync(projectGraphVersion = '
|
|
30
|
+
function createProjectGraphAsync(projectGraphVersion = '4.0') {
|
|
38
31
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
39
32
|
/**
|
|
40
33
|
* Using the daemon is currently an undocumented, opt-in feature while we build out its capabilities.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-graph.js","sourceRoot":"","sources":["../../../../../../packages/workspace/src/core/project-graph/project-graph.ts"],"names":[],"mappings":";;;;AACA,4DAAwE;AACxE,+
|
|
1
|
+
{"version":3,"file":"project-graph.js","sourceRoot":"","sources":["../../../../../../packages/workspace/src/core/project-graph/project-graph.ts"],"names":[],"mappings":";;;;AACA,4DAAwE;AACxE,+DAA0D;AAE1D;;;GAGG;AACH,SAAgB,sBAAsB,CACpC,mBAAmB,GAAG,KAAK;IAE3B,MAAM,iBAAiB,GAA8B,yBAAS,EAAE,CAAC;IACjE,IAAI,CAAC,iBAAiB,EAAE;QACtB,MAAM,IAAI,KAAK,CAAC;;;;;;;KAOf,CAAC,CAAC;KACJ;IACD,OAAO;QACL,OAAO,EAAE,iBAAiB,CAAC,OAAO;QAClC,KAAK,EAAE,iBAAiB,CAAC,KAAK;QAC9B,YAAY,EAAE,iBAAiB,CAAC,YAAY;KAC7C,CAAC;AACJ,CAAC;AAnBD,wDAmBC;AAED,SAAsB,uBAAuB,CAC3C,mBAAmB,GAAG,KAAK;;QAE3B;;;WAGG;QACH,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,KAAK,MAAM,EAAE;YACpC,OAAO,uCAAiB,CAAC,mBAAmB,CAAC,CAAC;SAC/C;QAED,MAAM,YAAY,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;QACvD,IAAI,CAAC,CAAC,MAAM,YAAY,CAAC,iBAAiB,EAAE,CAAC,EAAE;YAC7C,MAAM,YAAY,CAAC,iBAAiB,EAAE,CAAC;SACxC;QAED,OAAO,YAAY,CAAC,yBAAyB,EAAE,CAAC;IAClD,CAAC;CAAA;AAjBD,0DAiBC"}
|