@tezx/devtools 1.0.13 → 1.0.14
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 +0 -31
- package/cjs/index.js +10 -2
- package/index.d.ts +8 -0
- package/index.js +10 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,7 +25,6 @@ In your TezX app entry (e.g., `server.ts` or `index.ts`):
|
|
|
25
25
|
|
|
26
26
|
```ts
|
|
27
27
|
import { TezX } from "tezx";
|
|
28
|
-
import {nodeAdapter} from "tezx/node";
|
|
29
28
|
import DevTools from "@tezx/devtools";
|
|
30
29
|
|
|
31
30
|
const app = new TezX();
|
|
@@ -39,7 +38,6 @@ app.get(
|
|
|
39
38
|
})
|
|
40
39
|
);
|
|
41
40
|
|
|
42
|
-
nodeAdapter(app).listen(3000);
|
|
43
41
|
```
|
|
44
42
|
|
|
45
43
|
Now visit:
|
|
@@ -74,35 +72,6 @@ DevTools(app: TezX<any>, options?: Options): Callback
|
|
|
74
72
|
|
|
75
73
|
---
|
|
76
74
|
|
|
77
|
-
## 🛠️ Add Custom Tabs
|
|
78
|
-
|
|
79
|
-
You can inject your own debug panels using the `extraTabs` option.
|
|
80
|
-
|
|
81
|
-
```ts
|
|
82
|
-
import DevTools , { dumpMiddlewares } from "@tezx/devtools";
|
|
83
|
-
|
|
84
|
-
app.get(
|
|
85
|
-
"/devtools",
|
|
86
|
-
DevTools(app, {
|
|
87
|
-
extraTabs(ctx) {
|
|
88
|
-
const rows = dumpMiddlewares(app)
|
|
89
|
-
.map(r => `<tr><td>${r.endpoint}</td><td>${r.pattern}</td><td>${r.appliedMiddlewares}</td></tr>`)
|
|
90
|
-
.join("");
|
|
91
|
-
return [
|
|
92
|
-
{
|
|
93
|
-
tab: "middlewares",
|
|
94
|
-
label: "Middleware Table",
|
|
95
|
-
doc_title: "Middleware Overview",
|
|
96
|
-
content: `<table>${rows}</table>`
|
|
97
|
-
}
|
|
98
|
-
];
|
|
99
|
-
}
|
|
100
|
-
})
|
|
101
|
-
);
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
---
|
|
105
|
-
|
|
106
75
|
## 📚 Types
|
|
107
76
|
|
|
108
77
|
```ts
|
package/cjs/index.js
CHANGED
|
@@ -3,9 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DevTools = DevTools;
|
|
4
4
|
const helper_1 = require("tezx/helper");
|
|
5
5
|
const index_js_1 = require("./html/index.js");
|
|
6
|
-
function DevTools(app, options = {
|
|
7
|
-
|
|
6
|
+
function DevTools(app, options = {
|
|
7
|
+
disableTabs: [],
|
|
8
|
+
enable: true,
|
|
9
|
+
}) {
|
|
10
|
+
let { disableTabs } = options;
|
|
8
11
|
return async (ctx) => {
|
|
12
|
+
if (!options?.enable) {
|
|
13
|
+
return ctx
|
|
14
|
+
.status(404)
|
|
15
|
+
.json({ error: "Devtools not enabled in this environment" });
|
|
16
|
+
}
|
|
9
17
|
let extraTabs = await (typeof options.extraTabs === "function"
|
|
10
18
|
? options.extraTabs(ctx)
|
|
11
19
|
: []);
|
package/index.d.ts
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { Callback, Context, TezX } from "tezx";
|
|
2
2
|
import { Tab, TabType } from "./html/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Configuration options for the devtools.
|
|
5
|
+
*
|
|
6
|
+
* @property extraTabs - A function that receives the current context and returns additional tabs to be displayed. Can return a single tab or a promise resolving to a tab.
|
|
7
|
+
* @property disableTabs - An array of tabs to be disabled in the UI.
|
|
8
|
+
* @property enable - Indicates whether the devtools should be enabled. Set to `true` to activate devtools, or `false` to disable (e.g., in production).
|
|
9
|
+
*/
|
|
3
10
|
export type Options = {
|
|
4
11
|
extraTabs?: (ctx: Context) => Promise<TabType> | TabType;
|
|
5
12
|
disableTabs?: Tab[];
|
|
13
|
+
enable: boolean;
|
|
6
14
|
};
|
|
7
15
|
export declare function DevTools(app: TezX<any>, options?: Options): Callback;
|
|
8
16
|
export default DevTools;
|
package/index.js
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { GlobalConfig } from "tezx/helper";
|
|
2
2
|
import { html as htmlTab } from "./html/index.js";
|
|
3
|
-
export function DevTools(app, options = {
|
|
4
|
-
|
|
3
|
+
export function DevTools(app, options = {
|
|
4
|
+
disableTabs: [],
|
|
5
|
+
enable: true,
|
|
6
|
+
}) {
|
|
7
|
+
let { disableTabs } = options;
|
|
5
8
|
return async (ctx) => {
|
|
9
|
+
if (!options?.enable) {
|
|
10
|
+
return ctx
|
|
11
|
+
.status(404)
|
|
12
|
+
.json({ error: "Devtools not enabled in this environment" });
|
|
13
|
+
}
|
|
6
14
|
let extraTabs = await (typeof options.extraTabs === "function"
|
|
7
15
|
? options.extraTabs(ctx)
|
|
8
16
|
: []);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tezx/devtools",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.14",
|
|
4
4
|
"description": "Developer tools for the TezX framework, including route inspector, cookie manager, and real-time diagnostics. Lightweight and plug-and-play compatible with Node.js, Bun, and Deno.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "cjs/index.cjs",
|