@hedwigjs/devtools 0.1.0

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.
Files changed (46) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +340 -0
  3. package/dist/index.d.ts +9 -0
  4. package/dist/index.js +2 -0
  5. package/dist/index.js.LICENSE.txt +9 -0
  6. package/dist/inspector/attachInspector.d.ts +15 -0
  7. package/dist/inspector/createInspectorStore.d.ts +21 -0
  8. package/dist/inspector/matchPattern.d.ts +14 -0
  9. package/dist/inspector/ringLog.d.ts +29 -0
  10. package/dist/inspector/testFixtures.d.ts +4 -0
  11. package/dist/inspector/types.d.ts +165 -0
  12. package/dist/ui/MessageBrokerDevTools.d.ts +45 -0
  13. package/dist/ui/components/AccordionRow/AccordionRow.d.ts +13 -0
  14. package/dist/ui/shell/devtoolsShell/DevToolsShell.d.ts +16 -0
  15. package/dist/ui/shell/devtoolsShell/PanelResizeHandle.d.ts +8 -0
  16. package/dist/ui/shell/floatingToggleButton/FloatingToggleButton.d.ts +10 -0
  17. package/dist/ui/shell/layout/panelFrame.d.ts +5 -0
  18. package/dist/ui/shell/layout/panelTypes.d.ts +28 -0
  19. package/dist/ui/shell/layout/usePanelLayoutState.d.ts +16 -0
  20. package/dist/ui/tabs/bridges/BridgesTab.d.ts +6 -0
  21. package/dist/ui/tabs/bridges/components/BridgeRow/BridgeRow.d.ts +7 -0
  22. package/dist/ui/tabs/clients/ClientsLogTab.d.ts +9 -0
  23. package/dist/ui/tabs/clients/components/ClientCard/ClientCard.d.ts +10 -0
  24. package/dist/ui/tabs/clients/components/ClientDetail/ClientDetail.d.ts +10 -0
  25. package/dist/ui/tabs/clients/components/ClientSummary/ClientSummary.d.ts +11 -0
  26. package/dist/ui/tabs/debug/DebugTab.d.ts +20 -0
  27. package/dist/ui/tabs/debug/components/ResultPanel/ResultPanel.d.ts +12 -0
  28. package/dist/ui/tabs/debug/components/SourcePicker/SourcePicker.d.ts +20 -0
  29. package/dist/ui/tabs/debug/components/TopicPicker/TopicPicker.d.ts +16 -0
  30. package/dist/ui/tabs/definitions.d.ts +9 -0
  31. package/dist/ui/tabs/messages/MessagesLogTab.d.ts +12 -0
  32. package/dist/ui/tabs/messages/components/MessageDetail/MessageDetail.d.ts +7 -0
  33. package/dist/ui/tabs/messages/components/MessageRow/MessageRow.d.ts +7 -0
  34. package/dist/ui/tabs/messages/components/MessageSummary/MessageSummary.d.ts +9 -0
  35. package/dist/ui/tabs/messages/components/MessagesToolbar/MessagesToolbar.d.ts +13 -0
  36. package/dist/ui/tabs/messages/components/StreamRow/StreamRow.d.ts +15 -0
  37. package/dist/ui/tabs/messages/formatTimestamp.d.ts +1 -0
  38. package/dist/ui/tabs/messages/rollup.d.ts +44 -0
  39. package/dist/ui/tabs/renderActiveTab.d.ts +19 -0
  40. package/dist/ui/tabs/replay-buffer/ReplayBufferTab.d.ts +6 -0
  41. package/dist/ui/tabs/replay-buffer/components/HistoryEntryRow/HistoryEntryRow.d.ts +7 -0
  42. package/dist/ui/tabs/system-events/SystemEventsTab.d.ts +6 -0
  43. package/dist/ui/tabs/system-events/components/SystemEventRow/SystemEventRow.d.ts +7 -0
  44. package/dist/ui/topicsRegistry.d.ts +42 -0
  45. package/dist/ui/utils/formatRelativeTime.d.ts +5 -0
  46. package/package.json +80 -0
