cabbage-react 1.0.55 → 1.0.57

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.
@@ -1 +1 @@
1
- {"version":3,"file":"useCabbageMessage.d.ts","sourceRoot":"","sources":["../../src/hooks/useCabbageMessage.ts"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,GAAI,CAAC,EAClC,aAAa,MAAM,EACnB,UAAU;IACT,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,IAAI,CAAC;IACjC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;CAChB;;CA6BD,CAAC"}
1
+ {"version":3,"file":"useCabbageMessage.d.ts","sourceRoot":"","sources":["../../src/hooks/useCabbageMessage.ts"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,GAAI,CAAC,EAClC,aAAa,MAAM,EACnB,UAAU;IACT,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,IAAI,CAAC;IACjC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;CAChB;;CAmCD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"useCabbageProperties.d.ts","sourceRoot":"","sources":["../../src/hooks/useCabbageProperties.ts"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,GAChC,WAAW,MAAM,EACjB,UAAU;IACT,kBAAkB,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;IAC/D,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;CAChB;;CAkCD,CAAC"}
1
+ {"version":3,"file":"useCabbageProperties.d.ts","sourceRoot":"","sources":["../../src/hooks/useCabbageProperties.ts"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,GAChC,WAAW,MAAM,EACjB,UAAU;IACT,kBAAkB,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;IAC/D,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;CAChB;;CAwCD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"useCabbageState.d.ts","sourceRoot":"","sources":["../../src/hooks/useCabbageState.ts"],"names":[],"mappings":"AAKA;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,GAAI,CAAC,EAChC,WAAW,MAAM,EACjB,UAAU;IACT,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IACnC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;CAChB;;sBAmBO,CAAC,YACC,OAAO,GAAG,OAAO,GAAG,KAAK,GAAG,UAAU;CAiFhD,CAAC"}
1
+ {"version":3,"file":"useCabbageState.d.ts","sourceRoot":"","sources":["../../src/hooks/useCabbageState.ts"],"names":[],"mappings":"AAKA;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,GAAI,CAAC,EAChC,WAAW,MAAM,EACjB,UAAU;IACT,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IACnC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;CAChB;;sBAyBO,CAAC,YACC,OAAO,GAAG,OAAO,GAAG,KAAK,GAAG,UAAU;CAiFhD,CAAC"}
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react");class C{static sendControlData({channel:e,value:s,gesture:n="complete"},t=null){const a={command:"controlData",channel:e,value:s,gesture:n};t!==null?t.postMessage(a):typeof window.sendMessageFromUI=="function"?window.sendMessageFromUI(a):window.parent!==window?window.parent.postMessage(a,"*"):console.error("Cabbage: window.sendMessageFromUI is not available. Message:",a)}static isReadyToLoad(e=null,s={}){this.sendCustomCommand("isReadyToLoad",e)}static sendMidiMessageFromUI(e,s,n,t=null){var a={statusByte:e,dataByte1:s,dataByte2:n};const r={command:"midiMessage",obj:JSON.stringify(a)};t!==null?t.postMessage(r):typeof window.sendMessageFromUI=="function"?window.sendMessageFromUI(r):window.parent!==window?window.parent.postMessage(r,"*"):console.error("Cabbage: window.sendMessageFromUI is not available. Message:",r)}static MidiMessageFromHost(e,s,n){}static triggerFileOpenDialog(e,s,n={}){var t={channel:s,directory:n.directory||"",filters:n.filters||"*",openAtLastKnownLocation:n.openAtLastKnownLocation!==void 0?n.openAtLastKnownLocation:!0};const a={command:"fileOpen",obj:JSON.stringify(t)};e!==null?e.postMessage(a):typeof window.sendMessageFromUI=="function"?window.sendMessageFromUI(a):window.parent!==window?window.parent.postMessage(a,"*"):console.error("Cabbage: window.sendMessageFromUI is not available. Message:",a)}static openUrl(e,s,n){var t={url:s,file:n};const a={command:"openUrl",obj:JSON.stringify(t)};e!==null?e.postMessage(a):typeof window.sendMessageFromUI=="function"?window.sendMessageFromUI(a):window.parent!==window?window.parent.postMessage(a,"*"):console.error("Cabbage: window.sendMessageFromUI is not available. Message:",a)}static requestResize(e,s,n=null){const t={command:"requestResize",width:e,height:s};if(n!==null){console.warn("Cabbage: requestResize is not supported in VS Code extension mode");return}else typeof window.sendMessageFromUI=="function"?window.sendMessageFromUI(t):window.parent!==window?window.parent.postMessage(t,"*"):console.error("Cabbage: window.sendMessageFromUI is not available. Message:",t)}static consumeKeypresses(e){typeof window.consumeKeypresses=="function"&&window.consumeKeypresses(e)}static sendChannelData(e,s,n=null){var t={channel:e};if(typeof s=="string")t.stringData=s;else if(typeof s=="number")t.floatData=s;else{console.warn("Cabbage: sendChannelData received unsupported data type:",typeof s);return}const a={command:"channelData",obj:JSON.stringify(t)};n!==null?n.postMessage(a):typeof window.sendMessageFromUI=="function"?window.sendMessageFromUI(a):window.parent!==window?window.parent.postMessage(a,"*"):console.error("Cabbage: window.sendMessageFromUI is not available. Message:",a)}static sendWidgetUpdate(e,s=null){const n={command:"widgetStateUpdate",obj:JSON.stringify(CabbageUtils.sanitizeForEditor(e))};s!==null?s.postMessage(n):typeof window.sendMessageFromUI=="function"?window.sendMessageFromUI(n):window.parent!==window?window.parent.postMessage(n,"*"):console.error("Cabbage: window.sendMessageFromUI is not available. Message:",n)}static addMessageListener(e){const s=n=>{n.source!==window&&e(n.data)};return window.addEventListener("message",s),window.hostMessageCallback=e,()=>{window.removeEventListener("message",s),window.hostMessageCallback===e&&(window.hostMessageCallback=null)}}static sendCustomCommand(e,s=null,n={}){const t={command:e,text:JSON.stringify(n)};if(s!==null)s.postMessage(t);else if(typeof window.sendMessageFromUI=="function")try{const a=window.sendMessageFromUI(t)}catch(a){console.error("Cabbage: sendMessageFromUI threw error:",a),console.error("Cabbage: Error stack:",a.stack)}else window.parent!==window?window.parent.postMessage(t,"*"):(console.error("Cabbage: window.sendMessageFromUI is not available yet. Message:",t),console.error("Cabbage: typeof window.sendMessageFromUI:",typeof window.sendMessageFromUI),console.error("Cabbage: window.sendMessageFromUI value:",window.sendMessageFromUI))}}const b=(o,e)=>(...s)=>{e&&console.log(`[Cabbage-React][${o}]`,...s)},U=(o,e)=>{if(!o||e?.skip)return{properties:void 0};const s=b(`useCabbageProperties:${o}`,e?.debug),[n,t]=l.useState();return l.useEffect(()=>{const a=r=>{const{id:d,widgetJson:c,command:m}=r.data;if(d===o&&c&&m==="widgetUpdate"){const i=JSON.parse(c);s("Received properties",i),e?.onPropertiesUpdate&&e.onPropertiesUpdate(i),t(i)}};return window.addEventListener("message",a),()=>window.removeEventListener("message",a)},[o,e?.onPropertiesUpdate]),{properties:n}},y=(o,e)=>{if(!o||e?.skip)return{value:void 0,setValue:()=>{}};const s=b(`useCabbageState:${o}`,e?.debug),{properties:n}=U(o,{debug:e?.debug}),[t,a]=l.useState(),[r,d]=l.useState(),c=(i,g="complete")=>{a(i),C.sendControlData({channel:o,value:i,gesture:g})},m=i=>{e?.onValueUpdate&&e.onValueUpdate(i),a(i)};return l.useEffect(()=>{const i=n?.channels.find(u=>u.id===o);if(!i)return;const g=i.parameterIndex;if(r===void 0&&g!==void 0&&(s("Received parameterIndex",g),d(g)),t!==void 0)return;const w=i.range?.value;w!=null&&(s("Received initial value",w),m(w))},[n]),l.useEffect(()=>{const i=g=>{const{command:w}=g.data;if(w==="parameterChange"){const{value:u,paramIdx:f}=g.data.data;if(f!==r||u===null)return;s("Received parameterChange",u),m(u)}else if(w==="batchWidgetUpdate"){const f=g.data.widgets?.find(p=>p.id===o);if(!f)return;const M=JSON.parse(f.widgetJson).channels.find(p=>p.id===o)?.range?.value;s("Received batchWidgetUpdate",M),m(M)}};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[o,e?.onValueUpdate,r]),{value:t,setValue:c}},v=(o,e)=>{if(!o||e?.skip)return{message:void 0};const s=b(`useCabbageMessage:${o}`,e?.debug),[n,t]=l.useState();return l.useEffect(()=>{const a=r=>{const{data:d,type:c}=r;!d||c!=="message"||d.type===o&&(s("Received data",d),e?.onMessage&&e.onMessage(d),t(d))};return window.addEventListener("message",a),()=>window.removeEventListener("message",a)},[o,e?.onMessage]),{message:n}};exports.Cabbage=C;exports.useCabbageMessage=v;exports.useCabbageProperties=U;exports.useCabbageState=y;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react");class U{static sendControlData({channel:e,value:s,gesture:a="complete"},t=null){const n={command:"controlData",channel:e,value:s,gesture:a};t!==null?t.postMessage(n):typeof window.sendMessageFromUI=="function"?window.sendMessageFromUI(n):window.parent!==window?window.parent.postMessage(n,"*"):console.error("Cabbage: window.sendMessageFromUI is not available. Message:",n)}static isReadyToLoad(e=null,s={}){this.sendCustomCommand("isReadyToLoad",e)}static sendMidiMessageFromUI(e,s,a,t=null){var n={statusByte:e,dataByte1:s,dataByte2:a};const i={command:"midiMessage",obj:JSON.stringify(n)};t!==null?t.postMessage(i):typeof window.sendMessageFromUI=="function"?window.sendMessageFromUI(i):window.parent!==window?window.parent.postMessage(i,"*"):console.error("Cabbage: window.sendMessageFromUI is not available. Message:",i)}static MidiMessageFromHost(e,s,a){}static triggerFileOpenDialog(e,s,a={}){var t={channel:s,directory:a.directory||"",filters:a.filters||"*",openAtLastKnownLocation:a.openAtLastKnownLocation!==void 0?a.openAtLastKnownLocation:!0};const n={command:"fileOpen",obj:JSON.stringify(t)};e!==null?e.postMessage(n):typeof window.sendMessageFromUI=="function"?window.sendMessageFromUI(n):window.parent!==window?window.parent.postMessage(n,"*"):console.error("Cabbage: window.sendMessageFromUI is not available. Message:",n)}static openUrl(e,s,a){var t={url:s,file:a};const n={command:"openUrl",obj:JSON.stringify(t)};e!==null?e.postMessage(n):typeof window.sendMessageFromUI=="function"?window.sendMessageFromUI(n):window.parent!==window?window.parent.postMessage(n,"*"):console.error("Cabbage: window.sendMessageFromUI is not available. Message:",n)}static requestResize(e,s,a=null){const t={command:"requestResize",width:e,height:s};if(a!==null){console.warn("Cabbage: requestResize is not supported in VS Code extension mode");return}else typeof window.sendMessageFromUI=="function"?window.sendMessageFromUI(t):window.parent!==window?window.parent.postMessage(t,"*"):console.error("Cabbage: window.sendMessageFromUI is not available. Message:",t)}static consumeKeypresses(e){typeof window.consumeKeypresses=="function"&&window.consumeKeypresses(e)}static sendChannelData(e,s,a=null){var t={channel:e};if(typeof s=="string")t.stringData=s;else if(typeof s=="number")t.floatData=s;else{console.warn("Cabbage: sendChannelData received unsupported data type:",typeof s);return}const n={command:"channelData",obj:JSON.stringify(t)};a!==null?a.postMessage(n):typeof window.sendMessageFromUI=="function"?window.sendMessageFromUI(n):window.parent!==window?window.parent.postMessage(n,"*"):console.error("Cabbage: window.sendMessageFromUI is not available. Message:",n)}static sendWidgetUpdate(e,s=null){const a={command:"widgetStateUpdate",obj:JSON.stringify(CabbageUtils.sanitizeForEditor(e))};s!==null?s.postMessage(a):typeof window.sendMessageFromUI=="function"?window.sendMessageFromUI(a):window.parent!==window?window.parent.postMessage(a,"*"):console.error("Cabbage: window.sendMessageFromUI is not available. Message:",a)}static addMessageListener(e){const s=a=>{a.source!==window&&e(a.data)};return window.addEventListener("message",s),window.hostMessageCallback=e,()=>{window.removeEventListener("message",s),window.hostMessageCallback===e&&(window.hostMessageCallback=null)}}static sendCustomCommand(e,s=null,a={}){const t={command:e,text:JSON.stringify(a)};if(s!==null)s.postMessage(t);else if(typeof window.sendMessageFromUI=="function")try{const n=window.sendMessageFromUI(t)}catch(n){console.error("Cabbage: sendMessageFromUI threw error:",n),console.error("Cabbage: Error stack:",n.stack)}else window.parent!==window?window.parent.postMessage(t,"*"):(console.error("Cabbage: window.sendMessageFromUI is not available yet. Message:",t),console.error("Cabbage: typeof window.sendMessageFromUI:",typeof window.sendMessageFromUI),console.error("Cabbage: window.sendMessageFromUI value:",window.sendMessageFromUI))}}const M=(o,e)=>(...s)=>{e&&console.log(`[Cabbage-React][${o}]`,...s)},v=(o,e)=>{if(!o||e?.skip)return{properties:void 0};const s=d.useRef(void 0);s.current=M(`useCabbageProperties:${o}`,e?.debug);const a=s.current,[t,n]=d.useState();return d.useEffect(()=>{const i=w=>{const{id:g,widgetJson:c,command:m}=w.data;if(g===o&&c&&m==="widgetUpdate"){const r=JSON.parse(c);a("Received properties",r),e?.onPropertiesUpdate&&e.onPropertiesUpdate(r),n(r)}};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[o,e?.onPropertiesUpdate]),{properties:t}},y=(o,e)=>{if(!o||e?.skip)return{value:void 0,setValue:()=>{}};const s=d.useRef(void 0);s.current=M(`useCabbageState:${o}`,e?.debug);const a=s.current,{properties:t}=v(o,{debug:e?.debug}),[n,i]=d.useState(),[w,g]=d.useState(),c=(r,l="complete")=>{i(r),U.sendControlData({channel:o,value:r,gesture:l})},m=r=>{e?.onValueUpdate&&e.onValueUpdate(r),i(r)};return d.useEffect(()=>{const r=t?.channels.find(f=>f.id===o);if(!r)return;const l=r.parameterIndex;if(w===void 0&&l!==void 0&&(a("Received parameterIndex",l),g(l)),n!==void 0)return;const u=r.range?.value;u!=null&&(a("Received initial value",u),m(u))},[t]),d.useEffect(()=>{const r=l=>{const{command:u}=l.data;if(u==="parameterChange"){const{value:f,paramIdx:p}=l.data.data;if(p!==w||f===null)return;a("Received parameterChange",f),m(f)}else if(u==="batchWidgetUpdate"){const p=l.data.widgets?.find(b=>b.id===o);if(!p)return;const C=JSON.parse(p.widgetJson).channels.find(b=>b.id===o)?.range?.value;a("Received batchWidgetUpdate",C),m(C)}};return window.addEventListener("message",r),()=>window.removeEventListener("message",r)},[o,e?.onValueUpdate,w]),{value:n,setValue:c}},F=(o,e)=>{if(!o||e?.skip)return{message:void 0};const s=d.useRef(void 0);s.current=M(`useCabbageMessage:${o}`,e?.debug);const a=s.current,[t,n]=d.useState();return d.useEffect(()=>{const i=w=>{const{data:g,type:c}=w;!g||c!=="message"||g.type===o&&(a("Received data",g),e?.onMessage&&e.onMessage(g),n(g))};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[o,e?.onMessage]),{message:t}};exports.Cabbage=U;exports.useCabbageMessage=F;exports.useCabbageProperties=v;exports.useCabbageState=y;
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { useState as p, useEffect as f } from "react";
2
- class C {
1
+ import { useRef as U, useState as p, useEffect as b } from "react";
2
+ class y {
3
3
  /**
4
4
  * Send a widget value change to the Cabbage backend.
5
5
  *
@@ -287,86 +287,98 @@ class C {
287
287
  ));
288
288
  }
289
289
  }
290
- const M = (o, e) => (...s) => {
290
+ const C = (o, e) => (...s) => {
291
291
  e && console.log(`[Cabbage-React][${o}]`, ...s);
292
- }, y = (o, e) => {
292
+ }, F = (o, e) => {
293
293
  if (!o || e?.skip) return { properties: void 0 };
294
- const s = M(
294
+ const s = U(
295
+ void 0
296
+ );
297
+ s.current = C(
295
298
  `useCabbageProperties:${o}`,
296
299
  e?.debug
297
- ), [n, t] = p();
298
- return f(() => {
299
- const a = (r) => {
300
- const { id: d, widgetJson: l, command: u } = r.data;
301
- if (d === o && l && u === "widgetUpdate") {
302
- const i = JSON.parse(l);
303
- s("Received properties", i), e?.onPropertiesUpdate && e.onPropertiesUpdate(i), t(i);
300
+ );
301
+ const n = s.current, [t, a] = p();
302
+ return b(() => {
303
+ const r = (w) => {
304
+ const { id: d, widgetJson: c, command: m } = w.data;
305
+ if (d === o && c && m === "widgetUpdate") {
306
+ const i = JSON.parse(c);
307
+ n("Received properties", i), e?.onPropertiesUpdate && e.onPropertiesUpdate(i), a(i);
304
308
  }
305
309
  };
306
- return window.addEventListener("message", a), () => window.removeEventListener("message", a);
307
- }, [o, e?.onPropertiesUpdate]), { properties: n };
308
- }, h = (o, e) => {
310
+ return window.addEventListener("message", r), () => window.removeEventListener("message", r);
311
+ }, [o, e?.onPropertiesUpdate]), { properties: t };
312
+ }, R = (o, e) => {
309
313
  if (!o || e?.skip)
310
314
  return { value: void 0, setValue: () => {
311
315
  } };
312
- const s = M(
316
+ const s = U(
317
+ void 0
318
+ );
319
+ s.current = C(
313
320
  `useCabbageState:${o}`,
314
321
  e?.debug
315
- ), { properties: n } = y(o, {
322
+ );
323
+ const n = s.current, { properties: t } = F(o, {
316
324
  debug: e?.debug
317
- }), [t, a] = p(), [r, d] = p(), l = (i, g = "complete") => {
318
- a(i), C.sendControlData({
325
+ }), [a, r] = p(), [w, d] = p(), c = (i, g = "complete") => {
326
+ r(i), y.sendControlData({
319
327
  channel: o,
320
328
  value: i,
321
329
  gesture: g
322
330
  });
323
- }, u = (i) => {
324
- e?.onValueUpdate && e.onValueUpdate(i), a(i);
331
+ }, m = (i) => {
332
+ e?.onValueUpdate && e.onValueUpdate(i), r(i);
325
333
  };
326
- return f(() => {
327
- const i = n?.channels.find(
328
- (c) => c.id === o
334
+ return b(() => {
335
+ const i = t?.channels.find(
336
+ (u) => u.id === o
329
337
  );
330
338
  if (!i) return;
331
339
  const g = i.parameterIndex;
332
- if (r === void 0 && g !== void 0 && (s("Received parameterIndex", g), d(g)), t !== void 0) return;
333
- const w = i.range?.value;
334
- w != null && (s("Received initial value", w), u(w));
335
- }, [n]), f(() => {
340
+ if (w === void 0 && g !== void 0 && (n("Received parameterIndex", g), d(g)), a !== void 0) return;
341
+ const l = i.range?.value;
342
+ l != null && (n("Received initial value", l), m(l));
343
+ }, [t]), b(() => {
336
344
  const i = (g) => {
337
- const { command: w } = g.data;
338
- if (w === "parameterChange") {
339
- const { value: c, paramIdx: m } = g.data.data;
340
- if (m !== r || c === null) return;
341
- s("Received parameterChange", c), u(c);
342
- } else if (w === "batchWidgetUpdate") {
343
- const m = g.data.widgets?.find((b) => b.id === o);
344
- if (!m) return;
345
- const U = JSON.parse(m.widgetJson).channels.find(
346
- (b) => b.id === o
345
+ const { command: l } = g.data;
346
+ if (l === "parameterChange") {
347
+ const { value: u, paramIdx: f } = g.data.data;
348
+ if (f !== w || u === null) return;
349
+ n("Received parameterChange", u), m(u);
350
+ } else if (l === "batchWidgetUpdate") {
351
+ const f = g.data.widgets?.find((M) => M.id === o);
352
+ if (!f) return;
353
+ const v = JSON.parse(f.widgetJson).channels.find(
354
+ (M) => M.id === o
347
355
  )?.range?.value;
348
- s("Received batchWidgetUpdate", U), u(U);
356
+ n("Received batchWidgetUpdate", v), m(v);
349
357
  }
350
358
  };
351
359
  return window.addEventListener("message", i), () => window.removeEventListener("message", i);
352
- }, [o, e?.onValueUpdate, r]), { value: t, setValue: l };
353
- }, L = (o, e) => {
360
+ }, [o, e?.onValueUpdate, w]), { value: a, setValue: c };
361
+ }, S = (o, e) => {
354
362
  if (!o || e?.skip) return { message: void 0 };
355
- const s = M(
363
+ const s = U(
364
+ void 0
365
+ );
366
+ s.current = C(
356
367
  `useCabbageMessage:${o}`,
357
368
  e?.debug
358
- ), [n, t] = p();
359
- return f(() => {
360
- const a = (r) => {
361
- const { data: d, type: l } = r;
362
- !d || l !== "message" || d.type === o && (s("Received data", d), e?.onMessage && e.onMessage(d), t(d));
369
+ );
370
+ const n = s.current, [t, a] = p();
371
+ return b(() => {
372
+ const r = (w) => {
373
+ const { data: d, type: c } = w;
374
+ !d || c !== "message" || d.type === o && (n("Received data", d), e?.onMessage && e.onMessage(d), a(d));
363
375
  };
364
- return window.addEventListener("message", a), () => window.removeEventListener("message", a);
365
- }, [o, e?.onMessage]), { message: n };
376
+ return window.addEventListener("message", r), () => window.removeEventListener("message", r);
377
+ }, [o, e?.onMessage]), { message: t };
366
378
  };
367
379
  export {
368
- C as Cabbage,
369
- L as useCabbageMessage,
370
- y as useCabbageProperties,
371
- h as useCabbageState
380
+ y as Cabbage,
381
+ S as useCabbageMessage,
382
+ F as useCabbageProperties,
383
+ R as useCabbageState
372
384
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cabbage-react",
3
- "version": "1.0.55",
3
+ "version": "1.0.57",
4
4
  "type": "module",
5
5
  "keywords": [
6
6
  "cabbage",