@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.
Files changed (46) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/LICENSE +21 -0
  3. package/README.md +149 -0
  4. package/dist/brandapp/index.cjs +391 -0
  5. package/dist/brandapp/index.d.cts +95 -0
  6. package/dist/brandapp/index.d.ts +95 -0
  7. package/dist/brandapp/index.js +391 -0
  8. package/dist/chunk-4MJKIAXH.cjs +65 -0
  9. package/dist/chunk-5HRIQSVF.js +32 -0
  10. package/dist/chunk-6AGUYGVT.cjs +77 -0
  11. package/dist/chunk-EQPETYJJ.cjs +32 -0
  12. package/dist/chunk-H3F2WACS.cjs +568 -0
  13. package/dist/chunk-N7YO56TN.cjs +25 -0
  14. package/dist/chunk-SQ3E3QLA.cjs +253 -0
  15. package/dist/chunk-SW2FF6EV.js +568 -0
  16. package/dist/chunk-UJSIQF3A.js +25 -0
  17. package/dist/chunk-UQY5I3WS.js +253 -0
  18. package/dist/chunk-YCYIUFB4.js +65 -0
  19. package/dist/chunk-Z2KFRHSI.js +77 -0
  20. package/dist/datagrid/index.cjs +187 -0
  21. package/dist/datagrid/index.d.cts +14 -0
  22. package/dist/datagrid/index.d.ts +14 -0
  23. package/dist/datagrid/index.js +187 -0
  24. package/dist/editor/index.cjs +239 -0
  25. package/dist/editor/index.d.cts +14 -0
  26. package/dist/editor/index.d.ts +14 -0
  27. package/dist/editor/index.js +239 -0
  28. package/dist/harness/index.cjs +13 -0
  29. package/dist/harness/index.d.cts +30 -0
  30. package/dist/harness/index.d.ts +30 -0
  31. package/dist/harness/index.js +13 -0
  32. package/dist/index-Bakx4o8Z.d.cts +91 -0
  33. package/dist/index-Bakx4o8Z.d.ts +91 -0
  34. package/dist/index.cjs +3895 -0
  35. package/dist/index.d.cts +22 -0
  36. package/dist/index.d.ts +22 -0
  37. package/dist/index.js +3895 -0
  38. package/dist/theme/index.cjs +13 -0
  39. package/dist/theme/index.d.cts +33 -0
  40. package/dist/theme/index.d.ts +33 -0
  41. package/dist/theme/index.js +13 -0
  42. package/dist/ui/index.cjs +8 -0
  43. package/dist/ui/index.d.cts +2 -0
  44. package/dist/ui/index.d.ts +2 -0
  45. package/dist/ui/index.js +8 -0
  46. package/package.json +153 -0
