@reopt-ai/opt-devtool 1.0.0 → 1.0.2

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 (55) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +11 -2
  3. package/dist/brandapp/index.cjs +457 -363
  4. package/dist/brandapp/index.d.cts +80 -81
  5. package/dist/brandapp/index.d.ts +80 -81
  6. package/dist/brandapp/index.js +451 -361
  7. package/dist/datagrid/index.cjs +170 -180
  8. package/dist/datagrid/index.d.cts +9 -11
  9. package/dist/datagrid/index.d.ts +9 -11
  10. package/dist/datagrid/index.js +167 -179
  11. package/dist/editor/index.cjs +209 -228
  12. package/dist/editor/index.d.cts +9 -11
  13. package/dist/editor/index.d.ts +9 -11
  14. package/dist/editor/index.js +206 -227
  15. package/dist/harness/index.cjs +5 -12
  16. package/dist/harness/index.d.cts +14 -16
  17. package/dist/harness/index.d.ts +14 -16
  18. package/dist/harness/index.js +1 -11
  19. package/dist/harness-CJZXBH3w.js +528 -0
  20. package/dist/harness-CPOp9Wlj.cjs +582 -0
  21. package/dist/index.cjs +3619 -3782
  22. package/dist/index.d.cts +9 -17
  23. package/dist/index.d.ts +9 -17
  24. package/dist/index.js +3611 -3781
  25. package/dist/provider-Cjg2rSYG.js +110 -0
  26. package/dist/provider-H53ZWHCo.cjs +161 -0
  27. package/dist/theme/index.cjs +298 -12
  28. package/dist/theme/index.d.cts +26 -28
  29. package/dist/theme/index.d.ts +26 -28
  30. package/dist/theme/index.js +294 -11
  31. package/dist/theme-isolate-BOo3J259.js +42 -0
  32. package/dist/theme-isolate-D9AMkYrD.cjs +53 -0
  33. package/dist/types-BKmW0EBr.js +4 -0
  34. package/dist/types-Bz4DijhU.cjs +9 -0
  35. package/dist/types-D_lNT2Nr.d.cts +91 -0
  36. package/dist/types-D_lNT2Nr.d.ts +91 -0
  37. package/dist/ui/index.cjs +4 -8
  38. package/dist/ui/index.d.cts +3 -2
  39. package/dist/ui/index.d.ts +3 -2
  40. package/dist/ui/index.js +1 -7
  41. package/package.json +4 -4
  42. package/dist/chunk-4MJKIAXH.cjs +0 -65
  43. package/dist/chunk-5HRIQSVF.js +0 -32
  44. package/dist/chunk-6AGUYGVT.cjs +0 -77
  45. package/dist/chunk-EQPETYJJ.cjs +0 -32
  46. package/dist/chunk-H3F2WACS.cjs +0 -568
  47. package/dist/chunk-N7YO56TN.cjs +0 -25
  48. package/dist/chunk-SQ3E3QLA.cjs +0 -253
  49. package/dist/chunk-SW2FF6EV.js +0 -568
  50. package/dist/chunk-UJSIQF3A.js +0 -25
  51. package/dist/chunk-UQY5I3WS.js +0 -253
  52. package/dist/chunk-YCYIUFB4.js +0 -65
  53. package/dist/chunk-Z2KFRHSI.js +0 -77
  54. package/dist/index-Bakx4o8Z.d.cts +0 -91
  55. package/dist/index-Bakx4o8Z.d.ts +0 -91
