@reopt-ai/opt-devtool 1.0.0 → 1.0.1

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