@hazeljs/inspector 0.7.9 → 0.8.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
@@ -50,14 +50,14 @@ Then run your app and open:
50
50
 
51
51
  ## Configuration
52
52
 
53
- | Option | Default | Description |
54
- |--------|---------|-------------|
55
- | `enableInspector` | `true` | Enable the inspector |
56
- | `inspectorBasePath` | `'/__hazel'` | Base path for all inspector endpoints |
57
- | `exposeUi` | `true` | Serve the DevTools UI at the base path |
58
- | `exposeJson` | `true` | Expose JSON endpoints |
59
- | `developmentOnly` | `true` | Disable in production (NODE_ENV=production) |
60
- | `maxSnapshotCacheAgeMs` | `5000` | Cache snapshot for 5 seconds |
53
+ | Option | Default | Description |
54
+ | ----------------------- | ------------ | ------------------------------------------- |
55
+ | `enableInspector` | `true` | Enable the inspector |
56
+ | `inspectorBasePath` | `'/__hazel'` | Base path for all inspector endpoints |
57
+ | `exposeUi` | `true` | Serve the DevTools UI at the base path |
58
+ | `exposeJson` | `true` | Expose JSON endpoints |
59
+ | `developmentOnly` | `true` | Disable in production (NODE_ENV=production) |
60
+ | `maxSnapshotCacheAgeMs` | `5000` | Cache snapshot for 5 seconds |
61
61
 
62
62
  ## Security
63
63
 
@@ -75,9 +75,7 @@ import { HazelInspectorRegistry, type HazelInspectorPlugin } from '@hazeljs/insp
75
75
  const myPlugin: HazelInspectorPlugin = {
76
76
  name: 'my-plugin',
77
77
  supports: (ctx) => true,
78
- inspect: async (ctx) => [
79
- { id: 'custom:1', kind: 'route', packageName: '@my/package', /* ... */ },
80
- ],
78
+ inspect: async (ctx) => [{ id: 'custom:1', kind: 'route', packageName: '@my/package' /* ... */ }],
81
79
  };
82
80
 
83
81
  // Register during bootstrap (e.g. in a provider that runs early)
