cabbage-react 1.0.5 → 1.0.7
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.
|
@@ -4,17 +4,17 @@ export class Cabbage {
|
|
|
4
4
|
* This function automatically routes messages to the appropriate backend function
|
|
5
5
|
* based on the automatable flag:
|
|
6
6
|
*
|
|
7
|
-
* - automatable=
|
|
8
|
-
*
|
|
7
|
+
* - automatable=true: Routes to sendParameterUpdate for real-time parameter control /
|
|
8
|
+
* this also sends the value as channel data to Csound
|
|
9
9
|
*
|
|
10
|
-
* - automatable=
|
|
10
|
+
* - automatable=false: Routes to sendChannelData for string/numeric data transmission
|
|
11
11
|
*
|
|
12
12
|
* All widget interactions should use this function instead of calling the lower-level
|
|
13
13
|
* sendParameterUpdate or sendChannelData functions directly.
|
|
14
14
|
*/
|
|
15
|
-
static sendChannelUpdate(message: any, vscode?: null, automatable?:
|
|
15
|
+
static sendChannelUpdate(message: any, vscode?: null, automatable?: boolean): void;
|
|
16
16
|
static sendParameterUpdate(message: any, vscode?: null): void;
|
|
17
|
-
static sendCustomCommand(command: any, vscode?: null): void;
|
|
17
|
+
static sendCustomCommand(command: any, vscode?: null, additionalData?: {}): void;
|
|
18
18
|
static sendWidgetUpdate(widget: any, vscode?: null): void;
|
|
19
19
|
static sendMidiMessageFromUI(statusByte: any, dataByte1: any, dataByte2: any, vscode?: null): void;
|
|
20
20
|
static sendChannelData(channel: any, data: any, vscode?: null): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cabbage.d.ts","sourceRoot":"","sources":["../../src/cabbage/cabbage.js"],"names":[],"mappings":"AAMA;
|
|
1
|
+
{"version":3,"file":"cabbage.d.ts","sourceRoot":"","sources":["../../src/cabbage/cabbage.js"],"names":[],"mappings":"AAMA;IACC;;;;;;;;;;;;OAYG;IACH,mFAYC;IAED,8DAsCC;IAED,iFAiCC;IAED,0DAiBC;IAED,mGA6BC;IAED,qEAoCC;IAED,kFASC;IAED,4EA2BC;IAED,uDAsBC;CACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCabbageState.d.ts","sourceRoot":"","sources":["../../src/hooks/useCabbageState.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,CAAC,aAAa,MAAM;;
|
|
1
|
+
{"version":3,"file":"useCabbageState.d.ts","sourceRoot":"","sources":["../../src/hooks/useCabbageState.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,CAAC,aAAa,MAAM;;sBAMjB,CAAC;CAoFnC,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react");console.log("Cabbage: loading cabbage.js");class u{static sendChannelUpdate(e,n=null,a=!1){if(a===!0||a===1)u.sendParameterUpdate(e,n);else{const s=e.value!==void 0?e.value:e.stringData||e.floatData;u.sendChannelData(e.channel,s,n)}}static sendParameterUpdate(e,n=null){if(e.paramIdx===void 0||e.paramIdx===null){console.error("Cabbage.sendParameterUpdate: message missing paramIdx!",e);return}if(e.paramIdx<0){console.warn("Cabbage.sendParameterUpdate: paramIdx is -1, skipping (non-automatable widget)",e);return}const a={command:"parameterChange",paramIdx:e.paramIdx,channel:e.channel,value:e.value,channelType:e.channelType||"number"};n!==null?n.postMessage(a):typeof window.sendMessageFromUI=="function"?window.sendMessageFromUI(a):console.error("Cabbage: window.sendMessageFromUI is not available. Message:",a)}static sendCustomCommand(e,n=null,a={}){const s={command:e,text:JSON.stringify(a)};if(n!==null)n.postMessage(s);else if(typeof window.sendMessageFromUI=="function"){console.log("Cabbage: Calling window.sendMessageFromUI with:",s);try{const o=window.sendMessageFromUI(s);console.log("Cabbage: sendMessageFromUI returned:",o)}catch(o){console.error("Cabbage: sendMessageFromUI threw error:",o),console.error("Cabbage: Error stack:",o.stack)}}else console.error("Cabbage: window.sendMessageFromUI is not available yet. Message:",s),console.error("Cabbage: typeof window.sendMessageFromUI:",typeof window.sendMessageFromUI),console.error("Cabbage: window.sendMessageFromUI value:",window.sendMessageFromUI)}static sendWidgetUpdate(e,n=null){const a={command:"widgetStateUpdate",obj:JSON.stringify(CabbageUtils.sanitizeForEditor(e))};n!==null?n.postMessage(a):typeof window.sendMessageFromUI=="function"?window.sendMessageFromUI(a):console.error("Cabbage: window.sendMessageFromUI is not available. Message:",a)}static sendMidiMessageFromUI(e,n,a,s=null){var o={statusByte:e,dataByte1:n,dataByte2:a};const i={command:"midiMessage",obj:JSON.stringify(o)};s!==null?s.postMessage(i):typeof window.sendMessageFromUI=="function"?window.sendMessageFromUI(i):console.error("Cabbage: window.sendMessageFromUI is not available. Message:",i)}static sendChannelData(e,n,a=null){var s={channel:e};if(typeof n=="string")s.stringData=n;else if(typeof n=="number")s.floatData=n;else{console.warn("Cabbage: sendChannelData received unsupported data type:",typeof n);return}const o={command:"channelData",obj:JSON.stringify(s)};console.log("Cabbage: sending channel data from UI",s),a!==null?a.postMessage(o):typeof window.sendMessageFromUI=="function"?window.sendMessageFromUI(o):console.error("Cabbage: window.sendMessageFromUI is not available. Message:",o)}static MidiMessageFromHost(e,n,a){console.log("Cabbage: Got MIDI Message"+e+":"+n+":"+a)}static triggerFileOpenDialog(e,n,a={}){var s={channel:n,directory:a.directory||"",filters:a.filters||"*",openAtLastKnownLocation:a.openAtLastKnownLocation!==void 0?a.openAtLastKnownLocation:!0};const o={command:"fileOpen",obj:JSON.stringify(s)};e!==null?e.postMessage(o):typeof window.sendMessageFromUI=="function"?window.sendMessageFromUI(o):console.error("Cabbage: window.sendMessageFromUI is not available. Message:",o)}static openUrl(e,n,a){var s={url:n,file:a};const o={command:"openUrl",obj:JSON.stringify(s)};e!==null?e.postMessage(o):typeof window.sendMessageFromUI=="function"?window.sendMessageFromUI(o):console.error("Cabbage: window.sendMessageFromUI is not available. Message:",o)}}const f=d=>{const[e,n]=c.useState();return c.useEffect(()=>{const a=s=>{const{id:o,widgetJson:i,command:t}=s.data;if(o===d&&i&&t==="widgetUpdate"){const r=JSON.parse(i);console.log(`[Cabbage-React] Received properties for channelId ${o}`,r),n(r)}};return window.addEventListener("message",a),()=>{window.removeEventListener("message",a)}},[]),{properties:e}},w=d=>{const{properties:e}=f(d),[n,a]=c.useState(),[s,o]=c.useState(),i=t=>{a(t);const r={channel:d,paramIdx:s,value:t};u.sendParameterUpdate(r,null)};return c.useEffect(()=>{var m;const t=e==null?void 0:e.channels.find(b=>b.id===d);if(!t)return;const r=t==null?void 0:t.parameterIndex;s===void 0&&r!==void 0&&(console.log(`[Cabbage-React] Received parameterIndex for channelId "${t.id}"`,r),o(r));const g=e==null?void 0:e.value;g!=null&&(console.log(`[Cabbage-React] Received initial value for channelId "${d}"`,g),a(g));const l=(m=t.range)==null?void 0:m.defaultValue;n===void 0&&l!==void 0&&(console.log(`[Cabbage-React] Received default value for channelId "${t.id}"`,l),a(l))},[e]),c.useEffect(()=>{const t=r=>{const{command:g}=r.data;if(g==="parameterChange"){const{value:l,paramIdx:m}=r.data;if(console.log("event",r),m!==s||l==null)return;console.log(`[Cabbage-React] Received value change for parameterIndex ${m}`,l),a(l)}};return window.addEventListener("message",t),()=>{window.removeEventListener("message",t)}},[]),{value:n,setValue:i}};exports.Cabbage=u;exports.useCabbageProperties=f;exports.useCabbageState=w;
|
package/dist/index.mjs
CHANGED
|
@@ -1,177 +1,238 @@
|
|
|
1
|
-
import { useState as
|
|
1
|
+
import { useState as f, useEffect as u } from "react";
|
|
2
2
|
console.log("Cabbage: loading cabbage.js");
|
|
3
|
-
class
|
|
3
|
+
class m {
|
|
4
4
|
/**
|
|
5
5
|
* Main entry point for sending any data from UI widgets to the Cabbage backend.
|
|
6
6
|
* This function automatically routes messages to the appropriate backend function
|
|
7
7
|
* based on the automatable flag:
|
|
8
|
-
*
|
|
9
|
-
* - automatable=
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* - automatable=
|
|
13
|
-
*
|
|
8
|
+
*
|
|
9
|
+
* - automatable=true: Routes to sendParameterUpdate for real-time parameter control /
|
|
10
|
+
* this also sends the value as channel data to Csound
|
|
11
|
+
*
|
|
12
|
+
* - automatable=false: Routes to sendChannelData for string/numeric data transmission
|
|
13
|
+
*
|
|
14
14
|
* All widget interactions should use this function instead of calling the lower-level
|
|
15
15
|
* sendParameterUpdate or sendChannelData functions directly.
|
|
16
16
|
*/
|
|
17
|
-
static sendChannelUpdate(e,
|
|
18
|
-
if (
|
|
19
|
-
|
|
17
|
+
static sendChannelUpdate(e, n = null, a = !1) {
|
|
18
|
+
if (a === !0 || a === 1)
|
|
19
|
+
m.sendParameterUpdate(e, n);
|
|
20
20
|
else {
|
|
21
|
-
const
|
|
22
|
-
|
|
21
|
+
const s = e.value !== void 0 ? e.value : e.stringData || e.floatData;
|
|
22
|
+
m.sendChannelData(e.channel, s, n);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
-
static sendParameterUpdate(e,
|
|
26
|
-
|
|
25
|
+
static sendParameterUpdate(e, n = null) {
|
|
26
|
+
if (e.paramIdx === void 0 || e.paramIdx === null) {
|
|
27
|
+
console.error(
|
|
28
|
+
"Cabbage.sendParameterUpdate: message missing paramIdx!",
|
|
29
|
+
e
|
|
30
|
+
);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (e.paramIdx < 0) {
|
|
34
|
+
console.warn(
|
|
35
|
+
"Cabbage.sendParameterUpdate: paramIdx is -1, skipping (non-automatable widget)",
|
|
36
|
+
e
|
|
37
|
+
);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const a = {
|
|
27
41
|
command: "parameterChange",
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
42
|
+
paramIdx: e.paramIdx,
|
|
43
|
+
channel: e.channel,
|
|
44
|
+
value: e.value,
|
|
45
|
+
channelType: e.channelType || "number"
|
|
46
|
+
};
|
|
47
|
+
n !== null ? n.postMessage(a) : typeof window.sendMessageFromUI == "function" ? window.sendMessageFromUI(a) : console.error(
|
|
48
|
+
"Cabbage: window.sendMessageFromUI is not available. Message:",
|
|
49
|
+
a
|
|
50
|
+
);
|
|
31
51
|
}
|
|
32
|
-
static sendCustomCommand(e, a =
|
|
33
|
-
const
|
|
52
|
+
static sendCustomCommand(e, n = null, a = {}) {
|
|
53
|
+
const s = {
|
|
34
54
|
command: e,
|
|
35
|
-
text: JSON.stringify(
|
|
36
|
-
};
|
|
37
|
-
|
|
55
|
+
text: JSON.stringify(a)
|
|
56
|
+
};
|
|
57
|
+
if (n !== null)
|
|
58
|
+
n.postMessage(s);
|
|
59
|
+
else if (typeof window.sendMessageFromUI == "function") {
|
|
60
|
+
console.log("Cabbage: Calling window.sendMessageFromUI with:", s);
|
|
61
|
+
try {
|
|
62
|
+
const o = window.sendMessageFromUI(s);
|
|
63
|
+
console.log("Cabbage: sendMessageFromUI returned:", o);
|
|
64
|
+
} catch (o) {
|
|
65
|
+
console.error("Cabbage: sendMessageFromUI threw error:", o), console.error("Cabbage: Error stack:", o.stack);
|
|
66
|
+
}
|
|
67
|
+
} else
|
|
68
|
+
console.error(
|
|
69
|
+
"Cabbage: window.sendMessageFromUI is not available yet. Message:",
|
|
70
|
+
s
|
|
71
|
+
), console.error(
|
|
72
|
+
"Cabbage: typeof window.sendMessageFromUI:",
|
|
73
|
+
typeof window.sendMessageFromUI
|
|
74
|
+
), console.error(
|
|
75
|
+
"Cabbage: window.sendMessageFromUI value:",
|
|
76
|
+
window.sendMessageFromUI
|
|
77
|
+
);
|
|
38
78
|
}
|
|
39
|
-
static sendWidgetUpdate(e,
|
|
40
|
-
|
|
41
|
-
const n = {
|
|
79
|
+
static sendWidgetUpdate(e, n = null) {
|
|
80
|
+
const a = {
|
|
42
81
|
command: "widgetStateUpdate",
|
|
43
82
|
obj: JSON.stringify(CabbageUtils.sanitizeForEditor(e))
|
|
44
83
|
};
|
|
45
|
-
|
|
84
|
+
n !== null ? n.postMessage(a) : typeof window.sendMessageFromUI == "function" ? window.sendMessageFromUI(a) : console.error(
|
|
85
|
+
"Cabbage: window.sendMessageFromUI is not available. Message:",
|
|
86
|
+
a
|
|
87
|
+
);
|
|
46
88
|
}
|
|
47
|
-
static sendMidiMessageFromUI(e,
|
|
48
|
-
var
|
|
89
|
+
static sendMidiMessageFromUI(e, n, a, s = null) {
|
|
90
|
+
var o = {
|
|
49
91
|
statusByte: e,
|
|
50
|
-
dataByte1:
|
|
51
|
-
dataByte2:
|
|
92
|
+
dataByte1: n,
|
|
93
|
+
dataByte2: a
|
|
52
94
|
};
|
|
53
|
-
const
|
|
95
|
+
const i = {
|
|
54
96
|
command: "midiMessage",
|
|
55
|
-
obj: JSON.stringify(
|
|
97
|
+
obj: JSON.stringify(o)
|
|
56
98
|
};
|
|
57
|
-
|
|
99
|
+
s !== null ? s.postMessage(i) : typeof window.sendMessageFromUI == "function" ? window.sendMessageFromUI(i) : console.error(
|
|
100
|
+
"Cabbage: window.sendMessageFromUI is not available. Message:",
|
|
101
|
+
i
|
|
102
|
+
);
|
|
58
103
|
}
|
|
59
|
-
static sendChannelData(e,
|
|
60
|
-
var
|
|
104
|
+
static sendChannelData(e, n, a = null) {
|
|
105
|
+
var s = {
|
|
61
106
|
channel: e
|
|
62
107
|
};
|
|
63
|
-
if (typeof
|
|
64
|
-
|
|
65
|
-
else if (typeof
|
|
66
|
-
|
|
108
|
+
if (typeof n == "string")
|
|
109
|
+
s.stringData = n;
|
|
110
|
+
else if (typeof n == "number")
|
|
111
|
+
s.floatData = n;
|
|
67
112
|
else {
|
|
68
|
-
console.warn(
|
|
113
|
+
console.warn(
|
|
114
|
+
"Cabbage: sendChannelData received unsupported data type:",
|
|
115
|
+
typeof n
|
|
116
|
+
);
|
|
69
117
|
return;
|
|
70
118
|
}
|
|
71
|
-
const
|
|
119
|
+
const o = {
|
|
72
120
|
command: "channelData",
|
|
73
|
-
obj: JSON.stringify(
|
|
121
|
+
obj: JSON.stringify(s)
|
|
74
122
|
};
|
|
75
|
-
console.log("Cabbage: sending channel data from UI",
|
|
123
|
+
console.log("Cabbage: sending channel data from UI", s), a !== null ? a.postMessage(o) : typeof window.sendMessageFromUI == "function" ? window.sendMessageFromUI(o) : console.error(
|
|
124
|
+
"Cabbage: window.sendMessageFromUI is not available. Message:",
|
|
125
|
+
o
|
|
126
|
+
);
|
|
76
127
|
}
|
|
77
|
-
static MidiMessageFromHost(e,
|
|
78
|
-
console.log(
|
|
128
|
+
static MidiMessageFromHost(e, n, a) {
|
|
129
|
+
console.log(
|
|
130
|
+
"Cabbage: Got MIDI Message" + e + ":" + n + ":" + a
|
|
131
|
+
);
|
|
79
132
|
}
|
|
80
|
-
static triggerFileOpenDialog(e,
|
|
81
|
-
var
|
|
82
|
-
channel:
|
|
83
|
-
directory:
|
|
84
|
-
filters:
|
|
85
|
-
openAtLastKnownLocation:
|
|
133
|
+
static triggerFileOpenDialog(e, n, a = {}) {
|
|
134
|
+
var s = {
|
|
135
|
+
channel: n,
|
|
136
|
+
directory: a.directory || "",
|
|
137
|
+
filters: a.filters || "*",
|
|
138
|
+
openAtLastKnownLocation: a.openAtLastKnownLocation !== void 0 ? a.openAtLastKnownLocation : !0
|
|
86
139
|
};
|
|
87
|
-
const
|
|
140
|
+
const o = {
|
|
88
141
|
command: "fileOpen",
|
|
89
|
-
obj: JSON.stringify(
|
|
142
|
+
obj: JSON.stringify(s)
|
|
90
143
|
};
|
|
91
|
-
e !== null ? e.postMessage(
|
|
144
|
+
e !== null ? e.postMessage(o) : typeof window.sendMessageFromUI == "function" ? window.sendMessageFromUI(o) : console.error(
|
|
145
|
+
"Cabbage: window.sendMessageFromUI is not available. Message:",
|
|
146
|
+
o
|
|
147
|
+
);
|
|
92
148
|
}
|
|
93
|
-
static openUrl(e,
|
|
94
|
-
var
|
|
95
|
-
url:
|
|
96
|
-
file:
|
|
149
|
+
static openUrl(e, n, a) {
|
|
150
|
+
var s = {
|
|
151
|
+
url: n,
|
|
152
|
+
file: a
|
|
97
153
|
};
|
|
98
|
-
const
|
|
154
|
+
const o = {
|
|
99
155
|
command: "openUrl",
|
|
100
|
-
obj: JSON.stringify(
|
|
156
|
+
obj: JSON.stringify(s)
|
|
101
157
|
};
|
|
102
|
-
e !== null ? e.postMessage(
|
|
158
|
+
e !== null ? e.postMessage(o) : typeof window.sendMessageFromUI == "function" ? window.sendMessageFromUI(o) : console.error(
|
|
159
|
+
"Cabbage: window.sendMessageFromUI is not available. Message:",
|
|
160
|
+
o
|
|
161
|
+
);
|
|
103
162
|
}
|
|
104
163
|
}
|
|
105
|
-
const
|
|
106
|
-
const [e,
|
|
107
|
-
return
|
|
108
|
-
const
|
|
109
|
-
const { id:
|
|
110
|
-
if (
|
|
111
|
-
const
|
|
164
|
+
const b = (d) => {
|
|
165
|
+
const [e, n] = f();
|
|
166
|
+
return u(() => {
|
|
167
|
+
const a = (s) => {
|
|
168
|
+
const { id: o, widgetJson: i, command: t } = s.data;
|
|
169
|
+
if (o === d && i && t === "widgetUpdate") {
|
|
170
|
+
const r = JSON.parse(i);
|
|
112
171
|
console.log(
|
|
113
|
-
`[Cabbage-React] Received properties for channelId ${
|
|
114
|
-
|
|
115
|
-
),
|
|
172
|
+
`[Cabbage-React] Received properties for channelId ${o}`,
|
|
173
|
+
r
|
|
174
|
+
), n(r);
|
|
116
175
|
}
|
|
117
176
|
};
|
|
118
|
-
return window.addEventListener("message",
|
|
119
|
-
window.removeEventListener("message",
|
|
177
|
+
return window.addEventListener("message", a), () => {
|
|
178
|
+
window.removeEventListener("message", a);
|
|
120
179
|
};
|
|
121
180
|
}, []), {
|
|
122
181
|
properties: e
|
|
123
182
|
};
|
|
124
|
-
},
|
|
125
|
-
const { properties: e } =
|
|
126
|
-
|
|
127
|
-
const
|
|
183
|
+
}, M = (d) => {
|
|
184
|
+
const { properties: e } = b(d), [n, a] = f(), [s, o] = f(), i = (t) => {
|
|
185
|
+
a(t);
|
|
186
|
+
const r = {
|
|
128
187
|
channel: d,
|
|
129
|
-
|
|
130
|
-
|
|
188
|
+
paramIdx: s,
|
|
189
|
+
value: t
|
|
131
190
|
};
|
|
132
|
-
|
|
191
|
+
m.sendParameterUpdate(r, null);
|
|
133
192
|
};
|
|
134
|
-
return
|
|
135
|
-
var
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
console.log(
|
|
139
|
-
`[Cabbage-React] Received initial value for channelId "${d}"`,
|
|
140
|
-
s
|
|
141
|
-
), n(s);
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
const o = e == null ? void 0 : e.channels.find(
|
|
145
|
-
(g) => g.id === d
|
|
193
|
+
return u(() => {
|
|
194
|
+
var c;
|
|
195
|
+
const t = e == null ? void 0 : e.channels.find(
|
|
196
|
+
(w) => w.id === d
|
|
146
197
|
);
|
|
147
|
-
if (!
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
`[Cabbage-React] Received
|
|
151
|
-
|
|
152
|
-
),
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
198
|
+
if (!t) return;
|
|
199
|
+
const r = t == null ? void 0 : t.parameterIndex;
|
|
200
|
+
s === void 0 && r !== void 0 && (console.log(
|
|
201
|
+
`[Cabbage-React] Received parameterIndex for channelId "${t.id}"`,
|
|
202
|
+
r
|
|
203
|
+
), o(r));
|
|
204
|
+
const g = e == null ? void 0 : e.value;
|
|
205
|
+
g != null && (console.log(
|
|
206
|
+
`[Cabbage-React] Received initial value for channelId "${d}"`,
|
|
207
|
+
g
|
|
208
|
+
), a(g));
|
|
209
|
+
const l = (c = t.range) == null ? void 0 : c.defaultValue;
|
|
210
|
+
n === void 0 && l !== void 0 && (console.log(
|
|
211
|
+
`[Cabbage-React] Received default value for channelId "${t.id}"`,
|
|
212
|
+
l
|
|
213
|
+
), a(l));
|
|
214
|
+
}, [e]), u(() => {
|
|
215
|
+
const t = (r) => {
|
|
216
|
+
const { command: g } = r.data;
|
|
217
|
+
if (g === "parameterChange") {
|
|
218
|
+
const { value: l, paramIdx: c } = r.data;
|
|
219
|
+
if (console.log("event", r), c !== s || l == null) return;
|
|
159
220
|
console.log(
|
|
160
|
-
`[Cabbage-React] Received value change for parameterIndex ${
|
|
221
|
+
`[Cabbage-React] Received value change for parameterIndex ${c}`,
|
|
161
222
|
l
|
|
162
|
-
),
|
|
223
|
+
), a(l);
|
|
163
224
|
}
|
|
164
225
|
};
|
|
165
|
-
return window.addEventListener("message",
|
|
166
|
-
window.removeEventListener("message",
|
|
226
|
+
return window.addEventListener("message", t), () => {
|
|
227
|
+
window.removeEventListener("message", t);
|
|
167
228
|
};
|
|
168
229
|
}, []), {
|
|
169
|
-
value:
|
|
170
|
-
setValue:
|
|
230
|
+
value: n,
|
|
231
|
+
setValue: i
|
|
171
232
|
};
|
|
172
233
|
};
|
|
173
234
|
export {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
235
|
+
m as Cabbage,
|
|
236
|
+
b as useCabbageProperties,
|
|
237
|
+
M as useCabbageState
|
|
177
238
|
};
|