@reopt-ai/opt-devtool 1.0.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/CHANGELOG.md +31 -0
- package/LICENSE +21 -0
- package/README.md +149 -0
- package/dist/brandapp/index.cjs +391 -0
- package/dist/brandapp/index.d.cts +95 -0
- package/dist/brandapp/index.d.ts +95 -0
- package/dist/brandapp/index.js +391 -0
- package/dist/chunk-4MJKIAXH.cjs +65 -0
- package/dist/chunk-5HRIQSVF.js +32 -0
- package/dist/chunk-6AGUYGVT.cjs +77 -0
- package/dist/chunk-EQPETYJJ.cjs +32 -0
- package/dist/chunk-H3F2WACS.cjs +568 -0
- package/dist/chunk-N7YO56TN.cjs +25 -0
- package/dist/chunk-SQ3E3QLA.cjs +253 -0
- package/dist/chunk-SW2FF6EV.js +568 -0
- package/dist/chunk-UJSIQF3A.js +25 -0
- package/dist/chunk-UQY5I3WS.js +253 -0
- package/dist/chunk-YCYIUFB4.js +65 -0
- package/dist/chunk-Z2KFRHSI.js +77 -0
- package/dist/datagrid/index.cjs +187 -0
- package/dist/datagrid/index.d.cts +14 -0
- package/dist/datagrid/index.d.ts +14 -0
- package/dist/datagrid/index.js +187 -0
- package/dist/editor/index.cjs +239 -0
- package/dist/editor/index.d.cts +14 -0
- package/dist/editor/index.d.ts +14 -0
- package/dist/editor/index.js +239 -0
- package/dist/harness/index.cjs +13 -0
- package/dist/harness/index.d.cts +30 -0
- package/dist/harness/index.d.ts +30 -0
- package/dist/harness/index.js +13 -0
- package/dist/index-Bakx4o8Z.d.cts +91 -0
- package/dist/index-Bakx4o8Z.d.ts +91 -0
- package/dist/index.cjs +3895 -0
- package/dist/index.d.cts +22 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +3895 -0
- package/dist/theme/index.cjs +13 -0
- package/dist/theme/index.d.cts +33 -0
- package/dist/theme/index.d.ts +33 -0
- package/dist/theme/index.js +13 -0
- package/dist/ui/index.cjs +8 -0
- package/dist/ui/index.d.cts +2 -0
- package/dist/ui/index.d.ts +2 -0
- package/dist/ui/index.js +8 -0
- package/package.json +153 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@reopt-ai/opt-devtool` will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [1.0.0] - 2026-07-12
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- First stable public release on npm. The package API is now covered by semantic-versioning stability guarantees; no breaking changes from the 0.x line.
|
|
15
|
+
|
|
16
|
+
## [0.1.0] - 2026-05-15
|
|
17
|
+
|
|
18
|
+
### Added (initial publish)
|
|
19
|
+
|
|
20
|
+
- **Development-only devtool overlay** — toggle with `Ctrl+Shift+F`.
|
|
21
|
+
- **Multi-export bridges**: `/ui`, `/datagrid`, `/editor`, `/harness`, `/theme` — consumers import only the bridge they need so tree-shaking can drop unused integrations.
|
|
22
|
+
- **5 overlay types**: `inspect-tool`, `component-labels`, `composite-bounds`, `focus-guide`, `tab-order`.
|
|
23
|
+
- **6 panels**: `component-tree`, `component-trace`, `harness-panel`, `theme-panel`, and others.
|
|
24
|
+
- **Fiber traversal & composite detection** with visibility / tabbable analysis.
|
|
25
|
+
|
|
26
|
+
### Notes
|
|
27
|
+
|
|
28
|
+
- Development-only — must not be imported in production builds. Consumer apps gate the `<OptDevtool />` mount behind `process.env.NODE_ENV === "development"`.
|
|
29
|
+
- Renamed from `@reopt-ai/opt-inspect` (pre-publish). The `opt-inspect` namespace was never published.
|
|
30
|
+
|
|
31
|
+
See also `/docs/opt-ui/releases` (v1.7.0 wave) for cross-package context.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) reopt Inc.
|
|
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,149 @@
|
|
|
1
|
+
# @reopt-ai/opt-devtool
|
|
2
|
+
|
|
3
|
+
Development-only devtool overlay for the opt design modules. Inspect focus
|
|
4
|
+
flow, ARIA wiring, composite zones, harness state boundaries, theme tokens,
|
|
5
|
+
Brandapp SDK wiring, and live snapshots from `opt-datagrid` / `opt-editor` /
|
|
6
|
+
`opt-shell` in one floating panel.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
bun add -D @reopt-ai/opt-devtool
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
`react`, `react-dom`, `@reopt-ai/opt-ui`, and (optionally) the engine
|
|
15
|
+
packages you want bridges for must already be present.
|
|
16
|
+
|
|
17
|
+
## Quick start
|
|
18
|
+
|
|
19
|
+
Mount the provider once near the root of the app, render `<OptDevtool />`
|
|
20
|
+
in development, and call the per-engine bridges where you control the engine
|
|
21
|
+
state:
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
"use client";
|
|
25
|
+
|
|
26
|
+
import { OptDevtool, OptDevtoolProvider } from "@reopt-ai/opt-devtool";
|
|
27
|
+
|
|
28
|
+
export function DevtoolHost({ children }: { children: React.ReactNode }) {
|
|
29
|
+
return (
|
|
30
|
+
<OptDevtoolProvider>
|
|
31
|
+
{children}
|
|
32
|
+
{process.env.NODE_ENV !== "production" && <OptDevtool />}
|
|
33
|
+
</OptDevtoolProvider>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
The panel is hidden by default and toggles with **Ctrl+Shift+F**.
|
|
39
|
+
Pass `defaultOpen` to start visible.
|
|
40
|
+
|
|
41
|
+
## Multi-export
|
|
42
|
+
|
|
43
|
+
Import the bridge for the engine you want to inspect:
|
|
44
|
+
|
|
45
|
+
| Sub-path | Hook | Purpose |
|
|
46
|
+
| -------------------------------- | -------------------------- | ------------------------------------------------------ |
|
|
47
|
+
| `@reopt-ai/opt-devtool` | — | `OptDevtool`, `OptDevtoolProvider`, types |
|
|
48
|
+
| `@reopt-ai/opt-devtool/datagrid` | `useDataGridDevtoolBridge` | DataGrid runtime / selection / remote telemetry |
|
|
49
|
+
| `@reopt-ai/opt-devtool/editor` | `useEditorDevtoolBridge` | EditorSpec mode / streaming / selection / integrations |
|
|
50
|
+
| `@reopt-ai/opt-devtool/brandapp` | `useBrandappDevtoolBridge` | Brandapp ID, auth/env, EAV, AI, route wiring |
|
|
51
|
+
| `@reopt-ai/opt-devtool/harness` | `useShellDevtoolBridge` | Harness manifest / state boundaries / adapter status |
|
|
52
|
+
| `@reopt-ai/opt-devtool/theme` | `useThemeDevtoolBridge` | Resolved theme tokens, contrast pairs, palette config |
|
|
53
|
+
| `@reopt-ai/opt-devtool/ui` | — | Configure event constants for runtime control |
|
|
54
|
+
|
|
55
|
+
Each `useXxxBridge({ id, label, order? })` returns `{ inspect(snapshot) }`.
|
|
56
|
+
Call `inspect()` whenever the engine state you want to expose changes:
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
const { inspect } = useDataGridDevtoolBridge({ id: "users-grid", label: "Users" });
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
inspect(buildSnapshot(grid));
|
|
62
|
+
}, [grid.activeCell, grid.selection, ...]);
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
The harness and theme bridges also auto-listen for `SHELL_SNAPSHOT_EVENT` /
|
|
66
|
+
`SHELL_THEME_EVENT` dispatched by `ShellProvider`, so a manual bridge
|
|
67
|
+
call is optional when you only want the default panel.
|
|
68
|
+
|
|
69
|
+
## Brandapp SDK bridge
|
|
70
|
+
|
|
71
|
+
Use `@reopt-ai/opt-devtool/brandapp` to expose the Brandapp connection points
|
|
72
|
+
that make SDK integration debuggable: `brandappId`, masked client ID, required
|
|
73
|
+
env presence, auth/EAV/AI feature status, route wiring, schema hash, and notes.
|
|
74
|
+
The bridge does not import `@reopt-ai/brandapp-sdk`; pass a serializable
|
|
75
|
+
snapshot from the app so secrets can stay server-only.
|
|
76
|
+
|
|
77
|
+
If `snapshot` is provided, the Brandapp bridge is controlled by that prop.
|
|
78
|
+
The returned `inspect` and `clear` callbacks are for uncontrolled snapshots and
|
|
79
|
+
will not override the prop-driven view.
|
|
80
|
+
|
|
81
|
+
```tsx
|
|
82
|
+
"use client";
|
|
83
|
+
|
|
84
|
+
import { useBrandappDevtoolBridge } from "@reopt-ai/opt-devtool/brandapp";
|
|
85
|
+
|
|
86
|
+
export function BrandappDevtoolBridge() {
|
|
87
|
+
useBrandappDevtoolBridge({
|
|
88
|
+
id: "brandapp",
|
|
89
|
+
label: "Brandapp",
|
|
90
|
+
snapshot: {
|
|
91
|
+
brandappId: "brandapp_123",
|
|
92
|
+
clientId: "clie...9abc",
|
|
93
|
+
baseUrl: "https://api.reopt.ai",
|
|
94
|
+
auth: { status: "configured", provider: "better-auth / Reopt OAuth" },
|
|
95
|
+
eav: { status: "configured", schemaHash: "eav-hash" },
|
|
96
|
+
ai: { status: "configured", routePath: "/api/design-agent" },
|
|
97
|
+
env: [
|
|
98
|
+
{ name: "BRANDAPP_ID", present: true, required: true, scope: "server" },
|
|
99
|
+
{
|
|
100
|
+
name: "BRANDAPP_CLIENT_SECRET",
|
|
101
|
+
present: true,
|
|
102
|
+
required: true,
|
|
103
|
+
scope: "server",
|
|
104
|
+
note: "value hidden",
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Runtime control
|
|
115
|
+
|
|
116
|
+
Toggle internal state from any frame on the same window by dispatching
|
|
117
|
+
`OPT_DEVTOOL_CONFIGURE_EVENT`:
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
import { OPT_DEVTOOL_CONFIGURE_EVENT } from "@reopt-ai/opt-devtool/ui";
|
|
121
|
+
|
|
122
|
+
window.dispatchEvent(
|
|
123
|
+
new CustomEvent(OPT_DEVTOOL_CONFIGURE_EVENT, {
|
|
124
|
+
detail: { visible: true, showTabOrder: true, showInspect: false },
|
|
125
|
+
}),
|
|
126
|
+
);
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Available `OptDevtoolConfig` flags: `visible`, `showGuide`, `showTabOrder`,
|
|
130
|
+
`showSpatialNav`, `showEventLog`, `showComponentTrace`, `showComponentTree`,
|
|
131
|
+
`showInspect`, `showComponentLabels`, `showCompositeBounds`.
|
|
132
|
+
|
|
133
|
+
## Keyboard
|
|
134
|
+
|
|
135
|
+
| Shortcut | Action |
|
|
136
|
+
| ------------------------------------------------ | ------------------------ |
|
|
137
|
+
| `Ctrl+Shift+F` | Toggle the devtool panel |
|
|
138
|
+
| Click on element while **인스펙트** toggle is on | Pin inspect target |
|
|
139
|
+
| Click again | Unpin |
|
|
140
|
+
|
|
141
|
+
## Notes
|
|
142
|
+
|
|
143
|
+
- Development-only: `sideEffects: false` so unused bridges tree-shake out,
|
|
144
|
+
but it is still a good idea to gate `<OptDevtool />` behind `NODE_ENV`.
|
|
145
|
+
- Reads private React Fiber expando keys (`__reactFiber$`,
|
|
146
|
+
`__reactInternalInstance$`, `__reactContainer$`) to surface component
|
|
147
|
+
ancestry. Wrapped in try/catch so failures degrade silently.
|
|
148
|
+
- The legacy `opt-ui-helper-configure` event is still accepted for backward
|
|
149
|
+
compatibility but is deprecated and will be removed in 0.3.0.
|
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
var _chunk6AGUYGVTcjs = require('../chunk-6AGUYGVT.cjs');
|
|
6
|
+
require('../chunk-N7YO56TN.cjs');
|
|
7
|
+
|
|
8
|
+
// src/brandapp/index.tsx
|
|
9
|
+
var _react = require('react'); var React = _interopRequireWildcard(_react);
|
|
10
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
11
|
+
var STATUS_STYLES = {
|
|
12
|
+
connected: "bg-emerald-400",
|
|
13
|
+
configured: "bg-blue-400",
|
|
14
|
+
missing: "bg-red-400",
|
|
15
|
+
warning: "bg-amber-300",
|
|
16
|
+
error: "bg-red-400",
|
|
17
|
+
unknown: "bg-white/25"
|
|
18
|
+
};
|
|
19
|
+
var STATUS_TEXT_STYLES = {
|
|
20
|
+
connected: "text-emerald-300",
|
|
21
|
+
configured: "text-blue-300",
|
|
22
|
+
missing: "text-red-300",
|
|
23
|
+
warning: "text-amber-300",
|
|
24
|
+
error: "text-red-300",
|
|
25
|
+
unknown: "text-white/45"
|
|
26
|
+
};
|
|
27
|
+
function statusLabel(status) {
|
|
28
|
+
return status != null ? status : "unknown";
|
|
29
|
+
}
|
|
30
|
+
function getBrandappRequiredEnvSummary(env) {
|
|
31
|
+
const required = (env != null ? env : []).filter((item) => item.required);
|
|
32
|
+
return {
|
|
33
|
+
total: required.length,
|
|
34
|
+
present: required.filter((item) => item.present).length,
|
|
35
|
+
missing: required.filter((item) => !item.present).map((item) => item.name)
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function getBrandappSnapshotStatus(snapshot) {
|
|
39
|
+
var _a, _b, _c, _d, _e;
|
|
40
|
+
const requiredEnv = getBrandappRequiredEnvSummary(snapshot.env);
|
|
41
|
+
const statuses = [
|
|
42
|
+
(_a = snapshot.auth) == null ? void 0 : _a.status,
|
|
43
|
+
(_b = snapshot.eav) == null ? void 0 : _b.status,
|
|
44
|
+
(_c = snapshot.ai) == null ? void 0 : _c.status,
|
|
45
|
+
...((_d = snapshot.features) != null ? _d : []).map((feature) => feature.status),
|
|
46
|
+
...((_e = snapshot.routes) != null ? _e : []).map((route) => route.status)
|
|
47
|
+
];
|
|
48
|
+
if (statuses.includes("error")) {
|
|
49
|
+
return "error";
|
|
50
|
+
}
|
|
51
|
+
if (requiredEnv.missing.length > 0 || statuses.includes("missing")) {
|
|
52
|
+
return "missing";
|
|
53
|
+
}
|
|
54
|
+
if (statuses.includes("warning")) {
|
|
55
|
+
return "warning";
|
|
56
|
+
}
|
|
57
|
+
if (statuses.includes("connected")) {
|
|
58
|
+
return "connected";
|
|
59
|
+
}
|
|
60
|
+
if (statuses.includes("configured")) {
|
|
61
|
+
return "configured";
|
|
62
|
+
}
|
|
63
|
+
return "unknown";
|
|
64
|
+
}
|
|
65
|
+
function formatDate(value) {
|
|
66
|
+
if (value === void 0) {
|
|
67
|
+
return "-";
|
|
68
|
+
}
|
|
69
|
+
const date = typeof value === "number" ? new Date(value) : new Date(value);
|
|
70
|
+
if (Number.isNaN(date.getTime())) {
|
|
71
|
+
return String(value);
|
|
72
|
+
}
|
|
73
|
+
return date.toLocaleString();
|
|
74
|
+
}
|
|
75
|
+
function formatOptional(value) {
|
|
76
|
+
if (value === null || value === void 0 || value === "") {
|
|
77
|
+
return "-";
|
|
78
|
+
}
|
|
79
|
+
return String(value);
|
|
80
|
+
}
|
|
81
|
+
function StatusDot({
|
|
82
|
+
status,
|
|
83
|
+
label
|
|
84
|
+
}) {
|
|
85
|
+
const resolved = status != null ? status : "unknown";
|
|
86
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "inline-flex items-center gap-1.5", children: [
|
|
87
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
88
|
+
"span",
|
|
89
|
+
{
|
|
90
|
+
className: `inline-block h-1.5 w-1.5 rounded-full ${STATUS_STYLES[resolved]}`
|
|
91
|
+
}
|
|
92
|
+
),
|
|
93
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: STATUS_TEXT_STYLES[resolved], children: label })
|
|
94
|
+
] });
|
|
95
|
+
}
|
|
96
|
+
function InfoRow({
|
|
97
|
+
label,
|
|
98
|
+
value
|
|
99
|
+
}) {
|
|
100
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid min-w-0 grid-cols-[5.75rem_minmax(0,1fr)] items-center gap-1 rounded-md bg-white/[0.035] px-2 py-1", children: [
|
|
101
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "truncate text-[9px] font-semibold tracking-wide text-white/35 uppercase", children: label }),
|
|
102
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "min-w-0 truncate rounded bg-black/20 px-1.5 py-0.5 text-right font-mono text-[10px] text-white/78", children: formatOptional(value) })
|
|
103
|
+
] });
|
|
104
|
+
}
|
|
105
|
+
function CollapsibleGroup({
|
|
106
|
+
title,
|
|
107
|
+
trailing,
|
|
108
|
+
defaultOpen = true,
|
|
109
|
+
children
|
|
110
|
+
}) {
|
|
111
|
+
const [open, setOpen] = React.useState(defaultOpen);
|
|
112
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "section", { className: "overflow-hidden rounded-lg bg-white/[0.025]", children: [
|
|
113
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
114
|
+
"button",
|
|
115
|
+
{
|
|
116
|
+
type: "button",
|
|
117
|
+
tabIndex: -1,
|
|
118
|
+
onClick: () => setOpen((current) => !current),
|
|
119
|
+
className: "flex w-full items-center justify-between gap-2 bg-white/[0.045] px-2.5 py-1.5 text-left transition-colors hover:bg-white/[0.065]",
|
|
120
|
+
"aria-expanded": open,
|
|
121
|
+
children: [
|
|
122
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "flex min-w-0 items-center gap-1.5", children: [
|
|
123
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-[9px] text-white/35", children: open ? "\u25BE" : "\u25B8" }),
|
|
124
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "truncate text-[10px] font-semibold text-emerald-400", children: title })
|
|
125
|
+
] }),
|
|
126
|
+
trailing
|
|
127
|
+
]
|
|
128
|
+
}
|
|
129
|
+
),
|
|
130
|
+
open ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "px-2.5 py-2", children }) : null
|
|
131
|
+
] });
|
|
132
|
+
}
|
|
133
|
+
function SummaryPanel({ snapshot }) {
|
|
134
|
+
const requiredEnv = getBrandappRequiredEnvSummary(snapshot.env);
|
|
135
|
+
const status = getBrandappSnapshotStatus(snapshot);
|
|
136
|
+
const statusText = statusLabel(status);
|
|
137
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "section", { className: "rounded-lg bg-white/[0.05] px-2.5 py-2", children: [
|
|
138
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center justify-between gap-2", children: [
|
|
139
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, StatusDot, { status, label: `Brandapp ${statusText}` }),
|
|
140
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "rounded bg-black/20 px-1.5 py-0.5 font-mono text-[9px] text-white/55", children: [
|
|
141
|
+
"env ",
|
|
142
|
+
requiredEnv.present,
|
|
143
|
+
"/",
|
|
144
|
+
requiredEnv.total
|
|
145
|
+
] })
|
|
146
|
+
] }),
|
|
147
|
+
requiredEnv.missing.length > 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "mt-1.5 flex flex-wrap gap-1", children: requiredEnv.missing.map((name) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
148
|
+
"span",
|
|
149
|
+
{
|
|
150
|
+
className: "rounded bg-red-500/15 px-1.5 py-0.5 font-mono text-[9px] text-red-200",
|
|
151
|
+
children: [
|
|
152
|
+
"missing ",
|
|
153
|
+
name
|
|
154
|
+
]
|
|
155
|
+
},
|
|
156
|
+
name
|
|
157
|
+
)) }) : null
|
|
158
|
+
] });
|
|
159
|
+
}
|
|
160
|
+
function FeatureList({
|
|
161
|
+
features
|
|
162
|
+
}) {
|
|
163
|
+
if (!features || features.length === 0) {
|
|
164
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "text-[10px] text-white/40", children: "No feature signals." });
|
|
165
|
+
}
|
|
166
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex flex-col gap-1", children: features.map((feature) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
167
|
+
"div",
|
|
168
|
+
{
|
|
169
|
+
className: "grid min-w-0 grid-cols-[6.5rem_minmax(0,1fr)] items-start gap-1 rounded-md bg-white/[0.035] px-2 py-1",
|
|
170
|
+
children: [
|
|
171
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "min-w-0 truncate", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, StatusDot, { status: feature.status, label: feature.label }) }),
|
|
172
|
+
feature.detail ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "min-w-0 truncate rounded bg-black/20 px-1.5 py-0.5 font-mono text-[9px] text-white/55", children: feature.detail }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rounded bg-black/20 px-1.5 py-0.5 font-mono text-[9px] text-white/35", children: "-" })
|
|
173
|
+
]
|
|
174
|
+
},
|
|
175
|
+
feature.id
|
|
176
|
+
)) });
|
|
177
|
+
}
|
|
178
|
+
function EnvList({
|
|
179
|
+
env
|
|
180
|
+
}) {
|
|
181
|
+
if (!env || env.length === 0) {
|
|
182
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "text-[10px] text-white/40", children: "No env signals." });
|
|
183
|
+
}
|
|
184
|
+
const requiredEnv = getBrandappRequiredEnvSummary(env);
|
|
185
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col gap-1", children: [
|
|
186
|
+
requiredEnv.missing.length > 0 ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rounded bg-red-500/12 px-2 py-1 text-[10px] text-red-200", children: [
|
|
187
|
+
"Missing required env: ",
|
|
188
|
+
requiredEnv.missing.join(", ")
|
|
189
|
+
] }) : null,
|
|
190
|
+
env.map((item) => {
|
|
191
|
+
var _a, _b;
|
|
192
|
+
const status = item.present ? "configured" : item.required ? "missing" : "unknown";
|
|
193
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
194
|
+
"div",
|
|
195
|
+
{
|
|
196
|
+
className: "grid grid-cols-[minmax(0,1fr)_minmax(4.5rem,auto)] gap-1 rounded-md bg-white/[0.035] px-2 py-1",
|
|
197
|
+
children: [
|
|
198
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "min-w-0", children: [
|
|
199
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex min-w-0 items-center gap-1.5", children: [
|
|
200
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, StatusDot, { status, label: item.name }),
|
|
201
|
+
item.required ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rounded bg-amber-400/12 px-1 py-0.5 text-[8px] text-amber-300", children: "required" }) : null
|
|
202
|
+
] }),
|
|
203
|
+
item.note ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "truncate pl-3 text-[9px] text-white/35", children: item.note }) : null
|
|
204
|
+
] }),
|
|
205
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "min-w-0 truncate rounded bg-black/20 px-1.5 py-0.5 text-right font-mono text-[9px] text-white/55", children: (_b = (_a = item.maskedValue) != null ? _a : item.scope) != null ? _b : "" })
|
|
206
|
+
]
|
|
207
|
+
},
|
|
208
|
+
item.name
|
|
209
|
+
);
|
|
210
|
+
})
|
|
211
|
+
] });
|
|
212
|
+
}
|
|
213
|
+
function RouteList({
|
|
214
|
+
routes
|
|
215
|
+
}) {
|
|
216
|
+
if (!routes || routes.length === 0) {
|
|
217
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "text-[10px] text-white/40", children: "No route signals." });
|
|
218
|
+
}
|
|
219
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex flex-col gap-1", children: routes.map((route) => {
|
|
220
|
+
var _a, _b, _c;
|
|
221
|
+
const status = (_a = route.status) != null ? _a : "unknown";
|
|
222
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
223
|
+
"div",
|
|
224
|
+
{
|
|
225
|
+
className: "min-w-0 rounded-md bg-white/[0.035] px-2 py-1",
|
|
226
|
+
children: [
|
|
227
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid min-w-0 grid-cols-[3.25rem_minmax(0,1fr)] items-center gap-1", children: [
|
|
228
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "min-w-0 truncate", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, StatusDot, { status, label: (_c = route.method) != null ? _c : "GET" }) }),
|
|
229
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "truncate rounded bg-black/20 px-1.5 py-0.5 font-mono text-[10px] text-white/75", children: route.path })
|
|
230
|
+
] }),
|
|
231
|
+
route.statusCode !== void 0 || route.latencyMs !== void 0 || route.lastCheckedAt !== void 0 ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "mt-1 flex flex-wrap gap-1 pl-[3.75rem]", children: [
|
|
232
|
+
route.statusCode !== void 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rounded bg-black/20 px-1.5 py-0.5 text-[9px] text-white/45", children: route.statusCode }) : null,
|
|
233
|
+
route.latencyMs !== void 0 ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "rounded bg-black/20 px-1.5 py-0.5 text-[9px] text-white/45", children: [
|
|
234
|
+
route.latencyMs,
|
|
235
|
+
"ms"
|
|
236
|
+
] }) : null,
|
|
237
|
+
route.lastCheckedAt !== void 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rounded bg-black/20 px-1.5 py-0.5 text-[9px] text-white/40", children: formatDate(route.lastCheckedAt) }) : null
|
|
238
|
+
] }) : null,
|
|
239
|
+
route.description ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "truncate pl-3 text-[9px] text-white/35", children: route.description }) : null
|
|
240
|
+
]
|
|
241
|
+
},
|
|
242
|
+
`${(_b = route.method) != null ? _b : "GET"} ${route.path}`
|
|
243
|
+
);
|
|
244
|
+
}) });
|
|
245
|
+
}
|
|
246
|
+
function formatEntityMetric(entity) {
|
|
247
|
+
if (entity.recordCount !== void 0) {
|
|
248
|
+
return `${entity.recordCount} rows`;
|
|
249
|
+
}
|
|
250
|
+
if (entity.attributeCount !== void 0) {
|
|
251
|
+
return `${entity.attributeCount} attrs`;
|
|
252
|
+
}
|
|
253
|
+
if (entity.synced) {
|
|
254
|
+
return "synced";
|
|
255
|
+
}
|
|
256
|
+
return entity.id;
|
|
257
|
+
}
|
|
258
|
+
function EavPanel({ eav }) {
|
|
259
|
+
if (!eav) {
|
|
260
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "text-[10px] text-white/40", children: "No EAV signal." });
|
|
261
|
+
}
|
|
262
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col gap-1.5", children: [
|
|
263
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid gap-x-3 gap-y-1 text-[10px] md:grid-cols-2", children: [
|
|
264
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, InfoRow, { label: "status", value: statusLabel(eav.status) }),
|
|
265
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, InfoRow, { label: "schema", value: eav.schemaHash }),
|
|
266
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, InfoRow, { label: "lockfile", value: eav.lockfileHash }),
|
|
267
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, InfoRow, { label: "sync", value: formatDate(eav.lastSyncAt) })
|
|
268
|
+
] }),
|
|
269
|
+
eav.entities && eav.entities.length > 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex flex-col gap-1", children: eav.entities.slice(0, 6).map((entity) => {
|
|
270
|
+
var _a, _b;
|
|
271
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
272
|
+
"div",
|
|
273
|
+
{
|
|
274
|
+
className: "grid grid-cols-[minmax(0,1fr)_auto] gap-1 rounded-md bg-white/[0.035] px-2 py-1 text-[10px]",
|
|
275
|
+
children: [
|
|
276
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "truncate text-white/70", children: (_b = (_a = entity.label) != null ? _a : entity.name) != null ? _b : entity.id }),
|
|
277
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rounded bg-black/20 px-1.5 py-0.5 font-mono text-white/55", children: formatEntityMetric(entity) })
|
|
278
|
+
]
|
|
279
|
+
},
|
|
280
|
+
entity.id
|
|
281
|
+
);
|
|
282
|
+
}) }) : null
|
|
283
|
+
] });
|
|
284
|
+
}
|
|
285
|
+
function BrandappDevtoolPanel({
|
|
286
|
+
snapshot
|
|
287
|
+
}) {
|
|
288
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
289
|
+
if (!snapshot) {
|
|
290
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "text-[11px] text-white/55", children: "Waiting for Brandapp SDK snapshot." });
|
|
291
|
+
}
|
|
292
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col gap-3 text-[11px]", children: [
|
|
293
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, SummaryPanel, { snapshot }),
|
|
294
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, CollapsibleGroup, { title: "Identity", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid gap-x-3 gap-y-1 text-[10px] md:grid-cols-2", children: [
|
|
295
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, InfoRow, { label: "brandappId", value: snapshot.brandappId }),
|
|
296
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, InfoRow, { label: "clientId", value: snapshot.clientId }),
|
|
297
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, InfoRow, { label: "baseUrl", value: snapshot.baseUrl }),
|
|
298
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, InfoRow, { label: "sdk", value: snapshot.sdkVersion }),
|
|
299
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, InfoRow, { label: "env", value: snapshot.environment }),
|
|
300
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, InfoRow, { label: "updated", value: formatDate(snapshot.updatedAt) })
|
|
301
|
+
] }) }),
|
|
302
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, CollapsibleGroup, { title: "Connection", children: [
|
|
303
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-wrap gap-x-3 gap-y-1.5 text-white/70", children: [
|
|
304
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, StatusDot, { status: (_a = snapshot.auth) == null ? void 0 : _a.status, label: "Auth" }),
|
|
305
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, StatusDot, { status: (_b = snapshot.eav) == null ? void 0 : _b.status, label: "EAV" }),
|
|
306
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, StatusDot, { status: (_c = snapshot.ai) == null ? void 0 : _c.status, label: "AI" }),
|
|
307
|
+
((_d = snapshot.auth) == null ? void 0 : _d.session) ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "text-white/45", children: [
|
|
308
|
+
"session: ",
|
|
309
|
+
snapshot.auth.session
|
|
310
|
+
] }) : null
|
|
311
|
+
] }),
|
|
312
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "mt-1 grid gap-x-3 gap-y-1 text-[10px] md:grid-cols-2", children: [
|
|
313
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, InfoRow, { label: "provider", value: (_e = snapshot.auth) == null ? void 0 : _e.provider }),
|
|
314
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, InfoRow, { label: "callback", value: (_f = snapshot.auth) == null ? void 0 : _f.callbackPath }),
|
|
315
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, InfoRow, { label: "user", value: (_g = snapshot.auth) == null ? void 0 : _g.userId }),
|
|
316
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, InfoRow, { label: "org", value: (_h = snapshot.auth) == null ? void 0 : _h.organizationId })
|
|
317
|
+
] })
|
|
318
|
+
] }),
|
|
319
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, CollapsibleGroup, { title: "Features", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, FeatureList, { features: snapshot.features }) }),
|
|
320
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, CollapsibleGroup, { title: "Environment", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, EnvList, { env: snapshot.env }) }),
|
|
321
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, CollapsibleGroup, { title: "EAV", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, EavPanel, { eav: snapshot.eav }) }),
|
|
322
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, CollapsibleGroup, { title: "Routes", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, RouteList, { routes: snapshot.routes }) }),
|
|
323
|
+
snapshot.ai ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, CollapsibleGroup, { title: "AI", children: [
|
|
324
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid gap-x-3 gap-y-1 text-[10px] md:grid-cols-2", children: [
|
|
325
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, InfoRow, { label: "status", value: statusLabel(snapshot.ai.status) }),
|
|
326
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, InfoRow, { label: "route", value: snapshot.ai.routePath }),
|
|
327
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, InfoRow, { label: "model", value: snapshot.ai.defaultModel }),
|
|
328
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, InfoRow, { label: "credits", value: snapshot.ai.creditBalance })
|
|
329
|
+
] }),
|
|
330
|
+
snapshot.ai.models && snapshot.ai.models.length > 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "mt-1 flex flex-wrap gap-1", children: snapshot.ai.models.map((model) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
331
|
+
"span",
|
|
332
|
+
{
|
|
333
|
+
className: "rounded bg-white/[0.055] px-1.5 py-0.5 text-[9px] text-white/60",
|
|
334
|
+
children: model
|
|
335
|
+
},
|
|
336
|
+
model
|
|
337
|
+
)) }) : null
|
|
338
|
+
] }) : null,
|
|
339
|
+
snapshot.notes && snapshot.notes.length > 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CollapsibleGroup, { title: "Notes", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex flex-col gap-1 text-[10px] text-white/50", children: snapshot.notes.map((note, index) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
340
|
+
"div",
|
|
341
|
+
{
|
|
342
|
+
className: "rounded bg-white/[0.035] px-2 py-1",
|
|
343
|
+
children: note
|
|
344
|
+
},
|
|
345
|
+
`${index}-${note}`
|
|
346
|
+
)) }) }) : null
|
|
347
|
+
] });
|
|
348
|
+
}
|
|
349
|
+
function useBrandappDevtoolBridge({
|
|
350
|
+
id,
|
|
351
|
+
label,
|
|
352
|
+
order = 10,
|
|
353
|
+
snapshot: controlledSnapshot
|
|
354
|
+
}) {
|
|
355
|
+
const isControlled = controlledSnapshot !== void 0;
|
|
356
|
+
const [uncontrolledSnapshot, setUncontrolledSnapshot] = React.useState(controlledSnapshot != null ? controlledSnapshot : null);
|
|
357
|
+
const snapshot = isControlled ? controlledSnapshot : uncontrolledSnapshot;
|
|
358
|
+
const inspect = React.useCallback(
|
|
359
|
+
(nextSnapshot) => {
|
|
360
|
+
if (!isControlled) {
|
|
361
|
+
setUncontrolledSnapshot(nextSnapshot);
|
|
362
|
+
}
|
|
363
|
+
},
|
|
364
|
+
[isControlled]
|
|
365
|
+
);
|
|
366
|
+
const clear = React.useCallback(() => {
|
|
367
|
+
if (!isControlled) {
|
|
368
|
+
setUncontrolledSnapshot(null);
|
|
369
|
+
}
|
|
370
|
+
}, [isControlled]);
|
|
371
|
+
const plugin = React.useMemo(
|
|
372
|
+
() => ({
|
|
373
|
+
id,
|
|
374
|
+
label,
|
|
375
|
+
order,
|
|
376
|
+
tab: "brandapp",
|
|
377
|
+
renderPanel: () => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BrandappDevtoolPanel, { snapshot })
|
|
378
|
+
}),
|
|
379
|
+
[id, label, order, snapshot]
|
|
380
|
+
);
|
|
381
|
+
_chunk6AGUYGVTcjs.useOptDevtoolPlugin.call(void 0, plugin);
|
|
382
|
+
return {
|
|
383
|
+
inspect,
|
|
384
|
+
clear
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
exports.getBrandappRequiredEnvSummary = getBrandappRequiredEnvSummary; exports.getBrandappSnapshotStatus = getBrandappSnapshotStatus; exports.useBrandappDevtoolBridge = useBrandappDevtoolBridge;
|