@angelitosystems/nest-devtools 2.0.0 → 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 +6 -6
- package/dist/index.cjs +24 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +24 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
package/dist/index.d.cts
CHANGED
|
@@ -46,6 +46,8 @@ interface InitResult {
|
|
|
46
46
|
}
|
|
47
47
|
type NestDevToolsOptions = DevToolsUserConfig & {
|
|
48
48
|
plugins?: DevToolsPlugin[];
|
|
49
|
+
/** Start the local dashboard and WebSocket server in this process. */
|
|
50
|
+
embedded?: boolean;
|
|
49
51
|
};
|
|
50
52
|
/**
|
|
51
53
|
* Main entry point: `NestDevTools.init(app, config?)`.
|
|
@@ -56,6 +58,7 @@ type NestDevToolsOptions = DevToolsUserConfig & {
|
|
|
56
58
|
declare class NestDevTools {
|
|
57
59
|
private static readonly cleanups;
|
|
58
60
|
private static initialized;
|
|
61
|
+
private static embeddedServer;
|
|
59
62
|
/** Initialize DevTools for a NestJS application. One active instance per process. */
|
|
60
63
|
static init(app: INestApplication, userConfig?: NestDevToolsOptions): InitResult;
|
|
61
64
|
/** Teardown everything (mostly useful in tests). */
|
package/dist/index.d.ts
CHANGED
|
@@ -46,6 +46,8 @@ interface InitResult {
|
|
|
46
46
|
}
|
|
47
47
|
type NestDevToolsOptions = DevToolsUserConfig & {
|
|
48
48
|
plugins?: DevToolsPlugin[];
|
|
49
|
+
/** Start the local dashboard and WebSocket server in this process. */
|
|
50
|
+
embedded?: boolean;
|
|
49
51
|
};
|
|
50
52
|
/**
|
|
51
53
|
* Main entry point: `NestDevTools.init(app, config?)`.
|
|
@@ -56,6 +58,7 @@ type NestDevToolsOptions = DevToolsUserConfig & {
|
|
|
56
58
|
declare class NestDevTools {
|
|
57
59
|
private static readonly cleanups;
|
|
58
60
|
private static initialized;
|
|
61
|
+
private static embeddedServer;
|
|
59
62
|
/** Initialize DevTools for a NestJS application. One active instance per process. */
|
|
60
63
|
static init(app: INestApplication, userConfig?: NestDevToolsOptions): InitResult;
|
|
61
64
|
/** Teardown everything (mostly useful in tests). */
|
package/dist/index.js
CHANGED
|
@@ -1518,7 +1518,7 @@ function detectNestJsVersion() {
|
|
|
1518
1518
|
}
|
|
1519
1519
|
|
|
1520
1520
|
// src/version.ts
|
|
1521
|
-
var SDK_VERSION = "2.0.
|
|
1521
|
+
var SDK_VERSION = "2.0.1";
|
|
1522
1522
|
|
|
1523
1523
|
// src/banner.ts
|
|
1524
1524
|
var RESET = "\x1B[0m";
|
|
@@ -1643,9 +1643,11 @@ var PluginManager = class {
|
|
|
1643
1643
|
};
|
|
1644
1644
|
|
|
1645
1645
|
// src/sdk.ts
|
|
1646
|
+
import { DevToolsServer } from "@angelitosystems/nest-devtools-cli";
|
|
1646
1647
|
var NestDevTools = class {
|
|
1647
1648
|
static cleanups = [];
|
|
1648
1649
|
static initialized = false;
|
|
1650
|
+
static embeddedServer = null;
|
|
1649
1651
|
/** Initialize DevTools for a NestJS application. One active instance per process. */
|
|
1650
1652
|
static init(app, userConfig) {
|
|
1651
1653
|
const config = resolveConfig(userConfig);
|
|
@@ -1660,6 +1662,17 @@ var NestDevTools = class {
|
|
|
1660
1662
|
if (!config.enabled) return disabled;
|
|
1661
1663
|
this.initialized = true;
|
|
1662
1664
|
const registerCleanup = (fn) => this.cleanups.push(fn);
|
|
1665
|
+
if (userConfig?.embedded !== false) {
|
|
1666
|
+
const embeddedServer = createEmbeddedServer(config.server);
|
|
1667
|
+
this.embeddedServer = embeddedServer;
|
|
1668
|
+
void embeddedServer.start().catch(() => {
|
|
1669
|
+
});
|
|
1670
|
+
registerCleanup(() => {
|
|
1671
|
+
void embeddedServer.stop().catch(() => {
|
|
1672
|
+
});
|
|
1673
|
+
if (this.embeddedServer === embeddedServer) this.embeddedServer = null;
|
|
1674
|
+
});
|
|
1675
|
+
}
|
|
1663
1676
|
const projectInfo = {
|
|
1664
1677
|
projectId: config.projectId,
|
|
1665
1678
|
projectName: config.project ?? config.projectId,
|
|
@@ -1781,6 +1794,16 @@ function dashboardUrl(server) {
|
|
|
1781
1794
|
return "http://localhost:4317";
|
|
1782
1795
|
}
|
|
1783
1796
|
}
|
|
1797
|
+
function createEmbeddedServer(server) {
|
|
1798
|
+
const url = new URL(server);
|
|
1799
|
+
const wsPort = Number(url.port || 4318);
|
|
1800
|
+
const httpPort = wsPort > 1 ? wsPort - 1 : 4317;
|
|
1801
|
+
return new DevToolsServer({
|
|
1802
|
+
host: url.hostname || "localhost",
|
|
1803
|
+
httpPort,
|
|
1804
|
+
wsPort
|
|
1805
|
+
});
|
|
1806
|
+
}
|
|
1784
1807
|
|
|
1785
1808
|
// src/index.ts
|
|
1786
1809
|
import { requestContext as requestContext8 } from "@angelitosystems/devtools-core";
|