@@ -0,0 +1,110 @@
1
+ "use client";
2
+ import * as React from "react";
3
+ import { jsx } from "react/jsx-runtime";
4
+ // \0@oxc-project+runtime@0.156.0/helpers/esm/typeof.js
5
+ function _typeof(o) {
6
+ "@babel/helpers - typeof";
7
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
8
+ return typeof o;
9
+ } : function(o) {
10
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
11
+ }, _typeof(o);
12
+ }
13
+ // \0@oxc-project+runtime@0.156.0/helpers/esm/toPrimitive.js
14
+ function toPrimitive(t, r) {
15
+ if ("object" != _typeof(t) || !t) return t;
16
+ var e = t[Symbol.toPrimitive];
17
+ if (void 0 !== e) {
18
+ var i = e.call(t, r || "default");
19
+ if ("object" != _typeof(i)) return i;
20
+ throw new TypeError("@@toPrimitive must return a primitive value.");
21
+ }
22
+ return ("string" === r ? String : Number)(t);
23
+ }
24
+ // \0@oxc-project+runtime@0.156.0/helpers/esm/toPropertyKey.js
25
+ function toPropertyKey(t) {
26
+ var i = toPrimitive(t, "string");
27
+ return "symbol" == _typeof(i) ? i : i + "";
28
+ }
29
+ // \0@oxc-project+runtime@0.156.0/helpers/esm/defineProperty.js
30
+ function _defineProperty(e, r, t) {
31
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
32
+ value: t,
33
+ enumerable: !0,
34
+ configurable: !0,
35
+ writable: !0
36
+ }) : e[r] = t, e;
37
+ }
38
+ // \0@oxc-project+runtime@0.156.0/helpers/esm/objectSpread2.js
39
+ function ownKeys(e, r) {
40
+ var t = Object.keys(e);
41
+ if (Object.getOwnPropertySymbols) {
42
+ var o = Object.getOwnPropertySymbols(e);
43
+ r && (o = o.filter(function(r) {
44
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
45
+ })), t.push.apply(t, o);
46
+ }
47
+ return t;
48
+ }
49
+ function _objectSpread2(e) {
50
+ for (var r = 1; r < arguments.length; r++) {
51
+ var t = null != arguments[r] ? arguments[r] : {};
52
+ r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
53
+ _defineProperty(e, r, t[r]);
54
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
55
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
56
+ });
57
+ }
58
+ return e;
59
+ }
60
+ // src/provider.tsx
61
+ const OptDevtoolRegistryContext = React.createContext({
62
+ plugins: [],
63
+ registerPlugin: () => () => void 0
64
+ });
65
+ function sortPlugins(plugins) {
66
+ return [...plugins].sort((left, right) => {
67
+ var _left$order, _right$order;
68
+ const orderDelta = ((_left$order = left.order) !== null && _left$order !== void 0 ? _left$order : 0) - ((_right$order = right.order) !== null && _right$order !== void 0 ? _right$order : 0);
69
+ if (orderDelta !== 0) return orderDelta;
70
+ const labelDelta = left.label.localeCompare(right.label);
71
+ if (labelDelta !== 0) return labelDelta;
72
+ return left.id.localeCompare(right.id);
73
+ });
74
+ }
75
+ /** OptDevtoolProvider — see usage in callers. */
76
+ function OptDevtoolProvider({ children }) {
77
+ const [plugins, setPlugins] = React.useState([]);
78
+ const registerPlugin = React.useCallback((registrationKey, plugin) => {
79
+ setPlugins((current) => sortPlugins([...current.filter((item) => item.registrationKey !== registrationKey), _objectSpread2(_objectSpread2({}, plugin), {}, { registrationKey })]));
80
+ return () => {
81
+ setPlugins((current) => current.filter((item) => item.registrationKey !== registrationKey));
82
+ };
83
+ }, []);
84
+ const value = React.useMemo(() => ({
85
+ plugins,
86
+ registerPlugin
87
+ }), [plugins, registerPlugin]);
88
+ return /* @__PURE__ */ jsx(OptDevtoolRegistryContext.Provider, {
89
+ value,
90
+ children
91
+ });
92
+ }
93
+ /** useOptDevtoolRegistry — see usage in callers. */
94
+ function useOptDevtoolRegistry() {
95
+ return React.useContext(OptDevtoolRegistryContext);
96
+ }
97
+ /** useOptDevtoolPlugin — see usage in callers. */
98
+ function useOptDevtoolPlugin(plugin) {
99
+ const { registerPlugin } = useOptDevtoolRegistry();
100
+ const registrationKey = React.useId();
101
+ React.useEffect(() => {
102
+ if (!plugin) return;
103
+ return registerPlugin(registrationKey, plugin);
104
+ }, [
105
+ plugin,
106
+ registerPlugin,
107
+ registrationKey
108
+ ]);
109
+ }
110
+ export { _objectSpread2 as i, useOptDevtoolPlugin as n, useOptDevtoolRegistry as r, OptDevtoolProvider as t };
@@ -0,0 +1,161 @@
1
+ "use client";
2
+ // \0rolldown/runtime.js
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
+ get: ((k) => from[k]).bind(null, key),
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
20
+ value: mod,
21
+ enumerable: true
22
+ }) : target, mod));
23
+ let react = require("react");
24
+ react = __toESM(react, 1);
25
+ let react_jsx_runtime = require("react/jsx-runtime");
26
+ // \0@oxc-project+runtime@0.156.0/helpers/esm/typeof.js
27
+ function _typeof(o) {
28
+ "@babel/helpers - typeof";
29
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
30
+ return typeof o;
31
+ } : function(o) {
32
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
33
+ }, _typeof(o);
34
+ }
35
+ // \0@oxc-project+runtime@0.156.0/helpers/esm/toPrimitive.js
36
+ function toPrimitive(t, r) {
37
+ if ("object" != _typeof(t) || !t) return t;
38
+ var e = t[Symbol.toPrimitive];
39
+ if (void 0 !== e) {
40
+ var i = e.call(t, r || "default");
41
+ if ("object" != _typeof(i)) return i;
42
+ throw new TypeError("@@toPrimitive must return a primitive value.");
43
+ }
44
+ return ("string" === r ? String : Number)(t);
45
+ }
46
+ // \0@oxc-project+runtime@0.156.0/helpers/esm/toPropertyKey.js
47
+ function toPropertyKey(t) {
48
+ var i = toPrimitive(t, "string");
49
+ return "symbol" == _typeof(i) ? i : i + "";
50
+ }
51
+ // \0@oxc-project+runtime@0.156.0/helpers/esm/defineProperty.js
52
+ function _defineProperty(e, r, t) {
53
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
54
+ value: t,
55
+ enumerable: !0,
56
+ configurable: !0,
57
+ writable: !0
58
+ }) : e[r] = t, e;
59
+ }
60
+ // \0@oxc-project+runtime@0.156.0/helpers/esm/objectSpread2.js
61
+ function ownKeys(e, r) {
62
+ var t = Object.keys(e);
63
+ if (Object.getOwnPropertySymbols) {
64
+ var o = Object.getOwnPropertySymbols(e);
65
+ r && (o = o.filter(function(r) {
66
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
67
+ })), t.push.apply(t, o);
68
+ }
69
+ return t;
70
+ }
71
+ function _objectSpread2(e) {
72
+ for (var r = 1; r < arguments.length; r++) {
73
+ var t = null != arguments[r] ? arguments[r] : {};
74
+ r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
75
+ _defineProperty(e, r, t[r]);
76
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
77
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
78
+ });
79
+ }
80
+ return e;
81
+ }
82
+ // src/provider.tsx
83
+ const OptDevtoolRegistryContext = react.createContext({
84
+ plugins: [],
85
+ registerPlugin: () => () => void 0
86
+ });
87
+ function sortPlugins(plugins) {
88
+ return [...plugins].sort((left, right) => {
89
+ var _left$order, _right$order;
90
+ const orderDelta = ((_left$order = left.order) !== null && _left$order !== void 0 ? _left$order : 0) - ((_right$order = right.order) !== null && _right$order !== void 0 ? _right$order : 0);
91
+ if (orderDelta !== 0) return orderDelta;
92
+ const labelDelta = left.label.localeCompare(right.label);
93
+ if (labelDelta !== 0) return labelDelta;
94
+ return left.id.localeCompare(right.id);
95
+ });
96
+ }
97
+ /** OptDevtoolProvider — see usage in callers. */
98
+ function OptDevtoolProvider({ children }) {
99
+ const [plugins, setPlugins] = react.useState([]);
100
+ const registerPlugin = react.useCallback((registrationKey, plugin) => {
101
+ setPlugins((current) => sortPlugins([...current.filter((item) => item.registrationKey !== registrationKey), _objectSpread2(_objectSpread2({}, plugin), {}, { registrationKey })]));
102
+ return () => {
103
+ setPlugins((current) => current.filter((item) => item.registrationKey !== registrationKey));
104
+ };
105
+ }, []);
106
+ const value = react.useMemo(() => ({
107
+ plugins,
108
+ registerPlugin
109
+ }), [plugins, registerPlugin]);
110
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OptDevtoolRegistryContext.Provider, {
111
+ value,
112
+ children
113
+ });
114
+ }
115
+ /** useOptDevtoolRegistry — see usage in callers. */
116
+ function useOptDevtoolRegistry() {
117
+ return react.useContext(OptDevtoolRegistryContext);
118
+ }
119
+ /** useOptDevtoolPlugin — see usage in callers. */
120
+ function useOptDevtoolPlugin(plugin) {
121
+ const { registerPlugin } = useOptDevtoolRegistry();
122
+ const registrationKey = react.useId();
123
+ react.useEffect(() => {
124
+ if (!plugin) return;
125
+ return registerPlugin(registrationKey, plugin);
126
+ }, [
127
+ plugin,
128
+ registerPlugin,
129
+ registrationKey
130
+ ]);
131
+ }
132
+ Object.defineProperty(exports, "OptDevtoolProvider", {
133
+ enumerable: true,
134
+ get: function() {
135
+ return OptDevtoolProvider;
136
+ }
137
+ });
138
+ Object.defineProperty(exports, "__toESM", {
139
+ enumerable: true,
140
+ get: function() {
141
+ return __toESM;
142
+ }
143
+ });
144
+ Object.defineProperty(exports, "_objectSpread2", {
145
+ enumerable: true,
146
+ get: function() {
147
+ return _objectSpread2;
148
+ }
149
+ });
150
+ Object.defineProperty(exports, "useOptDevtoolPlugin", {
151
+ enumerable: true,
152
+ get: function() {
153
+ return useOptDevtoolPlugin;
154
+ }
155
+ });
156
+ Object.defineProperty(exports, "useOptDevtoolRegistry", {
157
+ enumerable: true,
158
+ get: function() {
159
+ return useOptDevtoolRegistry;
160
+ }
161
+ });
@@ -1,13 +1,299 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
1
  "use client";
