cabbage-react 1.0.38 → 1.0.40
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/hooks/useCabbageState.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +89 -84
- package/package.json +1 -1
|
@@ -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;
|
|
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;CAmGnC,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 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 r={command:"midiMessage",obj:JSON.stringify(s)};n!==null?n.postMessage(r):typeof window.sendMessageFromUI=="function"?window.sendMessageFromUI(r):console.error("Cabbage: window.sendMessageFromUI is not available. Message:",r)}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 p=i=>{const[o,e]=g.useState();return g.useEffect(()=>{const a=n=>{const{id:s,widgetJson:r,command:b}=n.data;if(s===i&&r&&b==="widgetUpdate"){const t=JSON.parse(r);console.log(`[Cabbage-React] Received properties for channelId: ${s}`,t),e(t)}};return window.addEventListener("message",a),()=>{window.removeEventListener("message",a)}},[]),{properties:o}},I=(i,o="complete")=>{const{properties:e}=p(i),[a,n]=g.useState(),[s,r]=g.useState(),b=t=>{n(t),C.sendControlData({channel:i,value:t,gesture:o})};return g.useEffect(()=>{var d;const t=e==null?void 0:e.channels.find(l=>l.id===i);if(!t)return;const c=t==null?void 0:t.parameterIndex;s===void 0&&c!==void 0&&(console.log(`[Cabbage-React] Received parameterIndex for channelId: ${t.id}`,c),r(c));const m=e==null?void 0:e.value;m!=null&&(console.log(`[Cabbage-React] Received initial value for channelId: ${i}`,m),n(m));const u=(d=t.range)==null?void 0:d.defaultValue;a===void 0&&u!==void 0&&(console.log(`[Cabbage-React] Received default value for channelId: ${t.id}`,u),n(u))},[e]),g.useEffect(()=>{const t=c=>{var u;const{command:m}=c.data;if(m==="parameterChange"){const{value:d,paramIdx:l}=c.data.data;if(l!==s||d===null)return;console.log(`[Cabbage-React] Received parameterChange for parameterIndex: ${l}`,d),n(d)}else if(m==="batchWidgetUpdate"){const d=c.data.widgets,l=d==null?void 0:d.find(w=>w.id===i);if(!l)return;const f=JSON.parse(l.widgetJson).channels.find(w=>w.id===i),M=(u=f==null?void 0:f.range)==null?void 0:u.value;console.log(`[Cabbage-React] Received batch widget update for channelId: ${l.id}`,M),n(M)}};return window.addEventListener("message",t),()=>{window.removeEventListener("message",t)}},[s]),{value:a,setValue:b}},U=i=>{const[o,e]=g.useState();return g.useEffect(()=>{const a=n=>{const{data:s,type:r}=n;if(s&&r==="message"){if(s.id!==i)return;console.log(`[Cabbage-React] Received data for messageId: ${s.id}`,s),e(s)}};return window.addEventListener("message",a),()=>{window.removeEventListener("message",a)}},[]),{data:o}};exports.Cabbage=C;exports.useCabbageMessage=U;exports.useCabbageProperties=p;exports.useCabbageState=I;
|
package/dist/index.mjs
CHANGED
|
@@ -21,16 +21,16 @@ class C {
|
|
|
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:
|
|
25
|
-
const
|
|
24
|
+
static sendControlData({ channel: o, value: e, gesture: a = "complete" }, n = null) {
|
|
25
|
+
const s = {
|
|
26
26
|
command: "controlData",
|
|
27
27
|
channel: o,
|
|
28
|
-
value:
|
|
28
|
+
value: e,
|
|
29
29
|
gesture: a
|
|
30
30
|
};
|
|
31
|
-
n !== null ? n.postMessage(
|
|
31
|
+
n !== null ? n.postMessage(s) : typeof window.sendMessageFromUI == "function" ? window.sendMessageFromUI(s) : console.error(
|
|
32
32
|
"Cabbage: window.sendMessageFromUI is not available. Message:",
|
|
33
|
-
|
|
33
|
+
s
|
|
34
34
|
);
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
@@ -39,7 +39,7 @@ class C {
|
|
|
39
39
|
* @param {Object|null} vscode - VS Code API object (null for plugin mode)
|
|
40
40
|
* @param {Object} additionalData - Additional initialization data
|
|
41
41
|
*/
|
|
42
|
-
static isReadyToLoad(o = null,
|
|
42
|
+
static isReadyToLoad(o = null, e = {}) {
|
|
43
43
|
this.sendCustomCommand("isReadyToLoad", o);
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
@@ -50,15 +50,15 @@ class C {
|
|
|
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,
|
|
54
|
-
var
|
|
53
|
+
static sendMidiMessageFromUI(o, e, a, n = null) {
|
|
54
|
+
var s = {
|
|
55
55
|
statusByte: o,
|
|
56
|
-
dataByte1:
|
|
56
|
+
dataByte1: e,
|
|
57
57
|
dataByte2: a
|
|
58
58
|
};
|
|
59
59
|
const r = {
|
|
60
60
|
command: "midiMessage",
|
|
61
|
-
obj: JSON.stringify(
|
|
61
|
+
obj: JSON.stringify(s)
|
|
62
62
|
};
|
|
63
63
|
n !== null ? n.postMessage(r) : typeof window.sendMessageFromUI == "function" ? window.sendMessageFromUI(r) : console.error(
|
|
64
64
|
"Cabbage: window.sendMessageFromUI is not available. Message:",
|
|
@@ -72,9 +72,9 @@ class C {
|
|
|
72
72
|
* @param {number} dataByte1 - First MIDI data byte
|
|
73
73
|
* @param {number} dataByte2 - Second MIDI data byte
|
|
74
74
|
*/
|
|
75
|
-
static MidiMessageFromHost(o,
|
|
75
|
+
static MidiMessageFromHost(o, e, a) {
|
|
76
76
|
console.log(
|
|
77
|
-
"Cabbage: Got MIDI Message" + o + ":" +
|
|
77
|
+
"Cabbage: Got MIDI Message" + o + ":" + e + ":" + a
|
|
78
78
|
);
|
|
79
79
|
}
|
|
80
80
|
/**
|
|
@@ -87,20 +87,20 @@ class C {
|
|
|
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,
|
|
90
|
+
static triggerFileOpenDialog(o, e, a = {}) {
|
|
91
91
|
var n = {
|
|
92
|
-
channel:
|
|
92
|
+
channel: e,
|
|
93
93
|
directory: a.directory || "",
|
|
94
94
|
filters: a.filters || "*",
|
|
95
95
|
openAtLastKnownLocation: a.openAtLastKnownLocation !== void 0 ? a.openAtLastKnownLocation : !0
|
|
96
96
|
};
|
|
97
|
-
const
|
|
97
|
+
const s = {
|
|
98
98
|
command: "fileOpen",
|
|
99
99
|
obj: JSON.stringify(n)
|
|
100
100
|
};
|
|
101
|
-
o !== null ? o.postMessage(
|
|
101
|
+
o !== null ? o.postMessage(s) : typeof window.sendMessageFromUI == "function" ? window.sendMessageFromUI(s) : console.error(
|
|
102
102
|
"Cabbage: window.sendMessageFromUI is not available. Message:",
|
|
103
|
-
|
|
103
|
+
s
|
|
104
104
|
);
|
|
105
105
|
}
|
|
106
106
|
/**
|
|
@@ -110,18 +110,18 @@ class C {
|
|
|
110
110
|
* @param {string} url - URL to open
|
|
111
111
|
* @param {string} file - File path to open
|
|
112
112
|
*/
|
|
113
|
-
static openUrl(o,
|
|
113
|
+
static openUrl(o, e, a) {
|
|
114
114
|
var n = {
|
|
115
|
-
url:
|
|
115
|
+
url: e,
|
|
116
116
|
file: a
|
|
117
117
|
};
|
|
118
|
-
const
|
|
118
|
+
const s = {
|
|
119
119
|
command: "openUrl",
|
|
120
120
|
obj: JSON.stringify(n)
|
|
121
121
|
};
|
|
122
|
-
o !== null ? o.postMessage(
|
|
122
|
+
o !== null ? o.postMessage(s) : typeof window.sendMessageFromUI == "function" ? window.sendMessageFromUI(s) : console.error(
|
|
123
123
|
"Cabbage: window.sendMessageFromUI is not available. Message:",
|
|
124
|
-
|
|
124
|
+
s
|
|
125
125
|
);
|
|
126
126
|
}
|
|
127
127
|
/**
|
|
@@ -136,11 +136,11 @@ class C {
|
|
|
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,
|
|
139
|
+
static requestResize(o, e, a = null) {
|
|
140
140
|
const n = {
|
|
141
141
|
command: "requestResize",
|
|
142
142
|
width: o,
|
|
143
|
-
height:
|
|
143
|
+
height: e
|
|
144
144
|
};
|
|
145
145
|
if (a !== null) {
|
|
146
146
|
console.warn(
|
|
@@ -160,28 +160,28 @@ class C {
|
|
|
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,
|
|
163
|
+
static sendChannelData(o, e, a = null) {
|
|
164
164
|
var n = {
|
|
165
165
|
channel: o
|
|
166
166
|
};
|
|
167
|
-
if (typeof
|
|
168
|
-
n.stringData =
|
|
169
|
-
else if (typeof
|
|
170
|
-
n.floatData =
|
|
167
|
+
if (typeof e == "string")
|
|
168
|
+
n.stringData = e;
|
|
169
|
+
else if (typeof e == "number")
|
|
170
|
+
n.floatData = e;
|
|
171
171
|
else {
|
|
172
172
|
console.warn(
|
|
173
173
|
"Cabbage: sendChannelData received unsupported data type:",
|
|
174
|
-
typeof
|
|
174
|
+
typeof e
|
|
175
175
|
);
|
|
176
176
|
return;
|
|
177
177
|
}
|
|
178
|
-
const
|
|
178
|
+
const s = {
|
|
179
179
|
command: "channelData",
|
|
180
180
|
obj: JSON.stringify(n)
|
|
181
181
|
};
|
|
182
|
-
console.log("Cabbage: sending channel data from UI", n), a !== null ? a.postMessage(
|
|
182
|
+
console.log("Cabbage: sending channel data from UI", n), a !== null ? a.postMessage(s) : typeof window.sendMessageFromUI == "function" ? window.sendMessageFromUI(s) : console.error(
|
|
183
183
|
"Cabbage: window.sendMessageFromUI is not available. Message:",
|
|
184
|
-
|
|
184
|
+
s
|
|
185
185
|
);
|
|
186
186
|
}
|
|
187
187
|
/**
|
|
@@ -191,12 +191,12 @@ class C {
|
|
|
191
191
|
* @param {Object} widget - The widget configuration object to update
|
|
192
192
|
* @param {Object|null} vscode - VS Code API object (null for plugin mode)
|
|
193
193
|
*/
|
|
194
|
-
static sendWidgetUpdate(o,
|
|
194
|
+
static sendWidgetUpdate(o, e = null) {
|
|
195
195
|
const a = {
|
|
196
196
|
command: "widgetStateUpdate",
|
|
197
197
|
obj: JSON.stringify(CabbageUtils.sanitizeForEditor(o))
|
|
198
198
|
};
|
|
199
|
-
|
|
199
|
+
e !== null ? e.postMessage(a) : typeof window.sendMessageFromUI == "function" ? window.sendMessageFromUI(a) : console.error(
|
|
200
200
|
"Cabbage: window.sendMessageFromUI is not available. Message:",
|
|
201
201
|
a
|
|
202
202
|
);
|
|
@@ -208,20 +208,20 @@ class C {
|
|
|
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,
|
|
211
|
+
static sendCustomCommand(o, e = null, a = {}) {
|
|
212
212
|
const n = {
|
|
213
213
|
command: o,
|
|
214
214
|
text: JSON.stringify(a)
|
|
215
215
|
};
|
|
216
|
-
if (
|
|
217
|
-
|
|
216
|
+
if (e !== null)
|
|
217
|
+
e.postMessage(n);
|
|
218
218
|
else if (typeof window.sendMessageFromUI == "function") {
|
|
219
219
|
console.log("Cabbage: Calling window.sendMessageFromUI with:", n);
|
|
220
220
|
try {
|
|
221
|
-
const
|
|
222
|
-
console.log("Cabbage: sendMessageFromUI returned:",
|
|
223
|
-
} catch (
|
|
224
|
-
console.error("Cabbage: sendMessageFromUI threw error:",
|
|
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);
|
|
225
225
|
}
|
|
226
226
|
} else
|
|
227
227
|
console.error(
|
|
@@ -237,16 +237,16 @@ class C {
|
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
239
|
const I = (i) => {
|
|
240
|
-
const [o,
|
|
240
|
+
const [o, e] = w();
|
|
241
241
|
return f(() => {
|
|
242
242
|
const a = (n) => {
|
|
243
|
-
const { id:
|
|
244
|
-
if (
|
|
243
|
+
const { id: s, widgetJson: r, command: b } = n.data;
|
|
244
|
+
if (s === i && r && b === "widgetUpdate") {
|
|
245
245
|
const t = JSON.parse(r);
|
|
246
246
|
console.log(
|
|
247
|
-
`[Cabbage-React] Received properties for channelId ${
|
|
247
|
+
`[Cabbage-React] Received properties for channelId: ${s}`,
|
|
248
248
|
t
|
|
249
|
-
),
|
|
249
|
+
), e(t);
|
|
250
250
|
}
|
|
251
251
|
};
|
|
252
252
|
return window.addEventListener("message", a), () => {
|
|
@@ -255,8 +255,8 @@ const I = (i) => {
|
|
|
255
255
|
}, []), {
|
|
256
256
|
properties: o
|
|
257
257
|
};
|
|
258
|
-
},
|
|
259
|
-
const { properties:
|
|
258
|
+
}, v = (i, o = "complete") => {
|
|
259
|
+
const { properties: e } = I(i), [a, n] = w(), [s, r] = w(), b = (t) => {
|
|
260
260
|
n(t), C.sendControlData({
|
|
261
261
|
channel: i,
|
|
262
262
|
value: t,
|
|
@@ -264,40 +264,45 @@ const I = (i) => {
|
|
|
264
264
|
});
|
|
265
265
|
};
|
|
266
266
|
return f(() => {
|
|
267
|
-
var
|
|
268
|
-
const t =
|
|
269
|
-
(
|
|
267
|
+
var d;
|
|
268
|
+
const t = e == null ? void 0 : e.channels.find(
|
|
269
|
+
(l) => l.id === i
|
|
270
270
|
);
|
|
271
271
|
if (!t) return;
|
|
272
|
-
const
|
|
273
|
-
|
|
274
|
-
`[Cabbage-React] Received parameterIndex for channelId
|
|
275
|
-
l
|
|
276
|
-
), r(l));
|
|
277
|
-
const g = (m = t.range) == null ? void 0 : m.defaultValue;
|
|
278
|
-
a === void 0 && g !== void 0 && (console.log(
|
|
279
|
-
`[Cabbage-React] Received default value for channelId "${t.id}"`,
|
|
272
|
+
const g = t == null ? void 0 : t.parameterIndex;
|
|
273
|
+
s === void 0 && g !== void 0 && (console.log(
|
|
274
|
+
`[Cabbage-React] Received parameterIndex for channelId: ${t.id}`,
|
|
280
275
|
g
|
|
281
|
-
),
|
|
282
|
-
|
|
283
|
-
|
|
276
|
+
), r(g));
|
|
277
|
+
const c = e == null ? void 0 : e.value;
|
|
278
|
+
c != null && (console.log(
|
|
279
|
+
`[Cabbage-React] Received initial value for channelId: ${i}`,
|
|
280
|
+
c
|
|
281
|
+
), n(c));
|
|
282
|
+
const m = (d = t.range) == null ? void 0 : d.defaultValue;
|
|
283
|
+
a === void 0 && m !== void 0 && (console.log(
|
|
284
|
+
`[Cabbage-React] Received default value for channelId: ${t.id}`,
|
|
285
|
+
m
|
|
286
|
+
), n(m));
|
|
287
|
+
}, [e]), f(() => {
|
|
288
|
+
const t = (g) => {
|
|
284
289
|
var m;
|
|
285
|
-
const { command:
|
|
286
|
-
if (
|
|
287
|
-
const { value: d, paramIdx:
|
|
288
|
-
if (
|
|
290
|
+
const { command: c } = g.data;
|
|
291
|
+
if (c === "parameterChange") {
|
|
292
|
+
const { value: d, paramIdx: l } = g.data.data;
|
|
293
|
+
if (l !== s || d === null) return;
|
|
289
294
|
console.log(
|
|
290
|
-
`[Cabbage-React] Received parameterChange for parameterIndex ${
|
|
295
|
+
`[Cabbage-React] Received parameterChange for parameterIndex: ${l}`,
|
|
291
296
|
d
|
|
292
297
|
), n(d);
|
|
293
|
-
} else if (
|
|
294
|
-
const d =
|
|
295
|
-
if (!
|
|
296
|
-
const u = JSON.parse(
|
|
298
|
+
} else if (c === "batchWidgetUpdate") {
|
|
299
|
+
const d = g.data.widgets, l = d == null ? void 0 : d.find((M) => M.id === i);
|
|
300
|
+
if (!l) return;
|
|
301
|
+
const u = JSON.parse(l.widgetJson).channels.find(
|
|
297
302
|
(M) => M.id === i
|
|
298
303
|
), p = (m = u == null ? void 0 : u.range) == null ? void 0 : m.value;
|
|
299
304
|
console.log(
|
|
300
|
-
`[Cabbage-React] Received batch widget update for channelId ${
|
|
305
|
+
`[Cabbage-React] Received batch widget update for channelId: ${l.id}`,
|
|
301
306
|
p
|
|
302
307
|
), n(p);
|
|
303
308
|
}
|
|
@@ -305,21 +310,21 @@ const I = (i) => {
|
|
|
305
310
|
return window.addEventListener("message", t), () => {
|
|
306
311
|
window.removeEventListener("message", t);
|
|
307
312
|
};
|
|
308
|
-
}, [
|
|
313
|
+
}, [s]), {
|
|
309
314
|
value: a,
|
|
310
315
|
setValue: b
|
|
311
316
|
};
|
|
312
|
-
},
|
|
313
|
-
const [o,
|
|
317
|
+
}, y = (i) => {
|
|
318
|
+
const [o, e] = w();
|
|
314
319
|
return f(() => {
|
|
315
320
|
const a = (n) => {
|
|
316
|
-
const { data:
|
|
317
|
-
if (
|
|
318
|
-
if (
|
|
321
|
+
const { data: s, type: r } = n;
|
|
322
|
+
if (s && r === "message") {
|
|
323
|
+
if (s.id !== i) return;
|
|
319
324
|
console.log(
|
|
320
|
-
`[Cabbage-React] Received data for messageId ${
|
|
321
|
-
|
|
322
|
-
), s
|
|
325
|
+
`[Cabbage-React] Received data for messageId: ${s.id}`,
|
|
326
|
+
s
|
|
327
|
+
), e(s);
|
|
323
328
|
}
|
|
324
329
|
};
|
|
325
330
|
return window.addEventListener("message", a), () => {
|
|
@@ -331,7 +336,7 @@ const I = (i) => {
|
|
|
331
336
|
};
|
|
332
337
|
export {
|
|
333
338
|
C as Cabbage,
|
|
334
|
-
|
|
339
|
+
y as useCabbageMessage,
|
|
335
340
|
I as useCabbageProperties,
|
|
336
|
-
|
|
341
|
+
v as useCabbageState
|
|
337
342
|
};
|