@rozenite/controls-plugin 1.7.0-rc.2 → 1.8.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.
@@ -22,7 +22,7 @@
22
22
  <script>
23
23
  var __ROZENITE_PANEL__ = true;
24
24
  </script>
25
- <script type="module" crossorigin src="../devtools/assets/panel-Csphk_TK.js"></script>
25
+ <script type="module" crossorigin src="../devtools/assets/panel-BoQwJa2M.js"></script>
26
26
  <link rel="stylesheet" crossorigin href="../devtools/assets/panel-B5zz0XK3.css">
27
27
  </head>
28
28
  <body>
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("@rozenite/plugin-bridge"),c=require("react"),f=require("@rozenite/agent-bridge"),w=(o,t)=>o?o(t):{valid:!0},U=o=>o.type==="text"?o:o.type==="toggle"?{id:o.id,type:o.type,title:o.title,value:o.value,description:o.description,disabled:o.disabled}:o.type==="button"?{id:o.id,type:o.type,title:o.title,actionLabel:o.actionLabel,description:o.description,disabled:o.disabled}:o.type==="select"?{id:o.id,type:o.type,title:o.title,value:o.value,options:o.options,description:o.description,disabled:o.disabled}:{id:o.id,type:o.type,title:o.title,value:o.value,placeholder:o.placeholder,applyLabel:o.applyLabel,description:o.description,disabled:o.disabled},P=o=>o.map(t=>({id:t.id,title:t.title,description:t.description,items:t.items.map(U)})),z=o=>{const t=new Map;return o.forEach(n=>{n.items.forEach(e=>{const i=`${n.id}:${e.id}`;e.type==="toggle"&&t.set(i,{type:"toggle",validate:e.validate,onUpdate:e.onUpdate}),e.type==="button"&&t.set(i,{type:"button",onPress:e.onPress}),e.type==="select"&&t.set(i,{type:"select",validate:e.validate,onUpdate:e.onUpdate}),e.type==="input"&&t.set(i,{type:"input",validate:e.validate,onUpdate:e.onUpdate})})}),t},$=(o,t)=>`${o}:${t}`,b="@rozenite/controls-plugin",S={name:"list-sections",description:"List all controls sections with their item IDs, types, and titles. Does not include values — call get-item for that.",inputSchema:{type:"object",properties:{}}},A={name:"get-item",description:"Get full details of a single controls item including its current value. For select items this includes available options.",inputSchema:{type:"object",properties:{sectionId:{type:"string",description:"Section ID."},itemId:{type:"string",description:"Item ID."}},required:["sectionId","itemId"]}},T={name:"set-value",description:"Update the value of a toggle, select, or input item. Runs the validate callback when present. Fails for text (read-only) and button items.",inputSchema:{type:"object",properties:{sectionId:{type:"string",description:"Section ID."},itemId:{type:"string",description:"Item ID."},value:{description:"New value. Boolean for toggle items, string for select/input items."}},required:["sectionId","itemId","value"]}},C={name:"press-button",description:"Trigger a button item's action. Fails if the item is not a button or is disabled.",inputSchema:{type:"object",properties:{sectionId:{type:"string",description:"Section ID."},itemId:{type:"string",description:"Item ID."}},required:["sectionId","itemId"]}},v=(o,t,n)=>{const e=o.find(s=>s.id===t);if(!e){const s=o.map(u=>u.id).join(", ");throw new Error(`Section "${t}" not found. Available: ${s||"(none)"}`)}const i=e.items.find(s=>s.id===n);if(!i){const s=e.items.map(u=>u.id).join(", ");throw new Error(`Item "${n}" not found in section "${t}". Available: ${s||"(none)"}`)}return{section:e,item:i}},D=o=>{f.useRozenitePluginAgentTool({pluginId:b,tool:S,handler:()=>({sections:o.map(t=>({id:t.id,title:t.title,description:t.description,items:t.items.map(n=>({id:n.id,type:n.type,title:n.title,disabled:"disabled"in n?n.disabled:void 0}))}))})}),f.useRozenitePluginAgentTool({pluginId:b,tool:A,handler:({sectionId:t,itemId:n})=>{const{item:e}=v(o,t,n);return e.type==="text"?{sectionId:t,item:{id:e.id,type:e.type,title:e.title,value:e.value,description:e.description}}:e.type==="toggle"?{sectionId:t,item:{id:e.id,type:e.type,title:e.title,value:e.value,description:e.description,disabled:e.disabled}}:e.type==="button"?{sectionId:t,item:{id:e.id,type:e.type,title:e.title,actionLabel:e.actionLabel,description:e.description,disabled:e.disabled}}:e.type==="select"?{sectionId:t,item:{id:e.id,type:e.type,title:e.title,value:e.value,options:e.options,description:e.description,disabled:e.disabled}}:{sectionId:t,item:{id:e.id,type:e.type,title:e.title,value:e.value,placeholder:e.placeholder,applyLabel:e.applyLabel,description:e.description,disabled:e.disabled}}}}),f.useRozenitePluginAgentTool({pluginId:b,tool:T,handler:async({sectionId:t,itemId:n,value:e})=>{const{item:i}=v(o,t,n);if(i.type==="text")throw new Error(`Item "${n}" is a read-only text item and cannot be updated.`);if(i.type==="button")throw new Error(`Item "${n}" is a button. Use press-button to trigger its action.`);if(i.disabled)throw new Error(`Item "${n}" is disabled.`);if(i.type==="toggle"){if(typeof e!="boolean")throw new Error(`Expected boolean value for toggle item "${n}".`);if(i.validate){const s=i.validate(e);if(!s.valid)throw new Error(s.message)}return await i.onUpdate(e),{applied:!0,sectionId:t,itemId:n}}if(typeof e!="string")throw new Error(`Expected string value for ${i.type} item "${n}".`);if(i.type==="select"){const s=i.options.map(u=>u.value);if(!s.includes(e))throw new Error(`Invalid option "${e}" for item "${n}". Valid options: ${s.join(", ")}`)}if(i.validate){const s=i.validate(e);if(!s.valid)throw new Error(s.message)}return await i.onUpdate(e),{applied:!0,sectionId:t,itemId:n}}}),f.useRozenitePluginAgentTool({pluginId:b,tool:C,handler:async({sectionId:t,itemId:n})=>{const{item:e}=v(o,t,n);if(e.type!=="button")throw new Error(`Item "${n}" is not a button (type: ${e.type}). Use set-value to update its value.`);if(e.disabled)throw new Error(`Button "${n}" is disabled.`);return await e.onPress(),{pressed:!0,sectionId:t,itemId:n}}})},L=({sections:o})=>{const t=R.useRozeniteDevToolsClient({pluginId:"@rozenite/controls-plugin"});D(o);const n=c.useMemo(()=>P(o),[o]),e=c.useMemo(()=>z(o),[o]),i=c.useRef(e);return c.useEffect(()=>{i.current=e},[e]),c.useEffect(()=>{t&&t.send("snapshot",{type:"snapshot",sections:n})},[t,n]),c.useEffect(()=>{if(!t)return;const s=async({requestId:r,sectionId:a,itemId:l,value:d})=>{const y=$(a,l),p=i.current.get(y);if(!p||p.type==="button"){t.send("update-result",{type:"update-result",requestId:r,sectionId:a,itemId:l,status:"error",message:"Update target not found."});return}try{if(p.type==="toggle"){if(typeof d!="boolean"){t.send("update-result",{type:"update-result",requestId:r,sectionId:a,itemId:l,status:"error",message:"Invalid toggle value."});return}const h=w(p.validate,d);if(!h.valid){t.send("update-result",{type:"update-result",requestId:r,sectionId:a,itemId:l,status:"error",message:h.message});return}await p.onUpdate(d),t.send("update-result",{type:"update-result",requestId:r,sectionId:a,itemId:l,status:"ok"});return}if(typeof d!="string"){t.send("update-result",{type:"update-result",requestId:r,sectionId:a,itemId:l,status:"error",message:`Invalid ${p.type} value.`});return}const g=w(p.validate,d);if(!g.valid){t.send("update-result",{type:"update-result",requestId:r,sectionId:a,itemId:l,status:"error",message:g.message});return}await p.onUpdate(d),t.send("update-result",{type:"update-result",requestId:r,sectionId:a,itemId:l,status:"ok"})}catch(g){console.warn(`[Rozenite] Controls Plugin: Update failed for ${a}/${l}.`,g),t.send("update-result",{type:"update-result",requestId:r,sectionId:a,itemId:l,status:"error",message:"Update failed on the device."})}},u=async({sectionId:r,itemId:a,action:l})=>{if(l!=="press"){console.warn(`[Rozenite] Controls Plugin: Unsupported action "${l}" for ${r}/${a}.`);return}const d=$(r,a),y=i.current.get(d);if(!y){console.warn(`[Rozenite] Controls Plugin: Action target not found for ${r}/${a}.`);return}try{if(y.type!=="button"){console.warn(`[Rozenite] Controls Plugin: Invalid press action payload for ${r}/${a}.`);return}await y.onPress()}catch(p){console.warn(`[Rozenite] Controls Plugin: Action failed for ${r}/${a}.`,p)}},E=[t.onMessage("get-snapshot",()=>{t.send("snapshot",{type:"snapshot",sections:n})}),t.onMessage("update-request",r=>{s(r)}),t.onMessage("invoke-action",r=>{u(r)})];return()=>{E.forEach(r=>r.remove())}},[t,n]),t};exports.useRozeniteControlsPlugin=L;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("@rozenite/plugin-bridge"),c=require("react"),f=require("@rozenite/agent-bridge"),b=require("@rozenite/agent-shared"),E=(n,t)=>n?n(t):{valid:!0},P=n=>n.type==="text"?n:n.type==="toggle"?{id:n.id,type:n.type,title:n.title,value:n.value,description:n.description,disabled:n.disabled}:n.type==="button"?{id:n.id,type:n.type,title:n.title,actionLabel:n.actionLabel,description:n.description,disabled:n.disabled}:n.type==="select"?{id:n.id,type:n.type,title:n.title,value:n.value,options:n.options,description:n.description,disabled:n.disabled}:{id:n.id,type:n.type,title:n.title,value:n.value,placeholder:n.placeholder,applyLabel:n.applyLabel,description:n.description,disabled:n.disabled},S=n=>n.map(t=>({id:t.id,title:t.title,description:t.description,items:t.items.map(P)})),z=n=>{const t=new Map;return n.forEach(o=>{o.items.forEach(e=>{const i=`${o.id}:${e.id}`;e.type==="toggle"&&t.set(i,{type:"toggle",validate:e.validate,onUpdate:e.onUpdate}),e.type==="button"&&t.set(i,{type:"button",onPress:e.onPress}),e.type==="select"&&t.set(i,{type:"select",validate:e.validate,onUpdate:e.onUpdate}),e.type==="input"&&t.set(i,{type:"input",validate:e.validate,onUpdate:e.onUpdate})})}),t},R=(n,t)=>`${n}:${t}`,v="@rozenite/controls-plugin",h={listSections:b.defineAgentToolContract({name:"list-sections",description:"List all controls sections with their item IDs, types, and titles. Does not include values — call get-item for that.",inputSchema:{type:"object",properties:{}}}),getItem:b.defineAgentToolContract({name:"get-item",description:"Get full details of a single controls item including its current value. For select items this includes available options.",inputSchema:{type:"object",properties:{sectionId:{type:"string",description:"Section ID."},itemId:{type:"string",description:"Item ID."}},required:["sectionId","itemId"]}}),setValue:b.defineAgentToolContract({name:"set-value",description:"Update the value of a toggle, select, or input item. Runs the validate callback when present. Fails for text (read-only) and button items.",inputSchema:{type:"object",properties:{sectionId:{type:"string",description:"Section ID."},itemId:{type:"string",description:"Item ID."},value:{description:"New value. Boolean for toggle items, string for select/input items."}},required:["sectionId","itemId","value"]}}),pressButton:b.defineAgentToolContract({name:"press-button",description:"Trigger a button item's action. Fails if the item is not a button or is disabled.",inputSchema:{type:"object",properties:{sectionId:{type:"string",description:"Section ID."},itemId:{type:"string",description:"Item ID."}},required:["sectionId","itemId"]}})},w=(n,t,o)=>{const e=n.find(s=>s.id===t);if(!e){const s=n.map(u=>u.id).join(", ");throw new Error(`Section "${t}" not found. Available: ${s||"(none)"}`)}const i=e.items.find(s=>s.id===o);if(!i){const s=e.items.map(u=>u.id).join(", ");throw new Error(`Item "${o}" not found in section "${t}". Available: ${s||"(none)"}`)}return{section:e,item:i}},T=n=>{f.useRozenitePluginAgentTool({pluginId:v,tool:h.listSections,handler:()=>({sections:n.map(t=>({id:t.id,title:t.title,description:t.description,items:t.items.map(o=>({id:o.id,type:o.type,title:o.title,disabled:"disabled"in o?o.disabled:void 0}))}))})}),f.useRozenitePluginAgentTool({pluginId:v,tool:h.getItem,handler:({sectionId:t,itemId:o})=>{const{item:e}=w(n,t,o);return e.type==="text"?{sectionId:t,item:{id:e.id,type:e.type,title:e.title,value:e.value,description:e.description}}:e.type==="toggle"?{sectionId:t,item:{id:e.id,type:e.type,title:e.title,value:e.value,description:e.description,disabled:e.disabled}}:e.type==="button"?{sectionId:t,item:{id:e.id,type:e.type,title:e.title,actionLabel:e.actionLabel,description:e.description,disabled:e.disabled}}:e.type==="select"?{sectionId:t,item:{id:e.id,type:e.type,title:e.title,value:e.value,options:e.options,description:e.description,disabled:e.disabled}}:{sectionId:t,item:{id:e.id,type:e.type,title:e.title,value:e.value,placeholder:e.placeholder,applyLabel:e.applyLabel,description:e.description,disabled:e.disabled}}}}),f.useRozenitePluginAgentTool({pluginId:v,tool:h.setValue,handler:async({sectionId:t,itemId:o,value:e})=>{const{item:i}=w(n,t,o);if(i.type==="text")throw new Error(`Item "${o}" is a read-only text item and cannot be updated.`);if(i.type==="button")throw new Error(`Item "${o}" is a button. Use press-button to trigger its action.`);if(i.disabled)throw new Error(`Item "${o}" is disabled.`);if(i.type==="toggle"){if(typeof e!="boolean")throw new Error(`Expected boolean value for toggle item "${o}".`);if(i.validate){const s=i.validate(e);if(!s.valid)throw new Error(s.message)}return await i.onUpdate(e),{applied:!0,sectionId:t,itemId:o}}if(typeof e!="string")throw new Error(`Expected string value for ${i.type} item "${o}".`);if(i.type==="select"){const s=i.options.map(u=>u.value);if(!s.includes(e))throw new Error(`Invalid option "${e}" for item "${o}". Valid options: ${s.join(", ")}`)}if(i.validate){const s=i.validate(e);if(!s.valid)throw new Error(s.message)}return await i.onUpdate(e),{applied:!0,sectionId:t,itemId:o}}}),f.useRozenitePluginAgentTool({pluginId:v,tool:h.pressButton,handler:async({sectionId:t,itemId:o})=>{const{item:e}=w(n,t,o);if(e.type!=="button")throw new Error(`Item "${o}" is not a button (type: ${e.type}). Use set-value to update its value.`);if(e.disabled)throw new Error(`Button "${o}" is disabled.`);return await e.onPress(),{pressed:!0,sectionId:t,itemId:o}}})},C=({sections:n})=>{const t=A.useRozeniteDevToolsClient({pluginId:"@rozenite/controls-plugin"});T(n);const o=c.useMemo(()=>S(n),[n]),e=c.useMemo(()=>z(n),[n]),i=c.useRef(e);return c.useEffect(()=>{i.current=e},[e]),c.useEffect(()=>{t&&t.send("snapshot",{type:"snapshot",sections:o})},[t,o]),c.useEffect(()=>{if(!t)return;const s=async({requestId:r,sectionId:a,itemId:l,value:d})=>{const y=R(a,l),p=i.current.get(y);if(!p||p.type==="button"){t.send("update-result",{type:"update-result",requestId:r,sectionId:a,itemId:l,status:"error",message:"Update target not found."});return}try{if(p.type==="toggle"){if(typeof d!="boolean"){t.send("update-result",{type:"update-result",requestId:r,sectionId:a,itemId:l,status:"error",message:"Invalid toggle value."});return}const $=E(p.validate,d);if(!$.valid){t.send("update-result",{type:"update-result",requestId:r,sectionId:a,itemId:l,status:"error",message:$.message});return}await p.onUpdate(d),t.send("update-result",{type:"update-result",requestId:r,sectionId:a,itemId:l,status:"ok"});return}if(typeof d!="string"){t.send("update-result",{type:"update-result",requestId:r,sectionId:a,itemId:l,status:"error",message:`Invalid ${p.type} value.`});return}const g=E(p.validate,d);if(!g.valid){t.send("update-result",{type:"update-result",requestId:r,sectionId:a,itemId:l,status:"error",message:g.message});return}await p.onUpdate(d),t.send("update-result",{type:"update-result",requestId:r,sectionId:a,itemId:l,status:"ok"})}catch(g){console.warn(`[Rozenite] Controls Plugin: Update failed for ${a}/${l}.`,g),t.send("update-result",{type:"update-result",requestId:r,sectionId:a,itemId:l,status:"error",message:"Update failed on the device."})}},u=async({sectionId:r,itemId:a,action:l})=>{if(l!=="press"){console.warn(`[Rozenite] Controls Plugin: Unsupported action "${l}" for ${r}/${a}.`);return}const d=R(r,a),y=i.current.get(d);if(!y){console.warn(`[Rozenite] Controls Plugin: Action target not found for ${r}/${a}.`);return}try{if(y.type!=="button"){console.warn(`[Rozenite] Controls Plugin: Invalid press action payload for ${r}/${a}.`);return}await y.onPress()}catch(p){console.warn(`[Rozenite] Controls Plugin: Action failed for ${r}/${a}.`,p)}},U=[t.onMessage("get-snapshot",()=>{t.send("snapshot",{type:"snapshot",sections:o})}),t.onMessage("update-request",r=>{s(r)}),t.onMessage("invoke-action",r=>{u(r)})];return()=>{U.forEach(r=>r.remove())}},[t,o]),t};exports.useRozeniteControlsPlugin=C;
@@ -1,7 +1,8 @@
1
- import { useRozeniteDevToolsClient as R } from "@rozenite/plugin-bridge";
2
- import { useMemo as w, useRef as z, useEffect as b } from "react";
1
+ import { useRozeniteDevToolsClient as S } from "@rozenite/plugin-bridge";
2
+ import { useMemo as E, useRef as P, useEffect as h } from "react";
3
3
  import { useRozenitePluginAgentTool as f } from "@rozenite/agent-bridge";
