@kontsedal/olas-devtools 0.0.1-rc.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Bohdan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,90 @@
1
+ # @kontsedal/olas-devtools
2
+
3
+ In-app devtools UI for an Olas root. Two React components: `<DevtoolsLauncher>` (floating draggable window with a launcher button) and `<DevtoolsPanel>` (the panel itself, for embedding in your own chrome). Both read the same `root.__debug` event stream.
4
+
5
+ A standalone browser extension reading the same stream is tracked in [`../../BACKLOG.md`](../../BACKLOG.md).
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pnpm add @kontsedal/olas-devtools @kontsedal/olas-core @kontsedal/olas-react @preact/signals-core react
11
+ ```
12
+
13
+ `react >= 18` and the three Olas packages are peer deps.
14
+
15
+ ## 30-second example
16
+
17
+ ```tsx
18
+ import { OlasProvider } from '@kontsedal/olas-react'
19
+ import { DevtoolsLauncher } from '@kontsedal/olas-devtools'
20
+ import { createRoot } from '@kontsedal/olas-core'
21
+
22
+ const root = createRoot(appController, { deps })
23
+
24
+ function AppShell() {
25
+ return (
26
+ <OlasProvider root={root}>
27
+ <App />
28
+ {import.meta.env.DEV && <DevtoolsLauncher root={root} />}
29
+ </OlasProvider>
30
+ )
31
+ }
32
+ ```
33
+
34
+ `DevtoolsLauncher` renders a small launcher button in the bottom right; clicking it opens a draggable, resizable window with the panel. Position + size + open / minimized state persist to `localStorage`.
35
+
36
+ If you'd rather host the panel yourself (e.g., fixed sidebar in a layout), import `DevtoolsPanel` directly and size it however you like. Styles are scoped to the `.olas-devtools-*` class prefix; no CSS imports needed.
37
+
38
+ ## What you'll see
39
+
40
+ | Tab | Content |
41
+ |-----|---------|
42
+ | **Tree** | Live controller tree. Each node shows its path segment and lifecycle state (active / suspended / disposed). |
43
+ | **Cache** | Chronological log of `cache:fetch-start` / `fetch-success` / `fetch-error` / `invalidated` / `gc` events. |
44
+ | **Mutations** | Chronological log of `mutation:run` / `success` / `error` / `rollback` events. |
45
+ | **Fields** | Field-level validation outcomes (when emitted — see below). |
46
+
47
+ The **Clear** button empties the three event logs (the tree is live state, not a log, and is preserved).
48
+
49
+ ## API
50
+
51
+ ```ts
52
+ function DevtoolsPanel(props: {
53
+ root: Root<unknown>
54
+ defaultTab?: 'tree' | 'cache' | 'mutations' | 'fields'
55
+ maxEntries?: number // per-log cap, oldest drop first; default 100
56
+ }): JSX.Element
57
+
58
+ // Lower-level store — exported so consumers can build their own UI.
59
+ class DevtoolsStore {
60
+ readonly tree$: Signal<ControllerNode>
61
+ readonly cache$: Signal<CacheEntry[]>
62
+ readonly mutations$: Signal<MutationEntry[]>
63
+ readonly fields$: Signal<FieldEntry[]>
64
+
65
+ attach(root): () => void // subscribes; returns unsubscribe
66
+ handle(event): void // for tests or programmatic feed
67
+ clearLogs(): void
68
+ }
69
+ ```
70
+
71
+ ## Important: the panel sees only post-mount events
72
+
73
+ The panel subscribes to `root.__debug` on mount. Events that fired before mount (e.g. the root controller's `controller:constructed`) are NOT in the tree. Mount the panel as early as possible if you want the full picture. The cache / mutation / field logs are bounded by `maxEntries` (default 100) anyway.
74
+
75
+ If you need historical state, build a parallel `DevtoolsStore` early (next to `createRoot`) and pass it into a custom UI later.
76
+
77
+ ## What's emitted by the runtime
78
+
79
+ Spec §20.9 lists the full `DebugEvent` union. Today the runtime emits:
80
+
81
+ - **controller:** `constructed` / `suspended` / `resumed` / `disposed`
82
+ - **cache:** `fetch-start` / `fetch-success` / `fetch-error` / `invalidated` / `gc`
83
+ - **mutation:** `run` / `success` / `error` / `rollback`
84
+
85
+ `cache:subscribed` and `field:validated` are declared in the type but not yet wired in the runtime. The panel renders them when they arrive; you can also feed them via `store.handle(event)` from your own instrumentation.
86
+
87
+ ## Further reading
88
+
89
+ - [`.wiki/modules/devtools.md`](../../.wiki/modules/devtools.md) — internal mechanics.
90
+ - Spec §13 (Devtools), §20.9 (`DebugEvent`).