cabbage-react 1.0.26 → 1.0.27

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.
@@ -8,6 +8,5 @@
8
8
  export declare const useCabbageState: <T>(channelId: string, gesture?: "begin" | "value" | "end" | "complete") => {
9
9
  value: T | undefined;
10
10
  setValue: (value: T) => void;
11
- parameterIndex: number | undefined;
12
11
  };
13
12
  //# sourceMappingURL=useCabbageState.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useCabbageState.d.ts","sourceRoot":"","sources":["../../src/hooks/useCabbageState.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAAI,CAAC,aACrB,MAAM,YACR,OAAO,GAAG,OAAO,GAAG,KAAK,GAAG,UAAU;;sBAOb,CAAC;;CAyFnC,CAAC"}
1
+ {"version":3,"file":"useCabbageState.d.ts","sourceRoot":"","sources":["../../src/hooks/useCabbageState.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAAI,CAAC,aACrB,MAAM,YACR,OAAO,GAAG,OAAO,GAAG,KAAK,GAAG,UAAU;;sBAOb,CAAC;CAwFnC,CAAC"}
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react");console.log("Cabbage: loading cabbage.js");class p{static sendControlData({channel:o,value:e,gesture:a="complete"},n=null){const s={command:"controlData",channel:o,value:e,gesture:a};n!==null?n.postMessage(s):typeof window.sendMessageFromUI=="function"?window.sendMessageFromUI(s):console.error("Cabbage: window.sendMessageFromUI is not available. Message:",s)}static isReadyToLoad(o=null,e={}){this.sendCustomCommand("isReadyToLoad",o)}static sendMidiMessageFromUI(o,e,a,n=null){var s={statusByte:o,dataByte1:e,dataByte2:a};const d={command:"midiMessage",obj:JSON.stringify(s)};n!==null?n.postMessage(d):typeof window.sendMessageFromUI=="function"?window.sendMessageFromUI(d):console.error("Cabbage: window.sendMessageFromUI is not available. Message:",d)}static MidiMessageFromHost(o,e,a){console.log("Cabbage: Got MIDI Message"+o+":"+e+":"+a)}static triggerFileOpenDialog(o,e,a={}){var n={channel:e,directory:a.directory||"",filters:a.filters||"*",openAtLastKnownLocation:a.openAtLastKnownLocation!==void 0?a.openAtLastKnownLocation:!0};const s={command:"fileOpen",obj:JSON.stringify(n)};o!==null?o.postMessage(s):typeof window.sendMessageFromUI=="function"?window.sendMessageFromUI(s):console.error("Cabbage: window.sendMessageFromUI is not available. Message:",s)}static openUrl(o,e,a){var n={url:e,file:a};const s={command:"openUrl",obj:JSON.stringify(n)};o!==null?o.postMessage(s):typeof window.sendMessageFromUI=="function"?window.sendMessageFromUI(s):console.error("Cabbage: window.sendMessageFromUI is not available. Message:",s)}static requestResize(o,e,a=null){const n={command:"requestResize",width:o,height:e};if(a!==null){console.warn("Cabbage: requestResize is not supported in VS Code extension mode");return}else typeof window.sendMessageFromUI=="function"?window.sendMessageFromUI(n):console.error("Cabbage: window.sendMessageFromUI is not available. Message:",n)}static sendChannelData(o,e,a=null){var n={channel:o};if(typeof e=="string")n.stringData=e;else if(typeof e=="number")n.floatData=e;else{console.warn("Cabbage: sendChannelData received unsupported data type:",typeof e);return}const s={command:"channelData",obj:JSON.stringify(n)};console.log("Cabbage: sending channel data from UI",n),a!==null?a.postMessage(s):typeof window.sendMessageFromUI=="function"?window.sendMessageFromUI(s):console.error("Cabbage: window.sendMessageFromUI is not available. Message:",s)}static sendWidgetUpdate(o,e=null){const a={command:"widgetStateUpdate",obj:JSON.stringify(CabbageUtils.sanitizeForEditor(o))};e!==null?e.postMessage(a):typeof window.sendMessageFromUI=="function"?window.sendMessageFromUI(a):console.error("Cabbage: window.sendMessageFromUI is not available. Message:",a)}static sendCustomCommand(o,e=null,a={}){const n={command:o,text:JSON.stringify(a)};if(e!==null)e.postMessage(n);else if(typeof window.sendMessageFromUI=="function"){console.log("Cabbage: Calling window.sendMessageFromUI with:",n);try{const s=window.sendMessageFromUI(n);console.log("Cabbage: sendMessageFromUI returned:",s)}catch(s){console.error("Cabbage: sendMessageFromUI threw error:",s),console.error("Cabbage: Error stack:",s.stack)}}else console.error("Cabbage: window.sendMessageFromUI is not available yet. Message:",n),console.error("Cabbage: typeof window.sendMessageFromUI:",typeof window.sendMessageFromUI),console.error("Cabbage: window.sendMessageFromUI value:",window.sendMessageFromUI)}}const C=r=>{const[o,e]=m.useState();return m.useEffect(()=>{const a=n=>{const{id:s,widgetJson:d,command:w}=n.data;if(s===r&&d&&w==="widgetUpdate"){const t=JSON.parse(d);console.log(`[Cabbage-React] Received properties for channelId ${s}`,t),e(t)}};return window.addEventListener("message",a),()=>{window.removeEventListener("message",a)}},[]),{properties:o}},I=(r,o="complete")=>{const{properties:e}=C(r),[a,n]=m.useState(),[s,d]=m.useState(),w=t=>{n(t),p.sendControlData({channel:r,value:t,gesture:o})};return m.useEffect(()=>{var b;const t=e==null?void 0:e.channels.find(i=>i.id===r);if(!t)return;const l=t==null?void 0:t.parameterIndex;s===void 0&&l!==void 0&&(console.log(`[Cabbage-React] Received parameterIndex for channelId "${t.id}"`,l),d(l));const g=(b=t.range)==null?void 0:b.defaultValue;a===void 0&&g!==void 0&&(console.log(`[Cabbage-React] Received default value for channelId "${t.id}"`,g),n(g))},[e]),m.useEffect(()=>{const t=l=>{var b;const{command:g}=l.data;if(g==="parameterChange"){const{value:i,paramIdx:c}=l.data.data;if(c!==s||i===null)return;console.log(`[Cabbage-React] Received parameterChange for parameterIndex ${c}`,i),n(i)}else if(g==="batchWidgetUpdate"){const i=l.data.widgets,c=i==null?void 0:i.find(f=>f.id===r);if(!c)return;const u=JSON.parse(c.widgetJson).channels.find(f=>f.id===r),M=(b=u==null?void 0:u.range)==null?void 0:b.value;console.log(`[Cabbage-React] Received batch widget update for channelId ${c.id}`,M),n(M)}};return window.addEventListener("message",t),()=>{window.removeEventListener("message",t)}},[s]),{value:a,setValue:w,parameterIndex:s}};exports.Cabbage=p;exports.useCabbageProperties=C;exports.useCabbageState=I;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react");console.log("Cabbage: loading cabbage.js");class p{static sendControlData({channel:o,value:e,gesture:s="complete"},a=null){const n={command:"controlData",channel:o,value:e,gesture:s};a!==null?a.postMessage(n):typeof window.sendMessageFromUI=="function"?window.sendMessageFromUI(n):console.error("Cabbage: window.sendMessageFromUI is not available. Message:",n)}static isReadyToLoad(o=null,e={}){this.sendCustomCommand("isReadyToLoad",o)}static sendMidiMessageFromUI(o,e,s,a=null){var n={statusByte:o,dataByte1:e,dataByte2:s};const d={command:"midiMessage",obj:JSON.stringify(n)};a!==null?a.postMessage(d):typeof window.sendMessageFromUI=="function"?window.sendMessageFromUI(d):console.error("Cabbage: window.sendMessageFromUI is not available. Message:",d)}static MidiMessageFromHost(o,e,s){console.log("Cabbage: Got MIDI Message"+o+":"+e+":"+s)}static triggerFileOpenDialog(o,e,s={}){var a={channel:e,directory:s.directory||"",filters:s.filters||"*",openAtLastKnownLocation:s.openAtLastKnownLocation!==void 0?s.openAtLastKnownLocation:!0};const n={command:"fileOpen",obj:JSON.stringify(a)};o!==null?o.postMessage(n):typeof window.sendMessageFromUI=="function"?window.sendMessageFromUI(n):console.error("Cabbage: window.sendMessageFromUI is not available. Message:",n)}static openUrl(o,e,s){var a={url:e,file:s};const n={command:"openUrl",obj:JSON.stringify(a)};o!==null?o.postMessage(n):typeof window.sendMessageFromUI=="function"?window.sendMessageFromUI(n):console.error("Cabbage: window.sendMessageFromUI is not available. Message:",n)}static requestResize(o,e,s=null){const a={command:"requestResize",width:o,height:e};if(s!==null){console.warn("Cabbage: requestResize is not supported in VS Code extension mode");return}else typeof window.sendMessageFromUI=="function"?window.sendMessageFromUI(a):console.error("Cabbage: window.sendMessageFromUI is not available. Message:",a)}static sendChannelData(o,e,s=null){var a={channel:o};if(typeof e=="string")a.stringData=e;else if(typeof e=="number")a.floatData=e;else{console.warn("Cabbage: sendChannelData received unsupported data type:",typeof e);return}const n={command:"channelData",obj:JSON.stringify(a)};console.log("Cabbage: sending channel data from UI",a),s!==null?s.postMessage(n):typeof window.sendMessageFromUI=="function"?window.sendMessageFromUI(n):console.error("Cabbage: window.sendMessageFromUI is not available. Message:",n)}static sendWidgetUpdate(o,e=null){const s={command:"widgetStateUpdate",obj:JSON.stringify(CabbageUtils.sanitizeForEditor(o))};e!==null?e.postMessage(s):typeof window.sendMessageFromUI=="function"?window.sendMessageFromUI(s):console.error("Cabbage: window.sendMessageFromUI is not available. Message:",s)}static sendCustomCommand(o,e=null,s={}){const a={command:o,text:JSON.stringify(s)};if(e!==null)e.postMessage(a);else if(typeof window.sendMessageFromUI=="function"){console.log("Cabbage: Calling window.sendMessageFromUI with:",a);try{const n=window.sendMessageFromUI(a);console.log("Cabbage: sendMessageFromUI returned:",n)}catch(n){console.error("Cabbage: sendMessageFromUI threw error:",n),console.error("Cabbage: Error stack:",n.stack)}}else console.error("Cabbage: window.sendMessageFromUI is not available yet. Message:",a),console.error("Cabbage: typeof window.sendMessageFromUI:",typeof window.sendMessageFromUI),console.error("Cabbage: window.sendMessageFromUI value:",window.sendMessageFromUI)}}const C=r=>{const[o,e]=m.useState();return m.useEffect(()=>{const s=a=>{const{id:n,widgetJson:d,command:w}=a.data;if(n===r&&d&&w==="widgetUpdate"){const t=JSON.parse(d);console.log(`[Cabbage-React] Received properties for channelId ${n}`,t),e(t)}};return window.addEventListener("message",s),()=>{window.removeEventListener("message",s)}},[]),{properties:o}},I=(r,o="complete")=>{const{properties:e}=C(r),[s,a]=m.useState(),[n,d]=m.useState(),w=t=>{a(t),p.sendControlData({channel:r,value:t,gesture:o})};return m.useEffect(()=>{var b;const t=e==null?void 0:e.channels.find(i=>i.id===r);if(!t)return;const l=t==null?void 0:t.parameterIndex;n===void 0&&l!==void 0&&(console.log(`[Cabbage-React] Received parameterIndex for channelId "${t.id}"`,l),d(l));const g=(b=t.range)==null?void 0:b.defaultValue;s===void 0&&g!==void 0&&(console.log(`[Cabbage-React] Received default value for channelId "${t.id}"`,g),a(g))},[e]),m.useEffect(()=>{const t=l=>{var b;const{command:g}=l.data;if(g==="parameterChange"){const{value:i,paramIdx:c}=l.data.data;if(c!==n||i===null)return;console.log(`[Cabbage-React] Received parameterChange for parameterIndex ${c}`,i),a(i)}else if(g==="batchWidgetUpdate"){const i=l.data.widgets,c=i==null?void 0:i.find(f=>f.id===r);if(!c)return;const u=JSON.parse(c.widgetJson).channels.find(f=>f.id===r),M=(b=u==null?void 0:u.range)==null?void 0:b.value;console.log(`[Cabbage-React] Received batch widget update for channelId ${c.id}`,M),a(M)}};return window.addEventListener("message",t),()=>{window.removeEventListener("message",t)}},[n]),{value:s,setValue:w}};exports.Cabbage=p;exports.useCabbageProperties=C;exports.useCabbageState=I;
package/dist/index.mjs CHANGED
@@ -21,16 +21,16 @@ class I {
21
21
  * @param {string} [data.gesture="complete"] - The gesture type: "begin" (start of interaction), "value" (during interaction), "end" (end of continuous interaction), or "complete" (discrete action e.g. button click).
22
22
  * @param {Object|null} vscode - VS Code API object (null for plugin mode)
23
23
  */
24
- static sendControlData({ channel: o, value: e, gesture: a = "complete" }, n = null) {
25
- const s = {
24
+ static sendControlData({ channel: o, value: e, gesture: s = "complete" }, a = null) {
25
+ const n = {
26
26
  command: "controlData",
27
27
  channel: o,
28
28
  value: e,
29
- gesture: a
29
+ gesture: s
30
30
  };
31
- n !== null ? n.postMessage(s) : typeof window.sendMessageFromUI == "function" ? window.sendMessageFromUI(s) : console.error(
31
+ a !== null ? a.postMessage(n) : typeof window.sendMessageFromUI == "function" ? window.sendMessageFromUI(n) : console.error(
32
32
  "Cabbage: window.sendMessageFromUI is not available. Message:",
33
- s
33
+ n
34
34
  );
35
35
  }
36
36
  /**
@@ -50,17 +50,17 @@ class I {
50
50
  * @param {number} dataByte2 - Second MIDI data byte
51
51
  * @param {Object|null} vscode - VS Code API object (null for plugin mode)
52
52
  */
53
- static sendMidiMessageFromUI(o, e, a, n = null) {
54
- var s = {
53
+ static sendMidiMessageFromUI(o, e, s, a = null) {
54
+ var n = {
55
55
  statusByte: o,
56
56
  dataByte1: e,
57
- dataByte2: a
57
+ dataByte2: s
58
58
  };
59
59
  const d = {
60
60
  command: "midiMessage",
61
- obj: JSON.stringify(s)
61
+ obj: JSON.stringify(n)
62
62
  };
63
- n !== null ? n.postMessage(d) : typeof window.sendMessageFromUI == "function" ? window.sendMessageFromUI(d) : console.error(
63
+ a !== null ? a.postMessage(d) : typeof window.sendMessageFromUI == "function" ? window.sendMessageFromUI(d) : console.error(
64
64
  "Cabbage: window.sendMessageFromUI is not available. Message:",
65
65
  d
66
66
  );
@@ -72,9 +72,9 @@ class I {
72
72
  * @param {number} dataByte1 - First MIDI data byte
73
73
  * @param {number} dataByte2 - Second MIDI data byte
74
74
  */
75
- static MidiMessageFromHost(o, e, a) {
75
+ static MidiMessageFromHost(o, e, s) {
76
76
  console.log(
77
- "Cabbage: Got MIDI Message" + o + ":" + e + ":" + a
77
+ "Cabbage: Got MIDI Message" + o + ":" + e + ":" + s
78
78
  );
79
79
  }
80
80
  /**
@@ -87,20 +87,20 @@ class I {
87
87
  * @param {string} [options.filters="*"] - File filters (e.g., "*.wav;*.aiff")
88
88
  * @param {boolean} [options.openAtLastKnownLocation=true] - Whether to open at last known location
89
89
  */
90
- static triggerFileOpenDialog(o, e, a = {}) {
91
- var n = {
90
+ static triggerFileOpenDialog(o, e, s = {}) {
91
+ var a = {
92
92
  channel: e,
93
- directory: a.directory || "",
94
- filters: a.filters || "*",
95
- openAtLastKnownLocation: a.openAtLastKnownLocation !== void 0 ? a.openAtLastKnownLocation : !0
93
+ directory: s.directory || "",
94
+ filters: s.filters || "*",
95
+ openAtLastKnownLocation: s.openAtLastKnownLocation !== void 0 ? s.openAtLastKnownLocation : !0
96
96
  };
97
- const s = {
97
+ const n = {
98
98
  command: "fileOpen",
99
- obj: JSON.stringify(n)
99
+ obj: JSON.stringify(a)
100
100
  };
101
- o !== null ? o.postMessage(s) : typeof window.sendMessageFromUI == "function" ? window.sendMessageFromUI(s) : console.error(
101
+ o !== null ? o.postMessage(n) : typeof window.sendMessageFromUI == "function" ? window.sendMessageFromUI(n) : console.error(
102
102
  "Cabbage: window.sendMessageFromUI is not available. Message:",
103
- s
103
+ n
104
104
  );
105
105
  }
106
106
  /**
@@ -110,18 +110,18 @@ class I {
110
110
  * @param {string} url - URL to open
111
111
  * @param {string} file - File path to open
112
112
  */
113
- static openUrl(o, e, a) {
114
- var n = {
113
+ static openUrl(o, e, s) {
114
+ var a = {
115
115
  url: e,
116
- file: a
116
+ file: s
117
117
  };
118
- const s = {
118
+ const n = {
119
119
  command: "openUrl",
120
- obj: JSON.stringify(n)
120
+ obj: JSON.stringify(a)
121
121
  };
122
- o !== null ? o.postMessage(s) : typeof window.sendMessageFromUI == "function" ? window.sendMessageFromUI(s) : console.error(
122
+ o !== null ? o.postMessage(n) : typeof window.sendMessageFromUI == "function" ? window.sendMessageFromUI(n) : console.error(
123
123
  "Cabbage: window.sendMessageFromUI is not available. Message:",
124
- s
124
+ n
125
125
  );
126
126
  }
127
127
  /**
@@ -136,21 +136,21 @@ class I {
136
136
  * The response will be sent via hostMessageCallback with:
137
137
  * {command: "resizeResponse", accepted: boolean, width: number, height: number}
138
138
  */
139
- static requestResize(o, e, a = null) {
140
- const n = {
139
+ static requestResize(o, e, s = null) {
140
+ const a = {
141
141
  command: "requestResize",
142
142
  width: o,
143
143
  height: e
144
144
  };
145
- if (a !== null) {
145
+ if (s !== null) {
146
146
  console.warn(
147
147
  "Cabbage: requestResize is not supported in VS Code extension mode"
148
148
  );
149
149
  return;
150
150
  } else
151
- typeof window.sendMessageFromUI == "function" ? window.sendMessageFromUI(n) : console.error(
151
+ typeof window.sendMessageFromUI == "function" ? window.sendMessageFromUI(a) : console.error(
152
152
  "Cabbage: window.sendMessageFromUI is not available. Message:",
153
- n
153
+ a
154
154
  );
155
155
  }
156
156
  /**
@@ -160,14 +160,14 @@ class I {
160
160
  * @param {number|string} data - The data to send (number or string)
161
161
  * @param {Object|null} vscode - VS Code API object (null for plugin mode)
162
162
  */
163
- static sendChannelData(o, e, a = null) {
164
- var n = {
163
+ static sendChannelData(o, e, s = null) {
164
+ var a = {
165
165
  channel: o
166
166
  };
167
167
  if (typeof e == "string")
168
- n.stringData = e;
168
+ a.stringData = e;
169
169
  else if (typeof e == "number")
170
- n.floatData = e;
170
+ a.floatData = e;
171
171
  else {
172
172
  console.warn(
173
173
  "Cabbage: sendChannelData received unsupported data type:",
@@ -175,13 +175,13 @@ class I {
175
175
  );
176
176
  return;
177
177
  }
178
- const s = {
178
+ const n = {
179
179
  command: "channelData",
180
- obj: JSON.stringify(n)
180
+ obj: JSON.stringify(a)
181
181
  };
182
- console.log("Cabbage: sending channel data from UI", n), a !== null ? a.postMessage(s) : typeof window.sendMessageFromUI == "function" ? window.sendMessageFromUI(s) : console.error(
182
+ console.log("Cabbage: sending channel data from UI", a), s !== null ? s.postMessage(n) : typeof window.sendMessageFromUI == "function" ? window.sendMessageFromUI(n) : console.error(
183
183
  "Cabbage: window.sendMessageFromUI is not available. Message:",
184
- s
184
+ n
185
185
  );
186
186
  }
187
187
  /**
@@ -192,13 +192,13 @@ class I {
192
192
  * @param {Object|null} vscode - VS Code API object (null for plugin mode)
193
193
  */
194
194
  static sendWidgetUpdate(o, e = null) {
195
- const a = {
195
+ const s = {
196
196
  command: "widgetStateUpdate",
197
197
  obj: JSON.stringify(CabbageUtils.sanitizeForEditor(o))
198
198
  };
199
- e !== null ? e.postMessage(a) : typeof window.sendMessageFromUI == "function" ? window.sendMessageFromUI(a) : console.error(
199
+ e !== null ? e.postMessage(s) : typeof window.sendMessageFromUI == "function" ? window.sendMessageFromUI(s) : console.error(
200
200
  "Cabbage: window.sendMessageFromUI is not available. Message:",
201
- a
201
+ s
202
202
  );
203
203
  }
204
204
  /**
@@ -208,25 +208,25 @@ class I {
208
208
  * @param {Object|null} vscode - VS Code API object (null for plugin mode)
209
209
  * @param {Object} additionalData - Additional data to include in the command
210
210
  */
211
- static sendCustomCommand(o, e = null, a = {}) {
212
- const n = {
211
+ static sendCustomCommand(o, e = null, s = {}) {
212
+ const a = {
213
213
  command: o,
214
- text: JSON.stringify(a)
214
+ text: JSON.stringify(s)
215
215
  };
216
216
  if (e !== null)
217
- e.postMessage(n);
217
+ e.postMessage(a);
218
218
  else if (typeof window.sendMessageFromUI == "function") {
219
- console.log("Cabbage: Calling window.sendMessageFromUI with:", n);
219
+ console.log("Cabbage: Calling window.sendMessageFromUI with:", a);
220
220
  try {
221
- const s = window.sendMessageFromUI(n);
222
- console.log("Cabbage: sendMessageFromUI returned:", s);
223
- } catch (s) {
224
- console.error("Cabbage: sendMessageFromUI threw error:", s), console.error("Cabbage: Error stack:", s.stack);
221
+ const n = window.sendMessageFromUI(a);
222
+ console.log("Cabbage: sendMessageFromUI returned:", n);
223
+ } catch (n) {
224
+ console.error("Cabbage: sendMessageFromUI threw error:", n), console.error("Cabbage: Error stack:", n.stack);
225
225
  }
226
226
  } else
227
227
  console.error(
228
228
  "Cabbage: window.sendMessageFromUI is not available yet. Message:",
229
- n
229
+ a
230
230
  ), console.error(
231
231
  "Cabbage: typeof window.sendMessageFromUI:",
232
232
  typeof window.sendMessageFromUI
@@ -239,25 +239,25 @@ class I {
239
239
  const C = (r) => {
240
240
  const [o, e] = u();
241
241
  return M(() => {
242
- const a = (n) => {
243
- const { id: s, widgetJson: d, command: w } = n.data;
244
- if (s === r && d && w === "widgetUpdate") {
242
+ const s = (a) => {
243
+ const { id: n, widgetJson: d, command: w } = a.data;
244
+ if (n === r && d && w === "widgetUpdate") {
245
245
  const t = JSON.parse(d);
246
246
  console.log(
247
- `[Cabbage-React] Received properties for channelId ${s}`,
247
+ `[Cabbage-React] Received properties for channelId ${n}`,
248
248
  t
249
249
  ), e(t);
250
250
  }
251
251
  };
252
- return window.addEventListener("message", a), () => {
253
- window.removeEventListener("message", a);
252
+ return window.addEventListener("message", s), () => {
253
+ window.removeEventListener("message", s);
254
254
  };
255
255
  }, []), {
256
256
  properties: o
257
257
  };
258
258
  }, y = (r, o = "complete") => {
259
- const { properties: e } = C(r), [a, n] = u(), [s, d] = u(), w = (t) => {
260
- n(t), I.sendControlData({
259
+ const { properties: e } = C(r), [s, a] = u(), [n, d] = u(), w = (t) => {
260
+ a(t), I.sendControlData({
261
261
  channel: r,
262
262
  value: t,
263
263
  gesture: o
@@ -270,26 +270,26 @@ const C = (r) => {
270
270
  );
271
271
  if (!t) return;
272
272
  const l = t == null ? void 0 : t.parameterIndex;
273
- s === void 0 && l !== void 0 && (console.log(
273
+ n === void 0 && l !== void 0 && (console.log(
274
274
  `[Cabbage-React] Received parameterIndex for channelId "${t.id}"`,
275
275
  l
276
276
  ), d(l));
277
277
  const g = (m = t.range) == null ? void 0 : m.defaultValue;
278
- a === void 0 && g !== void 0 && (console.log(
278
+ s === void 0 && g !== void 0 && (console.log(
279
279
  `[Cabbage-React] Received default value for channelId "${t.id}"`,
280
280
  g
281
- ), n(g));
281
+ ), a(g));
282
282
  }, [e]), M(() => {
283
283
  const t = (l) => {
284
284
  var m;
285
285
  const { command: g } = l.data;
286
286
  if (g === "parameterChange") {
287
287
  const { value: i, paramIdx: c } = l.data.data;
288
- if (c !== s || i === null) return;
288
+ if (c !== n || i === null) return;
289
289
  console.log(
290
290
  `[Cabbage-React] Received parameterChange for parameterIndex ${c}`,
291
291
  i
292
- ), n(i);
292
+ ), a(i);
293
293
  } else if (g === "batchWidgetUpdate") {
294
294
  const i = l.data.widgets, c = i == null ? void 0 : i.find((b) => b.id === r);
295
295
  if (!c) return;
@@ -299,16 +299,15 @@ const C = (r) => {
299
299
  console.log(
300
300
  `[Cabbage-React] Received batch widget update for channelId ${c.id}`,
301
301
  p
302
- ), n(p);
302
+ ), a(p);
303
303
  }
304
304
  };
305
305
  return window.addEventListener("message", t), () => {
306
306
  window.removeEventListener("message", t);
307
307
  };
308
- }, [s]), {
309
- value: a,
310
- setValue: w,
311
- parameterIndex: s
308
+ }, [n]), {
309
+ value: s,
310
+ setValue: w
312
311
  };
313
312
  };
314
313
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cabbage-react",
3
- "version": "1.0.26",
3
+ "version": "1.0.27",
4
4
  "type": "module",
5
5
  "keywords": [
6
6
  "cabbage",