@@ -0,0 +1,44 @@
1
+ import type { MessageLogEntry, MessagesRollupConfig } from "../../../inspector/types";
2
+ /**
3
+ * A contiguous run of messages that share `(topic, source)` and arrived
4
+ * within `windowMs` gaps of each other. Rendered as a single collapsible
5
+ * row so that stream-y topics (e.g. `chat.reply-chunk.v1`) don't flood the
6
+ * log.
7
+ */
8
+ export interface StreamGroup {
9
+ kind: "stream";
10
+ /** Stable React key derived from the first entry's id. */
11
+ key: string;
12
+ topic: string;
13
+ source: string;
14
+ /** Chronological (oldest → newest). */
15
+ entries: MessageLogEntry[];
16
+ count: number;
17
+ /** Unix ms of the first entry in the group. */
18
+ firstAt: number;
19
+ /** Unix ms of the latest entry in the group. */
20
+ lastAt: number;
21
+ }
22
+ export interface SingleGroup {
23
+ kind: "single";
24
+ entry: MessageLogEntry;
25
+ }
26
+ export type DisplayItem = StreamGroup | SingleGroup;
27
+ /**
28
+ * Fold consecutive matching entries into stream groups.
29
+ *
30
+ * Input is expected in chronological order (oldest → newest). Output is in
31
+ * the same order — reverse in the view layer for display.
32
+ *
33
+ * Boundary rules:
34
+ * - Group breaks when topic OR source changes.
35
+ * - Group breaks when the gap between adjacent entries exceeds `windowMs`.
36
+ * - A run with fewer than `minCount` entries is emitted as individual
37
+ * `SingleGroup`s rather than a stream — the rollup is only worth the
38
+ * click if the burst is substantial.
39
+ *
40
+ * Pending entries (no `createdAt` change) group by their creation
41
+ * timestamp; if a stream is still receiving frames, the last entry's time
42
+ * keeps advancing and new arrivals extend the same group naturally.
43
+ */
44
+ export declare function computeDisplayItems(entriesOldToNew: ReadonlyArray<MessageLogEntry>, rollup: MessagesRollupConfig | null): DisplayItem[];
@@ -0,0 +1,19 @@
1
+ import React from "react";
2
+ import type { MessageInspectorStore } from "../../inspector/createInspectorStore";
3
+ import type { MessageBrokerForDevTools, MessagesFilter, MessagesRollupConfig } from "../../inspector/types";
4
+ import type { DevToolsTabId } from "../shell/layout/panelTypes";
5
+ export interface TabNavigateOptions {
6
+ filterPatch?: Partial<MessagesFilter>;
7
+ }
8
+ export interface TabRenderContext {
9
+ /** Navigate to another tab, optionally pre-setting a Messages filter. */
10
+ onNavigate: (tab: DevToolsTabId, options?: TabNavigateOptions) => void;
11
+ /** Rollup config for the Messages tab; `null` disables grouping. */
12
+ messagesRollup: MessagesRollupConfig | null;
13
+ /** Broker reference — needed by the Debug tab to call $debug.send. */
14
+ broker: MessageBrokerForDevTools;
15
+ }
16
+ /**
17
+ * Extension point: add a new section by adding to `DevToolsTabId` union + a case here.
18
+ */
19
+ export declare function renderActiveTab(id: DevToolsTabId, store: MessageInspectorStore, context: TabRenderContext): React.ReactNode;
@@ -0,0 +1,6 @@
1
+ import type { ReactNode } from "react";
2
+ import type { MessageInspectorStore } from "../../../inspector/createInspectorStore";
3
+ export interface ReplayBufferTabProps {
4
+ store: MessageInspectorStore;
5
+ }
6
+ export declare function ReplayBufferTab({ store }: ReplayBufferTabProps): ReactNode;
@@ -0,0 +1,7 @@
1
+ import type { ReactNode } from "react";
2
+ import type { HistoryEntry } from "../../../../../inspector/types";
3
+ interface HistoryEntryRowProps {
4
+ entry: HistoryEntry;
5
+ }
6
+ export declare function HistoryEntryRow({ entry }: HistoryEntryRowProps): ReactNode;
7
+ export {};
@@ -0,0 +1,6 @@
1
+ import type { ReactNode } from "react";
2
+ import type { MessageInspectorStore } from "../../../inspector/createInspectorStore";
3
+ export interface SystemEventsTabProps {
4
+ store: MessageInspectorStore;
5
+ }
6
+ export declare function SystemEventsTab({ store }: SystemEventsTabProps): ReactNode;
@@ -0,0 +1,7 @@
1
+ import type { ReactNode } from "react";
2
+ import type { SystemEventLogEntry } from "../../../../../inspector/types";
3
+ interface SystemEventRowProps {
4
+ entry: SystemEventLogEntry;
5
+ }
6
+ export declare function SystemEventRow({ entry }: SystemEventRowProps): ReactNode;
7
+ export {};
@@ -0,0 +1,42 @@
1
+ import type { ReactNode } from "react";
2
+ /**
3
+ * Минимальная форма одного контракта, которую DevTools требует от реестра.
4
+ *
5
+ * Совместима со shape'ом `EventContract` из `@hedwigjs/create-registry`,
6
+ * но описана локально, чтобы DevTools не зависел от какого-либо
7
+ * конкретного registry-пакета.
8
+ */
9
+ export interface TopicContractInfo {
10
+ /** Имя топика, например `"users.fetched.v1"`. */
11
+ name: string;
12
+ /** Человекочитаемое описание для UI. */
13
+ description: string;
14
+ /** Именованные фикстуры payload'а. Минимум — ключ `happy`. */
15
+ examples?: Readonly<Record<string, unknown>>;
16
+ /** Если событие deprecated — имя топика-наследника. */
17
+ deprecatedBy?: string;
18
+ /**
19
+ * Топик — телеметрический (тrace/observability). У него по замыслу
20
+ * может не быть business-подписчиков, поэтому `NACK NO_SUBSCRIBERS`
21
+ * для него — ожидаемое состояние, не ошибка. DevTools использует
22
+ * этот флаг чтобы рендерить такие NACK'и нейтрально.
23
+ */
24
+ observability?: boolean;
25
+ }
26
+ /**
27
+ * Каталог топиков, индексированный по имени топика.
28
+ * Передаётся в `MessageBrokerDevTools` через prop `registry`.
29
+ */
30
+ export type TopicsRegistry = Readonly<Record<string, TopicContractInfo>>;
31
+ export interface TopicsRegistryProviderProps {
32
+ registry: TopicsRegistry | undefined;
33
+ children: ReactNode;
34
+ }
35
+ export declare function TopicsRegistryProvider({ registry, children, }: TopicsRegistryProviderProps): ReactNode;
36
+ /**
37
+ * Хук для табов DevTools: возвращает реестр топиков, переданный
38
+ * в `MessageBrokerDevTools`. `null` означает, что реестр не передан —
39
+ * UI должен это корректно обработать (показать пустое состояние / disable
40
+ * функциональность каталога).
41
+ */
42
+ export declare function useTopicsRegistry(): TopicsRegistry | null;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Formats a Unix timestamp (ms) as a human-readable relative time string.
3
+ * Returns "never" for null, "just now" for < 1s, otherwise "Xs/Xm/Xh ago".
4
+ */
5
+ export declare function formatRelativeTime(ts: number | null): string;
package/package.json ADDED
@@ -0,0 +1,80 @@
1
+ {
2
+ "name": "@hedwigjs/devtools",
3
+ "version": "0.1.0",
4
+ "description": "DevTools panel for @hedwigjs/broker — message flow, clients, and observability inspector.",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "main": "dist/index.js",
9
+ "types": "dist/index.d.ts",
10
+ "sideEffects": true,
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/index.js",
15
+ "require": "./dist/index.js"
16
+ },
17
+ "./package.json": "./package.json"
18
+ },
19
+ "license": "MIT",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/hedwigjs/hedwig.git",
23
+ "directory": "packages/devtools"
24
+ },
25
+ "bugs": {
26
+ "url": "https://github.com/hedwigjs/hedwig/issues"
27
+ },
28
+ "homepage": "https://github.com/hedwigjs/hedwig/tree/main/packages/devtools#readme",
29
+ "scripts": {
30
+ "build": "webpack --config webpack.config.cjs && tsc -p tsconfig.dts.json",
31
+ "watch": "webpack --config webpack.config.cjs --watch",
32
+ "test": "jest",
33
+ "test:watch": "jest --watch",
34
+ "typecheck": "tsc --noEmit"
35
+ },
36
+ "peerDependencies": {
37
+ "@hedwigjs/broker": "^0.1.0",
38
+ "react": "^19.1.1",
39
+ "react-dom": "^19.1.1"
40
+ },
41
+ "devDependencies": {
42
+ "@hedwigjs/broker": "*",
43
+ "@types/jest": "^29.5.0",
44
+ "@types/react": "^19.1.13",
45
+ "@types/react-dom": "^19.1.9",
46
+ "css-loader": "^6.10.0",
47
+ "jest": "^29.5.0",
48
+ "react": "^19.1.1",
49
+ "react-dom": "^19.1.1",
50
+ "style-loader": "^3.3.4",
51
+ "ts-jest": "^29.1.0",
52
+ "ts-loader": "^9.5.2",
53
+ "typescript": "^5.8.3",
54
+ "webpack": "^5.99.8",
55
+ "webpack-cli": "^6.0.1"
56
+ },
57
+ "keywords": [
58
+ "hedwig",
59
+ "devtools",
60
+ "message-broker",
61
+ "microfrontends",
62
+ "react",
63
+ "observability"
64
+ ],
65
+ "files": [
66
+ "dist",
67
+ "README.md",
68
+ "LICENSE"
69
+ ],
70
+ "engines": {
71
+ "node": ">=18.17.0"
72
+ },
73
+ "jest": {
74
+ "preset": "ts-jest",
75
+ "testEnvironment": "node",
76
+ "testMatch": [
77
+ "**/src/**/*.test.ts"
78
+ ]
79
+ }
80
+ }