@doufunao123/asset-gateway 0.11.1 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +47 -12
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -623,11 +623,11 @@ function createDescribeCommand() {
|
|
|
623
623
|
}
|
|
624
624
|
|
|
625
625
|
// src/commands/generate.ts
|
|
626
|
-
import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
627
|
-
import { dirname as dirname2, join as join2 } from "path";
|
|
626
|
+
import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
627
|
+
import { dirname as dirname2, extname, join as join2 } from "path";
|
|
628
628
|
import { Command as Command3 } from "commander";
|
|
629
629
|
function inferExtension(assetType) {
|
|
630
|
-
const map = { image: "png", audio: "mp3", music: "mp3", tts: "mp3", video: "mp4", model3d: "glb", text: "txt" };
|
|
630
|
+
const map = { image: "png", audio: "mp3", music: "mp3", tts: "mp3", video: "mp4", model3d: "glb", text: "txt", sprite: "png" };
|
|
631
631
|
return map[assetType] ?? "bin";
|
|
632
632
|
}
|
|
633
633
|
function stripDataUri(data) {
|
|
@@ -913,6 +913,41 @@ function createGenerateCommand() {
|
|
|
913
913
|
}
|
|
914
914
|
})
|
|
915
915
|
);
|
|
916
|
+
command.addCommand(
|
|
917
|
+
new Command3("sprite").description("Animate a sprite image using PixelEngine AI").requiredOption("--prompt <text>", "Animation prompt describing the desired motion").requiredOption("--input <path>", "Input sprite image (local path or URL)").option("--model <model>", "Model: pixel-engine-v1.1 or frame-engine-v1.1", "pixel-engine-v1.1").option("--output-frames <n>", "Number of animation frames (even integer)", "8").option("--output-format <fmt>", "Output format: spritesheet, webp, gif", "spritesheet").option("--colors <n>", "Pixel palette color count (2-256, pixel model only)").option("--negative-prompt <text>", "What to avoid in the generation").option("--seed <n>", "Seed for reproducibility").option("--matte-color <hex>", "Matte color for alpha flattening (6-char hex)").option("--enhance-prompt", "Enhance the prompt before generation").option("--output-dir <dir>", "Directory to save output", ".").action(async function(options) {
|
|
918
|
+
try {
|
|
919
|
+
const ctx = createContext(this);
|
|
920
|
+
const params = {
|
|
921
|
+
output_frames: Number(options.outputFrames),
|
|
922
|
+
output_format: options.outputFormat
|
|
923
|
+
};
|
|
924
|
+
if (options.colors) params.pixel_config = { colors: Number(options.colors) };
|
|
925
|
+
if (options.negativePrompt) params.negative_prompt = options.negativePrompt;
|
|
926
|
+
if (options.seed) params.seed = Number(options.seed);
|
|
927
|
+
if (options.matteColor) params.matte_color = options.matteColor;
|
|
928
|
+
let inputFile = options.input;
|
|
929
|
+
if (existsSync3(inputFile)) {
|
|
930
|
+
const ext = extname(inputFile).toLowerCase();
|
|
931
|
+
const mime = ext === ".jpg" || ext === ".jpeg" ? "image/jpeg" : "image/png";
|
|
932
|
+
const b64 = readFileSync2(inputFile).toString("base64");
|
|
933
|
+
inputFile = `data:${mime};base64,${b64}`;
|
|
934
|
+
}
|
|
935
|
+
const body = {
|
|
936
|
+
asset_type: "sprite",
|
|
937
|
+
prompt: options.prompt,
|
|
938
|
+
model: options.model,
|
|
939
|
+
input_file: inputFile,
|
|
940
|
+
params
|
|
941
|
+
};
|
|
942
|
+
const data = await ctx.client.post("/api/generate", body);
|
|
943
|
+
const localPath = await saveOutput(data, "sprite", options.outputDir);
|
|
944
|
+
if (localPath) data.local_path = localPath;
|
|
945
|
+
printSuccess("generate.sprite", data, ctx);
|
|
946
|
+
} catch (error2) {
|
|
947
|
+
printError("generate.sprite", error2);
|
|
948
|
+
}
|
|
949
|
+
})
|
|
950
|
+
);
|
|
916
951
|
return command;
|
|
917
952
|
}
|
|
918
953
|
|
|
@@ -962,13 +997,13 @@ function createJobCommand() {
|
|
|
962
997
|
}
|
|
963
998
|
|
|
964
999
|
// src/commands/process.ts
|
|
965
|
-
import { mkdirSync as mkdirSync3, readFileSync as
|
|
966
|
-
import { existsSync as
|
|
1000
|
+
import { mkdirSync as mkdirSync3, readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "fs";
|
|
1001
|
+
import { existsSync as existsSync4 } from "fs";
|
|
967
1002
|
import { join as join3 } from "path";
|
|
968
1003
|
import { Command as Command5 } from "commander";
|
|
969
1004
|
function readInputAsBase64(input) {
|
|
970
|
-
if (
|
|
971
|
-
const bytes =
|
|
1005
|
+
if (existsSync4(input)) {
|
|
1006
|
+
const bytes = readFileSync3(input);
|
|
972
1007
|
return `data:image/png;base64,${bytes.toString("base64")}`;
|
|
973
1008
|
}
|
|
974
1009
|
return input;
|
|
@@ -1467,11 +1502,11 @@ function createUploadCommand() {
|
|
|
1467
1502
|
}
|
|
1468
1503
|
|
|
1469
1504
|
// src/commands/voice.ts
|
|
1470
|
-
import { existsSync as
|
|
1471
|
-
import { extname } from "path";
|
|
1505
|
+
import { existsSync as existsSync5, readFileSync as readFileSync4 } from "fs";
|
|
1506
|
+
import { extname as extname2 } from "path";
|
|
1472
1507
|
import { Command as Command9 } from "commander";
|
|
1473
1508
|
function inferAudioMime(filePath) {
|
|
1474
|
-
const extension =
|
|
1509
|
+
const extension = extname2(filePath).toLowerCase();
|
|
1475
1510
|
const map = {
|
|
1476
1511
|
".mp3": "audio/mpeg",
|
|
1477
1512
|
".wav": "audio/wav",
|
|
@@ -1485,10 +1520,10 @@ function inferAudioMime(filePath) {
|
|
|
1485
1520
|
return map[extension] ?? "application/octet-stream";
|
|
1486
1521
|
}
|
|
1487
1522
|
function readAudioAsBase64(filePath) {
|
|
1488
|
-
if (!
|
|
1523
|
+
if (!existsSync5(filePath)) {
|
|
1489
1524
|
throw configError(`Audio file not found: ${filePath}`);
|
|
1490
1525
|
}
|
|
1491
|
-
const bytes =
|
|
1526
|
+
const bytes = readFileSync4(filePath);
|
|
1492
1527
|
return {
|
|
1493
1528
|
audio_base64: bytes.toString("base64"),
|
|
1494
1529
|
audio_mime: inferAudioMime(filePath)
|