@octanejs/tanstack-devtools 0.0.28 → 0.0.30
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 +11 -4
- package/src/devtools.tsrx +59 -42
- package/src/devtools.tsrx.d.ts +1 -1
- package/src/index.ts +11 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@octanejs/tanstack-devtools",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.30",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -33,13 +33,20 @@
|
|
|
33
33
|
"@tanstack/devtools": "0.12.5"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"octane": "0.1.
|
|
36
|
+
"octane": "0.1.36"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
+
"@tanstack/react-devtools": "0.10.7",
|
|
39
40
|
"@testing-library/jest-dom": "^6.9.1",
|
|
41
|
+
"@tsrx/react": "^0.2.56",
|
|
42
|
+
"@types/react": "19.2.17",
|
|
43
|
+
"@types/react-dom": "19.2.3",
|
|
44
|
+
"esbuild": "^0.28.1",
|
|
45
|
+
"react": "19.2.7",
|
|
46
|
+
"react-dom": "19.2.7",
|
|
40
47
|
"vitest": "^4.1.10",
|
|
41
|
-
"@octanejs/testing-library": "0.1.
|
|
42
|
-
"octane": "0.1.
|
|
48
|
+
"@octanejs/testing-library": "0.1.33",
|
|
49
|
+
"octane": "0.1.36"
|
|
43
50
|
},
|
|
44
51
|
"scripts": {
|
|
45
52
|
"test": "vitest run"
|
package/src/devtools.tsrx
CHANGED
|
@@ -26,15 +26,22 @@ import type {
|
|
|
26
26
|
// (a `unknown` union member collapses the whole union to `unknown`).
|
|
27
27
|
type Renderable = {} | null | undefined;
|
|
28
28
|
|
|
29
|
-
type PluginRender =
|
|
29
|
+
type PluginRender =
|
|
30
|
+
| Renderable
|
|
31
|
+
| ((el: HTMLElement, props: TanStackDevtoolsPluginProps) => Renderable);
|
|
30
32
|
|
|
31
33
|
type TriggerProps = {
|
|
32
34
|
theme: TanStackDevtoolsTheme;
|
|
33
35
|
};
|
|
34
36
|
|
|
35
|
-
type TriggerRender =
|
|
37
|
+
type TriggerRender =
|
|
38
|
+
| Renderable
|
|
39
|
+
| ((el: HTMLElement, props: TriggerProps) => Renderable);
|
|
36
40
|
|
|
37
|
-
export type TanStackDevtoolsOctanePlugin = Omit<
|
|
41
|
+
export type TanStackDevtoolsOctanePlugin = Omit<
|
|
42
|
+
TanStackDevtoolsPlugin,
|
|
43
|
+
'render' | 'name'
|
|
44
|
+
> & {
|
|
38
45
|
/**
|
|
39
46
|
* The render can be an octane element or a function that returns one. If it's a
|
|
40
47
|
* function, it's called to render the plugin; otherwise it's rendered directly.
|
|
@@ -59,7 +66,10 @@ export type TanStackDevtoolsOctanePlugin = Omit<TanStackDevtoolsPlugin, 'render'
|
|
|
59
66
|
name: string | PluginRender;
|
|
60
67
|
};
|
|
61
68
|
|
|
62
|
-
type TanStackDevtoolsOctaneConfig = Omit<
|
|
69
|
+
type TanStackDevtoolsOctaneConfig = Omit<
|
|
70
|
+
Partial<TanStackDevtoolsConfig>,
|
|
71
|
+
'customTrigger'
|
|
72
|
+
> & {
|
|
63
73
|
/**
|
|
64
74
|
* Optional custom trigger component. An octane element or a function returning one.
|
|
65
75
|
*
|
|
@@ -94,13 +104,9 @@ export interface TanStackDevtoolsOctaneInit {
|
|
|
94
104
|
eventBusConfig?: ClientEventBusConfig;
|
|
95
105
|
}
|
|
96
106
|
|
|
97
|
-
type ComponentMap = Record<string, Renderable>;
|
|
98
|
-
type ContainerMap = Record<string, HTMLElement>;
|
|
99
|
-
type SetComponents = (updater: (prev: ComponentMap) => ComponentMap) => void;
|
|
100
|
-
|
|
101
107
|
const convertRender = (
|
|
102
108
|
Component: PluginRender,
|
|
103
|
-
setComponents:
|
|
109
|
+
setComponents: (updater: (prev: Record<string, Renderable>) => Record<string, Renderable>) => void,
|
|
104
110
|
e: HTMLElement,
|
|
105
111
|
props: TanStackDevtoolsPluginProps,
|
|
106
112
|
) => {
|
|
@@ -114,7 +120,7 @@ const convertRender = (
|
|
|
114
120
|
|
|
115
121
|
const convertTrigger = (
|
|
116
122
|
Component: TriggerRender,
|
|
117
|
-
setComponent: (element: Renderable) => void,
|
|
123
|
+
setComponent: (element: Renderable | null) => void,
|
|
118
124
|
e: HTMLElement,
|
|
119
125
|
props: TriggerProps,
|
|
120
126
|
) => {
|
|
@@ -128,20 +134,22 @@ function DevtoolsPortal(props: { target: HTMLElement; content: Renderable }) {
|
|
|
128
134
|
return createPortal(props.content, props.target);
|
|
129
135
|
}
|
|
130
136
|
|
|
131
|
-
export
|
|
132
|
-
|
|
133
|
-
|
|
137
|
+
export const TanStackDevtools = ({
|
|
138
|
+
plugins,
|
|
139
|
+
config,
|
|
140
|
+
eventBusConfig,
|
|
141
|
+
}: TanStackDevtoolsOctaneInit): Renderable => {
|
|
134
142
|
const devToolRef = useRef<HTMLDivElement | null>(null);
|
|
135
143
|
|
|
136
|
-
const [pluginContainers, setPluginContainers] = useState<
|
|
137
|
-
const [titleContainers, setTitleContainers] = useState<
|
|
144
|
+
const [pluginContainers, setPluginContainers] = useState<Record<string, HTMLElement>>({});
|
|
145
|
+
const [titleContainers, setTitleContainers] = useState<Record<string, HTMLElement>>({});
|
|
138
146
|
const [triggerContainer, setTriggerContainer] = useState<HTMLElement | null>(null);
|
|
139
147
|
|
|
140
|
-
const [PluginComponents, setPluginComponents] = useState<
|
|
141
|
-
const [TitleComponents, setTitleComponents] = useState<
|
|
142
|
-
const [TriggerComponent, setTriggerComponent] = useState<Renderable>(null);
|
|
148
|
+
const [PluginComponents, setPluginComponents] = useState<Record<string, Renderable>>({});
|
|
149
|
+
const [TitleComponents, setTitleComponents] = useState<Record<string, Renderable>>({});
|
|
150
|
+
const [TriggerComponent, setTriggerComponent] = useState<Renderable | null>(null);
|
|
143
151
|
|
|
144
|
-
const pluginsMap = useMemo
|
|
152
|
+
const pluginsMap: Array<TanStackDevtoolsPlugin> = useMemo(
|
|
145
153
|
() =>
|
|
146
154
|
plugins?.map((plugin) => {
|
|
147
155
|
return {
|
|
@@ -149,7 +157,7 @@ export function TanStackDevtools(props: TanStackDevtoolsOctaneInit) {
|
|
|
149
157
|
name:
|
|
150
158
|
typeof plugin.name === 'string'
|
|
151
159
|
? plugin.name
|
|
152
|
-
: (e
|
|
160
|
+
: (e, props) => {
|
|
153
161
|
const id = e.getAttribute('id')!;
|
|
154
162
|
const target = e.ownerDocument.getElementById(id);
|
|
155
163
|
|
|
@@ -160,9 +168,14 @@ export function TanStackDevtools(props: TanStackDevtoolsOctaneInit) {
|
|
|
160
168
|
}));
|
|
161
169
|
}
|
|
162
170
|
|
|
163
|
-
convertRender(
|
|
171
|
+
convertRender(
|
|
172
|
+
plugin.name as PluginRender,
|
|
173
|
+
setTitleComponents,
|
|
174
|
+
e,
|
|
175
|
+
props,
|
|
176
|
+
);
|
|
164
177
|
},
|
|
165
|
-
render: (e
|
|
178
|
+
render: (e, theme) => {
|
|
166
179
|
const id = e.getAttribute('id')!;
|
|
167
180
|
const target = e.ownerDocument.getElementById(id);
|
|
168
181
|
|
|
@@ -173,9 +186,9 @@ export function TanStackDevtools(props: TanStackDevtoolsOctaneInit) {
|
|
|
173
186
|
}));
|
|
174
187
|
}
|
|
175
188
|
|
|
176
|
-
convertRender(plugin.render, setPluginComponents, e,
|
|
189
|
+
convertRender(plugin.render, setPluginComponents, e, theme);
|
|
177
190
|
},
|
|
178
|
-
}
|
|
191
|
+
};
|
|
179
192
|
}) ?? [],
|
|
180
193
|
[plugins],
|
|
181
194
|
);
|
|
@@ -186,9 +199,9 @@ export function TanStackDevtools(props: TanStackDevtoolsOctaneInit) {
|
|
|
186
199
|
config: {
|
|
187
200
|
...coreConfig,
|
|
188
201
|
customTrigger: customTrigger
|
|
189
|
-
? (el
|
|
202
|
+
? (el, props) => {
|
|
190
203
|
setTriggerContainer(el);
|
|
191
|
-
convertTrigger(customTrigger, setTriggerComponent, el,
|
|
204
|
+
convertTrigger(customTrigger, setTriggerComponent, el, props);
|
|
192
205
|
}
|
|
193
206
|
: undefined,
|
|
194
207
|
},
|
|
@@ -220,21 +233,25 @@ export function TanStackDevtools(props: TanStackDevtoolsOctaneInit) {
|
|
|
220
233
|
<>
|
|
221
234
|
<div style={{ position: 'absolute' }} ref={devToolRef} />
|
|
222
235
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
236
|
+
{hasPlugins
|
|
237
|
+
? Object.entries(pluginContainers).map(function mapPlugin([key, pluginContainer]) {
|
|
238
|
+
return (
|
|
239
|
+
<DevtoolsPortal key={key} target={pluginContainer} content={PluginComponents[key]} />
|
|
240
|
+
);
|
|
241
|
+
})
|
|
242
|
+
: null}
|
|
243
|
+
|
|
244
|
+
{hasTitles
|
|
245
|
+
? Object.entries(titleContainers).map(function mapTitle([key, titleContainer]) {
|
|
246
|
+
return (
|
|
247
|
+
<DevtoolsPortal key={key} target={titleContainer} content={TitleComponents[key]} />
|
|
248
|
+
);
|
|
249
|
+
})
|
|
250
|
+
: null}
|
|
251
|
+
|
|
252
|
+
{triggerContainer && TriggerComponent
|
|
253
|
+
? <DevtoolsPortal target={triggerContainer} content={TriggerComponent} />
|
|
254
|
+
: null}
|
|
238
255
|
</>
|
|
239
256
|
);
|
|
240
|
-
}
|
|
257
|
+
};
|
package/src/devtools.tsrx.d.ts
CHANGED
|
@@ -36,6 +36,6 @@ export interface TanStackDevtoolsOctaneInit {
|
|
|
36
36
|
eventBusConfig?: ClientEventBusConfig;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
export declare
|
|
39
|
+
export declare const TanStackDevtools: (props: TanStackDevtoolsOctaneInit) => Renderable;
|
|
40
40
|
|
|
41
41
|
export {};
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
// OCTANE DIVERGENCE[core-version][conformance:tanstack-devtools-core-version]
|
|
4
|
+
// OCTANE DIVERGENCE[octane-type-names][conformance:tanstack-devtools-octane-type-names]
|
|
5
|
+
import * as Devtools from './devtools.tsrx';
|
|
5
6
|
|
|
7
|
+
export const TanStackDevtools = Devtools.TanStackDevtools;
|
|
8
|
+
|
|
9
|
+
export type {
|
|
10
|
+
TanStackDevtoolsOctanePlugin,
|
|
11
|
+
TanStackDevtoolsOctaneInit,
|
|
12
|
+
} from './devtools.tsrx';
|
|
13
|
+
|
|
14
|
+
// OCTANE DIVERGENCE[extra-core-reexports][conformance:tanstack-devtools-extra-core-reexports]
|
|
6
15
|
// Re-export the framework-agnostic core surface so consumers don't need a direct
|
|
7
16
|
// dependency on @tanstack/devtools for plugin authoring types.
|
|
8
17
|
export {
|