cabbage-react 1.0.0-beta.1 → 1.0.0-beta.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/dist/cabbage/cabbage.d.ts +6 -39
- package/dist/cabbage/cabbage.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +20 -55
- package/package.json +1 -1
|
@@ -1,42 +1,9 @@
|
|
|
1
1
|
export class Cabbage {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
static
|
|
8
|
-
/**
|
|
9
|
-
* Sends a custom command message.
|
|
10
|
-
* @param {string} command - The custom command.
|
|
11
|
-
* @param {Object|null} [vscode=null] - Optional VSCode API object for messaging.
|
|
12
|
-
*/
|
|
13
|
-
static sendCustomCommand(command: string, vscode?: Object | null): void;
|
|
14
|
-
/**
|
|
15
|
-
* Sends a widget update message.
|
|
16
|
-
* @param {Object} widget - The widget object containing properties.
|
|
17
|
-
* @param {Object|null} [vscode=null] - Optional VSCode API object for messaging.
|
|
18
|
-
*/
|
|
19
|
-
static sendWidgetUpdate(widget: Object, vscode?: Object | null): void;
|
|
20
|
-
/**
|
|
21
|
-
* Sends a MIDI message from the UI.
|
|
22
|
-
* @param {number} statusByte - MIDI status byte.
|
|
23
|
-
* @param {number} dataByte1 - First data byte.
|
|
24
|
-
* @param {number} dataByte2 - Second data byte.
|
|
25
|
-
* @param {Object|null} [vscode=null] - Optional VSCode API object for messaging.
|
|
26
|
-
*/
|
|
27
|
-
static sendMidiMessageFromUI(statusByte: number, dataByte1: number, dataByte2: number, vscode?: Object | null): void;
|
|
28
|
-
/**
|
|
29
|
-
* Handles incoming MIDI messages from the host.
|
|
30
|
-
* @param {number} statusByte - MIDI status byte.
|
|
31
|
-
* @param {number} dataByte1 - First data byte.
|
|
32
|
-
* @param {number} dataByte2 - Second data byte.
|
|
33
|
-
*/
|
|
34
|
-
static MidiMessageFromHost(statusByte: number, dataByte1: number, dataByte2: number): void;
|
|
35
|
-
/**
|
|
36
|
-
* Triggers a file open dialog.
|
|
37
|
-
* @param {Object} vscode - VSCode API object for messaging.
|
|
38
|
-
* @param {string} channel - The channel identifier.
|
|
39
|
-
*/
|
|
40
|
-
static triggerFileOpenDialog(vscode: Object, channel: string): void;
|
|
2
|
+
static sendParameterUpdate(message: any, vscode?: null): void;
|
|
3
|
+
static sendCustomCommand(command: any, vscode?: null): void;
|
|
4
|
+
static sendWidgetUpdate(widget: any, vscode?: null): void;
|
|
5
|
+
static sendMidiMessageFromUI(statusByte: any, dataByte1: any, dataByte2: any, vscode?: null): void;
|
|
6
|
+
static MidiMessageFromHost(statusByte: any, dataByte1: any, dataByte2: any): void;
|
|
7
|
+
static triggerFileOpenDialog(vscode: any, channel: any): void;
|
|
41
8
|
}
|
|
42
9
|
//# sourceMappingURL=cabbage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cabbage.d.ts","sourceRoot":"","sources":["../../src/cabbage/cabbage.js"],"names":[],"mappings":"AAMA;
|
|
1
|
+
{"version":3,"file":"cabbage.d.ts","sourceRoot":"","sources":["../../src/cabbage/cabbage.js"],"names":[],"mappings":"AAMA;IAEE,8DAYC;IAED,4DAYC;IAED,0DAYC;IAED,mGAmBC;IAED,kFAEC;IAED,8DAeC;CAGF"}
|
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 i=require("react");console.log("Cabbage: loading cabbage.js");class m{static sendParameterUpdate(s,a=null){const e={command:"parameterChange",obj:JSON.stringify(s)};a!==null?a.postMessage(e):(console.log("Cabbage: sending parameter change from UI",e),window.sendMessageFromUI(e))}static sendCustomCommand(s,a=null){const e={command:s,text:JSON.stringify({})};console.log("Cabbage: sending custom command from UI",e),a!==null?a.postMessage(e):window.sendMessageFromUI(e)}static sendWidgetUpdate(s,a=null){console.log("Cabbage: sending widget update from UI",s.props);const e={command:"widgetStateUpdate",obj:JSON.stringify(s.props)};a!==null?a.postMessage(e):window.sendMessageFromUI(e)}static sendMidiMessageFromUI(s,a,e,t=null){var d={statusByte:s,dataByte1:a,dataByte2:e};const l={command:"midiMessage",obj:JSON.stringify(d)};console.log("Cabbage: sending midi message from UI",d),t!==null?t.postMessage(l):window.sendMessageFromUI(l)}static MidiMessageFromHost(s,a,e){console.log("Cabbage: Got MIDI Message"+s+":"+a+":"+e)}static triggerFileOpenDialog(s,a){var e={channel:a};const t={command:"fileOpen",obj:JSON.stringify(e)};s!==null?s.postMessage(t):window.sendMessageFromUI(t)}}const c=(o,s)=>{const[a,e]=i.useState(),[t,d]=i.useState(),l=g=>{e(g);const r={paramIdx:s,channel:o,value:g};m.sendParameterUpdate(r,null)};return i.useEffect(()=>{const g=r=>{const{data:n}=r;n.channel===o&&n.command==="widgetUpdate"&&(n.value&&e(n.value),n.data&&d(JSON.parse(n.data)))};return window.addEventListener("message",g),()=>{window.removeEventListener("message",g)}},[]),{value:a,setValue:l,data:t}},u=()=>{const[o,s]=i.useState();return i.useEffect(()=>{const a=e=>{const{data:t}=e;t.data&&t.channel==="MainForm"&&t.command==="widgetUpdate"&&s(JSON.parse(t.data))};return window.addEventListener("message",a),()=>{window.removeEventListener("message",a)}},[]),{data:o}};exports.useCabbageState=c;exports.useGetCabbageFormData=u;
|
package/dist/index.mjs
CHANGED
|
@@ -1,78 +1,43 @@
|
|
|
1
1
|
import { useState as m, useEffect as r } from "react";
|
|
2
2
|
console.log("Cabbage: loading cabbage.js");
|
|
3
3
|
class c {
|
|
4
|
-
/**
|
|
5
|
-
* Sends a parameter update message.
|
|
6
|
-
* @param {Object} message - The parameter update data.
|
|
7
|
-
* @param {Object|null} [vscode=null] - Optional VSCode API object for messaging.
|
|
8
|
-
*/
|
|
9
4
|
static sendParameterUpdate(s, a = null) {
|
|
10
5
|
const e = {
|
|
11
6
|
command: "parameterChange",
|
|
12
7
|
obj: JSON.stringify(s)
|
|
13
8
|
};
|
|
14
|
-
a !== null ? a.postMessage(e) : (console.log("Cabbage: sending parameter change from UI", e),
|
|
9
|
+
a !== null ? a.postMessage(e) : (console.log("Cabbage: sending parameter change from UI", e), window.sendMessageFromUI(e));
|
|
15
10
|
}
|
|
16
|
-
/**
|
|
17
|
-
* Sends a custom command message.
|
|
18
|
-
* @param {string} command - The custom command.
|
|
19
|
-
* @param {Object|null} [vscode=null] - Optional VSCode API object for messaging.
|
|
20
|
-
*/
|
|
21
11
|
static sendCustomCommand(s, a = null) {
|
|
22
12
|
const e = {
|
|
23
13
|
command: s,
|
|
24
14
|
text: JSON.stringify({})
|
|
25
15
|
};
|
|
26
|
-
console.log("Cabbage: sending custom command from UI", e), a !== null ? a.postMessage(e) :
|
|
16
|
+
console.log("Cabbage: sending custom command from UI", e), a !== null ? a.postMessage(e) : window.sendMessageFromUI(e);
|
|
27
17
|
}
|
|
28
|
-
/**
|
|
29
|
-
* Sends a widget update message.
|
|
30
|
-
* @param {Object} widget - The widget object containing properties.
|
|
31
|
-
* @param {Object|null} [vscode=null] - Optional VSCode API object for messaging.
|
|
32
|
-
*/
|
|
33
18
|
static sendWidgetUpdate(s, a = null) {
|
|
34
19
|
console.log("Cabbage: sending widget update from UI", s.props);
|
|
35
20
|
const e = {
|
|
36
21
|
command: "widgetStateUpdate",
|
|
37
22
|
obj: JSON.stringify(s.props)
|
|
38
23
|
};
|
|
39
|
-
a !== null ? a.postMessage(e) :
|
|
24
|
+
a !== null ? a.postMessage(e) : window.sendMessageFromUI(e);
|
|
40
25
|
}
|
|
41
|
-
/**
|
|
42
|
-
* Sends a MIDI message from the UI.
|
|
43
|
-
* @param {number} statusByte - MIDI status byte.
|
|
44
|
-
* @param {number} dataByte1 - First data byte.
|
|
45
|
-
* @param {number} dataByte2 - Second data byte.
|
|
46
|
-
* @param {Object|null} [vscode=null] - Optional VSCode API object for messaging.
|
|
47
|
-
*/
|
|
48
26
|
static sendMidiMessageFromUI(s, a, e, n = null) {
|
|
49
|
-
var
|
|
27
|
+
var i = {
|
|
50
28
|
statusByte: s,
|
|
51
29
|
dataByte1: a,
|
|
52
30
|
dataByte2: e
|
|
53
31
|
};
|
|
54
|
-
const
|
|
32
|
+
const d = {
|
|
55
33
|
command: "midiMessage",
|
|
56
|
-
obj: JSON.stringify(
|
|
34
|
+
obj: JSON.stringify(i)
|
|
57
35
|
};
|
|
58
|
-
console.log("Cabbage: sending midi message from UI",
|
|
36
|
+
console.log("Cabbage: sending midi message from UI", i), n !== null ? n.postMessage(d) : window.sendMessageFromUI(d);
|
|
59
37
|
}
|
|
60
|
-
/**
|
|
61
|
-
* Handles incoming MIDI messages from the host.
|
|
62
|
-
* @param {number} statusByte - MIDI status byte.
|
|
63
|
-
* @param {number} dataByte1 - First data byte.
|
|
64
|
-
* @param {number} dataByte2 - Second data byte.
|
|
65
|
-
*/
|
|
66
38
|
static MidiMessageFromHost(s, a, e) {
|
|
67
|
-
console.log(
|
|
68
|
-
"Cabbage: Got MIDI Message" + s + ":" + a + ":" + e
|
|
69
|
-
);
|
|
39
|
+
console.log("Cabbage: Got MIDI Message" + s + ":" + a + ":" + e);
|
|
70
40
|
}
|
|
71
|
-
/**
|
|
72
|
-
* Triggers a file open dialog.
|
|
73
|
-
* @param {Object} vscode - VSCode API object for messaging.
|
|
74
|
-
* @param {string} channel - The channel identifier.
|
|
75
|
-
*/
|
|
76
41
|
static triggerFileOpenDialog(s, a) {
|
|
77
42
|
var e = {
|
|
78
43
|
channel: a
|
|
@@ -81,33 +46,33 @@ class c {
|
|
|
81
46
|
command: "fileOpen",
|
|
82
47
|
obj: JSON.stringify(e)
|
|
83
48
|
};
|
|
84
|
-
s !== null ? s.postMessage(n) :
|
|
49
|
+
s !== null ? s.postMessage(n) : window.sendMessageFromUI(n);
|
|
85
50
|
}
|
|
86
51
|
}
|
|
87
|
-
const
|
|
88
|
-
const [a, e] = m(), [n,
|
|
52
|
+
const b = (o, s) => {
|
|
53
|
+
const [a, e] = m(), [n, i] = m(), d = (g) => {
|
|
89
54
|
e(g);
|
|
90
|
-
const
|
|
55
|
+
const l = {
|
|
91
56
|
paramIdx: s,
|
|
92
57
|
channel: o,
|
|
93
58
|
value: g
|
|
94
59
|
};
|
|
95
|
-
c.sendParameterUpdate(
|
|
60
|
+
c.sendParameterUpdate(l, null);
|
|
96
61
|
};
|
|
97
62
|
return r(() => {
|
|
98
|
-
const g = (
|
|
99
|
-
const { data: t } =
|
|
100
|
-
t.channel === o && t.command === "widgetUpdate" && (t.value && e(t.value), t.data &&
|
|
63
|
+
const g = (l) => {
|
|
64
|
+
const { data: t } = l;
|
|
65
|
+
t.channel === o && t.command === "widgetUpdate" && (t.value && e(t.value), t.data && i(JSON.parse(t.data)));
|
|
101
66
|
};
|
|
102
67
|
return window.addEventListener("message", g), () => {
|
|
103
68
|
window.removeEventListener("message", g);
|
|
104
69
|
};
|
|
105
70
|
}, []), {
|
|
106
71
|
value: a,
|
|
107
|
-
setValue:
|
|
72
|
+
setValue: d,
|
|
108
73
|
data: n
|
|
109
74
|
};
|
|
110
|
-
},
|
|
75
|
+
}, f = () => {
|
|
111
76
|
const [o, s] = m();
|
|
112
77
|
return r(() => {
|
|
113
78
|
const a = (e) => {
|
|
@@ -122,6 +87,6 @@ const f = (o, s) => {
|
|
|
122
87
|
};
|
|
123
88
|
};
|
|
124
89
|
export {
|
|
125
|
-
|
|
126
|
-
|
|
90
|
+
b as useCabbageState,
|
|
91
|
+
f as useGetCabbageFormData
|
|
127
92
|
};
|