@tezx/devtools 1.0.12 → 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 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/html/env.js CHANGED
@@ -42,39 +42,6 @@ export const app = new TezX({
42
42
  </tr>`;
43
43
  return `
44
44
  <style>
45
- .tabs {
46
- margin-bottom: 1rem;
47
- }
48
- .tabs a {
49
- display: inline-block;
50
- margin-right: 1rem;
51
- text-decoration: none;
52
- font-weight: 500;
53
- color: #0f172a;
54
- cursor: pointer;
55
- }
56
-
57
- table {
58
- width: 100%;
59
- border-collapse: collapse;
60
- }
61
-
62
- table th, table td {
63
- padding: 0.5rem;
64
- border: 1px solid #e2e8f0;
65
- text-align: left;
66
- }
67
-
68
- table td button.copy-btn {
69
- background: #f8fafc;
70
- border: none;
71
- padding: 0.3rem 0.4rem;
72
- border-radius: 0.375rem;
73
- cursor: pointer;
74
- color: #334155;
75
- transition: background 0.2s ease;
76
- }
77
-
78
45
  .search-container {
79
46
  margin-bottom: 1rem;
80
47
  }
@@ -68,7 +68,6 @@ function Routes(ctx, app) {
68
68
  font-size: 1.25rem;
69
69
  margin-bottom: 0.5rem;
70
70
  font-weight: 600;
71
- color: #334155;
72
71
  }
73
72
  </style>
74
73
 
@@ -111,7 +110,6 @@ function Routes(ctx, app) {
111
110
  ">${hn.method} <small style="opacity: 0.8;">(middleware)</small></span>`
112
111
  : `<span style="
113
112
  font-size: 14px;
114
- color: #333;
115
113
  ">${hn.method}</span>`}
116
114
  </td>
117
115
  <td>${hn.handlerNames.join(", ")}</td>
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 = { disableTabs: [] }) {
7
- let { disableTabs, extraTabs } = options;
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
  : []);
@@ -290,7 +298,7 @@ function DevTools(app, options = { disableTabs: [] }) {
290
298
  position: fixed;
291
299
  bottom: 20px;
292
300
  right: 20px;
293
- background: #323232;
301
+ background: var(--accent);
294
302
  color: white;
295
303
  padding: 10px 16px;
296
304
  border-radius: 8px;
package/html/env.js CHANGED
@@ -39,39 +39,6 @@ export const app = new TezX({
39
39
  </tr>`;
40
40
  return `
41
41
  <style>
42
- .tabs {
43
- margin-bottom: 1rem;
44
- }
45
- .tabs a {
46
- display: inline-block;
47
- margin-right: 1rem;
48
- text-decoration: none;
49
- font-weight: 500;
50
- color: #0f172a;
51
- cursor: pointer;
52
- }
53
-
54
- table {
55
- width: 100%;
56
- border-collapse: collapse;
57
- }
58
-
59
- table th, table td {
60
- padding: 0.5rem;
61
- border: 1px solid #e2e8f0;
62
- text-align: left;
63
- }
64
-
65
- table td button.copy-btn {
66
- background: #f8fafc;
67
- border: none;
68
- padding: 0.3rem 0.4rem;
69
- border-radius: 0.375rem;
70
- cursor: pointer;
71
- color: #334155;
72
- transition: background 0.2s ease;
73
- }
74
-
75
42
  .search-container {
76
43
  margin-bottom: 1rem;
77
44
  }
package/html/routes.js CHANGED
@@ -65,7 +65,6 @@ export function Routes(ctx, app) {
65
65
  font-size: 1.25rem;
66
66
  margin-bottom: 0.5rem;
67
67
  font-weight: 600;
68
- color: #334155;
69
68
  }
70
69
  </style>
71
70
 
@@ -108,7 +107,6 @@ export function Routes(ctx, app) {
108
107
  ">${hn.method} <small style="opacity: 0.8;">(middleware)</small></span>`
109
108
  : `<span style="
110
109
  font-size: 14px;
111
- color: #333;
112
110
  ">${hn.method}</span>`}
113
111
  </td>
114
112
  <td>${hn.handlerNames.join(", ")}</td>
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 = { disableTabs: [] }) {
4
- let { disableTabs, extraTabs } = options;
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
  : []);
@@ -287,7 +295,7 @@ export function DevTools(app, options = { disableTabs: [] }) {
287
295
  position: fixed;
288
296
  bottom: 20px;
289
297
  right: 20px;
290
- background: #323232;
298
+ background: var(--accent);
291
299
  color: white;
292
300
  padding: 10px 16px;
293
301
  border-radius: 8px;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tezx/devtools",
3
- "version": "1.0.12",
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",