@@ -1 +1 @@
1
- {"version":3,"file":"inspector.module.d.ts","sourceRoot":"","sources":["../src/inspector.module.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EAAoB,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AA6BlF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,eAAe;sBACR,sBAAsB,GAAG,aAAa;CA6CzD,CAAC"}
1
+ {"version":3,"file":"inspector.module.d.ts","sourceRoot":"","sources":["../src/inspector.module.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EAAoB,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AA8BlF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,eAAe;sBACR,sBAAsB,GAAG,aAAa;CA8CzD,CAAC"}
@@ -41,6 +41,7 @@ const data_inspector_1 = require("./plugins/data.inspector");
41
41
  const serverless_inspector_1 = require("./plugins/serverless.inspector");
42
42
  const ml_inspector_1 = require("./plugins/ml.inspector");
43
43
  const worker_inspector_1 = require("./plugins/worker.inspector");
44
+ const hcel_inspector_1 = require("./plugins/hcel.inspector");
44
45
  const inspector_config_1 = require("./config/inspector.config");
45
46
  const inspector_runtime_1 = require("./runtime/inspector-runtime");
46
47
  /** Eagerly resolves InspectorBootstrap so the early handler gets registered */
@@ -97,6 +98,7 @@ exports.InspectorModule = {
97
98
  registry.register(serverless_inspector_1.serverlessInspector);
98
99
  registry.register(ml_inspector_1.mlInspector);
99
100
  registry.register(worker_inspector_1.workerInspector);
101
+ registry.register(hcel_inspector_1.hcelInspector);
100
102
  const basePath = config.inspectorBasePath ?? '/__hazel';
101
103
  const handler = createInspectorHandler(service, config, app);
102
104
  app.addEarlyHandler(basePath, handler);
@@ -456,6 +458,20 @@ function createInspectorHandler(service, config, app) {
456
458
  res.end(JSON.stringify({ entries: workers }));
457
459
  return;
458
460
  }
461
+ if (pathSeg === '/hcel/trace' || pathSeg === '/hcel/trace/') {
462
+ try {
463
+ const ai = require('@hazeljs/ai');
464
+ ai.setHCELGlobalTraceEnabled?.(true);
465
+ const events = ai.getHCELTraceSnapshot?.() ?? [];
466
+ res.writeHead(200);
467
+ res.end(JSON.stringify({ events }));
468
+ }
469
+ catch (err) {
470
+ res.writeHead(500);
471
+ res.end(JSON.stringify({ error: String(err) }));
472
+ }
473
+ return;
474
+ }
459
475
  if (pathSeg === '/' || pathSeg === '') {
460
476
  res.writeHead(200);
461
477
  res.end(JSON.stringify({
@@ -482,6 +498,7 @@ function createInspectorHandler(service, config, app) {
482
498
  '/serverless',
483
499
  '/ml',
484
500
  '/workers',
501
+ '/hcel/trace',
485
502
  '/stats',
486
503
  ],
487
504
  }));
@@ -0,0 +1,6 @@
1
+ /**
2
+ * HCEL trace inspector — requires @hazeljs/ai
3
+ */
4
+ import type { HazelInspectorPlugin } from '../contracts/types';
5
+ export declare const hcelInspector: HazelInspectorPlugin;
6
+ //# sourceMappingURL=hcel.inspector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hcel.inspector.d.ts","sourceRoot":"","sources":["../../src/plugins/hcel.inspector.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAkB,MAAM,oBAAoB,CAAC;AAW/E,eAAO,MAAM,aAAa,EAAE,oBA4B3B,CAAC"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ /**
3
+ * HCEL trace inspector — requires @hazeljs/ai
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.hcelInspector = void 0;
7
+ function tryGetAI() {
8
+ try {
9
+ require.resolve('@hazeljs/ai');
10
+ return true;
11
+ }
12
+ catch {
13
+ return false;
14
+ }
15
+ }
16
+ exports.hcelInspector = {
17
+ name: 'hcel',
18
+ version: '1.0.0',
19
+ supports: () => tryGetAI(),
20
+ inspect: async () => {
21
+ if (!tryGetAI())
22
+ return [];
23
+ try {
24
+ const ai = require('@hazeljs/ai');
25
+ ai.setHCELGlobalTraceEnabled?.(true);
26
+ const trace = ai.getHCELTraceSnapshot?.() ?? [];
27
+ return [
28
+ {
29
+ id: 'hcel:trace',
30
+ kind: 'decorator',
31
+ packageName: '@hazeljs/ai',
32
+ decoratorName: 'HCELTrace',
33
+ targetType: 'class',
34
+ targetClass: 'HCELEngine',
35
+ decoratorArguments: [{ bufferedEvents: trace.length }],
36
+ },
37
+ ];
38
+ }
39
+ catch {
40
+ return [];
41
+ }
42
+ },
43
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hazeljs/inspector",
3
- "version": "0.7.9",
3
+ "version": "0.8.1",
4
4
  "description": "Framework-aware runtime inspector for HazelJS - metadata explorer and DevTools UI",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -87,7 +87,7 @@
87
87
  }
88
88
  },
89
89
  "devDependencies": {
90
- "@hazeljs/core": "^0.7.9",
90
+ "@hazeljs/core": "^0.8.1",
91
91
  "@types/jest": "^29.5.14",
92
92
  "@types/node": "^20.19.39",
93
93
  "@typescript-eslint/eslint-plugin": "^8.58.0",
@@ -120,5 +120,5 @@
120
120
  "url": "https://github.com/hazeljs/hazel-js/issues"
121
121
  },
122
122
  "homepage": "https://hazeljs.ai",
123
- "gitHead": "28c21c509aeca3bf2d0878fbee737d906b654c67"
123
+ "gitHead": "8b7685d1250c4622f25d83992f58e13a59bb3dba"
124
124
  }