cabbage-react 1.0.0-beta.23 → 1.0.0-beta.24

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/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react");console.log("Cabbage: loading cabbage.js");class M{static sendParameterUpdate(a,s=null){const e={command:"parameterChange",obj:JSON.stringify(a)};s!==null?s.postMessage(e):(console.log("Cabbage: sending parameter change from UI",e),window.sendMessageFromUI(e))}static sendCustomCommand(a,s=null){const e={command:a,text:JSON.stringify({})};console.log("Cabbage: sending custom command from UI",e),s!==null?s.postMessage(e):window.sendMessageFromUI(e)}static sendWidgetUpdate(a,s=null){console.log("Cabbage: sending widget update from UI",a.props);const e={command:"widgetStateUpdate",obj:JSON.stringify(a.props)};s!==null?s.postMessage(e):window.sendMessageFromUI(e)}static sendMidiMessageFromUI(a,s,e,o=null){var t={statusByte:a,dataByte1:s,dataByte2:e};const d={command:"midiMessage",obj:JSON.stringify(t)};console.log("Cabbage: sending midi message from UI",t),o!==null?o.postMessage(d):window.sendMessageFromUI(d)}static MidiMessageFromHost(a,s,e){console.log("Cabbage: Got MIDI Message"+a+":"+s+":"+e)}static triggerFileOpenDialog(a,s){var e={channel:s};const o={command:"fileOpen",obj:JSON.stringify(e)};a!==null?a.postMessage(o):window.sendMessageFromUI(o)}}const U=(r,a)=>{const[s,e]=i.useState(),[o,t]=i.useState(),d=l=>{e(l);const g={paramIdx:a,channelType:o,channel:r,value:l};M.sendParameterUpdate(g,null)};return i.useEffect(()=>{const l=g=>{var m,c,u,b,p,f,C,w;const{data:n}=g;console.log("Cabbage-React: receiving message",g),console.log("eple",g.data),console.log("banan",(m=g.data)==null?void 0:m.data),console.log("kongle",(u=(c=g.data)==null?void 0:c.data)==null?void 0:u.paramidx),console.log("ananas",(p=(b=g.data)==null?void 0:b.data)==null?void 0:p.value),n.command==="widgetUpdate"&&n.value!==void 0&&(e(n.value),typeof n.value=="number"?t("number"):typeof n.value=="string"&&t("string")),((f=n.data)==null?void 0:f.paramIdx)===a&&n.command==="parameterChange"&&((C=n==null?void 0:n.data)==null?void 0:C.value)!==void 0&&e((w=n==null?void 0:n.data)==null?void 0:w.value)};return window.addEventListener("message",l),()=>{window.removeEventListener("message",l)}},[]),{value:s,setValue:d}},h=r=>{const[a,s]=i.useState();return i.useEffect(()=>{const e=o=>{const{data:t}=o;t.channel===r&&t.data&&t.command==="widgetUpdate"&&(console.log("Cabbage-React: receiving data change",t),s(JSON.parse(t.data)))};return window.addEventListener("message",e),()=>{window.removeEventListener("message",e)}},[]),{properties:a}};exports.Cabbage=M;exports.useCabbageProperties=h;exports.useCabbageState=U;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react");console.log("Cabbage: loading cabbage.js");class M{static sendParameterUpdate(a,s=null){const e={command:"parameterChange",obj:JSON.stringify(a)};s!==null?s.postMessage(e):(console.log("Cabbage: sending parameter change from UI",e),window.sendMessageFromUI(e))}static sendCustomCommand(a,s=null){const e={command:a,text:JSON.stringify({})};console.log("Cabbage: sending custom command from UI",e),s!==null?s.postMessage(e):window.sendMessageFromUI(e)}static sendWidgetUpdate(a,s=null){console.log("Cabbage: sending widget update from UI",a.props);const e={command:"widgetStateUpdate",obj:JSON.stringify(a.props)};s!==null?s.postMessage(e):window.sendMessageFromUI(e)}static sendMidiMessageFromUI(a,s,e,o=null){var t={statusByte:a,dataByte1:s,dataByte2:e};const d={command:"midiMessage",obj:JSON.stringify(t)};console.log("Cabbage: sending midi message from UI",t),o!==null?o.postMessage(d):window.sendMessageFromUI(d)}static MidiMessageFromHost(a,s,e){console.log("Cabbage: Got MIDI Message"+a+":"+s+":"+e)}static triggerFileOpenDialog(a,s){var e={channel:s};const o={command:"fileOpen",obj:JSON.stringify(e)};a!==null?a.postMessage(o):window.sendMessageFromUI(o)}}const U=(r,a)=>{const[s,e]=l.useState(),[o,t]=l.useState(),d=i=>{e(i);const g={paramIdx:a,channelType:o,channel:r,value:i};M.sendParameterUpdate(g,null)};return l.useEffect(()=>{const i=g=>{var m,c,u,b,p,f,C,w;const{data:n}=g;console.log("Cabbage-React: receiving parameter change",g),console.log("eple",g.data),console.log("banan",(m=g.data)==null?void 0:m.data),console.log("kongle",(u=(c=g.data)==null?void 0:c.data)==null?void 0:u.paramidx),console.log("ananas",(p=(b=g.data)==null?void 0:b.data)==null?void 0:p.value),n.command==="widgetUpdate"&&n.value!==void 0&&(e(n.value),typeof n.value=="number"?t("number"):typeof n.value=="string"&&t("string")),((f=n.data)==null?void 0:f.paramIdx)===a&&n.command==="parameterChange"&&((C=n==null?void 0:n.data)==null?void 0:C.value)!==void 0&&e((w=n==null?void 0:n.data)==null?void 0:w.value)};return window.addEventListener("message",i),()=>{window.removeEventListener("message",i)}},[]),{value:s,setValue:d}},h=r=>{const[a,s]=l.useState();return l.useEffect(()=>{const e=o=>{const{data:t}=o;t.channel===r&&t.data&&t.command==="widgetUpdate"&&(console.log("Cabbage-React: receiving properties change",t),s(JSON.parse(t.data)))};return window.addEventListener("message",e),()=>{window.removeEventListener("message",e)}},[]),{properties:a}};exports.Cabbage=M;exports.useCabbageProperties=h;exports.useCabbageState=U;
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { useState as r, useEffect as C } from "react";
1
+ import { useState as d, useEffect as C } from "react";
2
2
  console.log("Cabbage: loading cabbage.js");
