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/index.js
CHANGED
|
@@ -259,7 +259,15 @@ var CharacterPortraitSizeSchema = z.union([
|
|
|
259
259
|
var CharacterPortraitSchema = z.object({
|
|
260
260
|
/** The base or state to portray, in the same style. */
|
|
261
261
|
of: z.string().min(1),
|
|
262
|
-
size: CharacterPortraitSizeSchema.default(64)
|
|
262
|
+
size: CharacterPortraitSizeSchema.default(64),
|
|
263
|
+
/** PixelLab's seed for this portrait, in place of the style's `seed`. Part of its identity. */
|
|
264
|
+
seed: z.number().int().min(0).optional(),
|
|
265
|
+
/**
|
|
266
|
+
* Attach the drawn portrait to the parent's PixelLab character record, as
|
|
267
|
+
* PixelLab's own app shows it (the default). `false` leaves that record as
|
|
268
|
+
* it is, for a character used elsewhere. Not part of the portrait's identity.
|
|
269
|
+
*/
|
|
270
|
+
attach: z.boolean().optional()
|
|
263
271
|
}).strict();
|
|
264
272
|
var MapScenePlacementSchema = z.union([
|
|
265
273
|
z.object({ oval: z.number().min(0.05).max(0.95) }).strict(),
|
|
@@ -8837,7 +8845,17 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
8837
8845
|
});
|
|
8838
8846
|
return {
|
|
8839
8847
|
jobId: res2.background_job_id,
|
|
8840
|
-
metadata: {
|
|
8848
|
+
metadata: {
|
|
8849
|
+
character: {
|
|
8850
|
+
kind: "portrait",
|
|
8851
|
+
parentCharacterId: parentId,
|
|
8852
|
+
backgroundJobId: res2.background_job_id,
|
|
8853
|
+
// PixelLab expires finished jobs within about a day, so the seed sent is kept here;
|
|
8854
|
+
// poll replaces it with the one the job reports using.
|
|
8855
|
+
...spec.seed != null ? { seed: spec.seed } : {},
|
|
8856
|
+
...character.portrait.attach ? {} : { attach: false }
|
|
8857
|
+
}
|
|
8858
|
+
}
|
|
8841
8859
|
};
|
|
8842
8860
|
}
|
|
8843
8861
|
const animation = character.animation;
|
|
@@ -9011,16 +9029,21 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
9011
9029
|
const job = await this.client.getPortraitCharacterJob(jobId);
|
|
9012
9030
|
if (job.status === "failed") return { status: "failed", error: "portrait generation failed upstream" };
|
|
9013
9031
|
if (job.status !== "completed" || !job.download_url) return { status: "processing" };
|
|
9014
|
-
|
|
9032
|
+
const attach = meta?.parentCharacterId && meta.attach !== false ? meta.parentCharacterId : null;
|
|
9033
|
+
if (attach) {
|
|
9015
9034
|
const bytes = await this.client.download(job.download_url);
|
|
9016
|
-
await this.client.setCharacterPortrait(
|
|
9035
|
+
await this.client.setCharacterPortrait(attach, { base64: bytes.toString("base64"), format: "png" });
|
|
9017
9036
|
}
|
|
9037
|
+
const { billed, lastResponse } = await this.readFinishedJob(meta?.backgroundJobId);
|
|
9038
|
+
const seed = typeof lastResponse?.seed === "number" ? lastResponse.seed : meta?.seed;
|
|
9018
9039
|
return {
|
|
9019
9040
|
status: "ready",
|
|
9020
9041
|
objectId: jobId,
|
|
9021
9042
|
sourceUrl: job.download_url,
|
|
9022
9043
|
sources: [{ url: job.download_url }],
|
|
9023
|
-
billed
|
|
9044
|
+
billed,
|
|
9045
|
+
...seed != null ? { metadata: { character: { ...meta, seed } } } : {},
|
|
9046
|
+
...attach ? { note: `attached to character ${attach} on PixelLab` } : {}
|
|
9024
9047
|
};
|
|
9025
9048
|
} catch (err) {
|
|
9026
9049
|
if (err instanceof PixelLabError && err.status === 423) return { status: "processing" };
|
|
@@ -9748,17 +9771,22 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
9748
9771
|
* known", not a failure worth surfacing.
|
|
9749
9772
|
*/
|
|
9750
9773
|
async billedForJob(backgroundJobId) {
|
|
9751
|
-
|
|
9774
|
+
return (await this.readFinishedJob(backgroundJobId)).billed;
|
|
9775
|
+
}
|
|
9776
|
+
/** A finished background job's bill (see `billedForJob`) and its `last_response`, read once. */
|
|
9777
|
+
async readFinishedJob(backgroundJobId) {
|
|
9778
|
+
if (!backgroundJobId) return { billed: null, lastResponse: null };
|
|
9752
9779
|
try {
|
|
9753
9780
|
const job = await this.client.getBackgroundJob(backgroundJobId);
|
|
9781
|
+
const lastResponse = job.last_response ?? null;
|
|
9754
9782
|
const nested = job.last_response?.billing_usage;
|
|
9755
9783
|
for (const usage of [job.usage, nested]) {
|
|
9756
9784
|
const billed = billedFromUsage(usage);
|
|
9757
|
-
if (billed && !(billed.unit === "usd" && billed.amount === 0)) return billed;
|
|
9785
|
+
if (billed && !(billed.unit === "usd" && billed.amount === 0)) return { billed, lastResponse };
|
|
9758
9786
|
}
|
|
9759
|
-
return null;
|
|
9787
|
+
return { billed: null, lastResponse };
|
|
9760
9788
|
} catch {
|
|
9761
|
-
return null;
|
|
9789
|
+
return { billed: null, lastResponse: null };
|
|
9762
9790
|
}
|
|
9763
9791
|
}
|
|
9764
9792
|
async poll(jobId, generator, context) {
|
|
@@ -13817,7 +13845,8 @@ async function resolveSpecs(loaded, filter) {
|
|
|
13817
13845
|
outline: style.outline,
|
|
13818
13846
|
shading: style.shading,
|
|
13819
13847
|
detail: style.detail,
|
|
13820
|
-
|
|
13848
|
+
// A portrait may pin its own; it reaches the wire and the identity like the style's.
|
|
13849
|
+
seed: asset.portrait?.seed ?? style.seed,
|
|
13821
13850
|
uiPieces: generator === "uiAsset" ? asset.pieces : void 0,
|
|
13822
13851
|
uiElements: generator === "uiAsset" ? asset.elements : void 0,
|
|
13823
13852
|
uiColorPalette: generator === "uiAsset" || generator === "uiElement" ? style.uiColorPalette : void 0,
|
|
@@ -14714,7 +14743,7 @@ async function resolveCharacterShape(asset, style, kind, files) {
|
|
|
14714
14743
|
};
|
|
14715
14744
|
}
|
|
14716
14745
|
if (asset.portrait) {
|
|
14717
|
-
shape.portrait = { size: asset.portrait.size };
|
|
14746
|
+
shape.portrait = { size: asset.portrait.size, attach: asset.portrait.attach ?? true };
|
|
14718
14747
|
}
|
|
14719
14748
|
if (asset.animation) {
|
|
14720
14749
|
const animationMode = asset.animation.mode ?? (asset.animation.template ? "template" : "v3");
|
|
@@ -20064,6 +20093,13 @@ function mountStyle(lock, styleId, manifestDir, mount, cells, sources = {}, outp
|
|
|
20064
20093
|
}
|
|
20065
20094
|
|
|
20066
20095
|
// src/pipeline/connected-sets.ts
|
|
20096
|
+
function unmatchedRoleWarning(label, outputs, terrainTiles) {
|
|
20097
|
+
const roles = new Set(terrainTiles.flatMap((tile) => isRecord2(tile) && typeof tile.role === "string" ? [tile.role] : []));
|
|
20098
|
+
const missing = outputs.flatMap((output) => output.role && !roles.has(output.role) ? [output.role] : []);
|
|
20099
|
+
if (!missing.length) return null;
|
|
20100
|
+
const shown = missing.slice(0, 3).join(", ") + (missing.length > 3 ? `, and ${missing.length - 3} more` : "");
|
|
20101
|
+
return `${label}: ${missing.length} tile(s) have a role that is not in the lock's terrainTiles (${shown}), so their corners were taken by position and may be wrong; regenerate the set if it paints the wrong tiles`;
|
|
20102
|
+
}
|
|
20067
20103
|
var key2 = (spec) => `${spec.styleId}/${spec.assetId}`;
|
|
20068
20104
|
var SIDES = ["lower", "upper"];
|
|
20069
20105
|
function connectedGroup(start, specs) {
|
|
@@ -20174,6 +20210,7 @@ function mergeConnectedTerrain(members, manifestDir) {
|
|
|
20174
20210
|
names[index] = name;
|
|
20175
20211
|
}
|
|
20176
20212
|
const tiles = [];
|
|
20213
|
+
const warnings = [];
|
|
20177
20214
|
const providerRules = {};
|
|
20178
20215
|
for (const { spec, entry } of members) {
|
|
20179
20216
|
const metadata = entry.providerMetadata?.[entry.provider];
|
|
@@ -20188,6 +20225,8 @@ function mergeConnectedTerrain(members, manifestDir) {
|
|
|
20188
20225
|
if (spec.source && sourceIsStem(spec.source, entry, manifestDir)) {
|
|
20189
20226
|
outputs = outputs.map((output) => ({ ...output, absolutePath: sourceOutputPath(spec.source, entry, output.index, manifestDir) }));
|
|
20190
20227
|
}
|
|
20228
|
+
const warning = unmatchedRoleWarning(key2(spec), outputs, terrainTiles);
|
|
20229
|
+
if (warning) warnings.push(warning);
|
|
20191
20230
|
for (const output of outputs) {
|
|
20192
20231
|
const tile = (output.role ? terrainTiles.find((item) => isRecord2(item) && item.role === output.role) : void 0) ?? terrainTiles[output.index];
|
|
20193
20232
|
if (!isRecord2(tile) || !isRecord2(tile.corners)) continue;
|
|
@@ -20205,7 +20244,7 @@ function mergeConnectedTerrain(members, manifestDir) {
|
|
|
20205
20244
|
}
|
|
20206
20245
|
}
|
|
20207
20246
|
if (!tiles.length) throw new Error(`connected sets ${ids.join(", ")} have no tiles with corner data`);
|
|
20208
|
-
return { assets: ids, terrains: names, tiles, tileType: members[0].spec.tileType, providerRules };
|
|
20247
|
+
return { assets: ids, terrains: names, tiles, tileType: members[0].spec.tileType, providerRules, warnings };
|
|
20209
20248
|
}
|
|
20210
20249
|
function tileCorners(rules, tile) {
|
|
20211
20250
|
if (tile.corners) return tile.corners;
|
|
@@ -20748,13 +20787,16 @@ function exportTileset(entry, spec, options) {
|
|
|
20748
20787
|
terrainRules && !normalizeTileRules(rawRules) ? terrainTileIndexes(metadata, outputs) : void 0,
|
|
20749
20788
|
spec.tileType === "isometric" ? isometricFootprint(packed.png, frames) : null
|
|
20750
20789
|
);
|
|
20790
|
+
const roleWarning = terrainRules && !normalizeTileRules(rawRules) && isRecord3(metadata) && Array.isArray(metadata.terrainTiles) ? unmatchedRoleWarning(`${spec.styleId}/${spec.assetId}`, outputs, metadata.terrainTiles) : null;
|
|
20791
|
+
const warnings = roleWarning ? [roleWarning] : [];
|
|
20751
20792
|
if (options.format === "generic") {
|
|
20752
20793
|
return {
|
|
20753
20794
|
png: packed.png,
|
|
20754
20795
|
extension: ".json",
|
|
20755
20796
|
document: JSON.stringify(generic, null, 2) + "\n",
|
|
20756
20797
|
generic,
|
|
20757
|
-
sources: packed.sources
|
|
20798
|
+
sources: packed.sources,
|
|
20799
|
+
warnings
|
|
20758
20800
|
};
|
|
20759
20801
|
}
|
|
20760
20802
|
assertUniformTiles(generic);
|
|
@@ -20778,7 +20820,7 @@ function exportTileset(entry, spec, options) {
|
|
|
20778
20820
|
"godot export does not yet map edge/side adjacency onto an oblique tile's diagonal peering bits safely; use --format generic or --format tiled"
|
|
20779
20821
|
);
|
|
20780
20822
|
}
|
|
20781
|
-
return renderTileset(generic, packed, spec.tileType, options);
|
|
20823
|
+
return { ...renderTileset(generic, packed, spec.tileType, options), warnings };
|
|
20782
20824
|
}
|
|
20783
20825
|
function terrainTileIndexes(metadata, outputs) {
|
|
20784
20826
|
const tiles = isRecord3(metadata) && Array.isArray(metadata.terrainTiles) ? metadata.terrainTiles : [];
|
|
@@ -20852,11 +20894,12 @@ function exportMergedTilesets(members, options) {
|
|
|
20852
20894
|
extension: ".json",
|
|
20853
20895
|
document: JSON.stringify(generic, null, 2) + "\n",
|
|
20854
20896
|
generic,
|
|
20855
|
-
sources: packed.sources
|
|
20897
|
+
sources: packed.sources,
|
|
20898
|
+
warnings: merged.warnings
|
|
20856
20899
|
};
|
|
20857
20900
|
}
|
|
20858
20901
|
assertUniformTiles(generic);
|
|
20859
|
-
return renderTileset(generic, packed, merged.tileType, options);
|
|
20902
|
+
return { ...renderTileset(generic, packed, merged.tileType, options), warnings: merged.warnings };
|
|
20860
20903
|
}
|
|
20861
20904
|
function isometricFootprint(png, frames) {
|
|
20862
20905
|
const image = decodePng(png);
|
|
@@ -21655,7 +21698,7 @@ async function poll(provider, lock, lockPath, opts = {}) {
|
|
|
21655
21698
|
billed: state.billed ?? entry.billed
|
|
21656
21699
|
});
|
|
21657
21700
|
result.completed++;
|
|
21658
|
-
log(` ready ${key3}`);
|
|
21701
|
+
log(` ready ${key3}${state.note ? ` (${state.note})` : ""}`);
|
|
21659
21702
|
} else if (state.status === "failed") {
|
|
21660
21703
|
upsert(lock, key3, { status: "failed", error: state.error });
|
|
21661
21704
|
result.failed++;
|