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.js
CHANGED
|
@@ -280,8 +280,21 @@ var AssetVfxSchema = z.object({
|
|
|
280
280
|
fps: z.number().int().min(1).max(60).optional(),
|
|
281
281
|
name: z.string().min(1).optional(),
|
|
282
282
|
description: z.string().trim().min(1).max(8e3).optional(),
|
|
283
|
-
artist: z.enum(["lite", "pro"]).optional()
|
|
283
|
+
artist: z.enum(["lite", "pro"]).optional(),
|
|
284
|
+
spriteFrames: z.number().int().min(1).max(32).optional(),
|
|
285
|
+
spriteFps: z.number().int().min(1).max(60).optional()
|
|
284
286
|
}).strict().superRefine((vfx, context) => {
|
|
287
|
+
for (const key2 of ["spriteFrames", "spriteFps"]) {
|
|
288
|
+
if (vfx[key2] === void 0) continue;
|
|
289
|
+
if (vfx.description === void 0) {
|
|
290
|
+
context.addIssue({ code: z.ZodIssueCode.custom, message: `${key2} describes the sprite sent to PixelLab's VFX artist; add a description`, path: [key2] });
|
|
291
|
+
} else if (!vfx.sprite) {
|
|
292
|
+
context.addIssue({ code: z.ZodIssueCode.custom, message: `${key2} describes a sprite strip; add a sprite`, path: [key2] });
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
if (vfx.spriteFps !== void 0 && vfx.sprite && vfx.description !== void 0 && (vfx.spriteFrames ?? 1) < 2) {
|
|
296
|
+
context.addIssue({ code: z.ZodIssueCode.custom, message: "spriteFps is the speed of a sprite strip; set spriteFrames to 2 or more", path: ["spriteFps"] });
|
|
297
|
+
}
|
|
285
298
|
if (vfx.description !== void 0) {
|
|
286
299
|
for (const key2 of ["preset", "recipe", "parts", "fps"]) {
|
|
287
300
|
if (vfx[key2] !== void 0) {
|
|
@@ -819,6 +832,33 @@ var StyleObjectSchema = z.object({
|
|
|
819
832
|
* Wall storey height as its own camera angle in degrees (5-90),
|
|
820
833
|
* decoupled from the ground's pitch. */
|
|
821
834
|
buildingWallAngle: z.number().min(5).max(90).optional(),
|
|
835
|
+
/**
|
|
836
|
+
* `tileFeature: "building"` with `buildingLayout: "materials"` only. The
|
|
837
|
+
* shape of the roof pieces' edges: `gable` (a straight slope, the API
|
|
838
|
+
* default) or `round` (curved).
|
|
839
|
+
*/
|
|
840
|
+
buildingRoofProfile: z.enum(["gable", "round"]).optional(),
|
|
841
|
+
/**
|
|
842
|
+
* `tileFeature: "tileset"` on square_topdown, isometric or oblique tiles.
|
|
843
|
+
* Terrain height in pixels, 0 to 12: raises the first terrain into a
|
|
844
|
+
* plateau with a cliff face down to the second. The API refuses a height
|
|
845
|
+
* that does not fit the tile's top face and wall at its size and view.
|
|
846
|
+
*/
|
|
847
|
+
tileElevation: z.number().int().min(0).max(12).optional(),
|
|
848
|
+
/**
|
|
849
|
+
* `tileFeature: "tileset"` with `tileElevation` above 0. How far the drop
|
|
850
|
+
* spreads sideways: 0 a cliff straight down (the default) to 2 a gentle
|
|
851
|
+
* slope.
|
|
852
|
+
*/
|
|
853
|
+
tileStepSlope: z.number().min(0).max(2).optional(),
|
|
854
|
+
/**
|
|
855
|
+
* `tileFeature: "tileset"` only. How far the border between the terrains
|
|
856
|
+
* meanders instead of running straight, 0 (the default) to 0.3. Tiles
|
|
857
|
+
* still connect seamlessly.
|
|
858
|
+
*/
|
|
859
|
+
tileBoundaryAmplitude: z.number().min(0).max(0.3).optional(),
|
|
860
|
+
/** `tileFeature: "tileset"` with `tileBoundaryAmplitude`. Which meander: another number gives a different border. */
|
|
861
|
+
tileBoundarySeed: z.number().int().min(0).optional(),
|
|
822
862
|
/**
|
|
823
863
|
* `tiles` generator only. How tile edges are drawn.
|
|
824
864
|
*
|
|
@@ -2082,6 +2122,53 @@ var ImportObjectSchema = z3.object({
|
|
|
2082
2122
|
size: z3.object({ width: z3.number(), height: z3.number() }).passthrough(),
|
|
2083
2123
|
image_url: z3.string()
|
|
2084
2124
|
}).passthrough();
|
|
2125
|
+
var ImportTilesetSchema = z3.object({ tileset_id: z3.string().min(1), status: z3.string().default("completed") }).passthrough();
|
|
2126
|
+
var ImportTilesProSchema = z3.object({ tile_id: z3.string().min(1), status: z3.string().default("completed") }).passthrough();
|
|
2127
|
+
var SaveToAssetSchema = z3.object({
|
|
2128
|
+
action: z3.enum(["saved", "added", "unchanged"]),
|
|
2129
|
+
target: z3.string().min(1),
|
|
2130
|
+
kind: z3.string(),
|
|
2131
|
+
width: z3.number(),
|
|
2132
|
+
height: z3.number(),
|
|
2133
|
+
frame_count: z3.number(),
|
|
2134
|
+
changed_pixels: z3.number().default(0),
|
|
2135
|
+
previous_frames: z3.array(z3.object({ base64: z3.string().min(1) }).passthrough()).nullable().optional(),
|
|
2136
|
+
note: z3.string().nullable().optional(),
|
|
2137
|
+
maps: z3.string().nullable().optional()
|
|
2138
|
+
}).passthrough();
|
|
2139
|
+
var VocalAnimationSubmitSchema = z3.object({ background_job_id: z3.string().min(1), status: z3.string().default("processing") }).passthrough();
|
|
2140
|
+
var VocalAnimationJobSchema = z3.object({
|
|
2141
|
+
status: z3.string(),
|
|
2142
|
+
mood: z3.string().optional(),
|
|
2143
|
+
viseme_count: z3.number().optional(),
|
|
2144
|
+
character_id: z3.string().nullable().optional(),
|
|
2145
|
+
completed_visemes: z3.array(z3.string()).default([]),
|
|
2146
|
+
visemes: z3.record(z3.string(), z3.object({ base64: z3.string().min(1) }).passthrough()).nullable().optional(),
|
|
2147
|
+
moods_on_character: z3.array(z3.string()).nullable().optional(),
|
|
2148
|
+
grid_url: z3.string().nullable().optional(),
|
|
2149
|
+
viseme_order: z3.array(z3.string()).nullable().optional(),
|
|
2150
|
+
usage: z3.unknown().optional()
|
|
2151
|
+
}).passthrough();
|
|
2152
|
+
var TalkingGifSchema = z3.object({
|
|
2153
|
+
gif_base64: z3.string().min(1),
|
|
2154
|
+
frames: z3.number(),
|
|
2155
|
+
duration_ms: z3.number(),
|
|
2156
|
+
frame_ms: z3.number(),
|
|
2157
|
+
hold_ms: z3.number(),
|
|
2158
|
+
width: z3.number(),
|
|
2159
|
+
height: z3.number(),
|
|
2160
|
+
mood: z3.string().nullable().optional()
|
|
2161
|
+
}).passthrough();
|
|
2162
|
+
var LipSyncSchema = z3.object({
|
|
2163
|
+
text: z3.string(),
|
|
2164
|
+
total_ms: z3.number(),
|
|
2165
|
+
viseme_order: z3.array(z3.string()),
|
|
2166
|
+
frames: z3.array(z3.object({ viseme: z3.string(), column: z3.number(), duration_ms: z3.number(), text_offset: z3.number() }).passthrough()),
|
|
2167
|
+
mood: z3.string().nullable().optional(),
|
|
2168
|
+
grid_url: z3.string().nullable().optional(),
|
|
2169
|
+
row: z3.number().nullable().optional(),
|
|
2170
|
+
rows: z3.number().nullable().optional()
|
|
2171
|
+
}).passthrough();
|
|
2085
2172
|
var ExpandRotationsSchema = z3.object({
|
|
2086
2173
|
object_id: z3.string().min(1),
|
|
2087
2174
|
background_job_id: z3.string().min(1),
|
|
@@ -2590,6 +2677,11 @@ var PixelLabClient = class {
|
|
|
2590
2677
|
if (args.buildingFloorDescription) body.building_floor_description = args.buildingFloorDescription;
|
|
2591
2678
|
if (args.buildingFloor2Description) body.building_floor2_description = args.buildingFloor2Description;
|
|
2592
2679
|
if (args.buildingWallAngle != null) body.building_wall_angle = args.buildingWallAngle;
|
|
2680
|
+
if (args.roofProfile) body.roof_profile = args.roofProfile;
|
|
2681
|
+
if (args.elevation != null) body.elevation = args.elevation;
|
|
2682
|
+
if (args.stepSlope != null) body.step_slope = args.stepSlope;
|
|
2683
|
+
if (args.boundaryAmplitude != null) body.boundary_amplitude = args.boundaryAmplitude;
|
|
2684
|
+
if (args.boundarySeed != null) body.boundary_seed = args.boundarySeed;
|
|
2593
2685
|
if (args.outlineMode) body.outline_mode = args.outlineMode;
|
|
2594
2686
|
if (args.seed != null) body.seed = args.seed;
|
|
2595
2687
|
if (args.styleImages?.length) body.style_images = args.styleImages;
|
|
@@ -3656,6 +3748,8 @@ var PixelLabClient = class {
|
|
|
3656
3748
|
const body = { description: args.description };
|
|
3657
3749
|
if (args.artist) body.artist = args.artist;
|
|
3658
3750
|
if (args.sprite) body.sprite = { type: "base64", base64: args.sprite.base64, format: args.sprite.format };
|
|
3751
|
+
if (args.sprite && args.spriteFrames != null && args.spriteFrames > 1) body.sprite_frames = args.spriteFrames;
|
|
3752
|
+
if (args.sprite && args.spriteFps != null) body.sprite_fps = args.spriteFps;
|
|
3659
3753
|
if (args.effectId) body.effect_id = args.effectId;
|
|
3660
3754
|
if (args.conversation) body.conversation = args.conversation;
|
|
3661
3755
|
if (args.name) body.name = args.name;
|
|
@@ -3800,6 +3894,108 @@ var PixelLabClient = class {
|
|
|
3800
3894
|
"objects/import"
|
|
3801
3895
|
);
|
|
3802
3896
|
}
|
|
3897
|
+
/**
|
|
3898
|
+
* `POST /vocal-animation`: one expression's mouth positions for a portrait,
|
|
3899
|
+
* from an image (nothing stored; the frames come back inline) or from a
|
|
3900
|
+
* character's stored portrait (saved onto it). Paid; `pixminimax` costs 3
|
|
3901
|
+
* generations for 7 positions at any size, `v3` 3 to 24 by size.
|
|
3902
|
+
*/
|
|
3903
|
+
async createVocalAnimation(args) {
|
|
3904
|
+
const body = {};
|
|
3905
|
+
if (args.portrait) body.portrait = { type: "base64", base64: args.portrait.base64, format: args.portrait.format };
|
|
3906
|
+
if (args.characterId) body.character_id = args.characterId;
|
|
3907
|
+
if (args.mood) body.mood = args.mood;
|
|
3908
|
+
if (args.visemeCount != null) body.viseme_count = args.visemeCount;
|
|
3909
|
+
if (args.engine) body.engine = args.engine;
|
|
3910
|
+
if (args.seed != null) body.seed = args.seed;
|
|
3911
|
+
return validateResponse(
|
|
3912
|
+
VocalAnimationSubmitSchema,
|
|
3913
|
+
await this.request("/vocal-animation", { method: "POST", body: JSON.stringify(body) }),
|
|
3914
|
+
"vocal-animation"
|
|
3915
|
+
);
|
|
3916
|
+
}
|
|
3917
|
+
/** `GET /vocal-animation/{job}`: the job's status, and its mouth positions once completed. Its bill is on `getBackgroundJob`. */
|
|
3918
|
+
async getVocalAnimation(jobId) {
|
|
3919
|
+
return validateResponse(VocalAnimationJobSchema, await this.request(`/vocal-animation/${encodeURIComponent(jobId)}`), "vocal-animation/{job}");
|
|
3920
|
+
}
|
|
3921
|
+
/** `POST /talking-gif`: a line of text lip-synced to a GIF from mouth positions already made. Free; answers at once. */
|
|
3922
|
+
async createTalkingGif(args) {
|
|
3923
|
+
const body = { text: args.text };
|
|
3924
|
+
if (args.visemes) {
|
|
3925
|
+
body.visemes = Object.fromEntries(Object.entries(args.visemes).map(([id, image]) => [id, { type: "base64", base64: image.base64, format: image.format }]));
|
|
3926
|
+
}
|
|
3927
|
+
if (args.characterId) body.character_id = args.characterId;
|
|
3928
|
+
if (args.mood) body.mood = args.mood;
|
|
3929
|
+
if (args.frameMs != null) body.frame_ms = args.frameMs;
|
|
3930
|
+
if (args.holdMs != null) body.hold_ms = args.holdMs;
|
|
3931
|
+
return validateResponse(TalkingGifSchema, await this.request("/talking-gif", { method: "POST", body: JSON.stringify(body) }), "talking-gif");
|
|
3932
|
+
}
|
|
3933
|
+
/** `POST /lip-sync`: which mouth position to show and for how long, for a line of text. Free; nothing is rendered. */
|
|
3934
|
+
async getLipSync(args) {
|
|
3935
|
+
const body = { text: args.text };
|
|
3936
|
+
if (args.characterId) body.character_id = args.characterId;
|
|
3937
|
+
if (args.mood) body.mood = args.mood;
|
|
3938
|
+
if (args.visemeCount != null) body.viseme_count = args.visemeCount;
|
|
3939
|
+
if (args.frameMs != null) body.frame_ms = args.frameMs;
|
|
3940
|
+
if (args.holdMs != null) body.hold_ms = args.holdMs;
|
|
3941
|
+
return validateResponse(LipSyncSchema, await this.request("/lip-sync", { method: "POST", body: JSON.stringify(body) }), "lip-sync");
|
|
3942
|
+
}
|
|
3943
|
+
/**
|
|
3944
|
+
* `POST /tilesets/import`: your own Wang sheet as a completed tileset, in
|
|
3945
|
+
* PixelLab's compact 4x4 layout or its 8-wide native one. Free. Send
|
|
3946
|
+
* `tileSize` whenever the sheet reads two ways: omitted, PixelLab takes the
|
|
3947
|
+
* 4x4 reading and cuts a native sheet into the wrong tiles.
|
|
3948
|
+
*/
|
|
3949
|
+
async importTileset(args) {
|
|
3950
|
+
const body = {
|
|
3951
|
+
spritesheet: { type: "base64", base64: args.spritesheet.base64, format: args.spritesheet.format }
|
|
3952
|
+
};
|
|
3953
|
+
if (args.mode) body.tileset_mode = args.mode;
|
|
3954
|
+
if (args.tileSize != null) body.tile_size = { width: args.tileSize, height: args.tileSize };
|
|
3955
|
+
if (args.lowerDescription) body.lower_description = args.lowerDescription;
|
|
3956
|
+
if (args.upperDescription) body.upper_description = args.upperDescription;
|
|
3957
|
+
if (args.transitionDescription) body.transition_description = args.transitionDescription;
|
|
3958
|
+
if (args.name) body.name = args.name;
|
|
3959
|
+
return validateResponse(
|
|
3960
|
+
ImportTilesetSchema,
|
|
3961
|
+
await this.request("/tilesets/import", { method: "POST", body: JSON.stringify(body) }),
|
|
3962
|
+
"tilesets/import"
|
|
3963
|
+
);
|
|
3964
|
+
}
|
|
3965
|
+
/** `POST /tiles-pro/import`: 1 to 32 of your own tile PNGs as one completed tile group. Free. */
|
|
3966
|
+
async importTilesPro(args) {
|
|
3967
|
+
const body = {
|
|
3968
|
+
frames: args.frames.map((frame) => ({ type: "base64", base64: frame.base64, format: frame.format })),
|
|
3969
|
+
tile_type: args.tileType,
|
|
3970
|
+
tile_size: args.tileSize
|
|
3971
|
+
};
|
|
3972
|
+
if (args.description) body.description = args.description;
|
|
3973
|
+
if (args.tileView) body.tile_view = args.tileView;
|
|
3974
|
+
return validateResponse(
|
|
3975
|
+
ImportTilesProSchema,
|
|
3976
|
+
await this.request("/tiles-pro/import", { method: "POST", body: JSON.stringify(body) }),
|
|
3977
|
+
"tiles-pro/import"
|
|
3978
|
+
);
|
|
3979
|
+
}
|
|
3980
|
+
/**
|
|
3981
|
+
* `POST /save-to-asset`: write edited pixels back into a stored character
|
|
3982
|
+
* or object rotation, one direction of an animation, a gallery image or a
|
|
3983
|
+
* tileset sheet, or add a new gallery image (`gallery:new`). Free. The
|
|
3984
|
+
* image must match what it replaces in size and frame count. What was
|
|
3985
|
+
* there comes back as `previous_frames`; saving those again is the undo.
|
|
3986
|
+
*/
|
|
3987
|
+
async saveToAsset(args) {
|
|
3988
|
+
const body = { target: args.target };
|
|
3989
|
+
if (args.image) body.image = { type: "base64", base64: args.image.base64, format: args.image.format };
|
|
3990
|
+
if (args.frames) body.frames = args.frames.map((frame) => ({ type: "base64", base64: frame.base64, format: frame.format }));
|
|
3991
|
+
if (args.name) body.name = args.name;
|
|
3992
|
+
if (args.description) body.description = args.description;
|
|
3993
|
+
return validateResponse(
|
|
3994
|
+
SaveToAssetSchema,
|
|
3995
|
+
await this.request("/save-to-asset", { method: "POST", body: JSON.stringify(body) }),
|
|
3996
|
+
"save-to-asset"
|
|
3997
|
+
);
|
|
3998
|
+
}
|
|
3803
3999
|
/**
|
|
3804
4000
|
* `POST /objects/{id}/expand-rotations`: draw the 7 missing directions of a
|
|
3805
4001
|
* 1-direction object. The object then waits in `review-expansion` until
|
|
@@ -4646,6 +4842,12 @@ function specHash(spec, styleImageHashes, providerOptionIdentity = spec.provider
|
|
|
4646
4842
|
tileType: spec.tileType,
|
|
4647
4843
|
tileView: spec.tileView,
|
|
4648
4844
|
tileFeature: spec.tileFeature,
|
|
4845
|
+
// `tiles` shape options added in November 2026, each only when set.
|
|
4846
|
+
buildingRoofProfile: spec.buildingRoofProfile,
|
|
4847
|
+
tileElevation: spec.tileElevation,
|
|
4848
|
+
tileStepSlope: spec.tileStepSlope,
|
|
4849
|
+
tileBoundaryAmplitude: spec.tileBoundaryAmplitude,
|
|
4850
|
+
tileBoundarySeed: spec.tileBoundarySeed,
|
|
4649
4851
|
outlineMode: spec.outlineMode,
|
|
4650
4852
|
isometricTileSize: spec.isometricTileSize,
|
|
4651
4853
|
isometricTileShape: spec.isometricTileShape,
|
|
@@ -4764,7 +4966,11 @@ function specHash(spec, styleImageHashes, providerOptionIdentity = spec.provider
|
|
|
4764
4966
|
fps: spec.vfx.fps,
|
|
4765
4967
|
sprite: spec.vfx.sprite ? "reference" in spec.vfx.sprite ? spec.vfx.sprite.reference : spec.vfx.sprite.sha256 : void 0,
|
|
4766
4968
|
description: spec.vfx.description,
|
|
4767
|
-
artist: spec.vfx.description ? spec.vfx.artist : void 0
|
|
4969
|
+
artist: spec.vfx.description ? spec.vfx.artist : void 0,
|
|
4970
|
+
// Absent for a still sprite, so every effect made before strips
|
|
4971
|
+
// existed keeps its hash.
|
|
4972
|
+
spriteFrames: spec.vfx.spriteFrames,
|
|
4973
|
+
spriteFps: spec.vfx.spriteFps
|
|
4768
4974
|
} : void 0,
|
|
4769
4975
|
// A mirror's bytes come from its source's recorded outputs; the plan
|
|
4770
4976
|
// compares those directly, so only the choice of source is identity.
|
|
@@ -5184,27 +5390,64 @@ async function makeVfx(client2, opts) {
|
|
|
5184
5390
|
}
|
|
5185
5391
|
var VFX_ARTISTS = ["lite", "pro"];
|
|
5186
5392
|
var VFX_ARTIST_MAX_SPRITE = 512;
|
|
5187
|
-
function vfxArtistQuote(artist, sprite, change = false) {
|
|
5393
|
+
function vfxArtistQuote(artist, sprite, change = false, animated = false) {
|
|
5188
5394
|
const table = {
|
|
5189
5395
|
lite: { new: [1, 1, 3, 5], change: [1, 1, 2, 2] },
|
|
5190
5396
|
pro: { new: [6, 8, 14, 28], change: [4, 4, 5, 8] }
|
|
5191
5397
|
};
|
|
5192
5398
|
const tier = sprite === "none" ? 0 : sprite === "unknown" ? 3 : sprite <= 128 ? 1 : sprite <= 256 ? 2 : 3;
|
|
5193
|
-
|
|
5399
|
+
const base = table[artist][change ? "change" : "new"][tier];
|
|
5400
|
+
return animated && tier > 0 ? base + VFX_ARTIST_ANIMATED_EXTRA[artist][tier - 1] : base;
|
|
5194
5401
|
}
|
|
5402
|
+
var VFX_ARTIST_ANIMATED_EXTRA = { lite: [1, 1, 1], pro: [1, 2, 5] };
|
|
5403
|
+
var VFX_ARTIST_MAX_FRAMES = 32;
|
|
5404
|
+
var VFX_ARTIST_MAX_STRIP = 1024;
|
|
5195
5405
|
function vfxArtistCeiling(quote) {
|
|
5196
5406
|
return quote * 2;
|
|
5197
5407
|
}
|
|
5198
|
-
function
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
|
|
5408
|
+
function gifSize(bytes) {
|
|
5409
|
+
if (bytes.length < 10) return null;
|
|
5410
|
+
const magic = bytes.toString("ascii", 0, 6);
|
|
5411
|
+
if (magic !== "GIF87a" && magic !== "GIF89a") return null;
|
|
5412
|
+
return { width: bytes.readUInt16LE(6), height: bytes.readUInt16LE(8) };
|
|
5413
|
+
}
|
|
5414
|
+
function vfxArtistFrameSide(width, height, frames, label) {
|
|
5415
|
+
if (!Number.isInteger(frames) || frames < 1 || frames > VFX_ARTIST_MAX_FRAMES) {
|
|
5416
|
+
throw new Error(`${label}: a sprite strip holds 1 to ${VFX_ARTIST_MAX_FRAMES} frames, got ${frames}`);
|
|
5417
|
+
}
|
|
5418
|
+
if (width % frames !== 0) {
|
|
5419
|
+
throw new Error(`${label} is ${width}px wide, which does not divide into ${frames} equal frames`);
|
|
5420
|
+
}
|
|
5421
|
+
if (frames > 1 && width > VFX_ARTIST_MAX_STRIP) {
|
|
5422
|
+
throw new Error(
|
|
5423
|
+
`${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`
|
|
5424
|
+
);
|
|
5425
|
+
}
|
|
5426
|
+
const frameWidth = width / frames;
|
|
5427
|
+
const side = Math.max(frameWidth, height);
|
|
5202
5428
|
if (side > VFX_ARTIST_MAX_SPRITE) {
|
|
5203
5429
|
throw new Error(
|
|
5204
|
-
`${label} is ${
|
|
5430
|
+
`${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)`
|
|
5205
5431
|
);
|
|
5206
5432
|
}
|
|
5207
|
-
return
|
|
5433
|
+
return side;
|
|
5434
|
+
}
|
|
5435
|
+
function vfxArtistSprite(bytes, label, frames = 1) {
|
|
5436
|
+
const gif = gifSize(bytes);
|
|
5437
|
+
if (gif) {
|
|
5438
|
+
if (frames !== 1) throw new Error(`${label} is a GIF, which brings its own frames; drop the frame count`);
|
|
5439
|
+
const side2 = Math.max(gif.width, gif.height);
|
|
5440
|
+
if (side2 > VFX_ARTIST_MAX_SPRITE) {
|
|
5441
|
+
throw new Error(
|
|
5442
|
+
`${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)`
|
|
5443
|
+
);
|
|
5444
|
+
}
|
|
5445
|
+
return { image: { base64: bytes.toString("base64"), format: "gif" }, side: side2, animated: true };
|
|
5446
|
+
}
|
|
5447
|
+
const metadata = imageMetadata(bytes);
|
|
5448
|
+
if (metadata?.format !== "png") throw new Error(`${label}: PixelLab's VFX artist takes a PNG or GIF sprite`);
|
|
5449
|
+
const side = vfxArtistFrameSide(metadata.width, metadata.height, frames, label);
|
|
5450
|
+
return { image: { base64: bytes.toString("base64"), format: "png" }, side, animated: frames > 1 };
|
|
5208
5451
|
}
|
|
5209
5452
|
function vfxArtistFiles(raw) {
|
|
5210
5453
|
const urlOf = (value) => {
|
|
@@ -5289,7 +5532,7 @@ async function makeVfxWithArtist(client2, opts) {
|
|
|
5289
5532
|
}
|
|
5290
5533
|
const progress = opts.onProgress ?? (() => {
|
|
5291
5534
|
});
|
|
5292
|
-
const sprite = opts.sprite ? vfxArtistSprite(await readFile(opts.sprite), opts.sprite).image : void 0;
|
|
5535
|
+
const sprite = opts.sprite ? vfxArtistSprite(await readFile(opts.sprite), opts.sprite, opts.spriteFrames ?? 1).image : void 0;
|
|
5293
5536
|
const sleep3 = opts.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
5294
5537
|
const interval = opts.intervalMs ?? 6e3;
|
|
5295
5538
|
const timeout = opts.timeoutMs ?? 10 * 6e4;
|
|
@@ -5297,6 +5540,8 @@ async function makeVfxWithArtist(client2, opts) {
|
|
|
5297
5540
|
description: opts.description,
|
|
5298
5541
|
artist: opts.artist,
|
|
5299
5542
|
sprite,
|
|
5543
|
+
spriteFrames: sprite ? opts.spriteFrames : void 0,
|
|
5544
|
+
spriteFps: sprite ? opts.spriteFps : void 0,
|
|
5300
5545
|
effectId: opts.effect,
|
|
5301
5546
|
conversation: opts.effect ? opts.conversation : void 0,
|
|
5302
5547
|
name: opts.name,
|
|
@@ -5354,6 +5599,8 @@ async function makeVfxWithArtist(client2, opts) {
|
|
|
5354
5599
|
message: result.message,
|
|
5355
5600
|
source: {
|
|
5356
5601
|
...opts.sprite ? { sprite: path.relative(path.dirname(paths.provenance), path.resolve(opts.sprite)).split(path.sep).join("/") } : {},
|
|
5602
|
+
...opts.sprite && opts.spriteFrames && opts.spriteFrames > 1 ? { spriteFrames: opts.spriteFrames } : {},
|
|
5603
|
+
...opts.sprite && opts.spriteFps ? { spriteFps: opts.spriteFps } : {},
|
|
5357
5604
|
...opts.effect ? { changed: opts.effect } : {}
|
|
5358
5605
|
},
|
|
5359
5606
|
...facts,
|
|
@@ -5697,8 +5944,9 @@ function pixelLabObjectUrl(generator, objectId) {
|
|
|
5697
5944
|
}
|
|
5698
5945
|
function vfxArtistSpecQuote(spec) {
|
|
5699
5946
|
const sprite = spec.vfx?.sprite;
|
|
5700
|
-
const
|
|
5701
|
-
|
|
5947
|
+
const frames = spec.vfx?.spriteFrames ?? 1;
|
|
5948
|
+
const side = !sprite ? "none" : "file" in sprite && sprite.width != null && sprite.height != null ? Math.max(Math.ceil(sprite.width / frames), sprite.height) : "unknown";
|
|
5949
|
+
return vfxArtistQuote(spec.vfx?.artist ?? "lite", side, false, frames > 1);
|
|
5702
5950
|
}
|
|
5703
5951
|
function workbenchVfxUrls(exported) {
|
|
5704
5952
|
const sheetFile = exported.files.find((file) => /\.png$/i.test(file));
|
|
@@ -5978,6 +6226,7 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
5978
6226
|
`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)`
|
|
5979
6227
|
);
|
|
5980
6228
|
}
|
|
6229
|
+
if (spec.generator === "tiles") this.validateTileOptions(spec);
|
|
5981
6230
|
const members = spec.revision?.sourceMembers;
|
|
5982
6231
|
if (spec.revision && members && !MEMBER_SET_REVISION_MODES.includes(spec.revision.mode)) {
|
|
5983
6232
|
throw new Error(
|
|
@@ -6249,6 +6498,31 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
6249
6498
|
);
|
|
6250
6499
|
}
|
|
6251
6500
|
}
|
|
6501
|
+
/** Where `/create-tiles-pro`'s newer shape options apply; elsewhere the API ignores or refuses them. */
|
|
6502
|
+
validateTileOptions(spec) {
|
|
6503
|
+
const tilesetOnly = {
|
|
6504
|
+
tileElevation: spec.tileElevation,
|
|
6505
|
+
tileStepSlope: spec.tileStepSlope,
|
|
6506
|
+
tileBoundaryAmplitude: spec.tileBoundaryAmplitude,
|
|
6507
|
+
tileBoundarySeed: spec.tileBoundarySeed
|
|
6508
|
+
};
|
|
6509
|
+
const set = Object.entries(tilesetOnly).filter(([, value]) => value != null).map(([field]) => field);
|
|
6510
|
+
if (set.length && spec.tileFeature !== "tileset") {
|
|
6511
|
+
throw new Error(`PixelLab tiles: ${set.join(", ")} shape a connectable terrain set; set tileFeature: "tileset"`);
|
|
6512
|
+
}
|
|
6513
|
+
if (spec.tileElevation != null && spec.tileElevation > 0 && spec.tileType && !["square_topdown", "isometric", "oblique"].includes(spec.tileType)) {
|
|
6514
|
+
throw new Error(`PixelLab tiles: tileElevation raises a plateau on square_topdown, isometric or oblique tiles, not "${spec.tileType}"`);
|
|
6515
|
+
}
|
|
6516
|
+
if (spec.tileStepSlope != null && !(spec.tileElevation != null && spec.tileElevation > 0)) {
|
|
6517
|
+
throw new Error("PixelLab tiles: tileStepSlope spreads the drop of a raised terrain; set tileElevation above 0");
|
|
6518
|
+
}
|
|
6519
|
+
if (spec.tileBoundarySeed != null && spec.tileBoundaryAmplitude == null) {
|
|
6520
|
+
throw new Error("PixelLab tiles: tileBoundarySeed picks tileBoundaryAmplitude's meander; set both or neither");
|
|
6521
|
+
}
|
|
6522
|
+
if (spec.buildingRoofProfile && !(spec.tileFeature === "building" && spec.buildingLayout === "materials")) {
|
|
6523
|
+
throw new Error(`PixelLab tiles: buildingRoofProfile shapes a building kit's roof pieces; set tileFeature: "building" with buildingLayout: "materials"`);
|
|
6524
|
+
}
|
|
6525
|
+
}
|
|
6252
6526
|
/** `/create-tileset`'s own rules, beyond the enums both terrain endpoints share. */
|
|
6253
6527
|
validateTopDownTerrain(spec) {
|
|
6254
6528
|
if (spec.terrainShapeStyle && spec.terrainMode === "pro") {
|
|
@@ -7139,6 +7413,11 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
7139
7413
|
buildingFloorDescription: spec.buildingFloorDescription,
|
|
7140
7414
|
buildingFloor2Description: spec.buildingFloor2Description,
|
|
7141
7415
|
buildingWallAngle: spec.buildingWallAngle,
|
|
7416
|
+
roofProfile: spec.buildingRoofProfile,
|
|
7417
|
+
elevation: spec.tileElevation,
|
|
7418
|
+
stepSlope: spec.tileStepSlope,
|
|
7419
|
+
boundaryAmplitude: spec.tileBoundaryAmplitude,
|
|
7420
|
+
boundarySeed: spec.tileBoundarySeed,
|
|
7142
7421
|
outlineMode: spec.outlineMode,
|
|
7143
7422
|
seed: spec.seed,
|
|
7144
7423
|
// TilesProStyleImage is flat and wants the reference's real dimensions,
|
|
@@ -7700,11 +7979,20 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
7700
7979
|
if (sha256(bytes) !== vfx.sprite.sha256) {
|
|
7701
7980
|
throw new Error(`vfx sprite changed after the manifest was resolved: ${file}; run the command again`);
|
|
7702
7981
|
}
|
|
7703
|
-
|
|
7982
|
+
const taken = vfxArtistSprite(bytes, `vfx sprite ${file}`, vfx.spriteFrames ?? 1).image;
|
|
7983
|
+
if (taken.format !== "png") throw new Error(`vfx sprite must be a PNG: ${file}`);
|
|
7984
|
+
sprite = { base64: taken.base64, format: "png" };
|
|
7704
7985
|
}
|
|
7705
7986
|
const previous = context?.replacedMetadata?.vfx ?? context?.lastGenerationMetadata?.vfx;
|
|
7706
7987
|
const artist = vfx.artist ?? "lite";
|
|
7707
|
-
const submitted = await this.client.createVfx({
|
|
7988
|
+
const submitted = await this.client.createVfx({
|
|
7989
|
+
description: vfx.description,
|
|
7990
|
+
artist,
|
|
7991
|
+
sprite,
|
|
7992
|
+
spriteFrames: vfx.spriteFrames,
|
|
7993
|
+
spriteFps: vfx.spriteFps,
|
|
7994
|
+
name: vfx.name
|
|
7995
|
+
});
|
|
7708
7996
|
return {
|
|
7709
7997
|
jobId: submitted.background_job_id,
|
|
7710
7998
|
metadata: {
|
|
@@ -11689,6 +11977,11 @@ async function resolveSpecs(loaded, filter) {
|
|
|
11689
11977
|
buildingFloorDescription: generator === "tiles" ? style.buildingFloorDescription : void 0,
|
|
11690
11978
|
buildingFloor2Description: generator === "tiles" ? style.buildingFloor2Description : void 0,
|
|
11691
11979
|
buildingWallAngle: generator === "tiles" ? style.buildingWallAngle : void 0,
|
|
11980
|
+
buildingRoofProfile: generator === "tiles" ? style.buildingRoofProfile : void 0,
|
|
11981
|
+
tileElevation: generator === "tiles" ? style.tileElevation : void 0,
|
|
11982
|
+
tileStepSlope: generator === "tiles" ? style.tileStepSlope : void 0,
|
|
11983
|
+
tileBoundaryAmplitude: generator === "tiles" ? style.tileBoundaryAmplitude : void 0,
|
|
11984
|
+
tileBoundarySeed: generator === "tiles" ? style.tileBoundarySeed : void 0,
|
|
11692
11985
|
outlineMode: generator === "tiles" ? style.outlineMode : void 0,
|
|
11693
11986
|
terrainLowerDescription: generator === "terrain" ? terrainLowerDescription : void 0,
|
|
11694
11987
|
terrainUpperDescription: generator === "terrain" ? terrainUpperDescription : void 0,
|
|
@@ -12306,6 +12599,9 @@ async function resolveVfxShape(root, assetId, vfx, defaultName) {
|
|
|
12306
12599
|
} else if (spriteRef) {
|
|
12307
12600
|
const image = await optionalRevisionImage(spriteRef, `assets.${assetId}.vfx.sprite`, vfx.description ? "png" : void 0);
|
|
12308
12601
|
sprite = { file: spriteRef, sha256: image?.hash ?? null, width: image?.width ?? null, height: image?.height ?? null, format: image?.format ?? null };
|
|
12602
|
+
if (image && vfx.description && (vfx.spriteFrames ?? 1) > 1) {
|
|
12603
|
+
vfxArtistFrameSide(image.width, image.height, vfx.spriteFrames, `assets.${assetId}.vfx.sprite`);
|
|
12604
|
+
}
|
|
12309
12605
|
}
|
|
12310
12606
|
return {
|
|
12311
12607
|
...vfx.preset ? { preset: vfx.preset } : {},
|
|
@@ -12315,7 +12611,10 @@ async function resolveVfxShape(root, assetId, vfx, defaultName) {
|
|
|
12315
12611
|
...vfx.fps !== void 0 ? { fps: vfx.fps } : {},
|
|
12316
12612
|
// The artist caps a name at 80 characters; a long default is cut, not refused.
|
|
12317
12613
|
name: vfx.name ?? (vfx.description ? defaultName.slice(0, 80) : defaultName),
|
|
12318
|
-
...vfx.description ? { description: vfx.description, artist: vfx.artist ?? "lite" } : {}
|
|
12614
|
+
...vfx.description ? { description: vfx.description, artist: vfx.artist ?? "lite" } : {},
|
|
12615
|
+
// A strip of one frame is a still: it is sent, priced and hashed as one.
|
|
12616
|
+
...vfx.spriteFrames !== void 0 && vfx.spriteFrames > 1 ? { spriteFrames: vfx.spriteFrames } : {},
|
|
12617
|
+
...vfx.spriteFps !== void 0 ? { spriteFps: vfx.spriteFps } : {}
|
|
12319
12618
|
};
|
|
12320
12619
|
}
|
|
12321
12620
|
async function optionalRevisionImage(file, label, requiredFormat) {
|
|
@@ -15695,7 +15994,7 @@ async function pullUiAsset(client2, uiAssetId, opts) {
|
|
|
15695
15994
|
|
|
15696
15995
|
// src/pixellab-assets.ts
|
|
15697
15996
|
import { existsSync as existsSync18 } from "fs";
|
|
15698
|
-
import { mkdir as mkdir9, readFile as readFile12, writeFile as writeFile9 } from "fs/promises";
|
|
15997
|
+
import { mkdir as mkdir9, readdir as readdir2, readFile as readFile12, stat as stat2, writeFile as writeFile9 } from "fs/promises";
|
|
15699
15998
|
import path23 from "path";
|
|
15700
15999
|
var ASSET_KINDS = ["object", "character"];
|
|
15701
16000
|
var EXPORT_FORMATS = ["zip", "spritesheet", "aseprite", "gif"];
|
|
@@ -15788,6 +16087,172 @@ async function pullExpansionReview(client2, id, opts) {
|
|
|
15788
16087
|
}
|
|
15789
16088
|
return { dir, existingDirection: review.existing_direction ?? null, files };
|
|
15790
16089
|
}
|
|
16090
|
+
var TILESET_MODES = ["topdown", "sidescroller"];
|
|
16091
|
+
var IMPORT_TILE_TYPES = ["square_topdown", "isometric", "oblique", "hex", "hex_pointy", "octagon"];
|
|
16092
|
+
var IMPORT_TILE_VIEWS = ["top-down", "high top-down", "low top-down", "side"];
|
|
16093
|
+
var SHEET_TILE_SIZES = [16, 24, 32, 48, 64];
|
|
16094
|
+
var IMPORT_MAX_TILES = 32;
|
|
16095
|
+
function tilesetSheetReadings(width, height) {
|
|
16096
|
+
if (height !== width && height !== width * 2) return [];
|
|
16097
|
+
const readings = [];
|
|
16098
|
+
if (SHEET_TILE_SIZES.includes(width / 4)) readings.push({ tileSize: width / 4, layout: "compact" });
|
|
16099
|
+
if (SHEET_TILE_SIZES.includes(width / 8)) readings.push({ tileSize: width / 8, layout: "native" });
|
|
16100
|
+
return readings;
|
|
16101
|
+
}
|
|
16102
|
+
function chooseTilesetSheetReading(file, width, height, tileSize) {
|
|
16103
|
+
const readings = tilesetSheetReadings(width, height);
|
|
16104
|
+
const describe = (reading) => `${reading.tileSize}px tiles (${reading.layout === "compact" ? "4 wide" : "8 wide"})`;
|
|
16105
|
+
if (readings.length === 0) {
|
|
16106
|
+
throw new Error(
|
|
16107
|
+
`${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`
|
|
16108
|
+
);
|
|
16109
|
+
}
|
|
16110
|
+
if (tileSize === void 0) {
|
|
16111
|
+
if (readings.length > 1) {
|
|
16112
|
+
throw new Error(
|
|
16113
|
+
`${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 ")}`
|
|
16114
|
+
);
|
|
16115
|
+
}
|
|
16116
|
+
return readings[0];
|
|
16117
|
+
}
|
|
16118
|
+
const chosen = readings.find((reading) => reading.tileSize === tileSize);
|
|
16119
|
+
if (!chosen) throw new Error(`${file} is ${width}x${height}, which holds ${readings.map(describe).join(" or ")}, not ${tileSize}px tiles`);
|
|
16120
|
+
return chosen;
|
|
16121
|
+
}
|
|
16122
|
+
function readPng(bytes, file) {
|
|
16123
|
+
const metadata = imageMetadata(bytes);
|
|
16124
|
+
if (!metadata || metadata.format !== "png") throw new Error(`${file} is not a PNG`);
|
|
16125
|
+
return metadata;
|
|
16126
|
+
}
|
|
16127
|
+
async function importTilesetFile(client2, file, opts = {}) {
|
|
16128
|
+
const bytes = await readFile12(file);
|
|
16129
|
+
const { width, height } = readPng(bytes, file);
|
|
16130
|
+
const reading = chooseTilesetSheetReading(file, width, height, opts.tileSize);
|
|
16131
|
+
const mode2 = opts.mode ?? "topdown";
|
|
16132
|
+
if (mode2 === "sidescroller" && opts.upperDescription) throw new Error("a sidescroller tileset has one terrain, the platform; drop the upper description");
|
|
16133
|
+
const res = await client2.importTileset({
|
|
16134
|
+
spritesheet: { base64: bytes.toString("base64"), format: "png" },
|
|
16135
|
+
mode: mode2,
|
|
16136
|
+
// PixelLab cannot be told 48, and a 4-wide reading is the one it takes unprompted.
|
|
16137
|
+
tileSize: reading.tileSize === 48 ? void 0 : reading.tileSize,
|
|
16138
|
+
lowerDescription: opts.lowerDescription,
|
|
16139
|
+
upperDescription: opts.upperDescription,
|
|
16140
|
+
transitionDescription: opts.transitionDescription,
|
|
16141
|
+
name: opts.name
|
|
16142
|
+
});
|
|
16143
|
+
return { tilesetId: res.tileset_id, mode: mode2, tileSize: reading.tileSize, layout: reading.layout };
|
|
16144
|
+
}
|
|
16145
|
+
async function pngFilesAt(from) {
|
|
16146
|
+
if (!existsSync18(from)) throw new Error(`${from} does not exist`);
|
|
16147
|
+
if (!(await stat2(from)).isDirectory()) return [from];
|
|
16148
|
+
const names = (await readdir2(from)).filter((name) => /\.png$/i.test(name)).sort((a, b) => a.localeCompare(b, void 0, { numeric: true }));
|
|
16149
|
+
if (names.length === 0) throw new Error(`${from} holds no PNG files`);
|
|
16150
|
+
return names.map((name) => path23.join(from, name));
|
|
16151
|
+
}
|
|
16152
|
+
function importTileHeights(tileType, tileSize) {
|
|
16153
|
+
if (tileType === "square_topdown" || tileType === "octagon") return { min: tileSize, max: tileSize };
|
|
16154
|
+
if (tileType === "oblique") return { min: tileSize, max: tileSize * 2 };
|
|
16155
|
+
return { min: tileSize / 2, max: tileSize * 2 };
|
|
16156
|
+
}
|
|
16157
|
+
async function importTilesFiles(client2, from, opts) {
|
|
16158
|
+
if (!IMPORT_TILE_TYPES.includes(opts.tileType)) throw new Error(`tile type must be one of ${IMPORT_TILE_TYPES.join(", ")}`);
|
|
16159
|
+
if (!Number.isInteger(opts.tileSize) || opts.tileSize < 16 || opts.tileSize > 256) throw new Error("tile size is a whole number from 16 to 256");
|
|
16160
|
+
const files = await pngFilesAt(from);
|
|
16161
|
+
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`);
|
|
16162
|
+
const heights = importTileHeights(opts.tileType, opts.tileSize);
|
|
16163
|
+
const frames = [];
|
|
16164
|
+
for (const file of files) {
|
|
16165
|
+
const bytes = await readFile12(file);
|
|
16166
|
+
const { width, height } = readPng(bytes, file);
|
|
16167
|
+
if (width !== opts.tileSize || height < heights.min || height > heights.max) {
|
|
16168
|
+
const tall = heights.min === heights.max ? `${heights.min}` : `${heights.min} to ${heights.max}`;
|
|
16169
|
+
throw new Error(`${file} is ${width}x${height}; a ${opts.tileSize}px ${opts.tileType} tile is ${opts.tileSize} wide and ${tall} tall`);
|
|
16170
|
+
}
|
|
16171
|
+
frames.push({ base64: bytes.toString("base64"), format: "png" });
|
|
16172
|
+
}
|
|
16173
|
+
const res = await client2.importTilesPro({ frames, tileType: opts.tileType, tileSize: opts.tileSize, description: opts.description, tileView: opts.tileView });
|
|
16174
|
+
return { tileId: res.tile_id, tiles: files.length, files };
|
|
16175
|
+
}
|
|
16176
|
+
function checkSaveTarget(target) {
|
|
16177
|
+
if (!/^(character:[^:]+:[^:]+(:[^:]+)?|object:[^:]+(:[^:]+){0,2}|gallery:[^:]+|tileset:[^:]+)$/.test(target)) {
|
|
16178
|
+
throw new Error(
|
|
16179
|
+
`--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>`
|
|
16180
|
+
);
|
|
16181
|
+
}
|
|
16182
|
+
}
|
|
16183
|
+
function saveUndoDir(target, now = /* @__PURE__ */ new Date()) {
|
|
16184
|
+
const stamp = now.toISOString().replace(/[-:]/g, "").replace(/\.\d+Z$/, "Z");
|
|
16185
|
+
return path23.resolve("pixelkiln-undo", `${target.replace(/[^a-zA-Z0-9-]+/g, "_")}-${stamp}`);
|
|
16186
|
+
}
|
|
16187
|
+
async function writeUndo(frames, dir) {
|
|
16188
|
+
await mkdir9(dir, { recursive: true });
|
|
16189
|
+
const files = [];
|
|
16190
|
+
for (const [index, frame] of frames.entries()) {
|
|
16191
|
+
const file = path23.join(dir, frames.length === 1 ? "previous.png" : `previous-${String(index).padStart(2, "0")}.png`);
|
|
16192
|
+
await writeFile9(file, Buffer.from(frame.base64, "base64"));
|
|
16193
|
+
files.push(file);
|
|
16194
|
+
}
|
|
16195
|
+
return files;
|
|
16196
|
+
}
|
|
16197
|
+
async function saveToAssetFile(client2, target, from, opts = {}) {
|
|
16198
|
+
checkSaveTarget(target);
|
|
16199
|
+
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");
|
|
16200
|
+
const files = await pngFilesAt(from).catch(async (error) => {
|
|
16201
|
+
if (existsSync18(from) && /\.gif$/i.test(from)) return [from];
|
|
16202
|
+
throw error;
|
|
16203
|
+
});
|
|
16204
|
+
let image;
|
|
16205
|
+
let frames;
|
|
16206
|
+
if (files.length === 1) {
|
|
16207
|
+
const bytes = await readFile12(files[0]);
|
|
16208
|
+
const gif = bytes.subarray(0, 4).toString("ascii") === "GIF8";
|
|
16209
|
+
if (!gif) readPng(bytes, files[0]);
|
|
16210
|
+
image = { base64: bytes.toString("base64"), format: gif ? "gif" : "png" };
|
|
16211
|
+
} else {
|
|
16212
|
+
if (files.length > 128) throw new Error(`${from} holds ${files.length} PNGs; PixelLab takes at most 128 frames`);
|
|
16213
|
+
let size;
|
|
16214
|
+
frames = [];
|
|
16215
|
+
for (const file of files) {
|
|
16216
|
+
const bytes = await readFile12(file);
|
|
16217
|
+
const { width, height } = readPng(bytes, file);
|
|
16218
|
+
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`);
|
|
16219
|
+
size = `${width}x${height}`;
|
|
16220
|
+
frames.push({ base64: bytes.toString("base64"), format: "png" });
|
|
16221
|
+
}
|
|
16222
|
+
}
|
|
16223
|
+
const undoDir = opts.undoDir ? path23.resolve(opts.undoDir) : saveUndoDir(target);
|
|
16224
|
+
let res;
|
|
16225
|
+
try {
|
|
16226
|
+
res = await client2.saveToAsset({ target, image, frames, name: opts.name, description: opts.description });
|
|
16227
|
+
} catch (error) {
|
|
16228
|
+
if (error instanceof PixelLabError && error.body.startsWith("{")) {
|
|
16229
|
+
let previous;
|
|
16230
|
+
try {
|
|
16231
|
+
previous = JSON.parse(error.body).detail?.previous_frames;
|
|
16232
|
+
} catch {
|
|
16233
|
+
previous = void 0;
|
|
16234
|
+
}
|
|
16235
|
+
if (Array.isArray(previous) && previous.length && previous.every((frame) => typeof frame?.base64 === "string")) {
|
|
16236
|
+
const written = await writeUndo(previous, undoDir);
|
|
16237
|
+
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`);
|
|
16238
|
+
}
|
|
16239
|
+
}
|
|
16240
|
+
throw error;
|
|
16241
|
+
}
|
|
16242
|
+
const undo = res.action === "saved" && res.previous_frames?.length ? await writeUndo(res.previous_frames, undoDir) : [];
|
|
16243
|
+
return {
|
|
16244
|
+
action: res.action,
|
|
16245
|
+
target: res.target,
|
|
16246
|
+
kind: res.kind,
|
|
16247
|
+
width: res.width,
|
|
16248
|
+
height: res.height,
|
|
16249
|
+
frames: res.frame_count,
|
|
16250
|
+
changedPixels: res.changed_pixels,
|
|
16251
|
+
undo,
|
|
16252
|
+
note: res.note ?? null,
|
|
16253
|
+
maps: res.maps ?? null
|
|
16254
|
+
};
|
|
16255
|
+
}
|
|
15791
16256
|
|
|
15792
16257
|
// src/pipeline/quality-regression.ts
|
|
15793
16258
|
import path24 from "path";
|
|
@@ -16246,7 +16711,7 @@ async function checkQualityBaseline(baselinePath) {
|
|
|
16246
16711
|
|
|
16247
16712
|
// src/pipeline/cache-health.ts
|
|
16248
16713
|
import { existsSync as existsSync23 } from "fs";
|
|
16249
|
-
import { readFile as readFile16, readdir as
|
|
16714
|
+
import { readFile as readFile16, readdir as readdir3, rm as rm6 } from "fs/promises";
|
|
16250
16715
|
import path27 from "path";
|
|
16251
16716
|
|
|
16252
16717
|
// src/cache.ts
|
|
@@ -16854,7 +17319,7 @@ async function inspectContentCache(contentDir, referenced) {
|
|
|
16854
17319
|
return report;
|
|
16855
17320
|
}
|
|
16856
17321
|
const present = /* @__PURE__ */ new Set();
|
|
16857
|
-
const entries = await
|
|
17322
|
+
const entries = await readdir3(contentDir, { withFileTypes: true });
|
|
16858
17323
|
for (const entry of entries) {
|
|
16859
17324
|
if (!entry.isFile()) {
|
|
16860
17325
|
report.invalid.push({ name: entry.name, reason: "not a regular file" });
|
|
@@ -18081,7 +18546,7 @@ async function poll(provider, lock, lockPath, opts = {}) {
|
|
|
18081
18546
|
|
|
18082
18547
|
// src/pipeline/doctor.ts
|
|
18083
18548
|
import { constants, existsSync as existsSync25 } from "fs";
|
|
18084
|
-
import { access, stat as
|
|
18549
|
+
import { access, stat as stat3 } from "fs/promises";
|
|
18085
18550
|
import path30 from "path";
|
|
18086
18551
|
|
|
18087
18552
|
// src/pipeline/install-check.ts
|
|
@@ -18326,7 +18791,7 @@ async function nearestExistingDirectory(start) {
|
|
|
18326
18791
|
let current = start;
|
|
18327
18792
|
for (; ; ) {
|
|
18328
18793
|
try {
|
|
18329
|
-
if ((await
|
|
18794
|
+
if ((await stat3(current)).isDirectory()) return current;
|
|
18330
18795
|
} catch {
|
|
18331
18796
|
}
|
|
18332
18797
|
const parent = path30.dirname(current);
|
|
@@ -18623,7 +19088,7 @@ import { existsSync as existsSync29 } from "fs";
|
|
|
18623
19088
|
import { readFile as readFile21 } from "fs/promises";
|
|
18624
19089
|
|
|
18625
19090
|
// src/pipeline/init.ts
|
|
18626
|
-
import { readdir as
|
|
19091
|
+
import { readdir as readdir4, readFile as readFile19, writeFile as writeFile13 } from "fs/promises";
|
|
18627
19092
|
import { existsSync as existsSync28 } from "fs";
|
|
18628
19093
|
import path33 from "path";
|
|
18629
19094
|
function pngSize(buf) {
|
|
@@ -18638,7 +19103,7 @@ function slugify(value) {
|
|
|
18638
19103
|
}
|
|
18639
19104
|
async function walk(dir, exclude) {
|
|
18640
19105
|
const out = [];
|
|
18641
|
-
for (const entry of await
|
|
19106
|
+
for (const entry of await readdir4(dir, { withFileTypes: true })) {
|
|
18642
19107
|
const full = path33.join(dir, entry.name);
|
|
18643
19108
|
if (exclude.some((x) => full.includes(x))) continue;
|
|
18644
19109
|
if (entry.isDirectory()) out.push(...await walk(full, exclude));
|
|
@@ -19420,7 +19885,7 @@ async function runPicker(provider, lock, lockPath, opts = {}) {
|
|
|
19420
19885
|
// src/gallery/snapshot.ts
|
|
19421
19886
|
import { createHash as createHash5 } from "crypto";
|
|
19422
19887
|
import { existsSync as existsSync35 } from "fs";
|
|
19423
|
-
import { readFile as readFile28, stat as
|
|
19888
|
+
import { readFile as readFile28, stat as stat4 } from "fs/promises";
|
|
19424
19889
|
import path41 from "path";
|
|
19425
19890
|
|
|
19426
19891
|
// src/workspace.ts
|
|
@@ -20858,7 +21323,7 @@ function describeCharacter(spec, entry) {
|
|
|
20858
21323
|
}
|
|
20859
21324
|
async function fileInfo(absolutePath) {
|
|
20860
21325
|
try {
|
|
20861
|
-
const info = await
|
|
21326
|
+
const info = await stat4(absolutePath);
|
|
20862
21327
|
return info.isFile() ? { bytes: info.size, modifiedAt: info.mtime.toISOString() } : null;
|
|
20863
21328
|
} catch {
|
|
20864
21329
|
return null;
|
|
@@ -21545,7 +22010,7 @@ var EDITOR_RELEASE_BASE = "https://github.com/gfargo/pixelkiln/releases/download
|
|
|
21545
22010
|
// src/editor/install.ts
|
|
21546
22011
|
import { createHash as createHash6 } from "crypto";
|
|
21547
22012
|
import { existsSync as existsSync37 } from "fs";
|
|
21548
|
-
import { mkdir as mkdir16, readFile as readFile29, rename as rename11, rm as rm12, stat as
|
|
22013
|
+
import { mkdir as mkdir16, readFile as readFile29, rename as rename11, rm as rm12, stat as stat5, writeFile as writeFile21 } from "fs/promises";
|
|
21549
22014
|
import os3 from "os";
|
|
21550
22015
|
import path42 from "path";
|
|
21551
22016
|
var EditorInstallError = class extends Error {
|
|
@@ -21590,7 +22055,7 @@ async function editorStatus(opts = {}) {
|
|
|
21590
22055
|
for (const [name, expected] of Object.entries(pin.files)) {
|
|
21591
22056
|
totalBytes += expected.bytes;
|
|
21592
22057
|
const file = path42.join(dir, name);
|
|
21593
|
-
const info = existsSync37(file) ? await
|
|
22058
|
+
const info = existsSync37(file) ? await stat5(file).catch(() => null) : null;
|
|
21594
22059
|
if (info && info.size === expected.bytes && await sha256Of(file) === expected.sha256) {
|
|
21595
22060
|
installedBytes += expected.bytes;
|
|
21596
22061
|
} else {
|
|
@@ -23149,6 +23614,9 @@ export {
|
|
|
23149
23614
|
HISTORY_ENV,
|
|
23150
23615
|
HandEditCompanionSchema,
|
|
23151
23616
|
IMPORT_MAX_SIDE,
|
|
23617
|
+
IMPORT_MAX_TILES,
|
|
23618
|
+
IMPORT_TILE_TYPES,
|
|
23619
|
+
IMPORT_TILE_VIEWS,
|
|
23152
23620
|
ImageQualityMetricsSchema,
|
|
23153
23621
|
InheritedStyleSchema,
|
|
23154
23622
|
LockEntrySchema,
|
|
@@ -23217,6 +23685,7 @@ export {
|
|
|
23217
23685
|
StyleInputSchema,
|
|
23218
23686
|
StyleSchema,
|
|
23219
23687
|
TARGET_PALETTE_GENERATORS,
|
|
23688
|
+
TILESET_MODES,
|
|
23220
23689
|
TerrainConnectSchema,
|
|
23221
23690
|
TerrainLinkSchema,
|
|
23222
23691
|
TerrainSideSchema,
|
|
@@ -23231,7 +23700,10 @@ export {
|
|
|
23231
23700
|
UnsupportedCapabilityError,
|
|
23232
23701
|
UsageError,
|
|
23233
23702
|
VFX_ARTISTS,
|
|
23703
|
+
VFX_ARTIST_ANIMATED_EXTRA,
|
|
23704
|
+
VFX_ARTIST_MAX_FRAMES,
|
|
23234
23705
|
VFX_ARTIST_MAX_SPRITE,
|
|
23706
|
+
VFX_ARTIST_MAX_STRIP,
|
|
23235
23707
|
VFX_TOOL,
|
|
23236
23708
|
VfxPartSchema,
|
|
23237
23709
|
WorkspaceProjectSchema,
|
|
@@ -23256,7 +23728,9 @@ export {
|
|
|
23256
23728
|
checkExportBytes,
|
|
23257
23729
|
checkQualityBaseline,
|
|
23258
23730
|
checkQualityRecord,
|
|
23731
|
+
checkSaveTarget,
|
|
23259
23732
|
checkUiInsets,
|
|
23733
|
+
chooseTilesetSheetReading,
|
|
23260
23734
|
clientFromEnv,
|
|
23261
23735
|
colorDistance,
|
|
23262
23736
|
countNumberedDescriptions,
|
|
@@ -23305,6 +23779,7 @@ export {
|
|
|
23305
23779
|
generateMusic,
|
|
23306
23780
|
generateSoundEffect,
|
|
23307
23781
|
generationCost,
|
|
23782
|
+
gifSize,
|
|
23308
23783
|
groupOrphansByStyle,
|
|
23309
23784
|
handEditBase,
|
|
23310
23785
|
handEditBases,
|
|
@@ -23319,6 +23794,9 @@ export {
|
|
|
23319
23794
|
imageMetadata,
|
|
23320
23795
|
importLocal,
|
|
23321
23796
|
importObjectFile,
|
|
23797
|
+
importTileHeights,
|
|
23798
|
+
importTilesFiles,
|
|
23799
|
+
importTilesetFile,
|
|
23322
23800
|
inspectCaches,
|
|
23323
23801
|
inspectQualityProfile,
|
|
23324
23802
|
inspectRevisionReadiness,
|
|
@@ -23385,6 +23863,7 @@ export {
|
|
|
23385
23863
|
pickHistory,
|
|
23386
23864
|
pixMiniMaxCost,
|
|
23387
23865
|
pixelateFile,
|
|
23866
|
+
pngFilesAt,
|
|
23388
23867
|
pngSize,
|
|
23389
23868
|
poll,
|
|
23390
23869
|
portableOutputPath,
|
|
@@ -23449,6 +23928,8 @@ export {
|
|
|
23449
23928
|
runVfxWorkbench,
|
|
23450
23929
|
saveHandEdit,
|
|
23451
23930
|
saveLock,
|
|
23931
|
+
saveToAssetFile,
|
|
23932
|
+
saveUndoDir,
|
|
23452
23933
|
saveWorkspace,
|
|
23453
23934
|
scanAssets,
|
|
23454
23935
|
selectEntryOutput,
|
|
@@ -23479,6 +23960,7 @@ export {
|
|
|
23479
23960
|
tileFeatureOutputCount,
|
|
23480
23961
|
tileVariationCount,
|
|
23481
23962
|
tilesCost,
|
|
23963
|
+
tilesetSheetReadings,
|
|
23482
23964
|
toPortablePath,
|
|
23483
23965
|
totalSpend,
|
|
23484
23966
|
uiElementCandidateCount,
|
|
@@ -23494,6 +23976,7 @@ export {
|
|
|
23494
23976
|
vfxArtistCeiling,
|
|
23495
23977
|
vfxArtistFiles,
|
|
23496
23978
|
vfxArtistFrameFacts,
|
|
23979
|
+
vfxArtistFrameSide,
|
|
23497
23980
|
vfxArtistQuote,
|
|
23498
23981
|
vfxArtistSprite,
|
|
23499
23982
|
vfxAtlasFrames,
|