cabbage-react 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -13
- package/dist/cabbage/cabbage.d.ts +17 -1
- package/dist/cabbage/cabbage.d.ts.map +1 -1
- package/dist/hooks/useCabbageProperties.d.ts +1 -1
- package/dist/hooks/useCabbageProperties.d.ts.map +1 -1
- package/dist/hooks/useCabbageState.d.ts +1 -1
- package/dist/hooks/useCabbageState.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +137 -92
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,8 +20,10 @@ npm install cabbage-react
|
|
|
20
20
|
|
|
21
21
|
Synchronize a parameter with Cabbage. This hook:
|
|
22
22
|
|
|
23
|
-
-
|
|
24
|
-
-
|
|
23
|
+
- Identifies and sets the default value defined in Cabbage to the state.
|
|
24
|
+
- Handles initialization when opening an existing session, or reopening the plugin window.
|
|
25
|
+
- Listens for value updates from the host (DAW), or from Csound.
|
|
26
|
+
- Sends changes back to Cabbage when using the provided value-setter.
|
|
25
27
|
|
|
26
28
|
### useCabbageProperties
|
|
27
29
|
|
|
@@ -33,21 +35,28 @@ This hook:
|
|
|
33
35
|
|
|
34
36
|
## Usage
|
|
35
37
|
|
|
36
|
-
```
|
|
38
|
+
```tsx
|
|
37
39
|
import { InputHTMLAttributes } from "react";
|
|
38
40
|
import { useCabbageProperties, useCabbageState } from "cabbage-react";
|
|
39
41
|
|
|
40
42
|
const HorizontalSlider = ({
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
channelId,
|
|
44
|
+
parameterIndex,
|
|
43
45
|
inputProps,
|
|
44
46
|
}: {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
inputProps?: InputHTMLAttributes<HTMLInputElement
|
|
47
|
+
channelId: string;
|
|
48
|
+
parameterIndex: number;
|
|
49
|
+
inputProps?: InputHTMLAttributes<HTMLInputElement>;
|
|
48
50
|
}) => {
|
|
49
|
-
const { properties } = useCabbageProperties(
|
|
50
|
-
const
|
|
51
|
+
const { properties } = useCabbageProperties(channelId);
|
|
52
|
+
const channelProperties = properties?.channels.find(
|
|
53
|
+
(c: any) => c.id === channelId
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
const { value, setValue } = useCabbageState<number>(
|
|
57
|
+
channelId,
|
|
58
|
+
parameterIndex
|
|
59
|
+
);
|
|
51
60
|
|
|
52
61
|
return (
|
|
53
62
|
<div>
|
|
@@ -56,9 +65,9 @@ const HorizontalSlider = ({
|
|
|
56
65
|
|
|
57
66
|
<input
|
|
58
67
|
type="range"
|
|
59
|
-
min={
|
|
60
|
-
max={
|
|
61
|
-
step={
|
|
68
|
+
min={channelProperties?.range?.min ?? 0}
|
|
69
|
+
max={channelProperties?.range?.max ?? 1}
|
|
70
|
+
step={channelProperties?.range?.increment ?? 0.01}
|
|
62
71
|
value={value}
|
|
63
72
|
onChange={(e) => setValue(e.target.valueAsNumber)}
|
|
64
73
|
{...inputProps}
|
|
@@ -1,9 +1,25 @@
|
|
|
1
1
|
export class Cabbage {
|
|
2
|
+
/**
|
|
3
|
+
* Main entry point for sending any data from UI widgets to the Cabbage backend.
|
|
4
|
+
* This function automatically routes messages to the appropriate backend function
|
|
5
|
+
* based on the automatable flag:
|
|
6
|
+
*
|
|
7
|
+
* - automatable=1: Routes to sendParameterUpdate for real-time parameter control /
|
|
8
|
+
* this also sends the value as channel data to Csound
|
|
9
|
+
*
|
|
10
|
+
* - automatable=0: Routes to sendChannelData for string/numeric data transmission
|
|
11
|
+
*
|
|
12
|
+
* All widget interactions should use this function instead of calling the lower-level
|
|
13
|
+
* sendParameterUpdate or sendChannelData functions directly.
|
|
14
|
+
*/
|
|
15
|
+
static sendChannelUpdate(message: any, vscode?: null, automatable?: number): void;
|
|
2
16
|
static sendParameterUpdate(message: any, vscode?: null): void;
|
|
3
17
|
static sendCustomCommand(command: any, vscode?: null): void;
|
|
4
18
|
static sendWidgetUpdate(widget: any, vscode?: null): void;
|
|
5
19
|
static sendMidiMessageFromUI(statusByte: any, dataByte1: any, dataByte2: any, vscode?: null): void;
|
|
20
|
+
static sendChannelData(channel: any, data: any, vscode?: null): void;
|
|
6
21
|
static MidiMessageFromHost(statusByte: any, dataByte1: any, dataByte2: any): void;
|
|
7
|
-
static triggerFileOpenDialog(vscode: any, channel: any): void;
|
|
22
|
+
static triggerFileOpenDialog(vscode: any, channel: any, options?: {}): void;
|
|
23
|
+
static openUrl(vscode: any, url: any, file: any): void;
|
|
8
24
|
}
|
|
9
25
|
//# sourceMappingURL=cabbage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cabbage.d.ts","sourceRoot":"","sources":["../../src/cabbage/cabbage.js"],"names":[],"mappings":"AAMA;IAEE,
|
|
1
|
+
{"version":3,"file":"cabbage.d.ts","sourceRoot":"","sources":["../../src/cabbage/cabbage.js"],"names":[],"mappings":"AAMA;IAEE;;;;;;;;;;;;OAYG;IACH,kFASC;IAED,8DAcC;IAED,4DAYC;IAED,0DAYC;IAED,mGAmBC;IAED,qEA2BC;IAED,kFAEC;IAED,4EAkBC;IAED,uDAgBC;CAGF"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* This hook listens for updates to parameter properties via Cabbage and updates the local state
|
|
4
4
|
* whenever new data is received.
|
|
5
5
|
*/
|
|
6
|
-
export declare const useCabbageProperties: (
|
|
6
|
+
export declare const useCabbageProperties: (channelId: string) => {
|
|
7
7
|
properties: Record<string, any> | undefined;
|
|
8
8
|
};
|
|
9
9
|
//# sourceMappingURL=useCabbageProperties.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCabbageProperties.d.ts","sourceRoot":"","sources":["../../src/hooks/useCabbageProperties.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,
|
|
1
|
+
{"version":3,"file":"useCabbageProperties.d.ts","sourceRoot":"","sources":["../../src/hooks/useCabbageProperties.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,cAAe,MAAM;;CAgCrD,CAAC"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* This hook listens for updates to a parameter value from Cabbage and
|
|
4
4
|
* sends updates to Cabbage when the parameter value changes locally (e.g., through a UI slider).
|
|
5
5
|
*/
|
|
6
|
-
export declare const useCabbageState: <T>(
|
|
6
|
+
export declare const useCabbageState: <T>(channelId: string, parameterIndex: number) => {
|
|
7
7
|
value: T | undefined;
|
|
8
8
|
setValue: (newValue: T) => void;
|
|
9
9
|
};
|
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"useCabbageState.d.ts","sourceRoot":"","sources":["../../src/hooks/useCabbageState.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,CAAC,aACrB,MAAM,kBACD,MAAM;;yBAMe,CAAC;CA6EtC,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 g=require("react");console.log("Cabbage: loading cabbage.js");class c{static sendChannelUpdate(n,e=null,a=0){if(a===1)c.sendParameterUpdate(n,e);else{const s=n.value!==void 0?n.value:n.stringData||n.floatData;c.sendChannelData(n.channel,s,e)}}static sendParameterUpdate(n,e=null){const a={command:"parameterChange",...n};console.log("Cabbage.sendParameterUpdate:",n,"vscode:",e,"msg:",a),e!==null?(console.log("Sending via vscode.postMessage"),e.postMessage(a)):(console.log("Sending via window.sendMessageFromUI"),window.sendMessageFromUI(a))}static sendCustomCommand(n,e=null){const a={command:n,text:JSON.stringify({})};console.log("Cabbage: sending custom command from UI",a),e!==null?e.postMessage(a):window.sendMessageFromUI(a)}static sendWidgetUpdate(n,e=null){console.log("Cabbage: sending widget update from UI",n.props);const a={command:"widgetStateUpdate",obj:JSON.stringify(CabbageUtils.sanitizeForEditor(n))};e!==null?e.postMessage(a):window.sendMessageFromUI(a)}static sendMidiMessageFromUI(n,e,a,s=null){var t={statusByte:n,dataByte1:e,dataByte2:a};const o={command:"midiMessage",obj:JSON.stringify(t)};console.log("Cabbage: sending midi message from UI",t),s!==null?s.postMessage(o):window.sendMessageFromUI(o)}static sendChannelData(n,e,a=null){var s={channel:n};if(typeof e=="string")s.stringData=e;else if(typeof e=="number")s.floatData=e;else{console.warn("Cabbage: sendChannelData received unsupported data type:",typeof e);return}const t={command:"channelData",obj:JSON.stringify(s)};console.log("Cabbage: sending channel data from UI",s),a!==null?a.postMessage(t):window.sendMessageFromUI(t)}static MidiMessageFromHost(n,e,a){console.log("Cabbage: Got MIDI Message"+n+":"+e+":"+a)}static triggerFileOpenDialog(n,e,a={}){var s={channel:e,directory:a.directory||"",filters:a.filters||"*",openAtLastKnownLocation:a.openAtLastKnownLocation!==void 0?a.openAtLastKnownLocation:!0};const t={command:"fileOpen",obj:JSON.stringify(s)};n!==null?n.postMessage(t):window.sendMessageFromUI(t)}static openUrl(n,e,a){var s={url:e,file:a};const t={command:"openUrl",obj:JSON.stringify(s)};n!==null?n.postMessage(t):window.sendMessageFromUI(t)}}const u=r=>{const[n,e]=g.useState();return g.useEffect(()=>{const a=s=>{const{id:t,widgetJson:o,command:l}=s.data;if(t===r&&o&&l==="widgetUpdate"){const i=JSON.parse(o);console.log(`[Cabbage-React] Received properties for channelId ${t}`,i),e(i)}};return window.addEventListener("message",a),()=>{window.removeEventListener("message",a)}},[]),{properties:n}},f=(r,n)=>{const{properties:e}=u(r),[a,s]=g.useState(),t=o=>{s(o);const l={paramIdx:n,channel:r,value:o};c.sendParameterUpdate(l,null)};return g.useEffect(()=>{var d;const o=e==null?void 0:e.value;if(o!=null){console.log(`[Cabbage-React] Received initial value for channelId "${r}"`,o),s(o);return}const l=e==null?void 0:e.channels.find(m=>m.id===r);if(!l)return;const i=(d=l.range)==null?void 0:d.defaultValue;a===void 0&&i!==void 0&&(console.log(`[Cabbage-React] Received default value for channelId "${l.id}"`,i),s(i))},[e]),g.useEffect(()=>{const o=l=>{const{command:i}=l.data;if(i==="parameterChange"){const{value:d,paramIdx:m}=l.data;if(m!==n||d===null)return;console.log(`[Cabbage-React] Received value change for parameterIndex ${m}`,d),s(d)}};return window.addEventListener("message",o),()=>{window.removeEventListener("message",o)}},[]),{value:a,setValue:t}};exports.Cabbage=c;exports.useCabbageProperties=u;exports.useCabbageState=f;
|
package/dist/index.mjs
CHANGED
|
@@ -1,132 +1,177 @@
|
|
|
1
|
-
import { useState as
|
|
1
|
+
import { useState as u, useEffect as m } from "react";
|
|
2
2
|
console.log("Cabbage: loading cabbage.js");
|
|
3
|
-
class
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
class c {
|
|
4
|
+
/**
|
|
5
|
+
* Main entry point for sending any data from UI widgets to the Cabbage backend.
|
|
6
|
+
* This function automatically routes messages to the appropriate backend function
|
|
7
|
+
* based on the automatable flag:
|
|
8
|
+
*
|
|
9
|
+
* - automatable=1: Routes to sendParameterUpdate for real-time parameter control /
|
|
10
|
+
* this also sends the value as channel data to Csound
|
|
11
|
+
*
|
|
12
|
+
* - automatable=0: Routes to sendChannelData for string/numeric data transmission
|
|
13
|
+
*
|
|
14
|
+
* All widget interactions should use this function instead of calling the lower-level
|
|
15
|
+
* sendParameterUpdate or sendChannelData functions directly.
|
|
16
|
+
*/
|
|
17
|
+
static sendChannelUpdate(a, e = null, n = 0) {
|
|
18
|
+
if (n === 1)
|
|
19
|
+
c.sendParameterUpdate(a, e);
|
|
20
|
+
else {
|
|
21
|
+
const s = a.value !== void 0 ? a.value : a.stringData || a.floatData;
|
|
22
|
+
c.sendChannelData(a.channel, s, e);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
static sendParameterUpdate(a, e = null) {
|
|
26
|
+
const n = {
|
|
6
27
|
command: "parameterChange",
|
|
7
|
-
|
|
28
|
+
...a
|
|
8
29
|
};
|
|
9
|
-
e !== null ? e.postMessage(
|
|
30
|
+
console.log("Cabbage.sendParameterUpdate:", a, "vscode:", e, "msg:", n), e !== null ? (console.log("Sending via vscode.postMessage"), e.postMessage(n)) : (console.log("Sending via window.sendMessageFromUI"), window.sendMessageFromUI(n));
|
|
10
31
|
}
|
|
11
|
-
static sendCustomCommand(
|
|
12
|
-
const
|
|
13
|
-
command:
|
|
32
|
+
static sendCustomCommand(a, e = null) {
|
|
33
|
+
const n = {
|
|
34
|
+
command: a,
|
|
14
35
|
text: JSON.stringify({})
|
|
15
36
|
};
|
|
16
|
-
console.log("Cabbage: sending custom command from UI",
|
|
37
|
+
console.log("Cabbage: sending custom command from UI", n), e !== null ? e.postMessage(n) : window.sendMessageFromUI(n);
|
|
17
38
|
}
|
|
18
|
-
static sendWidgetUpdate(
|
|
19
|
-
console.log("Cabbage: sending widget update from UI",
|
|
20
|
-
const
|
|
39
|
+
static sendWidgetUpdate(a, e = null) {
|
|
40
|
+
console.log("Cabbage: sending widget update from UI", a.props);
|
|
41
|
+
const n = {
|
|
21
42
|
command: "widgetStateUpdate",
|
|
22
|
-
obj: JSON.stringify(
|
|
43
|
+
obj: JSON.stringify(CabbageUtils.sanitizeForEditor(a))
|
|
23
44
|
};
|
|
24
|
-
e !== null ? e.postMessage(
|
|
45
|
+
e !== null ? e.postMessage(n) : window.sendMessageFromUI(n);
|
|
25
46
|
}
|
|
26
|
-
static sendMidiMessageFromUI(
|
|
27
|
-
var
|
|
28
|
-
statusByte:
|
|
47
|
+
static sendMidiMessageFromUI(a, e, n, s = null) {
|
|
48
|
+
var t = {
|
|
49
|
+
statusByte: a,
|
|
29
50
|
dataByte1: e,
|
|
30
|
-
dataByte2:
|
|
51
|
+
dataByte2: n
|
|
31
52
|
};
|
|
32
53
|
const o = {
|
|
33
54
|
command: "midiMessage",
|
|
34
|
-
obj: JSON.stringify(
|
|
55
|
+
obj: JSON.stringify(t)
|
|
56
|
+
};
|
|
57
|
+
console.log("Cabbage: sending midi message from UI", t), s !== null ? s.postMessage(o) : window.sendMessageFromUI(o);
|
|
58
|
+
}
|
|
59
|
+
static sendChannelData(a, e, n = null) {
|
|
60
|
+
var s = {
|
|
61
|
+
channel: a
|
|
62
|
+
};
|
|
63
|
+
if (typeof e == "string")
|
|
64
|
+
s.stringData = e;
|
|
65
|
+
else if (typeof e == "number")
|
|
66
|
+
s.floatData = e;
|
|
67
|
+
else {
|
|
68
|
+
console.warn("Cabbage: sendChannelData received unsupported data type:", typeof e);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const t = {
|
|
72
|
+
command: "channelData",
|
|
73
|
+
obj: JSON.stringify(s)
|
|
35
74
|
};
|
|
36
|
-
console.log("Cabbage: sending
|
|
75
|
+
console.log("Cabbage: sending channel data from UI", s), n !== null ? n.postMessage(t) : window.sendMessageFromUI(t);
|
|
37
76
|
}
|
|
38
|
-
static MidiMessageFromHost(
|
|
39
|
-
console.log("Cabbage: Got MIDI Message" +
|
|
77
|
+
static MidiMessageFromHost(a, e, n) {
|
|
78
|
+
console.log("Cabbage: Got MIDI Message" + a + ":" + e + ":" + n);
|
|
40
79
|
}
|
|
41
|
-
static triggerFileOpenDialog(
|
|
42
|
-
var
|
|
43
|
-
channel: e
|
|
80
|
+
static triggerFileOpenDialog(a, e, n = {}) {
|
|
81
|
+
var s = {
|
|
82
|
+
channel: e,
|
|
83
|
+
directory: n.directory || "",
|
|
84
|
+
filters: n.filters || "*",
|
|
85
|
+
openAtLastKnownLocation: n.openAtLastKnownLocation !== void 0 ? n.openAtLastKnownLocation : !0
|
|
44
86
|
};
|
|
45
87
|
const t = {
|
|
46
88
|
command: "fileOpen",
|
|
47
|
-
obj: JSON.stringify(
|
|
89
|
+
obj: JSON.stringify(s)
|
|
48
90
|
};
|
|
49
|
-
|
|
91
|
+
a !== null ? a.postMessage(t) : window.sendMessageFromUI(t);
|
|
92
|
+
}
|
|
93
|
+
static openUrl(a, e, n) {
|
|
94
|
+
var s = {
|
|
95
|
+
url: e,
|
|
96
|
+
file: n
|
|
97
|
+
};
|
|
98
|
+
const t = {
|
|
99
|
+
command: "openUrl",
|
|
100
|
+
obj: JSON.stringify(s)
|
|
101
|
+
};
|
|
102
|
+
a !== null ? a.postMessage(t) : window.sendMessageFromUI(t);
|
|
50
103
|
}
|
|
51
104
|
}
|
|
52
|
-
const
|
|
53
|
-
const [
|
|
54
|
-
return
|
|
55
|
-
const
|
|
56
|
-
const {
|
|
57
|
-
if (
|
|
58
|
-
const
|
|
105
|
+
const f = (r) => {
|
|
106
|
+
const [a, e] = u();
|
|
107
|
+
return m(() => {
|
|
108
|
+
const n = (s) => {
|
|
109
|
+
const { id: t, widgetJson: o, command: l } = s.data;
|
|
110
|
+
if (t === r && o && l === "widgetUpdate") {
|
|
111
|
+
const i = JSON.parse(o);
|
|
59
112
|
console.log(
|
|
60
|
-
`[Cabbage-React]
|
|
61
|
-
|
|
62
|
-
), e(
|
|
113
|
+
`[Cabbage-React] Received properties for channelId ${t}`,
|
|
114
|
+
i
|
|
115
|
+
), e(i);
|
|
63
116
|
}
|
|
64
117
|
};
|
|
65
|
-
return window.addEventListener("message",
|
|
66
|
-
window.removeEventListener("message",
|
|
118
|
+
return window.addEventListener("message", n), () => {
|
|
119
|
+
window.removeEventListener("message", n);
|
|
67
120
|
};
|
|
68
121
|
}, []), {
|
|
69
|
-
properties:
|
|
122
|
+
properties: a
|
|
70
123
|
};
|
|
71
|
-
},
|
|
72
|
-
const { properties: e } =
|
|
73
|
-
|
|
74
|
-
const
|
|
75
|
-
paramIdx:
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
C.sendParameterUpdate(i, null);
|
|
81
|
-
}, c = (s) => {
|
|
82
|
-
if (typeof s == "number") return "number";
|
|
83
|
-
if (typeof s == "string") return "string";
|
|
124
|
+
}, b = (r, a) => {
|
|
125
|
+
const { properties: e } = f(r), [n, s] = u(), t = (o) => {
|
|
126
|
+
s(o);
|
|
127
|
+
const l = {
|
|
128
|
+
paramIdx: a,
|
|
129
|
+
channel: r,
|
|
130
|
+
value: o
|
|
131
|
+
};
|
|
132
|
+
c.sendParameterUpdate(l, null);
|
|
84
133
|
};
|
|
85
|
-
return
|
|
86
|
-
var
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
if (a === void 0 && s !== void 0) {
|
|
134
|
+
return m(() => {
|
|
135
|
+
var d;
|
|
136
|
+
const o = e == null ? void 0 : e.value;
|
|
137
|
+
if (o != null) {
|
|
90
138
|
console.log(
|
|
91
|
-
`[Cabbage-React]
|
|
92
|
-
|
|
93
|
-
),
|
|
94
|
-
|
|
95
|
-
r && o(r);
|
|
139
|
+
`[Cabbage-React] Received initial value for channelId "${r}"`,
|
|
140
|
+
o
|
|
141
|
+
), s(o);
|
|
142
|
+
return;
|
|
96
143
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
g
|
|
117
|
-
), t(g));
|
|
144
|
+
const l = e == null ? void 0 : e.channels.find(
|
|
145
|
+
(g) => g.id === r
|
|
146
|
+
);
|
|
147
|
+
if (!l) return;
|
|
148
|
+
const i = (d = l.range) == null ? void 0 : d.defaultValue;
|
|
149
|
+
n === void 0 && i !== void 0 && (console.log(
|
|
150
|
+
`[Cabbage-React] Received default value for channelId "${l.id}"`,
|
|
151
|
+
i
|
|
152
|
+
), s(i));
|
|
153
|
+
}, [e]), m(() => {
|
|
154
|
+
const o = (l) => {
|
|
155
|
+
const { command: i } = l.data;
|
|
156
|
+
if (i === "parameterChange") {
|
|
157
|
+
const { value: d, paramIdx: g } = l.data;
|
|
158
|
+
if (g !== a || d === null) return;
|
|
159
|
+
console.log(
|
|
160
|
+
`[Cabbage-React] Received value change for parameterIndex ${g}`,
|
|
161
|
+
d
|
|
162
|
+
), s(d);
|
|
118
163
|
}
|
|
119
164
|
};
|
|
120
|
-
return window.addEventListener("message",
|
|
121
|
-
window.removeEventListener("message",
|
|
165
|
+
return window.addEventListener("message", o), () => {
|
|
166
|
+
window.removeEventListener("message", o);
|
|
122
167
|
};
|
|
123
168
|
}, []), {
|
|
124
|
-
value:
|
|
125
|
-
setValue:
|
|
169
|
+
value: n,
|
|
170
|
+
setValue: t
|
|
126
171
|
};
|
|
127
172
|
};
|
|
128
173
|
export {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
174
|
+
c as Cabbage,
|
|
175
|
+
f as useCabbageProperties,
|
|
176
|
+
b as useCabbageState
|
|
132
177
|
};
|