@angelitosystems/nest-devtools 1.0.17 → 2.0.1

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/README.md CHANGED
@@ -20,7 +20,7 @@ npm install @angelitosystems/nest-devtools
20
20
  bun add @angelitosystems/nest-devtools
21
21
  ```
22
22
 
23
- El servidor y el dashboard se instalan aparte con [`@angelitosystems/nest-devtools-cli`](../cli).
23
+ El servidor WebSocket y el dashboard se inician automaticamente dentro del proceso de NestJS.
24
24
 
25
25
  ## Uso
26
26
 
@@ -40,11 +40,8 @@ async function bootstrap() {
40
40
  bootstrap();
41
41
  ```
42
42
 
43
- Despues inicia el CLI y abre `http://localhost:4317`:
44
-
45
- ```bash
46
- npx @angelitosystems/nest-devtools-cli
47
- ```
43
+ Abre `http://localhost:4317` despues de arrancar tu aplicacion. No necesitas ejecutar
44
+ `nest-devtools start` en otra terminal.
48
45
 
49
46
  ## Configuracion
50
47
 
@@ -66,6 +63,9 @@ NestDevTools.init(app, {
66
63
  });
67
64
  ```
68
65
 
66
+ Para conectar con un servidor DevTools que ya se esta ejecutando, desactiva el modo
67
+ embebido con `embedded: false`.
68
+
69
69
  Opciones y variables de entorno principales:
70
70
 
71
71
  | Opcion | Variable | Valor predeterminado |
package/dist/index.cjs CHANGED
@@ -1549,7 +1549,7 @@ function detectNestJsVersion() {
1549
1549
  }
1550
1550
 
1551
1551
  // src/version.ts
1552
- var SDK_VERSION = "1.0.17";
1552
+ var SDK_VERSION = "2.0.1";
1553
1553
 
1554
1554
  // src/banner.ts
1555
1555
  var RESET = "\x1B[0m";
@@ -1674,9 +1674,11 @@ var PluginManager = class {
1674
1674
  };
1675
1675
 
1676
1676
  // src/sdk.ts
1677
+ var import_nest_devtools_cli = require("@angelitosystems/nest-devtools-cli");
1677
1678
  var NestDevTools = class {
1678
1679
  static cleanups = [];
1679
1680
  static initialized = false;
1681
+ static embeddedServer = null;
1680
1682
  /** Initialize DevTools for a NestJS application. One active instance per process. */
1681
1683
  static init(app, userConfig) {
1682
1684
  const config = (0, import_devtools_core11.resolveConfig)(userConfig);
@@ -1691,6 +1693,17 @@ var NestDevTools = class {
1691
1693
  if (!config.enabled) return disabled;
1692
1694
  this.initialized = true;
1693
1695
  const registerCleanup = (fn) => this.cleanups.push(fn);
1696
+ if (userConfig?.embedded !== false) {
1697
+ const embeddedServer = createEmbeddedServer(config.server);
1698
+ this.embeddedServer = embeddedServer;
1699
+ void embeddedServer.start().catch(() => {
1700
+ });
1701
+ registerCleanup(() => {
1702
+ void embeddedServer.stop().catch(() => {
1703
+ });
1704
+ if (this.embeddedServer === embeddedServer) this.embeddedServer = null;
1705
+ });
1706
+ }
1694
1707
  const projectInfo = {
1695
1708
  projectId: config.projectId,
1696
1709
  projectName: config.project ?? config.projectId,
@@ -1812,6 +1825,16 @@ function dashboardUrl(server) {
1812
1825
  return "http://localhost:4317";
1813
1826
  }
1814
1827
  }
1828
+ function createEmbeddedServer(server) {
1829
+ const url = new URL(server);
1830
+ const wsPort = Number(url.port || 4318);
1831
+ const httpPort = wsPort > 1 ? wsPort - 1 : 4317;
1832
+ return new import_nest_devtools_cli.DevToolsServer({
1833
+ host: url.hostname || "localhost",
1834
+ httpPort,
1835
+ wsPort
1836
+ });
1837
+ }
1815
1838
 
1816
1839
  // src/index.ts
1817
1840
  var import_devtools_core12 = require("@angelitosystems/devtools-core");