@angelitosystems/nest-devtools 1.0.6 → 1.0.7
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/dist/index.cjs +94 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +41 -4
- package/dist/index.d.ts +41 -4
- package/dist/index.js +93 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
NestDevTools: () => NestDevTools,
|
|
24
|
+
PluginManager: () => PluginManager,
|
|
24
25
|
captureError: () => captureError,
|
|
25
26
|
devtools: () => devtools,
|
|
26
27
|
requestContext: () => import_devtools_core12.requestContext
|
|
@@ -1375,6 +1376,84 @@ function printConnectionStatus(state, dashboard) {
|
|
|
1375
1376
|
writeOriginalConsole("log", ` ${paint(DIM, "Reintentando en segundo plano \u2014 se conectar\xE1 solo cuando el dashboard est\xE9 arriba.")}`);
|
|
1376
1377
|
}
|
|
1377
1378
|
|
|
1379
|
+
// src/plugins.ts
|
|
1380
|
+
var import_devtools_protocol7 = require("@angelitosystems/devtools-protocol");
|
|
1381
|
+
var PluginManager = class {
|
|
1382
|
+
constructor(plugins) {
|
|
1383
|
+
this.plugins = plugins;
|
|
1384
|
+
}
|
|
1385
|
+
plugins;
|
|
1386
|
+
cleanups = [];
|
|
1387
|
+
initialized = [];
|
|
1388
|
+
attach(app, config, project) {
|
|
1389
|
+
const redactor = new import_devtools_protocol7.Redactor({ redact: config.redact, allow: config.allow, maxBytes: config.maxPayloadBytes });
|
|
1390
|
+
const context = {
|
|
1391
|
+
config,
|
|
1392
|
+
project,
|
|
1393
|
+
redactor,
|
|
1394
|
+
emit: (event, payload) => {
|
|
1395
|
+
try {
|
|
1396
|
+
emit(event, redactor.redact(payload));
|
|
1397
|
+
} catch {
|
|
1398
|
+
}
|
|
1399
|
+
},
|
|
1400
|
+
custom: (name, data) => {
|
|
1401
|
+
try {
|
|
1402
|
+
emit("plugin.event", {
|
|
1403
|
+
projectId: project.projectId,
|
|
1404
|
+
plugin: "custom",
|
|
1405
|
+
name,
|
|
1406
|
+
data: redactor.redact(data),
|
|
1407
|
+
timestamp: Date.now()
|
|
1408
|
+
});
|
|
1409
|
+
} catch {
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
};
|
|
1413
|
+
for (const plugin of this.plugins) {
|
|
1414
|
+
if (!plugin || !plugin.name) continue;
|
|
1415
|
+
this.initialized.push(plugin);
|
|
1416
|
+
this.run(plugin.name, () => plugin.onInit?.(context));
|
|
1417
|
+
this.run(plugin.name, async () => {
|
|
1418
|
+
const cleanup = await plugin.onAttach?.(app, context);
|
|
1419
|
+
if (typeof cleanup === "function") this.cleanups.push(cleanup);
|
|
1420
|
+
});
|
|
1421
|
+
}
|
|
1422
|
+
return () => {
|
|
1423
|
+
for (const cleanup of this.cleanups.splice(0)) {
|
|
1424
|
+
try {
|
|
1425
|
+
cleanup();
|
|
1426
|
+
} catch {
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
for (const plugin of this.initialized.splice(0)) this.run(plugin.name, () => plugin.onDispose?.());
|
|
1430
|
+
};
|
|
1431
|
+
}
|
|
1432
|
+
run(name, operation) {
|
|
1433
|
+
try {
|
|
1434
|
+
const result = operation();
|
|
1435
|
+
if (result && typeof result.then === "function") {
|
|
1436
|
+
void result.catch((error) => this.reportFailure(name, error));
|
|
1437
|
+
}
|
|
1438
|
+
} catch (error) {
|
|
1439
|
+
this.reportFailure(name, error);
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
reportFailure(name, error) {
|
|
1443
|
+
try {
|
|
1444
|
+
emit("log.created", {
|
|
1445
|
+
projectId: "plugin-system",
|
|
1446
|
+
level: "error",
|
|
1447
|
+
message: `DevTools plugin ${name} failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
1448
|
+
processId: process.pid,
|
|
1449
|
+
timestamp: Date.now(),
|
|
1450
|
+
context: "plugin"
|
|
1451
|
+
});
|
|
1452
|
+
} catch {
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
};
|
|
1456
|
+
|
|
1378
1457
|
// src/sdk.ts
|
|
1379
1458
|
var NestDevTools = class {
|
|
1380
1459
|
static cleanups = [];
|
|
@@ -1420,6 +1499,9 @@ var NestDevTools = class {
|
|
|
1420
1499
|
}
|
|
1421
1500
|
}
|
|
1422
1501
|
});
|
|
1502
|
+
if (userConfig?.plugins && userConfig.plugins.length > 0) {
|
|
1503
|
+
registerCleanup(new PluginManager(userConfig.plugins).attach(app, config, projectInfo));
|
|
1504
|
+
}
|
|
1423
1505
|
const adapter = app.getHttpAdapter();
|
|
1424
1506
|
const httpReady = Boolean(adapter && ["http", "express"].includes(adapter.getType()));
|
|
1425
1507
|
const http = new HttpInstrumentation({ config, projectInfo });
|
|
@@ -1464,11 +1546,21 @@ var NestDevTools = class {
|
|
|
1464
1546
|
static isActive() {
|
|
1465
1547
|
return this.initialized;
|
|
1466
1548
|
}
|
|
1549
|
+
/** Start an explicit CPU or heap profile. */
|
|
1550
|
+
static startProfile(kind) {
|
|
1551
|
+
return import_devtools_core11.devtools.startProfile(kind);
|
|
1552
|
+
}
|
|
1553
|
+
/** Stop the active profile and return its captured result. */
|
|
1554
|
+
static stopProfile() {
|
|
1555
|
+
return import_devtools_core11.devtools.stopProfile();
|
|
1556
|
+
}
|
|
1467
1557
|
};
|
|
1468
1558
|
var devtools = {
|
|
1469
1559
|
init: NestDevTools.init.bind(NestDevTools),
|
|
1470
1560
|
destroy: NestDevTools.destroy.bind(NestDevTools),
|
|
1471
|
-
isActive: NestDevTools.isActive.bind(NestDevTools)
|
|
1561
|
+
isActive: NestDevTools.isActive.bind(NestDevTools),
|
|
1562
|
+
startProfile: NestDevTools.startProfile.bind(NestDevTools),
|
|
1563
|
+
stopProfile: NestDevTools.stopProfile.bind(NestDevTools)
|
|
1472
1564
|
};
|
|
1473
1565
|
function safeHostname() {
|
|
1474
1566
|
try {
|
|
@@ -1507,6 +1599,7 @@ var import_devtools_core12 = require("@angelitosystems/devtools-core");
|
|
|
1507
1599
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1508
1600
|
0 && (module.exports = {
|
|
1509
1601
|
NestDevTools,
|
|
1602
|
+
PluginManager,
|
|
1510
1603
|
captureError,
|
|
1511
1604
|
devtools,
|
|
1512
1605
|
requestContext
|