4
- const $ = (o, e) => o ? o(e) : { valid: !0 }, P = (o) => o.type === "text" ? o : o.type === "toggle" ? {
4
+ import { defineAgentToolContract as g } from "@rozenite/agent-shared";
5
+ const U = (o, e) => o ? o(e) : { valid: !0 }, z = (o) => o.type === "text" ? o : o.type === "toggle" ? {
5
6
  id: o.id,
6
7
  type: o.type,
7
8
  title: o.title,
@@ -32,75 +33,80 @@ const $ = (o, e) => o ? o(e) : { valid: !0 }, P = (o) => o.type === "text" ? o :
32
33
  applyLabel: o.applyLabel,
33
34
  description: o.description,
34
35
  disabled: o.disabled
35
- }, S = (o) => o.map((e) => ({
36
+ }, A = (o) => o.map((e) => ({
36
37
  id: e.id,
37
38
  title: e.title,
38
39
  description: e.description,
39
- items: e.items.map(P)
40
- })), m = (o) => {
40
+ items: e.items.map(z)
41
+ })), D = (o) => {
41
42
  const e = /* @__PURE__ */ new Map();
42
43
  return o.forEach((n) => {
43
44
  n.items.forEach((t) => {
44
- const r = `${n.id}:${t.id}`;
45
- t.type === "toggle" && e.set(r, {
45
+ const i = `${n.id}:${t.id}`;
46
+ t.type === "toggle" && e.set(i, {
46
47
  type: "toggle",
47
48
  validate: t.validate,
48
49
  onUpdate: t.onUpdate
49
- }), t.type === "button" && e.set(r, {
50
+ }), t.type === "button" && e.set(i, {
50
51
  type: "button",
51
52
  onPress: t.onPress
52
- }), t.type === "select" && e.set(r, {
53
+ }), t.type === "select" && e.set(i, {
53
54
  type: "select",
54
55
  validate: t.validate,
55
56
  onUpdate: t.onUpdate
56
- }), t.type === "input" && e.set(r, {
57
+ }), t.type === "input" && e.set(i, {
57
58
  type: "input",
58
59
  validate: t.validate,
59
60
  onUpdate: t.onUpdate
60
61
  });
61
62
  });
62
63
  }), e;
63
- }, E = (o, e) => `${o}:${e}`, g = "@rozenite/controls-plugin", A = {
64
- name: "list-sections",
65
- description: "List all controls sections with their item IDs, types, and titles. Does not include values — call get-item for that.",
66
- inputSchema: { type: "object", properties: {} }
67
- }, D = {
68
- name: "get-item",
69
- description: "Get full details of a single controls item including its current value. For select items this includes available options.",
70
- inputSchema: {
71
- type: "object",
72
- properties: {
73
- sectionId: { type: "string", description: "Section ID." },
74
- itemId: { type: "string", description: "Item ID." }
75
- },
76
- required: ["sectionId", "itemId"]
77
- }
78
- }, L = {
79
- name: "set-value",
80
- description: "Update the value of a toggle, select, or input item. Runs the validate callback when present. Fails for text (read-only) and button items.",
81
- inputSchema: {
82
- type: "object",
83
- properties: {
84
- sectionId: { type: "string", description: "Section ID." },
85
- itemId: { type: "string", description: "Item ID." },
86
- value: {
87
- description: "New value. Boolean for toggle items, string for select/input items."
88
- }
89
- },
90
- required: ["sectionId", "itemId", "value"]
91
- }
92
- }, k = {
93
- name: "press-button",
94
- description: "Trigger a button item's action. Fails if the item is not a button or is disabled.",
95
- inputSchema: {
96
- type: "object",
97
- properties: {
98
- sectionId: { type: "string", description: "Section ID." },
99
- itemId: { type: "string", description: "Item ID." }
100
- },
101
- required: ["sectionId", "itemId"]
102
- }
103
- }, v = (o, e, n) => {
64
+ }, R = (o, e) => `${o}:${e}`, b = "@rozenite/controls-plugin", v = {
65
+ listSections: g({
66
+ name: "list-sections",
67
+ description: "List all controls sections with their item IDs, types, and titles. Does not include values — call get-item for that.",
68
+ inputSchema: { type: "object", properties: {} }
69
+ }),
70
+ getItem: g({
71
+ name: "get-item",
72
+ description: "Get full details of a single controls item including its current value. For select items this includes available options.",
73
+ inputSchema: {
74
+ type: "object",
75
+ properties: {
76
+ sectionId: { type: "string", description: "Section ID." },
77
+ itemId: { type: "string", description: "Item ID." }
78
+ },
79
+ required: ["sectionId", "itemId"]
80
+ }
81
+ }),
82
+ setValue: g({
83
+ name: "set-value",
84
+ description: "Update the value of a toggle, select, or input item. Runs the validate callback when present. Fails for text (read-only) and button items.",
85
+ inputSchema: {
86
+ type: "object",
87
+ properties: {
88
+ sectionId: { type: "string", description: "Section ID." },
89
+ itemId: { type: "string", description: "Item ID." },
90
+ value: {
91
+ description: "New value. Boolean for toggle items, string for select/input items."
92
+ }
93
+ },
94
+ required: ["sectionId", "itemId", "value"]
95
+ }
96
+ }),
97
+ pressButton: g({
98
+ name: "press-button",
99
+ description: "Trigger a button item's action. Fails if the item is not a button or is disabled.",
100
+ inputSchema: {
101
+ type: "object",
102
+ properties: {
103
+ sectionId: { type: "string", description: "Section ID." },
104
+ itemId: { type: "string", description: "Item ID." }
105
+ },
106
+ required: ["sectionId", "itemId"]
107
+ }
108
+ })
109
+ }, w = (o, e, n) => {
104
110
  const t = o.find((s) => s.id === e);
105
111
  if (!t) {
106
112
  const s = o.map((u) => u.id).join(", ");
@@ -108,18 +114,18 @@ const $ = (o, e) => o ? o(e) : { valid: !0 }, P = (o) => o.type === "text" ? o :
108
114
  `Section "${e}" not found. Available: ${s || "(none)"}`
109
115
  );
110
116
  }
111
- const r = t.items.find((s) => s.id === n);
112
- if (!r) {
117
+ const i = t.items.find((s) => s.id === n);
118
+ if (!i) {
113
119
  const s = t.items.map((u) => u.id).join(", ");
114
120
  throw new Error(
115
121
  `Item "${n}" not found in section "${e}". Available: ${s || "(none)"}`
116
122
  );
117
123
  }
118
- return { section: t, item: r };
119
- }, x = (o) => {
124
+ return { section: t, item: i };
125
+ }, L = (o) => {
120
126
  f({
121
- pluginId: g,
122
- tool: A,
127
+ pluginId: b,
128
+ tool: v.listSections,
123
129
  handler: () => ({
124
130
  sections: o.map((e) => ({
125
131
  id: e.id,
@@ -134,10 +140,10 @@ const $ = (o, e) => o ? o(e) : { valid: !0 }, P = (o) => o.type === "text" ? o :
134
140
  }))
135
141
  })
136
142
  }), f({
137
- pluginId: g,
138
- tool: D,
143
+ pluginId: b,
144
+ tool: v.getItem,
139
145
  handler: ({ sectionId: e, itemId: n }) => {
140
- const { item: t } = v(o, e, n);
146
+ const { item: t } = w(o, e, n);
141
147
  return t.type === "text" ? {
142
148
  sectionId: e,
143
149
  item: {
@@ -193,55 +199,55 @@ const $ = (o, e) => o ? o(e) : { valid: !0 }, P = (o) => o.type === "text" ? o :
193
199
  };
194
200
  }
195
201
  }), f({
196
- pluginId: g,
197
- tool: L,
202
+ pluginId: b,
203
+ tool: v.setValue,
198
204
  handler: async ({ sectionId: e, itemId: n, value: t }) => {
199
- const { item: r } = v(o, e, n);
200
- if (r.type === "text")
205
+ const { item: i } = w(o, e, n);
206
+ if (i.type === "text")
201
207
  throw new Error(
202
208
  `Item "${n}" is a read-only text item and cannot be updated.`
203
209
  );
204
- if (r.type === "button")
210
+ if (i.type === "button")
205
211
  throw new Error(
206
212
  `Item "${n}" is a button. Use press-button to trigger its action.`
207
213
  );
208
- if (r.disabled)
214
+ if (i.disabled)
209
215
  throw new Error(`Item "${n}" is disabled.`);
210
- if (r.type === "toggle") {
216
+ if (i.type === "toggle") {
211
217
  if (typeof t != "boolean")
212
218
  throw new Error(
213
219
  `Expected boolean value for toggle item "${n}".`
214
220
  );
215
- if (r.validate) {
216
- const s = r.validate(t);
221
+ if (i.validate) {
222
+ const s = i.validate(t);
217
223
  if (!s.valid)
218
224
  throw new Error(s.message);
219
225
  }
220
- return await r.onUpdate(t), { applied: !0, sectionId: e, itemId: n };
226
+ return await i.onUpdate(t), { applied: !0, sectionId: e, itemId: n };
221
227
  }
222
228
  if (typeof t != "string")
223
229
  throw new Error(
224
- `Expected string value for ${r.type} item "${n}".`
230
+ `Expected string value for ${i.type} item "${n}".`
225
231
  );
226
- if (r.type === "select") {
227
- const s = r.options.map((u) => u.value);
232
+ if (i.type === "select") {
233
+ const s = i.options.map((u) => u.value);
228
234
  if (!s.includes(t))
229
235
  throw new Error(
230
236
  `Invalid option "${t}" for item "${n}". Valid options: ${s.join(", ")}`
231
237
  );
232
238
  }
233
- if (r.validate) {
234
- const s = r.validate(t);
239
+ if (i.validate) {
240
+ const s = i.validate(t);
235
241
  if (!s.valid)
236
242
  throw new Error(s.message);
237
243
  }
238
- return await r.onUpdate(t), { applied: !0, sectionId: e, itemId: n };
244
+ return await i.onUpdate(t), { applied: !0, sectionId: e, itemId: n };
239
245
  }
240
246
  }), f({
241
- pluginId: g,
242
- tool: k,
247
+ pluginId: b,
248
+ tool: v.pressButton,
243
249
  handler: async ({ sectionId: e, itemId: n }) => {
244
- const { item: t } = v(o, e, n);
250
+ const { item: t } = w(o, e, n);
245
251
  if (t.type !== "button")
246
252
  throw new Error(
247
253
  `Item "${n}" is not a button (type: ${t.type}). Use set-value to update its value.`
@@ -251,35 +257,35 @@ const $ = (o, e) => o ? o(e) : { valid: !0 }, P = (o) => o.type === "text" ? o :
251
257
  return await t.onPress(), { pressed: !0, sectionId: e, itemId: n };
252
258
  }
253
259
  });
254
- }, M = ({
260
+ }, j = ({
255
261
  sections: o
256
262
  }) => {
257
- const e = R({
263
+ const e = S({
258
264
  pluginId: "@rozenite/controls-plugin"
259
265
  });
260
- x(o);
261
- const n = w(() => S(o), [o]), t = w(() => m(o), [o]), r = z(t);
262
- return b(() => {
263
- r.current = t;
264
- }, [t]), b(() => {
266
+ L(o);
267
+ const n = E(() => A(o), [o]), t = E(() => D(o), [o]), i = P(t);
268
+ return h(() => {
269
+ i.current = t;
270
+ }, [t]), h(() => {
265
271
  e && e.send("snapshot", {
266
272
  type: "snapshot",
267
273
  sections: n
268
274
  });
269
- }, [e, n]), b(() => {
275
+ }, [e, n]), h(() => {
270
276
  if (!e)
271
277
  return;
272
278
  const s = async ({
273
- requestId: i,
279
+ requestId: r,
274
280
  sectionId: a,
275
281
  itemId: l,
276
282
  value: d
277
283
  }) => {
278
- const c = E(a, l), p = r.current.get(c);
284
+ const c = R(a, l), p = i.current.get(c);
279
285
  if (!p || p.type === "button") {
280
286
  e.send("update-result", {
281
287
  type: "update-result",
282
- requestId: i,
288
+ requestId: r,
283
289
  sectionId: a,
284
290
  itemId: l,
285
291
  status: "error",
@@ -292,7 +298,7 @@ const $ = (o, e) => o ? o(e) : { valid: !0 }, P = (o) => o.type === "text" ? o :
292
298
  if (typeof d != "boolean") {
293
299
  e.send("update-result", {
294
300
  type: "update-result",
295
- requestId: i,
301
+ requestId: r,
296
302
  sectionId: a,
297
303
  itemId: l,
298
304
  status: "error",
@@ -300,21 +306,21 @@ const $ = (o, e) => o ? o(e) : { valid: !0 }, P = (o) => o.type === "text" ? o :
300
306
  });
301
307
  return;
302
308
  }
303
- const h = $(p.validate, d);
304
- if (!h.valid) {
309
+ const $ = U(p.validate, d);
310
+ if (!$.valid) {
305
311
  e.send("update-result", {
306
312
  type: "update-result",
307
- requestId: i,
313
+ requestId: r,
308
314
  sectionId: a,
309
315
  itemId: l,
310
316
  status: "error",
311
- message: h.message
317
+ message: $.message
312
318
  });
313
319
  return;
314
320
  }
315
321
  await p.onUpdate(d), e.send("update-result", {
316
322
  type: "update-result",
317
- requestId: i,
323
+ requestId: r,
318
324
  sectionId: a,
319
325
  itemId: l,
320
326
  status: "ok"
@@ -324,7 +330,7 @@ const $ = (o, e) => o ? o(e) : { valid: !0 }, P = (o) => o.type === "text" ? o :
324
330
  if (typeof d != "string") {
325
331
  e.send("update-result", {
326
332
  type: "update-result",
327
- requestId: i,
333
+ requestId: r,
328
334
  sectionId: a,
329
335
  itemId: l,
330
336
  status: "error",
@@ -332,11 +338,11 @@ const $ = (o, e) => o ? o(e) : { valid: !0 }, P = (o) => o.type === "text" ? o :
332
338
  });
333
339
  return;
334
340
  }
335
- const y = $(p.validate, d);
341
+ const y = U(p.validate, d);
336
342
  if (!y.valid) {
337
343
  e.send("update-result", {
338
344
  type: "update-result",
339
- requestId: i,
345
+ requestId: r,
340
346
  sectionId: a,
341
347
  itemId: l,
342
348
  status: "error",
@@ -346,7 +352,7 @@ const $ = (o, e) => o ? o(e) : { valid: !0 }, P = (o) => o.type === "text" ? o :
346
352
  }
347
353
  await p.onUpdate(d), e.send("update-result", {
348
354
  type: "update-result",
349
- requestId: i,
355
+ requestId: r,
350
356
  sectionId: a,
351
357
  itemId: l,
352
358
  status: "ok"
@@ -357,7 +363,7 @@ const $ = (o, e) => o ? o(e) : { valid: !0 }, P = (o) => o.type === "text" ? o :
357
363
  y
358
364
  ), e.send("update-result", {
359
365
  type: "update-result",
360
- requestId: i,
366
+ requestId: r,
361
367
  sectionId: a,
362
368
  itemId: l,
363
369
  status: "error",
@@ -365,56 +371,56 @@ const $ = (o, e) => o ? o(e) : { valid: !0 }, P = (o) => o.type === "text" ? o :
365
371
  });
366
372
  }
367
373
  }, u = async ({
368
- sectionId: i,
374
+ sectionId: r,
369
375
  itemId: a,
370
376
  action: l
371
377
  }) => {
372
378
  if (l !== "press") {
373
379
  console.warn(
374
- `[Rozenite] Controls Plugin: Unsupported action "${l}" for ${i}/${a}.`
380
+ `[Rozenite] Controls Plugin: Unsupported action "${l}" for ${r}/${a}.`
375
381
  );
376
382
  return;
377
383
  }
378
- const d = E(i, a), c = r.current.get(d);
384
+ const d = R(r, a), c = i.current.get(d);
379
385
  if (!c) {
380
386
  console.warn(
381
- `[Rozenite] Controls Plugin: Action target not found for ${i}/${a}.`
387
+ `[Rozenite] Controls Plugin: Action target not found for ${r}/${a}.`
382
388
  );
383
389
  return;
384
390
  }
385
391
  try {
386
392
  if (c.type !== "button") {
387
393
  console.warn(
388
- `[Rozenite] Controls Plugin: Invalid press action payload for ${i}/${a}.`
394
+ `[Rozenite] Controls Plugin: Invalid press action payload for ${r}/${a}.`
389
395
  );
390
396
  return;
391
397
  }
392
398
  await c.onPress();
393
399
  } catch (p) {
394
400
  console.warn(
395
- `[Rozenite] Controls Plugin: Action failed for ${i}/${a}.`,
401
+ `[Rozenite] Controls Plugin: Action failed for ${r}/${a}.`,
396
402
  p
397
403
  );
398
404
  }
399
- }, U = [
405
+ }, m = [
400
406
  e.onMessage("get-snapshot", () => {
401
407
  e.send("snapshot", {
402
408
  type: "snapshot",
403
409
  sections: n
404
410
  });
405
411
  }),
406
- e.onMessage("update-request", (i) => {
407
- s(i);
412
+ e.onMessage("update-request", (r) => {
413
+ s(r);
408
414
  }),
409
- e.onMessage("invoke-action", (i) => {
410
- u(i);
415
+ e.onMessage("invoke-action", (r) => {
416
+ u(r);
411
417
  })
412
418
  ];
413
419
  return () => {
414
- U.forEach((i) => i.remove());
420
+ m.forEach((r) => r.remove());
415
421
  };
416
422
  }, [e, n]), e;
417
423
  };
418
424
  export {
419
- M as useRozeniteControlsPlugin
425
+ j as useRozeniteControlsPlugin
420
426
  };
@@ -1,4 +1,4 @@
1
- import { RozeniteDevToolsClient } from '../../../plugin-bridge/src/index.ts';
1
+ import { RozeniteDevToolsClient } from '@rozenite/plugin-bridge';
2
2
 
3
3
  export declare type ControlsButtonItem = {
4
4
  id: string;
@@ -1 +1 @@
1
- {"name":"@rozenite/controls-plugin","version":"1.7.0-rc.2","description":"A Rozenite plugin for exposing app-defined controls directly in React Native DevTools.","panels":[{"name":"Controls","source":"/devtools/panel.html"}]}
1
+ {"name":"@rozenite/controls-plugin","version":"1.8.0","description":"A Rozenite plugin for exposing app-defined controls directly in React Native DevTools.","panels":[{"name":"Controls","source":"/devtools/panel.html"}]}
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@rozenite/agent-shared"),t="@rozenite/controls-plugin",i={listSections:e.defineAgentToolContract({name:"list-sections",description:"List all controls sections with their item IDs, types, and titles. Does not include values — call get-item for that.",inputSchema:{type:"object",properties:{}}}),getItem:e.defineAgentToolContract({name:"get-item",description:"Get full details of a single controls item including its current value. For select items this includes available options.",inputSchema:{type:"object",properties:{sectionId:{type:"string",description:"Section ID."},itemId:{type:"string",description:"Item ID."}},required:["sectionId","itemId"]}}),setValue:e.defineAgentToolContract({name:"set-value",description:"Update the value of a toggle, select, or input item. Runs the validate callback when present. Fails for text (read-only) and button items.",inputSchema:{type:"object",properties:{sectionId:{type:"string",description:"Section ID."},itemId:{type:"string",description:"Item ID."},value:{description:"New value. Boolean for toggle items, string for select/input items."}},required:["sectionId","itemId","value"]}}),pressButton:e.defineAgentToolContract({name:"press-button",description:"Trigger a button item's action. Fails if the item is not a button or is disabled.",inputSchema:{type:"object",properties:{sectionId:{type:"string",description:"Section ID."},itemId:{type:"string",description:"Item ID."}},required:["sectionId","itemId"]}})},o=e.defineAgentToolDescriptors(t,i);exports.CONTROLS_AGENT_PLUGIN_ID=t;exports.controlsToolDefinitions=i;exports.controlsTools=o;