pixelkiln 0.119.0 → 0.121.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/dist/cli.js +61 -17
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +60 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +396 -258
- package/dist/index.d.ts +396 -258
- package/dist/index.js +60 -17
- package/dist/index.js.map +1 -1
- package/docs/CHARACTERS.md +36 -7
- package/docs/ENDPOINTS.md +20 -7
- package/docs/MANIFEST.md +1 -1
- package/docs/TILES.md +14 -4
- package/package.json +1 -1
- package/schema/manifest.schema.json +7 -0
- package/skills/pixelkiln/references/pixellab.md +16 -1
- package/skills/pixelkiln/references/tiles.md +8 -2
package/dist/cli.js
CHANGED
|
@@ -2010,7 +2010,15 @@ var CharacterPortraitSizeSchema = z.union([
|
|
|
2010
2010
|
var CharacterPortraitSchema = z.object({
|
|
2011
2011
|
/** The base or state to portray, in the same style. */
|
|
2012
2012
|
of: z.string().min(1),
|
|
2013
|
-
size: CharacterPortraitSizeSchema.default(64)
|
|
2013
|
+
size: CharacterPortraitSizeSchema.default(64),
|
|
2014
|
+
/** PixelLab's seed for this portrait, in place of the style's `seed`. Part of its identity. */
|
|
2015
|
+
seed: z.number().int().min(0).optional(),
|
|
2016
|
+
/**
|
|
2017
|
+
* Attach the drawn portrait to the parent's PixelLab character record, as
|
|
2018
|
+
* PixelLab's own app shows it (the default). `false` leaves that record as
|
|
2019
|
+
* it is, for a character used elsewhere. Not part of the portrait's identity.
|
|
2020
|
+
*/
|
|
2021
|
+
attach: z.boolean().optional()
|
|
2014
2022
|
}).strict();
|
|
2015
2023
|
var MapScenePlacementSchema = z.union([
|
|
2016
2024
|
z.object({ oval: z.number().min(0.05).max(0.95) }).strict(),
|
|
@@ -13042,7 +13050,17 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
13042
13050
|
});
|
|
13043
13051
|
return {
|
|
13044
13052
|
jobId: res2.background_job_id,
|
|
13045
|
-
metadata: {
|
|
13053
|
+
metadata: {
|
|
13054
|
+
character: {
|
|
13055
|
+
kind: "portrait",
|
|
13056
|
+
parentCharacterId: parentId,
|
|
13057
|
+
backgroundJobId: res2.background_job_id,
|
|
13058
|
+
// PixelLab expires finished jobs within about a day, so the seed sent is kept here;
|
|
13059
|
+
// poll replaces it with the one the job reports using.
|
|
13060
|
+
...spec.seed != null ? { seed: spec.seed } : {},
|
|
13061
|
+
...character.portrait.attach ? {} : { attach: false }
|
|
13062
|
+
}
|
|
13063
|
+
}
|
|
13046
13064
|
};
|
|
13047
13065
|
}
|
|
13048
13066
|
const animation = character.animation;
|
|
@@ -13216,16 +13234,21 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
13216
13234
|
const job = await this.client.getPortraitCharacterJob(jobId);
|
|
13217
13235
|
if (job.status === "failed") return { status: "failed", error: "portrait generation failed upstream" };
|
|
13218
13236
|
if (job.status !== "completed" || !job.download_url) return { status: "processing" };
|
|
13219
|
-
|
|
13237
|
+
const attach = meta?.parentCharacterId && meta.attach !== false ? meta.parentCharacterId : null;
|
|
13238
|
+
if (attach) {
|
|
13220
13239
|
const bytes = await this.client.download(job.download_url);
|
|
13221
|
-
await this.client.setCharacterPortrait(
|
|
13240
|
+
await this.client.setCharacterPortrait(attach, { base64: bytes.toString("base64"), format: "png" });
|
|
13222
13241
|
}
|
|
13242
|
+
const { billed, lastResponse } = await this.readFinishedJob(meta?.backgroundJobId);
|
|
13243
|
+
const seed = typeof lastResponse?.seed === "number" ? lastResponse.seed : meta?.seed;
|
|
13223
13244
|
return {
|
|
13224
13245
|
status: "ready",
|
|
13225
13246
|
objectId: jobId,
|
|
13226
13247
|
sourceUrl: job.download_url,
|
|
13227
13248
|
sources: [{ url: job.download_url }],
|
|
13228
|
-
billed
|
|
13249
|
+
billed,
|
|
13250
|
+
...seed != null ? { metadata: { character: { ...meta, seed } } } : {},
|
|
13251
|
+
...attach ? { note: `attached to character ${attach} on PixelLab` } : {}
|
|
13229
13252
|
};
|
|
13230
13253
|
} catch (err) {
|
|
13231
13254
|
if (err instanceof PixelLabError && err.status === 423) return { status: "processing" };
|
|
@@ -13953,17 +13976,22 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
13953
13976
|
* known", not a failure worth surfacing.
|
|
13954
13977
|
*/
|
|
13955
13978
|
async billedForJob(backgroundJobId) {
|
|
13956
|
-
|
|
13979
|
+
return (await this.readFinishedJob(backgroundJobId)).billed;
|
|
13980
|
+
}
|
|
13981
|
+
/** A finished background job's bill (see `billedForJob`) and its `last_response`, read once. */
|
|
13982
|
+
async readFinishedJob(backgroundJobId) {
|
|
13983
|
+
if (!backgroundJobId) return { billed: null, lastResponse: null };
|
|
13957
13984
|
try {
|
|
13958
13985
|
const job = await this.client.getBackgroundJob(backgroundJobId);
|
|
13986
|
+
const lastResponse = job.last_response ?? null;
|
|
13959
13987
|
const nested = job.last_response?.billing_usage;
|
|
13960
13988
|
for (const usage2 of [job.usage, nested]) {
|
|
13961
13989
|
const billed = billedFromUsage(usage2);
|
|
13962
|
-
if (billed && !(billed.unit === "usd" && billed.amount === 0)) return billed;
|
|
13990
|
+
if (billed && !(billed.unit === "usd" && billed.amount === 0)) return { billed, lastResponse };
|
|
13963
13991
|
}
|
|
13964
|
-
return null;
|
|
13992
|
+
return { billed: null, lastResponse };
|
|
13965
13993
|
} catch {
|
|
13966
|
-
return null;
|
|
13994
|
+
return { billed: null, lastResponse: null };
|
|
13967
13995
|
}
|
|
13968
13996
|
}
|
|
13969
13997
|
async poll(jobId, generator, context) {
|
|
@@ -16693,7 +16721,8 @@ async function resolveSpecs(loaded, filter) {
|
|
|
16693
16721
|
outline: style.outline,
|
|
16694
16722
|
shading: style.shading,
|
|
16695
16723
|
detail: style.detail,
|
|
16696
|
-
|
|
16724
|
+
// A portrait may pin its own; it reaches the wire and the identity like the style's.
|
|
16725
|
+
seed: asset.portrait?.seed ?? style.seed,
|
|
16697
16726
|
uiPieces: generator === "uiAsset" ? asset.pieces : void 0,
|
|
16698
16727
|
uiElements: generator === "uiAsset" ? asset.elements : void 0,
|
|
16699
16728
|
uiColorPalette: generator === "uiAsset" || generator === "uiElement" ? style.uiColorPalette : void 0,
|
|
@@ -17587,7 +17616,7 @@ async function resolveCharacterShape(asset, style, kind, files) {
|
|
|
17587
17616
|
};
|
|
17588
17617
|
}
|
|
17589
17618
|
if (asset.portrait) {
|
|
17590
|
-
shape.portrait = { size: asset.portrait.size };
|
|
17619
|
+
shape.portrait = { size: asset.portrait.size, attach: asset.portrait.attach ?? true };
|
|
17591
17620
|
}
|
|
17592
17621
|
if (asset.animation) {
|
|
17593
17622
|
const animationMode = asset.animation.mode ?? (asset.animation.template ? "template" : "v3");
|
|
@@ -25628,7 +25657,7 @@ async function poll(provider, lock, lockPath, opts = {}) {
|
|
|
25628
25657
|
billed: state.billed ?? entry.billed
|
|
25629
25658
|
});
|
|
25630
25659
|
result.completed++;
|
|
25631
|
-
log2(` ready ${key3}`);
|
|
25660
|
+
log2(` ready ${key3}${state.note ? ` (${state.note})` : ""}`);
|
|
25632
25661
|
} else if (state.status === "failed") {
|
|
25633
25662
|
upsert(lock, key3, { status: "failed", error: state.error });
|
|
25634
25663
|
result.failed++;
|
|
@@ -29078,6 +29107,13 @@ function mountStyle(lock, styleId, manifestDir, mount, cells, sources = {}, outp
|
|
|
29078
29107
|
}
|
|
29079
29108
|
|
|
29080
29109
|
// src/pipeline/connected-sets.ts
|
|
29110
|
+
function unmatchedRoleWarning(label, outputs, terrainTiles) {
|
|
29111
|
+
const roles = new Set(terrainTiles.flatMap((tile) => isRecord2(tile) && typeof tile.role === "string" ? [tile.role] : []));
|
|
29112
|
+
const missing = outputs.flatMap((output) => output.role && !roles.has(output.role) ? [output.role] : []);
|
|
29113
|
+
if (!missing.length) return null;
|
|
29114
|
+
const shown2 = missing.slice(0, 3).join(", ") + (missing.length > 3 ? `, and ${missing.length - 3} more` : "");
|
|
29115
|
+
return `${label}: ${missing.length} tile(s) have a role that is not in the lock's terrainTiles (${shown2}), so their corners were taken by position and may be wrong; regenerate the set if it paints the wrong tiles`;
|
|
29116
|
+
}
|
|
29081
29117
|
var key2 = (spec) => `${spec.styleId}/${spec.assetId}`;
|
|
29082
29118
|
var SIDES = ["lower", "upper"];
|
|
29083
29119
|
function connectedGroup(start, specs) {
|
|
@@ -29188,6 +29224,7 @@ function mergeConnectedTerrain(members, manifestDir) {
|
|
|
29188
29224
|
names[index] = name;
|
|
29189
29225
|
}
|
|
29190
29226
|
const tiles = [];
|
|
29227
|
+
const warnings = [];
|
|
29191
29228
|
const providerRules = {};
|
|
29192
29229
|
for (const { spec, entry } of members) {
|
|
29193
29230
|
const metadata = entry.providerMetadata?.[entry.provider];
|
|
@@ -29202,6 +29239,8 @@ function mergeConnectedTerrain(members, manifestDir) {
|
|
|
29202
29239
|
if (spec.source && sourceIsStem(spec.source, entry, manifestDir)) {
|
|
29203
29240
|
outputs = outputs.map((output) => ({ ...output, absolutePath: sourceOutputPath(spec.source, entry, output.index, manifestDir) }));
|
|
29204
29241
|
}
|
|
29242
|
+
const warning = unmatchedRoleWarning(key2(spec), outputs, terrainTiles);
|
|
29243
|
+
if (warning) warnings.push(warning);
|
|
29205
29244
|
for (const output of outputs) {
|
|
29206
29245
|
const tile = (output.role ? terrainTiles.find((item) => isRecord2(item) && item.role === output.role) : void 0) ?? terrainTiles[output.index];
|
|
29207
29246
|
if (!isRecord2(tile) || !isRecord2(tile.corners)) continue;
|
|
@@ -29219,7 +29258,7 @@ function mergeConnectedTerrain(members, manifestDir) {
|
|
|
29219
29258
|
}
|
|
29220
29259
|
}
|
|
29221
29260
|
if (!tiles.length) throw new Error(`connected sets ${ids.join(", ")} have no tiles with corner data`);
|
|
29222
|
-
return { assets: ids, terrains: names, tiles, tileType: members[0].spec.tileType, providerRules };
|
|
29261
|
+
return { assets: ids, terrains: names, tiles, tileType: members[0].spec.tileType, providerRules, warnings };
|
|
29223
29262
|
}
|
|
29224
29263
|
function tileCorners(rules, tile) {
|
|
29225
29264
|
if (tile.corners) return tile.corners;
|
|
@@ -29762,13 +29801,16 @@ function exportTileset(entry, spec, options) {
|
|
|
29762
29801
|
terrainRules && !normalizeTileRules(rawRules) ? terrainTileIndexes(metadata, outputs) : void 0,
|
|
29763
29802
|
spec.tileType === "isometric" ? isometricFootprint(packed.png, frames) : null
|
|
29764
29803
|
);
|
|
29804
|
+
const roleWarning = terrainRules && !normalizeTileRules(rawRules) && isRecord3(metadata) && Array.isArray(metadata.terrainTiles) ? unmatchedRoleWarning(`${spec.styleId}/${spec.assetId}`, outputs, metadata.terrainTiles) : null;
|
|
29805
|
+
const warnings = roleWarning ? [roleWarning] : [];
|
|
29765
29806
|
if (options.format === "generic") {
|
|
29766
29807
|
return {
|
|
29767
29808
|
png: packed.png,
|
|
29768
29809
|
extension: ".json",
|
|
29769
29810
|
document: JSON.stringify(generic, null, 2) + "\n",
|
|
29770
29811
|
generic,
|
|
29771
|
-
sources: packed.sources
|
|
29812
|
+
sources: packed.sources,
|
|
29813
|
+
warnings
|
|
29772
29814
|
};
|
|
29773
29815
|
}
|
|
29774
29816
|
assertUniformTiles(generic);
|
|
@@ -29792,7 +29834,7 @@ function exportTileset(entry, spec, options) {
|
|
|
29792
29834
|
"godot export does not yet map edge/side adjacency onto an oblique tile's diagonal peering bits safely; use --format generic or --format tiled"
|
|
29793
29835
|
);
|
|
29794
29836
|
}
|
|
29795
|
-
return renderTileset(generic, packed, spec.tileType, options);
|
|
29837
|
+
return { ...renderTileset(generic, packed, spec.tileType, options), warnings };
|
|
29796
29838
|
}
|
|
29797
29839
|
function terrainTileIndexes(metadata, outputs) {
|
|
29798
29840
|
const tiles = isRecord3(metadata) && Array.isArray(metadata.terrainTiles) ? metadata.terrainTiles : [];
|
|
@@ -29866,11 +29908,12 @@ function exportMergedTilesets(members, options) {
|
|
|
29866
29908
|
extension: ".json",
|
|
29867
29909
|
document: JSON.stringify(generic, null, 2) + "\n",
|
|
29868
29910
|
generic,
|
|
29869
|
-
sources: packed.sources
|
|
29911
|
+
sources: packed.sources,
|
|
29912
|
+
warnings: merged.warnings
|
|
29870
29913
|
};
|
|
29871
29914
|
}
|
|
29872
29915
|
assertUniformTiles(generic);
|
|
29873
|
-
return renderTileset(generic, packed, merged.tileType, options);
|
|
29916
|
+
return { ...renderTileset(generic, packed, merged.tileType, options), warnings: merged.warnings };
|
|
29874
29917
|
}
|
|
29875
29918
|
function isometricFootprint(png, frames) {
|
|
29876
29919
|
const image = decodePng(png);
|
|
@@ -30474,6 +30517,7 @@ async function runExport(args) {
|
|
|
30474
30517
|
log(
|
|
30475
30518
|
` ${path53.relative(process.cwd(), base)}.png + ${path53.basename(base)}${result.extension} + .pixelkiln.json`
|
|
30476
30519
|
);
|
|
30520
|
+
for (const warning of result.warnings) log(` warning: ${warning}`);
|
|
30477
30521
|
}
|
|
30478
30522
|
}
|
|
30479
30523
|
function sheetFormat(args) {
|