nx 22.2.0-canary.20251124-70bbbe9 → 22.2.0-canary.20251125-7e00ec4
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/bin/init-local.d.ts.map +1 -1
- package/bin/init-local.js +40 -2
- package/package.json +11 -11
- package/release/changelog-renderer/index.d.ts +1 -0
- package/release/changelog-renderer/index.d.ts.map +1 -1
- package/release/changelog-renderer/index.js +12 -12
- package/src/ai/constants.d.ts +6 -1
- package/src/ai/constants.d.ts.map +1 -1
- package/src/ai/constants.js +14 -3
- package/src/ai/set-up-ai-agents/set-up-ai-agents.d.ts.map +1 -1
- package/src/ai/set-up-ai-agents/set-up-ai-agents.js +41 -7
- package/src/command-line/report/report.d.ts +4 -0
- package/src/command-line/report/report.d.ts.map +1 -1
- package/src/command-line/report/report.js +72 -1
- package/src/core/graph/main.js +1 -1
- package/src/daemon/cache.d.ts +2 -1
- package/src/daemon/cache.d.ts.map +1 -1
- package/src/daemon/cache.js +10 -26
- package/src/daemon/client/client.d.ts +5 -0
- package/src/daemon/client/client.d.ts.map +1 -1
- package/src/daemon/client/client.js +67 -26
- package/src/daemon/is-nx-version-mismatch.d.ts +3 -0
- package/src/daemon/is-nx-version-mismatch.d.ts.map +1 -0
- package/src/daemon/is-nx-version-mismatch.js +24 -0
- package/src/daemon/message-types/nx-console.d.ts +18 -0
- package/src/daemon/message-types/nx-console.d.ts.map +1 -0
- package/src/daemon/message-types/nx-console.js +19 -0
- package/src/daemon/server/handle-nx-console.d.ts +4 -0
- package/src/daemon/server/handle-nx-console.d.ts.map +1 -0
- package/src/daemon/server/handle-nx-console.js +54 -0
- package/src/daemon/server/nx-console-operations.d.ts +31 -0
- package/src/daemon/server/nx-console-operations.d.ts.map +1 -0
- package/src/daemon/server/nx-console-operations.js +135 -0
- package/src/daemon/server/server.d.ts.map +1 -1
- package/src/daemon/server/server.js +19 -18
- package/src/daemon/server/shutdown-utils.d.ts.map +1 -1
- package/src/daemon/server/shutdown-utils.js +3 -0
- package/src/daemon/tmp-dir.d.ts.map +1 -1
- package/src/daemon/tmp-dir.js +1 -0
- package/src/devkit-internals.d.ts +1 -1
- package/src/devkit-internals.d.ts.map +1 -1
- package/src/devkit-internals.js +2 -1
- package/src/tasks-runner/pseudo-terminal.js +1 -1
- package/src/tasks-runner/task-orchestrator.d.ts +1 -0
- package/src/tasks-runner/task-orchestrator.d.ts.map +1 -1
- package/src/tasks-runner/task-orchestrator.js +22 -5
- package/src/utils/package-json.d.ts +4 -0
- package/src/utils/package-json.d.ts.map +1 -1
- package/src/utils/package-json.js +45 -11
- package/src/utils/package-manager.d.ts +1 -0
- package/src/utils/package-manager.d.ts.map +1 -1
- package/src/utils/package-manager.js +4 -0
package/src/daemon/cache.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export interface DaemonProcessJson {
|
|
2
2
|
processId: number;
|
|
3
|
+
socketPath: string;
|
|
4
|
+
nxVersion: string;
|
|
3
5
|
}
|
|
4
6
|
export declare const serverProcessJsonPath: string;
|
|
5
7
|
export declare function readDaemonProcessJsonCache(): DaemonProcessJson | null;
|
|
6
8
|
export declare function deleteDaemonJsonProcessCache(): void;
|
|
7
9
|
export declare function writeDaemonJsonProcessCache(daemonJson: DaemonProcessJson): Promise<void>;
|
|
8
|
-
export declare function waitForDaemonToExitAndCleanupProcessJson(): Promise<void>;
|
|
9
10
|
export declare function getDaemonProcessIdSync(): number | null;
|
|
10
11
|
//# sourceMappingURL=cache.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../../../packages/nx/src/daemon/cache.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../../../packages/nx/src/daemon/cache.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,qBAAqB,QAGjC,CAAC;AAEF,wBAAgB,0BAA0B,IAAI,iBAAiB,GAAG,IAAI,CAWrE;AAED,wBAAgB,4BAA4B,IAAI,IAAI,CAMnD;AAED,wBAAsB,2BAA2B,CAC/C,UAAU,EAAE,iBAAiB,GAC5B,OAAO,CAAC,IAAI,CAAC,CAIf;AAGD,wBAAgB,sBAAsB,IAAI,MAAM,GAAG,IAAI,CAUtD"}
|
package/src/daemon/cache.js
CHANGED
|
@@ -4,18 +4,25 @@ exports.serverProcessJsonPath = void 0;
|
|
|
4
4
|
exports.readDaemonProcessJsonCache = readDaemonProcessJsonCache;
|
|
5
5
|
exports.deleteDaemonJsonProcessCache = deleteDaemonJsonProcessCache;
|
|
6
6
|
exports.writeDaemonJsonProcessCache = writeDaemonJsonProcessCache;
|
|
7
|
-
exports.waitForDaemonToExitAndCleanupProcessJson = waitForDaemonToExitAndCleanupProcessJson;
|
|
8
7
|
exports.getDaemonProcessIdSync = getDaemonProcessIdSync;
|
|
9
8
|
const node_fs_1 = require("node:fs");
|
|
10
9
|
const path_1 = require("path");
|
|
11
10
|
const tmp_dir_1 = require("./tmp-dir");
|
|
12
11
|
const fileutils_1 = require("../utils/fileutils");
|
|
12
|
+
const versions_1 = require("../utils/versions");
|
|
13
13
|
exports.serverProcessJsonPath = (0, path_1.join)(tmp_dir_1.DAEMON_DIR_FOR_CURRENT_WORKSPACE, 'server-process.json');
|
|
14
14
|
function readDaemonProcessJsonCache() {
|
|
15
|
-
|
|
15
|
+
try {
|
|
16
|
+
const daemonJson = (0, fileutils_1.readJsonFile)(exports.serverProcessJsonPath);
|
|
17
|
+
// If the daemon version doesn't match the client version, treat it as stale
|
|
18
|
+
if (daemonJson.nxVersion !== versions_1.nxVersion) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return daemonJson;
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
16
24
|
return null;
|
|
17
25
|
}
|
|
18
|
-
return (0, fileutils_1.readJsonFile)(exports.serverProcessJsonPath);
|
|
19
26
|
}
|
|
20
27
|
function deleteDaemonJsonProcessCache() {
|
|
21
28
|
try {
|
|
@@ -30,29 +37,6 @@ async function writeDaemonJsonProcessCache(daemonJson) {
|
|
|
30
37
|
appendNewLine: true,
|
|
31
38
|
});
|
|
32
39
|
}
|
|
33
|
-
async function waitForDaemonToExitAndCleanupProcessJson() {
|
|
34
|
-
const daemonProcessJson = readDaemonProcessJsonCache();
|
|
35
|
-
if (daemonProcessJson && daemonProcessJson.processId) {
|
|
36
|
-
await new Promise((resolve, reject) => {
|
|
37
|
-
let count = 0;
|
|
38
|
-
const interval = setInterval(() => {
|
|
39
|
-
try {
|
|
40
|
-
// sending a signal 0 to a process checks if the process is running instead of actually killing it
|
|
41
|
-
process.kill(daemonProcessJson.processId, 0);
|
|
42
|
-
}
|
|
43
|
-
catch (e) {
|
|
44
|
-
clearInterval(interval);
|
|
45
|
-
resolve();
|
|
46
|
-
}
|
|
47
|
-
if ((count += 1) > 200) {
|
|
48
|
-
clearInterval(interval);
|
|
49
|
-
reject(`Daemon process ${daemonProcessJson.processId} didn't exit after 2 seconds.`);
|
|
50
|
-
}
|
|
51
|
-
}, 10);
|
|
52
|
-
});
|
|
53
|
-
deleteDaemonJsonProcessCache();
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
40
|
// Must be sync for the help output use case
|
|
57
41
|
function getDaemonProcessIdSync() {
|
|
58
42
|
if (!(0, node_fs_1.existsSync)(exports.serverProcessJsonPath)) {
|
|
@@ -6,6 +6,7 @@ import { ConfigurationSourceMaps } from '../../project-graph/utils/project-confi
|
|
|
6
6
|
import { NxWorkspaceFiles, TaskRun, TaskTarget } from '../../native';
|
|
7
7
|
import type { FlushSyncGeneratorChangesResult, SyncGeneratorRunResult } from '../../utils/sync-generators';
|
|
8
8
|
import { PostTasksExecutionContext, PreTasksExecutionContext } from '../../project-graph/plugins/public-api';
|
|
9
|
+
import { type NxConsoleStatusResponse, type SetNxConsolePreferenceAndInstallResponse } from '../message-types/nx-console';
|
|
9
10
|
export type UnregisterCallback = () => void;
|
|
10
11
|
export type ChangedFile = {
|
|
11
12
|
path: string;
|
|
@@ -27,6 +28,7 @@ export declare class DaemonClient {
|
|
|
27
28
|
private _err;
|
|
28
29
|
enabled(): boolean;
|
|
29
30
|
reset(): void;
|
|
31
|
+
private getSocketPath;
|
|
30
32
|
requestShutdown(): Promise<void>;
|
|
31
33
|
getProjectGraphAndSourceMaps(): Promise<{
|
|
32
34
|
projectGraph: ProjectGraph;
|
|
@@ -69,7 +71,10 @@ export declare class DaemonClient {
|
|
|
69
71
|
updateWorkspaceContext(createdFiles: string[], updatedFiles: string[], deletedFiles: string[]): Promise<void>;
|
|
70
72
|
runPreTasksExecution(context: PreTasksExecutionContext): Promise<NodeJS.ProcessEnv[]>;
|
|
71
73
|
runPostTasksExecution(context: PostTasksExecutionContext): Promise<void>;
|
|
74
|
+
getNxConsoleStatus(): Promise<NxConsoleStatusResponse>;
|
|
75
|
+
setNxConsolePreferenceAndInstall(preference: boolean): Promise<SetNxConsolePreferenceAndInstallResponse>;
|
|
72
76
|
isServerAvailable(): Promise<boolean>;
|
|
77
|
+
private startDaemonIfNecessary;
|
|
73
78
|
private sendToDaemonViaQueue;
|
|
74
79
|
private setUpConnection;
|
|
75
80
|
private sendMessageToDaemon;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/daemon/client/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAS,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/daemon/client/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAS,MAAM,eAAe,CAAC;AAmBpD,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,4BAA4B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YAAY,EAAE,MAAM,EAAE,EACtB,YAAY,EAAE,MAAM,EAAE,GACrB,OAAO,CAAC,IAAI,CAAC;IAUV,oBAAoB,CACxB,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;IAQzB,qBAAqB,CACzB,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,IAAI,CAAC;IAQhB,kBAAkB,IAAI,OAAO,CAAC,uBAAuB,CAAC;IAOtD,gCAAgC,CAC9B,UAAU,EAAE,OAAO,GAClB,OAAO,CAAC,wCAAwC,CAAC;IAQ9C,iBAAiB,IAAI,OAAO,CAAC,OAAO,CAAC;YAqB7B,sBAAsB;YAyBtB,oBAAoB;IASlC,OAAO,CAAC,eAAe;YAqDT,mBAAmB;YAsBnB,uCAAuC;IAiBrD,OAAO,CAAC,gCAAgC;IAyBxC,OAAO,CAAC,aAAa;IAmDf,iBAAiB,IAAI,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IAwDjD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAkB5B;AAED,eAAO,MAAM,YAAY,cAAqB,CAAC;AAE/C,wBAAgB,eAAe,YAE9B"}
|
|
@@ -10,7 +10,6 @@ const net_1 = require("net");
|
|
|
10
10
|
const path_1 = require("path");
|
|
11
11
|
const perf_hooks_1 = require("perf_hooks");
|
|
12
12
|
const output_1 = require("../../utils/output");
|
|
13
|
-
const socket_utils_1 = require("../socket-utils");
|
|
14
13
|
const tmp_dir_1 = require("../tmp-dir");
|
|
15
14
|
const is_ci_1 = require("../../utils/is-ci");
|
|
16
15
|
const nx_json_1 = require("../../config/nx-json");
|
|
@@ -18,6 +17,7 @@ const configuration_1 = require("../../config/configuration");
|
|
|
18
17
|
const promised_based_queue_1 = require("../../utils/promised-based-queue");
|
|
19
18
|
const daemon_socket_messenger_1 = require("./daemon-socket-messenger");
|
|
20
19
|
const cache_1 = require("../cache");
|
|
20
|
+
const is_nx_version_mismatch_1 = require("../is-nx-version-mismatch");
|
|
21
21
|
const error_types_1 = require("../../project-graph/error-types");
|
|
22
22
|
const native_1 = require("../../native");
|
|
23
23
|
const get_nx_workspace_files_1 = require("../message-types/get-nx-workspace-files");
|
|
@@ -32,6 +32,7 @@ const flush_sync_generator_changes_to_disk_1 = require("../message-types/flush-s
|
|
|
32
32
|
const delayed_spinner_1 = require("../../utils/delayed-spinner");
|
|
33
33
|
const run_tasks_execution_hooks_1 = require("../message-types/run-tasks-execution-hooks");
|
|
34
34
|
const register_project_graph_listener_1 = require("../message-types/register-project-graph-listener");
|
|
35
|
+
const nx_console_1 = require("../message-types/nx-console");
|
|
35
36
|
const node_v8_1 = require("node:v8");
|
|
36
37
|
const consume_messages_from_socket_1 = require("../../utils/consume-messages-from-socket");
|
|
37
38
|
const project_graph_1 = require("../../project-graph/project-graph");
|
|
@@ -81,7 +82,9 @@ class DaemonClient {
|
|
|
81
82
|
// docker=true,env=false => no daemon
|
|
82
83
|
// docker=true,env=true => daemon
|
|
83
84
|
// WASM => no daemon because file watching does not work
|
|
84
|
-
|
|
85
|
+
// version mismatch => no daemon because the installed nx version differs from the running one
|
|
86
|
+
if ((0, is_nx_version_mismatch_1.isNxVersionMismatch)() ||
|
|
87
|
+
(((0, is_ci_1.isCI)() || isDocker()) && env !== 'true') ||
|
|
85
88
|
(0, tmp_dir_1.isDaemonDisabled)() ||
|
|
86
89
|
nxJsonIsNotPresent() ||
|
|
87
90
|
(useDaemonProcessOption === undefined && env === 'false') ||
|
|
@@ -117,6 +120,15 @@ class DaemonClient {
|
|
|
117
120
|
this._daemonStatus = DaemonStatus.DISCONNECTED;
|
|
118
121
|
this._waitForDaemonReady = new Promise((resolve) => (this._daemonReady = resolve));
|
|
119
122
|
}
|
|
123
|
+
getSocketPath() {
|
|
124
|
+
const daemonProcessJson = (0, cache_1.readDaemonProcessJsonCache)();
|
|
125
|
+
if (daemonProcessJson?.socketPath) {
|
|
126
|
+
return daemonProcessJson.socketPath;
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
throw daemonProcessException('Unable to connect to daemon: no socket path available');
|
|
130
|
+
}
|
|
131
|
+
}
|
|
120
132
|
async requestShutdown() {
|
|
121
133
|
return this.sendToDaemonViaQueue({ type: 'REQUEST_SHUTDOWN' });
|
|
122
134
|
}
|
|
@@ -173,8 +185,10 @@ class DaemonClient {
|
|
|
173
185
|
}
|
|
174
186
|
}
|
|
175
187
|
let messenger;
|
|
176
|
-
await this.queue.sendToQueue(() => {
|
|
177
|
-
|
|
188
|
+
await this.queue.sendToQueue(async () => {
|
|
189
|
+
await this.startDaemonIfNecessary();
|
|
190
|
+
const socketPath = this.getSocketPath();
|
|
191
|
+
messenger = new daemon_socket_messenger_1.DaemonSocketMessenger((0, net_1.connect)(socketPath)).listen((message) => {
|
|
178
192
|
try {
|
|
179
193
|
const parsedMessage = (0, consume_messages_from_socket_1.isJsonMessage)(message)
|
|
180
194
|
? JSON.parse(message)
|
|
@@ -195,8 +209,10 @@ class DaemonClient {
|
|
|
195
209
|
}
|
|
196
210
|
async registerProjectGraphRecomputationListener(callback) {
|
|
197
211
|
let messenger;
|
|
198
|
-
await this.queue.sendToQueue(() => {
|
|
199
|
-
|
|
212
|
+
await this.queue.sendToQueue(async () => {
|
|
213
|
+
await this.startDaemonIfNecessary();
|
|
214
|
+
const socketPath = this.getSocketPath();
|
|
215
|
+
messenger = new daemon_socket_messenger_1.DaemonSocketMessenger((0, net_1.connect)(socketPath)).listen((message) => {
|
|
200
216
|
try {
|
|
201
217
|
const parsedMessage = (0, consume_messages_from_socket_1.isJsonMessage)(message)
|
|
202
218
|
? JSON.parse(message)
|
|
@@ -359,10 +375,28 @@ class DaemonClient {
|
|
|
359
375
|
};
|
|
360
376
|
return this.sendToDaemonViaQueue(message);
|
|
361
377
|
}
|
|
378
|
+
getNxConsoleStatus() {
|
|
379
|
+
const message = {
|
|
380
|
+
type: nx_console_1.GET_NX_CONSOLE_STATUS,
|
|
381
|
+
};
|
|
382
|
+
return this.sendToDaemonViaQueue(message);
|
|
383
|
+
}
|
|
384
|
+
setNxConsolePreferenceAndInstall(preference) {
|
|
385
|
+
const message = {
|
|
386
|
+
type: nx_console_1.SET_NX_CONSOLE_PREFERENCE_AND_INSTALL,
|
|
387
|
+
preference,
|
|
388
|
+
};
|
|
389
|
+
return this.sendToDaemonViaQueue(message);
|
|
390
|
+
}
|
|
362
391
|
async isServerAvailable() {
|
|
363
392
|
return new Promise((resolve) => {
|
|
364
393
|
try {
|
|
365
|
-
const
|
|
394
|
+
const socketPath = this.getSocketPath();
|
|
395
|
+
if (!socketPath) {
|
|
396
|
+
resolve(false);
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
const socket = (0, net_1.connect)(socketPath, () => {
|
|
366
400
|
socket.destroy();
|
|
367
401
|
resolve(true);
|
|
368
402
|
});
|
|
@@ -375,11 +409,35 @@ class DaemonClient {
|
|
|
375
409
|
}
|
|
376
410
|
});
|
|
377
411
|
}
|
|
412
|
+
async startDaemonIfNecessary() {
|
|
413
|
+
if (this._daemonStatus == DaemonStatus.CONNECTED) {
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
// Ensure daemon is running and socket path is available
|
|
417
|
+
if (this._daemonStatus == DaemonStatus.DISCONNECTED) {
|
|
418
|
+
this._daemonStatus = DaemonStatus.CONNECTING;
|
|
419
|
+
let daemonPid = null;
|
|
420
|
+
if (!(await this.isServerAvailable())) {
|
|
421
|
+
daemonPid = await this.startInBackground();
|
|
422
|
+
}
|
|
423
|
+
this.setUpConnection();
|
|
424
|
+
this._daemonStatus = DaemonStatus.CONNECTED;
|
|
425
|
+
this._daemonReady();
|
|
426
|
+
daemonPid ??= (0, cache_1.getDaemonProcessIdSync)();
|
|
427
|
+
await this.registerDaemonProcessWithMetricsService(daemonPid);
|
|
428
|
+
}
|
|
429
|
+
else if (this._daemonStatus == DaemonStatus.CONNECTING) {
|
|
430
|
+
await this._waitForDaemonReady;
|
|
431
|
+
const daemonPid = (0, cache_1.getDaemonProcessIdSync)();
|
|
432
|
+
await this.registerDaemonProcessWithMetricsService(daemonPid);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
378
435
|
async sendToDaemonViaQueue(messageToDaemon, force) {
|
|
379
436
|
return this.queue.sendToQueue(() => this.sendMessageToDaemon(messageToDaemon, force));
|
|
380
437
|
}
|
|
381
438
|
setUpConnection() {
|
|
382
|
-
|
|
439
|
+
const socketPath = this.getSocketPath();
|
|
440
|
+
this.socketMessenger = new daemon_socket_messenger_1.DaemonSocketMessenger((0, net_1.connect)(socketPath)).listen((message) => this.handleMessage(message), () => {
|
|
383
441
|
// it's ok for the daemon to terminate if the client doesn't wait on
|
|
384
442
|
// any messages from the daemon
|
|
385
443
|
if (this.queue.isEmpty()) {
|
|
@@ -407,7 +465,6 @@ class DaemonClient {
|
|
|
407
465
|
}
|
|
408
466
|
else if (err.message.startsWith('connect ECONNREFUSED')) {
|
|
409
467
|
error = daemonProcessException(`A server instance had not been fully shut down. Please try running the command again.`);
|
|
410
|
-
(0, socket_utils_1.killSocketOrPath)();
|
|
411
468
|
}
|
|
412
469
|
else if (err.message.startsWith('read ECONNRESET')) {
|
|
413
470
|
error = daemonProcessException(`Unable to connect to the daemon process.`);
|
|
@@ -419,23 +476,7 @@ class DaemonClient {
|
|
|
419
476
|
});
|
|
420
477
|
}
|
|
421
478
|
async sendMessageToDaemon(message, force) {
|
|
422
|
-
|
|
423
|
-
this._daemonStatus = DaemonStatus.CONNECTING;
|
|
424
|
-
let daemonPid = null;
|
|
425
|
-
if (!(await this.isServerAvailable())) {
|
|
426
|
-
daemonPid = await this.startInBackground();
|
|
427
|
-
}
|
|
428
|
-
this.setUpConnection();
|
|
429
|
-
this._daemonStatus = DaemonStatus.CONNECTED;
|
|
430
|
-
this._daemonReady();
|
|
431
|
-
daemonPid ??= (0, cache_1.getDaemonProcessIdSync)();
|
|
432
|
-
await this.registerDaemonProcessWithMetricsService(daemonPid);
|
|
433
|
-
}
|
|
434
|
-
else if (this._daemonStatus == DaemonStatus.CONNECTING) {
|
|
435
|
-
await this._waitForDaemonReady;
|
|
436
|
-
const daemonPid = (0, cache_1.getDaemonProcessIdSync)();
|
|
437
|
-
await this.registerDaemonProcessWithMetricsService(daemonPid);
|
|
438
|
-
}
|
|
479
|
+
await this.startDaemonIfNecessary();
|
|
439
480
|
// An open promise isn't enough to keep the event loop
|
|
440
481
|
// alive, so we set a timeout here and clear it when we hear
|
|
441
482
|
// back
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-nx-version-mismatch.d.ts","sourceRoot":"","sources":["../../../../../packages/nx/src/daemon/is-nx-version-mismatch.ts"],"names":[],"mappings":"AAMA,wBAAgB,qBAAqB,IAAI,MAAM,GAAG,IAAI,CAWrD;AAED,wBAAgB,mBAAmB,IAAI,OAAO,CAE7C"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getInstalledNxVersion = getInstalledNxVersion;
|
|
4
|
+
exports.isNxVersionMismatch = isNxVersionMismatch;
|
|
5
|
+
const fileutils_1 = require("../utils/fileutils");
|
|
6
|
+
const versions_1 = require("../utils/versions");
|
|
7
|
+
const workspace_root_1 = require("../utils/workspace-root");
|
|
8
|
+
const installation_directory_1 = require("../utils/installation-directory");
|
|
9
|
+
function getInstalledNxVersion() {
|
|
10
|
+
try {
|
|
11
|
+
const nxPackageJsonPath = require.resolve('nx/package.json', {
|
|
12
|
+
paths: (0, installation_directory_1.getNxRequirePaths)(workspace_root_1.workspaceRoot),
|
|
13
|
+
});
|
|
14
|
+
const { version } = (0, fileutils_1.readJsonFile)(nxPackageJsonPath);
|
|
15
|
+
return version;
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
// node modules are absent
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function isNxVersionMismatch() {
|
|
23
|
+
return getInstalledNxVersion() !== versions_1.nxVersion;
|
|
24
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const GET_NX_CONSOLE_STATUS: "GET_NX_CONSOLE_STATUS";
|
|
2
|
+
export declare const SET_NX_CONSOLE_PREFERENCE_AND_INSTALL: "SET_NX_CONSOLE_PREFERENCE_AND_INSTALL";
|
|
3
|
+
export type HandleGetNxConsoleStatusMessage = {
|
|
4
|
+
type: typeof GET_NX_CONSOLE_STATUS;
|
|
5
|
+
};
|
|
6
|
+
export type NxConsoleStatusResponse = {
|
|
7
|
+
shouldPrompt: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type HandleSetNxConsolePreferenceAndInstallMessage = {
|
|
10
|
+
type: typeof SET_NX_CONSOLE_PREFERENCE_AND_INSTALL;
|
|
11
|
+
preference: boolean;
|
|
12
|
+
};
|
|
13
|
+
export type SetNxConsolePreferenceAndInstallResponse = {
|
|
14
|
+
installed: boolean;
|
|
15
|
+
};
|
|
16
|
+
export declare function isHandleGetNxConsoleStatusMessage(message: unknown): message is HandleGetNxConsoleStatusMessage;
|
|
17
|
+
export declare function isHandleSetNxConsolePreferenceAndInstallMessage(message: unknown): message is HandleSetNxConsolePreferenceAndInstallMessage;
|
|
18
|
+
//# sourceMappingURL=nx-console.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nx-console.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/daemon/message-types/nx-console.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,EAAG,uBAAgC,CAAC;AACtE,eAAO,MAAM,qCAAqC,EAChD,uCAAgD,CAAC;AAEnD,MAAM,MAAM,+BAA+B,GAAG;IAC5C,IAAI,EAAE,OAAO,qBAAqB,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,YAAY,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,6CAA6C,GAAG;IAC1D,IAAI,EAAE,OAAO,qCAAqC,CAAC;IACnD,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,wCAAwC,GAAG;IACrD,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,wBAAgB,iCAAiC,CAC/C,OAAO,EAAE,OAAO,GACf,OAAO,IAAI,+BAA+B,CAO5C;AAED,wBAAgB,+CAA+C,CAC7D,OAAO,EAAE,OAAO,GACf,OAAO,IAAI,6CAA6C,CAO1D"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SET_NX_CONSOLE_PREFERENCE_AND_INSTALL = exports.GET_NX_CONSOLE_STATUS = void 0;
|
|
4
|
+
exports.isHandleGetNxConsoleStatusMessage = isHandleGetNxConsoleStatusMessage;
|
|
5
|
+
exports.isHandleSetNxConsolePreferenceAndInstallMessage = isHandleSetNxConsolePreferenceAndInstallMessage;
|
|
6
|
+
exports.GET_NX_CONSOLE_STATUS = 'GET_NX_CONSOLE_STATUS';
|
|
7
|
+
exports.SET_NX_CONSOLE_PREFERENCE_AND_INSTALL = 'SET_NX_CONSOLE_PREFERENCE_AND_INSTALL';
|
|
8
|
+
function isHandleGetNxConsoleStatusMessage(message) {
|
|
9
|
+
return (typeof message === 'object' &&
|
|
10
|
+
message !== null &&
|
|
11
|
+
'type' in message &&
|
|
12
|
+
message['type'] === exports.GET_NX_CONSOLE_STATUS);
|
|
13
|
+
}
|
|
14
|
+
function isHandleSetNxConsolePreferenceAndInstallMessage(message) {
|
|
15
|
+
return (typeof message === 'object' &&
|
|
16
|
+
message !== null &&
|
|
17
|
+
'type' in message &&
|
|
18
|
+
message['type'] === exports.SET_NX_CONSOLE_PREFERENCE_AND_INSTALL);
|
|
19
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { HandlerResult } from './server';
|
|
2
|
+
export declare function handleGetNxConsoleStatus(): Promise<HandlerResult>;
|
|
3
|
+
export declare function handleSetNxConsolePreferenceAndInstall(preference: boolean): Promise<HandlerResult>;
|
|
4
|
+
//# sourceMappingURL=handle-nx-console.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handle-nx-console.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/daemon/server/handle-nx-console.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAU9C,wBAAsB,wBAAwB,IAAI,OAAO,CAAC,aAAa,CAAC,CAmCvE;AAED,wBAAsB,sCAAsC,CAC1D,UAAU,EAAE,OAAO,GAClB,OAAO,CAAC,aAAa,CAAC,CAexB"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleGetNxConsoleStatus = handleGetNxConsoleStatus;
|
|
4
|
+
exports.handleSetNxConsolePreferenceAndInstall = handleSetNxConsolePreferenceAndInstall;
|
|
5
|
+
const nx_console_operations_1 = require("./nx-console-operations");
|
|
6
|
+
// Module-level state for caching
|
|
7
|
+
let cachedShouldPrompt = null;
|
|
8
|
+
let isComputing = false;
|
|
9
|
+
async function handleGetNxConsoleStatus() {
|
|
10
|
+
// Return cached result if available
|
|
11
|
+
if (cachedShouldPrompt !== null) {
|
|
12
|
+
const response = {
|
|
13
|
+
shouldPrompt: cachedShouldPrompt,
|
|
14
|
+
};
|
|
15
|
+
return {
|
|
16
|
+
response,
|
|
17
|
+
description: 'handleGetNxConsoleStatus',
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
// Kick off background computation if not already running
|
|
21
|
+
if (!isComputing) {
|
|
22
|
+
isComputing = true;
|
|
23
|
+
(0, nx_console_operations_1.getNxConsoleStatus)()
|
|
24
|
+
.then((result) => {
|
|
25
|
+
cachedShouldPrompt = result;
|
|
26
|
+
isComputing = false;
|
|
27
|
+
})
|
|
28
|
+
.catch(() => {
|
|
29
|
+
cachedShouldPrompt = null;
|
|
30
|
+
isComputing = false;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
// Return false for shouldPrompt if cache not ready (main process will noop)
|
|
34
|
+
const response = {
|
|
35
|
+
shouldPrompt: false,
|
|
36
|
+
};
|
|
37
|
+
return {
|
|
38
|
+
response,
|
|
39
|
+
description: 'handleGetNxConsoleStatus',
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
async function handleSetNxConsolePreferenceAndInstall(preference) {
|
|
43
|
+
// Immediately update cache - we know the answer now!
|
|
44
|
+
// User answered the prompt, so we won't prompt again
|
|
45
|
+
cachedShouldPrompt = false;
|
|
46
|
+
const result = await (0, nx_console_operations_1.handleNxConsolePreferenceAndInstall)({ preference });
|
|
47
|
+
const response = {
|
|
48
|
+
installed: result.installed,
|
|
49
|
+
};
|
|
50
|
+
return {
|
|
51
|
+
response,
|
|
52
|
+
description: 'handleSetNxConsolePreferenceAndInstall',
|
|
53
|
+
};
|
|
54
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gets the Nx Console status (whether we should prompt the user to install).
|
|
3
|
+
* Uses latest Nx version if available, falls back to local implementation.
|
|
4
|
+
*
|
|
5
|
+
* @returns boolean indicating whether we should prompt the user
|
|
6
|
+
*/
|
|
7
|
+
export declare function getNxConsoleStatus({ inner, }?: {
|
|
8
|
+
inner?: boolean;
|
|
9
|
+
}): Promise<boolean>;
|
|
10
|
+
/**
|
|
11
|
+
* Handles user preference submission and installs Nx Console if requested.
|
|
12
|
+
* Uses latest Nx version if available, falls back to local implementation.
|
|
13
|
+
*
|
|
14
|
+
* @param preference - whether the user wants to install Nx Console
|
|
15
|
+
* @returns object indicating whether installation succeeded
|
|
16
|
+
*/
|
|
17
|
+
export declare function handleNxConsolePreferenceAndInstall({ preference, inner, }: {
|
|
18
|
+
preference: boolean;
|
|
19
|
+
inner?: boolean;
|
|
20
|
+
}): Promise<{
|
|
21
|
+
installed: boolean;
|
|
22
|
+
}>;
|
|
23
|
+
/**
|
|
24
|
+
* Clean up the latest Nx installation on daemon shutdown.
|
|
25
|
+
*/
|
|
26
|
+
export declare function cleanupLatestNxInstallation(): void;
|
|
27
|
+
export declare function getNxConsoleStatusImpl(): Promise<boolean>;
|
|
28
|
+
export declare function handleNxConsolePreferenceAndInstallImpl(preference: boolean): Promise<{
|
|
29
|
+
installed: boolean;
|
|
30
|
+
}>;
|
|
31
|
+
//# sourceMappingURL=nx-console-operations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nx-console-operations.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/daemon/server/nx-console-operations.ts"],"names":[],"mappings":"AAiBA;;;;;GAKG;AACH,wBAAsB,kBAAkB,CAAC,EACvC,KAAK,GACN,GAAE;IACD,KAAK,CAAC,EAAE,OAAO,CAAC;CACZ,GAAG,OAAO,CAAC,OAAO,CAAC,CAwCxB;AAED;;;;;;GAMG;AACH,wBAAsB,mCAAmC,CAAC,EACxD,UAAU,EACV,KAAK,GACN,EAAE;IACD,UAAU,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,GAAG,OAAO,CAAC;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,CAAC,CAgDlC;AAED;;GAEG;AACH,wBAAgB,2BAA2B,IAAI,IAAI,CAOlD;AAED,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,OAAO,CAAC,CAsB/D;AAED,wBAAsB,uCAAuC,CAC3D,UAAU,EAAE,OAAO,GAClB,OAAO,CAAC;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,CAAC,CAUjC"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getNxConsoleStatus = getNxConsoleStatus;
|
|
4
|
+
exports.handleNxConsolePreferenceAndInstall = handleNxConsolePreferenceAndInstall;
|
|
5
|
+
exports.cleanupLatestNxInstallation = cleanupLatestNxInstallation;
|
|
6
|
+
exports.getNxConsoleStatusImpl = getNxConsoleStatusImpl;
|
|
7
|
+
exports.handleNxConsolePreferenceAndInstallImpl = handleNxConsolePreferenceAndInstallImpl;
|
|
8
|
+
const devkit_internals_1 = require("../../devkit-internals");
|
|
9
|
+
const os_1 = require("os");
|
|
10
|
+
const native_1 = require("../../native");
|
|
11
|
+
const logger_1 = require("./logger");
|
|
12
|
+
// Module-level state - persists across invocations within daemon lifecycle
|
|
13
|
+
let latestNxTmpPath = null;
|
|
14
|
+
let cleanupFn = null;
|
|
15
|
+
const log = (...messageParts) => {
|
|
16
|
+
logger_1.serverLogger.log('[NX-CONSOLE]:', ...messageParts);
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Gets the Nx Console status (whether we should prompt the user to install).
|
|
20
|
+
* Uses latest Nx version if available, falls back to local implementation.
|
|
21
|
+
*
|
|
22
|
+
* @returns boolean indicating whether we should prompt the user
|
|
23
|
+
*/
|
|
24
|
+
async function getNxConsoleStatus({ inner, } = {}) {
|
|
25
|
+
// Use local implementation if explicitly requested
|
|
26
|
+
if (process.env.NX_USE_LOCAL === 'true' || inner === true) {
|
|
27
|
+
log('Using local implementation (NX_USE_LOCAL=true or inner call)');
|
|
28
|
+
return await getNxConsoleStatusImpl();
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
// If we don't have a tmp path yet, pull latest Nx
|
|
32
|
+
if (latestNxTmpPath === null) {
|
|
33
|
+
log('Pulling latest Nx (latest) to check console status...');
|
|
34
|
+
const packageInstallResults = await (0, devkit_internals_1.installPackageToTmpAsync)('nx', 'latest');
|
|
35
|
+
latestNxTmpPath = packageInstallResults.tempDir;
|
|
36
|
+
cleanupFn = packageInstallResults.cleanup;
|
|
37
|
+
log('Successfully pulled latest Nx to', latestNxTmpPath);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
log('Reusing cached Nx installation from', latestNxTmpPath);
|
|
41
|
+
}
|
|
42
|
+
// Try to use the cached tmp path
|
|
43
|
+
const modulePath = require.resolve('nx/src/daemon/server/nx-console-operations.js', { paths: [latestNxTmpPath] });
|
|
44
|
+
const module = await Promise.resolve(`${modulePath}`).then(s => require(s));
|
|
45
|
+
const result = await module.getNxConsoleStatus({ inner: true });
|
|
46
|
+
log('Console status check completed, shouldPrompt:', result);
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
// If tmp path failed (e.g., directory was deleted), fall back to local immediately
|
|
51
|
+
log('Failed to use latest Nx, falling back to local implementation. Error:', error.message);
|
|
52
|
+
return await getNxConsoleStatusImpl();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Handles user preference submission and installs Nx Console if requested.
|
|
57
|
+
* Uses latest Nx version if available, falls back to local implementation.
|
|
58
|
+
*
|
|
59
|
+
* @param preference - whether the user wants to install Nx Console
|
|
60
|
+
* @returns object indicating whether installation succeeded
|
|
61
|
+
*/
|
|
62
|
+
async function handleNxConsolePreferenceAndInstall({ preference, inner, }) {
|
|
63
|
+
log('Handling user preference:', preference);
|
|
64
|
+
// Use local implementation if explicitly requested
|
|
65
|
+
if (process.env.NX_USE_LOCAL === 'true' || inner === true) {
|
|
66
|
+
log('Using local implementation (NX_USE_LOCAL=true or inner call)');
|
|
67
|
+
return await handleNxConsolePreferenceAndInstallImpl(preference);
|
|
68
|
+
}
|
|
69
|
+
try {
|
|
70
|
+
// If we don't have a tmp path yet, pull latest Nx
|
|
71
|
+
if (latestNxTmpPath === null) {
|
|
72
|
+
log('Pulling latest Nx (latest) to handle preference and install...');
|
|
73
|
+
const packageInstallResults = await (0, devkit_internals_1.installPackageToTmpAsync)('nx', 'latest');
|
|
74
|
+
latestNxTmpPath = packageInstallResults.tempDir;
|
|
75
|
+
cleanupFn = packageInstallResults.cleanup;
|
|
76
|
+
log('Successfully pulled latest Nx to', latestNxTmpPath);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
log('Reusing cached Nx installation from', latestNxTmpPath);
|
|
80
|
+
}
|
|
81
|
+
// Try to use the cached tmp path
|
|
82
|
+
const modulePath = require.resolve('nx/src/daemon/server/nx-console-operations.js', { paths: [latestNxTmpPath] });
|
|
83
|
+
const module = await Promise.resolve(`${modulePath}`).then(s => require(s));
|
|
84
|
+
const result = await module.handleNxConsolePreferenceAndInstall({
|
|
85
|
+
preference,
|
|
86
|
+
inner: true,
|
|
87
|
+
});
|
|
88
|
+
log('Preference saved and installation', result.installed ? 'succeeded' : 'skipped/failed');
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
// If tmp path failed (e.g., directory was deleted), fall back to local immediately
|
|
93
|
+
log('Failed to use latest Nx, falling back to local implementation. Error:', error.message);
|
|
94
|
+
return await handleNxConsolePreferenceAndInstallImpl(preference);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Clean up the latest Nx installation on daemon shutdown.
|
|
99
|
+
*/
|
|
100
|
+
function cleanupLatestNxInstallation() {
|
|
101
|
+
if (cleanupFn) {
|
|
102
|
+
log('Cleaning up latest Nx installation from', latestNxTmpPath);
|
|
103
|
+
cleanupFn();
|
|
104
|
+
}
|
|
105
|
+
latestNxTmpPath = null;
|
|
106
|
+
cleanupFn = null;
|
|
107
|
+
}
|
|
108
|
+
async function getNxConsoleStatusImpl() {
|
|
109
|
+
// If no cached preference, read from disk
|
|
110
|
+
const preferences = new native_1.NxConsolePreferences((0, os_1.homedir)());
|
|
111
|
+
const preference = preferences.getAutoInstallPreference();
|
|
112
|
+
const canInstallConsole = (0, native_1.canInstallNxConsole)();
|
|
113
|
+
// If user previously opted in but extension is not installed,
|
|
114
|
+
// they must have manually uninstalled it - respect that choice
|
|
115
|
+
if (preference === true && canInstallConsole) {
|
|
116
|
+
const preferences = new native_1.NxConsolePreferences((0, os_1.homedir)());
|
|
117
|
+
preferences.setAutoInstallPreference(false);
|
|
118
|
+
return false; // Don't prompt
|
|
119
|
+
}
|
|
120
|
+
// Noop if can't install
|
|
121
|
+
if (!canInstallConsole) {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
// Prompt if we can install and user hasn't answered yet
|
|
125
|
+
return typeof preference !== 'boolean';
|
|
126
|
+
}
|
|
127
|
+
async function handleNxConsolePreferenceAndInstallImpl(preference) {
|
|
128
|
+
const preferences = new native_1.NxConsolePreferences((0, os_1.homedir)());
|
|
129
|
+
preferences.setAutoInstallPreference(preference);
|
|
130
|
+
let installed = false;
|
|
131
|
+
if (preference) {
|
|
132
|
+
installed = (0, native_1.installNxConsole)();
|
|
133
|
+
}
|
|
134
|
+
return { installed };
|
|
135
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/daemon/server/server.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/daemon/server/server.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AA+JnD,MAAM,MAAM,aAAa,GAAG;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;CACtC,CAAC;AAGF,eAAO,MAAM,WAAW,EAAE,GAAG,CAAC,MAAM,CAAa,CAAC;AA8RlD,wBAAsB,YAAY,CAChC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,OAAO,CAAC,aAAa,CAAC,EAClC,IAAI,EAAE,MAAM,GAAG,IAAI,iBA6BpB;AAoLD,wBAAsB,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC,CAyEnD"}
|