@json-render/devtools-solid 0.18.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,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2025 Vercel Inc.
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # @json-render/devtools-solid
2
+
3
+ SolidJS adapter for the [json-render devtools](https://json-render.dev/docs/devtools). Drop-in `<JsonRenderDevtools />` component.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @json-render/devtools @json-render/devtools-solid
9
+ ```
10
+
11
+ Peer dep: `solid-js@^1.9`.
12
+
13
+ ## Usage
14
+
15
+ ```tsx
16
+ import { JsonRenderDevtools } from "@json-render/devtools-solid";
17
+
18
+ <JSONUIProvider registry={registry}>
19
+ <Renderer spec={spec()} registry={registry} />
20
+ <JsonRenderDevtools
21
+ spec={spec()}
22
+ catalog={catalog}
23
+ messages={messages()}
24
+ />
25
+ </JSONUIProvider>;
26
+ ```
27
+
28
+ - Floating toggle appears bottom-right.
29
+ - Hotkey: `Ctrl`/`Cmd` + `Shift` + `J`.
30
+ - Tree-shakes to `null` in production builds.
31
+
32
+ See the [devtools docs](https://json-render.dev/docs/devtools) for the full prop reference and panel tour.
33
+
34
+ ## License
35
+
36
+ Apache-2.0
@@ -0,0 +1,50 @@
1
+ import { Spec, Catalog } from '@json-render/core';
2
+ import { PanelPosition, DevtoolsEvent } from '@json-render/devtools';
3
+ export { DevtoolsEvent } from '@json-render/devtools';
4
+
5
+ interface ChatLikeMessage {
6
+ parts?: Array<{
7
+ type: string;
8
+ text?: string;
9
+ data?: unknown;
10
+ }>;
11
+ }
12
+ /**
13
+ * Props for `<JsonRenderDevtools />`.
14
+ */
15
+ interface JsonRenderDevtoolsProps {
16
+ spec?: Spec | null;
17
+ catalog?: Catalog | null;
18
+ messages?: ChatLikeMessage[];
19
+ initialOpen?: boolean;
20
+ /**
21
+ * Where the panel docks and where the floating toggle lives.
22
+ * - `"bottom-right"` (default), `"bottom-left"` — bottom-docked drawer.
23
+ * - `"right"` — right-docked panel spanning full height; best for
24
+ * app-shell layouts that already use `100vh` / fixed bottom elements.
25
+ */
26
+ position?: PanelPosition;
27
+ hotkey?: string | false;
28
+ bufferSize?: number;
29
+ /**
30
+ * Reserve space for the panel via body padding while open. Default `true`.
31
+ * Set `false` to keep the panel as a pure overlay; the
32
+ * `--jr-devtools-offset-bottom` / `--jr-devtools-offset-right` CSS
33
+ * custom properties are still published for apps to consume manually.
34
+ */
35
+ reserveSpace?: boolean;
36
+ /**
37
+ * Show a toolbar button to flip the panel between bottom-dock and
38
+ * right-dock. Default `true`. The user's choice persists to
39
+ * localStorage. Set `false` to lock the dock to `position`.
40
+ */
41
+ allowDockToggle?: boolean;
42
+ onEvent?: (evt: DevtoolsEvent) => void;
43
+ }
44
+ /**
45
+ * Drop this component anywhere inside a Solid `<JSONUIProvider>` to get a
46
+ * floating devtools panel. Production builds render nothing.
47
+ */
48
+ declare function JsonRenderDevtools(props: JsonRenderDevtoolsProps): null;
49
+
50
+ export { JsonRenderDevtools, type JsonRenderDevtoolsProps };
@@ -0,0 +1,50 @@
1
+ import { Spec, Catalog } from '@json-render/core';
2
+ import { PanelPosition, DevtoolsEvent } from '@json-render/devtools';
3
+ export { DevtoolsEvent } from '@json-render/devtools';
4
+
5
+ interface ChatLikeMessage {
6
+ parts?: Array<{
7
+ type: string;
8
+ text?: string;
9
+ data?: unknown;
10
+ }>;
11
+ }
12
+ /**
13
+ * Props for `<JsonRenderDevtools />`.
14
+ */
15
+ interface JsonRenderDevtoolsProps {
16
+ spec?: Spec | null;
17
+ catalog?: Catalog | null;
18
+ messages?: ChatLikeMessage[];
19
+ initialOpen?: boolean;
20
+ /**
21
+ * Where the panel docks and where the floating toggle lives.
22
+ * - `"bottom-right"` (default), `"bottom-left"` — bottom-docked drawer.
23
+ * - `"right"` — right-docked panel spanning full height; best for
24
+ * app-shell layouts that already use `100vh` / fixed bottom elements.
25
+ */
26
+ position?: PanelPosition;
27
+ hotkey?: string | false;
28
+ bufferSize?: number;
29
+ /**
30
+ * Reserve space for the panel via body padding while open. Default `true`.
31
+ * Set `false` to keep the panel as a pure overlay; the
32
+ * `--jr-devtools-offset-bottom` / `--jr-devtools-offset-right` CSS
33
+ * custom properties are still published for apps to consume manually.
34
+ */
35
+ reserveSpace?: boolean;
36
+ /**
37
+ * Show a toolbar button to flip the panel between bottom-dock and
38
+ * right-dock. Default `true`. The user's choice persists to
39
+ * localStorage. Set `false` to lock the dock to `position`.
40
+ */
41
+ allowDockToggle?: boolean;
42
+ onEvent?: (evt: DevtoolsEvent) => void;
43
+ }
44
+ /**
45
+ * Drop this component anywhere inside a Solid `<JSONUIProvider>` to get a
46
+ * floating devtools panel. Production builds render nothing.
47
+ */
48
+ declare function JsonRenderDevtools(props: JsonRenderDevtoolsProps): null;
49
+
50
+ export { JsonRenderDevtools, type JsonRenderDevtoolsProps };
package/dist/index.js ADDED
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.tsx
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ JsonRenderDevtools: () => JsonRenderDevtools
24
+ });
25
+ module.exports = __toCommonJS(index_exports);
26
+ var import_solid_js = require("solid-js");
27
+ var import_core = require("@json-render/core");
28
+ var import_solid = require("@json-render/solid");
29
+ var import_devtools = require("@json-render/devtools");
30
+ function JsonRenderDevtools(props) {
31
+ if ((0, import_devtools.isProduction)()) return null;
32
+ const stateCtx = (0, import_solid.useStateStore)();
33
+ const store = {
34
+ get: stateCtx.get,
35
+ set: stateCtx.set,
36
+ update: stateCtx.update,
37
+ getSnapshot: stateCtx.getSnapshot,
38
+ subscribe: () => () => {
39
+ }
40
+ };
41
+ const events = (0, import_devtools.createEventStore)({
42
+ bufferSize: props.bufferSize
43
+ });
44
+ const seenParts = /* @__PURE__ */ new WeakSet();
45
+ if (props.onEvent) {
46
+ const unsub = events.subscribe(() => {
47
+ const snap = events.snapshot();
48
+ const last = snap[snap.length - 1];
49
+ if (last) props.onEvent?.(last);
50
+ });
51
+ (0, import_solid_js.onCleanup)(unsub);
52
+ }
53
+ const unsubObserver = (0, import_core.registerActionObserver)({
54
+ onDispatch(evt) {
55
+ events.push({
56
+ kind: "action-dispatched",
57
+ at: evt.at,
58
+ id: evt.id,
59
+ name: evt.name,
60
+ params: evt.params
61
+ });
62
+ },
63
+ onSettle(evt) {
64
+ events.push({
65
+ kind: "action-settled",
66
+ at: evt.at,
67
+ id: evt.id,
68
+ ok: evt.ok,
69
+ durationMs: evt.durationMs,
70
+ result: evt.result,
71
+ error: evt.error !== void 0 ? String(evt.error) : void 0
72
+ });
73
+ }
74
+ });
75
+ (0, import_solid_js.onCleanup)(unsubObserver);
76
+ (0, import_solid_js.createEffect)(() => {
77
+ const messages = props.messages;
78
+ if (!messages) return;
79
+ for (const msg of messages) {
80
+ if (msg?.parts) (0, import_devtools.scanMessageParts)(msg.parts, events, seenParts);
81
+ }
82
+ });
83
+ let handle = null;
84
+ let releaseActive = null;
85
+ let unsubSelection = null;
86
+ (0, import_solid_js.onMount)(() => {
87
+ const selection = (0, import_devtools.createSelectionBus)();
88
+ handle = (0, import_devtools.createPanel)({
89
+ context: {
90
+ events,
91
+ getSpec: () => props.spec ?? null,
92
+ getCatalog: () => props.catalog ?? null,
93
+ getStateStore: () => store,
94
+ startPicker: (opts) => (0, import_devtools.startPicker)(opts),
95
+ selection,
96
+ activateTab: () => {
97
+ }
98
+ },
99
+ tabs: [(0, import_devtools.specTab)(), (0, import_devtools.stateTab)(), (0, import_devtools.actionsTab)(), (0, import_devtools.streamTab)(), (0, import_devtools.catalogTab)()],
100
+ initialOpen: props.initialOpen,
101
+ position: props.position,
102
+ hotkey: props.hotkey,
103
+ reserveSpace: props.reserveSpace,
104
+ allowDockToggle: props.allowDockToggle
105
+ });
106
+ unsubSelection = selection.subscribe((key) => {
107
+ if (key) (0, import_devtools.highlightElement)(key);
108
+ });
109
+ releaseActive = (0, import_core.markDevtoolsActive)();
110
+ });
111
+ (0, import_solid_js.onCleanup)(() => {
112
+ unsubSelection?.();
113
+ releaseActive?.();
114
+ handle?.destroy();
115
+ handle = null;
116
+ });
117
+ return null;
118
+ }
119
+ // Annotate the CommonJS export names for ESM import in node:
120
+ 0 && (module.exports = {
121
+ JsonRenderDevtools
122
+ });
123
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.tsx"],"sourcesContent":["import { createEffect, onCleanup, onMount } from \"solid-js\";\nimport type { Catalog, Spec, StateStore } from \"@json-render/core\";\nimport { markDevtoolsActive, registerActionObserver } from \"@json-render/core\";\nimport { useStateStore } from \"@json-render/solid\";\nimport {\n actionsTab,\n catalogTab,\n createEventStore,\n createPanel,\n createSelectionBus,\n highlightElement,\n isProduction,\n scanMessageParts,\n specTab,\n startPicker,\n stateTab,\n streamTab,\n type DevtoolsEvent,\n type PanelHandle,\n type PanelPosition,\n} from \"@json-render/devtools\";\n\ninterface ChatLikeMessage {\n parts?: Array<{ type: string; text?: string; data?: unknown }>;\n}\n\n/**\n * Props for `<JsonRenderDevtools />`.\n */\nexport interface JsonRenderDevtoolsProps {\n spec?: Spec | null;\n catalog?: Catalog | null;\n messages?: ChatLikeMessage[];\n initialOpen?: boolean;\n /**\n * Where the panel docks and where the floating toggle lives.\n * - `\"bottom-right\"` (default), `\"bottom-left\"` — bottom-docked drawer.\n * - `\"right\"` — right-docked panel spanning full height; best for\n * app-shell layouts that already use `100vh` / fixed bottom elements.\n */\n position?: PanelPosition;\n hotkey?: string | false;\n bufferSize?: number;\n /**\n * Reserve space for the panel via body padding while open. Default `true`.\n * Set `false` to keep the panel as a pure overlay; the\n * `--jr-devtools-offset-bottom` / `--jr-devtools-offset-right` CSS\n * custom properties are still published for apps to consume manually.\n */\n reserveSpace?: boolean;\n /**\n * Show a toolbar button to flip the panel between bottom-dock and\n * right-dock. Default `true`. The user's choice persists to\n * localStorage. Set `false` to lock the dock to `position`.\n */\n allowDockToggle?: boolean;\n onEvent?: (evt: DevtoolsEvent) => void;\n}\n\n/**\n * Drop this component anywhere inside a Solid `<JSONUIProvider>` to get a\n * floating devtools panel. Production builds render nothing.\n */\nexport function JsonRenderDevtools(props: JsonRenderDevtoolsProps) {\n if (isProduction()) return null;\n\n const stateCtx = useStateStore();\n const store: StateStore = {\n get: stateCtx.get,\n set: stateCtx.set,\n update: stateCtx.update,\n getSnapshot: stateCtx.getSnapshot,\n subscribe: () => () => {},\n };\n\n const events = createEventStore({ bufferSize: props.bufferSize });\n const seenParts = new WeakSet<object>();\n\n if (props.onEvent) {\n const unsub = events.subscribe(() => {\n const snap = events.snapshot();\n const last = snap[snap.length - 1];\n if (last) props.onEvent?.(last);\n });\n onCleanup(unsub);\n }\n\n const unsubObserver = registerActionObserver({\n onDispatch(evt) {\n events.push({\n kind: \"action-dispatched\",\n at: evt.at,\n id: evt.id,\n name: evt.name,\n params: evt.params,\n });\n },\n onSettle(evt) {\n events.push({\n kind: \"action-settled\",\n at: evt.at,\n id: evt.id,\n ok: evt.ok,\n durationMs: evt.durationMs,\n result: evt.result,\n error: evt.error !== undefined ? String(evt.error) : undefined,\n });\n },\n });\n onCleanup(unsubObserver);\n\n // Capture stream events from AI SDK messages.\n createEffect(() => {\n const messages = props.messages;\n if (!messages) return;\n for (const msg of messages) {\n if (msg?.parts) scanMessageParts(msg.parts, events, seenParts);\n }\n });\n\n let handle: PanelHandle | null = null;\n let releaseActive: (() => void) | null = null;\n let unsubSelection: (() => void) | null = null;\n\n onMount(() => {\n const selection = createSelectionBus();\n handle = createPanel({\n context: {\n events,\n getSpec: () => props.spec ?? null,\n getCatalog: () => props.catalog ?? null,\n getStateStore: () => store,\n startPicker: (opts) => startPicker(opts),\n selection,\n activateTab: () => {},\n },\n tabs: [specTab(), stateTab(), actionsTab(), streamTab(), catalogTab()],\n initialOpen: props.initialOpen,\n position: props.position,\n hotkey: props.hotkey,\n reserveSpace: props.reserveSpace,\n allowDockToggle: props.allowDockToggle,\n });\n unsubSelection = selection.subscribe((key) => {\n if (key) highlightElement(key);\n });\n releaseActive = markDevtoolsActive();\n });\n\n onCleanup(() => {\n unsubSelection?.();\n releaseActive?.();\n handle?.destroy();\n handle = null;\n });\n\n return null;\n}\n\nexport type { DevtoolsEvent } from \"@json-render/devtools\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;;;;sBAAiD;AAEjD,kBAA2D;AAC3D,mBAA8B;AAC9B,sBAgBO;AA2CA,SAASA,mBAAmBC,OAAgC;AACjE,UAAIC,8BAAa,EAAG,QAAO;AAE3B,QAAMC,eAAWC,4BAAc;AAC/B,QAAMC,QAAoB;IACxBC,KAAKH,SAASG;IACdC,KAAKJ,SAASI;IACdC,QAAQL,SAASK;IACjBC,aAAaN,SAASM;IACtBC,WAAWA,MAAM,MAAM;IAAC;EAC1B;AAEA,QAAMC,aAASC,kCAAiB;IAAEC,YAAYZ,MAAMY;EAAW,CAAC;AAChE,QAAMC,YAAY,oBAAIC,QAAgB;AAEtC,MAAId,MAAMe,SAAS;AACjB,UAAMC,QAAQN,OAAOD,UAAU,MAAM;AACnC,YAAMQ,OAAOP,OAAOQ,SAAS;AAC7B,YAAMC,OAAOF,KAAKA,KAAKG,SAAS,CAAC;AACjC,UAAID,KAAMnB,OAAMe,UAAUI,IAAI;IAChC,CAAC;AACDE,mCAAUL,KAAK;EACjB;AAEA,QAAMM,oBAAgBC,oCAAuB;IAC3CC,WAAWC,KAAK;AACdf,aAAOgB,KAAK;QACVC,MAAM;QACNC,IAAIH,IAAIG;QACRC,IAAIJ,IAAII;QACRC,MAAML,IAAIK;QACVC,QAAQN,IAAIM;MACd,CAAC;IACH;IACAC,SAASP,KAAK;AACZf,aAAOgB,KAAK;QACVC,MAAM;QACNC,IAAIH,IAAIG;QACRC,IAAIJ,IAAII;QACRI,IAAIR,IAAIQ;QACRC,YAAYT,IAAIS;QAChBC,QAAQV,IAAIU;QACZC,OAAOX,IAAIW,UAAUC,SAAYC,OAAOb,IAAIW,KAAK,IAAIC;MACvD,CAAC;IACH;EACF,CAAC;AACDhB,iCAAUC,aAAa;AAGvBiB,oCAAa,MAAM;AACjB,UAAMC,WAAWxC,MAAMwC;AACvB,QAAI,CAACA,SAAU;AACf,eAAWC,OAAOD,UAAU;AAC1B,UAAIC,KAAKC,MAAOC,uCAAiBF,IAAIC,OAAOhC,QAAQG,SAAS;IAC/D;EACF,CAAC;AAED,MAAI+B,SAA6B;AACjC,MAAIC,gBAAqC;AACzC,MAAIC,iBAAsC;AAE1CC,+BAAQ,MAAM;AACZ,UAAMC,gBAAYC,oCAAmB;AACrCL,iBAASM,6BAAY;MACnBC,SAAS;QACPzC;QACA0C,SAASA,MAAMpD,MAAMqD,QAAQ;QAC7BC,YAAYA,MAAMtD,MAAMuD,WAAW;QACnCC,eAAeA,MAAMpD;QACrBqD,aAAcC,cAASD,6BAAYC,IAAI;QACvCV;QACAW,aAAaA,MAAM;QAAC;MACtB;MACAC,MAAM,KAACC,yBAAQ,OAAGC,0BAAS,OAAGC,4BAAW,OAAGC,2BAAU,OAAGC,4BAAW,CAAC;MACrEC,aAAalE,MAAMkE;MACnBC,UAAUnE,MAAMmE;MAChBC,QAAQpE,MAAMoE;MACdC,cAAcrE,MAAMqE;MACpBC,iBAAiBtE,MAAMsE;IACzB,CAAC;AACDxB,qBAAiBE,UAAUvC,UAAW8D,SAAQ;AAC5C,UAAIA,IAAKC,uCAAiBD,GAAG;IAC/B,CAAC;AACD1B,wBAAgB4B,gCAAmB;EACrC,CAAC;AAEDpD,iCAAU,MAAM;AACdyB,qBAAiB;AACjBD,oBAAgB;AAChBD,YAAQ8B,QAAQ;AAChB9B,aAAS;EACX,CAAC;AAED,SAAO;AACT;","names":["JsonRenderDevtools","props","isProduction","stateCtx","useStateStore","store","get","set","update","getSnapshot","subscribe","events","createEventStore","bufferSize","seenParts","WeakSet","onEvent","unsub","snap","snapshot","last","length","onCleanup","unsubObserver","registerActionObserver","onDispatch","evt","push","kind","at","id","name","params","onSettle","ok","durationMs","result","error","undefined","String","createEffect","messages","msg","parts","scanMessageParts","handle","releaseActive","unsubSelection","onMount","selection","createSelectionBus","createPanel","context","getSpec","spec","getCatalog","catalog","getStateStore","startPicker","opts","activateTab","tabs","specTab","stateTab","actionsTab","streamTab","catalogTab","initialOpen","position","hotkey","reserveSpace","allowDockToggle","key","highlightElement","markDevtoolsActive","destroy"]}
package/dist/index.mjs ADDED
@@ -0,0 +1,98 @@
1
+ // src/index.tsx
2
+ import { createEffect, onCleanup, onMount } from "solid-js";
3
+ import { markDevtoolsActive, registerActionObserver } from "@json-render/core";
4
+ import { useStateStore } from "@json-render/solid";
5
+ import { actionsTab, catalogTab, createEventStore, createPanel, createSelectionBus, highlightElement, isProduction, scanMessageParts, specTab, startPicker, stateTab, streamTab } from "@json-render/devtools";
6
+ function JsonRenderDevtools(props) {
7
+ if (isProduction()) return null;
8
+ const stateCtx = useStateStore();
9
+ const store = {
10
+ get: stateCtx.get,
11
+ set: stateCtx.set,
12
+ update: stateCtx.update,
13
+ getSnapshot: stateCtx.getSnapshot,
14
+ subscribe: () => () => {
15
+ }
16
+ };
17
+ const events = createEventStore({
18
+ bufferSize: props.bufferSize
19
+ });
20
+ const seenParts = /* @__PURE__ */ new WeakSet();
21
+ if (props.onEvent) {
22
+ const unsub = events.subscribe(() => {
23
+ const snap = events.snapshot();
24
+ const last = snap[snap.length - 1];
25
+ if (last) props.onEvent?.(last);
26
+ });
27
+ onCleanup(unsub);
28
+ }
29
+ const unsubObserver = registerActionObserver({
30
+ onDispatch(evt) {
31
+ events.push({
32
+ kind: "action-dispatched",
33
+ at: evt.at,
34
+ id: evt.id,
35
+ name: evt.name,
36
+ params: evt.params
37
+ });
38
+ },
39
+ onSettle(evt) {
40
+ events.push({
41
+ kind: "action-settled",
42
+ at: evt.at,
43
+ id: evt.id,
44
+ ok: evt.ok,
45
+ durationMs: evt.durationMs,
46
+ result: evt.result,
47
+ error: evt.error !== void 0 ? String(evt.error) : void 0
48
+ });
49
+ }
50
+ });
51
+ onCleanup(unsubObserver);
52
+ createEffect(() => {
53
+ const messages = props.messages;
54
+ if (!messages) return;
55
+ for (const msg of messages) {
56
+ if (msg?.parts) scanMessageParts(msg.parts, events, seenParts);
57
+ }
58
+ });
59
+ let handle = null;
60
+ let releaseActive = null;
61
+ let unsubSelection = null;
62
+ onMount(() => {
63
+ const selection = createSelectionBus();
64
+ handle = createPanel({
65
+ context: {
66
+ events,
67
+ getSpec: () => props.spec ?? null,
68
+ getCatalog: () => props.catalog ?? null,
69
+ getStateStore: () => store,
70
+ startPicker: (opts) => startPicker(opts),
71
+ selection,
72
+ activateTab: () => {
73
+ }
74
+ },
75
+ tabs: [specTab(), stateTab(), actionsTab(), streamTab(), catalogTab()],
76
+ initialOpen: props.initialOpen,
77
+ position: props.position,
78
+ hotkey: props.hotkey,
79
+ reserveSpace: props.reserveSpace,
80
+ allowDockToggle: props.allowDockToggle
81
+ });
82
+ unsubSelection = selection.subscribe((key) => {
83
+ if (key) highlightElement(key);
84
+ });
85
+ releaseActive = markDevtoolsActive();
86
+ });
87
+ onCleanup(() => {
88
+ unsubSelection?.();
89
+ releaseActive?.();
90
+ handle?.destroy();
91
+ handle = null;
92
+ });
93
+ return null;
94
+ }
95
+ export {
96
+ JsonRenderDevtools
97
+ };
98
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.tsx"],"sourcesContent":["import { createEffect, onCleanup, onMount } from \"solid-js\";\nimport type { Catalog, Spec, StateStore } from \"@json-render/core\";\nimport { markDevtoolsActive, registerActionObserver } from \"@json-render/core\";\nimport { useStateStore } from \"@json-render/solid\";\nimport {\n actionsTab,\n catalogTab,\n createEventStore,\n createPanel,\n createSelectionBus,\n highlightElement,\n isProduction,\n scanMessageParts,\n specTab,\n startPicker,\n stateTab,\n streamTab,\n type DevtoolsEvent,\n type PanelHandle,\n type PanelPosition,\n} from \"@json-render/devtools\";\n\ninterface ChatLikeMessage {\n parts?: Array<{ type: string; text?: string; data?: unknown }>;\n}\n\n/**\n * Props for `<JsonRenderDevtools />`.\n */\nexport interface JsonRenderDevtoolsProps {\n spec?: Spec | null;\n catalog?: Catalog | null;\n messages?: ChatLikeMessage[];\n initialOpen?: boolean;\n /**\n * Where the panel docks and where the floating toggle lives.\n * - `\"bottom-right\"` (default), `\"bottom-left\"` — bottom-docked drawer.\n * - `\"right\"` — right-docked panel spanning full height; best for\n * app-shell layouts that already use `100vh` / fixed bottom elements.\n */\n position?: PanelPosition;\n hotkey?: string | false;\n bufferSize?: number;\n /**\n * Reserve space for the panel via body padding while open. Default `true`.\n * Set `false` to keep the panel as a pure overlay; the\n * `--jr-devtools-offset-bottom` / `--jr-devtools-offset-right` CSS\n * custom properties are still published for apps to consume manually.\n */\n reserveSpace?: boolean;\n /**\n * Show a toolbar button to flip the panel between bottom-dock and\n * right-dock. Default `true`. The user's choice persists to\n * localStorage. Set `false` to lock the dock to `position`.\n */\n allowDockToggle?: boolean;\n onEvent?: (evt: DevtoolsEvent) => void;\n}\n\n/**\n * Drop this component anywhere inside a Solid `<JSONUIProvider>` to get a\n * floating devtools panel. Production builds render nothing.\n */\nexport function JsonRenderDevtools(props: JsonRenderDevtoolsProps) {\n if (isProduction()) return null;\n\n const stateCtx = useStateStore();\n const store: StateStore = {\n get: stateCtx.get,\n set: stateCtx.set,\n update: stateCtx.update,\n getSnapshot: stateCtx.getSnapshot,\n subscribe: () => () => {},\n };\n\n const events = createEventStore({ bufferSize: props.bufferSize });\n const seenParts = new WeakSet<object>();\n\n if (props.onEvent) {\n const unsub = events.subscribe(() => {\n const snap = events.snapshot();\n const last = snap[snap.length - 1];\n if (last) props.onEvent?.(last);\n });\n onCleanup(unsub);\n }\n\n const unsubObserver = registerActionObserver({\n onDispatch(evt) {\n events.push({\n kind: \"action-dispatched\",\n at: evt.at,\n id: evt.id,\n name: evt.name,\n params: evt.params,\n });\n },\n onSettle(evt) {\n events.push({\n kind: \"action-settled\",\n at: evt.at,\n id: evt.id,\n ok: evt.ok,\n durationMs: evt.durationMs,\n result: evt.result,\n error: evt.error !== undefined ? String(evt.error) : undefined,\n });\n },\n });\n onCleanup(unsubObserver);\n\n // Capture stream events from AI SDK messages.\n createEffect(() => {\n const messages = props.messages;\n if (!messages) return;\n for (const msg of messages) {\n if (msg?.parts) scanMessageParts(msg.parts, events, seenParts);\n }\n });\n\n let handle: PanelHandle | null = null;\n let releaseActive: (() => void) | null = null;\n let unsubSelection: (() => void) | null = null;\n\n onMount(() => {\n const selection = createSelectionBus();\n handle = createPanel({\n context: {\n events,\n getSpec: () => props.spec ?? null,\n getCatalog: () => props.catalog ?? null,\n getStateStore: () => store,\n startPicker: (opts) => startPicker(opts),\n selection,\n activateTab: () => {},\n },\n tabs: [specTab(), stateTab(), actionsTab(), streamTab(), catalogTab()],\n initialOpen: props.initialOpen,\n position: props.position,\n hotkey: props.hotkey,\n reserveSpace: props.reserveSpace,\n allowDockToggle: props.allowDockToggle,\n });\n unsubSelection = selection.subscribe((key) => {\n if (key) highlightElement(key);\n });\n releaseActive = markDevtoolsActive();\n });\n\n onCleanup(() => {\n unsubSelection?.();\n releaseActive?.();\n handle?.destroy();\n handle = null;\n });\n\n return null;\n}\n\nexport type { DevtoolsEvent } from \"@json-render/devtools\";\n"],"mappings":";AAAA,SAASA,cAAcC,WAAWC,eAAe;AAEjD,SAASC,oBAAoBC,8BAA8B;AAC3D,SAASC,qBAAqB;AAC9B,SACEC,YACAC,YACAC,kBACAC,aACAC,oBACAC,kBACAC,cACAC,kBACAC,SACAC,aACAC,UACAC,iBAIK;AA2CA,SAASC,mBAAmBC,OAAgC;AACjE,MAAIP,aAAa,EAAG,QAAO;AAE3B,QAAMQ,WAAWf,cAAc;AAC/B,QAAMgB,QAAoB;IACxBC,KAAKF,SAASE;IACdC,KAAKH,SAASG;IACdC,QAAQJ,SAASI;IACjBC,aAAaL,SAASK;IACtBC,WAAWA,MAAM,MAAM;IAAC;EAC1B;AAEA,QAAMC,SAASnB,iBAAiB;IAAEoB,YAAYT,MAAMS;EAAW,CAAC;AAChE,QAAMC,YAAY,oBAAIC,QAAgB;AAEtC,MAAIX,MAAMY,SAAS;AACjB,UAAMC,QAAQL,OAAOD,UAAU,MAAM;AACnC,YAAMO,OAAON,OAAOO,SAAS;AAC7B,YAAMC,OAAOF,KAAKA,KAAKG,SAAS,CAAC;AACjC,UAAID,KAAMhB,OAAMY,UAAUI,IAAI;IAChC,CAAC;AACDlC,cAAU+B,KAAK;EACjB;AAEA,QAAMK,gBAAgBjC,uBAAuB;IAC3CkC,WAAWC,KAAK;AACdZ,aAAOa,KAAK;QACVC,MAAM;QACNC,IAAIH,IAAIG;QACRC,IAAIJ,IAAII;QACRC,MAAML,IAAIK;QACVC,QAAQN,IAAIM;MACd,CAAC;IACH;IACAC,SAASP,KAAK;AACZZ,aAAOa,KAAK;QACVC,MAAM;QACNC,IAAIH,IAAIG;QACRC,IAAIJ,IAAII;QACRI,IAAIR,IAAIQ;QACRC,YAAYT,IAAIS;QAChBC,QAAQV,IAAIU;QACZC,OAAOX,IAAIW,UAAUC,SAAYC,OAAOb,IAAIW,KAAK,IAAIC;MACvD,CAAC;IACH;EACF,CAAC;AACDlD,YAAUoC,aAAa;AAGvBrC,eAAa,MAAM;AACjB,UAAMqD,WAAWlC,MAAMkC;AACvB,QAAI,CAACA,SAAU;AACf,eAAWC,OAAOD,UAAU;AAC1B,UAAIC,KAAKC,MAAO1C,kBAAiByC,IAAIC,OAAO5B,QAAQE,SAAS;IAC/D;EACF,CAAC;AAED,MAAI2B,SAA6B;AACjC,MAAIC,gBAAqC;AACzC,MAAIC,iBAAsC;AAE1CxD,UAAQ,MAAM;AACZ,UAAMyD,YAAYjD,mBAAmB;AACrC8C,aAAS/C,YAAY;MACnBmD,SAAS;QACPjC;QACAkC,SAASA,MAAM1C,MAAM2C,QAAQ;QAC7BC,YAAYA,MAAM5C,MAAM6C,WAAW;QACnCC,eAAeA,MAAM5C;QACrBN,aAAcmD,UAASnD,YAAYmD,IAAI;QACvCP;QACAQ,aAAaA,MAAM;QAAC;MACtB;MACAC,MAAM,CAACtD,QAAQ,GAAGE,SAAS,GAAGV,WAAW,GAAGW,UAAU,GAAGV,WAAW,CAAC;MACrE8D,aAAalD,MAAMkD;MACnBC,UAAUnD,MAAMmD;MAChBC,QAAQpD,MAAMoD;MACdC,cAAcrD,MAAMqD;MACpBC,iBAAiBtD,MAAMsD;IACzB,CAAC;AACDf,qBAAiBC,UAAUjC,UAAWgD,SAAQ;AAC5C,UAAIA,IAAK/D,kBAAiB+D,GAAG;IAC/B,CAAC;AACDjB,oBAAgBtD,mBAAmB;EACrC,CAAC;AAEDF,YAAU,MAAM;AACdyD,qBAAiB;AACjBD,oBAAgB;AAChBD,YAAQmB,QAAQ;AAChBnB,aAAS;EACX,CAAC;AAED,SAAO;AACT;","names":["createEffect","onCleanup","onMount","markDevtoolsActive","registerActionObserver","useStateStore","actionsTab","catalogTab","createEventStore","createPanel","createSelectionBus","highlightElement","isProduction","scanMessageParts","specTab","startPicker","stateTab","streamTab","JsonRenderDevtools","props","stateCtx","store","get","set","update","getSnapshot","subscribe","events","bufferSize","seenParts","WeakSet","onEvent","unsub","snap","snapshot","last","length","unsubObserver","onDispatch","evt","push","kind","at","id","name","params","onSettle","ok","durationMs","result","error","undefined","String","messages","msg","parts","handle","releaseActive","unsubSelection","selection","context","getSpec","spec","getCatalog","catalog","getStateStore","opts","activateTab","tabs","initialOpen","position","hotkey","reserveSpace","allowDockToggle","key","destroy"]}
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@json-render/devtools-solid",
3
+ "version": "0.18.0",
4
+ "license": "Apache-2.0",
5
+ "description": "SolidJS adapter for @json-render/devtools. Drop-in <JsonRenderDevtools /> component.",
6
+ "keywords": [
7
+ "json",
8
+ "ui",
9
+ "solid",
10
+ "solidjs",
11
+ "devtools",
12
+ "inspector",
13
+ "generative-ui",
14
+ "debug"
15
+ ],
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/vercel-labs/json-render.git",
19
+ "directory": "packages/devtools-solid"
20
+ },
21
+ "homepage": "https://json-render.dev",
22
+ "bugs": {
23
+ "url": "https://github.com/vercel-labs/json-render/issues"
24
+ },
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
28
+ "main": "./dist/index.js",
29
+ "module": "./dist/index.mjs",
30
+ "types": "./dist/index.d.ts",
31
+ "exports": {
32
+ ".": {
33
+ "types": "./dist/index.d.ts",
34
+ "import": "./dist/index.mjs",
35
+ "require": "./dist/index.js"
36
+ }
37
+ },
38
+ "files": [
39
+ "dist"
40
+ ],
41
+ "dependencies": {
42
+ "@json-render/core": "0.18.0",
43
+ "@json-render/solid": "0.18.0",
44
+ "@json-render/devtools": "0.18.0"
45
+ },
46
+ "devDependencies": {
47
+ "esbuild-plugin-solid": "^0.6.0",
48
+ "solid-js": "^1.9.0",
49
+ "tsup": "^8.0.2",
50
+ "typescript": "^5.4.5",
51
+ "@internal/typescript-config": "0.0.0"
52
+ },
53
+ "peerDependencies": {
54
+ "solid-js": "^1.9.0"
55
+ },
56
+ "scripts": {
57
+ "build": "tsup",
58
+ "dev": "tsup --watch",
59
+ "typecheck": "tsc --noEmit"
60
+ }
61
+ }