@praxisjs/devtools 0.2.2 → 0.2.4

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": "@praxisjs/devtools",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -12,10 +12,10 @@
12
12
  },
13
13
  "dependencies": {
14
14
  "@unocss/reset": "^66.6.2",
15
- "@praxisjs/core": "0.4.0",
16
- "@praxisjs/decorators": "0.4.0",
17
- "@praxisjs/jsx": "0.3.0",
18
- "@praxisjs/runtime": "0.2.1",
15
+ "@praxisjs/core": "0.4.1",
16
+ "@praxisjs/decorators": "0.4.2",
17
+ "@praxisjs/jsx": "0.3.2",
18
+ "@praxisjs/runtime": "0.2.3",
19
19
  "@praxisjs/shared": "0.2.0"
20
20
  },
21
21
  "devDependencies": {
@@ -1,8 +1,7 @@
1
1
  import { time } from "@utils/format-time";
2
2
 
3
3
  import { StatefulComponent } from "@praxisjs/core";
4
- import { Component, State } from "@praxisjs/decorators";
5
-
4
+ import { Component, Prop, State } from "@praxisjs/decorators";
6
5
 
7
6
  import { Badge } from "./badge";
8
7
 
@@ -11,9 +10,12 @@ import type { TimelineEntry } from "@core/types";
11
10
  @Component()
12
11
  export class TimelineRow extends StatefulComponent {
13
12
  @State() open = false;
13
+ @Prop() entry: TimelineEntry | undefined;
14
14
 
15
15
  render() {
16
- const { entry } = this.props as { entry: TimelineEntry };
16
+ const entry = this.entry;
17
+ if (!entry) return null;
18
+
17
19
  const hasData = Object.keys(entry.data).length > 0;
18
20
 
19
21
  return (
@@ -7,7 +7,7 @@ import { TimelinePlugin } from "@plugins/timeline";
7
7
  import unoReset from "@unocss/reset/tailwind-v4.css?inline";
8
8
 
9
9
  import { StatefulComponent } from "@praxisjs/core";
10
- import { Component, State } from "@praxisjs/decorators";
10
+ import { Component, Prop, State } from "@praxisjs/decorators";
11
11
  import { render } from "@praxisjs/runtime";
12
12
 
13
13
  import { Panel } from "./panel";
@@ -27,23 +27,17 @@ export interface DevToolsOptions {
27
27
  @Component()
28
28
  class DevToolsApp extends StatefulComponent {
29
29
  @State() open = false;
30
-
31
- private get p() {
32
- return this.props as unknown as {
33
- plugins: DevtoolsPlugin[];
34
- registry: Registry;
35
- };
36
- }
30
+ @Prop() plugins: DevtoolsPlugin[] = [];
31
+ @Prop() registry: Registry | undefined;
37
32
 
38
33
  render() {
39
- const { plugins, registry } = this.p;
40
34
  return (
41
35
  <div>
42
36
  {() =>
43
37
  this.open ? (
44
38
  <Panel
45
- plugins={plugins}
46
- registry={registry}
39
+ plugins={this.plugins}
40
+ registry={this.registry}
47
41
  onClose={() => {
48
42
  this.open = false;
49
43
  }}
package/src/ui/panel.tsx CHANGED
@@ -10,18 +10,12 @@ import {
10
10
  import { IconButton } from "@shared/icon-button";
11
11
 
12
12
  import { StatefulComponent } from "@praxisjs/core";
13
- import { Component, State } from "@praxisjs/decorators";
13
+ import { Component, Emit, Prop, State } from "@praxisjs/decorators";
14
14
  import type { ComponentElement } from "@praxisjs/shared";
15
15
 
16
16
  import type { Registry } from "@core/registry";
17
17
  import type { DevtoolsPlugin } from "@plugins/types";
18
18
 
19
- interface PanelProps {
20
- plugins: DevtoolsPlugin[];
21
- registry: Registry;
22
- onClose: () => void;
23
- }
24
-
25
19
  type Dock = "bottom" | "top" | "left" | "right";
26
20
 
27
21
  const MIN_HEIGHT = 180;
@@ -44,12 +38,17 @@ export class Panel extends StatefulComponent {
44
38
  @State() bottomSize = DEFAULT_HEIGHT;
45
39
  @State() vertSize = DEFAULT_WIDTH;
46
40
 
47
- private get p() {
48
- return this.props as unknown as PanelProps;
41
+ @Prop() plugins: DevtoolsPlugin[] = [];
42
+ @Prop() registry: Registry | undefined;
43
+
44
+ @Emit("onClose")
45
+ handleClose() {
46
+ return;
49
47
  }
48
+ declare onClose: (() => void) | undefined;
50
49
 
51
- onBeforeMount() {
52
- this.activeTab = this.p.plugins[0]?.id ?? "";
50
+ onMount() {
51
+ if (this.plugins.length > 0) this.activeTab = this.plugins[0].id;
53
52
  }
54
53
 
55
54
  handleMouseDown(e: MouseEvent) {
@@ -81,18 +80,12 @@ export class Panel extends StatefulComponent {
81
80
  } else if (d === "left") {
82
81
  this.vertSize = Math.max(
83
82
  MIN_WIDTH,
84
- Math.min(
85
- window.innerWidth * 0.6,
86
- startSize + (ev.clientX - startX),
87
- ),
83
+ Math.min(window.innerWidth * 0.6, startSize + (ev.clientX - startX)),
88
84
  );
89
85
  } else {
90
86
  this.vertSize = Math.max(
91
87
  MIN_WIDTH,
92
- Math.min(
93
- window.innerWidth * 0.6,
94
- startSize + (startX - ev.clientX),
95
- ),
88
+ Math.min(window.innerWidth * 0.6, startSize + (startX - ev.clientX)),
96
89
  );
97
90
  }
98
91
  };
@@ -107,7 +100,7 @@ export class Panel extends StatefulComponent {
107
100
  }
108
101
 
109
102
  render() {
110
- const { plugins, registry, onClose } = this.p;
103
+ // const { plugins, registry, onClose } = this.p;
111
104
  return (
112
105
  <div
113
106
  class={() => {
@@ -128,13 +121,17 @@ export class Panel extends StatefulComponent {
128
121
  return "h-1 cursor-[ns-resize] bg-transparent hover:bg-accent transition-colors duration-200";
129
122
  return "w-1 cursor-[ew-resize] bg-transparent hover:bg-accent transition-colors duration-200";
130
123
  }}
131
- onMouseDown={(e: MouseEvent) => { this.handleMouseDown(e); }}
124
+ onMouseDown={(e: MouseEvent) => {
125
+ this.handleMouseDown(e);
126
+ }}
132
127
  />
133
128
  <div
134
129
  class={() => {
135
130
  const d = this.dock;
136
- if (d === "top") return "w-full h-full bg-bg border-b border-border";
137
- if (d === "left") return "w-full h-full bg-bg border-r border-border";
131
+ if (d === "top")
132
+ return "w-full h-full bg-bg border-b border-border";
133
+ if (d === "left")
134
+ return "w-full h-full bg-bg border-r border-border";
138
135
  if (d === "right")
139
136
  return "w-full h-full bg-bg border-l border-border";
140
137
  return "w-full h-full bg-bg border-t border-border";
@@ -156,26 +153,28 @@ export class Panel extends StatefulComponent {
156
153
  </div>
157
154
 
158
155
  <div class="flex items-stretch flex-1">
159
- {plugins.map((p) => (
160
- <button
161
- key={p.id}
162
- class={() =>
163
- this.activeTab === p.id
164
- ? "relative flex items-center px-3 text-[11px] font-semibold text-accent cursor-pointer"
165
- : "flex items-center px-3 text-[11px] text-muted cursor-pointer hover:text-text transition-colors duration-150"
166
- }
167
- onClick={() => {
168
- this.activeTab = p.id;
169
- }}
170
- >
171
- {p.label}
172
- {() =>
173
- this.activeTab === p.id ? (
174
- <span class="absolute bottom-0 left-0 right-0 h-[2px] bg-accent" />
175
- ) : null
176
- }
177
- </button>
178
- ))}
156
+ {() =>
157
+ this.plugins.map((p) => (
158
+ <button
159
+ key={p.id}
160
+ class={() =>
161
+ this.activeTab === p.id
162
+ ? "relative flex items-center px-3 text-[11px] font-semibold text-accent cursor-pointer"
163
+ : "flex items-center px-3 text-[11px] text-muted cursor-pointer hover:text-text transition-colors duration-150"
164
+ }
165
+ onClick={() => {
166
+ this.activeTab = p.id;
167
+ }}
168
+ >
169
+ {p.label}
170
+ {() =>
171
+ this.activeTab === p.id ? (
172
+ <span class="absolute bottom-0 left-0 right-0 h-[2px] bg-accent" />
173
+ ) : null
174
+ }
175
+ </button>
176
+ ))
177
+ }
179
178
  </div>
180
179
 
181
180
  <div class="flex items-center gap-[2px] shrink-0">
@@ -212,15 +211,23 @@ export class Panel extends StatefulComponent {
212
211
 
213
212
  <div class="w-px h-3 bg-border mx-1" />
214
213
 
215
- <IconButton title="Close" icon={XIcon} onClick={onClose} />
214
+ <IconButton
215
+ title="Close"
216
+ icon={XIcon}
217
+ onClick={() => {
218
+ this.handleClose();
219
+ }}
220
+ />
216
221
  </div>
217
222
  </div>
218
223
 
219
224
  <div class="flex-1 overflow-hidden flex flex-col">
220
225
  {() => {
221
- const plugin = plugins.find((p) => p.id === this.activeTab);
226
+ const plugin = this.plugins.find(
227
+ (p) => p.id === this.activeTab,
228
+ );
222
229
  const Active = plugin?.component;
223
- return Active ? <Active registry={registry} /> : null;
230
+ return Active ? <Active registry={this.registry} /> : null;
224
231
  }}
225
232
  </div>
226
233
  </div>