3
-
4
-
5
-
6
- var _chunkSQ3E3QLAcjs = require('../chunk-SQ3E3QLA.cjs');
7
- require('../chunk-EQPETYJJ.cjs');
8
- require('../chunk-6AGUYGVT.cjs');
9
- require('../chunk-N7YO56TN.cjs');
10
-
11
-
12
-
13
- exports.themeConfigToSnapshot = _chunkSQ3E3QLAcjs.themeConfigToSnapshot; exports.useThemeDevtoolBridge = _chunkSQ3E3QLAcjs.useThemeDevtoolBridge;
2
+ "use client";
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
+ const require_provider = require("../provider-H53ZWHCo.cjs");
5
+ const require_theme_isolate = require("../theme-isolate-D9AMkYrD.cjs");
6
+ let react = require("react");
7
+ react = require_provider.__toESM(react, 1);
8
+ let react_jsx_runtime = require("react/jsx-runtime");
9
+ let _reopt_ai_opt_palette = require("@reopt-ai/opt-palette");
10
+ // src/theme/index.tsx
11
+ const AUDIT_PAIRS = [
12
+ ["--opt-text", "--opt-surface"],
13
+ ["--opt-accent-fg", "--opt-accent"],
14
+ ["--opt-text-secondary", "--opt-surface"]
15
+ ];
16
+ function computeContrastPairs(tokens) {
17
+ const results = [];
18
+ for (const [fgName, bgName] of AUDIT_PAIRS) {
19
+ const fgVal = tokens[fgName];
20
+ const bgVal = tokens[bgName];
21
+ if (!fgVal || !bgVal) continue;
22
+ try {
23
+ const fgRgb = (0, _reopt_ai_opt_palette.hexToSrgb)(fgVal);
24
+ const bgRgb = (0, _reopt_ai_opt_palette.hexToSrgb)(bgVal);
25
+ const ratio = (0, _reopt_ai_opt_palette.contrastRatio)(fgRgb, bgRgb);
26
+ results.push({
27
+ fg: fgName,
28
+ bg: bgName,
29
+ ratio,
30
+ level: (0, _reopt_ai_opt_palette.wcagLevel)(ratio)
31
+ });
32
+ } catch (_unused) {}
33
+ }
34
+ return results;
35
+ }
36
+ /** Build a ThemeDevtoolSnapshot from a ResolvedShellThemeConfig */
37
+ function themeConfigToSnapshot(theme) {
38
+ if (theme.mode === "generated") return {
39
+ mode: theme.mode,
40
+ preset: theme.preset,
41
+ seed: theme.palette.seed,
42
+ harmony: theme.palette.harmony,
43
+ radiusScale: theme.palette.radiusScale,
44
+ shadowIntensity: theme.palette.shadowIntensity,
45
+ neutralTemperature: theme.palette.neutralTemperature,
46
+ forceLightOnly: theme.forceLightOnly,
47
+ lightTokens: theme.generatedLightTokens,
48
+ darkTokens: theme.generatedDarkTokens,
49
+ contrastPairs: computeContrastPairs(theme.generatedLightTokens)
50
+ };
51
+ return {
52
+ mode: theme.mode,
53
+ preset: theme.preset,
54
+ seed: void 0,
55
+ harmony: void 0,
56
+ radiusScale: void 0,
57
+ shadowIntensity: void 0,
58
+ neutralTemperature: void 0,
59
+ forceLightOnly: theme.forceLightOnly,
60
+ lightTokens: void 0,
61
+ darkTokens: void 0,
62
+ contrastPairs: void 0
63
+ };
64
+ }
65
+ const SWATCH_TOKENS = [
66
+ {
67
+ token: "--opt-accent",
68
+ label: "Accent"
69
+ },
70
+ {
71
+ token: "--opt-surface",
72
+ label: "Surface"
73
+ },
74
+ {
75
+ token: "--opt-text",
76
+ label: "Text"
77
+ },
78
+ {
79
+ token: "--opt-bg",
80
+ label: "BG"
81
+ },
82
+ {
83
+ token: "--opt-border",
84
+ label: "Border"
85
+ },
86
+ {
87
+ token: "--opt-success",
88
+ label: "OK"
89
+ },
90
+ {
91
+ token: "--opt-warning",
92
+ label: "Warn"
93
+ },
94
+ {
95
+ token: "--opt-danger",
96
+ label: "Err"
97
+ },
98
+ {
99
+ token: "--opt-chart-1",
100
+ label: "C1"
101
+ },
102
+ {
103
+ token: "--opt-chart-2",
104
+ label: "C2"
105
+ }
106
+ ];
107
+ const CONTRAST_CHECK_PAIRS = [
108
+ {
109
+ fg: "--opt-text",
110
+ bg: "--opt-surface",
111
+ label: "text/surface"
112
+ },
113
+ {
114
+ fg: "--opt-accent-fg",
115
+ bg: "--opt-accent",
116
+ label: "accentFg/accent"
117
+ },
118
+ {
119
+ fg: "--opt-text-secondary",
120
+ bg: "--opt-surface",
121
+ label: "text2nd/surface"
122
+ }
123
+ ];
124
+ function ThemeDevtoolPanel({ snapshot }) {
125
+ if (!snapshot) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
126
+ className: "text-[11px] text-white/55",
127
+ children: "Waiting for Theme snapshot."
128
+ });
129
+ const isGenerated = snapshot.mode === "generated";
130
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
131
+ className: "flex flex-col gap-3 text-[11px]",
132
+ style: require_theme_isolate.ISOLATE_STYLE,
133
+ children: [
134
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
135
+ className: "flex items-center gap-2",
136
+ children: [
137
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: `inline-block h-1.5 w-1.5 rounded-full ${isGenerated ? "bg-violet-400" : "bg-white/30"}` }),
138
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
139
+ className: isGenerated ? "text-violet-300" : "text-white/60",
140
+ children: isGenerated ? "Generated" : `Preset: ${snapshot.preset}`
141
+ }),
142
+ snapshot.forceLightOnly && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
143
+ className: "text-[9px] text-amber-400",
144
+ children: "light-only"
145
+ })
146
+ ]
147
+ }),
148
+ isGenerated && snapshot.seed && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
149
+ className: "flex flex-col gap-1.5",
150
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
151
+ className: "flex items-center gap-2",
152
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
153
+ className: "h-5 w-5 rounded border border-white/20",
154
+ style: { backgroundColor: snapshot.seed }
155
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
156
+ className: "font-mono text-[10px] text-white/70",
157
+ children: snapshot.seed
158
+ })]
159
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
160
+ className: "grid grid-cols-2 gap-x-3 gap-y-0.5 text-[10px] text-white/50",
161
+ children: [
162
+ snapshot.harmony && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
163
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
164
+ className: "text-white/30",
165
+ children: "Harmony"
166
+ }),
167
+ " ",
168
+ snapshot.harmony
169
+ ] }),
170
+ snapshot.radiusScale && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
171
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
172
+ className: "text-white/30",
173
+ children: "Radius"
174
+ }),
175
+ " ",
176
+ snapshot.radiusScale
177
+ ] }),
178
+ snapshot.shadowIntensity && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
179
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
180
+ className: "text-white/30",
181
+ children: "Shadow"
182
+ }),
183
+ " ",
184
+ snapshot.shadowIntensity
185
+ ] }),
186
+ snapshot.neutralTemperature && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
187
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
188
+ className: "text-white/30",
189
+ children: "Temp"
190
+ }),
191
+ " ",
192
+ snapshot.neutralTemperature
193
+ ] })
194
+ ]
195
+ })]
196
+ }),
197
+ isGenerated && snapshot.lightTokens && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
198
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
199
+ className: "mb-1 text-[10px] font-semibold text-violet-400",
200
+ children: "Light"
201
+ }),
202
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
203
+ className: "flex flex-wrap gap-1",
204
+ children: SWATCH_TOKENS.map(({ token, label }) => {
205
+ var _snapshot$lightTokens, _snapshot$lightTokens2;
206
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
207
+ className: "flex flex-col items-center gap-0.5",
208
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
209
+ className: "h-4 w-4 rounded-sm border border-white/15",
210
+ style: { backgroundColor: (_snapshot$lightTokens = (_snapshot$lightTokens2 = snapshot.lightTokens) === null || _snapshot$lightTokens2 === void 0 ? void 0 : _snapshot$lightTokens2[token]) !== null && _snapshot$lightTokens !== void 0 ? _snapshot$lightTokens : "#888" }
211
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
212
+ className: "text-[7px] text-white/30",
213
+ children: label
214
+ })]
215
+ }, token);
216
+ })
217
+ }),
218
+ snapshot.darkTokens && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
219
+ className: "mt-2 mb-1 text-[10px] font-semibold text-violet-400",
220
+ children: "Dark"
221
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
222
+ className: "flex flex-wrap gap-1",
223
+ children: SWATCH_TOKENS.map(({ token, label }) => {
224
+ var _snapshot$darkTokens$, _snapshot$darkTokens;
225
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
226
+ className: "flex flex-col items-center gap-0.5",
227
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
228
+ className: "h-4 w-4 rounded-sm border border-white/15",
229
+ style: { backgroundColor: (_snapshot$darkTokens$ = (_snapshot$darkTokens = snapshot.darkTokens) === null || _snapshot$darkTokens === void 0 ? void 0 : _snapshot$darkTokens[token]) !== null && _snapshot$darkTokens$ !== void 0 ? _snapshot$darkTokens$ : "#333" }
230
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
231
+ className: "text-[7px] text-white/30",
232
+ children: label
233
+ })]
234
+ }, token);
235
+ })
236
+ })] })
237
+ ] }),
238
+ isGenerated && snapshot.lightTokens && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
239
+ className: "mb-1 text-[10px] font-semibold text-violet-400",
240
+ children: "Contrast"
241
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
242
+ className: "flex flex-col gap-0.5 text-[10px]",
243
+ children: CONTRAST_CHECK_PAIRS.map(({ fg, bg, label }) => {
244
+ var _snapshot$lightTokens3, _snapshot$lightTokens4, _snapshot$contrastPai;
245
+ const fgVal = (_snapshot$lightTokens3 = snapshot.lightTokens) === null || _snapshot$lightTokens3 === void 0 ? void 0 : _snapshot$lightTokens3[fg];
246
+ const bgVal = (_snapshot$lightTokens4 = snapshot.lightTokens) === null || _snapshot$lightTokens4 === void 0 ? void 0 : _snapshot$lightTokens4[bg];
247
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
248
+ className: "flex items-center gap-1.5",
249
+ children: [
250
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
251
+ className: "flex gap-0.5",
252
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
253
+ className: "h-3 w-3 rounded-sm border border-white/10",
254
+ style: { backgroundColor: fgVal !== null && fgVal !== void 0 ? fgVal : "#888" }
255
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
256
+ className: "h-3 w-3 rounded-sm border border-white/10",
257
+ style: { backgroundColor: bgVal !== null && bgVal !== void 0 ? bgVal : "#fff" }
258
+ })]
259
+ }),
260
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
261
+ className: "text-white/50",
262
+ children: label
263
+ }),
264
+ (_snapshot$contrastPai = snapshot.contrastPairs) === null || _snapshot$contrastPai === void 0 ? void 0 : _snapshot$contrastPai.filter((p) => p.fg === fg && p.bg === bg).map((p, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
265
+ className: p.level === "Fail" ? "text-red-400" : p.level === "AAA" ? "text-emerald-400" : "text-amber-300",
266
+ children: [
267
+ p.ratio.toFixed(1),
268
+ " ",
269
+ p.level
270
+ ]
271
+ }, i))
272
+ ]
273
+ }, label);
274
+ })
275
+ })] })
276
+ ]
277
+ });
278
+ }
279
+ function useThemeDevtoolBridge({ id = "theme", label = "Theme", order = 15 } = {}) {
280
+ const [snapshot, setSnapshot] = react.useState(null);
281
+ const inspect = react.useCallback((nextSnapshot) => {
282
+ setSnapshot(nextSnapshot);
283
+ }, []);
284
+ const plugin = react.useMemo(() => ({
285
+ id,
286
+ label,
287
+ order,
288
+ renderPanel: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ThemeDevtoolPanel, { snapshot })
289
+ }), [
290
+ id,
291
+ label,
292
+ order,
293
+ snapshot
294
+ ]);
295
+ require_provider.useOptDevtoolPlugin(plugin);
296
+ return { inspect };
297
+ }
298
+ exports.themeConfigToSnapshot = themeConfigToSnapshot;
299
+ exports.useThemeDevtoolBridge = useThemeDevtoolBridge;
@@ -1,33 +1,31 @@
1
- import { ResolvedShellThemeConfig } from '@reopt-ai/opt-shell';
2
1
 
