@signalsandsorcery/plugin-sdk 1.0.0 → 1.2.1

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.js CHANGED
@@ -125,24 +125,60 @@ function InstrumentDrawer({
125
125
  currentPluginId,
126
126
  isLoading,
127
127
  onSelect,
128
- onRefresh
128
+ onRefresh,
129
+ stage = "instruments",
130
+ onShowEditor,
131
+ onBackToInstruments,
132
+ selectedInstrumentName
129
133
  }) {
130
134
  const [search, setSearch] = (0, import_react.useState)("");
131
135
  const SURGE_XT_DEFAULT_ID = "Surge XT";
132
136
  const filtered = (0, import_react.useMemo)(() => {
133
- const all = instruments.filter(
137
+ let all = instruments.filter(
134
138
  (i) => i.name !== "Surge XT"
135
139
  );
136
- if (!search.trim()) return all;
137
- const q = search.toLowerCase();
138
- return all.filter(
139
- (i) => i.name.toLowerCase().includes(q) || i.manufacturer.toLowerCase().includes(q)
140
- );
141
- }, [instruments, search]);
140
+ if (search.trim()) {
141
+ const q = search.toLowerCase();
142
+ all = all.filter(
143
+ (i) => i.name.toLowerCase().includes(q) || i.manufacturer.toLowerCase().includes(q)
144
+ );
145
+ }
146
+ if (currentPluginId) {
147
+ const selectedIdx = all.findIndex((i) => i.pluginId === currentPluginId);
148
+ if (selectedIdx > 0) {
149
+ const [selected] = all.splice(selectedIdx, 1);
150
+ all.unshift(selected);
151
+ }
152
+ }
153
+ return all;
154
+ }, [instruments, search, currentPluginId]);
142
155
  const isDefaultSelected = currentPluginId === null;
143
156
  const isSelected = (pluginId) => {
144
157
  return pluginId === currentPluginId;
145
158
  };
159
+ if (stage === "editor") {
160
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-col gap-2", children: [
161
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-2", children: [
162
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
163
+ "button",
164
+ {
165
+ onClick: () => onBackToInstruments?.(),
166
+ 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",
167
+ children: "\u2190 Back"
168
+ }
169
+ ),
170
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "text-xs text-sas-muted font-medium truncate flex-1", children: selectedInstrumentName ?? "Plugin" })
171
+ ] }),
172
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
173
+ "button",
174
+ {
175
+ onClick: () => onShowEditor?.(),
176
+ 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",
177
+ children: "Open Plugin Editor"
178
+ }
179
+ )
180
+ ] });
181
+ }
146
182
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-col gap-2", children: [
147
183
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-2", children: [
148
184
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -1007,7 +1043,10 @@ function TrackRow({
1007
1043
  currentInstrumentPluginId,
1008
1044
  onInstrumentSelect,
1009
1045
  instrumentsLoading,
1010
- onRefreshInstruments
1046
+ onRefreshInstruments,
1047
+ instrumentDrawerStage,
1048
+ onShowEditor,
1049
+ onBackToInstruments
1011
1050
  }) {
1012
1051
  const { muted: isMuted, solo: isSoloed, volume: currentVolume, pan: currentPan } = runtimeState;
1013
1052
  const needsGeneration = !!(prompt?.trim() && !hasMidi && !isGenerating);
@@ -1152,9 +1191,9 @@ function TrackRow({
1152
1191
  {
1153
1192
  "data-testid": "sdk-shuffle-button",
1154
1193
  onClick: onShuffle,
1155
- disabled: !hasMidi || isGenerating,
1156
- 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"}`,
1157
- title: hasMidi ? "Re-roll sound (keep MIDI)" : "Generate MIDI first",
1194
+ disabled: !hasMidi || isGenerating || !!currentInstrumentPluginId,
1195
+ 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"}`,
1196
+ title: currentInstrumentPluginId ? "Shuffle only works with default Surge XT" : hasMidi ? "Re-roll sound (keep MIDI)" : "Generate MIDI first",
1158
1197
  children: "Shuffle"
1159
1198
  }
1160
1199
  ),
@@ -1214,7 +1253,11 @@ function TrackRow({
1214
1253
  currentPluginId: currentInstrumentPluginId ?? null,
1215
1254
  isLoading: instrumentsLoading ?? false,
1216
1255
  onSelect: onInstrumentSelect,
1217
- onRefresh: onRefreshInstruments
1256
+ onRefresh: onRefreshInstruments,
1257
+ stage: instrumentDrawerStage,
1258
+ onShowEditor,
1259
+ onBackToInstruments,
1260
+ selectedInstrumentName: instrumentName
1218
1261
  }
1219
1262
  ) })
1220
1263
  ] });