@@ -0,0 +1,253 @@
1
+ "use client";
2
+ import {
3
+ ISOLATE_STYLE
4
+ } from "./chunk-5HRIQSVF.js";
5
+ import {
6
+ useOptDevtoolPlugin
7
+ } from "./chunk-Z2KFRHSI.js";
8
+
9
+ // src/theme/index.tsx
10
+ import * as React from "react";
11
+ import { contrastRatio, wcagLevel, hexToSrgb } from "@reopt-ai/opt-palette";
12
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
13
+ var AUDIT_PAIRS = [
14
+ ["--opt-text", "--opt-surface"],
15
+ ["--opt-accent-fg", "--opt-accent"],
16
+ ["--opt-text-secondary", "--opt-surface"]
17
+ ];
18
+ function computeContrastPairs(tokens) {
19
+ const results = [];
20
+ for (const [fgName, bgName] of AUDIT_PAIRS) {
21
+ const fgVal = tokens[fgName];
22
+ const bgVal = tokens[bgName];
23
+ if (!fgVal || !bgVal) continue;
24
+ try {
25
+ const fgRgb = hexToSrgb(fgVal);
26
+ const bgRgb = hexToSrgb(bgVal);
27
+ const ratio = contrastRatio(fgRgb, bgRgb);
28
+ results.push({
29
+ fg: fgName,
30
+ bg: bgName,
31
+ ratio,
32
+ level: wcagLevel(ratio)
33
+ });
34
+ } catch (e) {
35
+ }
36
+ }
37
+ return results;
38
+ }
39
+ function themeConfigToSnapshot(theme) {
40
+ if (theme.mode === "generated") {
41
+ return {
42
+ mode: theme.mode,
43
+ preset: theme.preset,
44
+ seed: theme.palette.seed,
45
+ harmony: theme.palette.harmony,
46
+ radiusScale: theme.palette.radiusScale,
47
+ shadowIntensity: theme.palette.shadowIntensity,
48
+ neutralTemperature: theme.palette.neutralTemperature,
49
+ forceLightOnly: theme.forceLightOnly,
50
+ lightTokens: theme.generatedLightTokens,
51
+ darkTokens: theme.generatedDarkTokens,
52
+ contrastPairs: computeContrastPairs(theme.generatedLightTokens)
53
+ };
54
+ }
55
+ return {
56
+ mode: theme.mode,
57
+ preset: theme.preset,
58
+ seed: void 0,
59
+ harmony: void 0,
60
+ radiusScale: void 0,
61
+ shadowIntensity: void 0,
62
+ neutralTemperature: void 0,
63
+ forceLightOnly: theme.forceLightOnly,
64
+ lightTokens: void 0,
65
+ darkTokens: void 0,
66
+ contrastPairs: void 0
67
+ };
68
+ }
69
+ var SWATCH_TOKENS = [
70
+ { token: "--opt-accent", label: "Accent" },
71
+ { token: "--opt-surface", label: "Surface" },
72
+ { token: "--opt-text", label: "Text" },
73
+ { token: "--opt-bg", label: "BG" },
74
+ { token: "--opt-border", label: "Border" },
75
+ { token: "--opt-success", label: "OK" },
76
+ { token: "--opt-warning", label: "Warn" },
77
+ { token: "--opt-danger", label: "Err" },
78
+ { token: "--opt-chart-1", label: "C1" },
79
+ { token: "--opt-chart-2", label: "C2" }
80
+ ];
81
+ var CONTRAST_CHECK_PAIRS = [
82
+ { fg: "--opt-text", bg: "--opt-surface", label: "text/surface" },
83
+ { fg: "--opt-accent-fg", bg: "--opt-accent", label: "accentFg/accent" },
84
+ {
85
+ fg: "--opt-text-secondary",
86
+ bg: "--opt-surface",
87
+ label: "text2nd/surface"
88
+ }
89
+ ];
90
+ function ThemeDevtoolPanel({
91
+ snapshot
92
+ }) {
93
+ if (!snapshot) {
94
+ return /* @__PURE__ */ jsx("div", { className: "text-[11px] text-white/55", children: "Waiting for Theme snapshot." });
95
+ }
96
+ const isGenerated = snapshot.mode === "generated";
97
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 text-[11px]", style: ISOLATE_STYLE, children: [
98
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
99
+ /* @__PURE__ */ jsx(
100
+ "span",
101
+ {
102
+ className: `inline-block h-1.5 w-1.5 rounded-full ${isGenerated ? "bg-violet-400" : "bg-white/30"}`
103
+ }
104
+ ),
105
+ /* @__PURE__ */ jsx("span", { className: isGenerated ? "text-violet-300" : "text-white/60", children: isGenerated ? "Generated" : `Preset: ${snapshot.preset}` }),
106
+ snapshot.forceLightOnly && /* @__PURE__ */ jsx("span", { className: "text-[9px] text-amber-400", children: "light-only" })
107
+ ] }),
108
+ isGenerated && snapshot.seed && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
109
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
110
+ /* @__PURE__ */ jsx(
111
+ "div",
112
+ {
113
+ className: "h-5 w-5 rounded border border-white/20",
114
+ style: { backgroundColor: snapshot.seed }
115
+ }
116
+ ),
117
+ /* @__PURE__ */ jsx("span", { className: "font-mono text-[10px] text-white/70", children: snapshot.seed })
118
+ ] }),
119
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-3 gap-y-0.5 text-[10px] text-white/50", children: [
120
+ snapshot.harmony && /* @__PURE__ */ jsxs("div", { children: [
121
+ /* @__PURE__ */ jsx("span", { className: "text-white/30", children: "Harmony" }),
122
+ " ",
123
+ snapshot.harmony
124
+ ] }),
125
+ snapshot.radiusScale && /* @__PURE__ */ jsxs("div", { children: [
126
+ /* @__PURE__ */ jsx("span", { className: "text-white/30", children: "Radius" }),
127
+ " ",
128
+ snapshot.radiusScale
129
+ ] }),
130
+ snapshot.shadowIntensity && /* @__PURE__ */ jsxs("div", { children: [
131
+ /* @__PURE__ */ jsx("span", { className: "text-white/30", children: "Shadow" }),
132
+ " ",
133
+ snapshot.shadowIntensity
134
+ ] }),
135
+ snapshot.neutralTemperature && /* @__PURE__ */ jsxs("div", { children: [
136
+ /* @__PURE__ */ jsx("span", { className: "text-white/30", children: "Temp" }),
137
+ " ",
138
+ snapshot.neutralTemperature
139
+ ] })
140
+ ] })
141
+ ] }),
142
+ isGenerated && snapshot.lightTokens && /* @__PURE__ */ jsxs("div", { children: [
143
+ /* @__PURE__ */ jsx("div", { className: "mb-1 text-[10px] font-semibold text-violet-400", children: "Light" }),
144
+ /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1", children: SWATCH_TOKENS.map(({ token, label }) => {
145
+ var _a, _b;
146
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-0.5", children: [
147
+ /* @__PURE__ */ jsx(
148
+ "div",
149
+ {
150
+ className: "h-4 w-4 rounded-sm border border-white/15",
151
+ style: {
152
+ backgroundColor: (_b = (_a = snapshot.lightTokens) == null ? void 0 : _a[token]) != null ? _b : "#888"
153
+ }
154
+ }
155
+ ),
156
+ /* @__PURE__ */ jsx("span", { className: "text-[7px] text-white/30", children: label })
157
+ ] }, token);
158
+ }) }),
159
+ snapshot.darkTokens && /* @__PURE__ */ jsxs(Fragment, { children: [
160
+ /* @__PURE__ */ jsx("div", { className: "mt-2 mb-1 text-[10px] font-semibold text-violet-400", children: "Dark" }),
161
+ /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1", children: SWATCH_TOKENS.map(({ token, label }) => {
162
+ var _a, _b;
163
+ return /* @__PURE__ */ jsxs(
164
+ "div",
165
+ {
166
+ className: "flex flex-col items-center gap-0.5",
167
+ children: [
168
+ /* @__PURE__ */ jsx(
169
+ "div",
170
+ {
171
+ className: "h-4 w-4 rounded-sm border border-white/15",
172
+ style: {
173
+ backgroundColor: (_b = (_a = snapshot.darkTokens) == null ? void 0 : _a[token]) != null ? _b : "#333"
174
+ }
175
+ }
176
+ ),
177
+ /* @__PURE__ */ jsx("span", { className: "text-[7px] text-white/30", children: label })
178
+ ]
179
+ },
180
+ token
181
+ );
182
+ }) })
183
+ ] })
184
+ ] }),
185
+ isGenerated && snapshot.lightTokens && /* @__PURE__ */ jsxs("div", { children: [
186
+ /* @__PURE__ */ jsx("div", { className: "mb-1 text-[10px] font-semibold text-violet-400", children: "Contrast" }),
187
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-0.5 text-[10px]", children: CONTRAST_CHECK_PAIRS.map(({ fg, bg, label }) => {
188
+ var _a, _b, _c;
189
+ const fgVal = (_a = snapshot.lightTokens) == null ? void 0 : _a[fg];
190
+ const bgVal = (_b = snapshot.lightTokens) == null ? void 0 : _b[bg];
191
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
192
+ /* @__PURE__ */ jsxs("div", { className: "flex gap-0.5", children: [
193
+ /* @__PURE__ */ jsx(
194
+ "div",
195
+ {
196
+ className: "h-3 w-3 rounded-sm border border-white/10",
197
+ style: { backgroundColor: fgVal != null ? fgVal : "#888" }
198
+ }
199
+ ),
200
+ /* @__PURE__ */ jsx(
201
+ "div",
202
+ {
203
+ className: "h-3 w-3 rounded-sm border border-white/10",
204
+ style: { backgroundColor: bgVal != null ? bgVal : "#fff" }
205
+ }
206
+ )
207
+ ] }),
208
+ /* @__PURE__ */ jsx("span", { className: "text-white/50", children: label }),
209
+ (_c = snapshot.contrastPairs) == null ? void 0 : _c.filter((p) => p.fg === fg && p.bg === bg).map((p, i) => /* @__PURE__ */ jsxs(
210
+ "span",
211
+ {
212
+ className: p.level === "Fail" ? "text-red-400" : p.level === "AAA" ? "text-emerald-400" : "text-amber-300",
213
+ children: [
214
+ p.ratio.toFixed(1),
215
+ " ",
216
+ p.level
217
+ ]
218
+ },
219
+ i
220
+ ))
221
+ ] }, label);
222
+ }) })
223
+ ] })
224
+ ] });
225
+ }
226
+ function useThemeDevtoolBridge({
227
+ id = "theme",
228
+ label = "Theme",
229
+ order = 15
230
+ } = {}) {
231
+ const [snapshot, setSnapshot] = React.useState(
232
+ null
233
+ );
234
+ const inspect = React.useCallback((nextSnapshot) => {
235
+ setSnapshot(nextSnapshot);
236
+ }, []);
237
+ const plugin = React.useMemo(
238
+ () => ({
239
+ id,
240
+ label,
241
+ order,
242
+ renderPanel: () => /* @__PURE__ */ jsx(ThemeDevtoolPanel, { snapshot })
243
+ }),
244
+ [id, label, order, snapshot]
245
+ );
246
+ useOptDevtoolPlugin(plugin);
247
+ return { inspect };
248
+ }
249
+
250
+ export {
251
+ themeConfigToSnapshot,
252
+ useThemeDevtoolBridge
253
+ };
@@ -0,0 +1,65 @@
1
+ "use client";
2
+
3
+ // src/i18n/ko.ts
4
+ var koDevtoolLabels = {
5
+ panelTitle: "opt-devtool",
6
+ toggleHint: "Ctrl+Shift+F",
7
+ copyButtonTooltip: "\uB514\uBC84\uADF8 \uC815\uBCF4 \uBCF5\uC0AC",
8
+ closeButton: "\uB2EB\uAE30",
9
+ tabComponent: "\uCEF4\uD3EC\uB10C\uD2B8",
10
+ tabEditor: "opt-editor",
11
+ tabBrandapp: "Brandapp",
12
+ tabTheme: "\uD14C\uB9C8",
13
+ tabHarness: "\uD558\uB124\uC2A4",
14
+ emptyComponent: "\uC544\uBB34 \uC694\uC18C\uB97C \uD3EC\uCEE4\uC2A4\uD558\uBA74\n\uC815\uBCF4\uAC00 \uC5EC\uAE30\uC5D0 \uD45C\uC2DC\uB429\uB2C8\uB2E4.",
15
+ emptyEditor: "\uC774 \uD398\uC774\uC9C0\uC5D0 \uB4F1\uB85D\uB41C Editor snapshot\uC774 \uC5C6\uC2B5\uB2C8\uB2E4",
16
+ emptyBrandapp: "\uC774 \uD398\uC774\uC9C0\uC5D0 \uB4F1\uB85D\uB41C Brandapp SDK snapshot\uC774 \uC5C6\uC2B5\uB2C8\uB2E4",
17
+ emptyEnginePanel: "\uD328\uB110\uC744 \uC120\uD0DD\uD558\uC138\uC694",
18
+ inspectingPinned: "\uC778\uC2A4\uD399\uD2B8 \uB300\uC0C1 (\uACE0\uC815)",
19
+ inspecting: "\uC778\uC2A4\uD399\uD2B8 \uB300\uC0C1",
20
+ currentFocus: "\uD604\uC7AC \uD3EC\uCEE4\uC2A4",
21
+ componentTrace: "\uCEF4\uD3EC\uB10C\uD2B8 \uCD94\uC801",
22
+ componentTree: "\uCEF4\uD3EC\uB10C\uD2B8 \uD2B8\uB9AC",
23
+ noReactComponent: "React \uCEF4\uD3EC\uB10C\uD2B8\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC74C",
24
+ tabOrderInline: "Tab \uC21C\uC11C",
25
+ tabOrderOut: "Tab \uC21C\uC11C (\uC21C\uC11C \uBC16)",
26
+ tabOrderHint: "Tab\uC73C\uB85C \uB3C4\uB2EC\uD560 \uC218 \uC5C6\uC74C (roving tabindex \uB610\uB294 \uD504\uB85C\uADF8\uB798\uBC0D \uD3EC\uCEE4\uC2A4)",
27
+ shiftTabPrev: "Shift+Tab (\uC774\uC804)",
28
+ tabNext: "Tab (\uB2E4\uC74C)",
29
+ arrowKeysTitle: (type, index, total) => `\uBC29\uD5A5\uD0A4 (${type}) ${index}/${total}`,
30
+ loopBadge: "Loop",
31
+ wrapBadge: "Wrap",
32
+ noArrowTarget: "\uBC29\uD5A5\uD0A4 \uB300\uC0C1 \uC5C6\uC74C (\uB05D)",
33
+ spatialNav: "\uACF5\uAC04 \uB124\uBE44\uAC8C\uC774\uC158",
34
+ spatialProtected: "\uBCF4\uD638\uB428",
35
+ spatialNoCandidate: "\uD6C4\uBCF4 \uC5C6\uC74C",
36
+ spatialTrappedContext: (context) => `trapped context (${context})`,
37
+ history: "\uC774\uB3D9 \uAE30\uB85D",
38
+ eventLogTitle: "\uC774\uBCA4\uD2B8 \uB85C\uADF8",
39
+ eventLogClear: "\uC9C0\uC6B0\uAE30",
40
+ eventLogWaiting: "\uC774\uBCA4\uD2B8 \uB300\uAE30 \uC911\u2026",
41
+ overlaysSection: "\uC624\uBC84\uB808\uC774",
42
+ panelsSection: "\uC815\uBCF4 \uD328\uB110",
43
+ toggleGuide: "\uAC00\uC774\uB4DC \uB77C\uC778",
44
+ toggleTabOrder: "Tab \uC21C\uC11C",
45
+ toggleSpatialNav: "\uACF5\uAC04 \uD0D0\uC0C9",
46
+ toggleComponentLabels: "\uCEF4\uD3EC\uB10C\uD2B8 \uB77C\uBCA8",
47
+ toggleCompositeBounds: "Composite \uC601\uC5ED",
48
+ toggleComponentTrace: "\uCEF4\uD3EC\uB10C\uD2B8 \uCD94\uC801",
49
+ toggleComponentTree: "\uCEF4\uD3EC\uB10C\uD2B8 \uD2B8\uB9AC",
50
+ toggleEventLog: "\uC774\uBCA4\uD2B8 \uB85C\uADF8",
51
+ toggleInspect: "\uC778\uC2A4\uD399\uD2B8",
52
+ trapped: "trapped",
53
+ protected: "\uBCF4\uD638",
54
+ filterUser: "\uC0AC\uC6A9\uC790",
55
+ filterPrimitives: "Primitives",
56
+ filterAll: "\uC804\uCCB4"
57
+ };
58
+
59
+ // src/types.ts
60
+ var OPT_DEVTOOL_CONFIGURE_EVENT = "opt-devtool-configure";
61
+
62
+ export {
63
+ koDevtoolLabels,
64
+ OPT_DEVTOOL_CONFIGURE_EVENT
65
+ };
@@ -0,0 +1,77 @@
1
+ "use client";
2
+ import {
3
+ __spreadProps,
4
+ __spreadValues
5
+ } from "./chunk-UJSIQF3A.js";
6
+
7
+ // src/provider.tsx
8
+ import * as React from "react";
9
+ import { jsx } from "react/jsx-runtime";
10
+ var EMPTY_REGISTRY = {
11
+ plugins: [],
12
+ registerPlugin: () => () => void 0
13
+ };
14
+ var OptDevtoolRegistryContext = React.createContext(EMPTY_REGISTRY);
15
+ function sortPlugins(plugins) {
16
+ return [...plugins].sort((left, right) => {
17
+ var _a, _b;
18
+ const orderDelta = ((_a = left.order) != null ? _a : 0) - ((_b = right.order) != null ? _b : 0);
19
+ if (orderDelta !== 0) {
20
+ return orderDelta;
21
+ }
22
+ const labelDelta = left.label.localeCompare(right.label);
23
+ if (labelDelta !== 0) {
24
+ return labelDelta;
25
+ }
26
+ return left.id.localeCompare(right.id);
27
+ });
28
+ }
29
+ function OptDevtoolProvider({
30
+ children
31
+ }) {
32
+ const [plugins, setPlugins] = React.useState(
33
+ []
34
+ );
35
+ const registerPlugin = React.useCallback((registrationKey, plugin) => {
36
+ setPlugins(
37
+ (current) => sortPlugins([
38
+ ...current.filter((item) => item.registrationKey !== registrationKey),
39
+ __spreadProps(__spreadValues({}, plugin), {
40
+ registrationKey
41
+ })
42
+ ])
43
+ );
44
+ return () => {
45
+ setPlugins(
46
+ (current) => current.filter((item) => item.registrationKey !== registrationKey)
47
+ );
48
+ };
49
+ }, []);
50
+ const value = React.useMemo(
51
+ () => ({
52
+ plugins,
53
+ registerPlugin
54
+ }),
55
+ [plugins, registerPlugin]
56
+ );
57
+ return /* @__PURE__ */ jsx(OptDevtoolRegistryContext.Provider, { value, children });
58
+ }
59
+ function useOptDevtoolRegistry() {
60
+ return React.useContext(OptDevtoolRegistryContext);
61
+ }
62
+ function useOptDevtoolPlugin(plugin) {
63
+ const { registerPlugin } = useOptDevtoolRegistry();
64
+ const registrationKey = React.useId();
65
+ React.useEffect(() => {
66
+ if (!plugin) {
67
+ return void 0;
68
+ }
69
+ return registerPlugin(registrationKey, plugin);
70
+ }, [plugin, registerPlugin, registrationKey]);
71
+ }
72
+
73
+ export {
74
+ OptDevtoolProvider,
75
+ useOptDevtoolRegistry,
76
+ useOptDevtoolPlugin
77
+ };
@@ -0,0 +1,187 @@
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/datagrid/index.tsx
9
+ var _react = require('react'); var React = _interopRequireWildcard(_react);
10
+ var _jsxruntime = require('react/jsx-runtime');
11
+ function StatusDot({ active, label }) {
12
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "inline-flex items-center gap-1", children: [
13
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
14
+ "span",
15
+ {
16
+ className: `inline-block h-1.5 w-1.5 rounded-full ${active ? "bg-emerald-400" : "bg-white/20"}`
17
+ }
18
+ ),
19
+ label
20
+ ] });
21
+ }
22
+ function DataGridDevtoolPanel({
23
+ snapshot,
24
+ telemetry
25
+ }) {
26
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
27
+ if (!snapshot) {
28
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "text-[11px] text-white/55", children: "Waiting for DataGrid snapshot." });
29
+ }
30
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col gap-3 text-[11px]", children: [
31
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "section", { children: [
32
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "mb-1 text-[10px] font-semibold text-emerald-400", children: "Runtime" }),
33
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid gap-1.5 text-white/70 md:grid-cols-2", children: [
34
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-1", children: [
35
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
36
+ "span",
37
+ {
38
+ className: `inline-block h-1.5 w-1.5 rounded-full ${snapshot.activeCell ? "bg-emerald-400" : "bg-white/20"}`
39
+ }
40
+ ),
41
+ "Active cell: r",
42
+ snapshot.activeCell.row + 1,
43
+ " c",
44
+ snapshot.activeCell.col + 1
45
+ ] }),
46
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-1", children: [
47
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
48
+ "span",
49
+ {
50
+ className: `inline-block h-1.5 w-1.5 rounded-full ${snapshot.editingCell ? "animate-pulse bg-emerald-400" : "bg-white/20"}`
51
+ }
52
+ ),
53
+ "Editing:",
54
+ " ",
55
+ snapshot.editingCell ? `r${snapshot.editingCell.row + 1} c${snapshot.editingCell.col + 1}` : "Closed"
56
+ ] }),
57
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
58
+ "Rows: ",
59
+ snapshot.rowCount.toLocaleString()
60
+ ] }),
61
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
62
+ "Columns: ",
63
+ snapshot.columnCount.toLocaleString()
64
+ ] }),
65
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, StatusDot, { active: snapshot.overlayOpen, label: "Overlay" }) }),
66
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex gap-2", children: [
67
+ "History:",
68
+ " ",
69
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, StatusDot, { active: snapshot.history.canUndo, label: "undo" }),
70
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, StatusDot, { active: snapshot.history.canRedo, label: "redo" })
71
+ ] })
72
+ ] })
73
+ ] }),
74
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "section", { children: [
75
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "mb-1 text-[10px] font-semibold text-emerald-400", children: "Selection" }),
76
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "text-white/70", children: [
77
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
78
+ "Range: r",
79
+ snapshot.selection.start.row + 1,
80
+ " c",
81
+ snapshot.selection.start.col + 1,
82
+ " \u2192 r",
83
+ snapshot.selection.end.row + 1,
84
+ " c",
85
+ snapshot.selection.end.col + 1
86
+ ] }),
87
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "mt-1", children: [
88
+ "Row picks: ",
89
+ ((_a = snapshot.selection.rows) != null ? _a : []).length,
90
+ " / Column picks:",
91
+ " ",
92
+ ((_b = snapshot.selection.columns) != null ? _b : []).length
93
+ ] }),
94
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "mt-1", children: [
95
+ "Visible region: r",
96
+ (_d = (_c = snapshot.visibleRegion) == null ? void 0 : _c.startRow) != null ? _d : 0,
97
+ "-",
98
+ (_f = (_e = snapshot.visibleRegion) == null ? void 0 : _e.endRow) != null ? _f : 0,
99
+ ", c",
100
+ (_h = (_g = snapshot.visibleRegion) == null ? void 0 : _g.startCol) != null ? _h : 0,
101
+ "-",
102
+ (_j = (_i = snapshot.visibleRegion) == null ? void 0 : _i.endCol) != null ? _j : 0
103
+ ] }),
104
+ snapshot.draftError ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "mt-1 flex items-center gap-1 text-rose-300", children: [
105
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "inline-block h-1.5 w-1.5 rounded-full bg-red-400" }),
106
+ "Draft error: ",
107
+ snapshot.draftError
108
+ ] }) : null
109
+ ] })
110
+ ] }),
111
+ telemetry ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "section", { children: [
112
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "mb-1 text-[10px] font-semibold text-emerald-400", children: "Remote telemetry" }),
113
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid gap-1.5 text-white/70 md:grid-cols-2", children: [
114
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
115
+ "Open views: ",
116
+ telemetry.viewOpenCount
117
+ ] }),
118
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
119
+ "Loads: ",
120
+ telemetry.loadCount
121
+ ] }),
122
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
123
+ "Saves: ",
124
+ telemetry.saveCount
125
+ ] }),
126
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
127
+ "Push invalidations: ",
128
+ telemetry.pushInvalidationCount
129
+ ] }),
130
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
131
+ "Rejected edits: ",
132
+ telemetry.rejectedEditCount
133
+ ] }),
134
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
135
+ "Page retries: ",
136
+ telemetry.pageRetryCount
137
+ ] }),
138
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
139
+ "Last open: ",
140
+ (_k = telemetry.lastViewOpenDurationMs) != null ? _k : "-",
141
+ " ms"
142
+ ] }),
143
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
144
+ "Last load: ",
145
+ (_l = telemetry.lastLoadDurationMs) != null ? _l : "-",
146
+ " ms"
147
+ ] }),
148
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
149
+ "Last save: ",
150
+ (_m = telemetry.lastSaveDurationMs) != null ? _m : "-",
151
+ " ms"
152
+ ] }),
153
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
154
+ "Invalidated pages: ",
155
+ telemetry.invalidatedPageCount
156
+ ] })
157
+ ] })
158
+ ] }) : null
159
+ ] });
160
+ }
161
+ function useDataGridDevtoolBridge({
162
+ id,
163
+ label,
164
+ order = 20,
165
+ telemetry
166
+ }) {
167
+ const [snapshot, setSnapshot] = React.useState(null);
168
+ const inspect = React.useCallback((nextSnapshot) => {
169
+ setSnapshot(nextSnapshot);
170
+ }, []);
171
+ const plugin = React.useMemo(
172
+ () => ({
173
+ id,
174
+ label,
175
+ order,
176
+ renderPanel: () => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DataGridDevtoolPanel, { snapshot, telemetry })
177
+ }),
178
+ [id, label, order, snapshot, telemetry]
179
+ );
180
+ _chunk6AGUYGVTcjs.useOptDevtoolPlugin.call(void 0, plugin);
181
+ return {
182
+ inspect
183
+ };
184
+ }
185
+
186
+
187
+ exports.useDataGridDevtoolBridge = useDataGridDevtoolBridge;
@@ -0,0 +1,14 @@
1
+ import { DataGridDevtoolSnapshot, DataGridRemoteTelemetry } from '@reopt-ai/opt-datagrid';
2
+
3
+ interface UseDataGridDevtoolBridgeOptions {
4
+ id: string;
5
+ label: string;
6
+ order?: number;
7
+ telemetry?: DataGridRemoteTelemetry | null;
8
+ }
9
+ interface RegisteredDataGridDevtoolBridge {
10
+ inspect: (snapshot: DataGridDevtoolSnapshot) => void;
11
+ }
12
+ declare function useDataGridDevtoolBridge({ id, label, order, telemetry, }: UseDataGridDevtoolBridgeOptions): RegisteredDataGridDevtoolBridge;
13
+
14
+ export { type RegisteredDataGridDevtoolBridge, type UseDataGridDevtoolBridgeOptions, useDataGridDevtoolBridge };
@@ -0,0 +1,14 @@
1
+ import { DataGridDevtoolSnapshot, DataGridRemoteTelemetry } from '@reopt-ai/opt-datagrid';
2
+
3
+ interface UseDataGridDevtoolBridgeOptions {
4
+ id: string;
5
+ label: string;
6
+ order?: number;
7
+ telemetry?: DataGridRemoteTelemetry | null;
8
+ }
9
+ interface RegisteredDataGridDevtoolBridge {
10
+ inspect: (snapshot: DataGridDevtoolSnapshot) => void;
11
+ }
12
+ declare function useDataGridDevtoolBridge({ id, label, order, telemetry, }: UseDataGridDevtoolBridgeOptions): RegisteredDataGridDevtoolBridge;
13
+
14
+ export { type RegisteredDataGridDevtoolBridge, type UseDataGridDevtoolBridgeOptions, useDataGridDevtoolBridge };