pixelkiln 0.146.0 → 0.148.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 +4 -4
- package/dist/cli.js +246 -101
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +144 -50
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +293 -194
- package/dist/index.d.ts +293 -194
- package/dist/index.js +151 -57
- package/dist/index.js.map +1 -1
- package/docs/CHARACTERS.md +55 -0
- package/docs/CLI.md +25 -3
- package/docs/ENDPOINTS.md +14 -3
- package/docs/GENERATORS.md +1 -1
- package/docs/GETTING_STARTED.md +5 -0
- package/docs/MANIFEST.md +2 -2
- package/package.json +1 -1
- package/schema/manifest.schema.json +7 -1
- package/skills/pixelkiln/SKILL.md +4 -0
- package/skills/pixelkiln/references/pixellab.md +18 -4
package/dist/index.cjs
CHANGED
|
@@ -580,14 +580,13 @@ function proTierCost(width, height) {
|
|
|
580
580
|
if (px <= 102400) return PRO_TIER_PRICES[1];
|
|
581
581
|
return PRO_TIER_PRICES[2];
|
|
582
582
|
}
|
|
583
|
+
var PIXMINIMAX_STEPS = [1, 1, 2, 2, 3, 3, 4, 5, 5, 6];
|
|
583
584
|
function pixMiniMaxCost(width, height, frames, enhancePrompt = false) {
|
|
584
|
-
const
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
else units = 6 + (f - 40) / 6;
|
|
590
|
-
const base = Math.max(1, Math.ceil(units - 1e-9));
|
|
585
|
+
const side = Math.max(1, width, height);
|
|
586
|
+
const upscaled = side * (side <= 64 ? 4 : side <= 128 ? 2 : 1);
|
|
587
|
+
const reference = Math.max(1, frames) * upscaled * upscaled / 65536;
|
|
588
|
+
const step = Math.max(1, Math.ceil(reference / 4 - 1e-9));
|
|
589
|
+
const base = PIXMINIMAX_STEPS[Math.min(step, PIXMINIMAX_STEPS.length) - 1];
|
|
591
590
|
return enhancePrompt ? base + 0.05 : base;
|
|
592
591
|
}
|
|
593
592
|
function tilesCost(tileSize, variations) {
|
|
@@ -682,7 +681,7 @@ var CharacterProportionsSchema = import_zod.z.union([
|
|
|
682
681
|
hipWidth: import_zod.z.number().min(0.5).max(2).optional()
|
|
683
682
|
}).strict()
|
|
684
683
|
]);
|
|
685
|
-
var CharacterAnimationModeSchema = import_zod.z.enum(["template", "skeleton-v3", "v3", "pro"]);
|
|
684
|
+
var CharacterAnimationModeSchema = import_zod.z.enum(["template", "skeleton-v3", "v3", "pixminimax", "pro"]);
|
|
686
685
|
var UiPieceSchema = import_zod.z.discriminatedUnion("kind", [
|
|
687
686
|
import_zod.z.object({
|
|
688
687
|
id: import_zod.z.string().min(1),
|
|
@@ -1006,12 +1005,13 @@ var CharacterAnimationSchema = import_zod.z.object({
|
|
|
1006
1005
|
motionFrom: import_zod.z.string().min(1).optional(),
|
|
1007
1006
|
/**
|
|
1008
1007
|
* Frames to generate without a template. A v3 loop takes an even 4 to 16;
|
|
1009
|
-
* a
|
|
1008
|
+
* a pixminimax loop a multiple of 4 from 4 to 40; a sentence loop
|
|
1009
|
+
* (`mode: "skeleton-v3"` with no `template`) takes 3 to 15.
|
|
1010
1010
|
*/
|
|
1011
|
-
frames: import_zod.z.number().int().min(3).max(
|
|
1011
|
+
frames: import_zod.z.number().int().min(3).max(40).optional(),
|
|
1012
1012
|
/** Playback rate recorded with the frames; PixelLab does not store one. */
|
|
1013
1013
|
fps: import_zod.z.number().int().min(1).max(60).default(8),
|
|
1014
|
-
/** v3
|
|
1014
|
+
/** v3 and pixminimax: keep the resting pose as frame 0, so `frames` generated frames land as `frames + 1` files. */
|
|
1015
1015
|
keepFirstFrame: import_zod.z.boolean().default(true),
|
|
1016
1016
|
/**
|
|
1017
1017
|
* `character` loops: strip the ghost pixels an animation model leaves
|
|
@@ -1025,28 +1025,41 @@ var CharacterAnimationSchema = import_zod.z.object({
|
|
|
1025
1025
|
* `template` when a template is named, otherwise `v3`; `skeleton-v3`
|
|
1026
1026
|
* poses a template with PixelLab's skeleton model instead, or, with no
|
|
1027
1027
|
* template, animates the asset's prompt as a sentence written into one 3D
|
|
1028
|
-
* motion (a v3 base; 3-15 `frames`); `
|
|
1029
|
-
*
|
|
1028
|
+
* motion (a v3 base; 3-15 `frames`); `pixminimax` draws from the
|
|
1029
|
+
* prompt on PixelLab's PixMiniMax engine (4 to 40 `frames`, a multiple
|
|
1030
|
+
* of 4); `pro` for the sequential high-quality engine.
|
|
1030
1031
|
*/
|
|
1031
1032
|
mode: CharacterAnimationModeSchema.optional(),
|
|
1032
1033
|
/**
|
|
1033
|
-
* v3
|
|
1034
|
-
* of the character's rotation for this direction. Up to 256px.
|
|
1034
|
+
* v3 and pixminimax: a manifest-relative image of the pose to start from,
|
|
1035
|
+
* instead of the character's rotation for this direction. Up to 256px.
|
|
1035
1036
|
*/
|
|
1036
1037
|
startFrame: import_zod.z.string().min(1).optional(),
|
|
1037
1038
|
/**
|
|
1038
|
-
* v3
|
|
1039
|
-
* start frame (the rotation, or `startFrame`) to this image,
|
|
1040
|
-
* be the same size as the start frame.
|
|
1039
|
+
* v3 and pixminimax: a pose to animate toward. The loop then interpolates
|
|
1040
|
+
* from the start frame (the rotation, or `startFrame`) to this image,
|
|
1041
|
+
* which must be the same size as the start frame. The same image as
|
|
1042
|
+
* `startFrame` closes a loop.
|
|
1041
1043
|
*/
|
|
1042
1044
|
endFrame: import_zod.z.string().min(1).optional(),
|
|
1043
|
-
/**
|
|
1045
|
+
/**
|
|
1046
|
+
* What is being animated, when the character's own description would
|
|
1047
|
+
* mislead the model. On a pixminimax loop it is PixelLab's
|
|
1048
|
+
* `subject_description`, one noun phrase of up to 300 characters; left
|
|
1049
|
+
* out, PixelLab reads it off the start frame.
|
|
1050
|
+
*/
|
|
1044
1051
|
subject: import_zod.z.string().min(1).optional(),
|
|
1052
|
+
/**
|
|
1053
|
+
* pixminimax only: the pose the start frame shows, up to 300 characters
|
|
1054
|
+
* ("standing beside the pole, one hand on it"). Left out, PixelLab reads
|
|
1055
|
+
* it off the image.
|
|
1056
|
+
*/
|
|
1057
|
+
initialPose: import_zod.z.string().min(1).max(300).optional(),
|
|
1045
1058
|
/** Template mode only: style hints for this loop, over the character's own. */
|
|
1046
1059
|
outline: import_zod.z.string().min(1).optional(),
|
|
1047
1060
|
shading: import_zod.z.string().min(1).optional(),
|
|
1048
1061
|
detail: import_zod.z.string().min(1).optional(),
|
|
1049
|
-
/** v3 text loops only: let PixelLab expand the action into a fuller motion description first. */
|
|
1062
|
+
/** v3 and pixminimax text loops only: let PixelLab expand the action into a fuller motion description first. */
|
|
1050
1063
|
enhancePrompt: import_zod.z.boolean().optional()
|
|
1051
1064
|
}).strict().superRefine((animation, context) => {
|
|
1052
1065
|
if (animation.directions !== void 0) {
|
|
@@ -1057,22 +1070,29 @@ var CharacterAnimationSchema = import_zod.z.object({
|
|
|
1057
1070
|
});
|
|
1058
1071
|
}
|
|
1059
1072
|
const sentence = animation.mode === "skeleton-v3" && !animation.template;
|
|
1060
|
-
|
|
1073
|
+
const pixminimax = animation.mode === "pixminimax";
|
|
1074
|
+
if (animation.frames !== void 0 && pixminimax) {
|
|
1075
|
+
if (animation.frames % 4 !== 0 || animation.frames < 4) {
|
|
1076
|
+
context.addIssue({ code: import_zod.z.ZodIssueCode.custom, message: "a pixminimax loop takes a multiple of 4 frames, 4 to 40", path: ["frames"] });
|
|
1077
|
+
}
|
|
1078
|
+
} else if (animation.frames !== void 0 && !sentence && animation.mode !== "pro") {
|
|
1061
1079
|
if (animation.frames % 2 !== 0) {
|
|
1062
1080
|
context.addIssue({ code: import_zod.z.ZodIssueCode.custom, message: "frames must be even", path: ["frames"] });
|
|
1063
|
-
} else if (animation.frames < 4) {
|
|
1064
|
-
context.addIssue({ code: import_zod.z.ZodIssueCode.custom, message: "frames must be 4 to 16", path: ["frames"] });
|
|
1081
|
+
} else if (animation.frames < 4 || animation.frames > 16) {
|
|
1082
|
+
context.addIssue({ code: import_zod.z.ZodIssueCode.custom, message: "frames must be 4 to 16 (a pixminimax loop takes up to 40)", path: ["frames"] });
|
|
1065
1083
|
}
|
|
1084
|
+
} else if (animation.frames !== void 0 && animation.mode === "pro" && animation.frames > 16) {
|
|
1085
|
+
context.addIssue({ code: import_zod.z.ZodIssueCode.custom, message: "frames must be 16 or fewer", path: ["frames"] });
|
|
1066
1086
|
}
|
|
1067
1087
|
if (animation.frames !== void 0 && sentence && animation.frames > 15) {
|
|
1068
1088
|
context.addIssue({ code: import_zod.z.ZodIssueCode.custom, message: "a skeleton-v3 loop from a sentence takes 3 to 15 frames", path: ["frames"] });
|
|
1069
1089
|
}
|
|
1070
1090
|
const mode2 = animation.mode ?? (animation.template ? "template" : "v3");
|
|
1071
1091
|
for (const key3 of ["startFrame", "endFrame", "enhancePrompt"]) {
|
|
1072
|
-
if (animation[key3] !== void 0 && mode2 !== "v3") {
|
|
1092
|
+
if (animation[key3] !== void 0 && mode2 !== "v3" && mode2 !== "pixminimax") {
|
|
1073
1093
|
context.addIssue({
|
|
1074
1094
|
code: import_zod.z.ZodIssueCode.custom,
|
|
1075
|
-
message: `${key3} is for v3 loops; a ${mode2} loop ${mode2 === "template" || mode2 === "skeleton-v3" ? `starts from the character's rotation and ${animation.template ? "follows its template" : "animates its sentence"}` : "takes neither"}`,
|
|
1095
|
+
message: `${key3} is for v3 and pixminimax loops; a ${mode2} loop ${mode2 === "template" || mode2 === "skeleton-v3" ? `starts from the character's rotation and ${animation.template ? "follows its template" : "animates its sentence"}` : "takes neither"}`,
|
|
1076
1096
|
path: [key3]
|
|
1077
1097
|
});
|
|
1078
1098
|
}
|
|
@@ -1082,6 +1102,12 @@ var CharacterAnimationSchema = import_zod.z.object({
|
|
|
1082
1102
|
context.addIssue({ code: import_zod.z.ZodIssueCode.custom, message: `${key3} overrides apply to template loops only`, path: [key3] });
|
|
1083
1103
|
}
|
|
1084
1104
|
}
|
|
1105
|
+
if (animation.initialPose !== void 0 && mode2 !== "pixminimax") {
|
|
1106
|
+
context.addIssue({ code: import_zod.z.ZodIssueCode.custom, message: `initialPose is for pixminimax loops; PixelLab's ${mode2} engine takes no pose caption`, path: ["initialPose"] });
|
|
1107
|
+
}
|
|
1108
|
+
if (pixminimax && animation.subject !== void 0 && animation.subject.length > 300) {
|
|
1109
|
+
context.addIssue({ code: import_zod.z.ZodIssueCode.custom, message: "a pixminimax loop's subject is one noun phrase of up to 300 characters", path: ["subject"] });
|
|
1110
|
+
}
|
|
1085
1111
|
if (animation.template && animation.mode && animation.mode !== "template" && animation.mode !== "skeleton-v3") {
|
|
1086
1112
|
context.addIssue({
|
|
1087
1113
|
code: import_zod.z.ZodIssueCode.custom,
|
|
@@ -4194,8 +4220,11 @@ var PixelLabClient = class {
|
|
|
4194
4220
|
* One animation of one character. Template mode costs a generation per
|
|
4195
4221
|
* direction and fixes the frame count; skeleton-v3 poses the same template
|
|
4196
4222
|
* with the skeleton video model (2-4 generations per direction); v3 draws
|
|
4197
|
-
* `frameCount` frames from the action text;
|
|
4198
|
-
*
|
|
4223
|
+
* `frameCount` frames from the action text; pixminimax does the same on
|
|
4224
|
+
* PixelLab's PixMiniMax engine (a multiple of 4 frames up to 40, the same
|
|
4225
|
+
* start/end frames, `keep_first_frame` and `enhance_prompt`, plus its own
|
|
4226
|
+
* `subject_description` and `initial_pose` captions); pro is the
|
|
4227
|
+
* sequential engine. One job per direction.
|
|
4199
4228
|
*
|
|
4200
4229
|
* Every mode but skeleton-v3 goes to `/animate-character`, the path whose
|
|
4201
4230
|
* shapes were measured live. skeleton-v3 is documented only on
|
|
@@ -4211,6 +4240,7 @@ var PixelLabClient = class {
|
|
|
4211
4240
|
async animateCharacter(args) {
|
|
4212
4241
|
const encode = (image) => ({ type: "base64", base64: image.base64, format: image.format });
|
|
4213
4242
|
const endpoint = args.mode === "skeleton-v3" ? "/characters/animations" : "/animate-character";
|
|
4243
|
+
const custom = args.mode === "v3" || args.mode === "pixminimax";
|
|
4214
4244
|
const raw = await this.request(endpoint, {
|
|
4215
4245
|
method: "POST",
|
|
4216
4246
|
body: JSON.stringify({
|
|
@@ -4222,12 +4252,14 @@ var PixelLabClient = class {
|
|
|
4222
4252
|
...args.template ? { template_animation_id: args.template } : {},
|
|
4223
4253
|
...args.actionDescription ? { action_description: args.actionDescription } : {},
|
|
4224
4254
|
...args.description ? { description: args.description } : {},
|
|
4225
|
-
// A template fixes its own frame count; v3 and a skeleton-v3 sentence take one.
|
|
4226
|
-
...(
|
|
4227
|
-
...
|
|
4228
|
-
...
|
|
4229
|
-
...
|
|
4230
|
-
...
|
|
4255
|
+
// A template fixes its own frame count; v3, pixminimax and a skeleton-v3 sentence take one.
|
|
4256
|
+
...(custom || args.mode === "skeleton-v3" && !args.template) && args.frameCount ? { frame_count: args.frameCount } : {},
|
|
4257
|
+
...custom && args.keepFirstFrame === false ? { keep_first_frame: false } : {},
|
|
4258
|
+
...custom && args.startFrame ? { custom_start_frame: encode(args.startFrame) } : {},
|
|
4259
|
+
...custom && args.endFrame ? { end_frame: encode(args.endFrame) } : {},
|
|
4260
|
+
...custom && args.enhancePrompt ? { enhance_prompt: true } : {},
|
|
4261
|
+
...args.mode === "pixminimax" && args.subjectDescription ? { subject_description: args.subjectDescription } : {},
|
|
4262
|
+
...args.mode === "pixminimax" && args.initialPose ? { initial_pose: args.initialPose } : {},
|
|
4231
4263
|
...args.mode === "template" && args.textGuidanceScale !== void 0 ? { text_guidance_scale: args.textGuidanceScale } : {},
|
|
4232
4264
|
...args.mode === "template" && args.outline ? { outline: args.outline } : {},
|
|
4233
4265
|
...args.mode === "template" && args.shading ? { shading: args.shading } : {},
|
|
@@ -8580,6 +8612,13 @@ function characterCost(spec) {
|
|
|
8580
8612
|
if (animation.mode === "template") return 1;
|
|
8581
8613
|
if (animation.mode === "skeleton-v3") return 4;
|
|
8582
8614
|
if (animation.mode === "v3") return Math.max(1, Math.ceil(px * animation.frames / 65536));
|
|
8615
|
+
if (animation.mode === "pixminimax") {
|
|
8616
|
+
const start = animation.startFrame;
|
|
8617
|
+
return Math.max(
|
|
8618
|
+
pixMiniMaxCost(spec.width, spec.height, animation.frames, animation.enhancePrompt),
|
|
8619
|
+
start ? pixMiniMaxCost(start.width, start.height, animation.frames, animation.enhancePrompt) : 0
|
|
8620
|
+
);
|
|
8621
|
+
}
|
|
8583
8622
|
return proCharacterTierCost(spec.width, spec.height);
|
|
8584
8623
|
}
|
|
8585
8624
|
if (character.kind === "state" || character.kind === "portrait") return proCharacterTierCost(spec.width, spec.height);
|
|
@@ -9321,7 +9360,7 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
9321
9360
|
const { startFrame, endFrame } = character.animation;
|
|
9322
9361
|
for (const [name, image] of [["start frame", startFrame], ["end frame", endFrame]]) {
|
|
9323
9362
|
if (image && (image.width > 256 || image.height > 256)) {
|
|
9324
|
-
throw new Error(`${label}: ${name} is ${image.width}x${image.height}; PixelLab
|
|
9363
|
+
throw new Error(`${label}: ${name} is ${image.width}x${image.height}; PixelLab ${character.animation.mode} takes up to 256px`);
|
|
9325
9364
|
}
|
|
9326
9365
|
}
|
|
9327
9366
|
if (endFrame) {
|
|
@@ -9436,6 +9475,9 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
9436
9475
|
`${spec.styleId}/${spec.assetId} needs a prompt describing the motion, or a template` + (sentence ? ' (a skeleton-v3 loop with no template animates its prompt, e.g. "swinging a sword in a wide arc")' : "")
|
|
9437
9476
|
);
|
|
9438
9477
|
}
|
|
9478
|
+
if (character.animation.mode === "pixminimax" && (character.animation.frames % 4 !== 0 || character.animation.frames < 4 || character.animation.frames > 40)) {
|
|
9479
|
+
throw new Error(`${spec.styleId}/${spec.assetId}: a pixminimax loop takes a multiple of 4 frames, 4 to 40; ${character.animation.frames} is not one`);
|
|
9480
|
+
}
|
|
9439
9481
|
if (sentence && (character.animation.frames < 3 || character.animation.frames > 15)) {
|
|
9440
9482
|
throw new Error(`${spec.styleId}/${spec.assetId}: a skeleton-v3 loop from a sentence takes 3 to 15 frames; ${character.animation.frames} is out of range`);
|
|
9441
9483
|
}
|
|
@@ -9747,7 +9789,9 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
9747
9789
|
isometric: character.isometric,
|
|
9748
9790
|
startFrame: animation.startFrame ? readPose(spec, "start frame", animation.startFrame) : void 0,
|
|
9749
9791
|
endFrame: animation.endFrame ? readPose(spec, "end frame", animation.endFrame) : void 0,
|
|
9750
|
-
|
|
9792
|
+
// PixMiniMax captions its start frame with its own two fields; the
|
|
9793
|
+
// other engines take `subject` as the general `description`.
|
|
9794
|
+
...animation.mode === "pixminimax" ? { subjectDescription: animation.subject, initialPose: animation.initialPose } : { description: animation.subject },
|
|
9751
9795
|
outline: animation.outline,
|
|
9752
9796
|
shading: animation.shading,
|
|
9753
9797
|
detail: animation.detail,
|
|
@@ -15726,6 +15770,8 @@ async function resolveCharacterShape(asset, style, kind, files) {
|
|
|
15726
15770
|
...asset.animation.startFrame ? { startFrame: await pose(asset.animation.startFrame, "Animation start frame") } : {},
|
|
15727
15771
|
...asset.animation.endFrame ? { endFrame: await pose(asset.animation.endFrame, "Animation end frame") } : {},
|
|
15728
15772
|
...asset.animation.subject ? { subject: asset.animation.subject } : {},
|
|
15773
|
+
// Set only on a pixminimax loop (the schema refuses it elsewhere), so no other spec's hash moves.
|
|
15774
|
+
...asset.animation.initialPose ? { initialPose: asset.animation.initialPose } : {},
|
|
15729
15775
|
...asset.animation.outline ? { outline: asset.animation.outline } : {},
|
|
15730
15776
|
...asset.animation.shading ? { shading: asset.animation.shading } : {},
|
|
15731
15777
|
...asset.animation.detail ? { detail: asset.animation.detail } : {},
|
|
@@ -15764,6 +15810,7 @@ async function resolveObjectProShape(assetId, asset, style, kind, files) {
|
|
|
15764
15810
|
for (const [field, value] of Object.entries({
|
|
15765
15811
|
template: asset.animation.template,
|
|
15766
15812
|
subject: asset.animation.subject,
|
|
15813
|
+
initialPose: asset.animation.initialPose,
|
|
15767
15814
|
outline: asset.animation.outline,
|
|
15768
15815
|
shading: asset.animation.shading,
|
|
15769
15816
|
detail: asset.animation.detail
|
|
@@ -15777,7 +15824,7 @@ async function resolveObjectProShape(assetId, asset, style, kind, files) {
|
|
|
15777
15824
|
if (asset.animation.clean !== void 0) {
|
|
15778
15825
|
throw new Error(`assets.${assetId}: animation.clean applies to character loops; objectPro loops are not cleaned`);
|
|
15779
15826
|
}
|
|
15780
|
-
if (asset.animation.mode === "template" || asset.animation.mode === "skeleton-v3") {
|
|
15827
|
+
if (asset.animation.mode === "template" || asset.animation.mode === "skeleton-v3" || asset.animation.mode === "pixminimax") {
|
|
15781
15828
|
throw new Error(`assets.${assetId}: objectPro animations have no "${asset.animation.mode}" mode; use "v3" or "pro"`);
|
|
15782
15829
|
}
|
|
15783
15830
|
const pose = async (rel, what) => {
|
|
@@ -23270,12 +23317,12 @@ async function adopt(provider, specs, lock, lockPath, opts = {}) {
|
|
|
23270
23317
|
provider: provider.id
|
|
23271
23318
|
});
|
|
23272
23319
|
matched++;
|
|
23273
|
-
log(` adopted ${key3} \u2190 ${obj.id}`);
|
|
23320
|
+
log(` ${opts.dryRun ? "would adopt" : "adopted"} ${key3} \u2190 ${obj.id}`);
|
|
23274
23321
|
}
|
|
23275
23322
|
}
|
|
23276
23323
|
}
|
|
23277
23324
|
await Promise.all(Array.from({ length: Math.min(concurrency, remote.length || 1) }, worker));
|
|
23278
|
-
await saveLock(lockPath, lock);
|
|
23325
|
+
if (!opts.dryRun) await saveLock(lockPath, lock);
|
|
23279
23326
|
if (!opts.noCache) {
|
|
23280
23327
|
pruneCache(cache, new Set(remote.map((o) => o.id)));
|
|
23281
23328
|
await saveCache(cachePath, cache);
|
|
@@ -23312,8 +23359,9 @@ async function tagAdopted(provider, specs, lock, opts = {}) {
|
|
|
23312
23359
|
var import_node_fs35 = require("fs");
|
|
23313
23360
|
var import_promises26 = require("fs/promises");
|
|
23314
23361
|
var import_node_path38 = __toESM(require("path"), 1);
|
|
23315
|
-
function buildImportedEntry(spec, bytes, opts = {}, now = /* @__PURE__ */ new Date()) {
|
|
23362
|
+
function buildImportedEntry(spec, bytes, opts = {}, now = /* @__PURE__ */ new Date(), frames) {
|
|
23316
23363
|
const png = decodePng(bytes);
|
|
23364
|
+
for (const frame of frames ?? []) decodePng(frame.bytes);
|
|
23317
23365
|
const at2 = now.toISOString();
|
|
23318
23366
|
const origin = {
|
|
23319
23367
|
...opts.tool ? { tool: opts.tool } : {},
|
|
@@ -23338,7 +23386,14 @@ function buildImportedEntry(spec, bytes, opts = {}, now = /* @__PURE__ */ new Da
|
|
|
23338
23386
|
error: null,
|
|
23339
23387
|
sourceUrl: null,
|
|
23340
23388
|
sourceUrls: [],
|
|
23341
|
-
|
|
23389
|
+
// A frame set is recorded the way fetch records one: an output per frame,
|
|
23390
|
+
// in order, each with its `frame-NN` role, so `plan` resolves the same paths.
|
|
23391
|
+
outputs: frames?.length ? frames.map((frame) => ({
|
|
23392
|
+
path: portableOutputPath(frame.file, spec.root),
|
|
23393
|
+
sha256: sha256(frame.bytes),
|
|
23394
|
+
role: frame.role,
|
|
23395
|
+
mediaType: MediaType.PNG
|
|
23396
|
+
})) : [{ path: portableOutputPath(spec.outFile, spec.root), sha256: sha256(bytes) }],
|
|
23342
23397
|
submittedAt: null,
|
|
23343
23398
|
downloadedAt: at2,
|
|
23344
23399
|
cost: opts.cost ?? 0,
|
|
@@ -23353,6 +23408,32 @@ function buildImportedEntry(spec, bytes, opts = {}, now = /* @__PURE__ */ new Da
|
|
|
23353
23408
|
}
|
|
23354
23409
|
};
|
|
23355
23410
|
}
|
|
23411
|
+
var frameRole2 = (index) => `frame-${String(index).padStart(2, "0")}`;
|
|
23412
|
+
async function findFrames(spec) {
|
|
23413
|
+
const at2 = (index) => memberPath(spec.outFile, frameRole2(index), 0, 2, MediaType.PNG);
|
|
23414
|
+
const base = import_node_path38.default.basename(at2(0)).replace(/00\.png$/, "");
|
|
23415
|
+
let names = [];
|
|
23416
|
+
try {
|
|
23417
|
+
names = await (0, import_promises26.readdir)(import_node_path38.default.dirname(spec.outFile));
|
|
23418
|
+
} catch {
|
|
23419
|
+
names = [];
|
|
23420
|
+
}
|
|
23421
|
+
const found = /* @__PURE__ */ new Set();
|
|
23422
|
+
for (const name of names) {
|
|
23423
|
+
if (!name.startsWith(base)) continue;
|
|
23424
|
+
const match = /^(\d+)\.png$/i.exec(name.slice(base.length));
|
|
23425
|
+
if (match) found.add(Number(match[1]));
|
|
23426
|
+
}
|
|
23427
|
+
const expected = spec.revision?.frames;
|
|
23428
|
+
const expectsFrames = expected !== void 0 || spec.generator === "frames";
|
|
23429
|
+
if (!found.size && !expectsFrames) return null;
|
|
23430
|
+
const highest = found.size ? Math.max(...found) : -1;
|
|
23431
|
+
const upTo = Math.max(highest + 1, expected ?? 0, expectsFrames ? 1 : 0);
|
|
23432
|
+
const missing = [];
|
|
23433
|
+
for (let index = 0; index < upTo; index++) if (!found.has(index)) missing.push(at2(index));
|
|
23434
|
+
if (missing.length) return { missing };
|
|
23435
|
+
return { files: Array.from({ length: upTo }, (_, index) => ({ role: frameRole2(index), file: at2(index) })) };
|
|
23436
|
+
}
|
|
23356
23437
|
function unimportable(spec) {
|
|
23357
23438
|
if (spec.character) return "a character is several files; import it with account adopt";
|
|
23358
23439
|
if (spec.vfx) return "an effect is rendered from its recipe, not imported";
|
|
@@ -23385,9 +23466,18 @@ async function importLocal(specs, lock, lockPath, opts = {}) {
|
|
|
23385
23466
|
skipped.push({ key: key3, reason });
|
|
23386
23467
|
continue;
|
|
23387
23468
|
}
|
|
23469
|
+
let frameFiles;
|
|
23388
23470
|
if (!(0, import_node_fs35.existsSync)(spec.outFile)) {
|
|
23389
|
-
|
|
23390
|
-
|
|
23471
|
+
const frames2 = await findFrames(spec);
|
|
23472
|
+
if (!frames2) {
|
|
23473
|
+
skipped.push({ key: key3, reason: `no file at ${spec.outFile}` });
|
|
23474
|
+
continue;
|
|
23475
|
+
}
|
|
23476
|
+
if ("missing" in frames2) {
|
|
23477
|
+
skipped.push({ key: key3, reason: `frame set is missing ${frames2.missing.map((file) => import_node_path38.default.basename(file)).join(", ")} (in ${import_node_path38.default.dirname(spec.outFile)})` });
|
|
23478
|
+
continue;
|
|
23479
|
+
}
|
|
23480
|
+
frameFiles = frames2.files;
|
|
23391
23481
|
}
|
|
23392
23482
|
if (lock.entries[key3] && !opts.force) {
|
|
23393
23483
|
skipped.push({ key: key3, reason: "already in the lockfile (use --force to replace it)" });
|
|
@@ -23395,9 +23485,11 @@ async function importLocal(specs, lock, lockPath, opts = {}) {
|
|
|
23395
23485
|
}
|
|
23396
23486
|
let patch;
|
|
23397
23487
|
let bytes;
|
|
23488
|
+
let frames;
|
|
23398
23489
|
try {
|
|
23399
|
-
|
|
23400
|
-
|
|
23490
|
+
frames = frameFiles ? await Promise.all(frameFiles.map(async (frame) => ({ ...frame, bytes: await (0, import_promises26.readFile)(frame.file) }))) : void 0;
|
|
23491
|
+
bytes = frames ? frames[0].bytes : await (0, import_promises26.readFile)(spec.outFile);
|
|
23492
|
+
patch = buildImportedEntry(spec, bytes, { ...opts, rawSha256 }, /* @__PURE__ */ new Date(), frames);
|
|
23401
23493
|
} catch (error) {
|
|
23402
23494
|
skipped.push({ key: key3, reason: `invalid PNG: ${error instanceof Error ? error.message : String(error)}` });
|
|
23403
23495
|
continue;
|
|
@@ -23407,9 +23499,10 @@ async function importLocal(specs, lock, lockPath, opts = {}) {
|
|
|
23407
23499
|
continue;
|
|
23408
23500
|
}
|
|
23409
23501
|
const existing = lock.entries[key3];
|
|
23410
|
-
const
|
|
23502
|
+
const sameBytes = existing !== void 0 && existing.outputs.length === patch.outputs.length && existing.outputs.every((output, index) => output.sha256 === patch.outputs[index].sha256);
|
|
23503
|
+
const history = sameBytes ? existing.history : historyAfterReplacing(existing, opts.historyLimit ?? DEFAULT_HISTORY_LIMIT, patch.downloadedAt ?? (/* @__PURE__ */ new Date()).toISOString());
|
|
23411
23504
|
if (cacheDir) {
|
|
23412
|
-
await cacheMedia(cacheDir, bytes, MediaType.PNG);
|
|
23505
|
+
for (const member of frames ?? [{ bytes }]) await cacheMedia(cacheDir, member.bytes, MediaType.PNG);
|
|
23413
23506
|
if (rawBytes) await cacheMedia(cacheDir, rawBytes, MediaType.PNG);
|
|
23414
23507
|
}
|
|
23415
23508
|
imported.push({ key: key3, entry: upsert(lock, key3, {
|
|
@@ -24962,12 +25055,12 @@ async function runPicker(provider, lock, lockPath, opts = {}) {
|
|
|
24962
25055
|
});
|
|
24963
25056
|
if (!session) return { selected: 0, skipped: 0 };
|
|
24964
25057
|
let autoSelected = 0;
|
|
24965
|
-
if (opts.autoAcceptSingle) {
|
|
24966
|
-
const singles = session.groups.filter((g) => g.mode === "frame-set" || g.frameUrls.length === 1);
|
|
25058
|
+
if (opts.acceptFirst || opts.autoAcceptSingle) {
|
|
25059
|
+
const singles = opts.acceptFirst ? session.groups : session.groups.filter((g) => g.mode === "frame-set" || g.frameUrls.length === 1);
|
|
24967
25060
|
if (singles.length) {
|
|
24968
25061
|
const res = await session.apply({ selections: singles.map((g) => ({ key: g.key, index: 0 })) }, lockPath);
|
|
24969
25062
|
autoSelected = res.selected;
|
|
24970
|
-
log(` --yes: accepted ${res.selected} single-candidate asset(s)`);
|
|
25063
|
+
log(opts.acceptFirst ? ` --accept-first: accepted the first candidate of ${res.selected} asset(s)` : ` --yes: accepted ${res.selected} single-candidate asset(s)`);
|
|
24971
25064
|
const rest = session.groups.filter((g) => !singles.includes(g)).map((g) => g.key);
|
|
24972
25065
|
session = rest.length ? await prepareReview(provider, lock, { onProgress: log, keys: rest, specs: opts.specs, lockPath }) : null;
|
|
24973
25066
|
if (!session) return { selected: autoSelected, skipped: 0 };
|
|
@@ -25375,7 +25468,8 @@ var NewAnimationSchema = import_zod9.z.object({
|
|
|
25375
25468
|
/** A PixelLab template id (`character` only; `objectPro` has no template concept). */
|
|
25376
25469
|
template: import_zod9.z.string().min(1).optional(),
|
|
25377
25470
|
direction: CharacterDirectionSchema.optional(),
|
|
25378
|
-
|
|
25471
|
+
/** 4 to 16; a pixminimax loop takes a multiple of 4 up to 40. The manifest's own schema checks the rest. */
|
|
25472
|
+
frames: import_zod9.z.number().int().min(4).max(40).optional(),
|
|
25379
25473
|
fps: import_zod9.z.number().int().min(1).max(60).optional(),
|
|
25380
25474
|
/** One loop per named direction, plus free mirrors; expanded when the manifest loads. */
|
|
25381
25475
|
directions: import_zod9.z.array(CharacterDirectionSchema).min(1).optional(),
|