mates-devtools 0.1.0-beta.1 → 0.1.0-beta.2

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 (2) hide show
  1. package/README.md +188 -0
  2. package/package.json +3 -2
package/README.md ADDED
@@ -0,0 +1,188 @@
1
+ # mates-devtools
2
+
3
+ In-app developer tools panel for the [Mates](https://www.npmjs.com/package/mates) framework.
4
+
5
+ Renders a floating FAB button that opens a resizable panel giving you full
6
+ visibility into your running app — components, atoms, hooks, logs, network
7
+ requests, and performance timings — all without leaving the browser.
8
+
9
+ ---
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ npm install mates-devtools
15
+ # mates is a required peer dependency
16
+ npm install mates
17
+ ```
18
+
19
+ ---
20
+
21
+ ## Quick start
22
+
23
+ Call `renderMatesDevTools()` **before** `renderX()` so hooks are installed
24
+ before any component mounts.
25
+
26
+ ```ts
27
+ import { renderX } from "mates";
28
+ import { renderMatesDevTools } from "mates-devtools";
29
+ import { App } from "./App";
30
+
31
+ renderMatesDevTools(); // 👈 must come first
32
+ renderX(App, document.getElementById("app")!);
33
+ ```
34
+
35
+ A ⚙️ FAB appears in the bottom-right corner of the page. Click it to open the
36
+ panel.
37
+
38
+ ---
39
+
40
+ ## API
41
+
42
+ ### `renderMatesDevTools()`
43
+
44
+ Installs the framework hooks and renders the FAB + panel into `document.body`.
45
+ Safe to call multiple times — subsequent calls are no-ops.
46
+
47
+ ```ts
48
+ import { renderMatesDevTools } from "mates-devtools";
49
+ renderMatesDevTools();
50
+ ```
51
+
52
+ ### `destroyMatesDevTools()`
53
+
54
+ Tears down the FAB, the panel, all subscriptions, and the framework hooks.
55
+ Safe to call even if DevTools was never started.
56
+
57
+ ```ts
58
+ import { destroyMatesDevTools } from "mates-devtools";
59
+ destroyMatesDevTools();
60
+ ```
61
+
62
+ ---
63
+
64
+ ## Panel tabs
65
+
66
+ | Tab | What you see |
67
+ |-----|-------------|
68
+ | **Components** | Live component tree with mount count, render count, and version badges that flash on every re-render. Click any component to inspect its props, scopes, atoms, hooks, and `useState` values. |
69
+ | **Logs** | Timestamped stream of component lifecycle events (mount / render / unmount), atom reads/writes, event triggers, and Fetch requests/responses/errors. |
70
+ | **Performance** | Per-component render timing: total time, average time, slowest render, and a micro bar chart of the last 20 renders. |
71
+ | **Timers** | Active `setInterval` / `setTimeout` calls tracked by the devtools timer interceptor, so you can spot runaway timers. |
72
+
73
+ ---
74
+
75
+ ## Component inspector
76
+
77
+ Selecting a component in the left-hand list reveals a right-hand inspector with
78
+ five collapsible sections:
79
+
80
+ - **Props** — current prop values rendered as a collapsible value tree.
81
+ - **Scopes** — reactive scopes owned by the component with their current atom snapshots.
82
+ - **Atoms** — all atoms read by the component and their current values.
83
+ - **Hooks** — lifecycle hooks (`onMount`, `onUnmount`, `onChange`, …) registered by the component.
84
+ - **useState** — local `useState` values.
85
+
86
+ ---
87
+
88
+ ## Low-level exports
89
+
90
+ Advanced usage only — these are the internal building blocks used by the panel
91
+ itself.
92
+
93
+ ### Registry
94
+
95
+ ```ts
96
+ import {
97
+ registerComponent, unregisterComponent, notifyRender,
98
+ getComponentName, getComponentGroups, getComponentsByView,
99
+ getComponentDepth, getAllComponents, getRenderVersion,
100
+ devToolsEvent,
101
+ } from "mates-devtools";
102
+ ```
103
+
104
+ ### Log store
105
+
106
+ ```ts
107
+ import {
108
+ connectLogStore, disconnectLogStore, getLogs,
109
+ getLogCount, getUnreadLogCount, isLogStoreConnected,
110
+ onLogEntry, markLogsRead, clearLogs,
111
+ logAtomSet, logAtomUpdate, logComponentMount,
112
+ logComponentRender, logComponentUnmount, logEventTrigger,
113
+ logCleanupEventTrigger,
114
+ } from "mates-devtools";
115
+ import type { LogEntry, LogCategory } from "mates-devtools";
116
+ ```
117
+
118
+ ### Perf store
119
+
120
+ ```ts
121
+ import {
122
+ connectPerfStore, disconnectPerfStore, isPerfStoreConnected,
123
+ recordRender, startRenderTiming, getPerfSummaries,
124
+ getRecentTimings, getSlowestRenders, clearPerfData,
125
+ onPerfEntry,
126
+ } from "mates-devtools";
127
+ import type { RenderTiming, ComponentPerfSummary } from "mates-devtools";
128
+ ```
129
+
130
+ ### Component fragments
131
+
132
+ Each panel section is independently exported if you want to embed a single
133
+ viewer in your own UI:
134
+
135
+ ```ts
136
+ import { renderAtomsViewer } from "mates-devtools";
137
+ import { renderComponentInspector } from "mates-devtools";
138
+ import { renderComponentList } from "mates-devtools";
139
+ import { renderComponentTree } from "mates-devtools";
140
+ import { renderHooksViewer } from "mates-devtools";
141
+ import { renderLogsViewer } from "mates-devtools";
142
+ import { renderPerfViewer } from "mates-devtools";
143
+ import { renderPropsViewer } from "mates-devtools";
144
+ import { renderScopesViewer } from "mates-devtools";
145
+ import { renderUseStateViewer } from "mates-devtools";
146
+ ```
147
+
148
+ ### Styles
149
+
150
+ The CSS-in-JS style map used internally — handy if you're theming the panel:
151
+
152
+ ```ts
153
+ import { styles } from "mates-devtools";
154
+ ```
155
+
156
+ ---
157
+
158
+ ## Types
159
+
160
+ ```ts
161
+ import type {
162
+ DevToolsPosition, // "bottom-right" | "bottom-left" | "top-right" | "top-left"
163
+ DevToolsTab, // "components" | "logs" | "perf" | "timers"
164
+ ComponentInfo,
165
+ ComponentGroup,
166
+ LogEntry,
167
+ LogCategory,
168
+ RenderTiming,
169
+ ComponentPerfSummary,
170
+ } from "mates-devtools";
171
+ ```
172
+
173
+ ---
174
+
175
+ ## Peer dependencies
176
+
177
+ | Package | Version |
178
+ |---------|---------|
179
+ | `mates` | `*` (any version) |
180
+
181
+ `mates-devtools` does **not** bundle mates — it is listed as a peer dependency
182
+ so you always get a single shared copy of the framework at runtime.
183
+
184
+ ---
185
+
186
+ ## License
187
+
188
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mates-devtools",
3
- "version": "0.1.0-beta.1",
3
+ "version": "0.1.0-beta.2",
4
4
  "description": "In-app DevTools panel for the Mates framework",
5
5
  "type": "module",
6
6
  "main": "./dist/mates-devtools.umd.js",
@@ -14,7 +14,8 @@
14
14
  }
15
15
  },
16
16
  "files": [
17
- "dist"
17
+ "dist",
18
+ "README.md"
18
19
  ],
19
20
  "scripts": {
20
21
  "build": "vite build && tsc -p tsconfig.build.json",