pixelkiln 0.98.0 → 0.100.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 +1 -1
- package/dist/cli.js +182 -13
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +151 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +472 -48
- package/dist/index.d.ts +472 -48
- package/dist/index.js +147 -5
- package/dist/index.js.map +1 -1
- package/docs/CLI.md +27 -4
- package/docs/ENDPOINTS.md +58 -4
- package/docs/MANIFEST.md +39 -0
- package/docs/PIXELLAB.md +1 -1
- package/docs/REVISIONS.md +9 -1
- package/package.json +1 -1
- package/schema/manifest.schema.json +52 -0
package/dist/index.js
CHANGED
|
@@ -524,6 +524,24 @@ var RevisionSchema = z.object({
|
|
|
524
524
|
removalTask: z.enum(["simple", "complex"]).optional(),
|
|
525
525
|
/** `normal-map` only: `opengl` (green up; PixelLab's default) or `directx` (green down, for Unreal). */
|
|
526
526
|
convention: NormalMapConventionSchema.optional(),
|
|
527
|
+
/**
|
|
528
|
+
* `normal-map` only: `lite` (PixelLab's default, 0.1 generation) makes the
|
|
529
|
+
* map from the art alone; `pro` (0.5) plans each part's shape, what is in
|
|
530
|
+
* front and what is sunk.
|
|
531
|
+
*/
|
|
532
|
+
normalMapMode: z.enum(["lite", "pro"]).optional(),
|
|
533
|
+
/** `normal-map` only: what the picture is. Left out, PixelLab reads it from the picture; set it for sidescroller, isometric and UI art. */
|
|
534
|
+
normalMapKind: z.enum(["character", "object", "topdown", "side", "iso", "ui"]).optional(),
|
|
535
|
+
/** `normal-map` only: how far every pixel tilts away from facing the viewer, 0 to 2 (the API refuses more). */
|
|
536
|
+
normalMapStrength: z.number().min(0).max(2).optional(),
|
|
537
|
+
/** `normal-map` only: how much the outline rounds off, 0 to 3; 0 keeps it flat to the edge. */
|
|
538
|
+
outlineRounding: z.number().min(0).max(3).optional(),
|
|
539
|
+
/** `normal-map` only: how much the sprite's 3D parts (a round head, an arm) add, 0 to 2. */
|
|
540
|
+
partShapes: z.number().min(0).max(2).optional(),
|
|
541
|
+
/** `normal-map` only: the art's own light and dark as bumps, 0 to 2; 0 for a smooth surface. */
|
|
542
|
+
surfaceDetail: z.number().min(0).max(2).optional(),
|
|
543
|
+
/** `normal-map` only: how far that detail is blurred, 0.6 to 3 px. */
|
|
544
|
+
detailSoftness: z.number().min(0.6).max(3).optional(),
|
|
527
545
|
/**
|
|
528
546
|
* `animate-skeleton`: what the character *looks like*, a noun
|
|
529
547
|
* phrase (colours, clothing, held items) — distinct from the asset's
|
|
@@ -684,6 +702,15 @@ var RevisionSchema = z.object({
|
|
|
684
702
|
path: ["convention"]
|
|
685
703
|
});
|
|
686
704
|
}
|
|
705
|
+
for (const field of ["normalMapMode", "normalMapKind", "normalMapStrength", "outlineRounding", "partShapes", "surfaceDetail", "detailSoftness"]) {
|
|
706
|
+
if (revision[field] !== void 0 && revision.mode !== "normal-map") {
|
|
707
|
+
context.addIssue({
|
|
708
|
+
code: z.ZodIssueCode.custom,
|
|
709
|
+
message: `${field} applies to normal-map revisions only`,
|
|
710
|
+
path: [field]
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
}
|
|
687
714
|
if (revision.description !== void 0 && revision.mode !== "animate-skeleton" && revision.mode !== "remove-background") {
|
|
688
715
|
context.addIssue({
|
|
689
716
|
code: z.ZodIssueCode.custom,
|
|
@@ -1320,6 +1347,17 @@ var AssetSchema = z.object({
|
|
|
1320
1347
|
* (a sword hand, a parted fringe) comes out the other way round.
|
|
1321
1348
|
*/
|
|
1322
1349
|
mirror: z.string().min(1).optional(),
|
|
1350
|
+
/**
|
|
1351
|
+
* `pixflux`, `map` and `isometricTile` styles: a PNG to start the drawing
|
|
1352
|
+
* from, relative to the manifest. PixelLab reworks it toward the prompt
|
|
1353
|
+
* instead of starting from nothing.
|
|
1354
|
+
*/
|
|
1355
|
+
initImage: z.string().min(1).optional(),
|
|
1356
|
+
/**
|
|
1357
|
+
* With `initImage`: how strongly the starting image holds, 1 to 999.
|
|
1358
|
+
* PixelLab's default is 300.
|
|
1359
|
+
*/
|
|
1360
|
+
initImageStrength: z.number().int().min(1).max(999).optional(),
|
|
1323
1361
|
/**
|
|
1324
1362
|
* `terrain` styles only: a PNG per terrain for PixelLab to take that
|
|
1325
1363
|
* terrain's look from, paths relative to the manifest. Top-down sets
|
|
@@ -1383,6 +1421,13 @@ var AssetSchema = z.object({
|
|
|
1383
1421
|
path: [shapes[1]]
|
|
1384
1422
|
});
|
|
1385
1423
|
}
|
|
1424
|
+
if (asset.initImageStrength !== void 0 && !asset.initImage) {
|
|
1425
|
+
context.addIssue({
|
|
1426
|
+
code: z.ZodIssueCode.custom,
|
|
1427
|
+
message: "initImageStrength sets how strongly initImage holds; add an initImage or drop it",
|
|
1428
|
+
path: ["initImageStrength"]
|
|
1429
|
+
});
|
|
1430
|
+
}
|
|
1386
1431
|
for (const shape of ["derive", "external"]) {
|
|
1387
1432
|
if (asset[shape] && (asset.source || Object.keys(asset.sourceByStyle).length)) {
|
|
1388
1433
|
context.addIssue({
|
|
@@ -2394,6 +2439,14 @@ function targetPaletteBody(palette) {
|
|
|
2394
2439
|
}
|
|
2395
2440
|
};
|
|
2396
2441
|
}
|
|
2442
|
+
var NORMAL_MAP_MODES = ["lite", "pro"];
|
|
2443
|
+
var NORMAL_MAP_KINDS = ["character", "object", "topdown", "side", "iso", "ui"];
|
|
2444
|
+
var NORMAL_MAP_SHAPE_RANGES = {
|
|
2445
|
+
outlineRounding: [0, 3],
|
|
2446
|
+
partShapes: [0, 2],
|
|
2447
|
+
surfaceDetail: [0, 2],
|
|
2448
|
+
detailSoftness: [0.6, 3]
|
|
2449
|
+
};
|
|
2397
2450
|
var PixelLabClient = class {
|
|
2398
2451
|
constructor(apiKey, timeoutMs = 12e4) {
|
|
2399
2452
|
this.apiKey = apiKey;
|
|
@@ -2491,6 +2544,10 @@ var PixelLabClient = class {
|
|
|
2491
2544
|
if (args.outline) body.outline = args.outline;
|
|
2492
2545
|
if (args.shading) body.shading = args.shading;
|
|
2493
2546
|
if (args.detail) body.detail = args.detail;
|
|
2547
|
+
if (args.initImage) {
|
|
2548
|
+
body.init_image = { type: "base64", base64: args.initImage.base64, format: args.initImage.format };
|
|
2549
|
+
if (args.initImageStrength != null) body.init_image_strength = args.initImageStrength;
|
|
2550
|
+
}
|
|
2494
2551
|
if (args.seed != null) body.seed = args.seed;
|
|
2495
2552
|
if (args.scene) {
|
|
2496
2553
|
const encode = (image) => ({ type: "base64", base64: image.base64, format: image.format });
|
|
@@ -2659,6 +2716,10 @@ var PixelLabClient = class {
|
|
|
2659
2716
|
if (args.outline) body.outline = args.outline;
|
|
2660
2717
|
if (args.shading) body.shading = args.shading;
|
|
2661
2718
|
if (args.detail) body.detail = args.detail;
|
|
2719
|
+
if (args.initImage) {
|
|
2720
|
+
body.init_image = { type: "base64", base64: args.initImage.base64, format: args.initImage.format };
|
|
2721
|
+
if (args.initImageStrength != null) body.init_image_strength = args.initImageStrength;
|
|
2722
|
+
}
|
|
2662
2723
|
if (args.seed != null) body.seed = args.seed;
|
|
2663
2724
|
return validateResponse(
|
|
2664
2725
|
IsometricTileSubmitSchema,
|
|
@@ -2783,6 +2844,10 @@ var PixelLabClient = class {
|
|
|
2783
2844
|
if (args.paletteSwatchBase64) {
|
|
2784
2845
|
body.color_image = { type: "base64", base64: args.paletteSwatchBase64, format: "png" };
|
|
2785
2846
|
}
|
|
2847
|
+
if (args.initImage) {
|
|
2848
|
+
body.init_image = { type: "base64", base64: args.initImage.base64, format: args.initImage.format };
|
|
2849
|
+
if (args.initImageStrength != null) body.init_image_strength = args.initImageStrength;
|
|
2850
|
+
}
|
|
2786
2851
|
if (args.seed != null) body.seed = args.seed;
|
|
2787
2852
|
const res = validateResponse(
|
|
2788
2853
|
PixfluxResponseSchema,
|
|
@@ -3472,8 +3537,15 @@ var PixelLabClient = class {
|
|
|
3472
3537
|
*/
|
|
3473
3538
|
async normalMap(args) {
|
|
3474
3539
|
const body = { image: args.image };
|
|
3540
|
+
if (args.mode) body.mode = args.mode;
|
|
3541
|
+
if (args.kind) body.kind = args.kind;
|
|
3542
|
+
if (args.shape?.strength != null) body.strength = args.shape.strength;
|
|
3475
3543
|
if (args.frames != null && args.frames !== 1) body.frames = args.frames;
|
|
3476
3544
|
if (args.convention) body.convention = args.convention;
|
|
3545
|
+
if (args.shape?.outlineRounding != null) body.outline_rounding = args.shape.outlineRounding;
|
|
3546
|
+
if (args.shape?.partShapes != null) body.part_shapes = args.shape.partShapes;
|
|
3547
|
+
if (args.shape?.surfaceDetail != null) body.surface_detail = args.shape.surfaceDetail;
|
|
3548
|
+
if (args.shape?.detailSoftness != null) body.detail_softness = args.shape.detailSoftness;
|
|
3477
3549
|
return validateResponse(
|
|
3478
3550
|
RevisionJobSubmitSchema,
|
|
3479
3551
|
await this.request("/normal-map", { method: "POST", body: JSON.stringify(body) }),
|
|
@@ -4599,6 +4671,8 @@ function specHash(spec, styleImageHashes, providerOptionIdentity = spec.provider
|
|
|
4599
4671
|
terrainEnhance: spec.terrainEnhance,
|
|
4600
4672
|
terrainPlatformThickness: spec.terrainPlatformThickness,
|
|
4601
4673
|
// Reference images enter as their bytes' hashes, never their paths.
|
|
4674
|
+
// The starting image by its bytes, with its strength only when set.
|
|
4675
|
+
initImage: spec.initImage ? { sha256: spec.initImage.sha256, strength: spec.initImage.strength } : void 0,
|
|
4602
4676
|
terrainReferences: spec.terrainReferences && Object.keys(spec.terrainReferences).length ? Object.fromEntries(
|
|
4603
4677
|
["lower", "upper", "transition"].flatMap((side) => {
|
|
4604
4678
|
const reference = spec.terrainReferences[side];
|
|
@@ -4737,6 +4811,14 @@ function specHash(spec, styleImageHashes, providerOptionIdentity = spec.provider
|
|
|
4737
4811
|
description: spec.revision.description,
|
|
4738
4812
|
removalTask: spec.revision.removalTask,
|
|
4739
4813
|
convention: spec.revision.convention,
|
|
4814
|
+
// Each only when set, so normal-map revisions made before them keep their hash.
|
|
4815
|
+
normalMapMode: spec.revision.normalMapMode,
|
|
4816
|
+
normalMapKind: spec.revision.normalMapKind,
|
|
4817
|
+
normalMapStrength: spec.revision.normalMapStrength,
|
|
4818
|
+
outlineRounding: spec.revision.outlineRounding,
|
|
4819
|
+
partShapes: spec.revision.partShapes,
|
|
4820
|
+
surfaceDetail: spec.revision.surfaceDetail,
|
|
4821
|
+
detailSoftness: spec.revision.detailSoftness,
|
|
4740
4822
|
driftThreshold: spec.revision.driftThreshold,
|
|
4741
4823
|
subjectDescription: spec.revision.subjectDescription,
|
|
4742
4824
|
initialPose: spec.revision.initialPose,
|
|
@@ -5513,6 +5595,9 @@ async function pixelateFile(client2, input, opts = {}) {
|
|
|
5513
5595
|
await sleep3(interval);
|
|
5514
5596
|
}
|
|
5515
5597
|
}
|
|
5598
|
+
function normalMapCost(mode2) {
|
|
5599
|
+
return mode2 === "pro" ? 0.5 : 0.1;
|
|
5600
|
+
}
|
|
5516
5601
|
var NORMAL_MAP_COST_GENERATIONS = 0.5;
|
|
5517
5602
|
var NORMAL_MAP_MIN_SIDE = 8;
|
|
5518
5603
|
var NORMAL_MAP_MAX_SIDE = 512;
|
|
@@ -5557,7 +5642,10 @@ async function normalMapFile(client2, input, opts = {}) {
|
|
|
5557
5642
|
const submitted = await client2.normalMap({
|
|
5558
5643
|
image: { base64: bytes.toString("base64"), format: "png" },
|
|
5559
5644
|
frames,
|
|
5560
|
-
convention: opts.convention
|
|
5645
|
+
convention: opts.convention,
|
|
5646
|
+
shape: opts.shape,
|
|
5647
|
+
mode: opts.mode,
|
|
5648
|
+
kind: opts.kind
|
|
5561
5649
|
});
|
|
5562
5650
|
const jobId = submitted.background_job_id;
|
|
5563
5651
|
const started = Date.now();
|
|
@@ -5822,7 +5910,7 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
5822
5910
|
return { unit: "generations", amount: 1, candidates: 1 };
|
|
5823
5911
|
}
|
|
5824
5912
|
if (spec.revision?.mode === "normal-map") {
|
|
5825
|
-
return { unit: "generations", amount:
|
|
5913
|
+
return { unit: "generations", amount: normalMapCost(spec.revision.normalMapMode), candidates: 1 };
|
|
5826
5914
|
}
|
|
5827
5915
|
if (spec.revision?.mode === "reduce-colors" || spec.revision?.mode === "correct-pixelart") {
|
|
5828
5916
|
return { unit: "generations", amount: 0.1, candidates: 1 };
|
|
@@ -7026,7 +7114,8 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
7026
7114
|
height: spec.height,
|
|
7027
7115
|
noBackground: spec.noBackground,
|
|
7028
7116
|
paletteSwatchBase64: swatch,
|
|
7029
|
-
seed: spec.seed
|
|
7117
|
+
seed: spec.seed,
|
|
7118
|
+
...await initImageArgs(spec)
|
|
7030
7119
|
});
|
|
7031
7120
|
const jobId = randomUUID();
|
|
7032
7121
|
writeFileSync(path3.join(_PixelLabProvider.cacheDir(), `${jobId}.png`), png);
|
|
@@ -7139,7 +7228,8 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
7139
7228
|
outline: spec.outline,
|
|
7140
7229
|
shading: spec.shading,
|
|
7141
7230
|
detail: spec.detail,
|
|
7142
|
-
seed: spec.seed
|
|
7231
|
+
seed: spec.seed,
|
|
7232
|
+
...await initImageArgs(spec)
|
|
7143
7233
|
});
|
|
7144
7234
|
return { jobId: res2.tile_id, metadata: { backgroundJobId: res2.background_job_id } };
|
|
7145
7235
|
}
|
|
@@ -7183,6 +7273,7 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
7183
7273
|
shading: spec.shading,
|
|
7184
7274
|
detail: spec.detail,
|
|
7185
7275
|
seed: spec.seed,
|
|
7276
|
+
...await initImageArgs(spec),
|
|
7186
7277
|
scene: spec.scene ? mapScenePayload(spec) : void 0
|
|
7187
7278
|
});
|
|
7188
7279
|
return { jobId: res.object_id, metadata: { backgroundJobId: res.background_job_id } };
|
|
@@ -7296,7 +7387,20 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
7296
7387
|
}
|
|
7297
7388
|
if (revision.mode === "normal-map") {
|
|
7298
7389
|
const strip = roles ? { base64: joinStripPng(images.map((member) => Buffer.from(member.base64, "base64"))).toString("base64"), format: "png" } : image;
|
|
7299
|
-
const res2 = await this.client.normalMap({
|
|
7390
|
+
const res2 = await this.client.normalMap({
|
|
7391
|
+
image: strip,
|
|
7392
|
+
frames: roles?.length ?? 1,
|
|
7393
|
+
convention: revision.convention,
|
|
7394
|
+
mode: revision.normalMapMode,
|
|
7395
|
+
kind: revision.normalMapKind,
|
|
7396
|
+
shape: {
|
|
7397
|
+
strength: revision.normalMapStrength,
|
|
7398
|
+
outlineRounding: revision.outlineRounding,
|
|
7399
|
+
partShapes: revision.partShapes,
|
|
7400
|
+
surfaceDetail: revision.surfaceDetail,
|
|
7401
|
+
detailSoftness: revision.detailSoftness
|
|
7402
|
+
}
|
|
7403
|
+
});
|
|
7300
7404
|
return {
|
|
7301
7405
|
jobId: res2.background_job_id,
|
|
7302
7406
|
metadata: roles ? { revisionMembers: roles, ...revision.sourceFps != null ? { revisionFps: revision.sourceFps } : {} } : {}
|
|
@@ -8298,6 +8402,16 @@ function sendsTargetPalette(spec) {
|
|
|
8298
8402
|
return false;
|
|
8299
8403
|
}
|
|
8300
8404
|
}
|
|
8405
|
+
async function initImageArgs(spec) {
|
|
8406
|
+
const init = spec.initImage;
|
|
8407
|
+
if (!init) return {};
|
|
8408
|
+
if (!existsSync3(init.file)) throw new Error(`init image is missing: ${init.file}`);
|
|
8409
|
+
const bytes = readFileSync(init.file);
|
|
8410
|
+
if (sha256(bytes) !== init.sha256) {
|
|
8411
|
+
throw new Error(`init image changed after the manifest was resolved: ${init.file}; run the command again`);
|
|
8412
|
+
}
|
|
8413
|
+
return { initImage: { base64: bytes.toString("base64"), format: "png" }, ...init.strength == null ? {} : { initImageStrength: init.strength } };
|
|
8414
|
+
}
|
|
8301
8415
|
async function terrainReferenceImage(spec, side) {
|
|
8302
8416
|
const reference = spec.terrainReferences?.[side];
|
|
8303
8417
|
if (!reference) return void 0;
|
|
@@ -11955,6 +12069,13 @@ async function resolveSpecs(loaded, filter) {
|
|
|
11955
12069
|
...asset.revision.description ? { description: asset.revision.description } : {},
|
|
11956
12070
|
...asset.revision.removalTask ? { removalTask: asset.revision.removalTask } : {},
|
|
11957
12071
|
...asset.revision.convention ? { convention: asset.revision.convention } : {},
|
|
12072
|
+
...asset.revision.normalMapMode ? { normalMapMode: asset.revision.normalMapMode } : {},
|
|
12073
|
+
...asset.revision.normalMapKind ? { normalMapKind: asset.revision.normalMapKind } : {},
|
|
12074
|
+
...asset.revision.normalMapStrength == null ? {} : { normalMapStrength: asset.revision.normalMapStrength },
|
|
12075
|
+
...asset.revision.outlineRounding == null ? {} : { outlineRounding: asset.revision.outlineRounding },
|
|
12076
|
+
...asset.revision.partShapes == null ? {} : { partShapes: asset.revision.partShapes },
|
|
12077
|
+
...asset.revision.surfaceDetail == null ? {} : { surfaceDetail: asset.revision.surfaceDetail },
|
|
12078
|
+
...asset.revision.detailSoftness == null ? {} : { detailSoftness: asset.revision.detailSoftness },
|
|
11958
12079
|
...asset.revision.driftThreshold == null ? {} : { driftThreshold: asset.revision.driftThreshold },
|
|
11959
12080
|
...asset.revision.subjectDescription ? { subjectDescription: asset.revision.subjectDescription } : {},
|
|
11960
12081
|
...asset.revision.initialPose ? { initialPose: asset.revision.initialPose } : {},
|
|
@@ -12029,6 +12150,23 @@ async function resolveSpecs(loaded, filter) {
|
|
|
12029
12150
|
}
|
|
12030
12151
|
resolved.terrainConnect = links;
|
|
12031
12152
|
}
|
|
12153
|
+
if (asset.initImage) {
|
|
12154
|
+
if (!["pixflux", "map", "isometricTile"].includes(resolved.generator)) {
|
|
12155
|
+
throw new Error(
|
|
12156
|
+
`assets.${assetId}.initImage: a starting image is taken by pixflux, map and isometricTile styles; style "${styleId}" uses "${resolved.generator}"`
|
|
12157
|
+
);
|
|
12158
|
+
}
|
|
12159
|
+
const file = path8.resolve(root, asset.initImage);
|
|
12160
|
+
const image = await optionalRevisionImage(file, "init image", "png");
|
|
12161
|
+
if (!image) throw new Error(`assets.${assetId}.initImage: ${asset.initImage} is missing or not a PNG`);
|
|
12162
|
+
resolved.initImage = {
|
|
12163
|
+
file,
|
|
12164
|
+
sha256: image?.hash ?? null,
|
|
12165
|
+
width: image?.width ?? null,
|
|
12166
|
+
height: image?.height ?? null,
|
|
12167
|
+
...asset.initImageStrength == null ? {} : { strength: asset.initImageStrength }
|
|
12168
|
+
};
|
|
12169
|
+
}
|
|
12032
12170
|
if (asset.terrainReferences) {
|
|
12033
12171
|
if (resolved.generator !== "terrain") {
|
|
12034
12172
|
throw new Error(`assets.${assetId}.terrainReferences: only a terrain set takes terrain references; style "${styleId}" uses "${resolved.generator}"`);
|
|
@@ -23041,9 +23179,12 @@ export {
|
|
|
23041
23179
|
MediaType,
|
|
23042
23180
|
NORMAL_MAP_CONVENTIONS,
|
|
23043
23181
|
NORMAL_MAP_COST_GENERATIONS,
|
|
23182
|
+
NORMAL_MAP_KINDS,
|
|
23044
23183
|
NORMAL_MAP_MAX_FRAMES,
|
|
23045
23184
|
NORMAL_MAP_MAX_SIDE,
|
|
23046
23185
|
NORMAL_MAP_MIN_SIDE,
|
|
23186
|
+
NORMAL_MAP_MODES,
|
|
23187
|
+
NORMAL_MAP_SHAPE_RANGES,
|
|
23047
23188
|
NormalMapConventionSchema,
|
|
23048
23189
|
OverwriteRefusedError,
|
|
23049
23190
|
PIXELATE_COST_GENERATIONS,
|
|
@@ -23211,6 +23352,7 @@ export {
|
|
|
23211
23352
|
mountStyle,
|
|
23212
23353
|
musicCost,
|
|
23213
23354
|
musicOutputPaths,
|
|
23355
|
+
normalMapCost,
|
|
23214
23356
|
normalMapFile,
|
|
23215
23357
|
normalMapResultPng,
|
|
23216
23358
|
normalMapSizeProblem,
|