pixelkiln 0.100.0 → 0.102.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 +1166 -191
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +517 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +946 -59
- package/dist/index.d.ts +946 -59
- package/dist/index.js +510 -27
- package/dist/index.js.map +1 -1
- package/docs/CLI.md +147 -8
- package/docs/ENDPOINTS.md +175 -8
- package/docs/GENERATORS.md +32 -2
- package/docs/MANIFEST.md +6 -1
- package/package.json +1 -1
- package/schema/manifest.schema.json +62 -0
- package/schema/recipe.schema.json +26 -0
- package/skills/pixelkiln/references/pixellab.md +11 -3
package/dist/index.cjs
CHANGED
|
@@ -76,6 +76,9 @@ __export(index_exports, {
|
|
|
76
76
|
HISTORY_ENV: () => HISTORY_ENV,
|
|
77
77
|
HandEditCompanionSchema: () => HandEditCompanionSchema,
|
|
78
78
|
IMPORT_MAX_SIDE: () => IMPORT_MAX_SIDE,
|
|
79
|
+
IMPORT_MAX_TILES: () => IMPORT_MAX_TILES,
|
|
80
|
+
IMPORT_TILE_TYPES: () => IMPORT_TILE_TYPES,
|
|
81
|
+
IMPORT_TILE_VIEWS: () => IMPORT_TILE_VIEWS,
|
|
79
82
|
ImageQualityMetricsSchema: () => ImageQualityMetricsSchema,
|
|
80
83
|
InheritedStyleSchema: () => InheritedStyleSchema,
|
|
81
84
|
LockEntrySchema: () => LockEntrySchema,
|
|
@@ -144,6 +147,7 @@ __export(index_exports, {
|
|
|
144
147
|
StyleInputSchema: () => StyleInputSchema,
|
|
145
148
|
StyleSchema: () => StyleSchema,
|
|
146
149
|
TARGET_PALETTE_GENERATORS: () => TARGET_PALETTE_GENERATORS,
|
|
150
|
+
TILESET_MODES: () => TILESET_MODES,
|
|
147
151
|
TerrainConnectSchema: () => TerrainConnectSchema,
|
|
148
152
|
TerrainLinkSchema: () => TerrainLinkSchema,
|
|
149
153
|
TerrainSideSchema: () => TerrainSideSchema,
|
|
@@ -158,7 +162,10 @@ __export(index_exports, {
|
|
|
158
162
|
UnsupportedCapabilityError: () => UnsupportedCapabilityError,
|
|
159
163
|
UsageError: () => UsageError,
|
|
160
164
|
VFX_ARTISTS: () => VFX_ARTISTS,
|
|
165
|
+
VFX_ARTIST_ANIMATED_EXTRA: () => VFX_ARTIST_ANIMATED_EXTRA,
|
|
166
|
+
VFX_ARTIST_MAX_FRAMES: () => VFX_ARTIST_MAX_FRAMES,
|
|
161
167
|
VFX_ARTIST_MAX_SPRITE: () => VFX_ARTIST_MAX_SPRITE,
|
|
168
|
+
VFX_ARTIST_MAX_STRIP: () => VFX_ARTIST_MAX_STRIP,
|
|
162
169
|
VFX_TOOL: () => VFX_TOOL,
|
|
163
170
|
VfxPartSchema: () => VfxPartSchema,
|
|
164
171
|
WorkspaceProjectSchema: () => WorkspaceProjectSchema,
|
|
@@ -183,7 +190,9 @@ __export(index_exports, {
|
|
|
183
190
|
checkExportBytes: () => checkExportBytes,
|
|
184
191
|
checkQualityBaseline: () => checkQualityBaseline,
|
|
185
192
|
checkQualityRecord: () => checkQualityRecord,
|
|
193
|
+
checkSaveTarget: () => checkSaveTarget,
|
|
186
194
|
checkUiInsets: () => checkUiInsets,
|
|
195
|
+
chooseTilesetSheetReading: () => chooseTilesetSheetReading,
|
|
187
196
|
clientFromEnv: () => clientFromEnv,
|
|
188
197
|
colorDistance: () => colorDistance,
|
|
189
198
|
countNumberedDescriptions: () => countNumberedDescriptions,
|
|
@@ -232,6 +241,7 @@ __export(index_exports, {
|
|
|
232
241
|
generateMusic: () => generateMusic,
|
|
233
242
|
generateSoundEffect: () => generateSoundEffect,
|
|
234
243
|
generationCost: () => generationCost,
|
|
244
|
+
gifSize: () => gifSize,
|
|
235
245
|
groupOrphansByStyle: () => groupOrphansByStyle,
|
|
236
246
|
handEditBase: () => handEditBase,
|
|
237
247
|
handEditBases: () => handEditBases,
|
|
@@ -246,6 +256,9 @@ __export(index_exports, {
|
|
|
246
256
|
imageMetadata: () => imageMetadata,
|
|
247
257
|
importLocal: () => importLocal,
|
|
248
258
|
importObjectFile: () => importObjectFile,
|
|
259
|
+
importTileHeights: () => importTileHeights,
|
|
260
|
+
importTilesFiles: () => importTilesFiles,
|
|
261
|
+
importTilesetFile: () => importTilesetFile,
|
|
249
262
|
inspectCaches: () => inspectCaches,
|
|
250
263
|
inspectQualityProfile: () => inspectQualityProfile,
|
|
251
264
|
inspectRevisionReadiness: () => inspectRevisionReadiness,
|
|
@@ -312,6 +325,7 @@ __export(index_exports, {
|
|
|
312
325
|
pickHistory: () => pickHistory,
|
|
313
326
|
pixMiniMaxCost: () => pixMiniMaxCost,
|
|
314
327
|
pixelateFile: () => pixelateFile,
|
|
328
|
+
pngFilesAt: () => pngFilesAt,
|
|
315
329
|
pngSize: () => pngSize,
|
|
316
330
|
poll: () => poll,
|
|
317
331
|
portableOutputPath: () => portableOutputPath,
|
|
@@ -376,6 +390,8 @@ __export(index_exports, {
|
|
|
376
390
|
runVfxWorkbench: () => runVfxWorkbench,
|
|
377
391
|
saveHandEdit: () => saveHandEdit,
|
|
378
392
|
saveLock: () => saveLock,
|
|
393
|
+
saveToAssetFile: () => saveToAssetFile,
|
|
394
|
+
saveUndoDir: () => saveUndoDir,
|
|
379
395
|
saveWorkspace: () => saveWorkspace,
|
|
380
396
|
scanAssets: () => scanAssets,
|
|
381
397
|
selectEntryOutput: () => selectEntryOutput,
|
|
@@ -406,6 +422,7 @@ __export(index_exports, {
|
|
|
406
422
|
tileFeatureOutputCount: () => tileFeatureOutputCount,
|
|
407
423
|
tileVariationCount: () => tileVariationCount,
|
|
408
424
|
tilesCost: () => tilesCost,
|
|
425
|
+
tilesetSheetReadings: () => tilesetSheetReadings,
|
|
409
426
|
toPortablePath: () => toPortablePath,
|
|
410
427
|
totalSpend: () => totalSpend,
|
|
411
428
|
uiElementCandidateCount: () => uiElementCandidateCount,
|
|
@@ -421,6 +438,7 @@ __export(index_exports, {
|
|
|
421
438
|
vfxArtistCeiling: () => vfxArtistCeiling,
|
|
422
439
|
vfxArtistFiles: () => vfxArtistFiles,
|
|
423
440
|
vfxArtistFrameFacts: () => vfxArtistFrameFacts,
|
|
441
|
+
vfxArtistFrameSide: () => vfxArtistFrameSide,
|
|
424
442
|
vfxArtistQuote: () => vfxArtistQuote,
|
|
425
443
|
vfxArtistSprite: () => vfxArtistSprite,
|
|
426
444
|
vfxAtlasFrames: () => vfxAtlasFrames,
|
|
@@ -721,8 +739,21 @@ var AssetVfxSchema = import_zod.z.object({
|
|
|
721
739
|
fps: import_zod.z.number().int().min(1).max(60).optional(),
|
|
722
740
|
name: import_zod.z.string().min(1).optional(),
|
|
723
741
|
description: import_zod.z.string().trim().min(1).max(8e3).optional(),
|
|
724
|
-
artist: import_zod.z.enum(["lite", "pro"]).optional()
|
|
742
|
+
artist: import_zod.z.enum(["lite", "pro"]).optional(),
|
|
743
|
+
spriteFrames: import_zod.z.number().int().min(1).max(32).optional(),
|
|
744
|
+
spriteFps: import_zod.z.number().int().min(1).max(60).optional()
|
|
725
745
|
}).strict().superRefine((vfx, context) => {
|
|
746
|
+
for (const key2 of ["spriteFrames", "spriteFps"]) {
|
|
747
|
+
if (vfx[key2] === void 0) continue;
|
|
748
|
+
if (vfx.description === void 0) {
|
|
749
|
+
context.addIssue({ code: import_zod.z.ZodIssueCode.custom, message: `${key2} describes the sprite sent to PixelLab's VFX artist; add a description`, path: [key2] });
|
|
750
|
+
} else if (!vfx.sprite) {
|
|
751
|
+
context.addIssue({ code: import_zod.z.ZodIssueCode.custom, message: `${key2} describes a sprite strip; add a sprite`, path: [key2] });
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
if (vfx.spriteFps !== void 0 && vfx.sprite && vfx.description !== void 0 && (vfx.spriteFrames ?? 1) < 2) {
|
|
755
|
+
context.addIssue({ code: import_zod.z.ZodIssueCode.custom, message: "spriteFps is the speed of a sprite strip; set spriteFrames to 2 or more", path: ["spriteFps"] });
|
|
756
|
+
}
|
|
726
757
|
if (vfx.description !== void 0) {
|
|
727
758
|
for (const key2 of ["preset", "recipe", "parts", "fps"]) {
|
|
728
759
|
if (vfx[key2] !== void 0) {
|
|
@@ -1260,6 +1291,33 @@ var StyleObjectSchema = import_zod.z.object({
|
|
|
1260
1291
|
* Wall storey height as its own camera angle in degrees (5-90),
|
|
1261
1292
|
* decoupled from the ground's pitch. */
|
|
1262
1293
|
buildingWallAngle: import_zod.z.number().min(5).max(90).optional(),
|
|
1294
|
+
/**
|
|
1295
|
+
* `tileFeature: "building"` with `buildingLayout: "materials"` only. The
|
|
1296
|
+
* shape of the roof pieces' edges: `gable` (a straight slope, the API
|
|
1297
|
+
* default) or `round` (curved).
|
|
1298
|
+
*/
|
|
1299
|
+
buildingRoofProfile: import_zod.z.enum(["gable", "round"]).optional(),
|
|
1300
|
+
/**
|
|
1301
|
+
* `tileFeature: "tileset"` on square_topdown, isometric or oblique tiles.
|
|
1302
|
+
* Terrain height in pixels, 0 to 12: raises the first terrain into a
|
|
1303
|
+
* plateau with a cliff face down to the second. The API refuses a height
|
|
1304
|
+
* that does not fit the tile's top face and wall at its size and view.
|
|
1305
|
+
*/
|
|
1306
|
+
tileElevation: import_zod.z.number().int().min(0).max(12).optional(),
|
|
1307
|
+
/**
|
|
1308
|
+
* `tileFeature: "tileset"` with `tileElevation` above 0. How far the drop
|
|
1309
|
+
* spreads sideways: 0 a cliff straight down (the default) to 2 a gentle
|
|
1310
|
+
* slope.
|
|
1311
|
+
*/
|
|
1312
|
+
tileStepSlope: import_zod.z.number().min(0).max(2).optional(),
|
|
1313
|
+
/**
|
|
1314
|
+
* `tileFeature: "tileset"` only. How far the border between the terrains
|
|
1315
|
+
* meanders instead of running straight, 0 (the default) to 0.3. Tiles
|
|
1316
|
+
* still connect seamlessly.
|
|
1317
|
+
*/
|
|
1318
|
+
tileBoundaryAmplitude: import_zod.z.number().min(0).max(0.3).optional(),
|
|
1319
|
+
/** `tileFeature: "tileset"` with `tileBoundaryAmplitude`. Which meander: another number gives a different border. */
|
|
1320
|
+
tileBoundarySeed: import_zod.z.number().int().min(0).optional(),
|
|
1263
1321
|
/**
|
|
1264
1322
|
* `tiles` generator only. How tile edges are drawn.
|
|
1265
1323
|
*
|
|
@@ -2523,6 +2581,53 @@ var ImportObjectSchema = import_zod3.z.object({
|
|
|
2523
2581
|
size: import_zod3.z.object({ width: import_zod3.z.number(), height: import_zod3.z.number() }).passthrough(),
|
|
2524
2582
|
image_url: import_zod3.z.string()
|
|
2525
2583
|
}).passthrough();
|
|
2584
|
+
var ImportTilesetSchema = import_zod3.z.object({ tileset_id: import_zod3.z.string().min(1), status: import_zod3.z.string().default("completed") }).passthrough();
|
|
2585
|
+
var ImportTilesProSchema = import_zod3.z.object({ tile_id: import_zod3.z.string().min(1), status: import_zod3.z.string().default("completed") }).passthrough();
|
|
2586
|
+
var SaveToAssetSchema = import_zod3.z.object({
|
|
2587
|
+
action: import_zod3.z.enum(["saved", "added", "unchanged"]),
|
|
2588
|
+
target: import_zod3.z.string().min(1),
|
|
2589
|
+
kind: import_zod3.z.string(),
|
|
2590
|
+
width: import_zod3.z.number(),
|
|
2591
|
+
height: import_zod3.z.number(),
|
|
2592
|
+
frame_count: import_zod3.z.number(),
|
|
2593
|
+
changed_pixels: import_zod3.z.number().default(0),
|
|
2594
|
+
previous_frames: import_zod3.z.array(import_zod3.z.object({ base64: import_zod3.z.string().min(1) }).passthrough()).nullable().optional(),
|
|
2595
|
+
note: import_zod3.z.string().nullable().optional(),
|
|
2596
|
+
maps: import_zod3.z.string().nullable().optional()
|
|
2597
|
+
}).passthrough();
|
|
2598
|
+
var VocalAnimationSubmitSchema = import_zod3.z.object({ background_job_id: import_zod3.z.string().min(1), status: import_zod3.z.string().default("processing") }).passthrough();
|
|
2599
|
+
var VocalAnimationJobSchema = import_zod3.z.object({
|
|
2600
|
+
status: import_zod3.z.string(),
|
|
2601
|
+
mood: import_zod3.z.string().optional(),
|
|
2602
|
+
viseme_count: import_zod3.z.number().optional(),
|
|
2603
|
+
character_id: import_zod3.z.string().nullable().optional(),
|
|
2604
|
+
completed_visemes: import_zod3.z.array(import_zod3.z.string()).default([]),
|
|
2605
|
+
visemes: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.object({ base64: import_zod3.z.string().min(1) }).passthrough()).nullable().optional(),
|
|
2606
|
+
moods_on_character: import_zod3.z.array(import_zod3.z.string()).nullable().optional(),
|
|
2607
|
+
grid_url: import_zod3.z.string().nullable().optional(),
|
|
2608
|
+
viseme_order: import_zod3.z.array(import_zod3.z.string()).nullable().optional(),
|
|
2609
|
+
usage: import_zod3.z.unknown().optional()
|
|
2610
|
+
}).passthrough();
|
|
2611
|
+
var TalkingGifSchema = import_zod3.z.object({
|
|
2612
|
+
gif_base64: import_zod3.z.string().min(1),
|
|
2613
|
+
frames: import_zod3.z.number(),
|
|
2614
|
+
duration_ms: import_zod3.z.number(),
|
|
2615
|
+
frame_ms: import_zod3.z.number(),
|
|
2616
|
+
hold_ms: import_zod3.z.number(),
|
|
2617
|
+
width: import_zod3.z.number(),
|
|
2618
|
+
height: import_zod3.z.number(),
|
|
2619
|
+
mood: import_zod3.z.string().nullable().optional()
|
|
2620
|
+
}).passthrough();
|
|
2621
|
+
var LipSyncSchema = import_zod3.z.object({
|
|
2622
|
+
text: import_zod3.z.string(),
|
|
2623
|
+
total_ms: import_zod3.z.number(),
|
|
2624
|
+
viseme_order: import_zod3.z.array(import_zod3.z.string()),
|
|
2625
|
+
frames: import_zod3.z.array(import_zod3.z.object({ viseme: import_zod3.z.string(), column: import_zod3.z.number(), duration_ms: import_zod3.z.number(), text_offset: import_zod3.z.number() }).passthrough()),
|
|
2626
|
+
mood: import_zod3.z.string().nullable().optional(),
|
|
2627
|
+
grid_url: import_zod3.z.string().nullable().optional(),
|
|
2628
|
+
row: import_zod3.z.number().nullable().optional(),
|
|
2629
|
+
rows: import_zod3.z.number().nullable().optional()
|
|
2630
|
+
}).passthrough();
|
|
2526
2631
|
var ExpandRotationsSchema = import_zod3.z.object({
|
|
2527
2632
|
object_id: import_zod3.z.string().min(1),
|
|
2528
2633
|
background_job_id: import_zod3.z.string().min(1),
|
|
@@ -3031,6 +3136,11 @@ var PixelLabClient = class {
|
|
|
3031
3136
|
if (args.buildingFloorDescription) body.building_floor_description = args.buildingFloorDescription;
|
|
3032
3137
|
if (args.buildingFloor2Description) body.building_floor2_description = args.buildingFloor2Description;
|
|
3033
3138
|
if (args.buildingWallAngle != null) body.building_wall_angle = args.buildingWallAngle;
|
|
3139
|
+
if (args.roofProfile) body.roof_profile = args.roofProfile;
|
|
3140
|
+
if (args.elevation != null) body.elevation = args.elevation;
|
|
3141
|
+
if (args.stepSlope != null) body.step_slope = args.stepSlope;
|
|
3142
|
+
if (args.boundaryAmplitude != null) body.boundary_amplitude = args.boundaryAmplitude;
|
|
3143
|
+
if (args.boundarySeed != null) body.boundary_seed = args.boundarySeed;
|
|
3034
3144
|
if (args.outlineMode) body.outline_mode = args.outlineMode;
|
|
3035
3145
|
if (args.seed != null) body.seed = args.seed;
|
|
3036
3146
|
if (args.styleImages?.length) body.style_images = args.styleImages;
|
|
@@ -4097,6 +4207,8 @@ var PixelLabClient = class {
|
|
|
4097
4207
|
const body = { description: args.description };
|
|
4098
4208
|
if (args.artist) body.artist = args.artist;
|
|
4099
4209
|
if (args.sprite) body.sprite = { type: "base64", base64: args.sprite.base64, format: args.sprite.format };
|
|
4210
|
+
if (args.sprite && args.spriteFrames != null && args.spriteFrames > 1) body.sprite_frames = args.spriteFrames;
|
|
4211
|
+
if (args.sprite && args.spriteFps != null) body.sprite_fps = args.spriteFps;
|
|
4100
4212
|
if (args.effectId) body.effect_id = args.effectId;
|
|
4101
4213
|
if (args.conversation) body.conversation = args.conversation;
|
|
4102
4214
|
if (args.name) body.name = args.name;
|
|
@@ -4241,6 +4353,108 @@ var PixelLabClient = class {
|
|
|
4241
4353
|
"objects/import"
|
|
4242
4354
|
);
|
|
4243
4355
|
}
|
|
4356
|
+
/**
|
|
4357
|
+
* `POST /vocal-animation`: one expression's mouth positions for a portrait,
|
|
4358
|
+
* from an image (nothing stored; the frames come back inline) or from a
|
|
4359
|
+
* character's stored portrait (saved onto it). Paid; `pixminimax` costs 3
|
|
4360
|
+
* generations for 7 positions at any size, `v3` 3 to 24 by size.
|
|
4361
|
+
*/
|
|
4362
|
+
async createVocalAnimation(args) {
|
|
4363
|
+
const body = {};
|
|
4364
|
+
if (args.portrait) body.portrait = { type: "base64", base64: args.portrait.base64, format: args.portrait.format };
|
|
4365
|
+
if (args.characterId) body.character_id = args.characterId;
|
|
4366
|
+
if (args.mood) body.mood = args.mood;
|
|
4367
|
+
if (args.visemeCount != null) body.viseme_count = args.visemeCount;
|
|
4368
|
+
if (args.engine) body.engine = args.engine;
|
|
4369
|
+
if (args.seed != null) body.seed = args.seed;
|
|
4370
|
+
return validateResponse(
|
|
4371
|
+
VocalAnimationSubmitSchema,
|
|
4372
|
+
await this.request("/vocal-animation", { method: "POST", body: JSON.stringify(body) }),
|
|
4373
|
+
"vocal-animation"
|
|
4374
|
+
);
|
|
4375
|
+
}
|
|
4376
|
+
/** `GET /vocal-animation/{job}`: the job's status, and its mouth positions once completed. Its bill is on `getBackgroundJob`. */
|
|
4377
|
+
async getVocalAnimation(jobId) {
|
|
4378
|
+
return validateResponse(VocalAnimationJobSchema, await this.request(`/vocal-animation/${encodeURIComponent(jobId)}`), "vocal-animation/{job}");
|
|
4379
|
+
}
|
|
4380
|
+
/** `POST /talking-gif`: a line of text lip-synced to a GIF from mouth positions already made. Free; answers at once. */
|
|
4381
|
+
async createTalkingGif(args) {
|
|
4382
|
+
const body = { text: args.text };
|
|
4383
|
+
if (args.visemes) {
|
|
4384
|
+
body.visemes = Object.fromEntries(Object.entries(args.visemes).map(([id, image]) => [id, { type: "base64", base64: image.base64, format: image.format }]));
|
|
4385
|
+
}
|
|
4386
|
+
if (args.characterId) body.character_id = args.characterId;
|
|
4387
|
+
if (args.mood) body.mood = args.mood;
|
|
4388
|
+
if (args.frameMs != null) body.frame_ms = args.frameMs;
|
|
4389
|
+
if (args.holdMs != null) body.hold_ms = args.holdMs;
|
|
4390
|
+
return validateResponse(TalkingGifSchema, await this.request("/talking-gif", { method: "POST", body: JSON.stringify(body) }), "talking-gif");
|
|
4391
|
+
}
|
|
4392
|
+
/** `POST /lip-sync`: which mouth position to show and for how long, for a line of text. Free; nothing is rendered. */
|
|
4393
|
+
async getLipSync(args) {
|
|
4394
|
+
const body = { text: args.text };
|
|
4395
|
+
if (args.characterId) body.character_id = args.characterId;
|
|
4396
|
+
if (args.mood) body.mood = args.mood;
|
|
4397
|
+
if (args.visemeCount != null) body.viseme_count = args.visemeCount;
|
|
4398
|
+
if (args.frameMs != null) body.frame_ms = args.frameMs;
|
|
4399
|
+
if (args.holdMs != null) body.hold_ms = args.holdMs;
|
|
4400
|
+
return validateResponse(LipSyncSchema, await this.request("/lip-sync", { method: "POST", body: JSON.stringify(body) }), "lip-sync");
|
|
4401
|
+
}
|
|
4402
|
+
/**
|
|
4403
|
+
* `POST /tilesets/import`: your own Wang sheet as a completed tileset, in
|
|
4404
|
+
* PixelLab's compact 4x4 layout or its 8-wide native one. Free. Send
|
|
4405
|
+
* `tileSize` whenever the sheet reads two ways: omitted, PixelLab takes the
|
|
4406
|
+
* 4x4 reading and cuts a native sheet into the wrong tiles.
|
|
4407
|
+
*/
|
|
4408
|
+
async importTileset(args) {
|
|
4409
|
+
const body = {
|
|
4410
|
+
spritesheet: { type: "base64", base64: args.spritesheet.base64, format: args.spritesheet.format }
|
|
4411
|
+
};
|
|
4412
|
+
if (args.mode) body.tileset_mode = args.mode;
|
|
4413
|
+
if (args.tileSize != null) body.tile_size = { width: args.tileSize, height: args.tileSize };
|
|
4414
|
+
if (args.lowerDescription) body.lower_description = args.lowerDescription;
|
|
4415
|
+
if (args.upperDescription) body.upper_description = args.upperDescription;
|
|
4416
|
+
if (args.transitionDescription) body.transition_description = args.transitionDescription;
|
|
4417
|
+
if (args.name) body.name = args.name;
|
|
4418
|
+
return validateResponse(
|
|
4419
|
+
ImportTilesetSchema,
|
|
4420
|
+
await this.request("/tilesets/import", { method: "POST", body: JSON.stringify(body) }),
|
|
4421
|
+
"tilesets/import"
|
|
4422
|
+
);
|
|
4423
|
+
}
|
|
4424
|
+
/** `POST /tiles-pro/import`: 1 to 32 of your own tile PNGs as one completed tile group. Free. */
|
|
4425
|
+
async importTilesPro(args) {
|
|
4426
|
+
const body = {
|
|
4427
|
+
frames: args.frames.map((frame) => ({ type: "base64", base64: frame.base64, format: frame.format })),
|
|
4428
|
+
tile_type: args.tileType,
|
|
4429
|
+
tile_size: args.tileSize
|
|
4430
|
+
};
|
|
4431
|
+
if (args.description) body.description = args.description;
|
|
4432
|
+
if (args.tileView) body.tile_view = args.tileView;
|
|
4433
|
+
return validateResponse(
|
|
4434
|
+
ImportTilesProSchema,
|
|
4435
|
+
await this.request("/tiles-pro/import", { method: "POST", body: JSON.stringify(body) }),
|
|
4436
|
+
"tiles-pro/import"
|
|
4437
|
+
);
|
|
4438
|
+
}
|
|
4439
|
+
/**
|
|
4440
|
+
* `POST /save-to-asset`: write edited pixels back into a stored character
|
|
4441
|
+
* or object rotation, one direction of an animation, a gallery image or a
|
|
4442
|
+
* tileset sheet, or add a new gallery image (`gallery:new`). Free. The
|
|
4443
|
+
* image must match what it replaces in size and frame count. What was
|
|
4444
|
+
* there comes back as `previous_frames`; saving those again is the undo.
|
|
4445
|
+
*/
|
|
4446
|
+
async saveToAsset(args) {
|
|
4447
|
+
const body = { target: args.target };
|
|
4448
|
+
if (args.image) body.image = { type: "base64", base64: args.image.base64, format: args.image.format };
|
|
4449
|
+
if (args.frames) body.frames = args.frames.map((frame) => ({ type: "base64", base64: frame.base64, format: frame.format }));
|
|
4450
|
+
if (args.name) body.name = args.name;
|
|
4451
|
+
if (args.description) body.description = args.description;
|
|
4452
|
+
return validateResponse(
|
|
4453
|
+
SaveToAssetSchema,
|
|
4454
|
+
await this.request("/save-to-asset", { method: "POST", body: JSON.stringify(body) }),
|
|
4455
|
+
"save-to-asset"
|
|
4456
|
+
);
|
|
4457
|
+
}
|
|
4244
4458
|
/**
|
|
4245
4459
|
* `POST /objects/{id}/expand-rotations`: draw the 7 missing directions of a
|
|
4246
4460
|
* 1-direction object. The object then waits in `review-expansion` until
|
|
@@ -5087,6 +5301,12 @@ function specHash(spec, styleImageHashes, providerOptionIdentity = spec.provider
|
|
|
5087
5301
|
tileType: spec.tileType,
|
|
5088
5302
|
tileView: spec.tileView,
|
|
5089
5303
|
tileFeature: spec.tileFeature,
|
|
5304
|
+
// `tiles` shape options added in November 2026, each only when set.
|
|
5305
|
+
buildingRoofProfile: spec.buildingRoofProfile,
|
|
5306
|
+
tileElevation: spec.tileElevation,
|
|
5307
|
+
tileStepSlope: spec.tileStepSlope,
|
|
5308
|
+
tileBoundaryAmplitude: spec.tileBoundaryAmplitude,
|
|
5309
|
+
tileBoundarySeed: spec.tileBoundarySeed,
|
|
5090
5310
|
outlineMode: spec.outlineMode,
|
|
5091
5311
|
isometricTileSize: spec.isometricTileSize,
|
|
5092
5312
|
isometricTileShape: spec.isometricTileShape,
|
|
@@ -5205,7 +5425,11 @@ function specHash(spec, styleImageHashes, providerOptionIdentity = spec.provider
|
|
|
5205
5425
|
fps: spec.vfx.fps,
|
|
5206
5426
|
sprite: spec.vfx.sprite ? "reference" in spec.vfx.sprite ? spec.vfx.sprite.reference : spec.vfx.sprite.sha256 : void 0,
|
|
5207
5427
|
description: spec.vfx.description,
|
|
5208
|
-
artist: spec.vfx.description ? spec.vfx.artist : void 0
|
|
5428
|
+
artist: spec.vfx.description ? spec.vfx.artist : void 0,
|
|
5429
|
+
// Absent for a still sprite, so every effect made before strips
|
|
5430
|
+
// existed keeps its hash.
|
|
5431
|
+
spriteFrames: spec.vfx.spriteFrames,
|
|
5432
|
+
spriteFps: spec.vfx.spriteFps
|
|
5209
5433
|
} : void 0,
|
|
5210
5434
|
// A mirror's bytes come from its source's recorded outputs; the plan
|
|
5211
5435
|
// compares those directly, so only the choice of source is identity.
|
|
@@ -5625,27 +5849,64 @@ async function makeVfx(client2, opts) {
|
|
|
5625
5849
|
}
|
|
5626
5850
|
var VFX_ARTISTS = ["lite", "pro"];
|
|
5627
5851
|
var VFX_ARTIST_MAX_SPRITE = 512;
|
|
5628
|
-
function vfxArtistQuote(artist, sprite, change = false) {
|
|
5852
|
+
function vfxArtistQuote(artist, sprite, change = false, animated = false) {
|
|
5629
5853
|
const table = {
|
|
5630
5854
|
lite: { new: [1, 1, 3, 5], change: [1, 1, 2, 2] },
|
|
5631
5855
|
pro: { new: [6, 8, 14, 28], change: [4, 4, 5, 8] }
|
|
5632
5856
|
};
|
|
5633
5857
|
const tier = sprite === "none" ? 0 : sprite === "unknown" ? 3 : sprite <= 128 ? 1 : sprite <= 256 ? 2 : 3;
|
|
5634
|
-
|
|
5858
|
+
const base = table[artist][change ? "change" : "new"][tier];
|
|
5859
|
+
return animated && tier > 0 ? base + VFX_ARTIST_ANIMATED_EXTRA[artist][tier - 1] : base;
|
|
5635
5860
|
}
|
|
5861
|
+
var VFX_ARTIST_ANIMATED_EXTRA = { lite: [1, 1, 1], pro: [1, 2, 5] };
|
|
5862
|
+
var VFX_ARTIST_MAX_FRAMES = 32;
|
|
5863
|
+
var VFX_ARTIST_MAX_STRIP = 1024;
|
|
5636
5864
|
function vfxArtistCeiling(quote) {
|
|
5637
5865
|
return quote * 2;
|
|
5638
5866
|
}
|
|
5639
|
-
function
|
|
5640
|
-
|
|
5641
|
-
|
|
5642
|
-
|
|
5867
|
+
function gifSize(bytes) {
|
|
5868
|
+
if (bytes.length < 10) return null;
|
|
5869
|
+
const magic = bytes.toString("ascii", 0, 6);
|
|
5870
|
+
if (magic !== "GIF87a" && magic !== "GIF89a") return null;
|
|
5871
|
+
return { width: bytes.readUInt16LE(6), height: bytes.readUInt16LE(8) };
|
|
5872
|
+
}
|
|
5873
|
+
function vfxArtistFrameSide(width, height, frames, label) {
|
|
5874
|
+
if (!Number.isInteger(frames) || frames < 1 || frames > VFX_ARTIST_MAX_FRAMES) {
|
|
5875
|
+
throw new Error(`${label}: a sprite strip holds 1 to ${VFX_ARTIST_MAX_FRAMES} frames, got ${frames}`);
|
|
5876
|
+
}
|
|
5877
|
+
if (width % frames !== 0) {
|
|
5878
|
+
throw new Error(`${label} is ${width}px wide, which does not divide into ${frames} equal frames`);
|
|
5879
|
+
}
|
|
5880
|
+
if (frames > 1 && width > VFX_ARTIST_MAX_STRIP) {
|
|
5881
|
+
throw new Error(
|
|
5882
|
+
`${label} is a ${width}px-wide strip; PixelLab's VFX artist takes a strip up to ${VFX_ARTIST_MAX_STRIP}px wide. Send fewer frames, or the animation as a GIF`
|
|
5883
|
+
);
|
|
5884
|
+
}
|
|
5885
|
+
const frameWidth = width / frames;
|
|
5886
|
+
const side = Math.max(frameWidth, height);
|
|
5643
5887
|
if (side > VFX_ARTIST_MAX_SPRITE) {
|
|
5644
5888
|
throw new Error(
|
|
5645
|
-
`${label} is ${
|
|
5889
|
+
`${label} is ${frameWidth}x${height}${frames > 1 ? " a frame" : ""}; PixelLab's VFX artist takes up to ${VFX_ARTIST_MAX_SPRITE}x${VFX_ARTIST_MAX_SPRITE} (crop or pad it; never rescale pixel art)`
|
|
5646
5890
|
);
|
|
5647
5891
|
}
|
|
5648
|
-
return
|
|
5892
|
+
return side;
|
|
5893
|
+
}
|
|
5894
|
+
function vfxArtistSprite(bytes, label, frames = 1) {
|
|
5895
|
+
const gif = gifSize(bytes);
|
|
5896
|
+
if (gif) {
|
|
5897
|
+
if (frames !== 1) throw new Error(`${label} is a GIF, which brings its own frames; drop the frame count`);
|
|
5898
|
+
const side2 = Math.max(gif.width, gif.height);
|
|
5899
|
+
if (side2 > VFX_ARTIST_MAX_SPRITE) {
|
|
5900
|
+
throw new Error(
|
|
5901
|
+
`${label} is ${gif.width}x${gif.height}; PixelLab's VFX artist takes up to ${VFX_ARTIST_MAX_SPRITE}x${VFX_ARTIST_MAX_SPRITE} (crop or pad it; never rescale pixel art)`
|
|
5902
|
+
);
|
|
5903
|
+
}
|
|
5904
|
+
return { image: { base64: bytes.toString("base64"), format: "gif" }, side: side2, animated: true };
|
|
5905
|
+
}
|
|
5906
|
+
const metadata = imageMetadata(bytes);
|
|
5907
|
+
if (metadata?.format !== "png") throw new Error(`${label}: PixelLab's VFX artist takes a PNG or GIF sprite`);
|
|
5908
|
+
const side = vfxArtistFrameSide(metadata.width, metadata.height, frames, label);
|
|
5909
|
+
return { image: { base64: bytes.toString("base64"), format: "png" }, side, animated: frames > 1 };
|
|
5649
5910
|
}
|
|
5650
5911
|
function vfxArtistFiles(raw) {
|
|
5651
5912
|
const urlOf = (value) => {
|
|
@@ -5730,7 +5991,7 @@ async function makeVfxWithArtist(client2, opts) {
|
|
|
5730
5991
|
}
|
|
5731
5992
|
const progress = opts.onProgress ?? (() => {
|
|
5732
5993
|
});
|
|
5733
|
-
const sprite = opts.sprite ? vfxArtistSprite(await (0, import_promises.readFile)(opts.sprite), opts.sprite).image : void 0;
|
|
5994
|
+
const sprite = opts.sprite ? vfxArtistSprite(await (0, import_promises.readFile)(opts.sprite), opts.sprite, opts.spriteFrames ?? 1).image : void 0;
|
|
5734
5995
|
const sleep3 = opts.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
5735
5996
|
const interval = opts.intervalMs ?? 6e3;
|
|
5736
5997
|
const timeout = opts.timeoutMs ?? 10 * 6e4;
|
|
@@ -5738,6 +5999,8 @@ async function makeVfxWithArtist(client2, opts) {
|
|
|
5738
5999
|
description: opts.description,
|
|
5739
6000
|
artist: opts.artist,
|
|
5740
6001
|
sprite,
|
|
6002
|
+
spriteFrames: sprite ? opts.spriteFrames : void 0,
|
|
6003
|
+
spriteFps: sprite ? opts.spriteFps : void 0,
|
|
5741
6004
|
effectId: opts.effect,
|
|
5742
6005
|
conversation: opts.effect ? opts.conversation : void 0,
|
|
5743
6006
|
name: opts.name,
|
|
@@ -5795,6 +6058,8 @@ async function makeVfxWithArtist(client2, opts) {
|
|
|
5795
6058
|
message: result.message,
|
|
5796
6059
|
source: {
|
|
5797
6060
|
...opts.sprite ? { sprite: import_node_path.default.relative(import_node_path.default.dirname(paths.provenance), import_node_path.default.resolve(opts.sprite)).split(import_node_path.default.sep).join("/") } : {},
|
|
6061
|
+
...opts.sprite && opts.spriteFrames && opts.spriteFrames > 1 ? { spriteFrames: opts.spriteFrames } : {},
|
|
6062
|
+
...opts.sprite && opts.spriteFps ? { spriteFps: opts.spriteFps } : {},
|
|
5798
6063
|
...opts.effect ? { changed: opts.effect } : {}
|
|
5799
6064
|
},
|
|
5800
6065
|
...facts,
|
|
@@ -6138,8 +6403,9 @@ function pixelLabObjectUrl(generator, objectId) {
|
|
|
6138
6403
|
}
|
|
6139
6404
|
function vfxArtistSpecQuote(spec) {
|
|
6140
6405
|
const sprite = spec.vfx?.sprite;
|
|
6141
|
-
const
|
|
6142
|
-
|
|
6406
|
+
const frames = spec.vfx?.spriteFrames ?? 1;
|
|
6407
|
+
const side = !sprite ? "none" : "file" in sprite && sprite.width != null && sprite.height != null ? Math.max(Math.ceil(sprite.width / frames), sprite.height) : "unknown";
|
|
6408
|
+
return vfxArtistQuote(spec.vfx?.artist ?? "lite", side, false, frames > 1);
|
|
6143
6409
|
}
|
|
6144
6410
|
function workbenchVfxUrls(exported) {
|
|
6145
6411
|
const sheetFile = exported.files.find((file) => /\.png$/i.test(file));
|
|
@@ -6419,6 +6685,7 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
6419
6685
|
`vfx sprite ${sprite.file} is ${sprite.width}x${sprite.height}; PixelLab's VFX artist takes up to ${VFX_ARTIST_MAX_SPRITE}x${VFX_ARTIST_MAX_SPRITE} (crop or pad it; never rescale pixel art)`
|
|
6420
6686
|
);
|
|
6421
6687
|
}
|
|
6688
|
+
if (spec.generator === "tiles") this.validateTileOptions(spec);
|
|
6422
6689
|
const members = spec.revision?.sourceMembers;
|
|
6423
6690
|
if (spec.revision && members && !MEMBER_SET_REVISION_MODES.includes(spec.revision.mode)) {
|
|
6424
6691
|
throw new Error(
|
|
@@ -6690,6 +6957,31 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
6690
6957
|
);
|
|
6691
6958
|
}
|
|
6692
6959
|
}
|
|
6960
|
+
/** Where `/create-tiles-pro`'s newer shape options apply; elsewhere the API ignores or refuses them. */
|
|
6961
|
+
validateTileOptions(spec) {
|
|
6962
|
+
const tilesetOnly = {
|
|
6963
|
+
tileElevation: spec.tileElevation,
|
|
6964
|
+
tileStepSlope: spec.tileStepSlope,
|
|
6965
|
+
tileBoundaryAmplitude: spec.tileBoundaryAmplitude,
|
|
6966
|
+
tileBoundarySeed: spec.tileBoundarySeed
|
|
6967
|
+
};
|
|
6968
|
+
const set = Object.entries(tilesetOnly).filter(([, value]) => value != null).map(([field]) => field);
|
|
6969
|
+
if (set.length && spec.tileFeature !== "tileset") {
|
|
6970
|
+
throw new Error(`PixelLab tiles: ${set.join(", ")} shape a connectable terrain set; set tileFeature: "tileset"`);
|
|
6971
|
+
}
|
|
6972
|
+
if (spec.tileElevation != null && spec.tileElevation > 0 && spec.tileType && !["square_topdown", "isometric", "oblique"].includes(spec.tileType)) {
|
|
6973
|
+
throw new Error(`PixelLab tiles: tileElevation raises a plateau on square_topdown, isometric or oblique tiles, not "${spec.tileType}"`);
|
|
6974
|
+
}
|
|
6975
|
+
if (spec.tileStepSlope != null && !(spec.tileElevation != null && spec.tileElevation > 0)) {
|
|
6976
|
+
throw new Error("PixelLab tiles: tileStepSlope spreads the drop of a raised terrain; set tileElevation above 0");
|
|
6977
|
+
}
|
|
6978
|
+
if (spec.tileBoundarySeed != null && spec.tileBoundaryAmplitude == null) {
|
|
6979
|
+
throw new Error("PixelLab tiles: tileBoundarySeed picks tileBoundaryAmplitude's meander; set both or neither");
|
|
6980
|
+
}
|
|
6981
|
+
if (spec.buildingRoofProfile && !(spec.tileFeature === "building" && spec.buildingLayout === "materials")) {
|
|
6982
|
+
throw new Error(`PixelLab tiles: buildingRoofProfile shapes a building kit's roof pieces; set tileFeature: "building" with buildingLayout: "materials"`);
|
|
6983
|
+
}
|
|
6984
|
+
}
|
|
6693
6985
|
/** `/create-tileset`'s own rules, beyond the enums both terrain endpoints share. */
|
|
6694
6986
|
validateTopDownTerrain(spec) {
|
|
6695
6987
|
if (spec.terrainShapeStyle && spec.terrainMode === "pro") {
|
|
@@ -7580,6 +7872,11 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
7580
7872
|
buildingFloorDescription: spec.buildingFloorDescription,
|
|
7581
7873
|
buildingFloor2Description: spec.buildingFloor2Description,
|
|
7582
7874
|
buildingWallAngle: spec.buildingWallAngle,
|
|
7875
|
+
roofProfile: spec.buildingRoofProfile,
|
|
7876
|
+
elevation: spec.tileElevation,
|
|
7877
|
+
stepSlope: spec.tileStepSlope,
|
|
7878
|
+
boundaryAmplitude: spec.tileBoundaryAmplitude,
|
|
7879
|
+
boundarySeed: spec.tileBoundarySeed,
|
|
7583
7880
|
outlineMode: spec.outlineMode,
|
|
7584
7881
|
seed: spec.seed,
|
|
7585
7882
|
// TilesProStyleImage is flat and wants the reference's real dimensions,
|
|
@@ -8141,11 +8438,20 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
8141
8438
|
if (sha256(bytes) !== vfx.sprite.sha256) {
|
|
8142
8439
|
throw new Error(`vfx sprite changed after the manifest was resolved: ${file}; run the command again`);
|
|
8143
8440
|
}
|
|
8144
|
-
|
|
8441
|
+
const taken = vfxArtistSprite(bytes, `vfx sprite ${file}`, vfx.spriteFrames ?? 1).image;
|
|
8442
|
+
if (taken.format !== "png") throw new Error(`vfx sprite must be a PNG: ${file}`);
|
|
8443
|
+
sprite = { base64: taken.base64, format: "png" };
|
|
8145
8444
|
}
|
|
8146
8445
|
const previous = context?.replacedMetadata?.vfx ?? context?.lastGenerationMetadata?.vfx;
|
|
8147
8446
|
const artist = vfx.artist ?? "lite";
|
|
8148
|
-
const submitted = await this.client.createVfx({
|
|
8447
|
+
const submitted = await this.client.createVfx({
|
|
8448
|
+
description: vfx.description,
|
|
8449
|
+
artist,
|
|
8450
|
+
sprite,
|
|
8451
|
+
spriteFrames: vfx.spriteFrames,
|
|
8452
|
+
spriteFps: vfx.spriteFps,
|
|
8453
|
+
name: vfx.name
|
|
8454
|
+
});
|
|
8149
8455
|
return {
|
|
8150
8456
|
jobId: submitted.background_job_id,
|
|
8151
8457
|
metadata: {
|
|
@@ -12130,6 +12436,11 @@ async function resolveSpecs(loaded, filter) {
|
|
|
12130
12436
|
buildingFloorDescription: generator === "tiles" ? style.buildingFloorDescription : void 0,
|
|
12131
12437
|
buildingFloor2Description: generator === "tiles" ? style.buildingFloor2Description : void 0,
|
|
12132
12438
|
buildingWallAngle: generator === "tiles" ? style.buildingWallAngle : void 0,
|
|
12439
|
+
buildingRoofProfile: generator === "tiles" ? style.buildingRoofProfile : void 0,
|
|
12440
|
+
tileElevation: generator === "tiles" ? style.tileElevation : void 0,
|
|
12441
|
+
tileStepSlope: generator === "tiles" ? style.tileStepSlope : void 0,
|
|
12442
|
+
tileBoundaryAmplitude: generator === "tiles" ? style.tileBoundaryAmplitude : void 0,
|
|
12443
|
+
tileBoundarySeed: generator === "tiles" ? style.tileBoundarySeed : void 0,
|
|
12133
12444
|
outlineMode: generator === "tiles" ? style.outlineMode : void 0,
|
|
12134
12445
|
terrainLowerDescription: generator === "terrain" ? terrainLowerDescription : void 0,
|
|
12135
12446
|
terrainUpperDescription: generator === "terrain" ? terrainUpperDescription : void 0,
|
|
@@ -12747,6 +13058,9 @@ async function resolveVfxShape(root, assetId, vfx, defaultName) {
|
|
|
12747
13058
|
} else if (spriteRef) {
|
|
12748
13059
|
const image = await optionalRevisionImage(spriteRef, `assets.${assetId}.vfx.sprite`, vfx.description ? "png" : void 0);
|
|
12749
13060
|
sprite = { file: spriteRef, sha256: image?.hash ?? null, width: image?.width ?? null, height: image?.height ?? null, format: image?.format ?? null };
|
|
13061
|
+
if (image && vfx.description && (vfx.spriteFrames ?? 1) > 1) {
|
|
13062
|
+
vfxArtistFrameSide(image.width, image.height, vfx.spriteFrames, `assets.${assetId}.vfx.sprite`);
|
|
13063
|
+
}
|
|
12750
13064
|
}
|
|
12751
13065
|
return {
|
|
12752
13066
|
...vfx.preset ? { preset: vfx.preset } : {},
|
|
@@ -12756,7 +13070,10 @@ async function resolveVfxShape(root, assetId, vfx, defaultName) {
|
|
|
12756
13070
|
...vfx.fps !== void 0 ? { fps: vfx.fps } : {},
|
|
12757
13071
|
// The artist caps a name at 80 characters; a long default is cut, not refused.
|
|
12758
13072
|
name: vfx.name ?? (vfx.description ? defaultName.slice(0, 80) : defaultName),
|
|
12759
|
-
...vfx.description ? { description: vfx.description, artist: vfx.artist ?? "lite" } : {}
|
|
13073
|
+
...vfx.description ? { description: vfx.description, artist: vfx.artist ?? "lite" } : {},
|
|
13074
|
+
// A strip of one frame is a still: it is sent, priced and hashed as one.
|
|
13075
|
+
...vfx.spriteFrames !== void 0 && vfx.spriteFrames > 1 ? { spriteFrames: vfx.spriteFrames } : {},
|
|
13076
|
+
...vfx.spriteFps !== void 0 ? { spriteFps: vfx.spriteFps } : {}
|
|
12760
13077
|
};
|
|
12761
13078
|
}
|
|
12762
13079
|
async function optionalRevisionImage(file, label, requiredFormat) {
|
|
@@ -16229,6 +16546,172 @@ async function pullExpansionReview(client2, id, opts) {
|
|
|
16229
16546
|
}
|
|
16230
16547
|
return { dir, existingDirection: review.existing_direction ?? null, files };
|
|
16231
16548
|
}
|
|
16549
|
+
var TILESET_MODES = ["topdown", "sidescroller"];
|
|
16550
|
+
var IMPORT_TILE_TYPES = ["square_topdown", "isometric", "oblique", "hex", "hex_pointy", "octagon"];
|
|
16551
|
+
var IMPORT_TILE_VIEWS = ["top-down", "high top-down", "low top-down", "side"];
|
|
16552
|
+
var SHEET_TILE_SIZES = [16, 24, 32, 48, 64];
|
|
16553
|
+
var IMPORT_MAX_TILES = 32;
|
|
16554
|
+
function tilesetSheetReadings(width, height) {
|
|
16555
|
+
if (height !== width && height !== width * 2) return [];
|
|
16556
|
+
const readings = [];
|
|
16557
|
+
if (SHEET_TILE_SIZES.includes(width / 4)) readings.push({ tileSize: width / 4, layout: "compact" });
|
|
16558
|
+
if (SHEET_TILE_SIZES.includes(width / 8)) readings.push({ tileSize: width / 8, layout: "native" });
|
|
16559
|
+
return readings;
|
|
16560
|
+
}
|
|
16561
|
+
function chooseTilesetSheetReading(file, width, height, tileSize) {
|
|
16562
|
+
const readings = tilesetSheetReadings(width, height);
|
|
16563
|
+
const describe = (reading) => `${reading.tileSize}px tiles (${reading.layout === "compact" ? "4 wide" : "8 wide"})`;
|
|
16564
|
+
if (readings.length === 0) {
|
|
16565
|
+
throw new Error(
|
|
16566
|
+
`${file} is ${width}x${height}, not a PixelLab tileset sheet: it takes a square sheet 4 or 8 tiles wide (or twice as tall, for a set with transitions) of 16, 24, 32, 48 or 64px tiles`
|
|
16567
|
+
);
|
|
16568
|
+
}
|
|
16569
|
+
if (tileSize === void 0) {
|
|
16570
|
+
if (readings.length > 1) {
|
|
16571
|
+
throw new Error(
|
|
16572
|
+
`${file} is ${width}x${height}, which reads as ${readings.map(describe).join(" or ")}; say which with --size ${readings.map((reading) => reading.tileSize).join(" or --size ")}`
|
|
16573
|
+
);
|
|
16574
|
+
}
|
|
16575
|
+
return readings[0];
|
|
16576
|
+
}
|
|
16577
|
+
const chosen = readings.find((reading) => reading.tileSize === tileSize);
|
|
16578
|
+
if (!chosen) throw new Error(`${file} is ${width}x${height}, which holds ${readings.map(describe).join(" or ")}, not ${tileSize}px tiles`);
|
|
16579
|
+
return chosen;
|
|
16580
|
+
}
|
|
16581
|
+
function readPng(bytes, file) {
|
|
16582
|
+
const metadata = imageMetadata(bytes);
|
|
16583
|
+
if (!metadata || metadata.format !== "png") throw new Error(`${file} is not a PNG`);
|
|
16584
|
+
return metadata;
|
|
16585
|
+
}
|
|
16586
|
+
async function importTilesetFile(client2, file, opts = {}) {
|
|
16587
|
+
const bytes = await (0, import_promises14.readFile)(file);
|
|
16588
|
+
const { width, height } = readPng(bytes, file);
|
|
16589
|
+
const reading = chooseTilesetSheetReading(file, width, height, opts.tileSize);
|
|
16590
|
+
const mode2 = opts.mode ?? "topdown";
|
|
16591
|
+
if (mode2 === "sidescroller" && opts.upperDescription) throw new Error("a sidescroller tileset has one terrain, the platform; drop the upper description");
|
|
16592
|
+
const res = await client2.importTileset({
|
|
16593
|
+
spritesheet: { base64: bytes.toString("base64"), format: "png" },
|
|
16594
|
+
mode: mode2,
|
|
16595
|
+
// PixelLab cannot be told 48, and a 4-wide reading is the one it takes unprompted.
|
|
16596
|
+
tileSize: reading.tileSize === 48 ? void 0 : reading.tileSize,
|
|
16597
|
+
lowerDescription: opts.lowerDescription,
|
|
16598
|
+
upperDescription: opts.upperDescription,
|
|
16599
|
+
transitionDescription: opts.transitionDescription,
|
|
16600
|
+
name: opts.name
|
|
16601
|
+
});
|
|
16602
|
+
return { tilesetId: res.tileset_id, mode: mode2, tileSize: reading.tileSize, layout: reading.layout };
|
|
16603
|
+
}
|
|
16604
|
+
async function pngFilesAt(from) {
|
|
16605
|
+
if (!(0, import_node_fs20.existsSync)(from)) throw new Error(`${from} does not exist`);
|
|
16606
|
+
if (!(await (0, import_promises14.stat)(from)).isDirectory()) return [from];
|
|
16607
|
+
const names = (await (0, import_promises14.readdir)(from)).filter((name) => /\.png$/i.test(name)).sort((a, b) => a.localeCompare(b, void 0, { numeric: true }));
|
|
16608
|
+
if (names.length === 0) throw new Error(`${from} holds no PNG files`);
|
|
16609
|
+
return names.map((name) => import_node_path23.default.join(from, name));
|
|
16610
|
+
}
|
|
16611
|
+
function importTileHeights(tileType, tileSize) {
|
|
16612
|
+
if (tileType === "square_topdown" || tileType === "octagon") return { min: tileSize, max: tileSize };
|
|
16613
|
+
if (tileType === "oblique") return { min: tileSize, max: tileSize * 2 };
|
|
16614
|
+
return { min: tileSize / 2, max: tileSize * 2 };
|
|
16615
|
+
}
|
|
16616
|
+
async function importTilesFiles(client2, from, opts) {
|
|
16617
|
+
if (!IMPORT_TILE_TYPES.includes(opts.tileType)) throw new Error(`tile type must be one of ${IMPORT_TILE_TYPES.join(", ")}`);
|
|
16618
|
+
if (!Number.isInteger(opts.tileSize) || opts.tileSize < 16 || opts.tileSize > 256) throw new Error("tile size is a whole number from 16 to 256");
|
|
16619
|
+
const files = await pngFilesAt(from);
|
|
16620
|
+
if (files.length > IMPORT_MAX_TILES) throw new Error(`${from} holds ${files.length} PNGs; PixelLab imports at most ${IMPORT_MAX_TILES} tiles in one group`);
|
|
16621
|
+
const heights = importTileHeights(opts.tileType, opts.tileSize);
|
|
16622
|
+
const frames = [];
|
|
16623
|
+
for (const file of files) {
|
|
16624
|
+
const bytes = await (0, import_promises14.readFile)(file);
|
|
16625
|
+
const { width, height } = readPng(bytes, file);
|
|
16626
|
+
if (width !== opts.tileSize || height < heights.min || height > heights.max) {
|
|
16627
|
+
const tall = heights.min === heights.max ? `${heights.min}` : `${heights.min} to ${heights.max}`;
|
|
16628
|
+
throw new Error(`${file} is ${width}x${height}; a ${opts.tileSize}px ${opts.tileType} tile is ${opts.tileSize} wide and ${tall} tall`);
|
|
16629
|
+
}
|
|
16630
|
+
frames.push({ base64: bytes.toString("base64"), format: "png" });
|
|
16631
|
+
}
|
|
16632
|
+
const res = await client2.importTilesPro({ frames, tileType: opts.tileType, tileSize: opts.tileSize, description: opts.description, tileView: opts.tileView });
|
|
16633
|
+
return { tileId: res.tile_id, tiles: files.length, files };
|
|
16634
|
+
}
|
|
16635
|
+
function checkSaveTarget(target) {
|
|
16636
|
+
if (!/^(character:[^:]+:[^:]+(:[^:]+)?|object:[^:]+(:[^:]+){0,2}|gallery:[^:]+|tileset:[^:]+)$/.test(target)) {
|
|
16637
|
+
throw new Error(
|
|
16638
|
+
`--target "${target}" is not a place PixelLab can save to. Use character:<id>:<direction>, object:<id>[:<direction>], either with :<animation group id> added, gallery:<id>, gallery:new, or tileset:<id>`
|
|
16639
|
+
);
|
|
16640
|
+
}
|
|
16641
|
+
}
|
|
16642
|
+
function saveUndoDir(target, now = /* @__PURE__ */ new Date()) {
|
|
16643
|
+
const stamp = now.toISOString().replace(/[-:]/g, "").replace(/\.\d+Z$/, "Z");
|
|
16644
|
+
return import_node_path23.default.resolve("pixelkiln-undo", `${target.replace(/[^a-zA-Z0-9-]+/g, "_")}-${stamp}`);
|
|
16645
|
+
}
|
|
16646
|
+
async function writeUndo(frames, dir) {
|
|
16647
|
+
await (0, import_promises14.mkdir)(dir, { recursive: true });
|
|
16648
|
+
const files = [];
|
|
16649
|
+
for (const [index, frame] of frames.entries()) {
|
|
16650
|
+
const file = import_node_path23.default.join(dir, frames.length === 1 ? "previous.png" : `previous-${String(index).padStart(2, "0")}.png`);
|
|
16651
|
+
await (0, import_promises14.writeFile)(file, Buffer.from(frame.base64, "base64"));
|
|
16652
|
+
files.push(file);
|
|
16653
|
+
}
|
|
16654
|
+
return files;
|
|
16655
|
+
}
|
|
16656
|
+
async function saveToAssetFile(client2, target, from, opts = {}) {
|
|
16657
|
+
checkSaveTarget(target);
|
|
16658
|
+
if ((opts.name || opts.description) && target !== "gallery:new") throw new Error("a name and a description belong to a new gallery image: --target gallery:new");
|
|
16659
|
+
const files = await pngFilesAt(from).catch(async (error) => {
|
|
16660
|
+
if ((0, import_node_fs20.existsSync)(from) && /\.gif$/i.test(from)) return [from];
|
|
16661
|
+
throw error;
|
|
16662
|
+
});
|
|
16663
|
+
let image;
|
|
16664
|
+
let frames;
|
|
16665
|
+
if (files.length === 1) {
|
|
16666
|
+
const bytes = await (0, import_promises14.readFile)(files[0]);
|
|
16667
|
+
const gif = bytes.subarray(0, 4).toString("ascii") === "GIF8";
|
|
16668
|
+
if (!gif) readPng(bytes, files[0]);
|
|
16669
|
+
image = { base64: bytes.toString("base64"), format: gif ? "gif" : "png" };
|
|
16670
|
+
} else {
|
|
16671
|
+
if (files.length > 128) throw new Error(`${from} holds ${files.length} PNGs; PixelLab takes at most 128 frames`);
|
|
16672
|
+
let size;
|
|
16673
|
+
frames = [];
|
|
16674
|
+
for (const file of files) {
|
|
16675
|
+
const bytes = await (0, import_promises14.readFile)(file);
|
|
16676
|
+
const { width, height } = readPng(bytes, file);
|
|
16677
|
+
if (size && size !== `${width}x${height}`) throw new Error(`${file} is ${width}x${height}, but the frames before it are ${size}; an animation's frames share one size`);
|
|
16678
|
+
size = `${width}x${height}`;
|
|
16679
|
+
frames.push({ base64: bytes.toString("base64"), format: "png" });
|
|
16680
|
+
}
|
|
16681
|
+
}
|
|
16682
|
+
const undoDir = opts.undoDir ? import_node_path23.default.resolve(opts.undoDir) : saveUndoDir(target);
|
|
16683
|
+
let res;
|
|
16684
|
+
try {
|
|
16685
|
+
res = await client2.saveToAsset({ target, image, frames, name: opts.name, description: opts.description });
|
|
16686
|
+
} catch (error) {
|
|
16687
|
+
if (error instanceof PixelLabError && error.body.startsWith("{")) {
|
|
16688
|
+
let previous;
|
|
16689
|
+
try {
|
|
16690
|
+
previous = JSON.parse(error.body).detail?.previous_frames;
|
|
16691
|
+
} catch {
|
|
16692
|
+
previous = void 0;
|
|
16693
|
+
}
|
|
16694
|
+
if (Array.isArray(previous) && previous.length && previous.every((frame) => typeof frame?.base64 === "string")) {
|
|
16695
|
+
const written = await writeUndo(previous, undoDir);
|
|
16696
|
+
throw new Error(`${error.message}. The save failed partway; what was stored before is in ${undoDir} (${written.length} frame(s)). Save it back to ${target} to restore it`);
|
|
16697
|
+
}
|
|
16698
|
+
}
|
|
16699
|
+
throw error;
|
|
16700
|
+
}
|
|
16701
|
+
const undo = res.action === "saved" && res.previous_frames?.length ? await writeUndo(res.previous_frames, undoDir) : [];
|
|
16702
|
+
return {
|
|
16703
|
+
action: res.action,
|
|
16704
|
+
target: res.target,
|
|
16705
|
+
kind: res.kind,
|
|
16706
|
+
width: res.width,
|
|
16707
|
+
height: res.height,
|
|
16708
|
+
frames: res.frame_count,
|
|
16709
|
+
changedPixels: res.changed_pixels,
|
|
16710
|
+
undo,
|
|
16711
|
+
note: res.note ?? null,
|
|
16712
|
+
maps: res.maps ?? null
|
|
16713
|
+
};
|
|
16714
|
+
}
|
|
16232
16715
|
|
|
16233
16716
|
// src/pipeline/quality-regression.ts
|
|
16234
16717
|
var import_node_path24 = __toESM(require("path"), 1);
|
|
@@ -23591,6 +24074,9 @@ async function workspaceStatus(ws, dir) {
|
|
|
23591
24074
|
HISTORY_ENV,
|
|
23592
24075
|
HandEditCompanionSchema,
|
|
23593
24076
|
IMPORT_MAX_SIDE,
|
|
24077
|
+
IMPORT_MAX_TILES,
|
|
24078
|
+
IMPORT_TILE_TYPES,
|
|
24079
|
+
IMPORT_TILE_VIEWS,
|
|
23594
24080
|
ImageQualityMetricsSchema,
|
|
23595
24081
|
InheritedStyleSchema,
|
|
23596
24082
|
LockEntrySchema,
|
|
@@ -23659,6 +24145,7 @@ async function workspaceStatus(ws, dir) {
|
|
|
23659
24145
|
StyleInputSchema,
|
|
23660
24146
|
StyleSchema,
|
|
23661
24147
|
TARGET_PALETTE_GENERATORS,
|
|
24148
|
+
TILESET_MODES,
|
|
23662
24149
|
TerrainConnectSchema,
|
|
23663
24150
|
TerrainLinkSchema,
|
|
23664
24151
|
TerrainSideSchema,
|
|
@@ -23673,7 +24160,10 @@ async function workspaceStatus(ws, dir) {
|
|
|
23673
24160
|
UnsupportedCapabilityError,
|
|
23674
24161
|
UsageError,
|
|
23675
24162
|
VFX_ARTISTS,
|
|
24163
|
+
VFX_ARTIST_ANIMATED_EXTRA,
|
|
24164
|
+
VFX_ARTIST_MAX_FRAMES,
|
|
23676
24165
|
VFX_ARTIST_MAX_SPRITE,
|
|
24166
|
+
VFX_ARTIST_MAX_STRIP,
|
|
23677
24167
|
VFX_TOOL,
|
|
23678
24168
|
VfxPartSchema,
|
|
23679
24169
|
WorkspaceProjectSchema,
|
|
@@ -23698,7 +24188,9 @@ async function workspaceStatus(ws, dir) {
|
|
|
23698
24188
|
checkExportBytes,
|
|
23699
24189
|
checkQualityBaseline,
|
|
23700
24190
|
checkQualityRecord,
|
|
24191
|
+
checkSaveTarget,
|
|
23701
24192
|
checkUiInsets,
|
|
24193
|
+
chooseTilesetSheetReading,
|
|
23702
24194
|
clientFromEnv,
|
|
23703
24195
|
colorDistance,
|
|
23704
24196
|
countNumberedDescriptions,
|
|
@@ -23747,6 +24239,7 @@ async function workspaceStatus(ws, dir) {
|
|
|
23747
24239
|
generateMusic,
|
|
23748
24240
|
generateSoundEffect,
|
|
23749
24241
|
generationCost,
|
|
24242
|
+
gifSize,
|
|
23750
24243
|
groupOrphansByStyle,
|
|
23751
24244
|
handEditBase,
|
|
23752
24245
|
handEditBases,
|
|
@@ -23761,6 +24254,9 @@ async function workspaceStatus(ws, dir) {
|
|
|
23761
24254
|
imageMetadata,
|
|
23762
24255
|
importLocal,
|
|
23763
24256
|
importObjectFile,
|
|
24257
|
+
importTileHeights,
|
|
24258
|
+
importTilesFiles,
|
|
24259
|
+
importTilesetFile,
|
|
23764
24260
|
inspectCaches,
|
|
23765
24261
|
inspectQualityProfile,
|
|
23766
24262
|
inspectRevisionReadiness,
|
|
@@ -23827,6 +24323,7 @@ async function workspaceStatus(ws, dir) {
|
|
|
23827
24323
|
pickHistory,
|
|
23828
24324
|
pixMiniMaxCost,
|
|
23829
24325
|
pixelateFile,
|
|
24326
|
+
pngFilesAt,
|
|
23830
24327
|
pngSize,
|
|
23831
24328
|
poll,
|
|
23832
24329
|
portableOutputPath,
|
|
@@ -23891,6 +24388,8 @@ async function workspaceStatus(ws, dir) {
|
|
|
23891
24388
|
runVfxWorkbench,
|
|
23892
24389
|
saveHandEdit,
|
|
23893
24390
|
saveLock,
|
|
24391
|
+
saveToAssetFile,
|
|
24392
|
+
saveUndoDir,
|
|
23894
24393
|
saveWorkspace,
|
|
23895
24394
|
scanAssets,
|
|
23896
24395
|
selectEntryOutput,
|
|
@@ -23921,6 +24420,7 @@ async function workspaceStatus(ws, dir) {
|
|
|
23921
24420
|
tileFeatureOutputCount,
|
|
23922
24421
|
tileVariationCount,
|
|
23923
24422
|
tilesCost,
|
|
24423
|
+
tilesetSheetReadings,
|
|
23924
24424
|
toPortablePath,
|
|
23925
24425
|
totalSpend,
|
|
23926
24426
|
uiElementCandidateCount,
|
|
@@ -23936,6 +24436,7 @@ async function workspaceStatus(ws, dir) {
|
|
|
23936
24436
|
vfxArtistCeiling,
|
|
23937
24437
|
vfxArtistFiles,
|
|
23938
24438
|
vfxArtistFrameFacts,
|
|
24439
|
+
vfxArtistFrameSide,
|
|
23939
24440
|
vfxArtistQuote,
|
|
23940
24441
|
vfxArtistSprite,
|
|
23941
24442
|
vfxAtlasFrames,
|