dist-mcp / services / drawThingsConfigMapper.js
dist-mcp / services / drawThingsConfigMapper.js
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildDtGenerationConfiguration = buildDtGenerationConfiguration;
const flatbuffers = __importStar(require("flatbuffers"));
const core_bundle_mjs_1 = require("../core-bundle.mjs");
function buildDtGenerationConfiguration(p) {
const w = typeof p.width === "number" ? p.width : 576;
const h = typeof p.height === "number" ? p.height : 768;
const start_width = Math.max(1, Math.round(w / 64));
const start_height = Math.max(1, Math.round(h / 64));
// Sampler: Accept number (SamplerType enum) directly, or string for legacy
let samplerEnum = core_bundle_mjs_1.SamplerType.UniPCTrailing; // Default
let samplerName = "UniPCTrailing";
if (typeof p.sampler === "number") {
// Direct number from custom_configs.json or explicit API call
samplerEnum = p.sampler;
// Reverse lookup for logging
samplerName =
Object.keys(core_bundle_mjs_1.SamplerType).find((k) => core_bundle_mjs_1.SamplerType[k] === p.sampler) || "Unknown";
}
else if (typeof p.sampler === "string") {
// Legacy string format (e.g., "UniPC Trailing")
samplerName = p.sampler.replace(/\s+/g, "");
samplerEnum =
core_bundle_mjs_1.SamplerType[samplerName] ?? core_bundle_mjs_1.SamplerType.UniPCTrailing;
}
const seedModeEnum = core_bundle_mjs_1.SeedMode[String(p.seed_mode || "Scale Alike").replace(/\s+/g, "")] ?? core_bundle_mjs_1.SeedMode.ScaleAlike;
const view = {
id: 1,
start_width,
start_height,
seed: typeof p.seed === "number" ? p.seed : undefined,
steps: typeof p.steps === "number" ? p.steps : undefined,
sampler: samplerName,
batch_count: typeof p.batch_count === "number"
? p.batch_count
: undefined,
batch_size: typeof p.batch_size === "number"
? Math.max(1, Math.min(4, Math.round(p.batch_size)))
: 1,
model: p.model || undefined,
seed_mode: String(p.seed_mode || "Scale Alike").replace(/\s+/g, ""),
t5_text: p.t5_text || undefined,
clip_l_text: p.clip_l_text || undefined,
image_guidance_scale: typeof p.image_guidance === "number" ? p.image_guidance : undefined,
tiled_decoding: !!p.tiled_decoding,
decoding_tile_width: typeof p.decoding_tile_width === "number"
? Math.max(1, Math.round(p.decoding_tile_width / 64))
: undefined,
decoding_tile_height: typeof p.decoding_tile_height === "number"
? Math.max(1, Math.round(p.decoding_tile_height / 64))
: undefined,
decoding_tile_overlap: typeof p.decoding_tile_overlap === "number"
? Math.max(0, Math.round(p.decoding_tile_overlap / 64))
: undefined,
compressionArtifacts: p.compressionArtifacts ?? p.compression_artifacts ?? undefined,
compressionArtifactsQuality: typeof p.compressionArtifactsQuality === "number"
? p.compressionArtifactsQuality
: typeof p.compression_artifacts_quality === "number"
? p.compression_artifacts_quality
: undefined,
num_frames: typeof p.num_frames === "number" ? p.num_frames : undefined,
};
// Cast: video and core may resolve flatbuffers from different node_modules
// (file: symlink). At runtime there is only one copy — the cast is safe.
const builder = new flatbuffers.Builder(2048);
// Strings
const modelOffset = p.model ? builder.createString(p.model) : 0;
const clipLTextOffset = p.clip_l_text
? builder.createString(p.clip_l_text)
: 0;
const t5TextOffset = p.t5_text ? builder.createString(p.t5_text) : 0;
const openClipGTextOffset = p.open_clip_g_text
? builder.createString(p.open_clip_g_text)
: 0;
// LoRAs
let lorasVector = 0;
if (Array.isArray(p.loras) && p.loras.length) {
const loff = [];
for (const l of p.loras) {
const f = l.file ? builder.createString(l.file) : 0;
const wt = typeof l.weight === "number" ? l.weight : 1.0;
loff.push(core_bundle_mjs_1.LoRA.createLoRA(builder, f, wt, core_bundle_mjs_1.LoRAMode.All));
}
lorasVector = core_bundle_mjs_1.GenerationConfiguration.createLorasVector(builder, loff);
}
// Start object
core_bundle_mjs_1.GenerationConfiguration.startGenerationConfiguration(builder);
core_bundle_mjs_1.GenerationConfiguration.addId(builder, BigInt(1));
core_bundle_mjs_1.GenerationConfiguration.addStartWidth(builder, start_width);
core_bundle_mjs_1.GenerationConfiguration.addStartHeight(builder, start_height);
if (typeof p.seed === "number")
core_bundle_mjs_1.GenerationConfiguration.addSeed(builder, p.seed);
if (typeof p.steps === "number")
core_bundle_mjs_1.GenerationConfiguration.addSteps(builder, p.steps);
if (typeof p.guidance_scale === "number")
core_bundle_mjs_1.GenerationConfiguration.addGuidanceScale(builder, p.guidance_scale);
if (typeof p.strength === "number")
core_bundle_mjs_1.GenerationConfiguration.addStrength(builder, p.strength);
if (modelOffset)
core_bundle_mjs_1.GenerationConfiguration.addModel(builder, modelOffset);
core_bundle_mjs_1.GenerationConfiguration.addSampler(builder, samplerEnum);
if (typeof p.batch_count === "number") {
core_bundle_mjs_1.GenerationConfiguration.addBatchCount(builder, p.batch_count);
}
// Respect requested batch_size (clamped 1..4) to control variants; batch_count remains 1
const batchSize = typeof p.batch_size === "number"
? Math.max(1, Math.min(4, Math.round(p.batch_size)))
: 1;
core_bundle_mjs_1.GenerationConfiguration.addBatchSize(builder, batchSize);
if (typeof p.image_guidance === "number")
core_bundle_mjs_1.GenerationConfiguration.addImageGuidanceScale(builder, p.image_guidance);
core_bundle_mjs_1.GenerationConfiguration.addSeedMode(builder, seedModeEnum);
if (typeof p.clip_skip === "number")
core_bundle_mjs_1.GenerationConfiguration.addClipSkip(builder, p.clip_skip);
if (lorasVector)
core_bundle_mjs_1.GenerationConfiguration.addLoras(builder, lorasVector);
if (typeof p.mask_blur === "number")
core_bundle_mjs_1.GenerationConfiguration.addMaskBlur(builder, p.mask_blur);
if (typeof p.clip_weight === "number")
core_bundle_mjs_1.GenerationConfiguration.addClipWeight(builder, p.clip_weight);
if (typeof p.image_prior_steps === "number")
core_bundle_mjs_1.GenerationConfiguration.addImagePriorSteps(builder, p.image_prior_steps);
if (typeof p.negative_original_height === "number")
core_bundle_mjs_1.GenerationConfiguration.addNegativeOriginalImageHeight(builder, p.negative_original_height);
if (typeof p.negative_original_width === "number")
core_bundle_mjs_1.GenerationConfiguration.addNegativeOriginalImageWidth(builder, p.negative_original_width);
if (typeof p.fps === "number")
core_bundle_mjs_1.GenerationConfiguration.addFpsId(builder, p.fps);
if (typeof p.motion_scale === "number")
core_bundle_mjs_1.GenerationConfiguration.addMotionBucketId(builder, p.motion_scale);
if (typeof p.start_frame_guidance === "number")
core_bundle_mjs_1.GenerationConfiguration.addStartFrameCfg(builder, p.start_frame_guidance);
if (typeof p.num_frames === "number")
core_bundle_mjs_1.GenerationConfiguration.addNumFrames(builder, p.num_frames);
if (typeof p.sharpness === "number")
core_bundle_mjs_1.GenerationConfiguration.addSharpness(builder, p.sharpness);
if (typeof p.shift === "number")
core_bundle_mjs_1.GenerationConfiguration.addShift(builder, p.shift);
if (typeof p.tiled_decoding === "boolean")
core_bundle_mjs_1.GenerationConfiguration.addTiledDecoding(builder, !!p.tiled_decoding);
if (typeof p.decoding_tile_width === "number")
core_bundle_mjs_1.GenerationConfiguration.addDecodingTileWidth(builder, Math.max(1, Math.round(p.decoding_tile_width / 64)));
if (typeof p.decoding_tile_height === "number")
core_bundle_mjs_1.GenerationConfiguration.addDecodingTileHeight(builder, Math.max(1, Math.round(p.decoding_tile_height / 64)));
if (typeof p.decoding_tile_overlap === "number")
core_bundle_mjs_1.GenerationConfiguration.addDecodingTileOverlap(builder, Math.max(0, Math.round(p.decoding_tile_overlap / 64)));
if (typeof p.stochastic_sampling_gamma === "number")
core_bundle_mjs_1.GenerationConfiguration.addStochasticSamplingGamma(builder, p.stochastic_sampling_gamma);
if (typeof p.tiled_diffusion === "boolean")
core_bundle_mjs_1.GenerationConfiguration.addTiledDiffusion(builder, !!p.tiled_diffusion);
if (clipLTextOffset)
core_bundle_mjs_1.GenerationConfiguration.addClipLText(builder, clipLTextOffset);
if (openClipGTextOffset)
core_bundle_mjs_1.GenerationConfiguration.addOpenClipGText(builder, openClipGTextOffset);
if (typeof p.speed_up_with_guidance_embed === "boolean")
core_bundle_mjs_1.GenerationConfiguration.addSpeedUpWithGuidanceEmbed(builder, !!p.speed_up_with_guidance_embed);
if (typeof p.guidance_embed === "number")
core_bundle_mjs_1.GenerationConfiguration.addGuidanceEmbed(builder, p.guidance_embed);
if (typeof p.resolution_dependent_shift === "boolean")
core_bundle_mjs_1.GenerationConfiguration.addResolutionDependentShift(builder, !!p.resolution_dependent_shift);
if (typeof p.tea_cache_start === "number")
core_bundle_mjs_1.GenerationConfiguration.addTeaCacheStart(builder, p.tea_cache_start);
if (typeof p.tea_cache_end === "number")
core_bundle_mjs_1.GenerationConfiguration.addTeaCacheEnd(builder, p.tea_cache_end);
if (typeof p.tea_cache_threshold === "number")
core_bundle_mjs_1.GenerationConfiguration.addTeaCacheThreshold(builder, p.tea_cache_threshold);
if (typeof p.tea_cache === "boolean")
core_bundle_mjs_1.GenerationConfiguration.addTeaCache(builder, !!p.tea_cache);
if (typeof p.separate_t5 === "boolean")
core_bundle_mjs_1.GenerationConfiguration.addSeparateT5(builder, !!p.separate_t5);
if (t5TextOffset)
core_bundle_mjs_1.GenerationConfiguration.addT5Text(builder, t5TextOffset);
if (typeof p.tea_cache_max_skip_steps === "number")
core_bundle_mjs_1.GenerationConfiguration.addTeaCacheMaxSkipSteps(builder, p.tea_cache_max_skip_steps);
if (typeof p.causal_inference === "number")
core_bundle_mjs_1.GenerationConfiguration.addCausalInference(builder, p.causal_inference);
if (typeof p.causal_inference_pad === "number")
core_bundle_mjs_1.GenerationConfiguration.addCausalInferencePad(builder, p.causal_inference_pad);
if (typeof p.cfg_zero_star === "boolean")
core_bundle_mjs_1.GenerationConfiguration.addCfgZeroStar(builder, !!p.cfg_zero_star);
if (typeof p.cfg_zero_init_steps === "number")
core_bundle_mjs_1.GenerationConfiguration.addCfgZeroInitSteps(builder, p.cfg_zero_init_steps);
const caValue = p.compressionArtifacts ?? p.compression_artifacts;
if (typeof caValue === "string") {
const ca = caValue;
const caEnum = ca === "h264" ? core_bundle_mjs_1.CompressionMethod.H264
: ca === "h265" ? core_bundle_mjs_1.CompressionMethod.H265
: ca === "jpeg" ? core_bundle_mjs_1.CompressionMethod.Jpeg
: core_bundle_mjs_1.CompressionMethod.Disabled;
core_bundle_mjs_1.GenerationConfiguration.addCompressionArtifacts(builder, caEnum);
}
const caQualityValue = p.compressionArtifactsQuality ?? p.compression_artifacts_quality;
if (typeof caQualityValue === "number")
core_bundle_mjs_1.GenerationConfiguration.addCompressionArtifactsQuality(builder, caQualityValue);
const root = core_bundle_mjs_1.GenerationConfiguration.endGenerationConfiguration(builder);
core_bundle_mjs_1.GenerationConfiguration.finishGenerationConfigurationBuffer(builder, root);
const bytes = Buffer.from(builder.asUint8Array());
return { view, bytes };
}
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildDtGenerationConfiguration = buildDtGenerationConfiguration;
const flatbuffers = __importStar(require("flatbuffers"));
const core_bundle_mjs_1 = require("../core-bundle.mjs");
function buildDtGenerationConfiguration(p) {
const w = typeof p.width === "number" ? p.width : 576;
const h = typeof p.height === "number" ? p.height : 768;
const start_width = Math.max(1, Math.round(w / 64));
const start_height = Math.max(1, Math.round(h / 64));
// Sampler: Accept number (SamplerType enum) directly, or string for legacy
let samplerEnum = core_bundle_mjs_1.SamplerType.UniPCTrailing; // Default
let samplerName = "UniPCTrailing";
if (typeof p.sampler === "number") {
// Direct number from custom_configs.json or explicit API call
samplerEnum = p.sampler;
// Reverse lookup for logging
samplerName =
Object.keys(core_bundle_mjs_1.SamplerType).find((k) => core_bundle_mjs_1.SamplerType[k] === p.sampler) || "Unknown";
}
else if (typeof p.sampler === "string") {
// Legacy string format (e.g., "UniPC Trailing")
samplerName = p.sampler.replace(/\s+/g, "");
samplerEnum =
core_bundle_mjs_1.SamplerType[samplerName] ?? core_bundle_mjs_1.SamplerType.UniPCTrailing;
}
const seedModeEnum = core_bundle_mjs_1.SeedMode[String(p.seed_mode || "Scale Alike").replace(/\s+/g, "")] ?? core_bundle_mjs_1.SeedMode.ScaleAlike;
const view = {
id: 1,
start_width,
start_height,
seed: typeof p.seed === "number" ? p.seed : undefined,
steps: typeof p.steps === "number" ? p.steps : undefined,
sampler: samplerName,
batch_count: typeof p.batch_count === "number"
? p.batch_count
: undefined,
batch_size: typeof p.batch_size === "number"
? Math.max(1, Math.min(4, Math.round(p.batch_size)))
: 1,
model: p.model || undefined,
seed_mode: String(p.seed_mode || "Scale Alike").replace(/\s+/g, ""),
t5_text: p.t5_text || undefined,
clip_l_text: p.clip_l_text || undefined,
image_guidance_scale: typeof p.image_guidance === "number" ? p.image_guidance : undefined,
tiled_decoding: !!p.tiled_decoding,
decoding_tile_width: typeof p.decoding_tile_width === "number"
? Math.max(1, Math.round(p.decoding_tile_width / 64))
: undefined,
decoding_tile_height: typeof p.decoding_tile_height === "number"
? Math.max(1, Math.round(p.decoding_tile_height / 64))
: undefined,
decoding_tile_overlap: typeof p.decoding_tile_overlap === "number"
? Math.max(0, Math.round(p.decoding_tile_overlap / 64))
: undefined,
compressionArtifacts: p.compressionArtifacts ?? p.compression_artifacts ?? undefined,
compressionArtifactsQuality: typeof p.compressionArtifactsQuality === "number"
? p.compressionArtifactsQuality
: typeof p.compression_artifacts_quality === "number"
? p.compression_artifacts_quality
: undefined,
num_frames: typeof p.num_frames === "number" ? p.num_frames : undefined,
};
// Cast: video and core may resolve flatbuffers from different node_modules
// (file: symlink). At runtime there is only one copy — the cast is safe.
const builder = new flatbuffers.Builder(2048);
// Strings
const modelOffset = p.model ? builder.createString(p.model) : 0;
const clipLTextOffset = p.clip_l_text
? builder.createString(p.clip_l_text)
: 0;
const t5TextOffset = p.t5_text ? builder.createString(p.t5_text) : 0;
const openClipGTextOffset = p.open_clip_g_text
? builder.createString(p.open_clip_g_text)
: 0;
// LoRAs
let lorasVector = 0;
if (Array.isArray(p.loras) && p.loras.length) {
const loff = [];
for (const l of p.loras) {
const f = l.file ? builder.createString(l.file) : 0;
const wt = typeof l.weight === "number" ? l.weight : 1.0;
loff.push(core_bundle_mjs_1.LoRA.createLoRA(builder, f, wt, core_bundle_mjs_1.LoRAMode.All));
}
lorasVector = core_bundle_mjs_1.GenerationConfiguration.createLorasVector(builder, loff);
}
// Start object
core_bundle_mjs_1.GenerationConfiguration.startGenerationConfiguration(builder);
core_bundle_mjs_1.GenerationConfiguration.addId(builder, BigInt(1));
core_bundle_mjs_1.GenerationConfiguration.addStartWidth(builder, start_width);
core_bundle_mjs_1.GenerationConfiguration.addStartHeight(builder, start_height);
if (typeof p.seed === "number")
core_bundle_mjs_1.GenerationConfiguration.addSeed(builder, p.seed);
if (typeof p.steps === "number")
core_bundle_mjs_1.GenerationConfiguration.addSteps(builder, p.steps);
if (typeof p.guidance_scale === "number")
core_bundle_mjs_1.GenerationConfiguration.addGuidanceScale(builder, p.guidance_scale);
if (typeof p.strength === "number")
core_bundle_mjs_1.GenerationConfiguration.addStrength(builder, p.strength);
if (modelOffset)
core_bundle_mjs_1.GenerationConfiguration.addModel(builder, modelOffset);
core_bundle_mjs_1.GenerationConfiguration.addSampler(builder, samplerEnum);
if (typeof p.batch_count === "number") {
core_bundle_mjs_1.GenerationConfiguration.addBatchCount(builder, p.batch_count);
}
// Respect requested batch_size (clamped 1..4) to control variants; batch_count remains 1
const batchSize = typeof p.batch_size === "number"
? Math.max(1, Math.min(4, Math.round(p.batch_size)))
: 1;
core_bundle_mjs_1.GenerationConfiguration.addBatchSize(builder, batchSize);
if (typeof p.image_guidance === "number")
core_bundle_mjs_1.GenerationConfiguration.addImageGuidanceScale(builder, p.image_guidance);
core_bundle_mjs_1.GenerationConfiguration.addSeedMode(builder, seedModeEnum);
if (typeof p.clip_skip === "number")
core_bundle_mjs_1.GenerationConfiguration.addClipSkip(builder, p.clip_skip);
if (lorasVector)
core_bundle_mjs_1.GenerationConfiguration.addLoras(builder, lorasVector);
if (typeof p.mask_blur === "number")
core_bundle_mjs_1.GenerationConfiguration.addMaskBlur(builder, p.mask_blur);
if (typeof p.clip_weight === "number")
core_bundle_mjs_1.GenerationConfiguration.addClipWeight(builder, p.clip_weight);
if (typeof p.image_prior_steps === "number")
core_bundle_mjs_1.GenerationConfiguration.addImagePriorSteps(builder, p.image_prior_steps);
if (typeof p.negative_original_height === "number")
core_bundle_mjs_1.GenerationConfiguration.addNegativeOriginalImageHeight(builder, p.negative_original_height);
if (typeof p.negative_original_width === "number")
core_bundle_mjs_1.GenerationConfiguration.addNegativeOriginalImageWidth(builder, p.negative_original_width);
if (typeof p.fps === "number")
core_bundle_mjs_1.GenerationConfiguration.addFpsId(builder, p.fps);
if (typeof p.motion_scale === "number")
core_bundle_mjs_1.GenerationConfiguration.addMotionBucketId(builder, p.motion_scale);
if (typeof p.start_frame_guidance === "number")
core_bundle_mjs_1.GenerationConfiguration.addStartFrameCfg(builder, p.start_frame_guidance);
if (typeof p.num_frames === "number")
core_bundle_mjs_1.GenerationConfiguration.addNumFrames(builder, p.num_frames);
if (typeof p.sharpness === "number")
core_bundle_mjs_1.GenerationConfiguration.addSharpness(builder, p.sharpness);
if (typeof p.shift === "number")
core_bundle_mjs_1.GenerationConfiguration.addShift(builder, p.shift);
if (typeof p.tiled_decoding === "boolean")
core_bundle_mjs_1.GenerationConfiguration.addTiledDecoding(builder, !!p.tiled_decoding);
if (typeof p.decoding_tile_width === "number")
core_bundle_mjs_1.GenerationConfiguration.addDecodingTileWidth(builder, Math.max(1, Math.round(p.decoding_tile_width / 64)));
if (typeof p.decoding_tile_height === "number")
core_bundle_mjs_1.GenerationConfiguration.addDecodingTileHeight(builder, Math.max(1, Math.round(p.decoding_tile_height / 64)));
if (typeof p.decoding_tile_overlap === "number")
core_bundle_mjs_1.GenerationConfiguration.addDecodingTileOverlap(builder, Math.max(0, Math.round(p.decoding_tile_overlap / 64)));
if (typeof p.stochastic_sampling_gamma === "number")
core_bundle_mjs_1.GenerationConfiguration.addStochasticSamplingGamma(builder, p.stochastic_sampling_gamma);
if (typeof p.tiled_diffusion === "boolean")
core_bundle_mjs_1.GenerationConfiguration.addTiledDiffusion(builder, !!p.tiled_diffusion);
if (clipLTextOffset)
core_bundle_mjs_1.GenerationConfiguration.addClipLText(builder, clipLTextOffset);
if (openClipGTextOffset)
core_bundle_mjs_1.GenerationConfiguration.addOpenClipGText(builder, openClipGTextOffset);
if (typeof p.speed_up_with_guidance_embed === "boolean")
core_bundle_mjs_1.GenerationConfiguration.addSpeedUpWithGuidanceEmbed(builder, !!p.speed_up_with_guidance_embed);
if (typeof p.guidance_embed === "number")
core_bundle_mjs_1.GenerationConfiguration.addGuidanceEmbed(builder, p.guidance_embed);
if (typeof p.resolution_dependent_shift === "boolean")
core_bundle_mjs_1.GenerationConfiguration.addResolutionDependentShift(builder, !!p.resolution_dependent_shift);
if (typeof p.tea_cache_start === "number")
core_bundle_mjs_1.GenerationConfiguration.addTeaCacheStart(builder, p.tea_cache_start);
if (typeof p.tea_cache_end === "number")
core_bundle_mjs_1.GenerationConfiguration.addTeaCacheEnd(builder, p.tea_cache_end);
if (typeof p.tea_cache_threshold === "number")
core_bundle_mjs_1.GenerationConfiguration.addTeaCacheThreshold(builder, p.tea_cache_threshold);
if (typeof p.tea_cache === "boolean")
core_bundle_mjs_1.GenerationConfiguration.addTeaCache(builder, !!p.tea_cache);
if (typeof p.separate_t5 === "boolean")
core_bundle_mjs_1.GenerationConfiguration.addSeparateT5(builder, !!p.separate_t5);
if (t5TextOffset)
core_bundle_mjs_1.GenerationConfiguration.addT5Text(builder, t5TextOffset);
if (typeof p.tea_cache_max_skip_steps === "number")
core_bundle_mjs_1.GenerationConfiguration.addTeaCacheMaxSkipSteps(builder, p.tea_cache_max_skip_steps);
if (typeof p.causal_inference === "number")
core_bundle_mjs_1.GenerationConfiguration.addCausalInference(builder, p.causal_inference);
if (typeof p.causal_inference_pad === "number")
core_bundle_mjs_1.GenerationConfiguration.addCausalInferencePad(builder, p.causal_inference_pad);
if (typeof p.cfg_zero_star === "boolean")
core_bundle_mjs_1.GenerationConfiguration.addCfgZeroStar(builder, !!p.cfg_zero_star);
if (typeof p.cfg_zero_init_steps === "number")
core_bundle_mjs_1.GenerationConfiguration.addCfgZeroInitSteps(builder, p.cfg_zero_init_steps);
const caValue = p.compressionArtifacts ?? p.compression_artifacts;
if (typeof caValue === "string") {
const ca = caValue;
const caEnum = ca === "h264" ? core_bundle_mjs_1.CompressionMethod.H264
: ca === "h265" ? core_bundle_mjs_1.CompressionMethod.H265
: ca === "jpeg" ? core_bundle_mjs_1.CompressionMethod.Jpeg
: core_bundle_mjs_1.CompressionMethod.Disabled;
core_bundle_mjs_1.GenerationConfiguration.addCompressionArtifacts(builder, caEnum);
}
const caQualityValue = p.compressionArtifactsQuality ?? p.compression_artifacts_quality;
if (typeof caQualityValue === "number")
core_bundle_mjs_1.GenerationConfiguration.addCompressionArtifactsQuality(builder, caQualityValue);
const root = core_bundle_mjs_1.GenerationConfiguration.endGenerationConfiguration(builder);
core_bundle_mjs_1.GenerationConfiguration.finishGenerationConfigurationBuffer(builder, root);
const bytes = Buffer.from(builder.asUint8Array());
return { view, bytes };
}