@signalsandsorcery/plugin-sdk 1.0.0 → 1.1.0

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.mjs CHANGED
@@ -75,24 +75,60 @@ function InstrumentDrawer({
75
75
  currentPluginId,
76
76
  isLoading,
77
77
  onSelect,
78
- onRefresh
78
+ onRefresh,
79
+ stage = "instruments",
80
+ onShowEditor,
81
+ onBackToInstruments,
82
+ selectedInstrumentName
79
83
  }) {
80
84
  const [search, setSearch] = useState("");
81
85
  const SURGE_XT_DEFAULT_ID = "Surge XT";
82
86
  const filtered = useMemo(() => {
83
- const all = instruments.filter(
87
+ let all = instruments.filter(
84
88
  (i) => i.name !== "Surge XT"
85
89
  );
86
- if (!search.trim()) return all;
87
- const q = search.toLowerCase();
88
- return all.filter(
89
- (i) => i.name.toLowerCase().includes(q) || i.manufacturer.toLowerCase().includes(q)
90
- );
91
- }, [instruments, search]);
90
+ if (search.trim()) {
91
+ const q = search.toLowerCase();
92
+ all = all.filter(
93
+ (i) => i.name.toLowerCase().includes(q) || i.manufacturer.toLowerCase().includes(q)
94
+ );
95
+ }
96
+ if (currentPluginId) {
97
+ const selectedIdx = all.findIndex((i) => i.pluginId === currentPluginId);
98
+ if (selectedIdx > 0) {
99
+ const [selected] = all.splice(selectedIdx, 1);
100
+ all.unshift(selected);
101
+ }
102
+ }
103
+ return all;
104
+ }, [instruments, search, currentPluginId]);
92
105
  const isDefaultSelected = currentPluginId === null;
93
106
  const isSelected = (pluginId) => {
94
107
  return pluginId === currentPluginId;
95
108
  };
109
+ if (stage === "editor") {
110
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
111
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
112
+ /* @__PURE__ */ jsx(
113
+ "button",
114
+ {
115
+ onClick: () => onBackToInstruments?.(),
116
+ className: "px-2 py-1 text-xs rounded-sm border border-sas-border text-sas-muted hover:text-sas-accent hover:border-sas-accent transition-colors",
117
+ children: "\u2190 Back"
118
+ }
119
+ ),
120
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-sas-muted font-medium truncate flex-1", children: selectedInstrumentName ?? "Plugin" })
121
+ ] }),
122
+ /* @__PURE__ */ jsx(
123
+ "button",
124
+ {
125
+ onClick: () => onShowEditor?.(),
126
+ className: "w-full py-2 text-xs font-medium rounded-sm border border-sas-accent bg-sas-accent/20 text-sas-accent hover:bg-sas-accent/40 transition-colors",
127
+ children: "Open Plugin Editor"
128
+ }
129
+ )
130
+ ] });
131
+ }
96
132
  return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
97
133
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
98
134
  /* @__PURE__ */ jsx(
@@ -957,7 +993,10 @@ function TrackRow({
957
993
  currentInstrumentPluginId,
958
994
  onInstrumentSelect,
959
995
  instrumentsLoading,
960
- onRefreshInstruments
996
+ onRefreshInstruments,
997
+ instrumentDrawerStage,
998
+ onShowEditor,
999
+ onBackToInstruments
961
1000
  }) {
962
1001
  const { muted: isMuted, solo: isSoloed, volume: currentVolume, pan: currentPan } = runtimeState;
963
1002
  const needsGeneration = !!(prompt?.trim() && !hasMidi && !isGenerating);
@@ -1102,9 +1141,9 @@ function TrackRow({
1102
1141
  {
1103
1142
  "data-testid": "sdk-shuffle-button",
1104
1143
  onClick: onShuffle,
1105
- disabled: !hasMidi || isGenerating,
1106
- className: `w-14 py-0.5 rounded-sm text-xs font-medium transition-colors border ${!hasMidi || isGenerating ? "bg-sas-panel border-sas-border text-sas-muted/30 cursor-not-allowed" : "bg-sas-panel-alt border-sas-border text-sas-muted hover:border-sas-accent hover:text-sas-accent"}`,
1107
- title: hasMidi ? "Re-roll sound (keep MIDI)" : "Generate MIDI first",
1144
+ disabled: !hasMidi || isGenerating || !!currentInstrumentPluginId,
1145
+ className: `w-14 py-0.5 rounded-sm text-xs font-medium transition-colors border ${!hasMidi || isGenerating || !!currentInstrumentPluginId ? "bg-sas-panel border-sas-border text-sas-muted/30 cursor-not-allowed" : "bg-sas-panel-alt border-sas-border text-sas-muted hover:border-sas-accent hover:text-sas-accent"}`,
1146
+ title: currentInstrumentPluginId ? "Shuffle only works with default Surge XT" : hasMidi ? "Re-roll sound (keep MIDI)" : "Generate MIDI first",
1108
1147
  children: "Shuffle"
1109
1148
  }
1110
1149
  ),
@@ -1164,7 +1203,11 @@ function TrackRow({
1164
1203
  currentPluginId: currentInstrumentPluginId ?? null,
1165
1204
  isLoading: instrumentsLoading ?? false,
1166
1205
  onSelect: onInstrumentSelect,
1167
- onRefresh: onRefreshInstruments
1206
+ onRefresh: onRefreshInstruments,
1207
+ stage: instrumentDrawerStage,
1208
+ onShowEditor,
1209
+ onBackToInstruments,
1210
+ selectedInstrumentName: instrumentName
1168
1211
  }
1169
1212
  ) })
1170
1213
  ] });