@moises.ai/extension 1.0.1 → 1.0.3
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/Readme.md +19 -1
- package/dist/{client-Bt6Snfq-.js → client-BuA0RRm3.js} +29 -32
- package/dist/client.js +1 -1
- package/dist/index.d.ts +71 -20
- package/dist/index.js +105 -45
- package/package.json +4 -7
- package/src/client.d.ts +71 -20
- package/src/index.d.ts +71 -20
- package/scripts/init-boilerplate.js +0 -114
package/Readme.md
CHANGED
@@ -1 +1,19 @@
|
|
1
|
-
# Moises Extensions SDK
|
1
|
+
# Moises AI | Extensions SDK
|
2
|
+
|
3
|
+
Create powerful extensions for the Moises AI Studio.
|
4
|
+
|
5
|
+
## Documentation
|
6
|
+
|
7
|
+
📖 **[Full Documentation](https://extensions.moises.ai/)** - Complete API reference, guides, and examples
|
8
|
+
|
9
|
+
## Quick Start
|
10
|
+
|
11
|
+
The best way to get started is to bootstrap a new extension project:
|
12
|
+
|
13
|
+
```bash
|
14
|
+
npm create @moises.ai/extension <my-extension>
|
15
|
+
```
|
16
|
+
|
17
|
+
This will create a new extension project with all the necessary files and dependencies to begin development.
|
18
|
+
|
19
|
+
For detailed setup instructions and API reference, visit our [documentation](https://extensions.moises.ai/).
|
@@ -12,29 +12,29 @@ class h {
|
|
12
12
|
this.connected = !1;
|
13
13
|
}
|
14
14
|
handleMessage(e) {
|
15
|
-
const { data: s, source:
|
16
|
-
if (
|
15
|
+
const { data: s, source: n, origin: t } = e;
|
16
|
+
if (n === this.target) {
|
17
17
|
if (s.type === "response") {
|
18
|
-
const { requestId: r, result:
|
19
|
-
|
18
|
+
const { requestId: r, result: c, error: o } = s, d = this.pendingRequests.get(r);
|
19
|
+
d && (o ? d.reject(new Error(o)) : d.resolve(c), this.pendingRequests.delete(r));
|
20
20
|
return;
|
21
21
|
}
|
22
22
|
if (s.type === "request") {
|
23
|
-
const { method: r, params:
|
24
|
-
if (!
|
25
|
-
this.sendResponse(
|
23
|
+
const { method: r, params: c, requestId: o } = s, d = this.handlers.get(r);
|
24
|
+
if (!d) {
|
25
|
+
this.sendResponse(n, o, null, `No handler for method: ${r}`);
|
26
26
|
return;
|
27
27
|
}
|
28
|
-
Promise.resolve().then(() => c
|
28
|
+
Promise.resolve().then(() => d(c)).then((a) => this.sendResponse(n, o, a)).catch((a) => this.sendResponse(n, o, null, a.message));
|
29
29
|
}
|
30
30
|
}
|
31
31
|
}
|
32
|
-
sendResponse(e, s,
|
32
|
+
sendResponse(e, s, n, t = null) {
|
33
33
|
e.postMessage({
|
34
34
|
type: "response",
|
35
35
|
requestId: s,
|
36
|
-
result:
|
37
|
-
error:
|
36
|
+
result: n,
|
37
|
+
error: t
|
38
38
|
}, "*");
|
39
39
|
}
|
40
40
|
on(e, s) {
|
@@ -44,17 +44,17 @@ class h {
|
|
44
44
|
this.handlers.delete(e);
|
45
45
|
}
|
46
46
|
once(e, s) {
|
47
|
-
const
|
48
|
-
this.on(e,
|
47
|
+
const n = async (t) => (this.off(e), s(t));
|
48
|
+
this.on(e, n);
|
49
49
|
}
|
50
50
|
async call(e, s) {
|
51
|
-
const
|
52
|
-
return new Promise((
|
53
|
-
this.pendingRequests.set(
|
51
|
+
const n = this.requestId++;
|
52
|
+
return new Promise((t, r) => {
|
53
|
+
this.pendingRequests.set(n, { resolve: t, reject: r }), this.target.postMessage({
|
54
54
|
type: "request",
|
55
55
|
method: e,
|
56
56
|
params: s,
|
57
|
-
requestId:
|
57
|
+
requestId: n
|
58
58
|
}, "*");
|
59
59
|
});
|
60
60
|
}
|
@@ -66,9 +66,12 @@ class u {
|
|
66
66
|
createProxy() {
|
67
67
|
return new Proxy(this.rpc, {
|
68
68
|
get: (e, s) => s in e ? e[s] : new Proxy({}, {
|
69
|
-
get: (
|
70
|
-
const
|
71
|
-
|
69
|
+
get: (n, t) => s === "link" ? async (r, c) => {
|
70
|
+
const o = await e.call("register.link", { category: t, options: r });
|
71
|
+
this.rpc.on(`${o.id}`, c);
|
72
|
+
} : async (r) => {
|
73
|
+
const c = `${s}.${t}`;
|
74
|
+
return e.call(c, r);
|
72
75
|
}
|
73
76
|
})
|
74
77
|
});
|
@@ -88,19 +91,13 @@ function l(i) {
|
|
88
91
|
version: i.version,
|
89
92
|
isLoaded: !1,
|
90
93
|
events: {}
|
91
|
-
}, { proxy: s, rpc:
|
94
|
+
}, { proxy: s, rpc: n } = new u({
|
92
95
|
target: window.parent
|
93
|
-
})
|
94
|
-
|
95
|
-
s
|
96
|
-
|
97
|
-
|
98
|
-
const c = await n.register.link({ category: r, options: d });
|
99
|
-
t.on(`${c.id}`, o);
|
100
|
-
}, n.connect = async function() {
|
101
|
-
const r = n.register.extension(e);
|
102
|
-
return e.isLoaded = !0, r;
|
103
|
-
}, n.plugin = e, n;
|
96
|
+
});
|
97
|
+
return s.connect = async function() {
|
98
|
+
const t = s.register.extension(e);
|
99
|
+
return e.isLoaded = !0, t;
|
100
|
+
}, s.plugin = e, s;
|
104
101
|
}
|
105
102
|
export {
|
106
103
|
l as M,
|
package/dist/client.js
CHANGED
package/dist/index.d.ts
CHANGED
@@ -1,4 +1,51 @@
|
|
1
1
|
|
2
|
+
/** Link API for managing extension links */
|
3
|
+
export interface LinkApi {
|
4
|
+
|
5
|
+
/** Creates a context menu item for tracks */
|
6
|
+
trackContextMenu: (config: {
|
7
|
+
|
8
|
+
/** Display label for the menu item */
|
9
|
+
label: string;
|
10
|
+
}, onClick: {
|
11
|
+
|
12
|
+
/** Parameters passed to the onClick handler */
|
13
|
+
params: any;
|
14
|
+
}) => void;
|
15
|
+
|
16
|
+
/** Creates a context menu item for single track selections */
|
17
|
+
singleTrackSelectionContextMenu: (config: {
|
18
|
+
|
19
|
+
/** Display label for the menu item */
|
20
|
+
label: string;
|
21
|
+
}, onClick: {
|
22
|
+
|
23
|
+
/** Parameters passed to the onClick handler */
|
24
|
+
params: any;
|
25
|
+
}) => void;
|
26
|
+
|
27
|
+
/** Creates a button in the toolbar */
|
28
|
+
toolbarButton: (config: {
|
29
|
+
|
30
|
+
/** Display label for the button */
|
31
|
+
label: string;
|
32
|
+
|
33
|
+
/** Icon identifier for the button */
|
34
|
+
icon: string;
|
35
|
+
}, onClick: Function) => void;
|
36
|
+
|
37
|
+
/** Creates a button in the footer */
|
38
|
+
footerButton: (config: {
|
39
|
+
|
40
|
+
/** Display label for the button */
|
41
|
+
label: string;
|
42
|
+
|
43
|
+
/** Icon identifier for the button */
|
44
|
+
icon: string;
|
45
|
+
}, onClick: Function) => void;
|
46
|
+
}
|
47
|
+
|
48
|
+
|
2
49
|
/** Controlling common UI elements */
|
3
50
|
export interface UiApi {
|
4
51
|
|
@@ -285,10 +332,10 @@ export interface ComputeApi {
|
|
285
332
|
|
286
333
|
/** The target for the session player */
|
287
334
|
inpaintingTarget: any[];
|
288
|
-
}) => Promise<
|
335
|
+
}) => Promise<any>;
|
289
336
|
|
290
337
|
/** Gets the list of session player presets */
|
291
|
-
sessionPlayerPresets: () =>
|
338
|
+
sessionPlayerPresets: () => void;
|
292
339
|
|
293
340
|
/** Inpaints an audio file */
|
294
341
|
sessionPlayerInpaint: (params: {
|
@@ -298,7 +345,7 @@ export interface ComputeApi {
|
|
298
345
|
|
299
346
|
/** The mask for the inpainting */
|
300
347
|
mask: any;
|
301
|
-
}) => Promise<
|
348
|
+
}) => Promise<any>;
|
302
349
|
|
303
350
|
/** Runs a workflow */
|
304
351
|
workflow: (params: {
|
@@ -306,26 +353,36 @@ export interface ComputeApi {
|
|
306
353
|
/** The ID of the workflow to run */
|
307
354
|
workflowId: string;
|
308
355
|
|
309
|
-
/** The parameters for the workflow
|
356
|
+
/** The parameters for the workflow */
|
310
357
|
params: any;
|
311
|
-
}) => Promise<
|
358
|
+
}) => Promise<any>;
|
312
359
|
|
313
360
|
/** Runs an automix job */
|
314
361
|
automix: (params: {
|
315
362
|
|
316
|
-
/** The ID of the workflow to run
|
363
|
+
/** The ID of the workflow to run */
|
317
364
|
workflowId: string;
|
318
365
|
|
319
|
-
/** The parameters for the workflow
|
366
|
+
/** The parameters for the workflow */
|
320
367
|
params: any;
|
321
|
-
}) => Promise<
|
368
|
+
}) => Promise<any>;
|
369
|
+
|
370
|
+
/** Extracts stems from an audio file */
|
371
|
+
stems: (params: {
|
372
|
+
|
373
|
+
/** The input audio data */
|
374
|
+
input: string;
|
375
|
+
|
376
|
+
/** The stems to extract */
|
377
|
+
stemsToExtract: any[];
|
378
|
+
}) => Promise<any>;
|
322
379
|
|
323
380
|
/** Detects instruments in an audio file */
|
324
381
|
instruments: (params: {
|
325
382
|
|
326
383
|
/** The input audio data */
|
327
|
-
|
328
|
-
}) => Promise<
|
384
|
+
inputUrl: string;
|
385
|
+
}) => Promise<any>;
|
329
386
|
|
330
387
|
/** Detects chords in an audio file */
|
331
388
|
chords: (params: {
|
@@ -354,16 +411,6 @@ export interface ComputeApi {
|
|
354
411
|
/** The input audio data */
|
355
412
|
input: string;
|
356
413
|
}) => Promise<void>;
|
357
|
-
|
358
|
-
/** Extracts stems from an audio file */
|
359
|
-
stems: (params: {
|
360
|
-
|
361
|
-
/** The input audio data */
|
362
|
-
input: string;
|
363
|
-
|
364
|
-
/** The stems to extract */
|
365
|
-
stemsToExtract: any[];
|
366
|
-
}) => void;
|
367
414
|
}
|
368
415
|
|
369
416
|
|
@@ -379,6 +426,8 @@ export interface RegisterApi {
|
|
379
426
|
|
380
427
|
|
381
428
|
export interface MoisesAPI {
|
429
|
+
/** Link API for managing extension links */
|
430
|
+
link: LinkApi;
|
382
431
|
/** Controlling common UI elements */
|
383
432
|
ui: UiApi;
|
384
433
|
/** Session API for managing audio sessions, tracks, and playback controls */
|
@@ -422,6 +471,8 @@ export interface MoisesHook {
|
|
422
471
|
isConnected: boolean;
|
423
472
|
/** Modal layout component for plugin UI */
|
424
473
|
ModalLayout: (props: { children: any; width?: number; height?: number; }) => any;
|
474
|
+
/** Modal layout component for plugin UI */
|
475
|
+
SidebarLayout: (props: { children: any; width?: number; title?: string; }) => any;
|
425
476
|
}
|
426
477
|
|
427
478
|
export interface ExtensionOptions {
|
package/dist/index.js
CHANGED
@@ -1,72 +1,132 @@
|
|
1
|
-
import { jsx as
|
2
|
-
import {
|
3
|
-
import { M as
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
1
|
+
import { jsxs as b, jsx as a } from "react/jsx-runtime";
|
2
|
+
import { useEffect as g, useState as k } from "react";
|
3
|
+
import { M as C, R as S } from "./client-BuA0RRm3.js";
|
4
|
+
import { Box as m, HeaderPanel as p } from "@moises.ai/design-system";
|
5
|
+
import { Cross1Icon as M } from "@moises.ai/design-system/icons";
|
6
|
+
function P({ state: r }) {
|
7
|
+
const { moises: n } = r;
|
8
|
+
function i({ children: s, title: c = "Sidebar Menu", width: u = "300" }) {
|
9
|
+
return g(() => {
|
10
|
+
n && n.ui.setPluginSize({ width: u, height: 0 });
|
11
|
+
}, [u, n]), /* @__PURE__ */ b(
|
12
|
+
m,
|
13
|
+
{
|
14
|
+
height: "100vh",
|
15
|
+
style: {
|
16
|
+
height: "100vh",
|
17
|
+
backgroundColor: "var(--gray-1)",
|
18
|
+
display: "flex",
|
19
|
+
flexDirection: "column",
|
20
|
+
overflow: "hidden"
|
21
|
+
},
|
22
|
+
children: [
|
23
|
+
/* @__PURE__ */ a(
|
24
|
+
m,
|
25
|
+
{
|
26
|
+
p: "4",
|
27
|
+
style: {
|
28
|
+
position: "sticky",
|
29
|
+
top: 0,
|
30
|
+
zIndex: 10,
|
31
|
+
backgroundColor: "var(--neutral-2)"
|
32
|
+
},
|
33
|
+
children: /* @__PURE__ */ a(p, { title: c, children: /* @__PURE__ */ a(
|
34
|
+
p.Button,
|
35
|
+
{
|
36
|
+
onClick: () => {
|
37
|
+
n.ui.close();
|
38
|
+
},
|
39
|
+
children: /* @__PURE__ */ a(M, {})
|
40
|
+
}
|
41
|
+
) })
|
42
|
+
}
|
43
|
+
),
|
44
|
+
/* @__PURE__ */ a(
|
45
|
+
m,
|
46
|
+
{
|
47
|
+
px: "4",
|
48
|
+
style: {
|
49
|
+
flex: 1,
|
50
|
+
overflowY: "auto",
|
51
|
+
backgroundColor: "var(--neutral-2)"
|
52
|
+
},
|
53
|
+
children: s
|
54
|
+
}
|
55
|
+
)
|
56
|
+
]
|
57
|
+
}
|
58
|
+
);
|
59
|
+
}
|
60
|
+
return i;
|
61
|
+
}
|
62
|
+
function z(r) {
|
63
|
+
r.id;
|
64
|
+
let n = null, i = !1;
|
65
|
+
function s() {
|
66
|
+
const [c, u] = k({
|
9
67
|
plugin: null,
|
10
|
-
isConnected:
|
68
|
+
isConnected: i,
|
11
69
|
moises: null
|
12
70
|
});
|
13
71
|
g(() => {
|
14
|
-
|
15
|
-
...
|
16
|
-
plugin:
|
17
|
-
moises:
|
72
|
+
n || (n = C(r), u((l) => ({
|
73
|
+
...l,
|
74
|
+
plugin: n.plugin,
|
75
|
+
moises: n
|
18
76
|
// The entire pluginInstance IS the moises API
|
19
77
|
})));
|
20
|
-
}, [
|
21
|
-
|
22
|
-
|
23
|
-
...
|
78
|
+
}, [r]), g(() => {
|
79
|
+
n && !i && n.connect().then(() => {
|
80
|
+
i = !0, u((l) => ({
|
81
|
+
...l,
|
24
82
|
isConnected: !0
|
25
83
|
}));
|
26
84
|
});
|
27
85
|
}, []);
|
28
|
-
|
29
|
-
|
86
|
+
const h = P({ state: c });
|
87
|
+
function o({ children: l, width: d, height: e }) {
|
88
|
+
const { moises: t } = c;
|
30
89
|
return g(() => {
|
31
|
-
|
32
|
-
}, [
|
90
|
+
t && t.ui.setPluginSize({ width: d, height: e });
|
91
|
+
}, [d, e, t]), /* @__PURE__ */ a("div", { height: "100vh", style: { height: "100vh", backgroundColor: "var(--gray-1)" }, children: /* @__PURE__ */ a("div", { p: "4", children: l }) });
|
33
92
|
}
|
34
93
|
return {
|
35
94
|
...c,
|
36
|
-
ModalLayout:
|
95
|
+
ModalLayout: o,
|
96
|
+
SidebarLayout: h
|
37
97
|
};
|
38
98
|
}
|
39
|
-
return
|
99
|
+
return s;
|
40
100
|
}
|
41
|
-
function
|
42
|
-
const
|
43
|
-
id:
|
44
|
-
url:
|
101
|
+
function I({ id: r, url: n, exposedAPI: i, iframeRef: s, onRegisterMetadata: c, onRegisterLink: u }) {
|
102
|
+
const h = {
|
103
|
+
id: r,
|
104
|
+
url: n
|
45
105
|
};
|
46
|
-
|
47
|
-
const
|
48
|
-
target:
|
106
|
+
s.current && (s.current.src = n);
|
107
|
+
const o = new S({
|
108
|
+
target: s.current.contentWindow
|
49
109
|
});
|
50
|
-
|
110
|
+
o.on("register.extension", async (e) => {
|
51
111
|
c(e);
|
52
|
-
}),
|
53
|
-
const f = `link:${e}:${
|
54
|
-
return u({ id: f, category: e, options:
|
112
|
+
}), o.on("register.link", async ({ category: e, options: t }) => {
|
113
|
+
const f = `link:${e}:${t.label}`;
|
114
|
+
return u({ id: f, category: e, options: t }), { id: f };
|
55
115
|
});
|
56
|
-
for (const [e,
|
57
|
-
for (const [f,
|
58
|
-
const
|
59
|
-
|
116
|
+
for (const [e, t] of Object.entries(i))
|
117
|
+
for (const [f, y] of Object.entries(t)) {
|
118
|
+
const v = `${e}.${f}`;
|
119
|
+
o.on(v, async (x) => await y(x));
|
60
120
|
}
|
61
|
-
function l(e,
|
62
|
-
return
|
121
|
+
function l(e, t) {
|
122
|
+
return o.call(e, t);
|
63
123
|
}
|
64
|
-
function
|
65
|
-
|
124
|
+
function d() {
|
125
|
+
o.disconnect();
|
66
126
|
}
|
67
|
-
return { plugin:
|
127
|
+
return { plugin: h, rpc: o, call: l, disconnect: d };
|
68
128
|
}
|
69
129
|
export {
|
70
|
-
|
71
|
-
|
130
|
+
I as MoisesExtensionHost,
|
131
|
+
z as initMoisesExtension
|
72
132
|
};
|
package/package.json
CHANGED
@@ -1,14 +1,11 @@
|
|
1
1
|
{
|
2
2
|
"name": "@moises.ai/extension",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.3",
|
4
4
|
"description": "SDK for Moises AI extensions",
|
5
5
|
"private": false,
|
6
6
|
"type": "module",
|
7
7
|
"main": "./dist/index.js",
|
8
8
|
"module": "./dist/index.js",
|
9
|
-
"bin": {
|
10
|
-
"moises-extension": "./scripts/init-boilerplate.js"
|
11
|
-
},
|
12
9
|
"exports": {
|
13
10
|
".": {
|
14
11
|
"import": "./dist/index.js",
|
@@ -26,8 +23,7 @@
|
|
26
23
|
"dist",
|
27
24
|
"styles.css",
|
28
25
|
"src/client.d.ts",
|
29
|
-
"src/index.d.ts"
|
30
|
-
"scripts/init-boilerplate.js"
|
26
|
+
"src/index.d.ts"
|
31
27
|
],
|
32
28
|
"scripts": {
|
33
29
|
"build": "vite build",
|
@@ -51,7 +47,8 @@
|
|
51
47
|
"@vitejs/plugin-react": "^4.2.1",
|
52
48
|
"react": "^19.0.0",
|
53
49
|
"react-dom": "^19.0.0",
|
54
|
-
"vite": "^5.1.0"
|
50
|
+
"vite": "^5.1.0",
|
51
|
+
"@moises.ai/design-system": "^2.0.33"
|
55
52
|
},
|
56
53
|
"publishConfig": {
|
57
54
|
"access": "public"
|
package/src/client.d.ts
CHANGED
@@ -1,4 +1,51 @@
|
|
1
1
|
|
2
|
+
/** Link API for managing extension links */
|
3
|
+
export interface LinkApi {
|
4
|
+
|
5
|
+
/** Creates a context menu item for tracks */
|
6
|
+
trackContextMenu: (config: {
|
7
|
+
|
8
|
+
/** Display label for the menu item */
|
9
|
+
label: string;
|
10
|
+
}, onClick: {
|
11
|
+
|
12
|
+
/** Parameters passed to the onClick handler */
|
13
|
+
params: any;
|
14
|
+
}) => void;
|
15
|
+
|
16
|
+
/** Creates a context menu item for single track selections */
|
17
|
+
singleTrackSelectionContextMenu: (config: {
|
18
|
+
|
19
|
+
/** Display label for the menu item */
|
20
|
+
label: string;
|
21
|
+
}, onClick: {
|
22
|
+
|
23
|
+
/** Parameters passed to the onClick handler */
|
24
|
+
params: any;
|
25
|
+
}) => void;
|
26
|
+
|
27
|
+
/** Creates a button in the toolbar */
|
28
|
+
toolbarButton: (config: {
|
29
|
+
|
30
|
+
/** Display label for the button */
|
31
|
+
label: string;
|
32
|
+
|
33
|
+
/** Icon identifier for the button */
|
34
|
+
icon: string;
|
35
|
+
}, onClick: Function) => void;
|
36
|
+
|
37
|
+
/** Creates a button in the footer */
|
38
|
+
footerButton: (config: {
|
39
|
+
|
40
|
+
/** Display label for the button */
|
41
|
+
label: string;
|
42
|
+
|
43
|
+
/** Icon identifier for the button */
|
44
|
+
icon: string;
|
45
|
+
}, onClick: Function) => void;
|
46
|
+
}
|
47
|
+
|
48
|
+
|
2
49
|
/** Controlling common UI elements */
|
3
50
|
export interface UiApi {
|
4
51
|
|
@@ -285,10 +332,10 @@ export interface ComputeApi {
|
|
285
332
|
|
286
333
|
/** The target for the session player */
|
287
334
|
inpaintingTarget: any[];
|
288
|
-
}) => Promise<
|
335
|
+
}) => Promise<any>;
|
289
336
|
|
290
337
|
/** Gets the list of session player presets */
|
291
|
-
sessionPlayerPresets: () =>
|
338
|
+
sessionPlayerPresets: () => void;
|
292
339
|
|
293
340
|
/** Inpaints an audio file */
|
294
341
|
sessionPlayerInpaint: (params: {
|
@@ -298,7 +345,7 @@ export interface ComputeApi {
|
|
298
345
|
|
299
346
|
/** The mask for the inpainting */
|
300
347
|
mask: any;
|
301
|
-
}) => Promise<
|
348
|
+
}) => Promise<any>;
|
302
349
|
|
303
350
|
/** Runs a workflow */
|
304
351
|
workflow: (params: {
|
@@ -306,26 +353,36 @@ export interface ComputeApi {
|
|
306
353
|
/** The ID of the workflow to run */
|
307
354
|
workflowId: string;
|
308
355
|
|
309
|
-
/** The parameters for the workflow
|
356
|
+
/** The parameters for the workflow */
|
310
357
|
params: any;
|
311
|
-
}) => Promise<
|
358
|
+
}) => Promise<any>;
|
312
359
|
|
313
360
|
/** Runs an automix job */
|
314
361
|
automix: (params: {
|
315
362
|
|
316
|
-
/** The ID of the workflow to run
|
363
|
+
/** The ID of the workflow to run */
|
317
364
|
workflowId: string;
|
318
365
|
|
319
|
-
/** The parameters for the workflow
|
366
|
+
/** The parameters for the workflow */
|
320
367
|
params: any;
|
321
|
-
}) => Promise<
|
368
|
+
}) => Promise<any>;
|
369
|
+
|
370
|
+
/** Extracts stems from an audio file */
|
371
|
+
stems: (params: {
|
372
|
+
|
373
|
+
/** The input audio data */
|
374
|
+
input: string;
|
375
|
+
|
376
|
+
/** The stems to extract */
|
377
|
+
stemsToExtract: any[];
|
378
|
+
}) => Promise<any>;
|
322
379
|
|
323
380
|
/** Detects instruments in an audio file */
|
324
381
|
instruments: (params: {
|
325
382
|
|
326
383
|
/** The input audio data */
|
327
|
-
|
328
|
-
}) => Promise<
|
384
|
+
inputUrl: string;
|
385
|
+
}) => Promise<any>;
|
329
386
|
|
330
387
|
/** Detects chords in an audio file */
|
331
388
|
chords: (params: {
|
@@ -354,16 +411,6 @@ export interface ComputeApi {
|
|
354
411
|
/** The input audio data */
|
355
412
|
input: string;
|
356
413
|
}) => Promise<void>;
|
357
|
-
|
358
|
-
/** Extracts stems from an audio file */
|
359
|
-
stems: (params: {
|
360
|
-
|
361
|
-
/** The input audio data */
|
362
|
-
input: string;
|
363
|
-
|
364
|
-
/** The stems to extract */
|
365
|
-
stemsToExtract: any[];
|
366
|
-
}) => void;
|
367
414
|
}
|
368
415
|
|
369
416
|
|
@@ -379,6 +426,8 @@ export interface RegisterApi {
|
|
379
426
|
|
380
427
|
|
381
428
|
export interface MoisesAPI {
|
429
|
+
/** Link API for managing extension links */
|
430
|
+
link: LinkApi;
|
382
431
|
/** Controlling common UI elements */
|
383
432
|
ui: UiApi;
|
384
433
|
/** Session API for managing audio sessions, tracks, and playback controls */
|
@@ -422,6 +471,8 @@ export interface MoisesHook {
|
|
422
471
|
isConnected: boolean;
|
423
472
|
/** Modal layout component for plugin UI */
|
424
473
|
ModalLayout: (props: { children: any; width?: number; height?: number; }) => any;
|
474
|
+
/** Modal layout component for plugin UI */
|
475
|
+
SidebarLayout: (props: { children: any; width?: number; title?: string; }) => any;
|
425
476
|
}
|
426
477
|
|
427
478
|
export interface ExtensionOptions {
|
package/src/index.d.ts
CHANGED
@@ -1,4 +1,51 @@
|
|
1
1
|
|
2
|
+
/** Link API for managing extension links */
|
3
|
+
export interface LinkApi {
|
4
|
+
|
5
|
+
/** Creates a context menu item for tracks */
|
6
|
+
trackContextMenu: (config: {
|
7
|
+
|
8
|
+
/** Display label for the menu item */
|
9
|
+
label: string;
|
10
|
+
}, onClick: {
|
11
|
+
|
12
|
+
/** Parameters passed to the onClick handler */
|
13
|
+
params: any;
|
14
|
+
}) => void;
|
15
|
+
|
16
|
+
/** Creates a context menu item for single track selections */
|
17
|
+
singleTrackSelectionContextMenu: (config: {
|
18
|
+
|
19
|
+
/** Display label for the menu item */
|
20
|
+
label: string;
|
21
|
+
}, onClick: {
|
22
|
+
|
23
|
+
/** Parameters passed to the onClick handler */
|
24
|
+
params: any;
|
25
|
+
}) => void;
|
26
|
+
|
27
|
+
/** Creates a button in the toolbar */
|
28
|
+
toolbarButton: (config: {
|
29
|
+
|
30
|
+
/** Display label for the button */
|
31
|
+
label: string;
|
32
|
+
|
33
|
+
/** Icon identifier for the button */
|
34
|
+
icon: string;
|
35
|
+
}, onClick: Function) => void;
|
36
|
+
|
37
|
+
/** Creates a button in the footer */
|
38
|
+
footerButton: (config: {
|
39
|
+
|
40
|
+
/** Display label for the button */
|
41
|
+
label: string;
|
42
|
+
|
43
|
+
/** Icon identifier for the button */
|
44
|
+
icon: string;
|
45
|
+
}, onClick: Function) => void;
|
46
|
+
}
|
47
|
+
|
48
|
+
|
2
49
|
/** Controlling common UI elements */
|
3
50
|
export interface UiApi {
|
4
51
|
|
@@ -285,10 +332,10 @@ export interface ComputeApi {
|
|
285
332
|
|
286
333
|
/** The target for the session player */
|
287
334
|
inpaintingTarget: any[];
|
288
|
-
}) => Promise<
|
335
|
+
}) => Promise<any>;
|
289
336
|
|
290
337
|
/** Gets the list of session player presets */
|
291
|
-
sessionPlayerPresets: () =>
|
338
|
+
sessionPlayerPresets: () => void;
|
292
339
|
|
293
340
|
/** Inpaints an audio file */
|
294
341
|
sessionPlayerInpaint: (params: {
|
@@ -298,7 +345,7 @@ export interface ComputeApi {
|
|
298
345
|
|
299
346
|
/** The mask for the inpainting */
|
300
347
|
mask: any;
|
301
|
-
}) => Promise<
|
348
|
+
}) => Promise<any>;
|
302
349
|
|
303
350
|
/** Runs a workflow */
|
304
351
|
workflow: (params: {
|
@@ -306,26 +353,36 @@ export interface ComputeApi {
|
|
306
353
|
/** The ID of the workflow to run */
|
307
354
|
workflowId: string;
|
308
355
|
|
309
|
-
/** The parameters for the workflow
|
356
|
+
/** The parameters for the workflow */
|
310
357
|
params: any;
|
311
|
-
}) => Promise<
|
358
|
+
}) => Promise<any>;
|
312
359
|
|
313
360
|
/** Runs an automix job */
|
314
361
|
automix: (params: {
|
315
362
|
|
316
|
-
/** The ID of the workflow to run
|
363
|
+
/** The ID of the workflow to run */
|
317
364
|
workflowId: string;
|
318
365
|
|
319
|
-
/** The parameters for the workflow
|
366
|
+
/** The parameters for the workflow */
|
320
367
|
params: any;
|
321
|
-
}) => Promise<
|
368
|
+
}) => Promise<any>;
|
369
|
+
|
370
|
+
/** Extracts stems from an audio file */
|
371
|
+
stems: (params: {
|
372
|
+
|
373
|
+
/** The input audio data */
|
374
|
+
input: string;
|
375
|
+
|
376
|
+
/** The stems to extract */
|
377
|
+
stemsToExtract: any[];
|
378
|
+
}) => Promise<any>;
|
322
379
|
|
323
380
|
/** Detects instruments in an audio file */
|
324
381
|
instruments: (params: {
|
325
382
|
|
326
383
|
/** The input audio data */
|
327
|
-
|
328
|
-
}) => Promise<
|
384
|
+
inputUrl: string;
|
385
|
+
}) => Promise<any>;
|
329
386
|
|
330
387
|
/** Detects chords in an audio file */
|
331
388
|
chords: (params: {
|
@@ -354,16 +411,6 @@ export interface ComputeApi {
|
|
354
411
|
/** The input audio data */
|
355
412
|
input: string;
|
356
413
|
}) => Promise<void>;
|
357
|
-
|
358
|
-
/** Extracts stems from an audio file */
|
359
|
-
stems: (params: {
|
360
|
-
|
361
|
-
/** The input audio data */
|
362
|
-
input: string;
|
363
|
-
|
364
|
-
/** The stems to extract */
|
365
|
-
stemsToExtract: any[];
|
366
|
-
}) => void;
|
367
414
|
}
|
368
415
|
|
369
416
|
|
@@ -379,6 +426,8 @@ export interface RegisterApi {
|
|
379
426
|
|
380
427
|
|
381
428
|
export interface MoisesAPI {
|
429
|
+
/** Link API for managing extension links */
|
430
|
+
link: LinkApi;
|
382
431
|
/** Controlling common UI elements */
|
383
432
|
ui: UiApi;
|
384
433
|
/** Session API for managing audio sessions, tracks, and playback controls */
|
@@ -422,6 +471,8 @@ export interface MoisesHook {
|
|
422
471
|
isConnected: boolean;
|
423
472
|
/** Modal layout component for plugin UI */
|
424
473
|
ModalLayout: (props: { children: any; width?: number; height?: number; }) => any;
|
474
|
+
/** Modal layout component for plugin UI */
|
475
|
+
SidebarLayout: (props: { children: any; width?: number; title?: string; }) => any;
|
425
476
|
}
|
426
477
|
|
427
478
|
export interface ExtensionOptions {
|
@@ -1,114 +0,0 @@
|
|
1
|
-
#!/usr/bin/env node
|
2
|
-
import { promisify } from "util";
|
3
|
-
import cp from "child_process";
|
4
|
-
import path from "path";
|
5
|
-
import fs from "fs";
|
6
|
-
|
7
|
-
// convert libs to promises
|
8
|
-
const exec = promisify(cp.exec);
|
9
|
-
const rm = promisify(fs.rm);
|
10
|
-
|
11
|
-
// Simple custom spinner implementation
|
12
|
-
class Spinner {
|
13
|
-
constructor(message) {
|
14
|
-
this.message = message;
|
15
|
-
this.frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
16
|
-
this.currentFrame = 0;
|
17
|
-
this.isSpinning = false;
|
18
|
-
this.interval = null;
|
19
|
-
}
|
20
|
-
|
21
|
-
start() {
|
22
|
-
this.isSpinning = true;
|
23
|
-
process.stdout.write('\x1B[?25l'); // Hide cursor
|
24
|
-
this.interval = setInterval(() => {
|
25
|
-
process.stdout.write('\r' + this.frames[this.currentFrame] + ' ' + this.message);
|
26
|
-
this.currentFrame = (this.currentFrame + 1) % this.frames.length;
|
27
|
-
}, 100);
|
28
|
-
return this;
|
29
|
-
}
|
30
|
-
|
31
|
-
succeed(successMessage) {
|
32
|
-
this.stop();
|
33
|
-
process.stdout.write('\r✅ ' + (successMessage || this.message) + '\n');
|
34
|
-
}
|
35
|
-
|
36
|
-
fail(errorMessage) {
|
37
|
-
this.stop();
|
38
|
-
process.stdout.write('\r❌ ' + (errorMessage || this.message) + '\n');
|
39
|
-
}
|
40
|
-
|
41
|
-
stop() {
|
42
|
-
if (this.interval) {
|
43
|
-
clearInterval(this.interval);
|
44
|
-
this.interval = null;
|
45
|
-
}
|
46
|
-
this.isSpinning = false;
|
47
|
-
process.stdout.write('\x1B[?25h'); // Show cursor
|
48
|
-
process.stdout.write('\r' + ' '.repeat(this.message.length + 10) + '\r');
|
49
|
-
}
|
50
|
-
}
|
51
|
-
|
52
|
-
if (process.argv.length < 3) {
|
53
|
-
console.log("You have to provide a name for your extension project.");
|
54
|
-
console.log("For example:");
|
55
|
-
console.log(" npx @moises.ai/extension my-extension");
|
56
|
-
process.exit(1);
|
57
|
-
}
|
58
|
-
|
59
|
-
// Display ASCII banner
|
60
|
-
console.log(`
|
61
|
-
_ _
|
62
|
-
(_) (_)
|
63
|
-
_ __ ___ ___ _ ___ ___ ___ __ _ _
|
64
|
-
| '_ \` _ \\ / _ \\| / __|/ _ \\/ __| / _\` | |
|
65
|
-
| | | | | | (_) | \\__ \\ __/\\__ \\| (_| | |
|
66
|
-
|_| |_| |_|\\___/|_|___/\\___||___(_)__,_|_|
|
67
|
-
|
68
|
-
`);
|
69
|
-
|
70
|
-
const projectName = process.argv[2];
|
71
|
-
const currentPath = process.cwd();
|
72
|
-
const projectPath = path.join(currentPath, projectName);
|
73
|
-
const git_repo = "https://github.com/moises-ai/extensions-boilerplate.git";
|
74
|
-
|
75
|
-
// create project directory
|
76
|
-
if (fs.existsSync(projectPath)) {
|
77
|
-
console.log(`The directory ${projectName} already exists in the current directory, please give it another name.`);
|
78
|
-
process.exit(1);
|
79
|
-
} else {
|
80
|
-
fs.mkdirSync(projectPath);
|
81
|
-
}
|
82
|
-
|
83
|
-
try {
|
84
|
-
const gitSpinner = new Spinner("Downloading boilerplate files...").start();
|
85
|
-
// clone the repo into the project folder -> creates the new boilerplate
|
86
|
-
await exec(`git clone --depth 1 ${git_repo} ${projectPath} --quiet`);
|
87
|
-
gitSpinner.succeed();
|
88
|
-
|
89
|
-
const cleanSpinner = new Spinner("Cleaning up template files...").start();
|
90
|
-
// remove git history to start fresh
|
91
|
-
const rmGit = rm(path.join(projectPath, ".git"), { recursive: true, force: true });
|
92
|
-
await rmGit;
|
93
|
-
cleanSpinner.succeed();
|
94
|
-
|
95
|
-
// change to project directory for npm operations
|
96
|
-
process.chdir(projectPath);
|
97
|
-
|
98
|
-
const npmSpinner = new Spinner("Installing dependencies...").start();
|
99
|
-
await exec("npm install");
|
100
|
-
npmSpinner.succeed();
|
101
|
-
|
102
|
-
console.log("\n🎉 Extension project created successfully!");
|
103
|
-
console.log("\nNext steps:");
|
104
|
-
console.log(` cd ${projectName}`);
|
105
|
-
console.log(` npm run dev`);
|
106
|
-
console.log("\nHappy coding! 🚀");
|
107
|
-
|
108
|
-
} catch (error) {
|
109
|
-
// clean up in case of error, so the user does not have to do it manually
|
110
|
-
fs.rmSync(projectPath, { recursive: true, force: true });
|
111
|
-
console.error("❌ Error creating extension project:");
|
112
|
-
console.error(error.message);
|
113
|
-
process.exit(1);
|
114
|
-
}
|