@octanejs/devtools 0.0.60 → 0.0.62

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@octanejs/devtools",
3
- "version": "0.0.60",
3
+ "version": "0.0.62",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "engines": {
@@ -45,13 +45,13 @@
45
45
  "@tanstack/devtools-event-client": "0.5.0"
46
46
  },
47
47
  "peerDependencies": {
48
- "octane": "^0.20.0"
48
+ "octane": "^0.22.0"
49
49
  },
50
50
  "devDependencies": {
51
- "@octanejs/testing-library": "0.1.72",
51
+ "@octanejs/testing-library": "0.1.74",
52
52
  "@tanstack/devtools-event-bus": "0.4.2",
53
53
  "@testing-library/jest-dom": "^6.9.1",
54
- "octane": "0.20.0",
54
+ "octane": "0.22.0",
55
55
  "vitest": "^4.1.10"
56
56
  },
57
57
  "scripts": {
package/src/bridge.ts CHANGED
@@ -45,7 +45,6 @@ const DEVTOOLS_OWN_COMPONENTS = new Set([
45
45
  'ProfilerTab',
46
46
  'TransitionsTab',
47
47
  'PerfModelTab',
48
- 'TreeRow',
49
48
  'NativeReadRows',
50
49
  'DevtoolsPortal',
51
50
  'TanStackDevtools',
@@ -4,7 +4,7 @@
4
4
  // (startBridge) and renders the live component tree plus a selected-node state
5
5
  // inspector. Read-only — selecting a node only asks the app to describe it
6
6
  // (`inspect-request`); it never mutates app state (see docs/devtools.md P1 scope).
7
- import { useEffect, useState } from 'octane';
7
+ import { useEffect, useMemo, useState } from 'octane';
8
8
  import type { OctaneNode } from 'octane';
9
9
  import {
10
10
  OctaneDevtoolsEventClient,
@@ -72,34 +72,29 @@ function NativeReadRows(props: { label: string; reads: readonly NativeReadWire[]
72
72
  </div>
73
73
  }
74
74
 
75
- function TreeRow(props: {
76
- node: WireTreeNode;
77
- onSelect: (id: number) => void;
78
- selected: number | null;
79
- }) @{
80
- <div>
81
- <button
82
- class={['odt-tree-row', props.selected === props.node.id && 'odt-selected']}
83
- onClick={() => props.onSelect(props.node.id)}
84
- >
85
- <span class={['odt-kind', props.node.kind === 'root' && 'odt-kind-root']}>
86
- {props.node.kind}
87
- </span>
88
- <span>{props.node.name}</span>
89
- </button>
90
- @if (props.node.children.length > 0) {
91
- <div class="odt-child">
92
- @for (const child of props.node.children; key child.id) {
93
- <TreeRow node={child} onSelect={props.onSelect} selected={props.selected} />
94
- }
95
- </div>
75
+ type TreeLine = { node: WireTreeNode; depth: number };
76
+
77
+ // Pre-order rows with their nesting depth. Rendering the tree as one flat,
78
+ // indented list keeps stack depth constant however deep the app's tree is (#3021).
79
+ function flattenTree(nodes: readonly WireTreeNode[]): TreeLine[] {
80
+ const lines: TreeLine[] = [];
81
+ const stack: TreeLine[] = [];
82
+ for (let i = nodes.length - 1; i >= 0; i--) stack.push({ node: nodes[i], depth: 0 });
83
+ while (stack.length > 0) {
84
+ const line = stack.pop()!;
85
+ lines.push(line);
86
+ const children = line.node.children;
87
+ for (let i = children.length - 1; i >= 0; i--) {
88
+ stack.push({ node: children[i], depth: line.depth + 1 });
96
89
  }
97
- </div>
90
+ }
91
+ return lines;
98
92
  }
99
93
 
100
94
  export function ComponentsTab(props: { client: OctaneDevtoolsEventClient }): OctaneNode {
101
95
  const { client } = props;
102
96
  const [nodes, setNodes] = useState<WireTreeNode[]>([]);
97
+ const lines = useMemo(() => flattenTree(nodes));
103
98
  const [selected, setSelected, getSelected] = useState<number | null>(null);
104
99
  const [detail, setDetail] = useState<NodeDetail | null>(null);
105
100
 
@@ -135,8 +130,17 @@ export function ComponentsTab(props: { client: OctaneDevtoolsEventClient }): Oct
135
130
  @if (nodes.length === 0) {
136
131
  <div class="odt-empty">No mounted roots yet.</div>
137
132
  } @else {
138
- @for (const node of nodes; key node.id) {
139
- <TreeRow node={node} onSelect={onSelect} selected={selected} />
133
+ @for (const line of lines; key line.node.id) {
134
+ <button
135
+ class={['odt-tree-row', selected === line.node.id && 'odt-selected']}
136
+ style={{ paddingLeft: `${6 + line.depth * 12}px` }}
137
+ onClick={() => onSelect(line.node.id)}
138
+ >
139
+ <span class={['odt-kind', line.node.kind === 'root' && 'odt-kind-root']}>
140
+ {line.node.kind}
141
+ </span>
142
+ <span>{line.node.name}</span>
143
+ </button>
140
144
  }
141
145
  }
142
146
  </div>
@@ -182,11 +182,6 @@ export const OCTANE_DEVTOOLS_CSS = `
182
182
  color: var(--odt-on-accent);
183
183
  background: var(--odt-accent);
184
184
  }
185
- .odt-child {
186
- margin-left: 12px;
187
- border-left: 1px solid var(--odt-border);
188
- padding-left: 4px;
189
- }
190
185
  /* Inspector */
191
186
  .odt-node-name {
192
187
  margin: 0 0 10px;
package/src/plugin.tsrx CHANGED
@@ -14,8 +14,13 @@ import { OctanePanel } from './panel/OctanePanel.tsrx';
14
14
  export function octaneDevtools() {
15
15
  const client = new OctaneDevtoolsEventClient();
16
16
  let stop: (() => void) | null = null;
17
+ // A panel failure stays inside the panel instead of reaching the app's boundary.
17
18
  const OctaneDevtoolsPanel = () => @{
18
- <OctanePanel client={client} />
19
+ @try {
20
+ <OctanePanel client={client} />
21
+ } @catch (error) {
22
+ <div class="odt-root">{'Octane DevTools failed: ' + String(error)}</div>
23
+ }
19
24
  };
20
25
  return {
21
26
  id: 'octane',