3
- interface ThemeDevtoolSnapshot {
4
- mode: "preset" | "generated";
5
- preset: string;
6
- seed?: string;
7
- harmony?: string;
8
- radiusScale?: string;
9
- shadowIntensity?: string;
10
- neutralTemperature?: string;
11
- forceLightOnly: boolean;
12
- lightTokens?: Record<string, string>;
13
- darkTokens?: Record<string, string>;
14
- contrastPairs?: {
15
- fg: string;
16
- bg: string;
17
- ratio: number;
18
- level: "AAA" | "AA" | "Fail";
19
- }[];
2
+ import { ResolvedShellThemeConfig } from "@reopt-ai/opt-shell";
3
+ export interface ThemeDevtoolSnapshot {
4
+ mode: "preset" | "generated";
5
+ preset: string;
6
+ seed?: string;
7
+ harmony?: string;
8
+ radiusScale?: string;
9
+ shadowIntensity?: string;
10
+ neutralTemperature?: string;
11
+ forceLightOnly: boolean;
12
+ lightTokens?: Record<string, string>;
13
+ darkTokens?: Record<string, string>;
14
+ contrastPairs?: {
15
+ fg: string;
16
+ bg: string;
17
+ ratio: number;
18
+ level: "AAA" | "AA" | "Fail";
19
+ }[];
20
20
  }
21
- interface UseThemeDevtoolBridgeOptions {
22
- id?: string;
23
- label?: string;
24
- order?: number;
21
+ export interface UseThemeDevtoolBridgeOptions {
22
+ id?: string;
23
+ label?: string;
24
+ order?: number;
25
25
  }
26
- interface RegisteredThemeDevtoolBridge {
27
- inspect: (snapshot: ThemeDevtoolSnapshot) => void;
26
+ export interface RegisteredThemeDevtoolBridge {
27
+ inspect: (snapshot: ThemeDevtoolSnapshot) => void;
28
28
  }
29
29
  /** Build a ThemeDevtoolSnapshot from a ResolvedShellThemeConfig */
30
- declare function themeConfigToSnapshot(theme: ResolvedShellThemeConfig): ThemeDevtoolSnapshot;
31
- declare function useThemeDevtoolBridge({ id, label, order, }?: UseThemeDevtoolBridgeOptions): RegisteredThemeDevtoolBridge;
32
-
33
- export { type RegisteredThemeDevtoolBridge, type ThemeDevtoolSnapshot, type UseThemeDevtoolBridgeOptions, themeConfigToSnapshot, useThemeDevtoolBridge };
30
+ export declare function themeConfigToSnapshot(theme: ResolvedShellThemeConfig): ThemeDevtoolSnapshot;
31
+ export declare function useThemeDevtoolBridge({ id, label, order }?: UseThemeDevtoolBridgeOptions): RegisteredThemeDevtoolBridge;