faustwave 0.97.0 → 0.98.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/README.md +16 -4
- package/dist/npm/faustwave.mjs +477 -218
- package/dist/npm/page/assets/index-BjG-7GzL.js +2 -0
- package/dist/npm/page/assets/{index-mh2yfI-1.css → index-DD296uwb.css} +1 -1
- package/dist/npm/page/files.json +1 -1
- package/dist/npm/page/index.html +2 -2
- package/package.json +1 -1
- package/dist/npm/page/assets/index-ZhxohMeI.js +0 -2
package/dist/npm/faustwave.mjs
CHANGED
|
@@ -8058,9 +8058,11 @@ __export(hub_exports, {
|
|
|
8058
8058
|
HUB_OPERATIONS: () => HUB_OPERATIONS,
|
|
8059
8059
|
hubCall: () => hubCall,
|
|
8060
8060
|
hubCommand: () => hubCommand,
|
|
8061
|
+
signedInAsAdmin: () => signedInAsAdmin,
|
|
8061
8062
|
zipFolder: () => zipFolder
|
|
8062
8063
|
});
|
|
8063
8064
|
import fs3 from "node:fs";
|
|
8065
|
+
import { gunzipSync } from "node:zlib";
|
|
8064
8066
|
import path5 from "node:path";
|
|
8065
8067
|
import { crc32, deflateRawSync } from "node:zlib";
|
|
8066
8068
|
async function tokenCall(fields) {
|
|
@@ -8091,6 +8093,7 @@ async function login() {
|
|
|
8091
8093
|
if (typeof t.refresh_token !== "string") throw new Error("Logto gave no refresh token (is offline_access allowed for the app?)");
|
|
8092
8094
|
writeLogin({ refreshToken: t.refresh_token });
|
|
8093
8095
|
const me = await hub("GET", "/users/me");
|
|
8096
|
+
rememberAdmin(me.role === "admin");
|
|
8094
8097
|
return `signed in to ${HUB} as ${me.username ?? me.displayName}${me.role === "admin" ? " (admin)" : ""}`;
|
|
8095
8098
|
}
|
|
8096
8099
|
throw new Error("the code expired \u2014 run faustwave login again");
|
|
@@ -8105,6 +8108,7 @@ async function accessToken() {
|
|
|
8105
8108
|
throw new Error(`the sign-in to ${HUB} has expired \u2014 run faustwave login`);
|
|
8106
8109
|
}
|
|
8107
8110
|
writeLogin({
|
|
8111
|
+
admin: login2.admin,
|
|
8108
8112
|
refreshToken: typeof t.refresh_token === "string" ? t.refresh_token : login2.refreshToken,
|
|
8109
8113
|
accessToken: t.access_token,
|
|
8110
8114
|
expiresAt: Date.now() + Number(t.expires_in ?? 3600) * 1e3
|
|
@@ -8160,7 +8164,7 @@ async function hub(method, route, body) {
|
|
|
8160
8164
|
const problems = Array.isArray(json?.problems) ? `
|
|
8161
8165
|
- ${json.problems.join("\n - ")}` : "";
|
|
8162
8166
|
const message = Array.isArray(json?.message) ? json.message.join("; ") : json?.message ?? res.statusText;
|
|
8163
|
-
throw new Error(`${method} ${route}: ${res.status} ${message}${problems}`);
|
|
8167
|
+
throw new Error(res.status >= 500 || !json?.message ? `${method} ${route}: ${res.status} ${message}${problems}` : `${message}${problems}`);
|
|
8164
8168
|
}
|
|
8165
8169
|
return json;
|
|
8166
8170
|
}
|
|
@@ -8211,6 +8215,39 @@ function zipFolder(dir) {
|
|
|
8211
8215
|
end.writeUInt32LE(offset, 16);
|
|
8212
8216
|
return Buffer.concat([...locals, cd, end]);
|
|
8213
8217
|
}
|
|
8218
|
+
async function waiting(slug) {
|
|
8219
|
+
const all = await hub("GET", "/review");
|
|
8220
|
+
const version2 = all.find((r) => r.app.slug === slug)?.version;
|
|
8221
|
+
if (!version2) throw new Error(`${slug}: no release of it waits \u2014 faustwave review lists what does`);
|
|
8222
|
+
return version2;
|
|
8223
|
+
}
|
|
8224
|
+
function pluginSays(file2) {
|
|
8225
|
+
let tar;
|
|
8226
|
+
try {
|
|
8227
|
+
tar = gunzipSync(file2);
|
|
8228
|
+
} catch {
|
|
8229
|
+
throw new Error("push takes a plugin package (.wclap.tar.gz, as faustwave build plugin makes it) or a player folder");
|
|
8230
|
+
}
|
|
8231
|
+
for (let at = 0; at + 512 <= tar.length; ) {
|
|
8232
|
+
const name = tar.toString("utf8", at, at + 100).replace(/\0.*$/, "");
|
|
8233
|
+
if (!name) break;
|
|
8234
|
+
const size = parseInt(tar.toString("ascii", at + 124, at + 136), 8) || 0;
|
|
8235
|
+
if (name === "plugin.json" || name === "./plugin.json") {
|
|
8236
|
+
const p = JSON.parse(tar.toString("utf8", at + 512, at + 512 + size));
|
|
8237
|
+
if (!p.name || !p.version) break;
|
|
8238
|
+
return { title: p.name, version: p.version, type: p.instrument ? "instrument" : "effect", channel: "wclap" };
|
|
8239
|
+
}
|
|
8240
|
+
at += 512 + Math.ceil(size / 512) * 512;
|
|
8241
|
+
}
|
|
8242
|
+
throw new Error("the package does not say its name and version (plugin.json) \u2014 build it with faustwave build plugin");
|
|
8243
|
+
}
|
|
8244
|
+
function playerSays(dir) {
|
|
8245
|
+
const file2 = path5.join(dir, "faustwave.json");
|
|
8246
|
+
if (!fs3.existsSync(file2)) throw new Error(`${dir} holds no faustwave.json \u2014 push a player folder as FaustWave exports it, or a plugin package`);
|
|
8247
|
+
const m = JSON.parse(fs3.readFileSync(file2, "utf8"));
|
|
8248
|
+
if (!m.name || !m.version || !m.type) throw new Error("faustwave.json does not say name, version and type");
|
|
8249
|
+
return { title: m.name, version: m.version, type: m.type, channel: "web" };
|
|
8250
|
+
}
|
|
8214
8251
|
async function hubCommand(command2, args) {
|
|
8215
8252
|
const enc = encodeURIComponent;
|
|
8216
8253
|
switch (command2) {
|
|
@@ -8220,11 +8257,6 @@ async function hubCommand(command2, args) {
|
|
|
8220
8257
|
writeLogin(null);
|
|
8221
8258
|
return `signed out of ${HUB}`;
|
|
8222
8259
|
case "app": {
|
|
8223
|
-
if (args[0] === "create") {
|
|
8224
|
-
const [, slug, type, ...title] = need(args, 4, "app create <slug> <type> <title>");
|
|
8225
|
-
await hub("POST", "/apps", { slug, type, title: title.join(" ") });
|
|
8226
|
-
return `app ${slug} made \u2014 a draft, seen by you only: describe it, give it a picture, push a build (faustwave push ${slug} <version> <channel> <file>), then faustwave submit ${slug} <version> \u2014 the admin reviews it and makes it public`;
|
|
8227
|
-
}
|
|
8228
8260
|
if (args[0] === "visibility") {
|
|
8229
8261
|
const [, slug, visibility] = need(args, 3, "app visibility <slug> <draft | unlisted | public>");
|
|
8230
8262
|
await hub("PATCH", `/apps/${enc(slug)}`, { visibility });
|
|
@@ -8237,91 +8269,118 @@ async function hubCommand(command2, args) {
|
|
|
8237
8269
|
await hub("PATCH", `/apps/${enc(slug)}`, { description });
|
|
8238
8270
|
return `app ${slug}: description set (${description.length} characters)`;
|
|
8239
8271
|
}
|
|
8240
|
-
if (args[0] === "items") {
|
|
8241
|
-
const [, slug] = need(args, 3, "app items <slug> <item\u2026| none>");
|
|
8242
|
-
const items = args[2] === "none" ? [] : args.slice(2);
|
|
8243
|
-
await hub("PATCH", `/apps/${enc(slug)}`, { items });
|
|
8244
|
-
return items.length ? `app ${slug} presents ${items.join(", ")} \u2014 its page offers them` : `app ${slug} presents nothing for sale`;
|
|
8245
|
-
}
|
|
8246
8272
|
if (args[0] === "cover") {
|
|
8247
|
-
const [, slug,
|
|
8248
|
-
const bytes = fs3.readFileSync(
|
|
8273
|
+
const [, slug, file2] = need(args, 3, "app cover <slug> <picture file>");
|
|
8274
|
+
const bytes = fs3.readFileSync(file2);
|
|
8249
8275
|
const body = new FormData();
|
|
8250
|
-
body.append("file", new Blob([new Uint8Array(bytes)]), path5.basename(
|
|
8276
|
+
body.append("file", new Blob([new Uint8Array(bytes)]), path5.basename(file2));
|
|
8251
8277
|
await hub("PUT", `/apps/${enc(slug)}/cover`, body);
|
|
8252
8278
|
return `app ${slug}: picture set (${(bytes.length / 1024).toFixed(0)} KB)`;
|
|
8253
8279
|
}
|
|
8254
|
-
throw new Error("usage: faustwave app
|
|
8255
|
-
}
|
|
8256
|
-
case "item": {
|
|
8257
|
-
if (args[0] === "create") {
|
|
8258
|
-
const [, slug, ...title] = need(args, 3, "item create <slug> <title>");
|
|
8259
|
-
await hub("POST", "/items", { slug, title: title.join(" ") });
|
|
8260
|
-
return `item ${slug} made \u2014 not for sale until it has a price (faustwave item price ${slug} <pri_\u2026>)`;
|
|
8261
|
-
}
|
|
8262
|
-
if (args[0] === "price") {
|
|
8263
|
-
const [, slug, price] = need(args, 3, "item price <slug> <pri_\u2026 | free | none>");
|
|
8264
|
-
const body = price === "free" ? { free: true } : price === "none" ? { free: false, paddlePriceId: null } : { paddlePriceId: price };
|
|
8265
|
-
await hub("PATCH", `/items/${enc(slug)}`, body);
|
|
8266
|
-
if (price === "free") return `item ${slug} is free \u2014 taken with a license, on the website`;
|
|
8267
|
-
return price === "none" ? `item ${slug} is not to have` : `item ${slug} sells at Paddle price ${price} (who took it free keeps it)`;
|
|
8268
|
-
}
|
|
8269
|
-
if (args[0] === "file") {
|
|
8270
|
-
const [, slug, file] = need(args, 3, "item file <slug> <file>");
|
|
8271
|
-
const bytes = fs3.readFileSync(file);
|
|
8272
|
-
const body = new FormData();
|
|
8273
|
-
body.append("file", new Blob([new Uint8Array(bytes)]), path5.basename(file));
|
|
8274
|
-
const item = await hub("PUT", `/items/${enc(slug)}/file`, body);
|
|
8275
|
-
return `item ${slug}: file set (${(bytes.length / 1024).toFixed(0)} KB) \u2014 its buyers download ${item.fileName ?? path5.basename(file)}`;
|
|
8276
|
-
}
|
|
8277
|
-
throw new Error("usage: faustwave item create <slug> <title> | item price <slug> <pri_\u2026 | free | none> | item file <slug> <file>");
|
|
8278
|
-
}
|
|
8279
|
-
case "purchases": {
|
|
8280
|
-
const [slug] = need(args, 1, "purchases <item>");
|
|
8281
|
-
const rows = await hub("GET", `/items/${enc(slug)}/purchases`);
|
|
8282
|
-
if (!rows.length) return `${slug}: no purchases`;
|
|
8283
|
-
return rows.map((p) => `${p.id} ${p.status.padEnd(8)} ${p.purchasedAt.slice(0, 10)} ${p.buyer} (${p.transactionId})`).join("\n");
|
|
8284
|
-
}
|
|
8285
|
-
case "refund": {
|
|
8286
|
-
const [id, ...reason] = need(args, 1, "refund <purchase-id> [reason]");
|
|
8287
|
-
const r = await hub("POST", `/purchases/${enc(id)}/refund`, reason.length ? { reason: reason.join(" ") } : {});
|
|
8288
|
-
return `refund asked of Paddle: ${r.transactionId} (${r.adjustmentId}, ${r.status}) \u2014 the purchase is revoked once Paddle reports it`;
|
|
8289
|
-
}
|
|
8290
|
-
case "reconcile": {
|
|
8291
|
-
const days = args[0] ? Number(args[0]) : void 0;
|
|
8292
|
-
const r = await hub("POST", "/shop/reconcile", days ? { days } : {});
|
|
8293
|
-
return `reconciled: ${r.transactions} transaction(s) at Paddle, ${r.added} purchase(s) added, ${r.changed} changed`;
|
|
8280
|
+
throw new Error("usage: faustwave app describe <slug> <text | file> | app cover <slug> <picture file> | app visibility <slug> <draft | unlisted | public>");
|
|
8294
8281
|
}
|
|
8295
8282
|
case "push": {
|
|
8296
|
-
const [
|
|
8283
|
+
const [source, named] = need(args, 1, "push <plugin.wclap.tar.gz | player folder> [slug]");
|
|
8297
8284
|
const stat = fs3.statSync(source);
|
|
8298
|
-
const
|
|
8285
|
+
const file2 = stat.isDirectory() ? zipFolder(source) : fs3.readFileSync(source);
|
|
8299
8286
|
const name = stat.isDirectory() ? `${path5.basename(path5.resolve(source))}.zip` : path5.basename(source);
|
|
8287
|
+
const says = stat.isDirectory() ? playerSays(source) : pluginSays(file2);
|
|
8288
|
+
const slug = named ?? says.title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
8289
|
+
const mine = await hub("GET", "/users/me/apps");
|
|
8290
|
+
const made = !mine.some((a) => a.slug === slug);
|
|
8291
|
+
if (made) await hub("POST", "/apps", { slug, type: says.type, title: says.title });
|
|
8300
8292
|
const body = new FormData();
|
|
8301
|
-
body.append("file", new Blob([new Uint8Array(
|
|
8302
|
-
|
|
8303
|
-
return
|
|
8293
|
+
body.append("file", new Blob([new Uint8Array(file2)]), name);
|
|
8294
|
+
await hub("PUT", `/apps/${enc(slug)}/releases/${enc(says.version)}/builds/${says.channel}`, body);
|
|
8295
|
+
return [
|
|
8296
|
+
`pushed ${name} (${(file2.length / 1024).toFixed(0)} KB) as ${slug} ${says.version}${made ? " \u2014 a new app" : ""}: a draft, seen by you only`,
|
|
8297
|
+
` play it: ${SITE}/${says.channel === "wclap" ? "plugins" : "apps"}/${slug} (signed in there as you)`,
|
|
8298
|
+
...made ? [` describe: faustwave app describe ${slug} <text | file> and its picture: faustwave app cover ${slug} <picture file>`] : [],
|
|
8299
|
+
` ready: faustwave submit ${slug} \u2014 the admin reviews it`
|
|
8300
|
+
].join("\n");
|
|
8304
8301
|
}
|
|
8305
8302
|
case "submit": {
|
|
8306
|
-
const [slug
|
|
8303
|
+
const [slug] = need(args, 1, "submit <slug>");
|
|
8304
|
+
const mine = await hub("GET", "/users/me/apps");
|
|
8305
|
+
const app = mine.find((a) => a.slug === slug);
|
|
8306
|
+
const version2 = app?.releases.find((r) => r.status === "draft" || r.status === "rejected")?.version;
|
|
8307
|
+
if (!version2)
|
|
8308
|
+
throw new Error(
|
|
8309
|
+
app?.releases.length ? `${slug}: nothing to submit \u2014 ${app.releases[0].version} is ${app.releases[0].status}; a new version: faustwave push <file>` : `${slug}: nothing of yours to submit \u2014 faustwave push <file> first (yours: faustwave me)`
|
|
8310
|
+
);
|
|
8307
8311
|
await hub("POST", `/apps/${enc(slug)}/releases/${enc(version2)}/submit`);
|
|
8308
|
-
|
|
8312
|
+
const lacks = [
|
|
8313
|
+
...app?.description ? [] : [` it has no description yet: faustwave app describe ${slug} <text | file>`],
|
|
8314
|
+
...app?.coverArtifactId ? [] : [` it has no picture yet: faustwave app cover ${slug} <picture file>`]
|
|
8315
|
+
];
|
|
8316
|
+
return [`${slug} ${version2} submitted \u2014 the admin reviews it: published, it is out and in the catalog (nothing more to do); rejected, faustwave me says why`, ...lacks].join("\n");
|
|
8309
8317
|
}
|
|
8310
8318
|
case "review": {
|
|
8311
8319
|
const asked = await request("GET", "/review");
|
|
8312
|
-
if (asked.status === 403) throw new Error("only the admin reviews \u2014 your own releases: faustwave
|
|
8320
|
+
if (asked.status === 403) throw new Error("only the admin reviews \u2014 your own releases: faustwave me");
|
|
8313
8321
|
if (asked.status >= 400) throw new Error(`GET /review: ${asked.status} ${String(asked.json?.message ?? asked.statusText)}`);
|
|
8314
|
-
const
|
|
8315
|
-
|
|
8316
|
-
|
|
8317
|
-
|
|
8318
|
-
|
|
8319
|
-
|
|
8322
|
+
const waiting2 = asked.json;
|
|
8323
|
+
const asking = await hub("GET", "/users/publishing/requests");
|
|
8324
|
+
if (!waiting2.length && !asking.length) return "nothing to review";
|
|
8325
|
+
return [
|
|
8326
|
+
...waiting2.flatMap((r) => [
|
|
8327
|
+
` ${r.app.slug.padEnd(24)} ${r.version.padEnd(12)} ${r.app.type.padEnd(10)} ${r.channels.join(", ").padEnd(16)} by ${r.app.owner ?? r.app.ownerId}, ${(r.submittedAt ?? "").slice(0, 16).replace("T", " ")}`,
|
|
8328
|
+
...r.lacks?.length ? [` its page has no ${r.lacks.join(" and no ")} yet`] : [],
|
|
8329
|
+
` ${r.app.title} \u2014 faustwave publish ${r.app.slug} | faustwave reject ${r.app.slug} <reason>`
|
|
8330
|
+
]),
|
|
8331
|
+
...asking.flatMap((u) => [
|
|
8332
|
+
` ${(u.username ?? u.id).padEnd(24)} asks to publish, ${(u.askedAt ?? "").slice(0, 16).replace("T", " ")}: ${u.ask}`,
|
|
8333
|
+
` ${u.displayName} \u2014 faustwave allow ${u.username ?? u.id} | faustwave decline ${u.username ?? u.id} <reason>`
|
|
8334
|
+
])
|
|
8335
|
+
].join("\n");
|
|
8336
|
+
}
|
|
8337
|
+
case "reject": {
|
|
8338
|
+
const [slug, ...reason] = need(args, 2, "reject <slug> <reason>");
|
|
8339
|
+
const version2 = await waiting(slug);
|
|
8340
|
+
await hub("POST", `/apps/${enc(slug)}/releases/${enc(version2)}/reject`, { reason: reason.join(" ") });
|
|
8341
|
+
return `${slug} ${version2} rejected \u2014 its publisher reads the reason and submits it again`;
|
|
8342
|
+
}
|
|
8343
|
+
case "me": {
|
|
8344
|
+
if (args[0] === "ask") {
|
|
8345
|
+
const words = args.slice(1).join(" ");
|
|
8346
|
+
if (!words) throw new Error("usage: faustwave me ask <what you want to publish> \u2014 a sentence or two, the admin reads it");
|
|
8347
|
+
await hub("POST", "/users/me/publishing", { words });
|
|
8348
|
+
return "asked \u2014 the admin answers; how it stands: faustwave me";
|
|
8349
|
+
}
|
|
8350
|
+
const who = await hub("GET", "/users/me");
|
|
8351
|
+
rememberAdmin(who.role === "admin");
|
|
8352
|
+
const publishing = who.role === "admin" ? "you are the admin \u2014 you publish" : who.publishing === "allowed" ? "you may publish" : who.publishing === "asked" ? `your request waits for the admin: ${who.publishingAsk ?? ""}` : who.publishing === "declined" ? `your request was declined: ${who.publishingNote ?? ""}
|
|
8353
|
+
ask again: faustwave me ask <what you want to publish>` : "you cannot publish yet \u2014 ask for it: faustwave me ask <what you want to publish>";
|
|
8354
|
+
const apps = await hub("GET", "/users/me/apps");
|
|
8355
|
+
return [
|
|
8356
|
+
`${who.username ?? who.displayName} (${who.role})`,
|
|
8357
|
+
`publishing: ${publishing}`,
|
|
8358
|
+
"apps:",
|
|
8359
|
+
...apps.length ? apps.flatMap((p) => [
|
|
8360
|
+
// (whether the catalog shows it — not its releases' state — and what its page still lacks)
|
|
8361
|
+
` ${p.title} (${p.slug}, ${p.type}) \u2014 ${p.visibility === "public" ? "in the catalog" : p.visibility === "unlisted" ? "unlisted: by its link only" : "not in the catalog yet"}${p.description ? "" : ", no description"}${p.coverArtifactId ? "" : ", no picture"}`,
|
|
8362
|
+
` ${SITE}/${p.releases[0]?.channels.includes("wclap") ? "plugins" : "apps"}/${p.slug}`,
|
|
8363
|
+
...(p.releases.length ? p.releases : [null]).flatMap(
|
|
8364
|
+
(r) => r ? [` ${r.version.padEnd(16)} ${r.status.padEnd(10)} ${r.channels.join(", ")}`, ...r.rejectReason ? [` rejected: ${r.rejectReason}`] : []] : [" no releases"]
|
|
8365
|
+
)
|
|
8366
|
+
]) : [who.role === "admin" || who.publishing === "allowed" ? " none \u2014 faustwave push <file>, then faustwave submit <slug>" : " none"]
|
|
8367
|
+
].join("\n");
|
|
8368
|
+
}
|
|
8369
|
+
case "allow": {
|
|
8370
|
+
const [who] = need(args, 1, "allow <user>");
|
|
8371
|
+
await hub("POST", `/users/${enc(who)}/publishing/allow`);
|
|
8372
|
+
return `${who} may publish`;
|
|
8373
|
+
}
|
|
8374
|
+
case "decline": {
|
|
8375
|
+
const [who, ...reason] = need(args, 2, "decline <user> <reason>");
|
|
8376
|
+
await hub("POST", `/users/${enc(who)}/publishing/decline`, { reason: reason.join(" ") });
|
|
8377
|
+
return `${who} declined \u2014 they read the reason and may ask again`;
|
|
8320
8378
|
}
|
|
8321
8379
|
case "publish": {
|
|
8322
|
-
const [slug
|
|
8380
|
+
const [slug] = need(args, 1, "publish <slug>");
|
|
8381
|
+
const version2 = await waiting(slug);
|
|
8323
8382
|
await hub("POST", `/apps/${enc(slug)}/releases/${enc(version2)}/publish`);
|
|
8324
|
-
return `${slug} ${version2} published`;
|
|
8383
|
+
return `${slug} ${version2} published \u2014 out, and in the catalog`;
|
|
8325
8384
|
}
|
|
8326
8385
|
case "yank": {
|
|
8327
8386
|
const [slug, version2] = need(args, 2, "yank <slug> <version>");
|
|
@@ -8332,20 +8391,22 @@ async function hubCommand(command2, args) {
|
|
|
8332
8391
|
const [slug] = need(args, 1, "releases <slug>");
|
|
8333
8392
|
const app = await hub("GET", `/apps/${enc(slug)}`);
|
|
8334
8393
|
const releases = await hub("GET", `/apps/${enc(slug)}/releases`);
|
|
8335
|
-
const lines = releases.map((r) => ` ${r.version.padEnd(16)} ${r.status.padEnd(10)} ${r.channels.join(", ")}`
|
|
8394
|
+
const lines = releases.map((r) => ` ${r.version.padEnd(16)} ${r.status.padEnd(10)} ${r.channels.join(", ")}${r.rejectReason ? `
|
|
8395
|
+
rejected: ${r.rejectReason}` : ""}`);
|
|
8336
8396
|
return [`${app.title} (${slug}, ${app.type}, ${app.visibility}) \u2014 latest: ${app.latestVersion ?? "none published"}`, ...lines.length ? lines : [" no releases"]].join("\n");
|
|
8337
8397
|
}
|
|
8338
8398
|
default:
|
|
8339
8399
|
throw new Error(`unknown command ${command2}`);
|
|
8340
8400
|
}
|
|
8341
8401
|
}
|
|
8342
|
-
var HUB, LOGTO, RESOURCE, clientId, loginFile, readLogins, writeLogin, form, HUB_OPERATIONS, need;
|
|
8402
|
+
var HUB, LOGTO, SITE, RESOURCE, clientId, loginFile, readLogins, writeLogin, form, signedInAsAdmin, rememberAdmin, HUB_OPERATIONS, need;
|
|
8343
8403
|
var init_hub = __esm({
|
|
8344
8404
|
"src/hub.ts"() {
|
|
8345
8405
|
"use strict";
|
|
8346
8406
|
init_pipe();
|
|
8347
8407
|
HUB = (process.env.FW_HUB_URL ?? "https://api.faustwave.io").replace(/\/$/, "");
|
|
8348
8408
|
LOGTO = (process.env.FW_LOGTO_ENDPOINT ?? "https://auth.faustwave.io").replace(/\/$/, "");
|
|
8409
|
+
SITE = (process.env.FW_SITE_URL ?? "https://faustwave.io").replace(/\/$/, "");
|
|
8349
8410
|
RESOURCE = "https://api.faustwave.app";
|
|
8350
8411
|
clientId = () => process.env.FW_LOGTO_CLI_APP_ID ?? "3lv6swtkqexu0opygy136";
|
|
8351
8412
|
loginFile = () => path5.join(userData(), "hub-login.json");
|
|
@@ -8368,6 +8429,11 @@ var init_hub = __esm({
|
|
|
8368
8429
|
headers: { "content-type": "application/x-www-form-urlencoded" },
|
|
8369
8430
|
body: new URLSearchParams(fields)
|
|
8370
8431
|
});
|
|
8432
|
+
signedInAsAdmin = () => readLogins()[HUB]?.admin === true;
|
|
8433
|
+
rememberAdmin = (admin) => {
|
|
8434
|
+
const login2 = readLogins()[HUB];
|
|
8435
|
+
if (login2 && login2.admin !== admin) writeLogin({ ...login2, admin });
|
|
8436
|
+
};
|
|
8371
8437
|
HUB_OPERATIONS = {
|
|
8372
8438
|
getApp: { method: "GET", route: "/apps/{slug}" },
|
|
8373
8439
|
createApp: { method: "POST", route: "/apps" },
|
|
@@ -8377,8 +8443,8 @@ var init_hub = __esm({
|
|
|
8377
8443
|
submitRelease: { method: "POST", route: "/apps/{slug}/releases/{version}/submit" },
|
|
8378
8444
|
publishRelease: { method: "POST", route: "/apps/{slug}/releases/{version}/publish" }
|
|
8379
8445
|
};
|
|
8380
|
-
need = (args, n,
|
|
8381
|
-
if (args.length < n || args.slice(0, n).some((a) => !a)) throw new Error(`usage: faustwave ${
|
|
8446
|
+
need = (args, n, usage2) => {
|
|
8447
|
+
if (args.length < n || args.slice(0, n).some((a) => !a)) throw new Error(`usage: faustwave ${usage2}`);
|
|
8382
8448
|
return args;
|
|
8383
8449
|
};
|
|
8384
8450
|
}
|
|
@@ -8416,14 +8482,14 @@ function answerOf(lines) {
|
|
|
8416
8482
|
return lines.next().then((r) => r.done ? null : !/^\s*(s|n|stop|no)\s*$/i.test(r.value));
|
|
8417
8483
|
}
|
|
8418
8484
|
function fileOf(what) {
|
|
8419
|
-
const [
|
|
8420
|
-
const bundled = new URL(`../workflows/${
|
|
8421
|
-
return [/^[a-z0-9-]+$/.test(
|
|
8485
|
+
const [file2, inFile] = what.split("#");
|
|
8486
|
+
const bundled = new URL(`../workflows/${file2}.arazzo.yaml`, import.meta.url);
|
|
8487
|
+
return [/^[a-z0-9-]+$/.test(file2) && fs4.existsSync(bundled) ? fileURLToPath(bundled) : file2, inFile];
|
|
8422
8488
|
}
|
|
8423
8489
|
function overHub(what) {
|
|
8424
8490
|
if (!what) return false;
|
|
8425
|
-
const [
|
|
8426
|
-
return /\.ya?ml$/i.test(
|
|
8491
|
+
const [file2] = fileOf(what);
|
|
8492
|
+
return /\.ya?ml$/i.test(file2) && fs4.existsSync(file2) && /url:\s*['"]?faustwave:hub\b/.test(fs4.readFileSync(file2, "utf8"));
|
|
8427
8493
|
}
|
|
8428
8494
|
async function workflow(args, out = (l) => process.stdout.write(l + "\n")) {
|
|
8429
8495
|
const [sub, what, inputs] = args;
|
|
@@ -8435,10 +8501,10 @@ async function workflow(args, out = (l) => process.stdout.write(l + "\n")) {
|
|
|
8435
8501
|
out("faustwave workflow list\nfaustwave workflow run <id | file.arazzo.yaml[#workflowId]> [inputs: json | file]\nfaustwave workflow run publish-plugin | review-release <inputs> (over the Hub \u2014 no IDE needed)");
|
|
8436
8502
|
return 2;
|
|
8437
8503
|
}
|
|
8438
|
-
const [
|
|
8439
|
-
const given = /\.ya?ml$/i.test(
|
|
8440
|
-
if (overHub(what)) return runOnHub(fs4.readFileSync(
|
|
8441
|
-
const input = given ? { source: fs4.readFileSync(
|
|
8504
|
+
const [file2, inFile] = fileOf(what);
|
|
8505
|
+
const given = /\.ya?ml$/i.test(file2) && fs4.existsSync(file2);
|
|
8506
|
+
if (overHub(what)) return runOnHub(fs4.readFileSync(file2, "utf8"), inFile, inputs, out);
|
|
8507
|
+
const input = given ? { source: fs4.readFileSync(file2, "utf8"), ...inFile ? { workflow: inFile } : {} } : { workflow: what };
|
|
8442
8508
|
if (inputs) input.inputs = JSON.parse(fs4.existsSync(inputs) ? fs4.readFileSync(inputs, "utf8") : inputs);
|
|
8443
8509
|
let run2 = await call("workflow.start", input);
|
|
8444
8510
|
out(`${run2.title ?? run2.id}`);
|
|
@@ -8529,9 +8595,11 @@ function deviceMeta(...trees) {
|
|
|
8529
8595
|
const faders = /* @__PURE__ */ new Set();
|
|
8530
8596
|
const cols = /* @__PURE__ */ new Map();
|
|
8531
8597
|
const monitors = [];
|
|
8532
|
-
const
|
|
8598
|
+
const steps = [];
|
|
8599
|
+
const rowAt = /* @__PURE__ */ new Map();
|
|
8600
|
+
const walk = (items, group, path8) => {
|
|
8533
8601
|
for (const it of items ?? []) {
|
|
8534
|
-
if (it.items) walk(it.items);
|
|
8602
|
+
if (it.items) walk(it.items, groupName(it.label), `${path8}/${it.label ?? ""}`);
|
|
8535
8603
|
if (!it.address) continue;
|
|
8536
8604
|
const says = (it.meta ?? []).filter((m) => typeof m.device === "string").map((m) => m.device.trim());
|
|
8537
8605
|
if (says.includes("big")) big.add(it.address);
|
|
@@ -8546,13 +8614,30 @@ function deviceMeta(...trees) {
|
|
|
8546
8614
|
if (!m.addresses.includes(it.address)) m.addresses.push(it.address);
|
|
8547
8615
|
if (col && !m.col) m.col = Number(col);
|
|
8548
8616
|
}
|
|
8617
|
+
const st = says.map((s) => /^steps(?::(.+))?$/.exec(s)).find(Boolean);
|
|
8618
|
+
if (st && it.type !== "button") {
|
|
8619
|
+
const name = (st[1] ?? "steps").trim();
|
|
8620
|
+
let g = steps.find((x) => x.name === name);
|
|
8621
|
+
if (!g) steps.push(g = { name, rows: [] });
|
|
8622
|
+
if (isBargraph(it)) g.marker ??= it.address;
|
|
8623
|
+
else if (it.type !== "checkbox") g.length ??= it.address;
|
|
8624
|
+
else {
|
|
8625
|
+
const at = `${name}\0${path8}`;
|
|
8626
|
+
let row = rowAt.get(at);
|
|
8627
|
+
if (!row) {
|
|
8628
|
+
g.rows.push(row = { name: group, addresses: [] });
|
|
8629
|
+
rowAt.set(at, row);
|
|
8630
|
+
}
|
|
8631
|
+
if (!row.addresses.includes(it.address)) row.addresses.push(it.address);
|
|
8632
|
+
}
|
|
8633
|
+
}
|
|
8549
8634
|
}
|
|
8550
8635
|
};
|
|
8551
|
-
for (const t of trees) walk(t);
|
|
8552
|
-
return { big, faders, cols, monitors };
|
|
8636
|
+
for (const t of trees) walk(t, "", "");
|
|
8637
|
+
return { big, faders, cols, monitors, steps: steps.filter((g) => g.rows.length) };
|
|
8553
8638
|
}
|
|
8554
8639
|
function laysOut(meta2) {
|
|
8555
|
-
return meta2.big.size > 0 || meta2.cols.size > 0 || meta2.monitors.length > 0;
|
|
8640
|
+
return meta2.big.size > 0 || meta2.cols.size > 0 || meta2.monitors.length > 0 || meta2.steps.length > 0;
|
|
8556
8641
|
}
|
|
8557
8642
|
function merged(trees) {
|
|
8558
8643
|
const merge2 = (into, items) => {
|
|
@@ -8565,21 +8650,38 @@ function merged(trees) {
|
|
|
8565
8650
|
};
|
|
8566
8651
|
return trees.reduce((all, t) => merge2(all, t), []);
|
|
8567
8652
|
}
|
|
8568
|
-
function deviceLayout(trees, meta2) {
|
|
8569
|
-
const monitorOf = new Map(meta2.monitors.flatMap((
|
|
8653
|
+
function deviceLayout(trees, meta2, dense = false) {
|
|
8654
|
+
const monitorOf = new Map(meta2.monitors.flatMap((m2) => m2.addresses.map((a) => [a, m2])));
|
|
8655
|
+
const stepsOf = new Map(meta2.steps.flatMap((g) => [...g.rows.flatMap((r) => r.addresses), ...g.marker ? [g.marker] : []].map((a) => [a, g])));
|
|
8656
|
+
const rowOf = (it) => {
|
|
8657
|
+
const held = it.items ?? [];
|
|
8658
|
+
return isGroup(it) && held.length > 0 && held.every((x) => x.address && stepsOf.has(x.address)) ? stepsOf.get(held[0].address) : void 0;
|
|
8659
|
+
};
|
|
8660
|
+
const stood = /* @__PURE__ */ new Set();
|
|
8570
8661
|
const isBig = (it) => !!it.address && meta2.big.has(it.address);
|
|
8571
8662
|
const sectionsOf = (items, path8) => {
|
|
8572
8663
|
const own2 = (items ?? []).filter((it) => !isGroup(it));
|
|
8573
8664
|
const monitors = [...new Set(own2.flatMap((it) => it.address && monitorOf.get(it.address) || []))];
|
|
8574
|
-
const
|
|
8665
|
+
const steps = [...new Set((items ?? []).flatMap((it) => rowOf(it) ?? (it.address ? stepsOf.get(it.address) : void 0) ?? []))].filter((g) => !stood.has(g));
|
|
8666
|
+
for (const g of steps) stood.add(g);
|
|
8667
|
+
const controls = own2.filter((it) => !(it.address && (monitorOf.has(it.address) || stepsOf.has(it.address))));
|
|
8575
8668
|
const name = path8.join(" / ");
|
|
8576
8669
|
const out = [];
|
|
8577
8670
|
if (controls.some(isBig)) out.push({ kind: "section", name, items: controls.filter(isBig), big: true });
|
|
8578
8671
|
const rest2 = controls.filter((it) => !isBig(it));
|
|
8579
|
-
if (rest2.length || monitors.length
|
|
8580
|
-
|
|
8672
|
+
if (rest2.length || monitors.length || steps.length)
|
|
8673
|
+
out.push({ kind: "section", name, items: rest2, big: false, ...monitors.length ? { monitors } : {}, ...steps.length ? { steps } : {} });
|
|
8674
|
+
for (const it of items ?? []) if (isGroup(it) && !rowOf(it)) out.push(...sectionsOf(it.items, [...path8, groupName(it.label)]));
|
|
8581
8675
|
return out;
|
|
8582
8676
|
};
|
|
8677
|
+
const isRow = (it) => isGroup(it) && (it.items ?? []).some((x) => isGroup(x) && !rowOf(x));
|
|
8678
|
+
const isStack = (it) => it.type === "vgroup" && (it.items ?? []).length > 0 && (it.items ?? []).every(isRow);
|
|
8679
|
+
const placesOf = (items) => [
|
|
8680
|
+
...sectionsOf((items ?? []).filter((it) => !isGroup(it) || rowOf(it)), []),
|
|
8681
|
+
...(items ?? []).flatMap(
|
|
8682
|
+
(it) => !isGroup(it) || rowOf(it) ? [] : isStack(it) ? [{ kind: "stack", name: groupName(it.label), rows: (it.items ?? []).map((r) => ({ name: groupName(r.label), places: placesOf(r.items).map((place) => ({ place, cells: 0 })) })) }] : sectionsOf(it.items, [groupName(it.label)])
|
|
8683
|
+
)
|
|
8684
|
+
];
|
|
8583
8685
|
const rows = [];
|
|
8584
8686
|
let loose = [];
|
|
8585
8687
|
const flush = () => {
|
|
@@ -8587,53 +8689,64 @@ function deviceLayout(trees, meta2) {
|
|
|
8587
8689
|
loose = [];
|
|
8588
8690
|
};
|
|
8589
8691
|
for (const top of merged(trees)) {
|
|
8590
|
-
const items = isGroup(top) ? top.items ?? [] : [top];
|
|
8591
|
-
loose.push(...sectionsOf(items.filter((it) => !isGroup(it)), []));
|
|
8592
|
-
for (const g of items.filter(isGroup)) {
|
|
8692
|
+
const items = (isGroup(top) ? top.items ?? [] : [top]).flatMap((it) => isGroup(top) && isGroup(it) && groupName(it.label) === groupName(top.label) ? it.items ?? [] : [it]);
|
|
8693
|
+
loose.push(...sectionsOf(items.filter((it) => !isGroup(it) || rowOf(it)), []));
|
|
8694
|
+
for (const g of items.filter((it) => isGroup(it) && !rowOf(it))) {
|
|
8593
8695
|
const name = groupName(g.label);
|
|
8594
|
-
if ((g
|
|
8696
|
+
if (isRow(g)) {
|
|
8595
8697
|
flush();
|
|
8596
|
-
rows.push({ name, places:
|
|
8698
|
+
rows.push({ name, places: placesOf(g.items) });
|
|
8597
8699
|
} else loose.push(...sectionsOf(g.items, [name]));
|
|
8598
8700
|
}
|
|
8599
8701
|
flush();
|
|
8600
8702
|
}
|
|
8601
|
-
const
|
|
8602
|
-
const
|
|
8703
|
+
const m = DEVICE_METRICS[dense ? "dense" : "normal"];
|
|
8704
|
+
const controlsWidth = (p) => p.items.reduce((n, it) => n + cellsOf(it, meta2, dense), 0);
|
|
8705
|
+
const stepsWidth = (p) => Math.max(0, ...(p.steps ?? []).map((g) => Math.ceil((stepsSize(g, m).width + 2 * m.pad + m.gap) / m.cell)));
|
|
8706
|
+
const widthOf = (p) => p.kind === "stack" ? Math.max(0, ...p.rows.map((r) => r.places.reduce((n, c) => n + (c.cells = widthOf(c.place)), 0))) : Math.max(p.monitors?.length ? MONITOR_CELLS : PLACE_CELLS, controlsWidth(p), stepsWidth(p));
|
|
8603
8707
|
const laid = rows.filter((r) => r.places.length).map((r) => ({ name: r.name, places: r.places.map((place) => ({ place, cells: widthOf(place) })) }));
|
|
8604
8708
|
const cells = Math.max(0, ...laid.map((r) => r.places.reduce((n, c) => n + c.cells, 0)));
|
|
8605
|
-
|
|
8709
|
+
const fill2 = (r, wide) => {
|
|
8606
8710
|
const used = r.places.reduce((n, c) => n + c.cells, 0);
|
|
8607
|
-
const
|
|
8608
|
-
if (
|
|
8609
|
-
|
|
8711
|
+
const screen = r.places.find((c) => c.place.kind === "section" && c.place.monitors?.length);
|
|
8712
|
+
if (screen && used < wide) screen.cells += wide - used;
|
|
8713
|
+
for (const c of r.places) if (c.place.kind === "stack") for (const sub of c.place.rows) fill2(sub, c.cells);
|
|
8714
|
+
};
|
|
8715
|
+
for (const r of laid) fill2(r, cells);
|
|
8610
8716
|
return { rows: laid, cells };
|
|
8611
8717
|
}
|
|
8612
8718
|
function deviceSize(layout, meta2, dense = false) {
|
|
8613
8719
|
const m = DEVICE_METRICS[dense ? "dense" : "normal"];
|
|
8614
8720
|
const width = layout.cells * m.cell;
|
|
8615
|
-
const tall = (p) => (p.items.length ? p.items.some((it) => it.address && meta2.big.has(it.address)) ? m.bigRow : m.row : 0) + (p.monitors?.length ? m.screen : 0);
|
|
8616
|
-
const rowHeight = (r) => m.title + 2 * m.pad + m.gap +
|
|
8721
|
+
const tall = (p) => (p.items.length ? p.items.some((it) => it.address && meta2.big.has(it.address)) ? m.bigRow : m.row : 0) + (p.monitors?.length ? m.screen : 0) + (p.steps ?? []).reduce((h, g) => h + stepsSize(g, m).height + 4, 0);
|
|
8722
|
+
const rowHeight = (r) => Math.max(...r.places.map((c) => c.place.kind === "stack" ? c.place.rows.reduce((h, sub) => h + rowHeight(sub), 0) : m.title + 2 * m.pad + m.gap + tall(c.place)));
|
|
8617
8723
|
return { width: Math.ceil(width), height: Math.ceil(layout.rows.reduce((h, r) => h + rowHeight(r), 0)) };
|
|
8618
8724
|
}
|
|
8619
|
-
var isGroup, isBargraph, groupName,
|
|
8725
|
+
var isGroup, isBargraph, groupName, radioCells, cellsOf, PLACE_CELLS, MONITOR_CELLS, stepsSize, DEVICE_METRICS;
|
|
8620
8726
|
var init_device = __esm({
|
|
8621
8727
|
"../faustwave-svelte/src/faust/device.ts"() {
|
|
8622
8728
|
"use strict";
|
|
8623
8729
|
isGroup = (it) => it.type === "vgroup" || it.type === "hgroup" || it.type === "tgroup";
|
|
8624
8730
|
isBargraph = (it) => it.type === "hbargraph" || it.type === "vbargraph";
|
|
8625
8731
|
groupName = (label) => (label ?? "").replace(/\[[^\]]*\]/g, "").trim();
|
|
8626
|
-
|
|
8732
|
+
radioCells = (it, dense) => {
|
|
8627
8733
|
const style = (it.meta ?? []).find((m2) => typeof m2.style === "string")?.style ?? "";
|
|
8628
8734
|
const m = /^\s*radio\s*\{(.*)\}\s*$/.exec(style);
|
|
8629
|
-
|
|
8735
|
+
if (!m) return 0;
|
|
8736
|
+
const names = m[1].split(";").filter((s) => s.trim()).map((s) => s.split(":")[0].trim().replace(/^'|'$/g, ""));
|
|
8737
|
+
const letters = groupName(it.label).length + names.reduce((n, x) => n + x.length, 0);
|
|
8738
|
+
return Math.max(names.length, Math.ceil((7 * letters + 18 * names.length + 12) / DEVICE_METRICS[dense ? "dense" : "normal"].cell));
|
|
8630
8739
|
};
|
|
8631
|
-
cellsOf = (it, meta2) => it.address && meta2.big.has(it.address) ? 1.5 : Math.max(1,
|
|
8740
|
+
cellsOf = (it, meta2, dense = false) => it.address && meta2.big.has(it.address) ? 1.5 : Math.max(1, radioCells(it, dense));
|
|
8632
8741
|
PLACE_CELLS = 2;
|
|
8633
8742
|
MONITOR_CELLS = 4;
|
|
8743
|
+
stepsSize = (g, m) => ({
|
|
8744
|
+
width: m.stepName + Math.max(0, ...g.rows.map((r) => r.addresses.length)) * m.step,
|
|
8745
|
+
height: (g.rows.length + 1) * m.step
|
|
8746
|
+
});
|
|
8634
8747
|
DEVICE_METRICS = {
|
|
8635
|
-
normal: { cell: 64, row: 96, bigRow: 120, title: 22, pad: 8, gap: 8, screen: 64 },
|
|
8636
|
-
dense: { cell: 52, row: 78, bigRow: 98, title: 18, pad: 6, gap: 6, screen: 48 }
|
|
8748
|
+
normal: { cell: 64, row: 96, bigRow: 120, title: 22, pad: 8, gap: 8, screen: 64, step: 20, stepName: 36 },
|
|
8749
|
+
dense: { cell: 52, row: 78, bigRow: 98, title: 18, pad: 6, gap: 6, screen: 48, step: 16, stepName: 30 }
|
|
8637
8750
|
};
|
|
8638
8751
|
}
|
|
8639
8752
|
});
|
|
@@ -8652,7 +8765,7 @@ function sizeOfControls(ui, dense = false, presets = false) {
|
|
|
8652
8765
|
const meta2 = deviceMeta(ui);
|
|
8653
8766
|
const clamp = (v, lo, hi) => Math.round(Math.min(hi, Math.max(lo, v)));
|
|
8654
8767
|
if (laysOut(meta2)) {
|
|
8655
|
-
const size = deviceSize(deviceLayout([ui], meta2), meta2, dense);
|
|
8768
|
+
const size = deviceSize(deviceLayout([ui], meta2, dense), meta2, dense);
|
|
8656
8769
|
return { width: clamp(size.width + 24, 360, 1400), height: clamp(size.height + 24 + bar, 200, 900) };
|
|
8657
8770
|
}
|
|
8658
8771
|
return { width: clamp(Math.min(n, 8) * 84 + 64, 360, 960), height: clamp(80 + Math.ceil(n / 8) * 110 + bar, 200, 800) };
|
|
@@ -8678,13 +8791,13 @@ function licenceOf(source, name) {
|
|
|
8678
8791
|
return [name, author && `by ${author}`, said && `Licence: ${said}`].filter(Boolean).join("\n") + "\n";
|
|
8679
8792
|
}
|
|
8680
8793
|
function controlsUi(trees, description) {
|
|
8681
|
-
const
|
|
8794
|
+
const keep2 = new Set([...description.params.filter((p) => !p.hidden), ...description.bargraphs.filter((b) => !b.hidden)].map((p) => p.address));
|
|
8682
8795
|
const cut = (items) => items.flatMap((it) => {
|
|
8683
8796
|
if ("items" in it && Array.isArray(it.items)) {
|
|
8684
8797
|
const inner = cut(it.items);
|
|
8685
8798
|
return inner.length ? [{ ...it, items: inner }] : [];
|
|
8686
8799
|
}
|
|
8687
|
-
return "address" in it &&
|
|
8800
|
+
return "address" in it && keep2.has(it.address) ? [it] : [];
|
|
8688
8801
|
});
|
|
8689
8802
|
return trees.flatMap((tree) => cut(Array.isArray(tree) ? tree : []));
|
|
8690
8803
|
}
|
|
@@ -8702,7 +8815,12 @@ function pluginFiles(page, p) {
|
|
|
8702
8815
|
}
|
|
8703
8816
|
function deviceTags(ui) {
|
|
8704
8817
|
const meta2 = deviceMeta(ui);
|
|
8705
|
-
|
|
8818
|
+
const rowsOf = (rs, under) => rs.flatMap((r) => [
|
|
8819
|
+
{ name: r.name, sections: r.places.flatMap((c) => c.place.kind === "section" ? [c.place.name] : []), ...under ? { under } : {} },
|
|
8820
|
+
...r.places.flatMap((c) => c.place.kind === "stack" ? rowsOf(c.place.rows, [under, r.name, c.place.name].filter(Boolean).join(" / ")) : [])
|
|
8821
|
+
]);
|
|
8822
|
+
const rows = laysOut(meta2) ? rowsOf(deviceLayout([ui], meta2).rows) : [];
|
|
8823
|
+
return { big: meta2.big.size, cols: [...new Set(meta2.cols.values())].sort(), monitors: meta2.monitors.map((m) => m.name), steps: meta2.steps.map((g) => ({ name: g.name, rows: g.rows.length, steps: Math.max(...g.rows.map((r) => r.addresses.length)) })), faders: meta2.faders.size, rows };
|
|
8706
8824
|
}
|
|
8707
8825
|
var FAUST_ARGS, PRESET_BAR, idPart, declaredOf, packageFileName;
|
|
8708
8826
|
var init_src2 = __esm({
|
|
@@ -8720,6 +8838,7 @@ var init_src2 = __esm({
|
|
|
8720
8838
|
// src/convert.ts
|
|
8721
8839
|
var convert_exports = {};
|
|
8722
8840
|
__export(convert_exports, {
|
|
8841
|
+
PLUGIN_HELP: () => PLUGIN_HELP,
|
|
8723
8842
|
convert: () => convert,
|
|
8724
8843
|
convertArgs: () => convertArgs
|
|
8725
8844
|
});
|
|
@@ -8733,26 +8852,25 @@ function convertArgs(args) {
|
|
|
8733
8852
|
let sources = false;
|
|
8734
8853
|
const files = [];
|
|
8735
8854
|
for (let i = 0; i < args.length; i++) {
|
|
8736
|
-
|
|
8737
|
-
const m = /^--(name|id|version|out|look|theme|css|density)$/.exec(args[i]);
|
|
8855
|
+
const m = /^--(name|id|version|out|theme|css|density)$/.exec(args[i]);
|
|
8738
8856
|
if (args[i] === "--sources") sources = true;
|
|
8739
8857
|
else if (m) {
|
|
8740
|
-
if (args[i + 1] === void 0) throw
|
|
8858
|
+
if (args[i + 1] === void 0) throw wrong(`${args[i]} needs a value`);
|
|
8741
8859
|
opts[m[1]] = args[++i];
|
|
8742
|
-
} else if (args[i].startsWith("-")) throw
|
|
8860
|
+
} else if (args[i].startsWith("-")) throw wrong(`${args[i]}: no such option`);
|
|
8743
8861
|
else files.push(args[i]);
|
|
8744
8862
|
}
|
|
8745
|
-
if (files.length !== 1) throw
|
|
8746
|
-
if (opts.density !== void 0 && opts.density !== "compact") throw
|
|
8747
|
-
if (opts.theme !== void 0
|
|
8748
|
-
|
|
8749
|
-
return { file: files[0], ...
|
|
8863
|
+
if (files.length !== 1) throw wrong(files.length ? `one patch at a time \u2014 ${files.length} were named: ${files.join(", ")}` : "which patch? faustwave build plugin <patch.dsp>");
|
|
8864
|
+
if (opts.density !== void 0 && opts.density !== "compact") throw wrong(`--density ${opts.density}: only compact`);
|
|
8865
|
+
if (opts.theme !== void 0 && !THEMES.includes(opts.theme)) throw wrong(`--theme ${opts.theme}: no such theme \u2014 ${THEMES.join(", ")}`);
|
|
8866
|
+
const { theme, ...rest2 } = opts;
|
|
8867
|
+
return { file: files[0], ...rest2, ...theme !== void 0 ? { look: theme } : {}, ...sources ? { sources } : {} };
|
|
8750
8868
|
}
|
|
8751
8869
|
async function convert(args) {
|
|
8752
8870
|
const o = convertArgs(args);
|
|
8753
|
-
const
|
|
8754
|
-
if (!fs5.existsSync(
|
|
8755
|
-
const source = fs5.readFileSync(
|
|
8871
|
+
const file2 = path6.resolve(o.file);
|
|
8872
|
+
if (!fs5.existsSync(file2)) throw new Error(`No such patch: ${file2}`);
|
|
8873
|
+
const source = fs5.readFileSync(file2, "utf8");
|
|
8756
8874
|
const req = requireAt(import.meta.url);
|
|
8757
8875
|
let fwDir, wclapDist;
|
|
8758
8876
|
try {
|
|
@@ -8772,13 +8890,17 @@ async function convert(args) {
|
|
|
8772
8890
|
const pageDir = path6.dirname(pageList);
|
|
8773
8891
|
const page = new Map(JSON.parse(fs5.readFileSync(pageList, "utf8")).map((f) => [f, new Uint8Array(fs5.readFileSync(path6.join(pageDir, f)))]));
|
|
8774
8892
|
const css = o.css === void 0 ? "" : fs5.readFileSync(path6.resolve(o.css), "utf8");
|
|
8893
|
+
const stderr = console.error.bind(console);
|
|
8894
|
+
console.error = (...said) => {
|
|
8895
|
+
if (!/^Aborted\(/.test(String(said[0]))) stderr(...said);
|
|
8896
|
+
};
|
|
8775
8897
|
const faustwasm = await import(pathToFileURL(path6.join(fwDir, "dist/esm/index.js")).href);
|
|
8776
8898
|
const wclap = await import(pathToFileURL(path6.join(wclapDist, "index.js")).href);
|
|
8777
8899
|
const compiler = new faustwasm.FaustCompiler(
|
|
8778
8900
|
new faustwasm.LibFaust(await faustwasm.instantiateFaustModuleFromFile(path6.join(fwDir, "libfaust-wasm/libfaust-wasm.js")))
|
|
8779
8901
|
);
|
|
8780
8902
|
const adapter = new Uint8Array(fs5.readFileSync(path6.join(wclapDist, "faustwasm-webclap-double.wasm")));
|
|
8781
|
-
const presetsFile = wclap.presetsFileOf(
|
|
8903
|
+
const presetsFile = wclap.presetsFileOf(file2);
|
|
8782
8904
|
let presets = [];
|
|
8783
8905
|
if (fs5.existsSync(presetsFile))
|
|
8784
8906
|
try {
|
|
@@ -8786,45 +8908,132 @@ async function convert(args) {
|
|
|
8786
8908
|
} catch (e) {
|
|
8787
8909
|
throw new Error(`${path6.basename(presetsFile)}: ${e instanceof Error ? e.message : String(e)}`);
|
|
8788
8910
|
}
|
|
8789
|
-
const info = pluginInfo(source, { fallbackName: path6.basename(
|
|
8911
|
+
const info = pluginInfo(source, { fallbackName: path6.basename(file2).replace(/\.dsp$/i, ""), name: o.name, id: o.id, version: o.version, presets, density: o.density });
|
|
8790
8912
|
const built = await wclap.compilePlugin(faustwasm, compiler, adapter, source, info, { args: FAUST_ARGS }).catch((e) => {
|
|
8791
8913
|
const said = e instanceof Error ? e.message : String(e);
|
|
8792
|
-
if (/no such sound was given/.test(said)) throw new Error("The patch plays soundfiles \u2014 build
|
|
8914
|
+
if (/no such sound was given/.test(said)) throw new Error("The patch plays soundfiles \u2014 faustwave build plugin loads none: a patch that makes its sounds itself builds.");
|
|
8793
8915
|
if (/^preset "/.test(said)) throw new Error(`${path6.basename(presetsFile)}: ${said}`);
|
|
8794
8916
|
throw new Error(`The patch does not compile: ${said}`);
|
|
8795
8917
|
});
|
|
8796
8918
|
const notices = new Uint8Array(fs5.readFileSync(path6.join(wclapDist, "THIRD-PARTY-NOTICES.md")));
|
|
8797
8919
|
const ui = controlsUi([built.faust.ui, built.effect.ui], built.description);
|
|
8798
|
-
const sources = o.sources ? new Map([[path6.basename(
|
|
8920
|
+
const sources = o.sources ? new Map([[path6.basename(file2), new Uint8Array(fs5.readFileSync(file2))], ...fs5.existsSync(presetsFile) ? [[path6.basename(presetsFile), new Uint8Array(fs5.readFileSync(presetsFile))]] : []]) : void 0;
|
|
8799
8921
|
const files = wclap.pluginPackage(built.module, licenceOf(source, info.name), pluginFiles(page, { description: built.description, ui, look: o.look, css, density: o.density, presets, notices, sources }));
|
|
8800
|
-
const out = path6.resolve(o.out ?? path6.dirname(
|
|
8922
|
+
const out = path6.resolve(o.out ?? path6.dirname(file2));
|
|
8801
8923
|
fs5.mkdirSync(out, { recursive: true });
|
|
8802
8924
|
const to = path6.join(out, packageFileName(info.name));
|
|
8803
8925
|
const archive = gzipSync(wclap.tar(files));
|
|
8804
8926
|
fs5.writeFileSync(to, archive);
|
|
8805
|
-
const
|
|
8806
|
-
const
|
|
8927
|
+
const itself = !built.voices && built.faust.inputs === 0;
|
|
8928
|
+
const what = built.voices ? `an instrument of ${built.voices} voices` : itself ? `an instrument that plays by itself (${/\[\s*midi\s*:\s*key\b/.test(source) ? "and by its [midi:key] controls" : "no notes"})` : "an effect";
|
|
8929
|
+
const ended = itself ? "it has stopped" : "its input or last note has ended";
|
|
8930
|
+
const tail = built.tail < 0 ? `its sound may never die away once ${ended}` : `its sound dies away ${built.tail.toFixed(2)} s after ${ended}`;
|
|
8807
8931
|
const tags = deviceTags(ui);
|
|
8808
|
-
const laid = tags.big || tags.cols.length || tags.monitors.length ? `laid out by its tags: ${[tags.big && `${tags.big} big`, tags.cols.length && `column ${tags.cols.join(", ")}`, tags.monitors.length && `monitor ${tags.monitors.join(", ")}`].filter(Boolean).join("; ")}` : "no [device:*] tags \u2014 as Faust groups the controls";
|
|
8932
|
+
const laid = tags.big || tags.cols.length || tags.monitors.length || tags.steps.length ? `laid out by its tags: ${[tags.big && `${tags.big} big knob${tags.big === 1 ? "" : "s"}`, tags.cols.length && `column ${tags.cols.join(", ")}`, tags.monitors.length && `monitor ${tags.monitors.join(", ")}`, ...tags.steps.map((g) => `steps ${g.name} ${g.rows} \xD7 ${g.steps}`)].filter(Boolean).join("; ")}` : "no [device:*] tags \u2014 as Faust groups the controls";
|
|
8809
8933
|
const withPresets = presets.length ? `, ${presets.length} preset${presets.length === 1 ? "" : "s"}` : "";
|
|
8810
|
-
|
|
8811
|
-
|
|
8812
|
-
}
|
|
8813
|
-
|
|
8934
|
+
const there = { row: tags.rows.map((r) => r.name), group: tags.rows.flatMap((r) => r.sections), monitor: tags.monitors, steps: tags.steps.map((g) => g.name) };
|
|
8935
|
+
const lost = [...css.replace(/\/\*[\s\S]*?\*\//g, "").matchAll(/\[data-(row|group|monitor|steps)\s*=\s*["']?([^"'\]]+?)["']?\s*\]/g)].filter(([, kind, name]) => !there[kind].includes(name)).map(([sel]) => sel);
|
|
8936
|
+
const withCss = o.css === void 0 ? "" : `with your CSS (${path6.basename(o.css)}${lost.length ? ` \u2014 but ${[...new Set(lost)].join(", ")} find${new Set(lost).size === 1 ? "s" : ""} nothing on the page` : ""})`;
|
|
8937
|
+
const rows = tags.rows.length ? `
|
|
8938
|
+
Its page, top to bottom: ${tags.rows.map((r) => `${r.under ? `in ${r.under}: ` : ""}${r.name || "a row"} [${[...new Set(r.sections)].join(", ")}]`).join(" \u2014 ")}${withCss && `; ${withCss}`}.` : withCss && `
|
|
8939
|
+
Its page: ${withCss}.`;
|
|
8940
|
+
return `${to}: "${info.name}" (${info.id}) ${info.version}, ${what}${withPresets}, ${sources ? "with its sources, " : ""}with its page (${built.info.ui ? `${built.info.ui.width} \xD7 ${built.info.ui.height}, ` : ""}${laid}), ${(archive.length / 1024).toFixed(0)} KB; ${tail}.${rows}
|
|
8941
|
+
Import it into a WebCLAP host \u2014 or publish it on faustwave.io: faustwave push ${/\s/.test(to) ? `"${to}"` : to} (faustwave me says whether you may)`;
|
|
8942
|
+
}
|
|
8943
|
+
var PLUGIN_HELP, THEMES, wrong;
|
|
8814
8944
|
var init_convert = __esm({
|
|
8815
8945
|
"src/convert.ts"() {
|
|
8816
8946
|
"use strict";
|
|
8817
8947
|
init_src2();
|
|
8818
|
-
|
|
8819
|
-
|
|
8820
|
-
|
|
8821
|
-
|
|
8822
|
-
|
|
8823
|
-
|
|
8824
|
-
|
|
8825
|
-
|
|
8826
|
-
|
|
8827
|
-
|
|
8948
|
+
PLUGIN_HELP = `faustwave build plugin <patch.dsp> [options]
|
|
8949
|
+
|
|
8950
|
+
A Faust patch as a WebCLAP plugin with its page: <name>.wclap.tar.gz \u2014 the module, its page, its licence. Presets come
|
|
8951
|
+
from <patch>.presets.json beside the patch, when there is one.
|
|
8952
|
+
|
|
8953
|
+
Options:
|
|
8954
|
+
--out <folder> where the package goes (default: here)
|
|
8955
|
+
--name <name> the plugin's name (default: the patch's declare name, else the file's)
|
|
8956
|
+
--id <id> its CLAP id (default: io.faustwave.<name>)
|
|
8957
|
+
--version <x.y.z> its version (default: the patch's declare version, else the day)
|
|
8958
|
+
--theme <theme> its page's colours: studio, amber (default: FaustWave's)
|
|
8959
|
+
--css <file> a look of your own: a CSS file over the theme (below: what it can set)
|
|
8960
|
+
--density compact smaller knobs, tighter panels (as a host's own devices sit)
|
|
8961
|
+
--sources pack the patch and its presets file with it, under src/ \u2014 who has the plugin can read them
|
|
8962
|
+
-h, --help this
|
|
8963
|
+
|
|
8964
|
+
An effect or an instrument: a patch with inputs is an effect. One that plays notes is an instrument \u2014 it takes
|
|
8965
|
+
freq (or key), gain and gate as Faust's MIDI convention has them, and says its voices:
|
|
8966
|
+
declare options "[midi:on][nvoices:8]";
|
|
8967
|
+
freq = hslider("freq", 440, 20, 20000, 0.01); gain = hslider("gain", 0.5, 0, 1, 0.01); gate = button("gate");
|
|
8968
|
+
|
|
8969
|
+
Examples:
|
|
8970
|
+
faustwave build plugin tremolo.dsp
|
|
8971
|
+
faustwave build plugin synth.dsp --theme studio --out plugins/
|
|
8972
|
+
faustwave build plugin synth.dsp --name "My Synth" --version 1.0.0 --sources
|
|
8973
|
+
|
|
8974
|
+
Its page lays the controls out as the patch's Faust groups say, once ONE control carries a [device:\u2026] tag (without
|
|
8975
|
+
any, the controls stand as Faust nests them \u2014 no rows, no sections). Two levels: a group is a row, the groups in it are
|
|
8976
|
+
the row's sections, each control a knob in its section. Faust sorts groups and controls by name; a number in front
|
|
8977
|
+
keeps your order:
|
|
8978
|
+
cutoff = hslider("h:[1]sound/h:[2]filter/[1]cutoff[unit:Hz][scale:log][device:big]", 1800, 80, 12000, 1);
|
|
8979
|
+
attack = hslider("h:[2]shape/h:[1]env/[1]attack[unit:s]", 0.02, 0.001, 2, 0.001);
|
|
8980
|
+
gives two rows, sound over shape, with the sections filter and env. Tags in a control's label:
|
|
8981
|
+
[device:big] a big knob (a section's big knobs stand in a section of their own, before its others)
|
|
8982
|
+
[device:monitor:<name>] on bargraphs: a screen in their section, a line drawn through them
|
|
8983
|
+
[unit:Hz] [scale:log] Faust's own: the unit beside the value, the knob's curve
|
|
8984
|
+
The build says the rows and sections it made \u2014 read it: a section that is missing or named "a / b" is a group too deep.
|
|
8985
|
+
A patch whose controls ALL lie in one top group has that group as itself, not as a row (Faust wraps a patch in a group
|
|
8986
|
+
of its name only when more than one thing stands at its top): a second group beside it makes both rows.
|
|
8987
|
+
|
|
8988
|
+
A monitor's line goes through ALL the bargraphs of its name, left to right \u2014 each bargraph one point; a single
|
|
8989
|
+
bargraph is a flat line. A signal over the last second, 32 points, the newest on the right:
|
|
8990
|
+
history(every, sig) = par(j, 32, at(31 - j))
|
|
8991
|
+
with { tick = (ba.time % every) == 0; at(0) = ba.sAndH(tick, sig); at(n) = ba.sAndH(tick, at(n - 1)'); };
|
|
8992
|
+
scope = history(1500, env) : par(k, 32, hbargraph("h:[2]shape/h:[2]out/s%2k[device:monitor:scope]", 0, 1)) :> _;
|
|
8993
|
+
process = attach(voice, scope) <: _, _;
|
|
8994
|
+
|
|
8995
|
+
A step sequencer: [device:steps:<name>] on checkboxes draws them as ONE grid \u2014 each group of them a row under the
|
|
8996
|
+
group's name, a square a step; on a bargraph it is the grid's running step (1 the first, 0: none), on a slider its length (the steps past it are
|
|
8997
|
+
drawn faint). A click turns a step on or off, a stroke over more steps gives them the same. The patch plays the
|
|
8998
|
+
steps itself, on the host's clock \u2014 Faust's MIDI sync controls, which the host's transport plays (no hand turns them):
|
|
8999
|
+
play = checkbox("h:sync/play[midi:start][midi:stop]"); // 1 while the host plays
|
|
9000
|
+
clock = checkbox("h:sync/clock[midi:clock]"); // toggles 24 times a quarter note
|
|
9001
|
+
songpos = hslider("h:sync/songpos[midi:songpos]", 0, 0, 1e9, 0.0001); // the song's place, in sixteenths
|
|
9002
|
+
onStep = (clock != clock') * play * (abs(songpos - rint(songpos)) < 0.01);
|
|
9003
|
+
step = int(floor(songpos + 0.01)) % 16;
|
|
9004
|
+
bd = par(i, 16, checkbox("v:[1]pattern/h:[1]BD/%2i[device:steps:pattern]")) : ba.selectn(16, step) : *(onStep);
|
|
9005
|
+
marker = (step + 1) * play : hbargraph("v:[1]pattern/step[device:steps:pattern]", 0, 16);
|
|
9006
|
+
bd is 1 on the sample its step begins when its box is on \u2014 a trigger for a drum; attach the marker to the sound.
|
|
9007
|
+
A patch without notes and without inputs is an instrument that plays by itself.
|
|
9008
|
+
Rows of knobs BESIDE a tall grid: a VERTICAL group (v:) in the grid's row whose groups are rows themselves stands as a
|
|
9009
|
+
stack (the sync controls above are the second thing at the patch's top, so "top" is a row) \u2014
|
|
9010
|
+
"h:[1]top/v:[1]pattern/h:[01]BD/%2i[device:steps:pattern]" the grid, left
|
|
9011
|
+
"h:[1]top/v:[2]knobs/h:[1]main/h:[1]play/[1]length" right of it: the row main, its section play
|
|
9012
|
+
"h:[1]top/v:[2]knobs/h:[2]drums/h:[1]BD/[1]level" under main: the row drums, its section BD
|
|
9013
|
+
|
|
9014
|
+
A look of your own (--css <file>): the file's CSS goes over the theme, inside the controls' frame. The file is the
|
|
9015
|
+
inside of one CSS rule: declarations at its top (they hold for the whole frame), rules for its parts below them.
|
|
9016
|
+
--bg: #05020a; the frame's ground
|
|
9017
|
+
--card: #12061f; --card-2: #1b0a2e; the sections' grounds
|
|
9018
|
+
--border: #3a1466; the lines
|
|
9019
|
+
--text: #f3e9ff; --text-2: #c9a7ff; --text-3: #9a6fe0; values; labels and titles; units
|
|
9020
|
+
--action: #ff2bd6; --focus: #ff2bd6; the knobs' arcs; the ring round the one in use
|
|
9021
|
+
--signal-audio: #2bf0ff; a monitor's line
|
|
9022
|
+
font-family: Georgia, serif; (any CSS property)
|
|
9023
|
+
[data-group="filter"] { background: linear-gradient(160deg, #2a0a3f, #12061f); border-radius: 18px; --action: #2bf0ff; }
|
|
9024
|
+
a section by its group's name \u2014 any CSS, and the colours again for it alone
|
|
9025
|
+
[data-row="sound"] { \u2026 } a row by its group's name
|
|
9026
|
+
[data-monitor="<name>"] svg { background: #020908; border-color: #3a1466; }
|
|
9027
|
+
a monitor's screen by its tag's name
|
|
9028
|
+
The knobs: the arc is --action, the track behind it --border-2, the pointer --text-2.
|
|
9029
|
+
The themes: FaustWave's (dark, teal), studio (light grey, orange), amber (black, amber). The window round the frame
|
|
9030
|
+
and the preset bar keep the theme's colours \u2014 choose the theme nearest to your look and put the CSS over it.
|
|
9031
|
+
|
|
9032
|
+
Import the package into a WebCLAP host, or try a patch first in the browser:
|
|
9033
|
+
https://faustwave.io/webclap`;
|
|
9034
|
+
THEMES = ["studio", "amber"];
|
|
9035
|
+
wrong = (said) => new Error(`${said}
|
|
9036
|
+
faustwave build plugin --help says the options.`);
|
|
8828
9037
|
}
|
|
8829
9038
|
});
|
|
8830
9039
|
|
|
@@ -8833,6 +9042,7 @@ var update_exports = {};
|
|
|
8833
9042
|
__export(update_exports, {
|
|
8834
9043
|
hint: () => hint,
|
|
8835
9044
|
newer: () => newer,
|
|
9045
|
+
todo: () => todo,
|
|
8836
9046
|
update: () => update
|
|
8837
9047
|
});
|
|
8838
9048
|
import { spawn } from "node:child_process";
|
|
@@ -8847,53 +9057,94 @@ function newer(a, b) {
|
|
|
8847
9057
|
async function latest() {
|
|
8848
9058
|
try {
|
|
8849
9059
|
const res = await fetch(`https://registry.npmjs.org/${NAME}/latest`, { signal: AbortSignal.timeout(2e3) });
|
|
8850
|
-
|
|
9060
|
+
const version2 = res.ok ? (await res.json()).version : void 0;
|
|
9061
|
+
return version2 && /^\d+\.\d+\.\d+(-[\w.]+)?$/.test(version2) ? version2 : null;
|
|
8851
9062
|
} catch {
|
|
8852
9063
|
return null;
|
|
8853
9064
|
}
|
|
8854
9065
|
}
|
|
8855
|
-
|
|
9066
|
+
function install(version2, quiet = false) {
|
|
9067
|
+
return new Promise((resolve) => {
|
|
9068
|
+
const child = spawn(`npm install --global ${NAME}@${version2}`, { stdio: quiet ? "ignore" : ["ignore", 2, 2], shell: true });
|
|
9069
|
+
child.on("close", (c) => resolve(c ?? 1));
|
|
9070
|
+
child.on("error", () => resolve(1));
|
|
9071
|
+
});
|
|
9072
|
+
}
|
|
9073
|
+
function read() {
|
|
9074
|
+
try {
|
|
9075
|
+
return JSON.parse(fs6.readFileSync(file(), "utf8"));
|
|
9076
|
+
} catch {
|
|
9077
|
+
return {};
|
|
9078
|
+
}
|
|
9079
|
+
}
|
|
9080
|
+
function keep(seen) {
|
|
9081
|
+
fs6.mkdirSync(path7.dirname(file()), { recursive: true });
|
|
9082
|
+
fs6.writeFileSync(file(), JSON.stringify(seen));
|
|
9083
|
+
}
|
|
9084
|
+
async function update(args = []) {
|
|
8856
9085
|
if (!VERSION2) throw new Error("faustwave update is the npm package's (npm i -g faustwave) \u2014 this faustwave updates with the IDE or with git.");
|
|
9086
|
+
if (args.length) {
|
|
9087
|
+
const [flag, to] = args;
|
|
9088
|
+
if (flag !== "--auto" || to !== "on" && to !== "off" || args.length > 2) throw new Error("faustwave update [--auto on|off]");
|
|
9089
|
+
keep({ ...read(), auto: to === "on" });
|
|
9090
|
+
return to === "on" ? "faustwave updates by itself from now on, after a command when there is a newer one" : "faustwave says when there is a newer one \u2014 faustwave update installs it";
|
|
9091
|
+
}
|
|
8857
9092
|
const l = await latest();
|
|
8858
9093
|
if (!l) throw new Error("npm gave no faustwave (not reached, or not published yet) \u2014 later again, or: npm i -g faustwave@latest");
|
|
8859
9094
|
if (!newer(l, VERSION2)) return `faustwave ${VERSION2} is the newest`;
|
|
8860
|
-
const code = await
|
|
8861
|
-
const child = spawn("npm", ["install", "--global", `${NAME}@${l}`], { stdio: "inherit", shell: process.platform === "win32" });
|
|
8862
|
-
child.on("close", (c) => resolve(c ?? 1));
|
|
8863
|
-
child.on("error", () => resolve(1));
|
|
8864
|
-
});
|
|
9095
|
+
const code = await install(l);
|
|
8865
9096
|
if (code) throw new Error(`npm install failed (${code}) \u2014 by hand: npm i -g faustwave@latest`);
|
|
8866
9097
|
return `faustwave ${VERSION2} \u2192 ${l}`;
|
|
8867
9098
|
}
|
|
9099
|
+
function todo(seen, version2, tty) {
|
|
9100
|
+
if (!seen.latest || !newer(seen.latest, version2)) return "nothing";
|
|
9101
|
+
if (seen.auto) return "install";
|
|
9102
|
+
if (!tty.out) return "nothing";
|
|
9103
|
+
return seen.auto === void 0 && tty.in ? "ask" : "tell";
|
|
9104
|
+
}
|
|
8868
9105
|
async function hint() {
|
|
8869
|
-
if (!VERSION2
|
|
9106
|
+
if (!VERSION2) return;
|
|
8870
9107
|
try {
|
|
8871
|
-
|
|
8872
|
-
let seen = {};
|
|
8873
|
-
try {
|
|
8874
|
-
seen = JSON.parse(fs6.readFileSync(file, "utf8"));
|
|
8875
|
-
} catch {
|
|
8876
|
-
}
|
|
9108
|
+
let seen = read();
|
|
8877
9109
|
if (!seen.checked || Date.now() - seen.checked > DAY) {
|
|
8878
|
-
seen = { checked: Date.now(), latest: await latest() };
|
|
8879
|
-
|
|
8880
|
-
|
|
8881
|
-
}
|
|
8882
|
-
|
|
8883
|
-
|
|
8884
|
-
|
|
9110
|
+
seen = { ...seen, checked: Date.now(), latest: await latest() };
|
|
9111
|
+
keep(seen);
|
|
9112
|
+
}
|
|
9113
|
+
const tty = { out: !!process.stderr.isTTY, in: !!process.stdin.isTTY };
|
|
9114
|
+
let what = todo(seen, VERSION2, tty);
|
|
9115
|
+
if (what === "nothing") return;
|
|
9116
|
+
const l = seen.latest;
|
|
9117
|
+
if (what === "ask") {
|
|
9118
|
+
const { createInterface } = await import("node:readline/promises");
|
|
9119
|
+
const rl = createInterface({ input: process.stdin, output: process.stderr });
|
|
9120
|
+
const yes = /^y/i.test((await rl.question(`
|
|
9121
|
+
faustwave ${l} is out (this is ${VERSION2}). Update now, and by itself from now on? [y/n] `)).trim());
|
|
9122
|
+
rl.close();
|
|
9123
|
+
keep({ ...seen, auto: yes });
|
|
9124
|
+
if (!yes) process.stderr.write("Then it says when there is a newer one: faustwave update installs it (by itself after all: faustwave update --auto on).\n");
|
|
9125
|
+
what = yes ? "install" : "nothing";
|
|
9126
|
+
}
|
|
9127
|
+
if (what === "tell") process.stderr.write(`
|
|
9128
|
+
faustwave ${l} is out (this is ${VERSION2}) \u2014 faustwave update
|
|
9129
|
+
`);
|
|
9130
|
+
if (what === "install") {
|
|
9131
|
+
const code = await install(l, !tty.out);
|
|
9132
|
+
if (tty.out) process.stderr.write(code ? `faustwave ${l} could not be installed (npm ended ${code}) \u2014 by hand: npm i -g faustwave@latest
|
|
9133
|
+
` : `faustwave ${VERSION2} \u2192 ${l} (by itself; off: faustwave update --auto off)
|
|
8885
9134
|
`);
|
|
9135
|
+
}
|
|
8886
9136
|
} catch {
|
|
8887
9137
|
}
|
|
8888
9138
|
}
|
|
8889
|
-
var VERSION2, NAME, DAY;
|
|
9139
|
+
var VERSION2, NAME, DAY, file;
|
|
8890
9140
|
var init_update = __esm({
|
|
8891
9141
|
"src/update.ts"() {
|
|
8892
9142
|
"use strict";
|
|
8893
9143
|
init_pipe();
|
|
8894
|
-
VERSION2 = false ? null : "0.
|
|
9144
|
+
VERSION2 = false ? null : "0.98.0";
|
|
8895
9145
|
NAME = "faustwave";
|
|
8896
9146
|
DAY = 24 * 60 * 60 * 1e3;
|
|
9147
|
+
file = () => path7.join(userData(), "cli-update.json");
|
|
8897
9148
|
}
|
|
8898
9149
|
});
|
|
8899
9150
|
|
|
@@ -31138,7 +31389,7 @@ init_pipe();
|
|
|
31138
31389
|
// package.json
|
|
31139
31390
|
var package_default = {
|
|
31140
31391
|
name: "faustwave",
|
|
31141
|
-
version: "0.
|
|
31392
|
+
version: "0.98.0",
|
|
31142
31393
|
description: "The FaustWave CLI \u2014 a Faust patch as a WebCLAP plugin with its page, from a terminal or a script.",
|
|
31143
31394
|
keywords: [
|
|
31144
31395
|
"faust",
|
|
@@ -31302,8 +31553,8 @@ async function mcp() {
|
|
|
31302
31553
|
init_pipe();
|
|
31303
31554
|
var STUDIO = false;
|
|
31304
31555
|
var STUDIO_COMMANDS = ["mcp", "run", "shot", "quit"];
|
|
31305
|
-
var HUB2 = false;
|
|
31306
31556
|
var USAGE_STUDIO = `
|
|
31557
|
+
With the running IDE:
|
|
31307
31558
|
mcp the MCP server an AI client starts (stdio) \u2014 it asks the running IDE
|
|
31308
31559
|
run <action> [json | file] run an action (palette.run) \u2014 its input as JSON, or a JSON file (a large source)
|
|
31309
31560
|
shot <module_id> [file] a stage's picture (stage.picture, JPEG), to a file
|
|
@@ -31314,62 +31565,69 @@ var USAGE_STUDIO = `
|
|
|
31314
31565
|
`;
|
|
31315
31566
|
var USAGE_HUB = `
|
|
31316
31567
|
|
|
31317
|
-
|
|
31568
|
+
Publish on faustwave.io:
|
|
31318
31569
|
login sign in \u2014 a code to confirm in the browser
|
|
31319
31570
|
logout forget the sign-in
|
|
31320
|
-
|
|
31321
|
-
|
|
31571
|
+
me whether you may publish, and your apps: each release and how it stands
|
|
31572
|
+
me ask <words> ask to publish (once, before your first push): what you want to publish, a sentence
|
|
31573
|
+
or two \u2014 the admin answers
|
|
31574
|
+
push <file | folder> [slug] upload a build: a plugin package (.wclap.tar.gz) or a player folder. Its name and
|
|
31575
|
+
version are read from it; the first push makes the app \u2014 a draft, seen by you only
|
|
31322
31576
|
app describe <slug> <text | file>
|
|
31323
|
-
its description on
|
|
31577
|
+
its description on its page: plain text, paragraphs by an empty line (the first
|
|
31578
|
+
paragraph: the catalog's teaser)
|
|
31324
31579
|
app cover <slug> <picture file>
|
|
31325
|
-
its picture
|
|
31326
|
-
|
|
31327
|
-
|
|
31328
|
-
|
|
31329
|
-
|
|
31330
|
-
|
|
31331
|
-
|
|
31332
|
-
|
|
31333
|
-
|
|
31334
|
-
|
|
31335
|
-
yank <slug> <version>
|
|
31336
|
-
releases <slug>
|
|
31337
|
-
|
|
31338
|
-
|
|
31339
|
-
|
|
31340
|
-
|
|
31341
|
-
|
|
31342
|
-
|
|
31343
|
-
|
|
31344
|
-
|
|
31345
|
-
|
|
31346
|
-
reconcile [days] the Hub against Paddle: purchases whose notification was lost, refunds, chargebacks`;
|
|
31347
|
-
var USAGE2 = `faustwave <command>
|
|
31348
|
-
${STUDIO ? USAGE_STUDIO : ""}
|
|
31580
|
+
its picture (PNG, JPEG or WebP, at most 5 MB; shown 16:9, e.g. 1600 \xD7 900)
|
|
31581
|
+
submit <slug> your release that is not out yet is ready \u2014 the admin reviews it`;
|
|
31582
|
+
var USAGE_ADMIN = `
|
|
31583
|
+
|
|
31584
|
+
The admin:
|
|
31585
|
+
review what waits: the releases submitted, and who asked to publish
|
|
31586
|
+
publish <slug> the release that waits: out, and its app in the catalog \u2014 it never changes again
|
|
31587
|
+
reject <slug> <reason> the release that waits: back to its publisher, with the reason
|
|
31588
|
+
allow <user> a user may publish
|
|
31589
|
+
decline <user> <reason> a request to publish declined, with the reason
|
|
31590
|
+
yank <slug> <version> withdraw a published release
|
|
31591
|
+
releases <slug> any app's releases
|
|
31592
|
+
app visibility <slug> <draft | unlisted | public>`;
|
|
31593
|
+
var VERSION3 = false ? null : "0.98.0";
|
|
31594
|
+
var usage = (admin) => `faustwave \u2014 build WebCLAP plugins from Faust patches and publish them on faustwave.io
|
|
31595
|
+
|
|
31596
|
+
faustwave <command> [options]
|
|
31597
|
+
|
|
31598
|
+
${STUDIO ? "No IDE needed:" : "Commands:"}
|
|
31599
|
+
build plugin <patch.dsp> a Faust patch as a WebCLAP plugin with its page: <name>.wclap.tar.gz
|
|
31600
|
+
(faustwave build plugin --help: its options, examples, the layout tags)
|
|
31349
31601
|
update the newest faustwave (the npm package: npm i -g faustwave@latest)
|
|
31602
|
+
update --auto on|off whether faustwave updates by itself when there is a newer one (asked once)
|
|
31603
|
+
help this (also: -h, --help)
|
|
31604
|
+
version which faustwave this is (also: -v, --version)
|
|
31605
|
+
${STUDIO ? USAGE_STUDIO : ""}${USAGE_HUB}${admin ? USAGE_ADMIN : ""}
|
|
31350
31606
|
|
|
31351
|
-
|
|
31352
|
-
build plugin
|
|
31353
|
-
|
|
31354
|
-
|
|
31355
|
-
controls laid out by [device:*] tags (faustwave build plugin alone says them); --sources packs
|
|
31356
|
-
the patch with it
|
|
31357
|
-
${HUB2 ? USAGE_HUB : ""}`;
|
|
31358
|
-
var HUB_COMMANDS = ["login", "logout", "app", "item", "purchases", "refund", "reconcile", "push", "submit", "review", "publish", "yank", "releases"];
|
|
31607
|
+
Start here:
|
|
31608
|
+
faustwave build plugin tremolo.dsp then import tremolo.wclap.tar.gz into a WebCLAP host
|
|
31609
|
+
https://faustwave.io/webclap write and hear a patch in the browser first`;
|
|
31610
|
+
var HUB_COMMANDS = ["login", "logout", "app", "push", "submit", "review", "publish", "reject", "me", "allow", "decline", "yank", "releases"];
|
|
31359
31611
|
var run = async (action, input = {}) => {
|
|
31360
31612
|
const r = await askWaking({ op: "call", name: "palette.run", input: { action_id: action, input } });
|
|
31361
31613
|
return typeof r === "string" ? r : JSON.stringify(r);
|
|
31362
31614
|
};
|
|
31363
31615
|
var inputOf = (arg) => arg === void 0 ? {} : JSON.parse(fs7.existsSync(arg) ? fs7.readFileSync(arg, "utf8") : arg);
|
|
31364
31616
|
var [command, ...rest] = process.argv.slice(2);
|
|
31617
|
+
var HELP = ["help", "--help", "-h"];
|
|
31618
|
+
var pluginHelp = HELP.includes(command) && rest[0] === "build" || command === "build" && rest.some((a) => HELP.includes(a)) || command === "build" && rest.length === 1 && rest[0] === "plugin";
|
|
31365
31619
|
var endsByItself = HUB_COMMANDS.includes(command) && !process.versions.electron;
|
|
31366
31620
|
var done = () => process.stdout.write("", () => process.exit(0));
|
|
31367
31621
|
try {
|
|
31368
31622
|
if (!STUDIO && (STUDIO_COMMANDS.includes(command) || command === "workflow" && !(await Promise.resolve().then(() => (init_workflow(), workflow_exports))).overHub(rest[1])))
|
|
31369
31623
|
throw new Error(`faustwave ${command} plays the FaustWave studio \u2014 it comes with a later update (faustwave update).`);
|
|
31370
|
-
if (
|
|
31371
|
-
|
|
31372
|
-
if (command === "
|
|
31624
|
+
if (pluginHelp) process.stdout.write(`${(await Promise.resolve().then(() => (init_convert(), convert_exports))).PLUGIN_HELP}
|
|
31625
|
+
`);
|
|
31626
|
+
else if (command === void 0 || HELP.includes(command) || rest.includes("--help") || rest.includes("-h")) process.stdout.write(`${usage((await Promise.resolve().then(() => (init_hub(), hub_exports))).signedInAsAdmin())}
|
|
31627
|
+
`);
|
|
31628
|
+
else if (["version", "--version", "-v"].includes(command)) process.stdout.write(`faustwave ${VERSION3 ?? "(a development checkout \u2014 it has no version of its own)"}
|
|
31629
|
+
`);
|
|
31630
|
+
else if (command === "mcp") await mcp();
|
|
31373
31631
|
else if (command === "run" && rest[0]) process.stdout.write(await run(rest[0], inputOf(rest[1])) + "\n");
|
|
31374
31632
|
else if (command === "shot" && rest[0]) {
|
|
31375
31633
|
const r = await askWaking({ op: "call", name: "palette.run", input: { action_id: "stage.picture", input: { module_id: rest[0] } } });
|
|
@@ -31400,11 +31658,12 @@ try {
|
|
|
31400
31658
|
`);
|
|
31401
31659
|
else if (command === "update") {
|
|
31402
31660
|
endsByItself = !process.versions.electron;
|
|
31403
|
-
process.stdout.write(`${await (await Promise.resolve().then(() => (init_update(), update_exports))).update()}
|
|
31661
|
+
process.stdout.write(`${await (await Promise.resolve().then(() => (init_update(), update_exports))).update(rest)}
|
|
31404
31662
|
`);
|
|
31405
31663
|
} else {
|
|
31406
|
-
process.stderr.write(
|
|
31407
|
-
|
|
31664
|
+
process.stderr.write(`faustwave ${command}: no such command \u2014 faustwave help lists them.
|
|
31665
|
+
`);
|
|
31666
|
+
process.exit(2);
|
|
31408
31667
|
}
|
|
31409
31668
|
if (command !== "mcp" && command !== "update") await (await Promise.resolve().then(() => (init_update(), update_exports))).hint();
|
|
31410
31669
|
if (command !== "mcp" && !endsByItself) done();
|