@doufunao123/asset-gateway 0.12.0 → 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.
Files changed (2) hide show
  1. package/dist/index.js +19 -12
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -623,8 +623,8 @@ 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
630
  const map = { image: "png", audio: "mp3", music: "mp3", tts: "mp3", video: "mp4", model3d: "glb", text: "txt", sprite: "png" };
@@ -925,11 +925,18 @@ function createGenerateCommand() {
925
925
  if (options.negativePrompt) params.negative_prompt = options.negativePrompt;
926
926
  if (options.seed) params.seed = Number(options.seed);
927
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
+ }
928
935
  const body = {
929
936
  asset_type: "sprite",
930
937
  prompt: options.prompt,
931
938
  model: options.model,
932
- input_file: options.input,
939
+ input_file: inputFile,
933
940
  params
934
941
  };
935
942
  const data = await ctx.client.post("/api/generate", body);
@@ -990,13 +997,13 @@ function createJobCommand() {
990
997
  }
991
998
 
992
999
  // src/commands/process.ts
993
- import { mkdirSync as mkdirSync3, readFileSync as readFileSync2, writeFileSync as writeFileSync3 } from "fs";
994
- import { existsSync as existsSync3 } from "fs";
1000
+ import { mkdirSync as mkdirSync3, readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "fs";
1001
+ import { existsSync as existsSync4 } from "fs";
995
1002
  import { join as join3 } from "path";
996
1003
  import { Command as Command5 } from "commander";
997
1004
  function readInputAsBase64(input) {
998
- if (existsSync3(input)) {
999
- const bytes = readFileSync2(input);
1005
+ if (existsSync4(input)) {
1006
+ const bytes = readFileSync3(input);
1000
1007
  return `data:image/png;base64,${bytes.toString("base64")}`;
1001
1008
  }
1002
1009
  return input;
@@ -1495,11 +1502,11 @@ function createUploadCommand() {
1495
1502
  }
1496
1503
 
1497
1504
  // src/commands/voice.ts
1498
- import { existsSync as existsSync4, readFileSync as readFileSync3 } from "fs";
1499
- import { extname } from "path";
1505
+ import { existsSync as existsSync5, readFileSync as readFileSync4 } from "fs";
1506
+ import { extname as extname2 } from "path";
1500
1507
  import { Command as Command9 } from "commander";
1501
1508
  function inferAudioMime(filePath) {
1502
- const extension = extname(filePath).toLowerCase();
1509
+ const extension = extname2(filePath).toLowerCase();
1503
1510
  const map = {
1504
1511
  ".mp3": "audio/mpeg",
1505
1512
  ".wav": "audio/wav",
@@ -1513,10 +1520,10 @@ function inferAudioMime(filePath) {
1513
1520
  return map[extension] ?? "application/octet-stream";
1514
1521
  }
1515
1522
  function readAudioAsBase64(filePath) {
1516
- if (!existsSync4(filePath)) {
1523
+ if (!existsSync5(filePath)) {
1517
1524
  throw configError(`Audio file not found: ${filePath}`);
1518
1525
  }
1519
- const bytes = readFileSync3(filePath);
1526
+ const bytes = readFileSync4(filePath);
1520
1527
  return {
1521
1528
  audio_base64: bytes.toString("base64"),
1522
1529
  audio_mime: inferAudioMime(filePath)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doufunao123/asset-gateway",
3
- "version": "0.12.0",
3
+ "version": "0.12.1",
4
4
  "description": "Universal asset generation gateway CLI",
5
5
  "type": "module",
6
6
  "bin": {