cabbage-react 1.0.14 → 1.0.15
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/dist/cabbage/cabbage.d.ts +13 -0
- package/dist/cabbage/cabbage.d.ts.map +1 -1
- package/dist/context/CabbageContext.d.ts +6 -0
- package/dist/context/CabbageContext.d.ts.map +1 -0
- package/dist/hooks/useCabbageState.d.ts +1 -0
- package/dist/hooks/useCabbageState.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +126 -87
- package/package.json +1 -1
|
@@ -21,5 +21,18 @@ export class Cabbage {
|
|
|
21
21
|
static MidiMessageFromHost(statusByte: any, dataByte1: any, dataByte2: any): void;
|
|
22
22
|
static triggerFileOpenDialog(vscode: any, channel: any, options?: {}): void;
|
|
23
23
|
static openUrl(vscode: any, url: any, file: any): void;
|
|
24
|
+
/**
|
|
25
|
+
* Request a resize of the plugin GUI window.
|
|
26
|
+
* This is only supported in plugin mode (CLAP/VST3/AUv2).
|
|
27
|
+
* The host may accept or reject the resize request.
|
|
28
|
+
*
|
|
29
|
+
* @param {number} width - The requested width in pixels
|
|
30
|
+
* @param {number} height - The requested height in pixels
|
|
31
|
+
* @param {object} vscode - The vscode API object (null for plugin mode)
|
|
32
|
+
*
|
|
33
|
+
* The response will be sent via hostMessageCallback with:
|
|
34
|
+
* {command: "resizeResponse", accepted: boolean, width: number, height: number}
|
|
35
|
+
*/
|
|
36
|
+
static requestResize(width: number, height: number, vscode?: object): void;
|
|
24
37
|
}
|
|
25
38
|
//# sourceMappingURL=cabbage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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
|
+
{"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;IAED;;;;;;;;;;;OAWG;IACH,4BAPW,MAAM,UACN,MAAM,WACN,MAAM,QA4BhB;CACD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CabbageContext.d.ts","sourceRoot":"","sources":["../../src/context/CabbageContext.ts"],"names":[],"mappings":"AAEA,UAAU,cAAc;IACvB,OAAO,EAAE,OAAO,CAAC;CACjB;AAED,eAAO,MAAM,cAAc,yCAEzB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCabbageState.d.ts","sourceRoot":"","sources":["../../src/hooks/useCabbageState.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCabbageState.d.ts","sourceRoot":"","sources":["../../src/hooks/useCabbageState.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,CAAC,aAAa,MAAM;;sBAQjB,CAAC;;CA0GnC,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"),C=c.createContext({devMode:!1});console.log("Cabbage: loading cabbage.js");class f{static sendChannelUpdate(e,a=null,n=!1){if(n===!0||n===1)f.sendParameterUpdate(e,a);else{const s=e.value!==void 0?e.value:e.stringData||e.floatData;f.sendChannelData(e.channel,s,a)}}static sendParameterUpdate(e,a=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 n={command:"parameterChange",paramIdx:e.paramIdx,channel:e.channel,value:e.value,channelType:e.channelType||"number"};a!==null?a.postMessage(n):typeof window.sendMessageFromUI=="function"?window.sendMessageFromUI(n):console.error("Cabbage: window.sendMessageFromUI is not available. Message:",n)}static sendCustomCommand(e,a=null,n={}){const s={command:e,text:JSON.stringify(n)};if(a!==null)a.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,a=null){const n={command:"widgetStateUpdate",obj:JSON.stringify(CabbageUtils.sanitizeForEditor(e))};a!==null?a.postMessage(n):typeof window.sendMessageFromUI=="function"?window.sendMessageFromUI(n):console.error("Cabbage: window.sendMessageFromUI is not available. Message:",n)}static sendMidiMessageFromUI(e,a,n,s=null){var o={statusByte:e,dataByte1:a,dataByte2:n};const l={command:"midiMessage",obj:JSON.stringify(o)};s!==null?s.postMessage(l):typeof window.sendMessageFromUI=="function"?window.sendMessageFromUI(l):console.error("Cabbage: window.sendMessageFromUI is not available. Message:",l)}static sendChannelData(e,a,n=null){var s={channel:e};if(typeof a=="string")s.stringData=a;else if(typeof a=="number")s.floatData=a;else{console.warn("Cabbage: sendChannelData received unsupported data type:",typeof a);return}const o={command:"channelData",obj:JSON.stringify(s)};console.log("Cabbage: sending channel data from UI",s),n!==null?n.postMessage(o):typeof window.sendMessageFromUI=="function"?window.sendMessageFromUI(o):console.error("Cabbage: window.sendMessageFromUI is not available. Message:",o)}static MidiMessageFromHost(e,a,n){console.log("Cabbage: Got MIDI Message"+e+":"+a+":"+n)}static triggerFileOpenDialog(e,a,n={}){var s={channel:a,directory:n.directory||"",filters:n.filters||"*",openAtLastKnownLocation:n.openAtLastKnownLocation!==void 0?n.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,a,n){var s={url:a,file:n};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)}static requestResize(e,a,n=null){const s={command:"requestResize",width:e,height:a};if(n!==null){console.warn("Cabbage: requestResize is not supported in VS Code extension mode");return}else typeof window.sendMessageFromUI=="function"?window.sendMessageFromUI(s):console.error("Cabbage: window.sendMessageFromUI is not available. Message:",s)}}const I=i=>{const[e,a]=c.useState();return c.useEffect(()=>{const n=s=>{const{id:o,widgetJson:l,command:b}=s.data;if(o===i&&l&&b==="widgetUpdate"){const t=JSON.parse(l);console.log(`[Cabbage-React] Received properties for channelId ${o}`,t),a(t)}};return window.addEventListener("message",n),()=>{window.removeEventListener("message",n)}},[]),{properties:e}},U=i=>{const{devMode:e}=c.useContext(C),{properties:a}=I(i),[n,s]=c.useState(),[o,l]=c.useState(),b=t=>{if(e)s(t);else{if(o===void 0){console.warn(`[Cabbage-React] parameterIndex not ready for "${i}"`);return}const d={channel:i,paramIdx:o,value:t};f.sendParameterUpdate(d,null)}};return c.useEffect(()=>{var r;const t=a==null?void 0:a.channels.find(g=>g.id===i);if(!t)return;const d=t==null?void 0:t.parameterIndex;o===void 0&&d!==void 0&&(console.log(`[Cabbage-React] Received parameterIndex for channelId "${t.id}"`,d),l(d));const m=a==null?void 0:a.value;m!=null&&(console.log(`[Cabbage-React] Received initial value for channelId "${i}"`,m),s(m));const u=(r=t.range)==null?void 0:r.defaultValue;n===void 0&&u!==void 0&&(console.log(`[Cabbage-React] Received default value for channelId "${t.id}"`,u),s(u))},[a]),c.useEffect(()=>{const t=d=>{var u;const{command:m}=d.data;if(m==="parameterChange"){const{value:r,paramIdx:g}=d.data.data;if(g!==o||r===null)return;console.log(`[Cabbage-React] Received parameterChange for parameterIndex ${g}`,r),s(r)}else if(m==="batchWidgetUpdate"){const r=d.data.widgets,g=r==null?void 0:r.find(p=>p.id===i);if(!g)return;const w=JSON.parse(g.widgetJson).channels.find(p=>p.id===i),M=(u=w==null?void 0:w.range)==null?void 0:u.value;console.log(`[Cabbage-React] Received batch widget update for channelId ${g.id}`,M),s(M)}};return window.addEventListener("message",t),()=>{window.removeEventListener("message",t)}},[o]),{value:n,setValue:b,parameterIndex:o}};exports.Cabbage=f;exports.CabbageContext=C;exports.useCabbageProperties=I;exports.useCabbageState=U;
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import { useState as
|
|
1
|
+
import { createContext as C, useState as p, useEffect as M, useContext as U } from "react";
|
|
2
|
+
const F = C({
|
|
3
|
+
devMode: !1
|
|
4
|
+
});
|
|
2
5
|
console.log("Cabbage: loading cabbage.js");
|
|
3
6
|
class f {
|
|
4
7
|
/**
|
|
@@ -14,15 +17,15 @@ class f {
|
|
|
14
17
|
* All widget interactions should use this function instead of calling the lower-level
|
|
15
18
|
* sendParameterUpdate or sendChannelData functions directly.
|
|
16
19
|
*/
|
|
17
|
-
static sendChannelUpdate(e,
|
|
18
|
-
if (
|
|
19
|
-
f.sendParameterUpdate(e,
|
|
20
|
+
static sendChannelUpdate(e, a = null, n = !1) {
|
|
21
|
+
if (n === !0 || n === 1)
|
|
22
|
+
f.sendParameterUpdate(e, a);
|
|
20
23
|
else {
|
|
21
24
|
const s = e.value !== void 0 ? e.value : e.stringData || e.floatData;
|
|
22
|
-
f.sendChannelData(e.channel, s,
|
|
25
|
+
f.sendChannelData(e.channel, s, a);
|
|
23
26
|
}
|
|
24
27
|
}
|
|
25
|
-
static sendParameterUpdate(e,
|
|
28
|
+
static sendParameterUpdate(e, a = null) {
|
|
26
29
|
if (e.paramIdx === void 0 || e.paramIdx === null) {
|
|
27
30
|
console.error(
|
|
28
31
|
"Cabbage.sendParameterUpdate: message missing paramIdx!",
|
|
@@ -37,25 +40,25 @@ class f {
|
|
|
37
40
|
);
|
|
38
41
|
return;
|
|
39
42
|
}
|
|
40
|
-
const
|
|
43
|
+
const n = {
|
|
41
44
|
command: "parameterChange",
|
|
42
45
|
paramIdx: e.paramIdx,
|
|
43
46
|
channel: e.channel,
|
|
44
47
|
value: e.value,
|
|
45
48
|
channelType: e.channelType || "number"
|
|
46
49
|
};
|
|
47
|
-
|
|
50
|
+
a !== null ? a.postMessage(n) : typeof window.sendMessageFromUI == "function" ? window.sendMessageFromUI(n) : console.error(
|
|
48
51
|
"Cabbage: window.sendMessageFromUI is not available. Message:",
|
|
49
|
-
|
|
52
|
+
n
|
|
50
53
|
);
|
|
51
54
|
}
|
|
52
|
-
static sendCustomCommand(e,
|
|
55
|
+
static sendCustomCommand(e, a = null, n = {}) {
|
|
53
56
|
const s = {
|
|
54
57
|
command: e,
|
|
55
|
-
text: JSON.stringify(
|
|
58
|
+
text: JSON.stringify(n)
|
|
56
59
|
};
|
|
57
|
-
if (
|
|
58
|
-
|
|
60
|
+
if (a !== null)
|
|
61
|
+
a.postMessage(s);
|
|
59
62
|
else if (typeof window.sendMessageFromUI == "function") {
|
|
60
63
|
console.log("Cabbage: Calling window.sendMessageFromUI with:", s);
|
|
61
64
|
try {
|
|
@@ -76,21 +79,21 @@ class f {
|
|
|
76
79
|
window.sendMessageFromUI
|
|
77
80
|
);
|
|
78
81
|
}
|
|
79
|
-
static sendWidgetUpdate(e,
|
|
80
|
-
const
|
|
82
|
+
static sendWidgetUpdate(e, a = null) {
|
|
83
|
+
const n = {
|
|
81
84
|
command: "widgetStateUpdate",
|
|
82
85
|
obj: JSON.stringify(CabbageUtils.sanitizeForEditor(e))
|
|
83
86
|
};
|
|
84
|
-
|
|
87
|
+
a !== null ? a.postMessage(n) : typeof window.sendMessageFromUI == "function" ? window.sendMessageFromUI(n) : console.error(
|
|
85
88
|
"Cabbage: window.sendMessageFromUI is not available. Message:",
|
|
86
|
-
|
|
89
|
+
n
|
|
87
90
|
);
|
|
88
91
|
}
|
|
89
|
-
static sendMidiMessageFromUI(e,
|
|
92
|
+
static sendMidiMessageFromUI(e, a, n, s = null) {
|
|
90
93
|
var o = {
|
|
91
94
|
statusByte: e,
|
|
92
|
-
dataByte1:
|
|
93
|
-
dataByte2:
|
|
95
|
+
dataByte1: a,
|
|
96
|
+
dataByte2: n
|
|
94
97
|
};
|
|
95
98
|
const l = {
|
|
96
99
|
command: "midiMessage",
|
|
@@ -101,18 +104,18 @@ class f {
|
|
|
101
104
|
l
|
|
102
105
|
);
|
|
103
106
|
}
|
|
104
|
-
static sendChannelData(e,
|
|
107
|
+
static sendChannelData(e, a, n = null) {
|
|
105
108
|
var s = {
|
|
106
109
|
channel: e
|
|
107
110
|
};
|
|
108
|
-
if (typeof
|
|
109
|
-
s.stringData =
|
|
110
|
-
else if (typeof
|
|
111
|
-
s.floatData =
|
|
111
|
+
if (typeof a == "string")
|
|
112
|
+
s.stringData = a;
|
|
113
|
+
else if (typeof a == "number")
|
|
114
|
+
s.floatData = a;
|
|
112
115
|
else {
|
|
113
116
|
console.warn(
|
|
114
117
|
"Cabbage: sendChannelData received unsupported data type:",
|
|
115
|
-
typeof
|
|
118
|
+
typeof a
|
|
116
119
|
);
|
|
117
120
|
return;
|
|
118
121
|
}
|
|
@@ -120,22 +123,22 @@ class f {
|
|
|
120
123
|
command: "channelData",
|
|
121
124
|
obj: JSON.stringify(s)
|
|
122
125
|
};
|
|
123
|
-
console.log("Cabbage: sending channel data from UI", s),
|
|
126
|
+
console.log("Cabbage: sending channel data from UI", s), n !== null ? n.postMessage(o) : typeof window.sendMessageFromUI == "function" ? window.sendMessageFromUI(o) : console.error(
|
|
124
127
|
"Cabbage: window.sendMessageFromUI is not available. Message:",
|
|
125
128
|
o
|
|
126
129
|
);
|
|
127
130
|
}
|
|
128
|
-
static MidiMessageFromHost(e,
|
|
131
|
+
static MidiMessageFromHost(e, a, n) {
|
|
129
132
|
console.log(
|
|
130
|
-
"Cabbage: Got MIDI Message" + e + ":" +
|
|
133
|
+
"Cabbage: Got MIDI Message" + e + ":" + a + ":" + n
|
|
131
134
|
);
|
|
132
135
|
}
|
|
133
|
-
static triggerFileOpenDialog(e,
|
|
136
|
+
static triggerFileOpenDialog(e, a, n = {}) {
|
|
134
137
|
var s = {
|
|
135
|
-
channel:
|
|
136
|
-
directory:
|
|
137
|
-
filters:
|
|
138
|
-
openAtLastKnownLocation:
|
|
138
|
+
channel: a,
|
|
139
|
+
directory: n.directory || "",
|
|
140
|
+
filters: n.filters || "*",
|
|
141
|
+
openAtLastKnownLocation: n.openAtLastKnownLocation !== void 0 ? n.openAtLastKnownLocation : !0
|
|
139
142
|
};
|
|
140
143
|
const o = {
|
|
141
144
|
command: "fileOpen",
|
|
@@ -146,10 +149,10 @@ class f {
|
|
|
146
149
|
o
|
|
147
150
|
);
|
|
148
151
|
}
|
|
149
|
-
static openUrl(e,
|
|
152
|
+
static openUrl(e, a, n) {
|
|
150
153
|
var s = {
|
|
151
|
-
url:
|
|
152
|
-
file:
|
|
154
|
+
url: a,
|
|
155
|
+
file: n
|
|
153
156
|
};
|
|
154
157
|
const o = {
|
|
155
158
|
command: "openUrl",
|
|
@@ -160,90 +163,126 @@ class f {
|
|
|
160
163
|
o
|
|
161
164
|
);
|
|
162
165
|
}
|
|
166
|
+
/**
|
|
167
|
+
* Request a resize of the plugin GUI window.
|
|
168
|
+
* This is only supported in plugin mode (CLAP/VST3/AUv2).
|
|
169
|
+
* The host may accept or reject the resize request.
|
|
170
|
+
*
|
|
171
|
+
* @param {number} width - The requested width in pixels
|
|
172
|
+
* @param {number} height - The requested height in pixels
|
|
173
|
+
* @param {object} vscode - The vscode API object (null for plugin mode)
|
|
174
|
+
*
|
|
175
|
+
* The response will be sent via hostMessageCallback with:
|
|
176
|
+
* {command: "resizeResponse", accepted: boolean, width: number, height: number}
|
|
177
|
+
*/
|
|
178
|
+
static requestResize(e, a, n = null) {
|
|
179
|
+
const s = {
|
|
180
|
+
command: "requestResize",
|
|
181
|
+
width: e,
|
|
182
|
+
height: a
|
|
183
|
+
};
|
|
184
|
+
if (n !== null) {
|
|
185
|
+
console.warn(
|
|
186
|
+
"Cabbage: requestResize is not supported in VS Code extension mode"
|
|
187
|
+
);
|
|
188
|
+
return;
|
|
189
|
+
} else
|
|
190
|
+
typeof window.sendMessageFromUI == "function" ? window.sendMessageFromUI(s) : console.error(
|
|
191
|
+
"Cabbage: window.sendMessageFromUI is not available. Message:",
|
|
192
|
+
s
|
|
193
|
+
);
|
|
194
|
+
}
|
|
163
195
|
}
|
|
164
|
-
const
|
|
165
|
-
const [e,
|
|
166
|
-
return
|
|
167
|
-
const
|
|
168
|
-
const { id: o, widgetJson: l, command:
|
|
169
|
-
if (o ===
|
|
170
|
-
const
|
|
196
|
+
const v = (i) => {
|
|
197
|
+
const [e, a] = p();
|
|
198
|
+
return M(() => {
|
|
199
|
+
const n = (s) => {
|
|
200
|
+
const { id: o, widgetJson: l, command: u } = s.data;
|
|
201
|
+
if (o === i && l && u === "widgetUpdate") {
|
|
202
|
+
const t = JSON.parse(l);
|
|
171
203
|
console.log(
|
|
172
204
|
`[Cabbage-React] Received properties for channelId ${o}`,
|
|
173
|
-
|
|
174
|
-
),
|
|
205
|
+
t
|
|
206
|
+
), a(t);
|
|
175
207
|
}
|
|
176
208
|
};
|
|
177
|
-
return window.addEventListener("message",
|
|
178
|
-
window.removeEventListener("message",
|
|
209
|
+
return window.addEventListener("message", n), () => {
|
|
210
|
+
window.removeEventListener("message", n);
|
|
179
211
|
};
|
|
180
212
|
}, []), {
|
|
181
213
|
properties: e
|
|
182
214
|
};
|
|
183
|
-
},
|
|
184
|
-
const {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
215
|
+
}, x = (i) => {
|
|
216
|
+
const { devMode: e } = U(F), { properties: a } = v(i), [n, s] = p(), [o, l] = p(), u = (t) => {
|
|
217
|
+
if (e)
|
|
218
|
+
s(t);
|
|
219
|
+
else {
|
|
220
|
+
if (o === void 0) {
|
|
221
|
+
console.warn(
|
|
222
|
+
`[Cabbage-React] parameterIndex not ready for "${i}"`
|
|
223
|
+
);
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
const d = { channel: i, paramIdx: o, value: t };
|
|
227
|
+
f.sendParameterUpdate(d, null);
|
|
228
|
+
}
|
|
192
229
|
};
|
|
193
|
-
return
|
|
194
|
-
var
|
|
195
|
-
const t =
|
|
196
|
-
(g) => g.id ===
|
|
230
|
+
return M(() => {
|
|
231
|
+
var r;
|
|
232
|
+
const t = a == null ? void 0 : a.channels.find(
|
|
233
|
+
(g) => g.id === i
|
|
197
234
|
);
|
|
198
235
|
if (!t) return;
|
|
199
|
-
const
|
|
200
|
-
|
|
236
|
+
const d = t == null ? void 0 : t.parameterIndex;
|
|
237
|
+
o === void 0 && d !== void 0 && (console.log(
|
|
201
238
|
`[Cabbage-React] Received parameterIndex for channelId "${t.id}"`,
|
|
202
|
-
|
|
203
|
-
),
|
|
204
|
-
const c =
|
|
239
|
+
d
|
|
240
|
+
), l(d));
|
|
241
|
+
const c = a == null ? void 0 : a.value;
|
|
205
242
|
c != null && (console.log(
|
|
206
|
-
`[Cabbage-React] Received initial value for channelId "${
|
|
243
|
+
`[Cabbage-React] Received initial value for channelId "${i}"`,
|
|
207
244
|
c
|
|
208
|
-
),
|
|
209
|
-
const m = (
|
|
245
|
+
), s(c));
|
|
246
|
+
const m = (r = t.range) == null ? void 0 : r.defaultValue;
|
|
210
247
|
n === void 0 && m !== void 0 && (console.log(
|
|
211
248
|
`[Cabbage-React] Received default value for channelId "${t.id}"`,
|
|
212
249
|
m
|
|
213
|
-
),
|
|
214
|
-
}, [
|
|
215
|
-
const t = (
|
|
250
|
+
), s(m));
|
|
251
|
+
}, [a]), M(() => {
|
|
252
|
+
const t = (d) => {
|
|
216
253
|
var m;
|
|
217
|
-
const { command: c } =
|
|
254
|
+
const { command: c } = d.data;
|
|
218
255
|
if (c === "parameterChange") {
|
|
219
|
-
const { value:
|
|
220
|
-
if (g !==
|
|
256
|
+
const { value: r, paramIdx: g } = d.data.data;
|
|
257
|
+
if (g !== o || r === null) return;
|
|
221
258
|
console.log(
|
|
222
259
|
`[Cabbage-React] Received parameterChange for parameterIndex ${g}`,
|
|
223
|
-
|
|
224
|
-
),
|
|
260
|
+
r
|
|
261
|
+
), s(r);
|
|
225
262
|
} else if (c === "batchWidgetUpdate") {
|
|
226
|
-
const
|
|
263
|
+
const r = d.data.widgets, g = r == null ? void 0 : r.find((b) => b.id === i);
|
|
227
264
|
if (!g) return;
|
|
228
|
-
const
|
|
229
|
-
(
|
|
230
|
-
),
|
|
265
|
+
const w = JSON.parse(g.widgetJson).channels.find(
|
|
266
|
+
(b) => b.id === i
|
|
267
|
+
), I = (m = w == null ? void 0 : w.range) == null ? void 0 : m.value;
|
|
231
268
|
console.log(
|
|
232
269
|
`[Cabbage-React] Received batch widget update for channelId ${g.id}`,
|
|
233
|
-
|
|
234
|
-
),
|
|
270
|
+
I
|
|
271
|
+
), s(I);
|
|
235
272
|
}
|
|
236
273
|
};
|
|
237
274
|
return window.addEventListener("message", t), () => {
|
|
238
275
|
window.removeEventListener("message", t);
|
|
239
276
|
};
|
|
240
|
-
}, [
|
|
277
|
+
}, [o]), {
|
|
241
278
|
value: n,
|
|
242
|
-
setValue:
|
|
279
|
+
setValue: u,
|
|
280
|
+
parameterIndex: o
|
|
243
281
|
};
|
|
244
282
|
};
|
|
245
283
|
export {
|
|
246
284
|
f as Cabbage,
|
|
247
|
-
|
|
248
|
-
|
|
285
|
+
F as CabbageContext,
|
|
286
|
+
v as useCabbageProperties,
|
|
287
|
+
x as useCabbageState
|
|
249
288
|
};
|