3
3
  class U {
4
4
  static sendParameterUpdate(a, s = null) {
@@ -29,11 +29,11 @@ class U {
29
29
  dataByte1: s,
30
30
  dataByte2: e
31
31
  };
32
- const d = {
32
+ const r = {
33
33
  command: "midiMessage",
34
34
  obj: JSON.stringify(t)
35
35
  };
36
- console.log("Cabbage: sending midi message from UI", t), o !== null ? o.postMessage(d) : window.sendMessageFromUI(d);
36
+ console.log("Cabbage: sending midi message from UI", t), o !== null ? o.postMessage(r) : window.sendMessageFromUI(r);
37
37
  }
38
38
  static MidiMessageFromHost(a, s, e) {
39
39
  console.log("Cabbage: Got MIDI Message" + a + ":" + s + ":" + e);
@@ -50,7 +50,7 @@ class U {
50
50
  }
51
51
  }
52
52
  const y = (i, a) => {
53
- const [s, e] = r(), [o, t] = r(), d = (l) => {
53
+ const [s, e] = d(), [o, t] = d(), r = (l) => {
54
54
  e(l);
55
55
  const g = {
56
56
  paramIdx: a,
@@ -64,21 +64,21 @@ const y = (i, a) => {
64
64
  const l = (g) => {
65
65
  var m, c, u, p, b, f, w, M;
66
66
  const { data: n } = g;
67
- console.log("Cabbage-React: receiving message", g), console.log("eple", g.data), console.log("banan", (m = g.data) == null ? void 0 : m.data), console.log("kongle", (u = (c = g.data) == null ? void 0 : c.data) == null ? void 0 : u.paramidx), console.log("ananas", (b = (p = g.data) == null ? void 0 : p.data) == null ? void 0 : b.value), n.command === "widgetUpdate" && n.value !== void 0 && (e(n.value), typeof n.value == "number" ? t("number") : typeof n.value == "string" && t("string")), ((f = n.data) == null ? void 0 : f.paramIdx) === a && n.command === "parameterChange" && ((w = n == null ? void 0 : n.data) == null ? void 0 : w.value) !== void 0 && e((M = n == null ? void 0 : n.data) == null ? void 0 : M.value);
67
+ console.log("Cabbage-React: receiving parameter change", g), console.log("eple", g.data), console.log("banan", (m = g.data) == null ? void 0 : m.data), console.log("kongle", (u = (c = g.data) == null ? void 0 : c.data) == null ? void 0 : u.paramidx), console.log("ananas", (b = (p = g.data) == null ? void 0 : p.data) == null ? void 0 : b.value), n.command === "widgetUpdate" && n.value !== void 0 && (e(n.value), typeof n.value == "number" ? t("number") : typeof n.value == "string" && t("string")), ((f = n.data) == null ? void 0 : f.paramIdx) === a && n.command === "parameterChange" && ((w = n == null ? void 0 : n.data) == null ? void 0 : w.value) !== void 0 && e((M = n == null ? void 0 : n.data) == null ? void 0 : M.value);
68
68
  };
69
69
  return window.addEventListener("message", l), () => {
70
70
  window.removeEventListener("message", l);
71
71
  };
72
72
  }, []), {
73
73
  value: s,
74
- setValue: d
74
+ setValue: r
75
75
  };
76
76
  }, I = (i) => {
77
- const [a, s] = r();
77
+ const [a, s] = d();
78
78
  return C(() => {
79
79
  const e = (o) => {
80
80
  const { data: t } = o;
81
- t.channel === i && t.data && t.command === "widgetUpdate" && (console.log("Cabbage-React: receiving data change", t), s(JSON.parse(t.data)));
81
+ t.channel === i && t.data && t.command === "widgetUpdate" && (console.log("Cabbage-React: receiving properties change", t), s(JSON.parse(t.data)));
82
82
  };
83
83
  return window.addEventListener("message", e), () => {
84
84
  window.removeEventListener("message", e);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cabbage-react",
3
- "version": "1.0.0-beta.23",
3
+ "version": "1.0.0-beta.24",
4
4
  "type": "module",
5
5
  "keywords": [
6
6
  "cabbage",