pixelkiln 0.148.1 → 0.149.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +650 -375
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +482 -330
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +76 -14
- package/dist/index.d.ts +76 -14
- package/dist/index.js +419 -267
- package/dist/index.js.map +1 -1
- package/docs/CLI.md +19 -1
- package/docs/PAPERDOLL.md +73 -8
- package/package.json +1 -1
- package/skills/pixelkiln/references/paperdoll.md +15 -0
package/dist/cli.js
CHANGED
|
@@ -244,6 +244,7 @@ var COMMANDS = [
|
|
|
244
244
|
"estimate-skeleton",
|
|
245
245
|
"anchors",
|
|
246
246
|
"redraw",
|
|
247
|
+
"layer",
|
|
247
248
|
"skeleton-preview",
|
|
248
249
|
"unzoom",
|
|
249
250
|
"pixelate",
|
|
@@ -276,6 +277,7 @@ var TALK_SUBCOMMANDS = ["visemes", "gif", "plan"];
|
|
|
276
277
|
var ASSET_SUBCOMMANDS = ["canvas", "mirror", "import", "save", "expand", "review", "export"];
|
|
277
278
|
var UI_SUBCOMMANDS = ["show", "split", "states", "nine-slice", "pull"];
|
|
278
279
|
var PARALLAX_SUBCOMMANDS = ["preview", "export"];
|
|
280
|
+
var LAYER_SUBCOMMANDS = ["preview"];
|
|
279
281
|
function parseArgs(argv) {
|
|
280
282
|
const [command = "help"] = argv;
|
|
281
283
|
if (!COMMANDS.includes(command)) {
|
|
@@ -378,6 +380,18 @@ function parseArgs(argv) {
|
|
|
378
380
|
target = rest[0]?.startsWith("-") ? void 0 : rest[0];
|
|
379
381
|
if (target === void 0) throw new UsageError("redraw needs a layer's asset id: pixelkiln redraw <asset> --frame <name>");
|
|
380
382
|
rest = rest.slice(1);
|
|
383
|
+
} else if (command === "layer") {
|
|
384
|
+
subcommand = rest[0];
|
|
385
|
+
if (subcommand === void 0 || subcommand.startsWith("-")) {
|
|
386
|
+
throw new UsageError(`layer needs a subcommand: ${LAYER_SUBCOMMANDS.join(", ")}`);
|
|
387
|
+
}
|
|
388
|
+
if (!LAYER_SUBCOMMANDS.includes(subcommand)) {
|
|
389
|
+
throw new UsageError(`Unknown layer subcommand "${subcommand}". Known: ${LAYER_SUBCOMMANDS.join(", ")}`);
|
|
390
|
+
}
|
|
391
|
+
rest = rest.slice(1);
|
|
392
|
+
target = rest[0]?.startsWith("-") ? void 0 : rest[0];
|
|
393
|
+
if (target === void 0) throw new UsageError("layer preview needs a layer's asset id: pixelkiln layer preview <asset>");
|
|
394
|
+
rest = rest.slice(1);
|
|
381
395
|
} else if (command === "skeleton-preview") {
|
|
382
396
|
target = rest[0]?.startsWith("-") ? void 0 : rest[0];
|
|
383
397
|
if (target === void 0) {
|
|
@@ -746,6 +760,11 @@ Commands
|
|
|
746
760
|
beside them. Direct and un-budgeted, 10 to 25 generations by sheet
|
|
747
761
|
size. The new frames replace the old in the lockfile. Without
|
|
748
762
|
--frame it lists the names; --dry-run prices the call.
|
|
763
|
+
layer preview <layer> [--style <id>]
|
|
764
|
+
Free and offline: build a paperdoll layer's sheet, keyed sheet and
|
|
765
|
+
mask as gen would send them, write them (and each frame's own) to
|
|
766
|
+
.pixelkiln/layers/<style>/<layer>/preview/, and print each frame's
|
|
767
|
+
neck row and the inpaint's price. Nothing is submitted.
|
|
749
768
|
skeleton-preview <keypoints.json | asset> [--from <image>] [--out <file>]
|
|
750
769
|
Draw every pose of a keypoints file over its source image as one
|
|
751
770
|
PNG, locally and free. Given an animate-skeleton asset id, reads
|
|
@@ -1473,10 +1492,10 @@ function normalizeHex(value) {
|
|
|
1473
1492
|
function sha256(data) {
|
|
1474
1493
|
return createHash("sha256").update(data).digest("hex");
|
|
1475
1494
|
}
|
|
1476
|
-
async function sha256File(
|
|
1495
|
+
async function sha256File(path81) {
|
|
1477
1496
|
return new Promise((resolve, reject) => {
|
|
1478
1497
|
const hash = createHash("sha256");
|
|
1479
|
-
const stream = createReadStream(
|
|
1498
|
+
const stream = createReadStream(path81);
|
|
1480
1499
|
stream.on("data", (chunk2) => hash.update(chunk2));
|
|
1481
1500
|
stream.on("error", reject);
|
|
1482
1501
|
stream.on("end", () => resolve(hash.digest("hex")));
|
|
@@ -1619,6 +1638,8 @@ function specHash(spec, styleImageHashes, providerOptionIdentity = spec.provider
|
|
|
1619
1638
|
keyed: spec.character.layer.keyed?.sha256,
|
|
1620
1639
|
skin: spec.character.layer.skin?.map(normalizeHex),
|
|
1621
1640
|
key: spec.character.layer.key ? normalizeHex(spec.character.layer.key) : void 0,
|
|
1641
|
+
// Omitted unless set so a layer made before it existed keeps its identity.
|
|
1642
|
+
cover: spec.character.layer.cover,
|
|
1622
1643
|
clean: spec.character.layer.clean,
|
|
1623
1644
|
columns: spec.character.layer.columns,
|
|
1624
1645
|
// Omitted at their defaults so a layer made before these existed keeps its identity.
|
|
@@ -2202,6 +2223,13 @@ var CharacterLayerSchema = z.object({
|
|
|
2202
2223
|
skin: z.array(HexColorSchema).min(1).max(64).optional(),
|
|
2203
2224
|
/** The stand-in colour skin is painted before the provider sees it. Default cyan. */
|
|
2204
2225
|
key: HexColorSchema.optional(),
|
|
2226
|
+
/**
|
|
2227
|
+
* Key every opaque pixel inside the mask, whatever its colour, not only
|
|
2228
|
+
* skin. For a base that wears underwear (or anything else it cannot be
|
|
2229
|
+
* drawn without): what it wears is body to dress over, so the outfit
|
|
2230
|
+
* covers it instead of being drawn around it. Default false.
|
|
2231
|
+
*/
|
|
2232
|
+
cover: z.boolean().optional(),
|
|
2205
2233
|
/**
|
|
2206
2234
|
* Remove animation ghosts from the loops before dressing them, judged
|
|
2207
2235
|
* against the stills among `of` (bases and states). Default true; it has
|
|
@@ -2242,7 +2270,7 @@ var CharacterLayerSchema = z.object({
|
|
|
2242
2270
|
attach: CharacterAttachSchema.optional()
|
|
2243
2271
|
}).strict().superRefine((layer, context) => {
|
|
2244
2272
|
if (!layer.attach) return;
|
|
2245
|
-
for (const field of ["mask", "keyed", "skin", "key", "clean", "region"]) {
|
|
2273
|
+
for (const field of ["mask", "keyed", "skin", "key", "cover", "clean", "region"]) {
|
|
2246
2274
|
if (layer[field] !== void 0) {
|
|
2247
2275
|
context.addIssue({
|
|
2248
2276
|
code: z.ZodIssueCode.custom,
|
|
@@ -3246,7 +3274,7 @@ var AssetDeriveSchema = z.object({
|
|
|
3246
3274
|
/** key-skin: how far a pixel may sit from a `skin` colour. despeckle: how near a reference colour must be to vouch for a pixel. */
|
|
3247
3275
|
tolerance: z.number().min(0).max(442).optional()
|
|
3248
3276
|
}).strict().superRefine((derive, context) => {
|
|
3249
|
-
const issue = (message6,
|
|
3277
|
+
const issue = (message6, path81) => context.addIssue({ code: z.ZodIssueCode.custom, message: message6, path: [path81] });
|
|
3250
3278
|
if (Boolean(derive.from) === Boolean(derive.file)) {
|
|
3251
3279
|
issue("name exactly one source: `from` (an asset in this style) or `file` (a committed PNG)", derive.from ? "file" : "from");
|
|
3252
3280
|
}
|
|
@@ -4574,8 +4602,23 @@ function hsv(r, g, b) {
|
|
|
4574
4602
|
}
|
|
4575
4603
|
return { h, s: max === 0 ? 0 : delta / max, v: max / 255 };
|
|
4576
4604
|
}
|
|
4605
|
+
function unpackSheet(sheet, cells) {
|
|
4606
|
+
const image = decodePng(sheet);
|
|
4607
|
+
return cells.map((cell, index) => {
|
|
4608
|
+
if (cell.x < 0 || cell.y < 0 || cell.x + cell.width > image.width || cell.y + cell.height > image.height) {
|
|
4609
|
+
throw new Error(`cell ${index} does not fit inside the ${image.width}x${image.height} sheet`);
|
|
4610
|
+
}
|
|
4611
|
+
const out = Buffer.alloc(cell.width * cell.height * 4);
|
|
4612
|
+
for (let y = 0; y < cell.height; y++) {
|
|
4613
|
+
const from = at(image, cell.x, cell.y + y);
|
|
4614
|
+
image.pixels.copy(out, y * cell.width * 4, from, from + cell.width * 4);
|
|
4615
|
+
}
|
|
4616
|
+
return encodeRgbaPng(cell.width, cell.height, out);
|
|
4617
|
+
});
|
|
4618
|
+
}
|
|
4577
4619
|
var DEFAULT_KEY = "#00ffff";
|
|
4578
4620
|
var KEY_SATURATION = 0.85;
|
|
4621
|
+
var COVER_FLOOR = 96;
|
|
4579
4622
|
function keySkin(png, options = {}) {
|
|
4580
4623
|
const image = decodePng(png);
|
|
4581
4624
|
const key3 = parseHex(options.key ?? DEFAULT_KEY);
|
|
@@ -4628,23 +4671,103 @@ function neckRow(image, cell = whole(image)) {
|
|
|
4628
4671
|
}
|
|
4629
4672
|
return best === null ? null : cell.y + best;
|
|
4630
4673
|
}
|
|
4631
|
-
function
|
|
4674
|
+
function longestRun(image, cell, y) {
|
|
4675
|
+
let best = null;
|
|
4676
|
+
let start = -1;
|
|
4677
|
+
for (let x = 0; x <= cell.width; x++) {
|
|
4678
|
+
const on = x < cell.width && opaque(image, cell.x + x, cell.y + y);
|
|
4679
|
+
if (on && start < 0) start = x;
|
|
4680
|
+
if (!on && start >= 0) {
|
|
4681
|
+
if (!best || x - 1 - start > best[1] - best[0]) best = [start, x - 1];
|
|
4682
|
+
start = -1;
|
|
4683
|
+
}
|
|
4684
|
+
}
|
|
4685
|
+
return best;
|
|
4686
|
+
}
|
|
4687
|
+
var median = (values) => {
|
|
4688
|
+
const sorted = [...values].sort((a, b) => a - b);
|
|
4689
|
+
return sorted[Math.floor((sorted.length - 1) / 2)];
|
|
4690
|
+
};
|
|
4691
|
+
function layerMask(sheet, cells, region = "body") {
|
|
4632
4692
|
const image = decodePng(sheet);
|
|
4633
4693
|
const out = Buffer.alloc(image.width * image.height * 4);
|
|
4634
4694
|
for (let i = 3; i < out.length; i += 4) out[i] = 255;
|
|
4635
|
-
|
|
4695
|
+
const all = cells ?? [whole(image)];
|
|
4696
|
+
const first = all.map((cell) => {
|
|
4697
|
+
let top = -1;
|
|
4698
|
+
let bottom = -1;
|
|
4699
|
+
for (let y = 0; y < cell.height && top < 0; y++) if (longestRun(image, cell, y)) top = y;
|
|
4700
|
+
for (let y = cell.height - 1; y >= 0 && bottom < 0; y--) if (longestRun(image, cell, y)) bottom = y;
|
|
4701
|
+
if (top < 0) return null;
|
|
4636
4702
|
const neck = neckRow(image, cell);
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4703
|
+
return { top, bottom, detected: neck === null ? null : neck - cell.y };
|
|
4704
|
+
});
|
|
4705
|
+
const seen = first.filter((frame) => frame !== null);
|
|
4706
|
+
const offsets = seen.filter((frame) => frame.detected !== null).map((frame) => frame.detected - frame.top);
|
|
4707
|
+
if (!offsets.length) return { png: encodeRgbaPng(image.width, image.height, out), necks: all.map(() => null) };
|
|
4708
|
+
const drop = median(offsets);
|
|
4709
|
+
const heads = seen.map((frame) => {
|
|
4710
|
+
const cell = all[first.indexOf(frame)];
|
|
4711
|
+
const run = longestRun(image, cell, Math.min(frame.bottom, frame.top + Math.floor(drop / 2)));
|
|
4712
|
+
return run ? run[1] - run[0] + 1 : 1;
|
|
4713
|
+
});
|
|
4714
|
+
const wide = Math.max(1, Math.ceil(median(heads) / 2));
|
|
4715
|
+
const necks = all.map((cell, index) => {
|
|
4716
|
+
const frame = first[index];
|
|
4717
|
+
if (!frame) return null;
|
|
4718
|
+
let head = frame.top;
|
|
4719
|
+
for (let y = frame.top; y <= frame.bottom; y++) {
|
|
4720
|
+
const run = longestRun(image, cell, y);
|
|
4721
|
+
if (run && run[1] - run[0] + 1 >= wide) {
|
|
4722
|
+
head = y;
|
|
4723
|
+
break;
|
|
4724
|
+
}
|
|
4725
|
+
}
|
|
4726
|
+
const row = Math.min(head + drop, frame.bottom);
|
|
4727
|
+
const slack = Math.max(2, Math.round((frame.bottom - frame.top + 1) * 0.06));
|
|
4728
|
+
const corrected = frame.detected === null || Math.abs(frame.detected - row) > slack;
|
|
4729
|
+
const from = region === "head" ? 0 : row + 1;
|
|
4730
|
+
const to = region === "head" ? row + 1 : cell.height;
|
|
4640
4731
|
for (let y = from; y < to; y++) {
|
|
4641
|
-
for (let x =
|
|
4642
|
-
if (region === "body" && !opaque(image, x, y)) continue;
|
|
4643
|
-
out.fill(255, at(image, x, y), at(image, x, y) + 3);
|
|
4732
|
+
for (let x = 0; x < cell.width; x++) {
|
|
4733
|
+
if (region === "body" && !opaque(image, cell.x + x, cell.y + y)) continue;
|
|
4734
|
+
out.fill(255, at(image, cell.x + x, cell.y + y), at(image, cell.x + x, cell.y + y) + 3);
|
|
4735
|
+
}
|
|
4736
|
+
}
|
|
4737
|
+
if (region === "body") {
|
|
4738
|
+
const seed = longestRun(image, cell, head);
|
|
4739
|
+
const inHead = new Uint8Array(cell.width * (row + 1));
|
|
4740
|
+
const queue = [];
|
|
4741
|
+
for (let x = seed[0]; x <= seed[1]; x++) {
|
|
4742
|
+
inHead[head * cell.width + x] = 1;
|
|
4743
|
+
queue.push([x, head]);
|
|
4744
|
+
}
|
|
4745
|
+
let left = seed[0];
|
|
4746
|
+
let right = seed[1];
|
|
4747
|
+
while (queue.length) {
|
|
4748
|
+
const [x, y] = queue.pop();
|
|
4749
|
+
left = Math.min(left, x);
|
|
4750
|
+
right = Math.max(right, x);
|
|
4751
|
+
for (const [dx, dy] of STEPS) {
|
|
4752
|
+
const nx = x + dx;
|
|
4753
|
+
const ny = y + dy;
|
|
4754
|
+
if (nx < 0 || nx >= cell.width || ny < 0 || ny > row) continue;
|
|
4755
|
+
if (inHead[ny * cell.width + nx] || !opaque(image, cell.x + nx, cell.y + ny)) continue;
|
|
4756
|
+
inHead[ny * cell.width + nx] = 1;
|
|
4757
|
+
queue.push([nx, ny]);
|
|
4758
|
+
}
|
|
4759
|
+
}
|
|
4760
|
+
for (let y = 0; y <= row; y++) {
|
|
4761
|
+
for (let x = 0; x < cell.width; x++) {
|
|
4762
|
+
if (x >= left - 1 && x <= right + 1) continue;
|
|
4763
|
+
if (!opaque(image, cell.x + x, cell.y + y)) continue;
|
|
4764
|
+
out.fill(255, at(image, cell.x + x, cell.y + y), at(image, cell.x + x, cell.y + y) + 3);
|
|
4765
|
+
}
|
|
4644
4766
|
}
|
|
4645
4767
|
}
|
|
4646
|
-
|
|
4647
|
-
|
|
4768
|
+
return { row, head, detected: frame.detected, corrected };
|
|
4769
|
+
});
|
|
4770
|
+
return { png: encodeRgbaPng(image.width, image.height, out), necks };
|
|
4648
4771
|
}
|
|
4649
4772
|
function extractLayer(result, keyed, mask, options = {}) {
|
|
4650
4773
|
const out = decodePng(result);
|
|
@@ -4939,23 +5062,55 @@ function buildLayerSheet(sources, options) {
|
|
|
4939
5062
|
}
|
|
4940
5063
|
return png;
|
|
4941
5064
|
};
|
|
4942
|
-
const
|
|
5065
|
+
const computed = options.mask ? void 0 : layerMask(sheetPng, frames.map((frame) => frame.cell), options.region);
|
|
5066
|
+
const mask = options.mask ? sized("mask", options.mask) : computed.png;
|
|
5067
|
+
const keyed = options.keyed ? void 0 : keyInsideMask(sheetPng, mask, { key: options.key, skin: options.skin, cover: options.cover });
|
|
4943
5068
|
return {
|
|
4944
5069
|
sheet: sheetPng,
|
|
4945
|
-
keyed: options.keyed ? sized("keyed sheet", options.keyed) :
|
|
5070
|
+
keyed: options.keyed ? sized("keyed sheet", options.keyed) : keyed.png,
|
|
4946
5071
|
mask,
|
|
4947
5072
|
frames,
|
|
4948
|
-
cleaned
|
|
5073
|
+
cleaned,
|
|
5074
|
+
...computed ? { necks: computed.necks } : {},
|
|
5075
|
+
...keyed ? { closed: keyed.closed } : {}
|
|
4949
5076
|
};
|
|
4950
5077
|
}
|
|
4951
5078
|
function keyInsideMask(sheet, mask, options) {
|
|
4952
5079
|
const original = decodePng(sheet);
|
|
4953
|
-
const keyed = decodePng(keySkin(sheet, options));
|
|
4954
5080
|
const allowed = decodePng(mask);
|
|
5081
|
+
const key3 = parseHex(options.key ?? DEFAULT_KEY);
|
|
5082
|
+
const keyed = options.cover ? { ...original, pixels: Buffer.from(original.pixels) } : decodePng(keySkin(sheet, options));
|
|
5083
|
+
const paint = (i, lift) => {
|
|
5084
|
+
const brightest = Math.max(original.pixels[i], original.pixels[i + 1], original.pixels[i + 2]);
|
|
5085
|
+
const value = lift ? COVER_FLOOR + Math.floor(brightest * (255 - COVER_FLOOR) / 255) : brightest;
|
|
5086
|
+
const tint = (channel) => Math.floor(value * (1 - KEY_SATURATION + KEY_SATURATION * channel / 255));
|
|
5087
|
+
keyed.pixels[i] = tint(key3.r);
|
|
5088
|
+
keyed.pixels[i + 1] = tint(key3.g);
|
|
5089
|
+
keyed.pixels[i + 2] = tint(key3.b);
|
|
5090
|
+
};
|
|
4955
5091
|
for (let i = 0; i < keyed.pixels.length; i += 4) {
|
|
4956
5092
|
if (allowed.pixels[i] !== 255) original.pixels.copy(keyed.pixels, i, i, i + 4);
|
|
5093
|
+
else if (options.cover && original.pixels[i + 3]) paint(i, true);
|
|
5094
|
+
}
|
|
5095
|
+
let closed = 0;
|
|
5096
|
+
if (!options.cover && !options.skin) {
|
|
5097
|
+
const changed = (i) => original.pixels[i + 3] > 0 && original.pixels.compare(keyed.pixels, i, i + 3, i, i + 3) !== 0;
|
|
5098
|
+
const holes = [];
|
|
5099
|
+
for (let y = 0; y < keyed.height; y++) {
|
|
5100
|
+
for (let x = 0; x < keyed.width; x++) {
|
|
5101
|
+
const i = (y * keyed.width + x) * 4;
|
|
5102
|
+
if (allowed.pixels[i] !== 255 || !original.pixels[i + 3] || changed(i)) continue;
|
|
5103
|
+
const near = (dir) => [1, 2, 3].some((k) => {
|
|
5104
|
+
const nx = x + dir * k;
|
|
5105
|
+
return nx >= 0 && nx < keyed.width && allowed.pixels[i + dir * k * 4] === 255 && changed(i + dir * k * 4);
|
|
5106
|
+
});
|
|
5107
|
+
if (near(-1) && near(1)) holes.push(i);
|
|
5108
|
+
}
|
|
5109
|
+
}
|
|
5110
|
+
for (const i of holes) paint(i, false);
|
|
5111
|
+
closed = holes.length;
|
|
4957
5112
|
}
|
|
4958
|
-
return encodeRgbaPng(keyed.width, keyed.height, keyed.pixels);
|
|
5113
|
+
return { png: encodeRgbaPng(keyed.width, keyed.height, keyed.pixels), closed };
|
|
4959
5114
|
}
|
|
4960
5115
|
var SPECK = 8;
|
|
4961
5116
|
var BLEED = 20;
|
|
@@ -9496,9 +9651,9 @@ var PixelLabClient = class {
|
|
|
9496
9651
|
apiKey;
|
|
9497
9652
|
http;
|
|
9498
9653
|
/** Retries transport failures, 429, and 5xx; see http.ts for the policy. */
|
|
9499
|
-
async request(
|
|
9654
|
+
async request(path81, init) {
|
|
9500
9655
|
const auth = this.apiKey.startsWith("Bearer ") ? this.apiKey : `Bearer ${this.apiKey}`;
|
|
9501
|
-
const res = await this.http(`${BASE}${
|
|
9656
|
+
const res = await this.http(`${BASE}${path81}`, {
|
|
9502
9657
|
...init,
|
|
9503
9658
|
headers: {
|
|
9504
9659
|
Authorization: auth,
|
|
@@ -9509,13 +9664,13 @@ var PixelLabClient = class {
|
|
|
9509
9664
|
const text = await res.text();
|
|
9510
9665
|
if (!res.ok) {
|
|
9511
9666
|
const hint = res.status === 500 && text.includes("Failed to start any animation jobs") ? '; a skeleton-v3 loop needs a character with a stored 3D skeleton (a v3 base), use mode: "template" on a standard one' : "";
|
|
9512
|
-
throw new PixelLabError(`${init?.method ?? "GET"} ${
|
|
9667
|
+
throw new PixelLabError(`${init?.method ?? "GET"} ${path81} \u2192 ${res.status}${hint}${refusalReason(res.status, text)}`, res.status, text);
|
|
9513
9668
|
}
|
|
9514
9669
|
if (!text) return {};
|
|
9515
9670
|
try {
|
|
9516
9671
|
return JSON.parse(text);
|
|
9517
9672
|
} catch {
|
|
9518
|
-
throw new Error(`${init?.method ?? "GET"} ${
|
|
9673
|
+
throw new Error(`${init?.method ?? "GET"} ${path81} returned invalid JSON`);
|
|
9519
9674
|
}
|
|
9520
9675
|
}
|
|
9521
9676
|
async balance() {
|
|
@@ -10067,10 +10222,10 @@ var PixelLabClient = class {
|
|
|
10067
10222
|
const palette = args.paletteSwatchBase64 ? { color_image: { type: "base64", base64: args.paletteSwatchBase64, format: "png" }, force_colors: true } : {};
|
|
10068
10223
|
const encode = (image) => ({ type: "base64", base64: image.base64, format: image.format });
|
|
10069
10224
|
const south = args.reference?.south;
|
|
10070
|
-
let
|
|
10225
|
+
let path81;
|
|
10071
10226
|
let body;
|
|
10072
10227
|
if (args.mode === "v3") {
|
|
10073
|
-
|
|
10228
|
+
path81 = "/create-character-v3";
|
|
10074
10229
|
body = {
|
|
10075
10230
|
description: args.description,
|
|
10076
10231
|
image_size: imageSize,
|
|
@@ -10084,7 +10239,7 @@ var PixelLabClient = class {
|
|
|
10084
10239
|
...args.enhancePrompt ? { enhance_prompt: true } : {}
|
|
10085
10240
|
};
|
|
10086
10241
|
} else if (args.mode === "pro-flash") {
|
|
10087
|
-
|
|
10242
|
+
path81 = "/create-character-pro-flash";
|
|
10088
10243
|
const traits = args.styleTraits;
|
|
10089
10244
|
body = {
|
|
10090
10245
|
description: args.description,
|
|
@@ -10108,7 +10263,7 @@ var PixelLabClient = class {
|
|
|
10108
10263
|
} : {}
|
|
10109
10264
|
};
|
|
10110
10265
|
} else if (args.mode === "pro") {
|
|
10111
|
-
|
|
10266
|
+
path81 = "/create-character-pro";
|
|
10112
10267
|
body = {
|
|
10113
10268
|
description: args.description,
|
|
10114
10269
|
image_size: imageSize,
|
|
@@ -10122,7 +10277,7 @@ var PixelLabClient = class {
|
|
|
10122
10277
|
...!south && args.styleCharacterId ? { style_character_id: args.styleCharacterId } : {}
|
|
10123
10278
|
};
|
|
10124
10279
|
} else {
|
|
10125
|
-
|
|
10280
|
+
path81 = args.directions === 4 ? "/create-character-with-4-directions" : "/create-character-with-8-directions";
|
|
10126
10281
|
body = {
|
|
10127
10282
|
description: args.description,
|
|
10128
10283
|
image_size: imageSize,
|
|
@@ -10140,8 +10295,8 @@ var PixelLabClient = class {
|
|
|
10140
10295
|
};
|
|
10141
10296
|
}
|
|
10142
10297
|
if (args.mode === "pro" || args.mode === "pro-flash") Object.assign(body, targetPaletteBody(args.targetPalette));
|
|
10143
|
-
const raw = await this.request(
|
|
10144
|
-
return validateResponse(CharacterSubmitSchema, raw,
|
|
10298
|
+
const raw = await this.request(path81, { method: "POST", body: JSON.stringify(body) });
|
|
10299
|
+
return validateResponse(CharacterSubmitSchema, raw, path81.slice(1));
|
|
10145
10300
|
}
|
|
10146
10301
|
/** A text edit of an existing character, applied to every direction and stored as a sibling. */
|
|
10147
10302
|
async createCharacterState(args) {
|
|
@@ -11195,8 +11350,8 @@ var PixelLabClient = class {
|
|
|
11195
11350
|
}
|
|
11196
11351
|
/** Irreversible: the character, its states are separate records, and its animations. Checks `success` like `deleteObject`. */
|
|
11197
11352
|
async deleteCharacter(characterId) {
|
|
11198
|
-
const
|
|
11199
|
-
return deleteSucceeded(await this.request(
|
|
11353
|
+
const path81 = `/characters/${encodeURIComponent(characterId)}`;
|
|
11354
|
+
return deleteSucceeded(await this.request(path81, { method: "DELETE" }), `DELETE ${path81}`);
|
|
11200
11355
|
}
|
|
11201
11356
|
setCharacterTags(characterId, tags) {
|
|
11202
11357
|
return this.request(`/characters/${encodeURIComponent(characterId)}/tags`, {
|
|
@@ -12539,6 +12694,37 @@ var GRASP_PROMPT = "Every cyan mannequin on this spritesheet carries the same it
|
|
|
12539
12694
|
function layerWorkDir(spec) {
|
|
12540
12695
|
return path17.join(spec.root, ".pixelkiln", "layers", spec.styleId, spec.assetId);
|
|
12541
12696
|
}
|
|
12697
|
+
function layerSheetFor(spec, outputs) {
|
|
12698
|
+
const character = spec.character;
|
|
12699
|
+
const layer = character.layer;
|
|
12700
|
+
const label = `${spec.styleId}/${spec.assetId}`;
|
|
12701
|
+
if (!outputs.length) throw new Error(`${label}: its layer sources have no downloaded frames`);
|
|
12702
|
+
const sources = outputs.map((output) => ({
|
|
12703
|
+
assetId: output.assetId ?? character.parentAssetId,
|
|
12704
|
+
...output.role ? { role: output.role } : {},
|
|
12705
|
+
png: readFileSync2(output.path),
|
|
12706
|
+
still: output.still === true
|
|
12707
|
+
}));
|
|
12708
|
+
const supplied = (name, file) => {
|
|
12709
|
+
if (!file) return void 0;
|
|
12710
|
+
const bytes = readFileSync2(file.path);
|
|
12711
|
+
if (sha256(bytes) !== file.sha256) throw new Error(`${label}: layer ${name} changed after the manifest was resolved: ${file.path}`);
|
|
12712
|
+
return bytes;
|
|
12713
|
+
};
|
|
12714
|
+
return buildLayerSheet(sources, {
|
|
12715
|
+
minSide: 32,
|
|
12716
|
+
maxSide: LAYER_SHEET_MAX_SIDE,
|
|
12717
|
+
columns: layer.columns,
|
|
12718
|
+
region: layer.region,
|
|
12719
|
+
padding: layer.padding,
|
|
12720
|
+
key: layer.key,
|
|
12721
|
+
skin: layer.skin,
|
|
12722
|
+
cover: layer.cover,
|
|
12723
|
+
reference: layer.clean ? sources.filter((source) => source.still).map((source) => source.png) : [],
|
|
12724
|
+
mask: supplied("mask", layer.mask),
|
|
12725
|
+
keyed: supplied("keyed sheet", layer.keyed)
|
|
12726
|
+
});
|
|
12727
|
+
}
|
|
12542
12728
|
var PixelLabProvider = class _PixelLabProvider {
|
|
12543
12729
|
/**
|
|
12544
12730
|
* `mcp` reaches the tools PixelLab offers only over MCP (the VFX
|
|
@@ -13430,31 +13616,7 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
13430
13616
|
const layer = character.layer;
|
|
13431
13617
|
const label = `${spec.styleId}/${spec.assetId}`;
|
|
13432
13618
|
const outputs = context?.parentOutputs ?? [];
|
|
13433
|
-
|
|
13434
|
-
const sources = outputs.map((output) => ({
|
|
13435
|
-
assetId: output.assetId ?? character.parentAssetId,
|
|
13436
|
-
...output.role ? { role: output.role } : {},
|
|
13437
|
-
png: readFileSync2(output.path),
|
|
13438
|
-
still: output.still === true
|
|
13439
|
-
}));
|
|
13440
|
-
const supplied = (name2, file) => {
|
|
13441
|
-
if (!file) return void 0;
|
|
13442
|
-
const bytes = readFileSync2(file.path);
|
|
13443
|
-
if (sha256(bytes) !== file.sha256) throw new Error(`${label}: layer ${name2} changed after the manifest was resolved: ${file.path}`);
|
|
13444
|
-
return bytes;
|
|
13445
|
-
};
|
|
13446
|
-
const built = buildLayerSheet(sources, {
|
|
13447
|
-
minSide: 32,
|
|
13448
|
-
maxSide: LAYER_SHEET_MAX_SIDE,
|
|
13449
|
-
columns: layer.columns,
|
|
13450
|
-
region: layer.region,
|
|
13451
|
-
padding: layer.padding,
|
|
13452
|
-
key: layer.key,
|
|
13453
|
-
skin: layer.skin,
|
|
13454
|
-
reference: layer.clean ? sources.filter((source) => source.still).map((source) => source.png) : [],
|
|
13455
|
-
mask: supplied("mask", layer.mask),
|
|
13456
|
-
keyed: supplied("keyed sheet", layer.keyed)
|
|
13457
|
-
});
|
|
13619
|
+
const built = layerSheetFor(spec, outputs);
|
|
13458
13620
|
const dir = layerWorkDir(spec);
|
|
13459
13621
|
mkdirSync(dir, { recursive: true });
|
|
13460
13622
|
let prepared = built;
|
|
@@ -13509,7 +13671,15 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
13509
13671
|
character: {
|
|
13510
13672
|
kind: "layer",
|
|
13511
13673
|
backgroundJobId: res2.background_job_id,
|
|
13512
|
-
sheet: {
|
|
13674
|
+
sheet: {
|
|
13675
|
+
width,
|
|
13676
|
+
height,
|
|
13677
|
+
frames: prepared.frames.length,
|
|
13678
|
+
cleanedPixels: prepared.cleaned,
|
|
13679
|
+
// Each frame's neck row in its cell, and the frames whose own narrowest row was overruled; submit prints both.
|
|
13680
|
+
...prepared.necks ? { necks: prepared.necks.map((neck) => neck?.row ?? null) } : {},
|
|
13681
|
+
...prepared.necks?.some((neck) => neck?.corrected) ? { neckCorrected: prepared.necks.flatMap((neck, index) => neck?.corrected ? [index] : []) } : {}
|
|
13682
|
+
}
|
|
13513
13683
|
}
|
|
13514
13684
|
}
|
|
13515
13685
|
};
|
|
@@ -15572,9 +15742,9 @@ var RetroDiffusionClient = class {
|
|
|
15572
15742
|
if (!response.ok) throw new ProviderError("retrodiffusion", `Retro Diffusion download failed (${response.status})`, { status: response.status });
|
|
15573
15743
|
return Buffer.from(await response.arrayBuffer());
|
|
15574
15744
|
}
|
|
15575
|
-
async call(
|
|
15745
|
+
async call(path81, init = {}) {
|
|
15576
15746
|
if (!this.token) throw new Error("RD_API_KEY is not set");
|
|
15577
|
-
const response = await this.request(`${this.baseUrl}${
|
|
15747
|
+
const response = await this.request(`${this.baseUrl}${path81}`, {
|
|
15578
15748
|
...init,
|
|
15579
15749
|
headers: {
|
|
15580
15750
|
"Content-Type": "application/json",
|
|
@@ -17751,6 +17921,7 @@ async function resolveSpecs(loaded, filter) {
|
|
|
17751
17921
|
...keyed ? { keyed } : {},
|
|
17752
17922
|
...asset.layer.skin ? { skin: asset.layer.skin } : {},
|
|
17753
17923
|
...asset.layer.key ? { key: asset.layer.key } : {},
|
|
17924
|
+
...asset.layer.cover ? { cover: true } : {},
|
|
17754
17925
|
clean: asset.layer.clean ?? true,
|
|
17755
17926
|
...asset.layer.columns ? { columns: asset.layer.columns } : {},
|
|
17756
17927
|
region: asset.layer.region ?? "body",
|
|
@@ -19034,10 +19205,10 @@ function isSha256Hash(value) {
|
|
|
19034
19205
|
function parseCache(value) {
|
|
19035
19206
|
return HashCacheSchema.parse(value);
|
|
19036
19207
|
}
|
|
19037
|
-
async function loadCache(
|
|
19038
|
-
if (!existsSync18(
|
|
19208
|
+
async function loadCache(path81) {
|
|
19209
|
+
if (!existsSync18(path81)) return { version: 1, hashes: {} };
|
|
19039
19210
|
try {
|
|
19040
|
-
const parsed = HashCacheSchema.safeParse(JSON.parse(await readFile13(
|
|
19211
|
+
const parsed = HashCacheSchema.safeParse(JSON.parse(await readFile13(path81, "utf8")));
|
|
19041
19212
|
if (!parsed.success) return { version: 1, hashes: {} };
|
|
19042
19213
|
return {
|
|
19043
19214
|
version: 1,
|
|
@@ -19049,18 +19220,18 @@ async function loadCache(path79) {
|
|
|
19049
19220
|
return { version: 1, hashes: {} };
|
|
19050
19221
|
}
|
|
19051
19222
|
}
|
|
19052
|
-
async function saveCache(
|
|
19223
|
+
async function saveCache(path81, cache) {
|
|
19053
19224
|
const sorted = {};
|
|
19054
19225
|
for (const key3 of Object.keys(cache.hashes).sort()) {
|
|
19055
19226
|
const hash = cache.hashes[key3];
|
|
19056
19227
|
if (!isSha256Hash(hash)) throw new Error(`Refusing to cache invalid SHA-256 for ${key3}`);
|
|
19057
19228
|
sorted[key3] = hash;
|
|
19058
19229
|
}
|
|
19059
|
-
await mkdir9(pathModule.dirname(pathModule.resolve(
|
|
19060
|
-
const tmp = `${
|
|
19230
|
+
await mkdir9(pathModule.dirname(pathModule.resolve(path81)), { recursive: true });
|
|
19231
|
+
const tmp = `${path81}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
|
|
19061
19232
|
try {
|
|
19062
19233
|
await writeFile9(tmp, JSON.stringify({ version: 1, hashes: sorted }, null, 2) + "\n");
|
|
19063
|
-
await rename7(tmp,
|
|
19234
|
+
await rename7(tmp, path81);
|
|
19064
19235
|
} finally {
|
|
19065
19236
|
await rm5(tmp, { force: true });
|
|
19066
19237
|
}
|
|
@@ -23383,13 +23554,13 @@ function poseNodes(document, pose) {
|
|
|
23383
23554
|
const posed = /* @__PURE__ */ new Map();
|
|
23384
23555
|
for (const channel of animation.channels) {
|
|
23385
23556
|
const node = channel.target.node;
|
|
23386
|
-
const
|
|
23387
|
-
if (node === void 0 || !["translation", "rotation", "scale"].includes(
|
|
23557
|
+
const path81 = channel.target.path;
|
|
23558
|
+
if (node === void 0 || !["translation", "rotation", "scale"].includes(path81)) continue;
|
|
23388
23559
|
const sampler = animation.samplers[channel.sampler];
|
|
23389
23560
|
if (!sampler) continue;
|
|
23390
23561
|
const times = readAccessor(document, sampler.input).data;
|
|
23391
23562
|
const values = readAccessor(document, sampler.output);
|
|
23392
|
-
const width =
|
|
23563
|
+
const width = path81 === "rotation" ? 4 : 3;
|
|
23393
23564
|
const cubic = sampler.interpolation === "CUBICSPLINE";
|
|
23394
23565
|
const valueAt = (key4) => Array.from(values.data.subarray((cubic ? key4 * 3 + 1 : key4) * width, (cubic ? key4 * 3 + 1 : key4) * width + width));
|
|
23395
23566
|
const last = times.length - 1;
|
|
@@ -23401,16 +23572,16 @@ function poseNodes(document, pose) {
|
|
|
23401
23572
|
const span = times[key3 + 1] - times[key3];
|
|
23402
23573
|
const f = span > 0 ? (time - times[key3]) / span : 0;
|
|
23403
23574
|
const next = valueAt(key3 + 1);
|
|
23404
|
-
const sign =
|
|
23575
|
+
const sign = path81 === "rotation" && value.reduce((sum, v, k) => sum + v * next[k], 0) < 0 ? -1 : 1;
|
|
23405
23576
|
value = value.map((v, k) => v * (1 - f) + next[k] * sign * f);
|
|
23406
23577
|
}
|
|
23407
|
-
if (
|
|
23578
|
+
if (path81 === "rotation") {
|
|
23408
23579
|
const length = Math.hypot(...value) || 1;
|
|
23409
23580
|
value = value.map((v) => v / length);
|
|
23410
23581
|
}
|
|
23411
23582
|
const base = posed.get(node) ?? { ...document.json.nodes?.[node] ?? {} };
|
|
23412
23583
|
if (base.matrix) delete base.matrix;
|
|
23413
|
-
base[
|
|
23584
|
+
base[path81] = value;
|
|
23414
23585
|
posed.set(node, base);
|
|
23415
23586
|
}
|
|
23416
23587
|
return posed;
|
|
@@ -25893,7 +26064,7 @@ function describeSize(document, image) {
|
|
|
25893
26064
|
}
|
|
25894
26065
|
|
|
25895
26066
|
// src/cli/commands/gallery.ts
|
|
25896
|
-
import
|
|
26067
|
+
import path48 from "path";
|
|
25897
26068
|
import { existsSync as existsSync39 } from "fs";
|
|
25898
26069
|
|
|
25899
26070
|
// src/gallery/server.ts
|
|
@@ -26633,6 +26804,83 @@ async function poll(provider, lock, lockPath, opts = {}) {
|
|
|
26633
26804
|
return result;
|
|
26634
26805
|
}
|
|
26635
26806
|
|
|
26807
|
+
// src/pipeline/layer-preview.ts
|
|
26808
|
+
import { mkdir as mkdir19, rm as rm13, writeFile as writeFile23 } from "fs/promises";
|
|
26809
|
+
import path44 from "path";
|
|
26810
|
+
function layerSourceOutputs(spec, lock) {
|
|
26811
|
+
return spec.character.layer.sources.flatMap((source) => {
|
|
26812
|
+
const sourceEntry = lock.entries[lockKey(source.spec.styleId, source.spec.assetId)];
|
|
26813
|
+
return sourceEntry.outputs.map((output, index) => ({
|
|
26814
|
+
path: currentEntryOutputPath(sourceEntry, source.spec, index),
|
|
26815
|
+
role: output.role,
|
|
26816
|
+
assetId: source.assetId,
|
|
26817
|
+
still: source.spec.character?.kind !== "animation"
|
|
26818
|
+
}));
|
|
26819
|
+
});
|
|
26820
|
+
}
|
|
26821
|
+
function overlay(sheet, mask) {
|
|
26822
|
+
const image = decodePng(sheet);
|
|
26823
|
+
const allowed = decodePng(mask);
|
|
26824
|
+
const out = Buffer.from(image.pixels);
|
|
26825
|
+
for (let i = 0; i < out.length; i += 4) {
|
|
26826
|
+
if (allowed.pixels[i] === 255) {
|
|
26827
|
+
out[i] = Math.round(out[i] * 0.4 + 255 * 0.6);
|
|
26828
|
+
out[i + 1] = Math.round(out[i + 1] * 0.4);
|
|
26829
|
+
out[i + 2] = Math.round(out[i + 2] * 0.4 + 255 * 0.6);
|
|
26830
|
+
out[i + 3] = 255;
|
|
26831
|
+
} else if (out[i + 3]) {
|
|
26832
|
+
out[i + 3] = 110;
|
|
26833
|
+
}
|
|
26834
|
+
}
|
|
26835
|
+
return encodeRgbaPng(image.width, image.height, out);
|
|
26836
|
+
}
|
|
26837
|
+
async function previewLayer(spec, lock) {
|
|
26838
|
+
const label = `${spec.styleId}/${spec.assetId}`;
|
|
26839
|
+
const layer = spec.character?.kind === "layer" ? spec.character.layer : void 0;
|
|
26840
|
+
if (!layer) throw new Error(`${label} is not a paperdoll layer`);
|
|
26841
|
+
if (layer.attach) throw new Error(`${label} is a held item, placed rather than inpainted; it has no mask to preview`);
|
|
26842
|
+
await requireRevisionReady(spec, lock);
|
|
26843
|
+
const built = layerSheetFor(spec, layerSourceOutputs(spec, lock));
|
|
26844
|
+
const { width, height } = decodePng(built.keyed);
|
|
26845
|
+
const dir = path44.join(layerWorkDir(spec), "preview");
|
|
26846
|
+
await rm13(dir, { recursive: true, force: true });
|
|
26847
|
+
await mkdir19(path44.join(dir, "frames"), { recursive: true });
|
|
26848
|
+
const written = [];
|
|
26849
|
+
const put = async (name, png) => {
|
|
26850
|
+
const file = path44.join(dir, name);
|
|
26851
|
+
await writeFile23(file, png);
|
|
26852
|
+
written.push(file);
|
|
26853
|
+
};
|
|
26854
|
+
await put("sheet.png", built.sheet);
|
|
26855
|
+
await put("keyed.png", built.keyed);
|
|
26856
|
+
await put("mask.png", built.mask);
|
|
26857
|
+
await put("overlay.png", overlay(built.sheet, built.mask));
|
|
26858
|
+
const cells = built.frames.map((frame) => frame.cell);
|
|
26859
|
+
const keyedCells = unpackSheet(built.keyed, cells);
|
|
26860
|
+
const maskCells = unpackSheet(built.mask, cells);
|
|
26861
|
+
const frames = [];
|
|
26862
|
+
for (const [index, frame] of built.frames.entries()) {
|
|
26863
|
+
const name = `${frame.assetId}.${frame.role ?? String(index).padStart(2, "0")}`;
|
|
26864
|
+
const stem2 = `${String(index).padStart(3, "0")}-${name.replace(/[^A-Za-z0-9._-]/g, "_")}`;
|
|
26865
|
+
await put(path44.join("frames", `${stem2}.keyed.png`), keyedCells[index]);
|
|
26866
|
+
await put(path44.join("frames", `${stem2}.mask.png`), maskCells[index]);
|
|
26867
|
+
const { pixels } = decodePng(maskCells[index]);
|
|
26868
|
+
let masked = 0;
|
|
26869
|
+
for (let i = 0; i < pixels.length; i += 4) if (pixels[i] === 255) masked++;
|
|
26870
|
+
frames.push({ name, neck: built.necks?.[index] ?? null, masked });
|
|
26871
|
+
}
|
|
26872
|
+
return {
|
|
26873
|
+
dir,
|
|
26874
|
+
sheet: { width, height },
|
|
26875
|
+
cost: proTierCost(width, height),
|
|
26876
|
+
frames,
|
|
26877
|
+
supplied: { mask: Boolean(layer.mask), keyed: Boolean(layer.keyed) },
|
|
26878
|
+
...built.closed !== void 0 ? { closed: built.closed } : {},
|
|
26879
|
+
cleaned: built.cleaned,
|
|
26880
|
+
written
|
|
26881
|
+
};
|
|
26882
|
+
}
|
|
26883
|
+
|
|
26636
26884
|
// src/pipeline/submit.ts
|
|
26637
26885
|
var IN_FLIGHT_POLL_MS = 5e3;
|
|
26638
26886
|
var sleep2 = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
@@ -26915,15 +27163,7 @@ async function submit(provider, loaded, items, lock, lockPath, opts = {}) {
|
|
|
26915
27163
|
const parentOutputs = spec.character?.kind === "outfit" && parentEntry ? parentEntry.outputs.map((output, index) => ({
|
|
26916
27164
|
path: currentEntryOutputPath(parentEntry, spec.character.parentSpec, index),
|
|
26917
27165
|
role: output.role
|
|
26918
|
-
})) : spec.character?.kind === "layer" ? spec
|
|
26919
|
-
const sourceEntry = lock.entries[lockKey(source.spec.styleId, source.spec.assetId)];
|
|
26920
|
-
return sourceEntry.outputs.map((output, index) => ({
|
|
26921
|
-
path: currentEntryOutputPath(sourceEntry, source.spec, index),
|
|
26922
|
-
role: output.role,
|
|
26923
|
-
assetId: source.assetId,
|
|
26924
|
-
still: source.spec.character?.kind !== "animation"
|
|
26925
|
-
}));
|
|
26926
|
-
}) : void 0;
|
|
27166
|
+
})) : spec.character?.kind === "layer" ? layerSourceOutputs(spec, lock) : void 0;
|
|
26927
27167
|
const referenceSourceImageId = ownedReferenceImageId(spec, lock, provider.id);
|
|
26928
27168
|
const { jobId, metadata } = await provider.submit(spec, refs, {
|
|
26929
27169
|
...previousJobId ? { previousJobId } : {},
|
|
@@ -26972,6 +27212,13 @@ async function submit(provider, loaded, items, lock, lockPath, opts = {}) {
|
|
|
26972
27212
|
log2(
|
|
26973
27213
|
` ${key3} \u2192 ${jobId} (${spec.width}x${spec.height}` + (estimate.candidates > 1 ? `, ${estimate.candidates} ${spec.tileFeature ? "outputs" : "candidates"}` : "") + `, ${estimate.amount})`
|
|
26974
27214
|
);
|
|
27215
|
+
const sheet = metadata?.character?.sheet;
|
|
27216
|
+
if (sheet?.necks) {
|
|
27217
|
+
log2(` neck rows by frame: ${sheet.necks.map((row) => row ?? "-").join(" ")}`);
|
|
27218
|
+
if (sheet.neckCorrected?.length) {
|
|
27219
|
+
log2(` frame${sheet.neckCorrected.length === 1 ? "" : "s"} ${sheet.neckCorrected.join(", ")}: own narrowest row disagreed; neck taken from the head and the other frames`);
|
|
27220
|
+
}
|
|
27221
|
+
}
|
|
26975
27222
|
} catch (err) {
|
|
26976
27223
|
const message6 = err instanceof Error ? err.message : String(err);
|
|
26977
27224
|
const entry = lock.entries[key3];
|
|
@@ -27014,9 +27261,9 @@ import { existsSync as existsSync37 } from "fs";
|
|
|
27014
27261
|
import { readFile as readFile33 } from "fs/promises";
|
|
27015
27262
|
|
|
27016
27263
|
// src/pipeline/init.ts
|
|
27017
|
-
import { readdir as readdir4, readFile as readFile32, writeFile as
|
|
27264
|
+
import { readdir as readdir4, readFile as readFile32, writeFile as writeFile24 } from "fs/promises";
|
|
27018
27265
|
import { existsSync as existsSync36 } from "fs";
|
|
27019
|
-
import
|
|
27266
|
+
import path45 from "path";
|
|
27020
27267
|
function pngSize(buf) {
|
|
27021
27268
|
if (buf.length < 24) return null;
|
|
27022
27269
|
const isPng = buf.readUInt32BE(0) === 2303741511 && buf.readUInt32BE(4) === 218765834;
|
|
@@ -27030,7 +27277,7 @@ function slugify(value) {
|
|
|
27030
27277
|
async function walk(dir, exclude) {
|
|
27031
27278
|
const out = [];
|
|
27032
27279
|
for (const entry of await readdir4(dir, { withFileTypes: true })) {
|
|
27033
|
-
const full =
|
|
27280
|
+
const full = path45.join(dir, entry.name);
|
|
27034
27281
|
if (exclude.some((x) => full.includes(x))) continue;
|
|
27035
27282
|
if (entry.isDirectory()) out.push(...await walk(full, exclude));
|
|
27036
27283
|
else if (entry.name.toLowerCase().endsWith(".png")) out.push(full);
|
|
@@ -27049,9 +27296,9 @@ async function scanAssets(root, opts = {}) {
|
|
|
27049
27296
|
skipped.push(`${file} (not a readable PNG)`);
|
|
27050
27297
|
continue;
|
|
27051
27298
|
}
|
|
27052
|
-
const rel =
|
|
27053
|
-
const category =
|
|
27054
|
-
let id = slugify(
|
|
27299
|
+
const rel = path45.relative(root, file);
|
|
27300
|
+
const category = path45.dirname(rel) === "." ? "" : path45.dirname(rel);
|
|
27301
|
+
let id = slugify(path45.basename(rel));
|
|
27055
27302
|
if (seen.has(id)) {
|
|
27056
27303
|
const n = seen.get(id) + 1;
|
|
27057
27304
|
seen.set(id, n);
|
|
@@ -27112,7 +27359,7 @@ async function writeManifestFile(target, manifest) {
|
|
|
27112
27359
|
if (existsSync36(target)) {
|
|
27113
27360
|
throw new Error(`${target} already exists; refusing to overwrite an existing manifest.`);
|
|
27114
27361
|
}
|
|
27115
|
-
await
|
|
27362
|
+
await writeFile24(target, JSON.stringify(manifest, null, 2) + "\n");
|
|
27116
27363
|
}
|
|
27117
27364
|
|
|
27118
27365
|
// src/pick/sheet.ts
|
|
@@ -28820,14 +29067,14 @@ function createGenerateHandlers(opts) {
|
|
|
28820
29067
|
|
|
28821
29068
|
// src/gallery/editor.ts
|
|
28822
29069
|
import { readFile as readFile35 } from "fs/promises";
|
|
28823
|
-
import
|
|
29070
|
+
import path47 from "path";
|
|
28824
29071
|
|
|
28825
29072
|
// src/editor/install.ts
|
|
28826
29073
|
import { createHash as createHash6 } from "crypto";
|
|
28827
29074
|
import { existsSync as existsSync38 } from "fs";
|
|
28828
|
-
import { mkdir as
|
|
29075
|
+
import { mkdir as mkdir20, readFile as readFile34, rename as rename14, rm as rm14, stat as stat4, writeFile as writeFile25 } from "fs/promises";
|
|
28829
29076
|
import os3 from "os";
|
|
28830
|
-
import
|
|
29077
|
+
import path46 from "path";
|
|
28831
29078
|
|
|
28832
29079
|
// tools/pixelorama-bridge/pin.json
|
|
28833
29080
|
var pin_default = {
|
|
@@ -28891,15 +29138,15 @@ var EditorInstallError = class extends Error {
|
|
|
28891
29138
|
};
|
|
28892
29139
|
function editorToolsRoot() {
|
|
28893
29140
|
const override = process.env.PIXELKILN_TOOLS_DIR?.trim();
|
|
28894
|
-
if (override) return
|
|
28895
|
-
if (process.platform === "darwin") return
|
|
29141
|
+
if (override) return path46.resolve(override);
|
|
29142
|
+
if (process.platform === "darwin") return path46.join(os3.homedir(), "Library", "Caches", "pixelkiln", "tools");
|
|
28896
29143
|
if (process.platform === "win32") {
|
|
28897
|
-
return
|
|
29144
|
+
return path46.join(process.env.LOCALAPPDATA ?? path46.join(os3.homedir(), "AppData", "Local"), "pixelkiln", "tools");
|
|
28898
29145
|
}
|
|
28899
|
-
return
|
|
29146
|
+
return path46.join(process.env.XDG_CACHE_HOME ?? path46.join(os3.homedir(), ".cache"), "pixelkiln", "tools");
|
|
28900
29147
|
}
|
|
28901
29148
|
function editorDir(pin = EDITOR_PIN, root = editorToolsRoot()) {
|
|
28902
|
-
return
|
|
29149
|
+
return path46.join(root, "pixelorama", pin.release ?? "unpublished");
|
|
28903
29150
|
}
|
|
28904
29151
|
function editorBaseUrl(pin = EDITOR_PIN) {
|
|
28905
29152
|
const override = process.env.PIXELKILN_EDITOR_URL?.trim();
|
|
@@ -28922,7 +29169,7 @@ async function editorStatus(opts = {}) {
|
|
|
28922
29169
|
let totalBytes = 0;
|
|
28923
29170
|
for (const [name, expected] of Object.entries(pin.files)) {
|
|
28924
29171
|
totalBytes += expected.bytes;
|
|
28925
|
-
const file =
|
|
29172
|
+
const file = path46.join(dir, name);
|
|
28926
29173
|
const info = existsSync38(file) ? await stat4(file).catch(() => null) : null;
|
|
28927
29174
|
if (info && info.size === expected.bytes && await sha256Of(file) === expected.sha256) {
|
|
28928
29175
|
installedBytes += expected.bytes;
|
|
@@ -28952,7 +29199,7 @@ async function installEditor(opts = {}) {
|
|
|
28952
29199
|
);
|
|
28953
29200
|
}
|
|
28954
29201
|
if (!baseUrl) throw new EditorInstallError("no download location for the editor build");
|
|
28955
|
-
await
|
|
29202
|
+
await mkdir20(dir, { recursive: true });
|
|
28956
29203
|
const downloaded = [];
|
|
28957
29204
|
const skipped = Object.keys(pin.files).filter((name) => !before.missing.includes(name));
|
|
28958
29205
|
let fetchedBytes = before.installedBytes;
|
|
@@ -28980,13 +29227,13 @@ async function installEditor(opts = {}) {
|
|
|
28980
29227
|
if (digest2 !== expected.sha256) {
|
|
28981
29228
|
throw new EditorInstallError(`${name}: sha256 ${digest2.slice(0, 12)}\u2026 does not match the pinned ${expected.sha256.slice(0, 12)}\u2026`, name);
|
|
28982
29229
|
}
|
|
28983
|
-
const final =
|
|
29230
|
+
const final = path46.join(dir, name);
|
|
28984
29231
|
const tmp = `${final}.${process.pid}.part`;
|
|
28985
29232
|
try {
|
|
28986
|
-
await
|
|
29233
|
+
await writeFile25(tmp, bytes);
|
|
28987
29234
|
await rename14(tmp, final);
|
|
28988
29235
|
} finally {
|
|
28989
|
-
await
|
|
29236
|
+
await rm14(tmp, { force: true });
|
|
28990
29237
|
}
|
|
28991
29238
|
fetchedBytes += bytes.length;
|
|
28992
29239
|
downloaded.push(name);
|
|
@@ -29026,7 +29273,7 @@ var EDITOR_CONTENT_TYPES = {
|
|
|
29026
29273
|
".json": "application/json; charset=utf-8"
|
|
29027
29274
|
};
|
|
29028
29275
|
function editorContentType(name) {
|
|
29029
|
-
return EDITOR_CONTENT_TYPES[
|
|
29276
|
+
return EDITOR_CONTENT_TYPES[path46.extname(name).toLowerCase()] ?? null;
|
|
29030
29277
|
}
|
|
29031
29278
|
|
|
29032
29279
|
// src/gallery/editor.ts
|
|
@@ -29102,7 +29349,7 @@ function createGalleryEditorHandlers(opts = {}) {
|
|
|
29102
29349
|
if (!status.installed) return null;
|
|
29103
29350
|
let bytes;
|
|
29104
29351
|
try {
|
|
29105
|
-
bytes = await readFile35(
|
|
29352
|
+
bytes = await readFile35(path47.join(dir, name));
|
|
29106
29353
|
} catch {
|
|
29107
29354
|
verified = null;
|
|
29108
29355
|
return null;
|
|
@@ -29142,7 +29389,7 @@ async function serveUntilStopped(initial, reload, args, access2) {
|
|
|
29142
29389
|
};
|
|
29143
29390
|
const loadProject = async (project2) => {
|
|
29144
29391
|
const ctx = await access2.loadProject(project2);
|
|
29145
|
-
loadProjectEnv(
|
|
29392
|
+
loadProjectEnv(path48.dirname(ctx.loaded.path));
|
|
29146
29393
|
return ctx;
|
|
29147
29394
|
};
|
|
29148
29395
|
const loadProjectEnv = (dir) => {
|
|
@@ -29151,7 +29398,7 @@ async function serveUntilStopped(initial, reload, args, access2) {
|
|
|
29151
29398
|
for (const [name, value] of Object.entries(declared)) {
|
|
29152
29399
|
if (credentialNames.has(name) && name in process.env && process.env[name] !== value) {
|
|
29153
29400
|
throw new Error(
|
|
29154
|
-
`${
|
|
29401
|
+
`${path48.relative(process.cwd(), dir) || "."} sets ${name} to a different value than the one this gallery already loaded; run a separate gallery for that project so its work uses its own account.`
|
|
29155
29402
|
);
|
|
29156
29403
|
}
|
|
29157
29404
|
}
|
|
@@ -29159,7 +29406,7 @@ async function serveUntilStopped(initial, reload, args, access2) {
|
|
|
29159
29406
|
};
|
|
29160
29407
|
const quoters = /* @__PURE__ */ new Map();
|
|
29161
29408
|
const quoteFor = async (project2) => {
|
|
29162
|
-
loadProjectEnv(
|
|
29409
|
+
loadProjectEnv(path48.dirname(path48.resolve(await access2.manifestFor(project2))));
|
|
29163
29410
|
const key3 = process.env.PIXELLAB_API_KEY;
|
|
29164
29411
|
if (!key3) return null;
|
|
29165
29412
|
let quoter = quoters.get(key3);
|
|
@@ -29210,7 +29457,7 @@ async function serveUntilStopped(initial, reload, args, access2) {
|
|
|
29210
29457
|
}
|
|
29211
29458
|
async function runGallery(args) {
|
|
29212
29459
|
if (args.workspace) {
|
|
29213
|
-
const workspacePath =
|
|
29460
|
+
const workspacePath = path48.resolve(args.workspace);
|
|
29214
29461
|
if (!existsSync39(workspacePath)) {
|
|
29215
29462
|
throw new Error(`Workspace catalog not found: ${workspacePath}`);
|
|
29216
29463
|
}
|
|
@@ -29231,7 +29478,7 @@ async function runGallery(args) {
|
|
|
29231
29478
|
const registered = async (projectId) => {
|
|
29232
29479
|
const project2 = (await loadWorkspace(workspacePath)).projects.find((candidate) => candidate.id === projectId);
|
|
29233
29480
|
if (!projectId || !project2) throw new Error(`unknown workspace project "${projectId ?? ""}"`);
|
|
29234
|
-
return resolveProject(
|
|
29481
|
+
return resolveProject(path48.dirname(workspacePath), project2);
|
|
29235
29482
|
};
|
|
29236
29483
|
await serveUntilStopped(initial, build2, args, {
|
|
29237
29484
|
manifestFor: async (projectId) => (await registered(projectId)).manifestPath,
|
|
@@ -29256,7 +29503,7 @@ async function runGallery(args) {
|
|
|
29256
29503
|
return buildGallerySnapshot({ ...fresh, filter });
|
|
29257
29504
|
};
|
|
29258
29505
|
await serveUntilStopped(await build(), reload, args, {
|
|
29259
|
-
manifestFor: () =>
|
|
29506
|
+
manifestFor: () => path48.resolve(args.manifest),
|
|
29260
29507
|
loadProject: () => openProject(args.manifest, { lockPath: args.lock, env: false })
|
|
29261
29508
|
});
|
|
29262
29509
|
}
|
|
@@ -29603,14 +29850,14 @@ import { existsSync as existsSync41 } from "fs";
|
|
|
29603
29850
|
|
|
29604
29851
|
// src/pipeline/cache-health.ts
|
|
29605
29852
|
import { existsSync as existsSync40 } from "fs";
|
|
29606
|
-
import { readFile as readFile36, readdir as readdir5, rm as
|
|
29607
|
-
import
|
|
29853
|
+
import { readFile as readFile36, readdir as readdir5, rm as rm15 } from "fs/promises";
|
|
29854
|
+
import path49 from "path";
|
|
29608
29855
|
async function inspectCaches(lock, lockPath, options = {}) {
|
|
29609
29856
|
if (options.prune && !existsSync40(lockPath)) {
|
|
29610
|
-
throw new Error(`Refusing to prune without an existing lockfile at ${
|
|
29857
|
+
throw new Error(`Refusing to prune without an existing lockfile at ${path49.resolve(lockPath)}`);
|
|
29611
29858
|
}
|
|
29612
|
-
const contentDir =
|
|
29613
|
-
const remotePath =
|
|
29859
|
+
const contentDir = path49.resolve(path49.dirname(lockPath), ".pixelkiln", "cache");
|
|
29860
|
+
const remotePath = path49.resolve(cachePathFor(lockPath));
|
|
29614
29861
|
const referenced = referencedHashes(lock);
|
|
29615
29862
|
let content = await inspectContentCache(contentDir, referenced);
|
|
29616
29863
|
let remoteHashes = await inspectRemoteHashCache(remotePath);
|
|
@@ -29622,7 +29869,7 @@ async function inspectCaches(lock, lockPath, options = {}) {
|
|
|
29622
29869
|
]);
|
|
29623
29870
|
for (const name of names) {
|
|
29624
29871
|
try {
|
|
29625
|
-
await
|
|
29872
|
+
await rm15(path49.join(contentDir, name), { force: true });
|
|
29626
29873
|
removed.contentFiles++;
|
|
29627
29874
|
} catch {
|
|
29628
29875
|
}
|
|
@@ -29670,7 +29917,7 @@ async function inspectContentCache(contentDir, referenced) {
|
|
|
29670
29917
|
continue;
|
|
29671
29918
|
}
|
|
29672
29919
|
report.files++;
|
|
29673
|
-
const file =
|
|
29920
|
+
const file = path49.join(contentDir, entry.name);
|
|
29674
29921
|
const mediaType = mediaTypeFromExtension(entry.name);
|
|
29675
29922
|
const expected = mediaType ? entry.name.slice(0, -4) : "";
|
|
29676
29923
|
let bytes;
|
|
@@ -29841,46 +30088,46 @@ This drops their provenance from the lockfile. The art on disk is`);
|
|
|
29841
30088
|
}
|
|
29842
30089
|
|
|
29843
30090
|
// src/cli/commands/init.ts
|
|
29844
|
-
import
|
|
30091
|
+
import path50 from "path";
|
|
29845
30092
|
import { existsSync as existsSync42 } from "fs";
|
|
29846
30093
|
async function runInit(args) {
|
|
29847
30094
|
if (!args.from) throw new Error("init needs --from <dir> pointing at your existing PNGs.");
|
|
29848
|
-
const root =
|
|
30095
|
+
const root = path50.resolve(args.from);
|
|
29849
30096
|
if (!existsSync42(root)) throw new Error(`No directory at ${root}`);
|
|
29850
30097
|
const generator = args.generator ?? "map";
|
|
29851
30098
|
if (generator !== "1dir" && generator !== "map") {
|
|
29852
30099
|
throw new Error(`--generator must be "1dir" or "map", got "${args.generator}".`);
|
|
29853
30100
|
}
|
|
29854
|
-
const target =
|
|
30101
|
+
const target = path50.resolve(args.out ?? "pixelkiln.manifest.json");
|
|
29855
30102
|
const { assets, skipped } = await scanAssets(root, { exclude: args.exclude });
|
|
29856
30103
|
if (!assets.length) throw new Error(`No PNGs found under ${root}`);
|
|
29857
30104
|
const manifest = buildManifest(
|
|
29858
|
-
args.name ??
|
|
30105
|
+
args.name ?? path50.basename(path50.dirname(target)),
|
|
29859
30106
|
args.styles[0] ?? "base",
|
|
29860
30107
|
generator,
|
|
29861
|
-
|
|
30108
|
+
path50.relative(path50.dirname(target), root) || ".",
|
|
29862
30109
|
assets
|
|
29863
30110
|
);
|
|
29864
30111
|
await writeManifestFile(target, manifest);
|
|
29865
|
-
log(` scanned ${assets.length} PNG(s) under ${
|
|
30112
|
+
log(` scanned ${assets.length} PNG(s) under ${path50.relative(process.cwd(), root)}`);
|
|
29866
30113
|
if (skipped.length) log(` skipped ${skipped.length} unreadable file(s)`);
|
|
29867
|
-
log(` wrote ${
|
|
30114
|
+
log(` wrote ${path50.relative(process.cwd(), target)}`);
|
|
29868
30115
|
log(`
|
|
29869
30116
|
Prompts are intentionally empty. To recover the real ones from your`);
|
|
29870
30117
|
log(` PixelLab account instead of inventing them:`);
|
|
29871
30118
|
log(`
|
|
29872
|
-
pixelkiln adopt --manifest ${
|
|
30119
|
+
pixelkiln adopt --manifest ${path50.relative(process.cwd(), target)} --write-prompts
|
|
29873
30120
|
`);
|
|
29874
30121
|
}
|
|
29875
30122
|
|
|
29876
30123
|
// src/pipeline/doctor.ts
|
|
29877
30124
|
import { constants, existsSync as existsSync44 } from "fs";
|
|
29878
30125
|
import { access, stat as stat5 } from "fs/promises";
|
|
29879
|
-
import
|
|
30126
|
+
import path52 from "path";
|
|
29880
30127
|
|
|
29881
30128
|
// src/pipeline/install-check.ts
|
|
29882
30129
|
import { existsSync as existsSync43, readFileSync as readFileSync7 } from "fs";
|
|
29883
|
-
import
|
|
30130
|
+
import path51 from "path";
|
|
29884
30131
|
function readJson(file) {
|
|
29885
30132
|
try {
|
|
29886
30133
|
return JSON.parse(readFileSync7(file, "utf8"));
|
|
@@ -29889,18 +30136,18 @@ function readJson(file) {
|
|
|
29889
30136
|
}
|
|
29890
30137
|
}
|
|
29891
30138
|
function readInstallFacts(manifestDir, running) {
|
|
29892
|
-
let dir =
|
|
30139
|
+
let dir = path51.resolve(manifestDir);
|
|
29893
30140
|
for (let depth = 0; depth < 4; depth++) {
|
|
29894
|
-
const pkg = readJson(
|
|
30141
|
+
const pkg = readJson(path51.join(dir, "package.json"));
|
|
29895
30142
|
if (pkg) {
|
|
29896
30143
|
const pinned = ["dependencies", "devDependencies", "optionalDependencies"].map((field) => pkg[field]?.pixelkiln).find((spec) => typeof spec === "string");
|
|
29897
30144
|
if (pinned) {
|
|
29898
|
-
const installedPkg = readJson(
|
|
30145
|
+
const installedPkg = readJson(path51.join(dir, "node_modules", "pixelkiln", "package.json"));
|
|
29899
30146
|
const installed = typeof installedPkg?.version === "string" ? installedPkg.version : void 0;
|
|
29900
30147
|
return { pinned, installed, running };
|
|
29901
30148
|
}
|
|
29902
30149
|
}
|
|
29903
|
-
const parent =
|
|
30150
|
+
const parent = path51.dirname(dir);
|
|
29904
30151
|
if (parent === dir || !existsSync43(parent)) break;
|
|
29905
30152
|
dir = parent;
|
|
29906
30153
|
}
|
|
@@ -29964,12 +30211,12 @@ async function doctor(loaded, specs, lock, lockPath, opts = {}) {
|
|
|
29964
30211
|
`${entry.kind === "style" ? "styles" : "assets"}.${entry.id} was left out: ${entry.issues.join("; ")}`
|
|
29965
30212
|
);
|
|
29966
30213
|
}
|
|
29967
|
-
const facts = readInstallFacts(
|
|
30214
|
+
const facts = readInstallFacts(path52.dirname(loaded.path), opts.runningVersion !== void 0 ? opts.runningVersion : pixelkilnVersion());
|
|
29968
30215
|
if (facts) for (const finding of checkInstall(facts)) add("install", finding.level, finding.message);
|
|
29969
30216
|
add("lock", "ok", `${Object.keys(lock.entries).length} valid v2 lock entr(ies)`);
|
|
29970
30217
|
const dirs = [...new Set(specs.flatMap((spec) => [
|
|
29971
|
-
|
|
29972
|
-
...spec.quality ? [
|
|
30218
|
+
path52.dirname(spec.outFile),
|
|
30219
|
+
...spec.quality ? [path52.dirname(spec.quality.outFile)] : []
|
|
29973
30220
|
]))];
|
|
29974
30221
|
const unwritable = [];
|
|
29975
30222
|
for (const dir of dirs) {
|
|
@@ -29992,7 +30239,7 @@ async function doctor(loaded, specs, lock, lockPath, opts = {}) {
|
|
|
29992
30239
|
for (let index = 0; index < entry.outputs.length; index++) {
|
|
29993
30240
|
const output = entry.outputs[index];
|
|
29994
30241
|
const spec = specByKey.get(key3);
|
|
29995
|
-
const absolute = spec ? currentEntryOutputPath(entry, spec, index) : resolveOutputPath(output.path,
|
|
30242
|
+
const absolute = spec ? currentEntryOutputPath(entry, spec, index) : resolveOutputPath(output.path, path52.dirname(lockPath));
|
|
29996
30243
|
const owner = outputOwners.get(absolute);
|
|
29997
30244
|
if (owner && owner !== key3) duplicateOutputs.push(`${output.path} (${owner}, ${key3})`);
|
|
29998
30245
|
outputOwners.set(absolute, key3);
|
|
@@ -30007,7 +30254,7 @@ async function doctor(loaded, specs, lock, lockPath, opts = {}) {
|
|
|
30007
30254
|
} else {
|
|
30008
30255
|
add("lock-outputs", "ok", `${outputOwners.size} recorded output path(s) are uniquely owned`);
|
|
30009
30256
|
}
|
|
30010
|
-
const cacheDir =
|
|
30257
|
+
const cacheDir = path52.join(path52.dirname(lockPath), ".pixelkiln", "cache");
|
|
30011
30258
|
const stranded = [];
|
|
30012
30259
|
const invalidState = [];
|
|
30013
30260
|
const staleMapUrls = [];
|
|
@@ -30023,7 +30270,7 @@ async function doctor(loaded, specs, lock, lockPath, opts = {}) {
|
|
|
30023
30270
|
const hasSource = Boolean(entry.sourceUrl || entry.sourceUrls?.length);
|
|
30024
30271
|
let hasCache = false;
|
|
30025
30272
|
for (const output of entry.outputs) {
|
|
30026
|
-
const cached2 =
|
|
30273
|
+
const cached2 = path52.join(
|
|
30027
30274
|
cacheDir,
|
|
30028
30275
|
cacheFileName(output.sha256, output.mediaType ?? MediaType.PNG)
|
|
30029
30276
|
);
|
|
@@ -30123,7 +30370,7 @@ async function nearestExistingDirectory(start) {
|
|
|
30123
30370
|
if ((await stat5(current)).isDirectory()) return current;
|
|
30124
30371
|
} catch {
|
|
30125
30372
|
}
|
|
30126
|
-
const parent =
|
|
30373
|
+
const parent = path52.dirname(current);
|
|
30127
30374
|
if (parent === current) return current;
|
|
30128
30375
|
current = parent;
|
|
30129
30376
|
}
|
|
@@ -30132,7 +30379,7 @@ async function nearestExistingDirectory(start) {
|
|
|
30132
30379
|
// src/pipeline/audit.ts
|
|
30133
30380
|
import { readFile as readFile37 } from "fs/promises";
|
|
30134
30381
|
import { existsSync as existsSync45 } from "fs";
|
|
30135
|
-
import
|
|
30382
|
+
import path53 from "path";
|
|
30136
30383
|
function paletteDistance(asset, reference) {
|
|
30137
30384
|
if (!asset.length || !reference.length) return 0;
|
|
30138
30385
|
let total = 0;
|
|
@@ -30197,7 +30444,7 @@ async function auditStyle(loaded, specs, styleId, lock) {
|
|
|
30197
30444
|
let referenceFromStyleImages = false;
|
|
30198
30445
|
const refPalettes = [];
|
|
30199
30446
|
for (const img of style.styleImages) {
|
|
30200
|
-
const abs =
|
|
30447
|
+
const abs = path53.resolve(loaded.root, img.path);
|
|
30201
30448
|
if (!existsSync45(abs)) continue;
|
|
30202
30449
|
try {
|
|
30203
30450
|
refPalettes.push(extractPalette(decodePng(await readFile37(abs)), 12));
|
|
@@ -30455,24 +30702,24 @@ async function runHash(args) {
|
|
|
30455
30702
|
}
|
|
30456
30703
|
|
|
30457
30704
|
// src/cli/commands/pack.ts
|
|
30458
|
-
import
|
|
30705
|
+
import path55 from "path";
|
|
30459
30706
|
import { readFile as readFile38 } from "fs/promises";
|
|
30460
30707
|
|
|
30461
30708
|
// src/pipeline/pack.ts
|
|
30462
30709
|
import { readFileSync as readFileSync8 } from "fs";
|
|
30463
|
-
import
|
|
30710
|
+
import path54 from "path";
|
|
30464
30711
|
var DEFAULT_FRAME_SET_FPS = 12;
|
|
30465
30712
|
function resolvePackInputs(raw, inputsFilePath) {
|
|
30466
30713
|
if (!Array.isArray(raw) || !raw.length) {
|
|
30467
30714
|
throw new Error("--inputs must be a non-empty JSON array of { id, path }");
|
|
30468
30715
|
}
|
|
30469
|
-
const baseDir =
|
|
30716
|
+
const baseDir = path54.dirname(path54.resolve(inputsFilePath));
|
|
30470
30717
|
return raw.map((entry, i) => {
|
|
30471
30718
|
const e = entry;
|
|
30472
30719
|
if (typeof e.id !== "string" || typeof e.path !== "string") {
|
|
30473
30720
|
throw new Error(`--inputs[${i}] needs string "id" and "path"`);
|
|
30474
30721
|
}
|
|
30475
|
-
return { id: e.id, path:
|
|
30722
|
+
return { id: e.id, path: path54.resolve(baseDir, e.path) };
|
|
30476
30723
|
});
|
|
30477
30724
|
}
|
|
30478
30725
|
function packSprites(inputs, options = {}) {
|
|
@@ -30556,7 +30803,7 @@ function packStyle(lock, styleId, manifestDir, options = {}) {
|
|
|
30556
30803
|
}
|
|
30557
30804
|
const inputs2 = Object.entries(options.sourceOverrides).map(([id, source]) => ({
|
|
30558
30805
|
id,
|
|
30559
|
-
path:
|
|
30806
|
+
path: path54.resolve(source)
|
|
30560
30807
|
}));
|
|
30561
30808
|
if (!inputs2.length) throw new Error(`No approved quality outputs for style "${styleId}".`);
|
|
30562
30809
|
const packed2 = packSprites(inputs2, options);
|
|
@@ -30588,7 +30835,7 @@ function packStyle(lock, styleId, manifestDir, options = {}) {
|
|
|
30588
30835
|
let outputs = resolveEntryOutputs(entry, id, manifestDir);
|
|
30589
30836
|
const source = sources[id];
|
|
30590
30837
|
if (source && outputs.length <= 1) {
|
|
30591
|
-
inputs.push({ id, path:
|
|
30838
|
+
inputs.push({ id, path: path54.resolve(manifestDir, source) });
|
|
30592
30839
|
continue;
|
|
30593
30840
|
}
|
|
30594
30841
|
if (source && sourceIsStem(source, entry, manifestDir)) {
|
|
@@ -30625,7 +30872,7 @@ function packStyle(lock, styleId, manifestDir, options = {}) {
|
|
|
30625
30872
|
}
|
|
30626
30873
|
}
|
|
30627
30874
|
for (const [id, source] of Object.entries(sources)) {
|
|
30628
|
-
if (!locked.has(id)) inputs.push({ id, path:
|
|
30875
|
+
if (!locked.has(id)) inputs.push({ id, path: path54.resolve(manifestDir, source) });
|
|
30629
30876
|
}
|
|
30630
30877
|
if (!inputs.length) {
|
|
30631
30878
|
throw new Error(`No readable sprites for style "${styleId}"; ${noOutput.length} skipped.`);
|
|
@@ -30760,7 +31007,7 @@ function mountStyle(lock, styleId, manifestDir, mount, cells, sources = {}, outp
|
|
|
30760
31007
|
const source = sources[id];
|
|
30761
31008
|
const entry = lock.entries[`${styleId}/${id}`];
|
|
30762
31009
|
if (source && !(entry && sourceIsStem(source, entry, manifestDir))) {
|
|
30763
|
-
placements.push({ id, path:
|
|
31010
|
+
placements.push({ id, path: path54.resolve(manifestDir, source), cell });
|
|
30764
31011
|
continue;
|
|
30765
31012
|
}
|
|
30766
31013
|
if (source && entry) {
|
|
@@ -30793,7 +31040,7 @@ function mountStyle(lock, styleId, manifestDir, mount, cells, sources = {}, outp
|
|
|
30793
31040
|
`Nothing to mount for style "${styleId}": ${ids.length} asset(s) declare a cell, but none has generated output or a \`source\`. Run \`pixelkiln gen --style ${styleId}\`, or point each at a file.${detail}`
|
|
30794
31041
|
);
|
|
30795
31042
|
}
|
|
30796
|
-
const basePng = mount.base ? readFileSync8(
|
|
31043
|
+
const basePng = mount.base ? readFileSync8(path54.resolve(manifestDir, mount.base)) : void 0;
|
|
30797
31044
|
const mounted = mountSprites(placements, {
|
|
30798
31045
|
cellWidth: mount.cellWidth,
|
|
30799
31046
|
cellHeight: mount.cellHeight,
|
|
@@ -30803,7 +31050,7 @@ function mountStyle(lock, styleId, manifestDir, mount, cells, sources = {}, outp
|
|
|
30803
31050
|
...mounted,
|
|
30804
31051
|
sources: mount.base ? [{
|
|
30805
31052
|
id: "$base",
|
|
30806
|
-
path:
|
|
31053
|
+
path: path54.resolve(manifestDir, mount.base),
|
|
30807
31054
|
sha256: sha256(basePng),
|
|
30808
31055
|
included: true
|
|
30809
31056
|
}, ...mounted.sources] : mounted.sources,
|
|
@@ -31980,12 +32227,12 @@ async function runPack(args) {
|
|
|
31980
32227
|
if (args.primaryOnly || args.outputRoles.length) {
|
|
31981
32228
|
throw new Error("--primary-only and --output-role require manifest-driven pack");
|
|
31982
32229
|
}
|
|
31983
|
-
const raw = JSON.parse(await readFile38(
|
|
32230
|
+
const raw = JSON.parse(await readFile38(path55.resolve(args.inputs), "utf8"));
|
|
31984
32231
|
const inputs = resolvePackInputs(raw, args.inputs);
|
|
31985
32232
|
const { png, atlas, skipped, sources } = packSprites(inputs, { columns: args.columns });
|
|
31986
32233
|
const format = sheetFormat(args);
|
|
31987
|
-
const base =
|
|
31988
|
-
const { extension, document } = renderSheetDocument(format, atlas, { imageName:
|
|
32234
|
+
const base = path55.resolve(args.out.replace(/\.(?:png|json|tres)$/i, ""));
|
|
32235
|
+
const { extension, document } = renderSheetDocument(format, atlas, { imageName: path55.basename(`${base}.png`) });
|
|
31989
32236
|
const outputs = [
|
|
31990
32237
|
{ path: `${base}.png`, data: png },
|
|
31991
32238
|
{ path: `${base}${extension}`, data: document }
|
|
@@ -31998,7 +32245,7 @@ async function runPack(args) {
|
|
|
31998
32245
|
log(
|
|
31999
32246
|
` ${atlas.frames.length} sprite(s), ${atlas.sheet.width}x${atlas.sheet.height} in ${atlas.columns} column(s), ${(png.length / 1024).toFixed(1)} KB (${format})`
|
|
32000
32247
|
);
|
|
32001
|
-
log(` ${
|
|
32248
|
+
log(` ${path55.relative(process.cwd(), base)}.png + ${extension} + .pixelkiln.json`);
|
|
32002
32249
|
for (const s of skipped) log(` skipped ${s.id}: ${s.reason}`);
|
|
32003
32250
|
return;
|
|
32004
32251
|
}
|
|
@@ -32006,7 +32253,7 @@ async function runPack(args) {
|
|
|
32006
32253
|
if (args.primaryOnly && args.outputRoles.length) {
|
|
32007
32254
|
throw new Error("pack accepts either --primary-only or --output-role, not both");
|
|
32008
32255
|
}
|
|
32009
|
-
const manifestDir =
|
|
32256
|
+
const manifestDir = path55.dirname(path55.resolve(args.manifest));
|
|
32010
32257
|
const styleIds = args.styles.length ? args.styles : Object.keys(loaded.manifest.styles);
|
|
32011
32258
|
for (const styleId of styleIds) {
|
|
32012
32259
|
const style = loaded.manifest.styles[styleId];
|
|
@@ -32021,9 +32268,9 @@ async function runPack(args) {
|
|
|
32021
32268
|
sourceOverrides: qualitySources,
|
|
32022
32269
|
sources: manifestSources(loaded.manifest, styleId)
|
|
32023
32270
|
});
|
|
32024
|
-
const base = args.out ?
|
|
32271
|
+
const base = args.out ? path55.resolve(args.out.replace(/\.(?:png|json|tres)$/i, "")) : path55.resolve(manifestDir, style.outDir, `${styleId}-sheet`);
|
|
32025
32272
|
const format = sheetFormat(args);
|
|
32026
|
-
const { extension, document } = renderSheetDocument(format, atlas, { imageName:
|
|
32273
|
+
const { extension, document } = renderSheetDocument(format, atlas, { imageName: path55.basename(`${base}.png`) });
|
|
32027
32274
|
const outputs = [
|
|
32028
32275
|
{ path: `${base}.png`, data: png },
|
|
32029
32276
|
{ path: `${base}${extension}`, data: document }
|
|
@@ -32055,13 +32302,13 @@ async function runPack(args) {
|
|
|
32055
32302
|
log(
|
|
32056
32303
|
` ${styleId}: ${atlas.frames.length} sprite(s), ${atlas.sheet.width}x${atlas.sheet.height} in ${atlas.columns} column(s)` + (atlas.sets?.length ? `, ${atlas.sets.length} set(s)` : "") + ` (${format})`
|
|
32057
32304
|
);
|
|
32058
|
-
log(` ${
|
|
32305
|
+
log(` ${path55.relative(process.cwd(), base)}.png + ${extension} + .pixelkiln.json`);
|
|
32059
32306
|
for (const s of skipped) log(` skipped ${s.id}: ${s.reason}`);
|
|
32060
32307
|
}
|
|
32061
32308
|
}
|
|
32062
32309
|
async function runMount(args) {
|
|
32063
32310
|
const { loaded, lock } = await openProject2(args);
|
|
32064
|
-
const manifestDir =
|
|
32311
|
+
const manifestDir = path55.dirname(path55.resolve(args.manifest));
|
|
32065
32312
|
const styleIds = args.styles.length ? args.styles : Object.keys(loaded.manifest.styles);
|
|
32066
32313
|
for (const styleId of styleIds) {
|
|
32067
32314
|
const style = loaded.manifest.styles[styleId];
|
|
@@ -32100,9 +32347,9 @@ async function runMount(args) {
|
|
|
32100
32347
|
sources,
|
|
32101
32348
|
outputRoles
|
|
32102
32349
|
);
|
|
32103
|
-
const out =
|
|
32350
|
+
const out = path55.resolve(manifestDir, style.mount.out);
|
|
32104
32351
|
const format = sheetFormat(args);
|
|
32105
|
-
const { extension, document } = renderSheetDocument(format, atlas, { imageName:
|
|
32352
|
+
const { extension, document } = renderSheetDocument(format, atlas, { imageName: path55.basename(out) });
|
|
32106
32353
|
const metadata = out.replace(/\.png$/, "") + extension;
|
|
32107
32354
|
const companion = out.replace(/\.png$/, "") + ".pixelkiln.json";
|
|
32108
32355
|
const outputs = [
|
|
@@ -32122,7 +32369,7 @@ async function runMount(args) {
|
|
|
32122
32369
|
await provenanceFile("$lock", args.lock),
|
|
32123
32370
|
...qualityRecords,
|
|
32124
32371
|
...artifactSources.filter(
|
|
32125
|
-
(source) => source.id !== "$base" ||
|
|
32372
|
+
(source) => source.id !== "$base" || path55.resolve(source.path) !== out
|
|
32126
32373
|
)
|
|
32127
32374
|
],
|
|
32128
32375
|
options: {
|
|
@@ -32136,14 +32383,14 @@ async function runMount(args) {
|
|
|
32136
32383
|
log(
|
|
32137
32384
|
` ${styleId}: ${atlas.frames.length} cell(s) into ${atlas.sheet.width}x${atlas.sheet.height}` + (overBase ? ` over ${style.mount.base}` : " (new sheet)")
|
|
32138
32385
|
);
|
|
32139
|
-
log(` ${
|
|
32386
|
+
log(` ${path55.relative(process.cwd(), out)} + atlas/provenance JSON`);
|
|
32140
32387
|
for (const s of skipped) log(` skipped ${s.id}: ${s.reason}`);
|
|
32141
32388
|
}
|
|
32142
32389
|
}
|
|
32143
32390
|
async function runExport(args) {
|
|
32144
32391
|
const { loaded, specs, lock } = await openProject2(args);
|
|
32145
32392
|
const format = args.format ?? "generic";
|
|
32146
|
-
const manifestDir =
|
|
32393
|
+
const manifestDir = path55.dirname(path55.resolve(args.manifest));
|
|
32147
32394
|
const selected = specs.filter((spec) => {
|
|
32148
32395
|
if (spec.generator !== "tiles" && spec.generator !== "terrain") return false;
|
|
32149
32396
|
if (args.styles.length && !args.styles.includes(spec.styleId)) return false;
|
|
@@ -32183,12 +32430,12 @@ async function runExport(args) {
|
|
|
32183
32430
|
const merged = group.length > 1;
|
|
32184
32431
|
const style = loaded.manifest.styles[spec.styleId];
|
|
32185
32432
|
const assetName = group.map((member) => member.assetId).join("-");
|
|
32186
|
-
const defaultBase =
|
|
32187
|
-
const base = args.out ?
|
|
32433
|
+
const defaultBase = path55.resolve(manifestDir, style.outDir, `${assetName}-tileset`);
|
|
32434
|
+
const base = args.out ? path55.resolve(args.out.replace(/\.(?:png|json|tsj|tres|ldtk)$/i, "")) : defaultBase;
|
|
32188
32435
|
const exportOptions = {
|
|
32189
32436
|
format,
|
|
32190
32437
|
manifestDir,
|
|
32191
|
-
imageName:
|
|
32438
|
+
imageName: path55.basename(`${base}.png`),
|
|
32192
32439
|
columns: args.columns
|
|
32193
32440
|
};
|
|
32194
32441
|
const result = merged ? exportMergedTilesets(
|
|
@@ -32210,7 +32457,7 @@ async function runExport(args) {
|
|
|
32210
32457
|
asset: result.generic.asset,
|
|
32211
32458
|
columns: args.columns ?? null,
|
|
32212
32459
|
format,
|
|
32213
|
-
image:
|
|
32460
|
+
image: path55.basename(`${base}.png`),
|
|
32214
32461
|
providerRules: result.generic.providerRules,
|
|
32215
32462
|
...merged ? { sets: result.generic.sets } : {},
|
|
32216
32463
|
style: spec.styleId,
|
|
@@ -32221,7 +32468,7 @@ async function runExport(args) {
|
|
|
32221
32468
|
` ${spec.styleId}/${merged ? group.map((member) => member.assetId).join(" + ") : spec.assetId}: ${result.generic.tiles.length} tile(s), ` + (merged ? `${result.generic.rules.terrains.length} terrains (${result.generic.rules.terrains.join(", ")}), ` : "") + `${result.generic.sheet.width}x${result.generic.sheet.height} (${format})`
|
|
32222
32469
|
);
|
|
32223
32470
|
log(
|
|
32224
|
-
` ${
|
|
32471
|
+
` ${path55.relative(process.cwd(), base)}.png + ${path55.basename(base)}${result.extension} + .pixelkiln.json`
|
|
32225
32472
|
);
|
|
32226
32473
|
for (const warning of result.warnings) log(` warning: ${warning}`);
|
|
32227
32474
|
}
|
|
@@ -32236,21 +32483,21 @@ function sheetFormat(args) {
|
|
|
32236
32483
|
|
|
32237
32484
|
// src/cli/commands/pixellab-utils.ts
|
|
32238
32485
|
import { readFile as readFile41 } from "fs/promises";
|
|
32239
|
-
import
|
|
32486
|
+
import path59 from "path";
|
|
32240
32487
|
|
|
32241
32488
|
// src/codex-vfx.ts
|
|
32242
32489
|
import { createHash as createHash8 } from "crypto";
|
|
32243
32490
|
import { existsSync as existsSync47, readFileSync as readFileSync9, readdirSync as readdirSync2 } from "fs";
|
|
32244
32491
|
import { readFile as readFile39 } from "fs/promises";
|
|
32245
32492
|
import { createRequire as createRequire2 } from "module";
|
|
32246
|
-
import
|
|
32493
|
+
import path57 from "path";
|
|
32247
32494
|
import { pathToFileURL } from "url";
|
|
32248
32495
|
import vm from "vm";
|
|
32249
32496
|
|
|
32250
32497
|
// src/local-vfx.ts
|
|
32251
32498
|
import { existsSync as existsSync46 } from "fs";
|
|
32252
|
-
import { mkdir as
|
|
32253
|
-
import
|
|
32499
|
+
import { mkdir as mkdir21, writeFile as writeFile26 } from "fs/promises";
|
|
32500
|
+
import path56 from "path";
|
|
32254
32501
|
function localSheet(render) {
|
|
32255
32502
|
const { width, height, frames } = render;
|
|
32256
32503
|
const columns = Math.min(frames.length, Math.max(1, Math.ceil(Math.sqrt(frames.length * height / width))));
|
|
@@ -32278,7 +32525,7 @@ function assertFreshOutputs(out, force) {
|
|
|
32278
32525
|
async function writeLocalVfx(opts) {
|
|
32279
32526
|
const { paths, render } = opts;
|
|
32280
32527
|
const sheet = localSheet(render);
|
|
32281
|
-
const clip =
|
|
32528
|
+
const clip = path56.basename(paths.sheet, ".png");
|
|
32282
32529
|
const anchor = { kind: "origin", ...render.anchor };
|
|
32283
32530
|
const size = { w: render.width, h: render.height };
|
|
32284
32531
|
const atlas = {
|
|
@@ -32294,7 +32541,7 @@ async function writeLocalVfx(opts) {
|
|
|
32294
32541
|
meta: {
|
|
32295
32542
|
app: "pixelkiln",
|
|
32296
32543
|
version: "1",
|
|
32297
|
-
image:
|
|
32544
|
+
image: path56.basename(paths.sheet),
|
|
32298
32545
|
format: "RGBA8888",
|
|
32299
32546
|
size: { w: sheet.columns * render.width, h: sheet.rows * render.height },
|
|
32300
32547
|
scale: "1",
|
|
@@ -32328,16 +32575,16 @@ async function writeLocalVfx(opts) {
|
|
|
32328
32575
|
version: 1,
|
|
32329
32576
|
...opts.record,
|
|
32330
32577
|
...facts,
|
|
32331
|
-
files: { sheet:
|
|
32578
|
+
files: { sheet: path56.basename(paths.sheet), atlas: path56.basename(paths.atlas) },
|
|
32332
32579
|
sheetSha256,
|
|
32333
32580
|
exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
32334
32581
|
recipe: opts.recipe
|
|
32335
32582
|
};
|
|
32336
|
-
await
|
|
32337
|
-
await
|
|
32338
|
-
await
|
|
32583
|
+
await mkdir21(path56.dirname(paths.sheet), { recursive: true });
|
|
32584
|
+
await writeFile26(paths.sheet, sheet.png);
|
|
32585
|
+
await writeFile26(paths.atlas, `${JSON.stringify(atlas, null, 2)}
|
|
32339
32586
|
`);
|
|
32340
|
-
await
|
|
32587
|
+
await writeFile26(paths.provenance, `${JSON.stringify(record, null, 2)}
|
|
32341
32588
|
`);
|
|
32342
32589
|
return { facts, columns: sheet.columns, sheetSha256, paths: { sheet: paths.sheet, atlas: paths.atlas, provenance: paths.provenance } };
|
|
32343
32590
|
}
|
|
@@ -32358,14 +32605,14 @@ function missingCodex(cause) {
|
|
|
32358
32605
|
);
|
|
32359
32606
|
}
|
|
32360
32607
|
function findCodexRoot(from) {
|
|
32361
|
-
const bases = from?.map((base) => pathToFileURL(
|
|
32362
|
-
pathToFileURL(
|
|
32608
|
+
const bases = from?.map((base) => pathToFileURL(path57.resolve(base, "package.json")).href) ?? [
|
|
32609
|
+
pathToFileURL(path57.join(process.cwd(), "package.json")).href,
|
|
32363
32610
|
import.meta.url
|
|
32364
32611
|
];
|
|
32365
32612
|
let failure;
|
|
32366
32613
|
for (const base of bases) {
|
|
32367
32614
|
try {
|
|
32368
|
-
return
|
|
32615
|
+
return path57.dirname(createRequire2(base).resolve(`${CODEX_PACKAGE}/package.json`));
|
|
32369
32616
|
} catch (error) {
|
|
32370
32617
|
failure = error;
|
|
32371
32618
|
}
|
|
@@ -32374,11 +32621,11 @@ function findCodexRoot(from) {
|
|
|
32374
32621
|
}
|
|
32375
32622
|
function loadCodex(from) {
|
|
32376
32623
|
const root = findCodexRoot(from);
|
|
32377
|
-
const read = (...parts) => readFileSync9(
|
|
32624
|
+
const read = (...parts) => readFileSync9(path57.join(root, ...parts), "utf8");
|
|
32378
32625
|
const pkg = JSON.parse(read("package.json"));
|
|
32379
32626
|
const version = typeof pkg.version === "string" ? pkg.version : "unknown";
|
|
32380
32627
|
for (const required of ["engine/pxfx.js", "engine/kit.js", "fx", "data/meta.json"]) {
|
|
32381
|
-
if (!existsSync47(
|
|
32628
|
+
if (!existsSync47(path57.join(root, required))) {
|
|
32382
32629
|
throw new PixelKilnError(`The installed ${CODEX_PACKAGE} (${version}) has no ${required}; PixelKiln was written against its 1.0.0 layout`, "capability");
|
|
32383
32630
|
}
|
|
32384
32631
|
}
|
|
@@ -32390,7 +32637,7 @@ function loadCodex(from) {
|
|
|
32390
32637
|
throw new PixelKilnError(`The installed ${CODEX_PACKAGE} (${version}) does not define PXFX.View and PXFX.get`, "capability");
|
|
32391
32638
|
}
|
|
32392
32639
|
const loadErrors = [];
|
|
32393
|
-
for (const file of readdirSync2(
|
|
32640
|
+
for (const file of readdirSync2(path57.join(root, "fx")).filter((name) => name.endsWith(".js")).sort()) {
|
|
32394
32641
|
try {
|
|
32395
32642
|
vm.runInContext(read("fx", file), context, { filename: `fx/${file}` });
|
|
32396
32643
|
} catch (error) {
|
|
@@ -32610,7 +32857,7 @@ async function makeCodexVfx(lib, opts) {
|
|
|
32610
32857
|
import { existsSync as existsSync48, readFileSync as readFileSync10 } from "fs";
|
|
32611
32858
|
import { readFile as readFile40 } from "fs/promises";
|
|
32612
32859
|
import { createRequire as createRequire3 } from "module";
|
|
32613
|
-
import
|
|
32860
|
+
import path58 from "path";
|
|
32614
32861
|
import { pathToFileURL as pathToFileURL2 } from "url";
|
|
32615
32862
|
var PIXELFX_TOOL = "pixelfx";
|
|
32616
32863
|
var PIXELFX_REPOSITORY = "https://github.com/patch-gg/pixelfx";
|
|
@@ -32623,8 +32870,8 @@ function missingPixelfx(cause) {
|
|
|
32623
32870
|
);
|
|
32624
32871
|
}
|
|
32625
32872
|
function pixelfxVersion(entry) {
|
|
32626
|
-
for (let dir =
|
|
32627
|
-
const file =
|
|
32873
|
+
for (let dir = path58.dirname(entry); dir !== path58.dirname(dir); dir = path58.dirname(dir)) {
|
|
32874
|
+
const file = path58.join(dir, "package.json");
|
|
32628
32875
|
if (!existsSync48(file)) continue;
|
|
32629
32876
|
const pkg = JSON.parse(readFileSync10(file, "utf8"));
|
|
32630
32877
|
if (pkg.name === "pixelfx") return typeof pkg.version === "string" ? pkg.version : "unknown";
|
|
@@ -32632,8 +32879,8 @@ function pixelfxVersion(entry) {
|
|
|
32632
32879
|
return "unknown";
|
|
32633
32880
|
}
|
|
32634
32881
|
async function loadPixelfx(from) {
|
|
32635
|
-
const bases = from?.map((base) => pathToFileURL2(
|
|
32636
|
-
pathToFileURL2(
|
|
32882
|
+
const bases = from?.map((base) => pathToFileURL2(path58.resolve(base)).href) ?? [
|
|
32883
|
+
pathToFileURL2(path58.join(process.cwd(), "package.json")).href,
|
|
32637
32884
|
import.meta.url
|
|
32638
32885
|
];
|
|
32639
32886
|
let resolved;
|
|
@@ -32858,7 +33105,7 @@ async function makePixelfxVfx(lib, opts) {
|
|
|
32858
33105
|
|
|
32859
33106
|
// src/cli/commands/pixellab-utils.ts
|
|
32860
33107
|
function loadKeys(args) {
|
|
32861
|
-
loadEnvFiles(
|
|
33108
|
+
loadEnvFiles(path59.dirname(path59.resolve(args.manifest)));
|
|
32862
33109
|
loadEnvFiles(process.cwd());
|
|
32863
33110
|
}
|
|
32864
33111
|
async function runUnzoom(args) {
|
|
@@ -33114,7 +33361,7 @@ async function runVfx(args) {
|
|
|
33114
33361
|
const fromRecipe = args.recipe ? await readVfxRecipe(args.recipe) : void 0;
|
|
33115
33362
|
const sprite = args.sprite ?? fromRecipe?.sprite;
|
|
33116
33363
|
const recipeName = typeof fromRecipe?.recipe.name === "string" ? fromRecipe.recipe.name : void 0;
|
|
33117
|
-
const name = args.name ?? (args.effect ? void 0 : recipeName ?? args.preset ??
|
|
33364
|
+
const name = args.name ?? (args.effect ? void 0 : recipeName ?? args.preset ?? path59.basename(paths.sheet, ".png"));
|
|
33118
33365
|
const from = args.preset ? `preset ${args.preset}` : args.recipe ? `recipe ${args.recipe}` : args.effect ? `saved effect ${args.effect}` : "nothing";
|
|
33119
33366
|
log(
|
|
33120
33367
|
` vfx ${name ? `"${name}"` : "(keeping its saved name)"} from ${from}${args.parts.length ? ` + ${args.parts.join(", ")}` : ""}${sprite ? ` around ${sprite}` : ""} \u2192 ${paths.sheet} (+ .gif, .json, .vfx.json${args.gamePack ? ", -game.zip" : ""})`
|
|
@@ -33309,7 +33556,7 @@ async function runVfxArtist(args, out) {
|
|
|
33309
33556
|
);
|
|
33310
33557
|
if (args.effect) {
|
|
33311
33558
|
log(
|
|
33312
|
-
` changes saved effect ${args.effect} in place` + (conversation ? `, priced as a change (its conversation is in ${
|
|
33559
|
+
` changes saved effect ${args.effect} in place` + (conversation ? `, priced as a change (its conversation is in ${path59.basename(paths.provenance)})` : `; ${path59.basename(paths.provenance)} holds no conversation for it, so PixelLab prices it as a new effect`)
|
|
33313
33560
|
);
|
|
33314
33561
|
}
|
|
33315
33562
|
log(` cost: about ${quote} generations by PixelLab's table, billed on delivery; at most ${ceiling} if the effect runs long`);
|
|
@@ -33360,12 +33607,12 @@ async function runVfxArtist(args, out) {
|
|
|
33360
33607
|
|
|
33361
33608
|
// src/cli/commands/audio.ts
|
|
33362
33609
|
import { readFile as readFile42 } from "fs/promises";
|
|
33363
|
-
import
|
|
33610
|
+
import path61 from "path";
|
|
33364
33611
|
|
|
33365
33612
|
// src/pixellab-audio.ts
|
|
33366
33613
|
import { existsSync as existsSync49 } from "fs";
|
|
33367
|
-
import { mkdir as
|
|
33368
|
-
import
|
|
33614
|
+
import { mkdir as mkdir22, writeFile as writeFile27 } from "fs/promises";
|
|
33615
|
+
import path60 from "path";
|
|
33369
33616
|
var MUSIC_COST_GENERATIONS = 10;
|
|
33370
33617
|
var MUSIC_LOOP_COST_GENERATIONS = 4;
|
|
33371
33618
|
var MUSIC_LOOP_MIN_BODY_SECONDS = 36;
|
|
@@ -33422,7 +33669,7 @@ async function billedUsage(client2, jobId) {
|
|
|
33422
33669
|
}
|
|
33423
33670
|
}
|
|
33424
33671
|
function musicOutputPaths(out) {
|
|
33425
|
-
const base =
|
|
33672
|
+
const base = path60.resolve(out.replace(/\.(music\.json|mp3)$/i, ""));
|
|
33426
33673
|
return {
|
|
33427
33674
|
takes: [`${base}.mp3`, `${base}.take2.mp3`],
|
|
33428
33675
|
loops: [`${base}.loop.mp3`, `${base}.loop.take2.mp3`],
|
|
@@ -33444,8 +33691,8 @@ async function collectTakes(client2, songs, files, what, opts) {
|
|
|
33444
33691
|
if (!song.audio_url) throw new Error(`PixelLab ${what} ${song.id} completed without an audio URL`);
|
|
33445
33692
|
const bytes = await client2.download(song.audio_url);
|
|
33446
33693
|
validateAudio(bytes, "mp3");
|
|
33447
|
-
await
|
|
33448
|
-
await
|
|
33694
|
+
await mkdir22(path60.dirname(file), { recursive: true });
|
|
33695
|
+
await writeFile27(file, bytes);
|
|
33449
33696
|
finished.push(song);
|
|
33450
33697
|
takes.push({
|
|
33451
33698
|
songId: song.id,
|
|
@@ -33510,10 +33757,10 @@ async function generateMusic(client2, opts) {
|
|
|
33510
33757
|
quotedGenerations: quoted,
|
|
33511
33758
|
usage: usage2
|
|
33512
33759
|
});
|
|
33513
|
-
const relative = (take) => ({ ...take, file:
|
|
33760
|
+
const relative = (take) => ({ ...take, file: path60.basename(take.file) });
|
|
33514
33761
|
const writeRecord = async (result2) => {
|
|
33515
|
-
await
|
|
33516
|
-
await
|
|
33762
|
+
await mkdir22(path60.dirname(paths.record), { recursive: true });
|
|
33763
|
+
await writeFile27(
|
|
33517
33764
|
paths.record,
|
|
33518
33765
|
JSON.stringify(
|
|
33519
33766
|
{
|
|
@@ -33553,7 +33800,7 @@ async function generateMusic(client2, opts) {
|
|
|
33553
33800
|
submitted = await client2.loopMusic(loopSource);
|
|
33554
33801
|
} catch (error) {
|
|
33555
33802
|
const detail = refusalDetail(error);
|
|
33556
|
-
const kept = takes.length ? ` The song's takes are saved (${
|
|
33803
|
+
const kept = takes.length ? ` The song's takes are saved (${path60.basename(paths.record)}); nothing was charged for the loop.` : "";
|
|
33557
33804
|
throw new Error(`PixelLab refused to loop ${loopSource}: ${detail ?? (error instanceof Error ? error.message : String(error))}${kept}`, { cause: error });
|
|
33558
33805
|
}
|
|
33559
33806
|
quoted = (quoted ?? 0) + (submitted.quoted_generations ?? 0);
|
|
@@ -33567,7 +33814,7 @@ async function generateMusic(client2, opts) {
|
|
|
33567
33814
|
return result;
|
|
33568
33815
|
}
|
|
33569
33816
|
function soundEffectOutputPaths(out) {
|
|
33570
|
-
const base =
|
|
33817
|
+
const base = path60.resolve(out.replace(/\.(sfx\.json|wav)$/i, ""));
|
|
33571
33818
|
return { wav: `${base}.wav`, record: `${base}.sfx.json` };
|
|
33572
33819
|
}
|
|
33573
33820
|
async function generateSoundEffect(client2, opts) {
|
|
@@ -33582,8 +33829,8 @@ async function generateSoundEffect(client2, opts) {
|
|
|
33582
33829
|
if (!clip.audio_url) throw new Error(`PixelLab sound effect ${id} completed without an audio URL`);
|
|
33583
33830
|
const bytes = await client2.download(clip.audio_url);
|
|
33584
33831
|
validateAudio(bytes, "wav");
|
|
33585
|
-
await
|
|
33586
|
-
await
|
|
33832
|
+
await mkdir22(path60.dirname(wav), { recursive: true });
|
|
33833
|
+
await writeFile27(wav, bytes);
|
|
33587
33834
|
const result = {
|
|
33588
33835
|
soundEffectId: id,
|
|
33589
33836
|
file: wav,
|
|
@@ -33594,7 +33841,7 @@ async function generateSoundEffect(client2, opts) {
|
|
|
33594
33841
|
quotedGenerations: submitted.quoted_generations ?? null,
|
|
33595
33842
|
usage: await billedUsage(client2, submitted.background_job_id)
|
|
33596
33843
|
};
|
|
33597
|
-
await
|
|
33844
|
+
await writeFile27(
|
|
33598
33845
|
record,
|
|
33599
33846
|
JSON.stringify(
|
|
33600
33847
|
{
|
|
@@ -33605,7 +33852,7 @@ async function generateSoundEffect(client2, opts) {
|
|
|
33605
33852
|
prompt: opts.prompt,
|
|
33606
33853
|
seconds,
|
|
33607
33854
|
soundEffectId: id,
|
|
33608
|
-
file:
|
|
33855
|
+
file: path60.basename(wav),
|
|
33609
33856
|
sha256: result.sha256,
|
|
33610
33857
|
durationMs: result.durationMs,
|
|
33611
33858
|
quotedGenerations: result.quotedGenerations,
|
|
@@ -33620,7 +33867,7 @@ async function generateSoundEffect(client2, opts) {
|
|
|
33620
33867
|
|
|
33621
33868
|
// src/cli/commands/audio.ts
|
|
33622
33869
|
function loadKeys2(args) {
|
|
33623
|
-
loadEnvFiles(
|
|
33870
|
+
loadEnvFiles(path61.dirname(path61.resolve(args.manifest)));
|
|
33624
33871
|
loadEnvFiles(process.cwd());
|
|
33625
33872
|
}
|
|
33626
33873
|
function progress() {
|
|
@@ -33677,7 +33924,7 @@ async function runMusic(args) {
|
|
|
33677
33924
|
const cost = musicCost({ loop: args.loop, loopOf: args.loopOf });
|
|
33678
33925
|
const paths = musicOutputPaths(args.out);
|
|
33679
33926
|
const what = args.loopOf ? `loop of ${args.loopOf} (two loop takes)` : `"${args.description}"${vocals ? ", with vocals" : ", instrumental"}, two takes${args.loop ? " plus loops of take 1" : ""}`;
|
|
33680
|
-
log(` music: ${what} \u2192 ${
|
|
33927
|
+
log(` music: ${what} \u2192 ${path61.relative(process.cwd(), args.loopOf ? paths.loops[0] : paths.takes[0])} \u2026`);
|
|
33681
33928
|
log(` cost: ${cost} generations (PixelLab's published price)${args.improve ? ", plus about 0.05 for --improve" : ""}`);
|
|
33682
33929
|
if (args.budget !== void 0 && args.budget < cost) {
|
|
33683
33930
|
throw new Error(`--budget ${args.budget} is below this run's ${cost}-generation cost`);
|
|
@@ -33694,7 +33941,7 @@ async function runMusic(args) {
|
|
|
33694
33941
|
style = (await client2.improveMusicStyle({ style, instrumental: !vocals, bpm: args.bpm })).style;
|
|
33695
33942
|
log(` style: ${style}`);
|
|
33696
33943
|
}
|
|
33697
|
-
const lyrics = args.lyrics ? await readFile42(
|
|
33944
|
+
const lyrics = args.lyrics ? await readFile42(path61.resolve(args.lyrics), "utf8") : void 0;
|
|
33698
33945
|
const res = await generateMusic(client2, {
|
|
33699
33946
|
style,
|
|
33700
33947
|
lyrics,
|
|
@@ -33730,7 +33977,7 @@ async function runSfx(args) {
|
|
|
33730
33977
|
const seconds = args.seconds ?? 2;
|
|
33731
33978
|
const cost = soundEffectCost(seconds);
|
|
33732
33979
|
const { wav } = soundEffectOutputPaths(args.out);
|
|
33733
|
-
log(` sfx: "${args.description}", ${seconds} s \u2192 ${
|
|
33980
|
+
log(` sfx: "${args.description}", ${seconds} s \u2192 ${path61.relative(process.cwd(), wav)}`);
|
|
33734
33981
|
log(` cost: ${cost} generation${cost === 1 ? "" : "s"} (PixelLab's published price, by length)`);
|
|
33735
33982
|
if (args.budget !== void 0 && args.budget < cost) {
|
|
33736
33983
|
throw new Error(`--budget ${args.budget} is below this clip's ${cost}-generation cost`);
|
|
@@ -33758,12 +34005,12 @@ async function runSfx(args) {
|
|
|
33758
34005
|
}
|
|
33759
34006
|
|
|
33760
34007
|
// src/cli/commands/ui.ts
|
|
33761
|
-
import
|
|
34008
|
+
import path63 from "path";
|
|
33762
34009
|
|
|
33763
34010
|
// src/pixellab-ui.ts
|
|
33764
34011
|
import { existsSync as existsSync50 } from "fs";
|
|
33765
|
-
import { mkdir as
|
|
33766
|
-
import
|
|
34012
|
+
import { mkdir as mkdir23, writeFile as writeFile28 } from "fs/promises";
|
|
34013
|
+
import path62 from "path";
|
|
33767
34014
|
var UI_STATES_COSTS = [10, 15, 25];
|
|
33768
34015
|
var UI_STATES_MAX_COST = 25;
|
|
33769
34016
|
var UI_STATES_MAX_ELEMENTS = 64;
|
|
@@ -33856,8 +34103,8 @@ async function pullUiAsset(client2, uiAssetId, opts) {
|
|
|
33856
34103
|
const asset = await client2.getUiAssetDetail(uiAssetId);
|
|
33857
34104
|
if (asset.status && asset.status !== "completed") throw new Error(`UI asset ${uiAssetId} is ${asset.status}; pull it once it is completed`);
|
|
33858
34105
|
if (!asset.image_url) throw new Error(`UI asset ${uiAssetId} has no image yet`);
|
|
33859
|
-
const dir =
|
|
33860
|
-
const record =
|
|
34106
|
+
const dir = path62.resolve(opts.out);
|
|
34107
|
+
const record = path62.join(dir, "ui.json");
|
|
33861
34108
|
const plan = [];
|
|
33862
34109
|
const insets = (part) => part.nine_slice ? { nineSlice: { left: part.nine_slice.left, right: part.nine_slice.right, top: part.nine_slice.top, bottom: part.nine_slice.bottom } } : {};
|
|
33863
34110
|
const taken = /* @__PURE__ */ new Set();
|
|
@@ -33905,7 +34152,7 @@ async function pullUiAsset(client2, uiAssetId, opts) {
|
|
|
33905
34152
|
}
|
|
33906
34153
|
if (kind === "element") addStates(asset, rootName, asset.states);
|
|
33907
34154
|
if (!opts.force) {
|
|
33908
|
-
for (const file of [record, ...plan.map((item) =>
|
|
34155
|
+
for (const file of [record, ...plan.map((item) => path62.join(dir, item.file))]) {
|
|
33909
34156
|
if (existsSync50(file)) throw new Error(`${file} already exists; pass --force to replace it`);
|
|
33910
34157
|
}
|
|
33911
34158
|
}
|
|
@@ -33913,12 +34160,12 @@ async function pullUiAsset(client2, uiAssetId, opts) {
|
|
|
33913
34160
|
for (const { url, ...item } of plan) {
|
|
33914
34161
|
const bytes = await client2.download(url);
|
|
33915
34162
|
validateMedia(bytes, MediaType.PNG);
|
|
33916
|
-
const target =
|
|
33917
|
-
await
|
|
33918
|
-
await
|
|
34163
|
+
const target = path62.join(dir, item.file);
|
|
34164
|
+
await mkdir23(path62.dirname(target), { recursive: true });
|
|
34165
|
+
await writeFile28(target, bytes);
|
|
33919
34166
|
files.push({ ...item, sha256: sha256(bytes) });
|
|
33920
34167
|
}
|
|
33921
|
-
await
|
|
34168
|
+
await writeFile28(
|
|
33922
34169
|
record,
|
|
33923
34170
|
JSON.stringify(
|
|
33924
34171
|
{
|
|
@@ -33940,7 +34187,7 @@ async function pullUiAsset(client2, uiAssetId, opts) {
|
|
|
33940
34187
|
|
|
33941
34188
|
// src/cli/commands/ui.ts
|
|
33942
34189
|
function loadKeys3(args) {
|
|
33943
|
-
loadEnvFiles(
|
|
34190
|
+
loadEnvFiles(path63.dirname(path63.resolve(args.manifest)));
|
|
33944
34191
|
loadEnvFiles(process.cwd());
|
|
33945
34192
|
}
|
|
33946
34193
|
function requireId(args) {
|
|
@@ -34054,18 +34301,18 @@ async function runUi(args) {
|
|
|
34054
34301
|
log(JSON.stringify({ version: 1, ...res }, null, 2));
|
|
34055
34302
|
return;
|
|
34056
34303
|
}
|
|
34057
|
-
for (const file of res.files) log(` wrote ${
|
|
34058
|
-
log(` wrote ${
|
|
34304
|
+
for (const file of res.files) log(` wrote ${path63.join(args.out, file.file)} (${file.kind}, ${file.size.width}x${file.size.height})`);
|
|
34305
|
+
log(` wrote ${path63.join(args.out, "ui.json")}`);
|
|
34059
34306
|
}
|
|
34060
34307
|
|
|
34061
34308
|
// src/cli/commands/asset.ts
|
|
34062
34309
|
import { readFile as readFile44 } from "fs/promises";
|
|
34063
|
-
import
|
|
34310
|
+
import path65 from "path";
|
|
34064
34311
|
|
|
34065
34312
|
// src/pixellab-assets.ts
|
|
34066
34313
|
import { existsSync as existsSync51 } from "fs";
|
|
34067
|
-
import { mkdir as
|
|
34068
|
-
import
|
|
34314
|
+
import { mkdir as mkdir24, readdir as readdir6, readFile as readFile43, stat as stat6, writeFile as writeFile29 } from "fs/promises";
|
|
34315
|
+
import path64 from "path";
|
|
34069
34316
|
var ASSET_KINDS = ["object", "character"];
|
|
34070
34317
|
var EXPORT_FORMATS = ["zip", "spritesheet", "aseprite", "gif"];
|
|
34071
34318
|
var MIRROR_DIRECTIONS = ["east", "west", "south-east", "south-west", "north-east", "north-west"];
|
|
@@ -34085,7 +34332,7 @@ function parseCanvasSize(text, kind) {
|
|
|
34085
34332
|
}
|
|
34086
34333
|
function exportOutPath(out, format) {
|
|
34087
34334
|
const extension = format === "aseprite" ? ".aseprite" : format === "gif" ? ".gif" : ".zip";
|
|
34088
|
-
return
|
|
34335
|
+
return path64.extname(out) ? path64.resolve(out) : path64.resolve(`${out}${extension}`);
|
|
34089
34336
|
}
|
|
34090
34337
|
function checkExportBytes(bytes, format) {
|
|
34091
34338
|
const ok = format === "gif" ? bytes.subarray(0, 4).toString("ascii") === "GIF8" : format === "aseprite" ? bytes.length > 6 && bytes.readUInt16LE(4) === 42464 : bytes.subarray(0, 2).toString("ascii") === "PK";
|
|
@@ -34096,8 +34343,8 @@ async function exportAssetFile(client2, kind, id, format, opts) {
|
|
|
34096
34343
|
if (existsSync51(out) && !opts.force) throw new Error(`${out} already exists; pass --force to replace it`);
|
|
34097
34344
|
const bytes = await client2.exportAsset(kind, id, format, { animationGroupId: opts.animationGroupId, direction: opts.direction });
|
|
34098
34345
|
checkExportBytes(bytes, format);
|
|
34099
|
-
await
|
|
34100
|
-
await
|
|
34346
|
+
await mkdir24(path64.dirname(out), { recursive: true });
|
|
34347
|
+
await writeFile29(out, bytes);
|
|
34101
34348
|
return { out, bytes: bytes.length };
|
|
34102
34349
|
}
|
|
34103
34350
|
async function importObjectFile(client2, file, opts = {}) {
|
|
@@ -34143,17 +34390,17 @@ async function pullExpansionReview(client2, id, opts) {
|
|
|
34143
34390
|
if (object.status !== "review-expansion" || !review?.rotation_urls) {
|
|
34144
34391
|
throw new Error(`object ${id} is ${object.status ?? "unknown"}; there is no expansion waiting for review`);
|
|
34145
34392
|
}
|
|
34146
|
-
const dir =
|
|
34393
|
+
const dir = path64.resolve(opts.out);
|
|
34147
34394
|
const entries = Object.entries(review.rotation_urls).filter((entry) => typeof entry[1] === "string");
|
|
34148
|
-
const files = entries.map(([direction]) => ({ direction, file:
|
|
34395
|
+
const files = entries.map(([direction]) => ({ direction, file: path64.join(dir, `${direction}.png`) }));
|
|
34149
34396
|
if (!opts.force) {
|
|
34150
34397
|
for (const { file } of files) if (existsSync51(file)) throw new Error(`${file} already exists; pass --force to replace it`);
|
|
34151
34398
|
}
|
|
34152
|
-
await
|
|
34399
|
+
await mkdir24(dir, { recursive: true });
|
|
34153
34400
|
for (const [index, [, url]] of entries.entries()) {
|
|
34154
34401
|
const bytes = await client2.download(url);
|
|
34155
34402
|
validateMedia(bytes, MediaType.PNG);
|
|
34156
|
-
await
|
|
34403
|
+
await writeFile29(files[index].file, bytes);
|
|
34157
34404
|
}
|
|
34158
34405
|
return { dir, existingDirection: review.existing_direction ?? null, files };
|
|
34159
34406
|
}
|
|
@@ -34216,7 +34463,7 @@ async function pngFilesAt(from) {
|
|
|
34216
34463
|
if (!(await stat6(from)).isDirectory()) return [from];
|
|
34217
34464
|
const names = (await readdir6(from)).filter((name) => /\.png$/i.test(name)).sort((a, b) => a.localeCompare(b, void 0, { numeric: true }));
|
|
34218
34465
|
if (names.length === 0) throw new Error(`${from} holds no PNG files`);
|
|
34219
|
-
return names.map((name) =>
|
|
34466
|
+
return names.map((name) => path64.join(from, name));
|
|
34220
34467
|
}
|
|
34221
34468
|
function importTileHeights(tileType, tileSize) {
|
|
34222
34469
|
if (tileType === "square_topdown" || tileType === "octagon") return { min: tileSize, max: tileSize };
|
|
@@ -34251,14 +34498,14 @@ function checkSaveTarget(target) {
|
|
|
34251
34498
|
}
|
|
34252
34499
|
function saveUndoDir(target, now = /* @__PURE__ */ new Date()) {
|
|
34253
34500
|
const stamp = now.toISOString().replace(/[-:]/g, "").replace(/\.\d+Z$/, "Z");
|
|
34254
|
-
return
|
|
34501
|
+
return path64.resolve("pixelkiln-undo", `${target.replace(/[^a-zA-Z0-9-]+/g, "_")}-${stamp}`);
|
|
34255
34502
|
}
|
|
34256
34503
|
async function writeUndo(frames, dir) {
|
|
34257
|
-
await
|
|
34504
|
+
await mkdir24(dir, { recursive: true });
|
|
34258
34505
|
const files = [];
|
|
34259
34506
|
for (const [index, frame] of frames.entries()) {
|
|
34260
|
-
const file =
|
|
34261
|
-
await
|
|
34507
|
+
const file = path64.join(dir, frames.length === 1 ? "previous.png" : `previous-${String(index).padStart(2, "0")}.png`);
|
|
34508
|
+
await writeFile29(file, Buffer.from(frame.base64, "base64"));
|
|
34262
34509
|
files.push(file);
|
|
34263
34510
|
}
|
|
34264
34511
|
return files;
|
|
@@ -34289,7 +34536,7 @@ async function saveToAssetFile(client2, target, from, opts = {}) {
|
|
|
34289
34536
|
frames.push({ base64: bytes.toString("base64"), format: "png" });
|
|
34290
34537
|
}
|
|
34291
34538
|
}
|
|
34292
|
-
const undoDir = opts.undoDir ?
|
|
34539
|
+
const undoDir = opts.undoDir ? path64.resolve(opts.undoDir) : saveUndoDir(target);
|
|
34293
34540
|
let res;
|
|
34294
34541
|
try {
|
|
34295
34542
|
res = await client2.saveToAsset({ target, image, frames, name: opts.name, description: opts.description });
|
|
@@ -34325,7 +34572,7 @@ async function saveToAssetFile(client2, target, from, opts = {}) {
|
|
|
34325
34572
|
|
|
34326
34573
|
// src/cli/commands/asset.ts
|
|
34327
34574
|
function loadKeys4(args) {
|
|
34328
|
-
loadEnvFiles(
|
|
34575
|
+
loadEnvFiles(path65.dirname(path65.resolve(args.manifest)));
|
|
34329
34576
|
loadEnvFiles(process.cwd());
|
|
34330
34577
|
}
|
|
34331
34578
|
function kindOf(args) {
|
|
@@ -34446,7 +34693,7 @@ async function runAsset(args) {
|
|
|
34446
34693
|
const res2 = await pullExpansionReview(clientFromEnv(), id, { out: args.out, force: args.force });
|
|
34447
34694
|
if (args.json) emit(res2);
|
|
34448
34695
|
else {
|
|
34449
|
-
for (const file of res2.files) log(` wrote ${
|
|
34696
|
+
for (const file of res2.files) log(` wrote ${path65.join(args.out, `${file.direction}.png`)}${file.direction === res2.existingDirection ? " (your image, unchanged)" : ""}`);
|
|
34450
34697
|
log(` keep them: pixelkiln asset expand --id ${id} --keep discard: pixelkiln asset expand --id ${id} --discard`);
|
|
34451
34698
|
}
|
|
34452
34699
|
return;
|
|
@@ -34530,7 +34777,7 @@ async function runSave(args, emit) {
|
|
|
34530
34777
|
if (!args.from) throw new UsageError("asset save needs --from: a PNG, an animated GIF, or a directory of PNG frames");
|
|
34531
34778
|
await usage(() => checkSaveTarget(target));
|
|
34532
34779
|
const adding = target === "gallery:new";
|
|
34533
|
-
const undoDir = args.out ?
|
|
34780
|
+
const undoDir = args.out ? path65.resolve(args.out) : saveUndoDir(target);
|
|
34534
34781
|
if (adding) log(` add ${args.from} to your PixelLab gallery as a new image (free)`);
|
|
34535
34782
|
else {
|
|
34536
34783
|
log(` save ${args.from} over ${target} on PixelLab (free)`);
|
|
@@ -34553,7 +34800,7 @@ async function runSave(args, emit) {
|
|
|
34553
34800
|
else {
|
|
34554
34801
|
log(` ${res.target}: ${res.kind} saved, ${res.width}x${res.height}, ${res.frames} frame(s), ${res.changedPixels} pixel(s) changed`);
|
|
34555
34802
|
for (const file of res.undo) log(` kept the old pixels: ${file}`);
|
|
34556
|
-
if (res.undo.length) log(` undo: pixelkiln asset save --target ${res.target} --from ${res.undo.length === 1 ? res.undo[0] :
|
|
34803
|
+
if (res.undo.length) log(` undo: pixelkiln asset save --target ${res.target} --from ${res.undo.length === 1 ? res.undo[0] : path65.dirname(res.undo[0])} --yes`);
|
|
34557
34804
|
}
|
|
34558
34805
|
if (res.note) log(` ${res.note}`);
|
|
34559
34806
|
if (res.maps) log(` ${res.maps}`);
|
|
@@ -34561,13 +34808,13 @@ async function runSave(args, emit) {
|
|
|
34561
34808
|
|
|
34562
34809
|
// src/cli/commands/talk.ts
|
|
34563
34810
|
import { existsSync as existsSync53 } from "fs";
|
|
34564
|
-
import { mkdir as
|
|
34565
|
-
import
|
|
34811
|
+
import { mkdir as mkdir26, readFile as readFile46, writeFile as writeFile31 } from "fs/promises";
|
|
34812
|
+
import path67 from "path";
|
|
34566
34813
|
|
|
34567
34814
|
// src/pixellab-talk.ts
|
|
34568
34815
|
import { existsSync as existsSync52 } from "fs";
|
|
34569
|
-
import { mkdir as
|
|
34570
|
-
import
|
|
34816
|
+
import { mkdir as mkdir25, readFile as readFile45, writeFile as writeFile30 } from "fs/promises";
|
|
34817
|
+
import path66 from "path";
|
|
34571
34818
|
var TALK_MOODS = ["neutral", "happy", "angry", "sad", "surprised"];
|
|
34572
34819
|
var VISEME_COUNTS = [3, 5, 7, 12];
|
|
34573
34820
|
var VISEME_ENGINES = ["v3", "pixminimax"];
|
|
@@ -34578,7 +34825,7 @@ function visemeCost(engine, side, count) {
|
|
|
34578
34825
|
return Math.ceil(forSeven * count / 7);
|
|
34579
34826
|
}
|
|
34580
34827
|
function talkOutputPaths(out) {
|
|
34581
|
-
const base =
|
|
34828
|
+
const base = path66.resolve(out.replace(/\.(png|json)$/i, "").replace(/\.(talk|visemes)$/i, ""));
|
|
34582
34829
|
return { strip: `${base}.visemes.png`, record: `${base}.talk.json` };
|
|
34583
34830
|
}
|
|
34584
34831
|
function readPortrait(bytes, label) {
|
|
@@ -34672,8 +34919,8 @@ async function makeVisemes(client2, opts) {
|
|
|
34672
34919
|
throw new Error(`PixelLab vocal-animation job ${jobId} finished with no mouth positions and no spritesheet`);
|
|
34673
34920
|
}
|
|
34674
34921
|
const usage2 = (await client2.getBackgroundJob(jobId).catch(() => null))?.usage ?? job.usage ?? null;
|
|
34675
|
-
await
|
|
34676
|
-
await
|
|
34922
|
+
await mkdir25(path66.dirname(paths.strip), { recursive: true });
|
|
34923
|
+
await writeFile30(paths.strip, strip);
|
|
34677
34924
|
const record = {
|
|
34678
34925
|
version: 1,
|
|
34679
34926
|
provider: "pixellab",
|
|
@@ -34683,14 +34930,14 @@ async function makeVisemes(client2, opts) {
|
|
|
34683
34930
|
visemeCount,
|
|
34684
34931
|
visemeOrder,
|
|
34685
34932
|
cell,
|
|
34686
|
-
strip:
|
|
34687
|
-
source: opts.portrait ? { portrait:
|
|
34933
|
+
strip: path66.basename(paths.strip),
|
|
34934
|
+
source: opts.portrait ? { portrait: path66.relative(path66.dirname(paths.record), path66.resolve(opts.portrait)).split(path66.sep).join("/") } : { characterId: opts.characterId },
|
|
34688
34935
|
...job.moods_on_character ? { moodsOnCharacter: job.moods_on_character } : {},
|
|
34689
34936
|
jobId,
|
|
34690
34937
|
usage: usage2,
|
|
34691
34938
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
34692
34939
|
};
|
|
34693
|
-
await
|
|
34940
|
+
await writeFile30(paths.record, `${JSON.stringify(record, null, 2)}
|
|
34694
34941
|
`);
|
|
34695
34942
|
return { ...record, paths };
|
|
34696
34943
|
}
|
|
@@ -34704,7 +34951,7 @@ async function readTalkRecord(file) {
|
|
|
34704
34951
|
if (record?.tool !== "vocal-animation" || !Array.isArray(record.visemeOrder) || !record.cell || !record.strip) {
|
|
34705
34952
|
throw new Error(`${file} is not a .talk.json record from pixelkiln talk visemes`);
|
|
34706
34953
|
}
|
|
34707
|
-
const stripFile =
|
|
34954
|
+
const stripFile = path66.resolve(path66.dirname(path66.resolve(file)), record.strip);
|
|
34708
34955
|
if (!existsSync52(stripFile)) throw new Error(`${file} names ${record.strip}, which is missing beside it`);
|
|
34709
34956
|
const row = Math.max(0, record.moodsOnCharacter?.indexOf(record.mood) ?? 0);
|
|
34710
34957
|
const cells = cutStrip(await readFile45(stripFile), record.visemeOrder.length, record.cell, row);
|
|
@@ -34720,15 +34967,15 @@ function checkText(text) {
|
|
|
34720
34967
|
async function makeTalkingGif(client2, text, source, opts) {
|
|
34721
34968
|
if (Boolean(source.record) === Boolean(source.characterId)) throw new Error("give a .talk.json record or a character id, not both");
|
|
34722
34969
|
if (source.record && source.mood) throw new Error("a record holds one expression; --mood picks among a character's stored ones");
|
|
34723
|
-
const out =
|
|
34970
|
+
const out = path66.extname(opts.out) ? path66.resolve(opts.out) : path66.resolve(`${opts.out}.gif`);
|
|
34724
34971
|
if (existsSync52(out) && !opts.force) throw new Error(`${out} already exists; pass --force to replace it`);
|
|
34725
34972
|
const line = checkText(text);
|
|
34726
34973
|
const visemes = source.record ? (await readTalkRecord(source.record)).visemes : void 0;
|
|
34727
34974
|
const res = await client2.createTalkingGif({ text: line, visemes, characterId: source.characterId, mood: source.mood, frameMs: opts.frameMs, holdMs: opts.holdMs });
|
|
34728
34975
|
const bytes = Buffer.from(res.gif_base64, "base64");
|
|
34729
34976
|
if (bytes.subarray(0, 4).toString("ascii") !== "GIF8") throw new Error(`PixelLab's talking GIF was not a GIF (${bytes.length} bytes)`);
|
|
34730
|
-
await
|
|
34731
|
-
await
|
|
34977
|
+
await mkdir25(path66.dirname(out), { recursive: true });
|
|
34978
|
+
await writeFile30(out, bytes);
|
|
34732
34979
|
return { out, frames: res.frames, durationMs: res.duration_ms, frameMs: res.frame_ms, holdMs: res.hold_ms, width: res.width, height: res.height, bytes: bytes.length };
|
|
34733
34980
|
}
|
|
34734
34981
|
async function planLipSync(client2, text, source, opts = {}) {
|
|
@@ -34760,7 +35007,7 @@ async function planLipSync(client2, text, source, opts = {}) {
|
|
|
34760
35007
|
|
|
34761
35008
|
// src/cli/commands/talk.ts
|
|
34762
35009
|
function loadKeys5(args) {
|
|
34763
|
-
loadEnvFiles(
|
|
35010
|
+
loadEnvFiles(path67.dirname(path67.resolve(args.manifest)));
|
|
34764
35011
|
loadEnvFiles(process.cwd());
|
|
34765
35012
|
}
|
|
34766
35013
|
function moodOf(args) {
|
|
@@ -34883,10 +35130,10 @@ async function runPlan2(args) {
|
|
|
34883
35130
|
log(json2.trimEnd());
|
|
34884
35131
|
return;
|
|
34885
35132
|
}
|
|
34886
|
-
const out =
|
|
35133
|
+
const out = path67.extname(args.out) ? path67.resolve(args.out) : path67.resolve(`${args.out}.json`);
|
|
34887
35134
|
if (existsSync53(out) && !args.force) throw new Error(`${out} already exists; pass --force to replace it`);
|
|
34888
|
-
await
|
|
34889
|
-
await
|
|
35135
|
+
await mkdir26(path67.dirname(out), { recursive: true });
|
|
35136
|
+
await writeFile31(out, json2);
|
|
34890
35137
|
if (args.json) log(json2.trimEnd());
|
|
34891
35138
|
else log(` wrote ${out} (${plan.frames.length} frames, ${(plan.totalMs / 1e3).toFixed(2)} s, free)`);
|
|
34892
35139
|
}
|
|
@@ -34897,11 +35144,11 @@ async function runTalk(args) {
|
|
|
34897
35144
|
}
|
|
34898
35145
|
|
|
34899
35146
|
// src/cli/commands/quality.ts
|
|
34900
|
-
import
|
|
35147
|
+
import path69 from "path";
|
|
34901
35148
|
import { readFile as readFile48 } from "fs/promises";
|
|
34902
35149
|
|
|
34903
35150
|
// src/pipeline/quality-regression.ts
|
|
34904
|
-
import
|
|
35151
|
+
import path68 from "path";
|
|
34905
35152
|
import { existsSync as existsSync54 } from "fs";
|
|
34906
35153
|
import { readFile as readFile47 } from "fs/promises";
|
|
34907
35154
|
import { z as z17 } from "zod";
|
|
@@ -34909,7 +35156,7 @@ var SHA256_RE = /^[0-9a-f]{64}$/;
|
|
|
34909
35156
|
var HEX_RE = /^#[0-9a-f]{6}$/;
|
|
34910
35157
|
var MAX_REDMEAN_DISTANCE = 765;
|
|
34911
35158
|
var QualityPathSchema = z17.string().min(1).refine(
|
|
34912
|
-
(value) => !
|
|
35159
|
+
(value) => !path68.posix.isAbsolute(value) && !value.includes("\\"),
|
|
34913
35160
|
"expected a portable relative path"
|
|
34914
35161
|
);
|
|
34915
35162
|
var DEFAULT_QUALITY_TOLERANCES = {
|
|
@@ -35056,7 +35303,7 @@ function measureDecodedImageQuality(png, digest2) {
|
|
|
35056
35303
|
};
|
|
35057
35304
|
}
|
|
35058
35305
|
async function measureImageQuality(file) {
|
|
35059
|
-
const absolute =
|
|
35306
|
+
const absolute = path68.resolve(file);
|
|
35060
35307
|
let bytes;
|
|
35061
35308
|
try {
|
|
35062
35309
|
bytes = await readFile47(absolute);
|
|
@@ -35078,11 +35325,11 @@ function resolveQualityInputs(raw, inputsFilePath) {
|
|
|
35078
35325
|
}
|
|
35079
35326
|
const ids = parsed.data.map((entry) => entry.id);
|
|
35080
35327
|
if (new Set(ids).size !== ids.length) throw new Error("--inputs contains a duplicate quality case id.");
|
|
35081
|
-
const root =
|
|
35328
|
+
const root = path68.dirname(path68.resolve(inputsFilePath));
|
|
35082
35329
|
return parsed.data.map((entry) => ({
|
|
35083
35330
|
id: entry.id,
|
|
35084
|
-
file:
|
|
35085
|
-
...entry.record ? { record:
|
|
35331
|
+
file: path68.resolve(root, entry.path),
|
|
35332
|
+
...entry.record ? { record: path68.resolve(root, entry.record) } : {},
|
|
35086
35333
|
tolerances: QualityToleranceSchema.parse({
|
|
35087
35334
|
...DEFAULT_QUALITY_TOLERANCES,
|
|
35088
35335
|
...entry.tolerances
|
|
@@ -35090,7 +35337,7 @@ function resolveQualityInputs(raw, inputsFilePath) {
|
|
|
35090
35337
|
}));
|
|
35091
35338
|
}
|
|
35092
35339
|
function portableRelative2(from, to) {
|
|
35093
|
-
return
|
|
35340
|
+
return path68.relative(from, path68.resolve(to)).split(path68.sep).join("/") || ".";
|
|
35094
35341
|
}
|
|
35095
35342
|
async function verifyRecordForImage(recordPath, imagePath) {
|
|
35096
35343
|
const verification = await verifyArtifactBundle(recordPath);
|
|
@@ -35105,20 +35352,20 @@ async function verifyRecordForImage(recordPath, imagePath) {
|
|
|
35105
35352
|
if (record.kind !== "refine" || options === null || typeof options !== "object" || options.schema !== "pixelkiln-quality") {
|
|
35106
35353
|
throw new Error(`Quality record ${recordPath} is not a PixelKiln refinement record.`);
|
|
35107
35354
|
}
|
|
35108
|
-
const outputs = record.outputs.map((output) =>
|
|
35109
|
-
if (!outputs.includes(
|
|
35355
|
+
const outputs = record.outputs.map((output) => path68.resolve(path68.dirname(recordPath), output.path));
|
|
35356
|
+
if (!outputs.includes(path68.resolve(imagePath))) {
|
|
35110
35357
|
throw new Error(`Quality record ${recordPath} does not own ${imagePath}.`);
|
|
35111
35358
|
}
|
|
35112
35359
|
}
|
|
35113
35360
|
async function snapshotQualityBaseline(inputs, baselinePath, options = {}) {
|
|
35114
35361
|
if (!inputs.length) throw new Error("Cannot snapshot an empty quality baseline.");
|
|
35115
|
-
const absolute =
|
|
35362
|
+
const absolute = path68.resolve(baselinePath);
|
|
35116
35363
|
for (const input of inputs) {
|
|
35117
|
-
if (
|
|
35364
|
+
if (path68.resolve(input.file) === absolute || input.record && path68.resolve(input.record) === absolute) {
|
|
35118
35365
|
throw new Error(`Quality baseline output would overwrite an input: ${absolute}.`);
|
|
35119
35366
|
}
|
|
35120
35367
|
}
|
|
35121
|
-
const root =
|
|
35368
|
+
const root = path68.dirname(absolute);
|
|
35122
35369
|
const cases = [];
|
|
35123
35370
|
for (const input of [...inputs].sort((a, b) => a.id.localeCompare(b.id))) {
|
|
35124
35371
|
const expected = await measureImageQuality(input.file);
|
|
@@ -35158,7 +35405,7 @@ async function snapshotQualityBaseline(inputs, baselinePath, options = {}) {
|
|
|
35158
35405
|
return { baseline, path: absolute, changed: result.changed.length > 0 };
|
|
35159
35406
|
}
|
|
35160
35407
|
async function snapshotQualityCases(inputs, baselinePath, only, options = {}) {
|
|
35161
|
-
const absolute =
|
|
35408
|
+
const absolute = path68.resolve(baselinePath);
|
|
35162
35409
|
if (!existsSync54(absolute)) {
|
|
35163
35410
|
throw new Error(`quality snapshot --only updates an existing baseline; ${absolute} does not exist. Run a full snapshot first.`);
|
|
35164
35411
|
}
|
|
@@ -35174,12 +35421,12 @@ async function snapshotQualityCases(inputs, baselinePath, only, options = {}) {
|
|
|
35174
35421
|
if (unknown.length) {
|
|
35175
35422
|
throw new Error(`--only names ${unknown.join(", ")}, which the quality inputs do not list. Known: ${[...byId.keys()].sort().join(", ")}`);
|
|
35176
35423
|
}
|
|
35177
|
-
const root =
|
|
35424
|
+
const root = path68.dirname(absolute);
|
|
35178
35425
|
const cases = [...raw.cases];
|
|
35179
35426
|
const report = [];
|
|
35180
35427
|
for (const id of only) {
|
|
35181
35428
|
const input = byId.get(id);
|
|
35182
|
-
if (
|
|
35429
|
+
if (path68.resolve(input.file) === absolute || input.record && path68.resolve(input.record) === absolute) {
|
|
35183
35430
|
throw new Error(`Quality baseline output would overwrite an input: ${absolute}.`);
|
|
35184
35431
|
}
|
|
35185
35432
|
const expected = await measureImageQuality(input.file);
|
|
@@ -35215,7 +35462,7 @@ async function snapshotQualityCases(inputs, baselinePath, only, options = {}) {
|
|
|
35215
35462
|
return { baseline, path: absolute, changed, cases: report };
|
|
35216
35463
|
}
|
|
35217
35464
|
async function readQualityBaseline(baselinePath) {
|
|
35218
|
-
const absolute =
|
|
35465
|
+
const absolute = path68.resolve(baselinePath);
|
|
35219
35466
|
let raw;
|
|
35220
35467
|
try {
|
|
35221
35468
|
raw = JSON.parse(await readFile47(absolute, "utf8"));
|
|
@@ -35240,7 +35487,7 @@ async function readQualityBaseline(baselinePath) {
|
|
|
35240
35487
|
throw new Error(
|
|
35241
35488
|
`Invalid quality baseline ${absolute}:
|
|
35242
35489
|
` + parsed.error.issues.map((issue) => ` ${where(issue.path)}: ${issue.message}`).join("\n") + (missing.length ? `
|
|
35243
|
-
Entries missing fields: re-measure them with \`pixelkiln quality snapshot --inputs <inputs> --out ${
|
|
35490
|
+
Entries missing fields: re-measure them with \`pixelkiln quality snapshot --inputs <inputs> --out ${path68.basename(absolute)} --only ${missing.join(",")}\` rather than editing the JSON by hand.` : "")
|
|
35244
35491
|
);
|
|
35245
35492
|
}
|
|
35246
35493
|
return parsed.data;
|
|
@@ -35302,12 +35549,12 @@ function regressionViolations(expected, actual, tolerances) {
|
|
|
35302
35549
|
return { violations, warnings };
|
|
35303
35550
|
}
|
|
35304
35551
|
async function checkQualityBaseline(baselinePath) {
|
|
35305
|
-
const absolute =
|
|
35552
|
+
const absolute = path68.resolve(baselinePath);
|
|
35306
35553
|
const baseline = await readQualityBaseline(absolute);
|
|
35307
|
-
const root =
|
|
35554
|
+
const root = path68.dirname(absolute);
|
|
35308
35555
|
const cases = [];
|
|
35309
35556
|
for (const entry of baseline.cases) {
|
|
35310
|
-
const file =
|
|
35557
|
+
const file = path68.resolve(root, entry.file);
|
|
35311
35558
|
let actual = null;
|
|
35312
35559
|
const violations = [];
|
|
35313
35560
|
const warnings = [];
|
|
@@ -35320,7 +35567,7 @@ async function checkQualityBaseline(baselinePath) {
|
|
|
35320
35567
|
violations.push(message4(error));
|
|
35321
35568
|
}
|
|
35322
35569
|
if (entry.record) {
|
|
35323
|
-
const recordPath =
|
|
35570
|
+
const recordPath = path68.resolve(root, entry.record.path);
|
|
35324
35571
|
try {
|
|
35325
35572
|
const recordHash = await sha256File(recordPath);
|
|
35326
35573
|
if (recordHash !== entry.record.sha256) violations.push("quality record hash changed");
|
|
@@ -35362,15 +35609,15 @@ async function runQuality(args) {
|
|
|
35362
35609
|
if (!args.out) throw new Error("quality snapshot needs --out <pixelkiln.quality.json>.");
|
|
35363
35610
|
let raw;
|
|
35364
35611
|
try {
|
|
35365
|
-
raw = JSON.parse(await readFile48(
|
|
35612
|
+
raw = JSON.parse(await readFile48(path69.resolve(args.inputs), "utf8"));
|
|
35366
35613
|
} catch (error) {
|
|
35367
35614
|
throw new Error(
|
|
35368
|
-
`Could not read quality inputs ${
|
|
35615
|
+
`Could not read quality inputs ${path69.resolve(args.inputs)}: ${error instanceof Error ? error.message : String(error)}`,
|
|
35369
35616
|
{ cause: error }
|
|
35370
35617
|
);
|
|
35371
35618
|
}
|
|
35372
35619
|
const inputs = resolveQualityInputs(raw, args.inputs);
|
|
35373
|
-
if (
|
|
35620
|
+
if (path69.resolve(args.inputs) === path69.resolve(args.out)) {
|
|
35374
35621
|
throw new Error("quality snapshot --out must not overwrite its --inputs file.");
|
|
35375
35622
|
}
|
|
35376
35623
|
if (args.assets.length) {
|
|
@@ -35385,7 +35632,7 @@ async function runQuality(args) {
|
|
|
35385
35632
|
}
|
|
35386
35633
|
log(
|
|
35387
35634
|
`
|
|
35388
|
-
${result2.changed ? args.dryRun ? "would write" : "wrote" : "no changes to"} ${
|
|
35635
|
+
${result2.changed ? args.dryRun ? "would write" : "wrote" : "no changes to"} ${path69.relative(process.cwd(), result2.path)}; other cases left as they were.`
|
|
35389
35636
|
);
|
|
35390
35637
|
return;
|
|
35391
35638
|
}
|
|
@@ -35400,7 +35647,7 @@ async function runQuality(args) {
|
|
|
35400
35647
|
}, null, 2));
|
|
35401
35648
|
} else {
|
|
35402
35649
|
log(
|
|
35403
|
-
` ${result.changed ? "wrote" : "unchanged"} ${
|
|
35650
|
+
` ${result.changed ? "wrote" : "unchanged"} ${path69.relative(process.cwd(), result.path)} (${result.baseline.cases.length} case(s))`
|
|
35404
35651
|
);
|
|
35405
35652
|
log(` Review the tolerances, commit the baseline, then run quality check in CI.`);
|
|
35406
35653
|
}
|
|
@@ -35426,10 +35673,10 @@ async function runQuality(args) {
|
|
|
35426
35673
|
}
|
|
35427
35674
|
|
|
35428
35675
|
// src/cli/commands/recipe.ts
|
|
35429
|
-
import
|
|
35676
|
+
import path71 from "path";
|
|
35430
35677
|
|
|
35431
35678
|
// src/recipes.ts
|
|
35432
|
-
import
|
|
35679
|
+
import path70 from "path";
|
|
35433
35680
|
import { existsSync as existsSync55 } from "fs";
|
|
35434
35681
|
import { readdir as readdir7, readFile as readFile49 } from "fs/promises";
|
|
35435
35682
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
@@ -35440,7 +35687,7 @@ var VERSION_RE = /^\d+\.\d+\.\d+$/;
|
|
|
35440
35687
|
var RECIPE_FILE = "pixelkiln.recipe.json";
|
|
35441
35688
|
var RECIPE_DIR_TOKEN = "{{recipeDir}}";
|
|
35442
35689
|
var PortablePathSchema = z18.string().min(1).refine((value) => {
|
|
35443
|
-
if (value.includes("\\") ||
|
|
35690
|
+
if (value.includes("\\") || path70.posix.isAbsolute(value)) return false;
|
|
35444
35691
|
const parts = value.split("/");
|
|
35445
35692
|
return !parts.includes("") && !parts.includes(".") && !parts.includes("..");
|
|
35446
35693
|
}, "expected a portable relative path without '.', '..', or backslashes");
|
|
@@ -35637,7 +35884,7 @@ function message5(error) {
|
|
|
35637
35884
|
return error instanceof Error ? error.message : String(error);
|
|
35638
35885
|
}
|
|
35639
35886
|
async function readRecipeFile(recipePath, bundled) {
|
|
35640
|
-
const absolute =
|
|
35887
|
+
const absolute = path70.resolve(recipePath);
|
|
35641
35888
|
let raw;
|
|
35642
35889
|
try {
|
|
35643
35890
|
raw = JSON.parse(await readFile49(absolute, "utf8"));
|
|
@@ -35651,13 +35898,13 @@ async function readRecipeFile(recipePath, bundled) {
|
|
|
35651
35898
|
` + parsed.error.issues.map((issue) => ` ${issue.path.join(".") || "$"}: ${issue.message}`).join("\n")
|
|
35652
35899
|
);
|
|
35653
35900
|
}
|
|
35654
|
-
return { recipe: parsed.data, authored: raw, path: absolute, dir:
|
|
35901
|
+
return { recipe: parsed.data, authored: raw, path: absolute, dir: path70.dirname(absolute), bundled };
|
|
35655
35902
|
}
|
|
35656
35903
|
async function walkRecipeFiles(root) {
|
|
35657
35904
|
if (!existsSync55(root)) return [];
|
|
35658
35905
|
const out = [];
|
|
35659
35906
|
for (const entry of await readdir7(root, { withFileTypes: true })) {
|
|
35660
|
-
const resolved =
|
|
35907
|
+
const resolved = path70.join(root, entry.name);
|
|
35661
35908
|
if (entry.isDirectory()) out.push(...await walkRecipeFiles(resolved));
|
|
35662
35909
|
else if (entry.isFile() && entry.name === RECIPE_FILE) out.push(resolved);
|
|
35663
35910
|
}
|
|
@@ -35668,7 +35915,7 @@ function bundledRecipeRoot() {
|
|
|
35668
35915
|
}
|
|
35669
35916
|
async function listBundledRecipes(root = bundledRecipeRoot()) {
|
|
35670
35917
|
const recipes = await Promise.all(
|
|
35671
|
-
(await walkRecipeFiles(
|
|
35918
|
+
(await walkRecipeFiles(path70.resolve(root))).map((file) => readRecipeFile(file, true))
|
|
35672
35919
|
);
|
|
35673
35920
|
return recipes.sort(
|
|
35674
35921
|
(a, b) => a.recipe.id.localeCompare(b.recipe.id) || compareVersions(b.recipe.version, a.recipe.version)
|
|
@@ -35691,9 +35938,9 @@ function parseSelector(selector) {
|
|
|
35691
35938
|
return { id: match[1], version: match[2] };
|
|
35692
35939
|
}
|
|
35693
35940
|
async function resolveRecipe(target, bundledRoot = bundledRecipeRoot()) {
|
|
35694
|
-
const local =
|
|
35941
|
+
const local = path70.resolve(target);
|
|
35695
35942
|
if (existsSync55(local)) {
|
|
35696
|
-
const recipePath =
|
|
35943
|
+
const recipePath = path70.basename(local) === RECIPE_FILE ? local : path70.join(local, RECIPE_FILE);
|
|
35697
35944
|
return readRecipeFile(recipePath, false);
|
|
35698
35945
|
}
|
|
35699
35946
|
if (target.startsWith(".") || target.startsWith("/") || target.includes("\\")) {
|
|
@@ -35707,7 +35954,7 @@ async function resolveRecipe(target, bundledRoot = bundledRecipeRoot()) {
|
|
|
35707
35954
|
return matches[0];
|
|
35708
35955
|
}
|
|
35709
35956
|
async function verifyFile(root, file) {
|
|
35710
|
-
const absolute =
|
|
35957
|
+
const absolute = path70.resolve(root, ...file.path.split("/"));
|
|
35711
35958
|
if (!existsSync55(absolute)) {
|
|
35712
35959
|
return { path: file.path, expectedSha256: file.sha256, actualSha256: null, status: "missing" };
|
|
35713
35960
|
}
|
|
@@ -35723,7 +35970,7 @@ async function verifyRecipe(target, options = {}) {
|
|
|
35723
35970
|
const loaded = await resolveRecipe(target, options.bundledRoot);
|
|
35724
35971
|
const actualIntegrity = recipeDigest(loaded.authored);
|
|
35725
35972
|
const files = await Promise.all(loaded.recipe.files.map((file) => verifyFile(loaded.dir, file)));
|
|
35726
|
-
const modelRoot = options.modelRoot ?
|
|
35973
|
+
const modelRoot = options.modelRoot ? path70.resolve(options.modelRoot) : null;
|
|
35727
35974
|
const models = modelRoot ? await Promise.all(loaded.recipe.models.map(async (model) => ({
|
|
35728
35975
|
...await verifyFile(modelRoot, model),
|
|
35729
35976
|
source: model.source,
|
|
@@ -35757,7 +36004,7 @@ async function verifyRecipe(target, options = {}) {
|
|
|
35757
36004
|
};
|
|
35758
36005
|
}
|
|
35759
36006
|
function renderStyle(style, destination, cwd) {
|
|
35760
|
-
const portableDir =
|
|
36007
|
+
const portableDir = path70.relative(cwd, destination).split(path70.sep).join("/") || ".";
|
|
35761
36008
|
const replace = (value) => {
|
|
35762
36009
|
if (typeof value === "string") return value.replaceAll(RECIPE_DIR_TOKEN, portableDir);
|
|
35763
36010
|
if (Array.isArray(value)) return value.map(replace);
|
|
@@ -35769,19 +36016,19 @@ function renderStyle(style, destination, cwd) {
|
|
|
35769
36016
|
return replace(style);
|
|
35770
36017
|
}
|
|
35771
36018
|
async function installRecipe(target, options = {}) {
|
|
35772
|
-
const cwd =
|
|
36019
|
+
const cwd = path70.resolve(options.cwd ?? process.cwd());
|
|
35773
36020
|
const loaded = await resolveRecipe(target, options.bundledRoot);
|
|
35774
36021
|
const verification = await verifyRecipe(loaded.path);
|
|
35775
36022
|
if (!verification.ok) {
|
|
35776
36023
|
throw new Error(`Recipe ${loaded.recipe.id}@${loaded.recipe.version} failed integrity verification.`);
|
|
35777
36024
|
}
|
|
35778
|
-
const destination = options.out ?
|
|
36025
|
+
const destination = options.out ? path70.resolve(cwd, options.out) : path70.join(cwd, "pixelkiln-recipes", ...loaded.recipe.id.split("/"), loaded.recipe.version);
|
|
35779
36026
|
const sources = [
|
|
35780
36027
|
{ path: RECIPE_FILE, source: loaded.path },
|
|
35781
|
-
...loaded.recipe.files.map((file) => ({ path: file.path, source:
|
|
36028
|
+
...loaded.recipe.files.map((file) => ({ path: file.path, source: path70.join(loaded.dir, ...file.path.split("/")) }))
|
|
35782
36029
|
];
|
|
35783
36030
|
const files = await Promise.all(sources.map(async (file) => ({
|
|
35784
|
-
path:
|
|
36031
|
+
path: path70.join(destination, ...file.path.split("/")),
|
|
35785
36032
|
data: await readFile49(file.source)
|
|
35786
36033
|
})));
|
|
35787
36034
|
if (!options.force) {
|
|
@@ -35881,14 +36128,14 @@ async function runRecipe(args) {
|
|
|
35881
36128
|
}, null, 2));
|
|
35882
36129
|
} else {
|
|
35883
36130
|
log(` installed ${result.recipe.id}@${result.recipe.version}`);
|
|
35884
|
-
log(` ${
|
|
36131
|
+
log(` ${path71.relative(process.cwd(), result.destination) || "."}`);
|
|
35885
36132
|
log(`
|
|
35886
36133
|
Add this entry under your manifest's styles object:`);
|
|
35887
36134
|
log(JSON.stringify({ [result.styleId]: result.style }, null, 2));
|
|
35888
36135
|
if (result.recipe.models.length) {
|
|
35889
36136
|
log(`
|
|
35890
36137
|
Models are not downloaded automatically. Verify them with:`);
|
|
35891
|
-
log(` pixelkiln recipe verify ${
|
|
36138
|
+
log(` pixelkiln recipe verify ${path71.relative(process.cwd(), result.destination)} --model-root <ComfyUI/models>`);
|
|
35892
36139
|
}
|
|
35893
36140
|
}
|
|
35894
36141
|
return;
|
|
@@ -35896,7 +36143,7 @@ async function runRecipe(args) {
|
|
|
35896
36143
|
}
|
|
35897
36144
|
|
|
35898
36145
|
// src/cli/commands/refine.ts
|
|
35899
|
-
import
|
|
36146
|
+
import path72 from "path";
|
|
35900
36147
|
async function runRefine(args) {
|
|
35901
36148
|
if (args.from || args.subcommand === "approve") {
|
|
35902
36149
|
if (!args.from) {
|
|
@@ -35926,12 +36173,12 @@ async function runRefine(args) {
|
|
|
35926
36173
|
` recovered ${result3.detection.columns}x${result3.detection.rows} native grid (${result3.detection.confidence}: ${result3.detection.consensus})`
|
|
35927
36174
|
);
|
|
35928
36175
|
log(` enforced ${result3.palette.length}-color palette without dithering`);
|
|
35929
|
-
log(` wrote ${
|
|
35930
|
-
log(` quality record: ${
|
|
36176
|
+
log(` wrote ${path72.relative(process.cwd(), result3.output)}`);
|
|
36177
|
+
log(` quality record: ${path72.relative(process.cwd(), result3.record)}`);
|
|
35931
36178
|
log(`
|
|
35932
36179
|
Automated checks passed. Human 1\xD7 review is still required:`);
|
|
35933
36180
|
log(
|
|
35934
|
-
` pixelkiln refine approve --from ${
|
|
36181
|
+
` pixelkiln refine approve --from ${path72.relative(process.cwd(), result3.record)} --reviewer "Your Name"`
|
|
35935
36182
|
);
|
|
35936
36183
|
}
|
|
35937
36184
|
return;
|
|
@@ -35959,7 +36206,7 @@ async function runRefine(args) {
|
|
|
35959
36206
|
if (args.json) log(JSON.stringify(result3, null, 2));
|
|
35960
36207
|
else {
|
|
35961
36208
|
log(
|
|
35962
|
-
result3.options.frameSet ? ` approved ${result3.outputs.length} frames in ${
|
|
36209
|
+
result3.options.frameSet ? ` approved ${result3.outputs.length} frames in ${path72.relative(process.cwd(), result3.record)} by ${args.reviewer.trim()}` : ` approved ${path72.relative(process.cwd(), result3.output)} by ${args.reviewer.trim()}`
|
|
35963
36210
|
);
|
|
35964
36211
|
}
|
|
35965
36212
|
return;
|
|
@@ -35968,7 +36215,7 @@ async function runRefine(args) {
|
|
|
35968
36215
|
if (args.json) {
|
|
35969
36216
|
log(JSON.stringify(result2, null, 2));
|
|
35970
36217
|
} else {
|
|
35971
|
-
log(` ${result2.safe ? "release-ready" : "not release-ready"}: ${
|
|
36218
|
+
log(` ${result2.safe ? "release-ready" : "not release-ready"}: ${path72.relative(process.cwd(), result2.output || result2.record)}`);
|
|
35972
36219
|
for (const reason of result2.reasons) log(` ${reason}`);
|
|
35973
36220
|
}
|
|
35974
36221
|
if (!result2.safe) process.exitCode = 1;
|
|
@@ -36014,7 +36261,7 @@ async function runRefine(args) {
|
|
|
36014
36261
|
log(` ${item.state.padEnd(16)} ${item.key} ${item.reason}`);
|
|
36015
36262
|
if (item.state === "needs-approval") {
|
|
36016
36263
|
log(
|
|
36017
|
-
` pixelkiln refine approve --from ${
|
|
36264
|
+
` pixelkiln refine approve --from ${path72.relative(process.cwd(), item.record)} --reviewer "Your Name"`
|
|
36018
36265
|
);
|
|
36019
36266
|
}
|
|
36020
36267
|
}
|
|
@@ -36027,7 +36274,7 @@ async function runRefine(args) {
|
|
|
36027
36274
|
}
|
|
36028
36275
|
|
|
36029
36276
|
// src/cli/commands/anchors.ts
|
|
36030
|
-
import
|
|
36277
|
+
import path73 from "path";
|
|
36031
36278
|
async function runAnchors(args) {
|
|
36032
36279
|
const target = args.target;
|
|
36033
36280
|
const { specs, lock } = await openProject2(args);
|
|
@@ -36048,7 +36295,7 @@ async function runAnchors(args) {
|
|
|
36048
36295
|
dryRun: args.dryRun,
|
|
36049
36296
|
onProgress: log
|
|
36050
36297
|
});
|
|
36051
|
-
const file =
|
|
36298
|
+
const file = path73.relative(spec.root, result.file) || result.file;
|
|
36052
36299
|
if (args.dryRun) {
|
|
36053
36300
|
log(` ${result.estimated} frame${result.estimated === 1 ? "" : "s"} to estimate (about ${cost(result.estimated)}), ${result.current} already current`);
|
|
36054
36301
|
} else if (result.estimated) {
|
|
@@ -36060,12 +36307,12 @@ async function runAnchors(args) {
|
|
|
36060
36307
|
}
|
|
36061
36308
|
|
|
36062
36309
|
// src/cli/commands/parallax.ts
|
|
36063
|
-
import
|
|
36310
|
+
import path75 from "path";
|
|
36064
36311
|
|
|
36065
36312
|
// src/pipeline/parallax.ts
|
|
36066
36313
|
import { createHash as createHash9 } from "crypto";
|
|
36067
36314
|
import { readFile as readFile50 } from "fs/promises";
|
|
36068
|
-
import
|
|
36315
|
+
import path74 from "path";
|
|
36069
36316
|
var PARALLAX_FORMATS = ["tiled", "godot", "ldtk"];
|
|
36070
36317
|
var SEAM_WARN_RATIO = 2;
|
|
36071
36318
|
function layerFiles(layer) {
|
|
@@ -36134,7 +36381,7 @@ function seamRatio(png) {
|
|
|
36134
36381
|
}
|
|
36135
36382
|
function layerName(layer, index) {
|
|
36136
36383
|
if (layer.name) return layer.name;
|
|
36137
|
-
const base = layer.asset ?? (layer.file ?
|
|
36384
|
+
const base = layer.asset ?? (layer.file ? path74.basename(layer.file, path74.extname(layer.file)) : layer.run ? "run" : "sky");
|
|
36138
36385
|
const slug3 = base.replace(/[^A-Za-z0-9_-]+/g, "_").replace(/^[^A-Za-z]+/, "");
|
|
36139
36386
|
return slug3 || `layer${index + 1}`;
|
|
36140
36387
|
}
|
|
@@ -36497,7 +36744,7 @@ function timeColours(set) {
|
|
|
36497
36744
|
}
|
|
36498
36745
|
async function readPicture(manifest, manifestDir, lock, setId, name, ref, warnings) {
|
|
36499
36746
|
if (ref.file) {
|
|
36500
|
-
const file2 =
|
|
36747
|
+
const file2 = path74.resolve(manifestDir, ref.file);
|
|
36501
36748
|
return { png: decodePng(await readFile50(file2)), source: { kind: "file", path: file2 } };
|
|
36502
36749
|
}
|
|
36503
36750
|
const assetId = ref.asset;
|
|
@@ -36506,7 +36753,7 @@ async function readPicture(manifest, manifestDir, lock, setId, name, ref, warnin
|
|
|
36506
36753
|
if (!entry) throw new Error(`parallax ${setId}: ${style}/${assetId} has not been generated; run gen first`);
|
|
36507
36754
|
const output = entry.outputs.find((candidate) => /\.png$/i.test(candidate.path)) ?? entry.outputs[0];
|
|
36508
36755
|
if (!output) throw new Error(`parallax ${setId}: ${style}/${assetId} has no output in the lockfile`);
|
|
36509
|
-
const file =
|
|
36756
|
+
const file = path74.resolve(manifestDir, output.path);
|
|
36510
36757
|
if (entry.outputs.length > 1) warnings.push(`${name}: ${style}/${assetId} has ${entry.outputs.length} outputs; using ${output.path}`);
|
|
36511
36758
|
return { png: decodePng(await readFile50(file)), source: { kind: "asset", style, asset: assetId, path: file } };
|
|
36512
36759
|
}
|
|
@@ -36622,7 +36869,7 @@ function cameraPath(set, frames) {
|
|
|
36622
36869
|
function layerPngs(set, base) {
|
|
36623
36870
|
return set.layers.map((layer) => ({
|
|
36624
36871
|
layer,
|
|
36625
|
-
file: `${
|
|
36872
|
+
file: `${path74.basename(base)}-${layer.name}.png`,
|
|
36626
36873
|
png: encodeRgbaPng(layer.png.width, layer.png.height, layer.png.pixels)
|
|
36627
36874
|
}));
|
|
36628
36875
|
}
|
|
@@ -36672,7 +36919,7 @@ function exportTiled(set, base) {
|
|
|
36672
36919
|
]
|
|
36673
36920
|
};
|
|
36674
36921
|
return {
|
|
36675
|
-
files: [{ path: `${base}.tmj`, data: JSON.stringify(map, null, 2) + "\n" }, ...pictures.map((p) => ({ path:
|
|
36922
|
+
files: [{ path: `${base}.tmj`, data: JSON.stringify(map, null, 2) + "\n" }, ...pictures.map((p) => ({ path: path74.join(path74.dirname(base), p.file), data: p.png }))],
|
|
36676
36923
|
options: { format: "tiled", start: [0, set.climb] }
|
|
36677
36924
|
};
|
|
36678
36925
|
}
|
|
@@ -36685,7 +36932,7 @@ function godotNumber(value) {
|
|
|
36685
36932
|
function exportGodot(set, base) {
|
|
36686
36933
|
const [vw, vh] = set.view;
|
|
36687
36934
|
const pictures = layerPngs(set, base);
|
|
36688
|
-
const name =
|
|
36935
|
+
const name = path74.basename(base);
|
|
36689
36936
|
const times = set.times ?? [];
|
|
36690
36937
|
const lines = [`[gd_scene load_steps=${pictures.length + 1 + (times.length ? 3 : 0)} format=3]`, ""];
|
|
36691
36938
|
pictures.forEach(({ file }, index) => {
|
|
@@ -36722,7 +36969,7 @@ function exportGodot(set, base) {
|
|
|
36722
36969
|
lines.push(`position = Vector2(${px}, ${py})`);
|
|
36723
36970
|
});
|
|
36724
36971
|
return {
|
|
36725
|
-
files: [{ path: `${base}.tscn`, data: lines.join("\n") + "\n" }, ...pictures.map((p) => ({ path:
|
|
36972
|
+
files: [{ path: `${base}.tscn`, data: lines.join("\n") + "\n" }, ...pictures.map((p) => ({ path: path74.join(path74.dirname(base), p.file), data: p.png })), ...extra],
|
|
36726
36973
|
options: { format: "godot", start: [0, set.climb], ...times.length ? { shader: `${name}.gdshader` } : {} }
|
|
36727
36974
|
};
|
|
36728
36975
|
}
|
|
@@ -36736,7 +36983,7 @@ function exportLdtk(set, base) {
|
|
|
36736
36983
|
const grid = LDTK_GRID;
|
|
36737
36984
|
const levelW = vw + set.travel;
|
|
36738
36985
|
const levelH = vh + set.climb;
|
|
36739
|
-
const name =
|
|
36986
|
+
const name = path74.basename(base);
|
|
36740
36987
|
const files = [];
|
|
36741
36988
|
const warnings = [];
|
|
36742
36989
|
const identifiers = /* @__PURE__ */ new Set();
|
|
@@ -36771,7 +37018,7 @@ function exportLdtk(set, base) {
|
|
|
36771
37018
|
const span = { width: cols * grid, height: rows * grid, pixels: Buffer.alloc(cols * grid * rows * grid * 4) };
|
|
36772
37019
|
drawLayer(span, layer, px.pad + layer.x - x0, py.pad + layer.y - y0);
|
|
36773
37020
|
const file = `${name}-${layer.name}.png`;
|
|
36774
|
-
files.push({ path:
|
|
37021
|
+
files.push({ path: path74.join(path74.dirname(base), file), data: encodeRgbaPng(span.width, span.height, span.pixels) });
|
|
36775
37022
|
const tilesetUid = uid++;
|
|
36776
37023
|
const layerUid = uid++;
|
|
36777
37024
|
let identifier2 = layer.name.replace(/[^A-Za-z0-9_]/g, "_");
|
|
@@ -36974,7 +37221,7 @@ function exportParallax(set, format, base) {
|
|
|
36974
37221
|
if (!warnings.includes(warning)) result.options.warnings = [...warnings, warning];
|
|
36975
37222
|
}
|
|
36976
37223
|
}
|
|
36977
|
-
result.options.maps = [
|
|
37224
|
+
result.options.maps = [path74.basename(result.files[0].path), ...set.times.map((t) => `${path74.basename(base)}.${t.name}${path74.extname(result.files[0].path)}`)];
|
|
36978
37225
|
return result;
|
|
36979
37226
|
}
|
|
36980
37227
|
var GODOT_TIMES_SHADER = `// Written by pixelkiln parallax export. Recolours the set to one of its times of day.
|
|
@@ -37101,7 +37348,7 @@ Promise.all(images.flat().map((image) => image.decode())).then(() => requestAnim
|
|
|
37101
37348
|
// src/cli/commands/parallax.ts
|
|
37102
37349
|
async function runParallax(args) {
|
|
37103
37350
|
const { loaded, lock } = await openProject2(args);
|
|
37104
|
-
const manifestDir =
|
|
37351
|
+
const manifestDir = path75.dirname(path75.resolve(args.manifest));
|
|
37105
37352
|
const ids = Object.keys(loaded.manifest.parallax ?? {});
|
|
37106
37353
|
if (!ids.length) throw new Error('The manifest has no parallax sets. Add one under "parallax"; see docs/PARALLAX.md.');
|
|
37107
37354
|
const wanted = args.target ? [args.target] : ids;
|
|
@@ -37110,7 +37357,7 @@ async function runParallax(args) {
|
|
|
37110
37357
|
}
|
|
37111
37358
|
for (const id of wanted) {
|
|
37112
37359
|
const set = await resolveParallaxSet(loaded.manifest, manifestDir, lock, id);
|
|
37113
|
-
const root =
|
|
37360
|
+
const root = path75.resolve(args.out ?? path75.join(manifestDir, "parallax", id));
|
|
37114
37361
|
const sources = [
|
|
37115
37362
|
await provenanceFile("$manifest", args.manifest),
|
|
37116
37363
|
await provenanceFile("$lock", args.lock),
|
|
@@ -37124,7 +37371,7 @@ async function runParallax(args) {
|
|
|
37124
37371
|
if (args.subcommand === "export") {
|
|
37125
37372
|
const formats = args.format ? [args.format] : [...PARALLAX_FORMATS];
|
|
37126
37373
|
for (const format of formats) {
|
|
37127
|
-
const base =
|
|
37374
|
+
const base = path75.join(root, format, id);
|
|
37128
37375
|
const result = exportParallax(set, format, base);
|
|
37129
37376
|
const outputs = result.files.map((file) => ({ path: file.path, data: typeof file.data === "string" ? Buffer.from(file.data) : file.data }));
|
|
37130
37377
|
await writeManagedArtifactBundle(`${base}.pixelkiln.json`, outputs, {
|
|
@@ -37132,7 +37379,7 @@ async function runParallax(args) {
|
|
|
37132
37379
|
sources,
|
|
37133
37380
|
options: { set: id, ...describe2, ...result.options }
|
|
37134
37381
|
}, { force: args.force });
|
|
37135
|
-
log(` ${id} (${format}): ${
|
|
37382
|
+
log(` ${id} (${format}): ${path75.relative(process.cwd(), result.files[0].path)} + ${result.files.length - 1} more file(s)`);
|
|
37136
37383
|
for (const warning of result.options.warnings ?? []) log(` warning: ${warning}`);
|
|
37137
37384
|
}
|
|
37138
37385
|
} else {
|
|
@@ -37143,7 +37390,7 @@ async function runParallax(args) {
|
|
|
37143
37390
|
return encodeRgbaPng(frame.width, frame.height, frame.pixels);
|
|
37144
37391
|
})
|
|
37145
37392
|
);
|
|
37146
|
-
const base =
|
|
37393
|
+
const base = path75.join(root, `${id}.preview`);
|
|
37147
37394
|
await writeManagedArtifactBundle(`${base}.pixelkiln.json`, [
|
|
37148
37395
|
{ path: `${base}.html`, data: Buffer.from(previewHtml(set)) },
|
|
37149
37396
|
{ path: `${base}.png`, data: strip(set) },
|
|
@@ -37154,8 +37401,8 @@ async function runParallax(args) {
|
|
|
37154
37401
|
sources,
|
|
37155
37402
|
options: { set: id, ...describe2, preview: { frames } }
|
|
37156
37403
|
}, { force: args.force });
|
|
37157
|
-
log(` ${id}: ${
|
|
37158
|
-
if (set.times?.length) log(` times: ${set.times.map((time) => `${time.name} (${
|
|
37404
|
+
log(` ${id}: ${path75.relative(process.cwd(), base)}.html (scrolls in a browser) + .png (${frames} frames, start to end)`);
|
|
37405
|
+
if (set.times?.length) log(` times: ${set.times.map((time) => `${time.name} (${path75.basename(base)}.${time.name}.png)`).join(", ")}`);
|
|
37159
37406
|
}
|
|
37160
37407
|
for (const layer of set.layers) {
|
|
37161
37408
|
const seam = (layer.seamRatio === void 0 ? "" : `, seam ${layer.seamRatio.toFixed(1)}`) + (layer.seamRatioY === void 0 ? "" : `, vertical seam ${layer.seamRatioY.toFixed(1)}`);
|
|
@@ -37188,12 +37435,12 @@ function setOptions(set) {
|
|
|
37188
37435
|
}
|
|
37189
37436
|
|
|
37190
37437
|
// src/cli/commands/redraw.ts
|
|
37191
|
-
import
|
|
37438
|
+
import path77 from "path";
|
|
37192
37439
|
|
|
37193
37440
|
// src/pipeline/redraw.ts
|
|
37194
37441
|
import { existsSync as existsSync56 } from "fs";
|
|
37195
|
-
import { mkdir as
|
|
37196
|
-
import
|
|
37442
|
+
import { mkdir as mkdir27, readFile as readFile51, rename as rename15, writeFile as writeFile32 } from "fs/promises";
|
|
37443
|
+
import path76 from "path";
|
|
37197
37444
|
function redrawRoles(spec, lock) {
|
|
37198
37445
|
return (lock.entries[lockKey(spec.styleId, spec.assetId)]?.outputs ?? []).map((output) => output.role ?? "");
|
|
37199
37446
|
}
|
|
@@ -37256,6 +37503,7 @@ async function redrawLayerFrames(spec, lock, painter, opts) {
|
|
|
37256
37503
|
padding: layer.padding,
|
|
37257
37504
|
key: layer.key,
|
|
37258
37505
|
skin: layer.skin,
|
|
37506
|
+
cover: layer.cover,
|
|
37259
37507
|
reference: layer.clean ? stills : []
|
|
37260
37508
|
});
|
|
37261
37509
|
const offset = entry.postprocess?.offset;
|
|
@@ -37280,12 +37528,12 @@ async function redrawLayerFrames(spec, lock, painter, opts) {
|
|
|
37280
37528
|
const prepared = redrawSheet(built, layers, redraw);
|
|
37281
37529
|
const size = decodePng(prepared.keyed);
|
|
37282
37530
|
const cost = proTierCost(size.width, size.height);
|
|
37283
|
-
const workDir =
|
|
37531
|
+
const workDir = path76.join(layerWorkDir(spec), "redraw");
|
|
37284
37532
|
const result = { roles, guides, sheet: { width: size.width, height: size.height }, cost, billed: null, written: [], workDir };
|
|
37285
37533
|
if (opts.dryRun) return result;
|
|
37286
|
-
await
|
|
37287
|
-
await
|
|
37288
|
-
await
|
|
37534
|
+
await mkdir27(workDir, { recursive: true });
|
|
37535
|
+
await writeFile32(path76.join(workDir, "keyed.png"), prepared.keyed);
|
|
37536
|
+
await writeFile32(path76.join(workDir, "mask.png"), prepared.mask);
|
|
37289
37537
|
const count = roles.length;
|
|
37290
37538
|
const description = `${spec.prompt}. Every figure but ${count === 1 ? "one" : count} already wears it. Dress the unfinished figure${count === 1 ? "" : "s"} in exactly the same thing, the same colours and details, seen from the side ${count === 1 ? "that figure faces" : "each of those figures faces"}.`;
|
|
37291
37539
|
const jobId = await painter.paintSheet({ description, keyed: prepared.keyed, mask: prepared.mask, seed: opts.seed ?? spec.seed });
|
|
@@ -37303,13 +37551,13 @@ async function redrawLayerFrames(spec, lock, painter, opts) {
|
|
|
37303
37551
|
if (Date.now() > deadline) throw new Error(`${label}: redraw job ${jobId} did not finish in time; nothing was changed`);
|
|
37304
37552
|
await new Promise((resolve) => setTimeout(resolve, opts.pollMs ?? 3e3));
|
|
37305
37553
|
}
|
|
37306
|
-
await
|
|
37554
|
+
await writeFile32(path76.join(workDir, "result.png"), painted);
|
|
37307
37555
|
const returned = decodePng(painted);
|
|
37308
37556
|
if (returned.width !== size.width || returned.height !== size.height) {
|
|
37309
37557
|
throw new Error(`${label}: redraw job ${jobId} returned a ${returned.width}x${returned.height} image for a ${size.width}x${size.height} sheet`);
|
|
37310
37558
|
}
|
|
37311
37559
|
const cut = cutLayerFrames(painted, { keyed: prepared.keyed, mask: prepared.mask, frames: built.frames }, { key: layer.key, region: layer.region });
|
|
37312
|
-
const cacheDir =
|
|
37560
|
+
const cacheDir = path76.resolve(opts.cacheDir ?? path76.join(path76.dirname(opts.lockPath), ".pixelkiln", "cache"));
|
|
37313
37561
|
const outputs = [...entry.outputs];
|
|
37314
37562
|
const renames = [];
|
|
37315
37563
|
for (const [index, at2] of targets) {
|
|
@@ -37323,7 +37571,7 @@ async function redrawLayerFrames(spec, lock, painter, opts) {
|
|
|
37323
37571
|
const processed = applyPostprocess(raw, MediaType.PNG, entry.postprocess, [], role);
|
|
37324
37572
|
await cacheMedia(cacheDir, processed.bytes, MediaType.PNG);
|
|
37325
37573
|
const tmp = `${target}.pixelkiln.tmp`;
|
|
37326
|
-
await
|
|
37574
|
+
await writeFile32(tmp, processed.bytes);
|
|
37327
37575
|
renames.push([tmp, target]);
|
|
37328
37576
|
const { raw: _raw, ...kept } = outputs[at2];
|
|
37329
37577
|
outputs[at2] = { ...kept, sha256: sha256(processed.bytes), ...processed.changed ? { raw: sha256(raw) } : {} };
|
|
@@ -37367,7 +37615,7 @@ async function runRedraw(args) {
|
|
|
37367
37615
|
const painter = args.dryRun ? { paintSheet: never, paintedSheet: never } : new PixelLabProvider(clientFromEnv());
|
|
37368
37616
|
const result = await redrawLayerFrames(spec, project2.lock, painter, {
|
|
37369
37617
|
frames: args.redrawFrames,
|
|
37370
|
-
lockPath:
|
|
37618
|
+
lockPath: path77.resolve(args.lock),
|
|
37371
37619
|
seed: args.seed,
|
|
37372
37620
|
dryRun: args.dryRun,
|
|
37373
37621
|
onProgress: log
|
|
@@ -37378,16 +37626,42 @@ async function runRedraw(args) {
|
|
|
37378
37626
|
log(` would redraw ${frames} (${result.roles.join(", ")}) beside ${result.guides} dressed, on a ${sheet} sheet: about ${result.cost} generations`);
|
|
37379
37627
|
return;
|
|
37380
37628
|
}
|
|
37381
|
-
for (const file of result.written) log(` wrote ${
|
|
37629
|
+
for (const file of result.written) log(` wrote ${path77.relative(process.cwd(), file)}`);
|
|
37382
37630
|
const billed = result.billed ? `${result.billed.amount} ${result.billed.unit} billed` : `about ${result.cost} generations`;
|
|
37383
|
-
log(` redrew ${frames} of ${target} (${billed}); the sheet and result are in ${
|
|
37631
|
+
log(` redrew ${frames} of ${target} (${billed}); the sheet and result are in ${path77.relative(process.cwd(), result.workDir)}`);
|
|
37384
37632
|
log(` look at ${result.written.length === 1 ? "it" : "them"}, then run pixelkiln gen to rebuild anything made from this layer`);
|
|
37385
37633
|
}
|
|
37386
37634
|
|
|
37635
|
+
// src/cli/commands/layer.ts
|
|
37636
|
+
import path78 from "path";
|
|
37637
|
+
async function runLayer(args) {
|
|
37638
|
+
const target = args.target;
|
|
37639
|
+
const project2 = await openProject2(args);
|
|
37640
|
+
const named = project2.specs.filter((spec) => spec.assetId === target);
|
|
37641
|
+
if (!named.length) throw new UsageError(`No asset "${target}" in ${args.manifest}`);
|
|
37642
|
+
const layers = named.filter((spec) => spec.character?.kind === "layer");
|
|
37643
|
+
if (!layers.length) throw new UsageError(`${target} is not a paperdoll layer`);
|
|
37644
|
+
if (layers.length > 1) {
|
|
37645
|
+
throw new UsageError(`${target} is a layer in ${layers.length} styles (${layers.map((spec) => spec.styleId).join(", ")}); pick one with --style`);
|
|
37646
|
+
}
|
|
37647
|
+
const result = await previewLayer(layers[0], project2.lock);
|
|
37648
|
+
const width = Math.max(...result.frames.map((frame) => frame.name.length));
|
|
37649
|
+
for (const frame of result.frames) {
|
|
37650
|
+
const neck = frame.neck ? `neck row ${String(frame.neck.row).padStart(3)}` + (frame.neck.corrected ? ` (own narrowest row ${frame.neck.detected ?? "none"}; taken from the head and the other frames)` : "") : result.supplied.mask ? "mask supplied" : "empty";
|
|
37651
|
+
log(` ${frame.name.padEnd(width)} ${String(frame.masked).padStart(6)} px open ${neck}`);
|
|
37652
|
+
}
|
|
37653
|
+
const corrected = result.frames.filter((frame) => frame.neck?.corrected).length;
|
|
37654
|
+
if (corrected) log(` ${corrected} frame${corrected === 1 ? "'s" : "s'"} neck overruled; look at those in overlay.png before paying`);
|
|
37655
|
+
if (result.closed) log(` ${result.closed} pinhole pixel${result.closed === 1 ? "" : "s"} keyed shut inside the mask`);
|
|
37656
|
+
if (result.cleaned) log(` ${result.cleaned} ghost pixel${result.cleaned === 1 ? "" : "s"} cleaned from the loops`);
|
|
37657
|
+
log(` wrote ${result.written.length} files to ${path78.relative(process.cwd(), result.dir) || "."} (overlay.png shows the mask over the frames)`);
|
|
37658
|
+
log(` ${result.frames.length} frames on a ${result.sheet.width}x${result.sheet.height} sheet: about ${result.cost} generations when generated; nothing was sent`);
|
|
37659
|
+
}
|
|
37660
|
+
|
|
37387
37661
|
// src/cli/commands/skeleton.ts
|
|
37388
|
-
import
|
|
37662
|
+
import path79 from "path";
|
|
37389
37663
|
import { existsSync as existsSync57 } from "fs";
|
|
37390
|
-
import { readFile as readFile52, writeFile as
|
|
37664
|
+
import { readFile as readFile52, writeFile as writeFile33 } from "fs/promises";
|
|
37391
37665
|
|
|
37392
37666
|
// src/skeleton-preview.ts
|
|
37393
37667
|
var RIGHT = [255, 140, 40, 255];
|
|
@@ -37508,12 +37782,12 @@ var Canvas = class {
|
|
|
37508
37782
|
async function runEstimateSkeleton(args) {
|
|
37509
37783
|
const image = args.target;
|
|
37510
37784
|
if (!image) throw new UsageError("estimate-skeleton needs an image path: pixelkiln estimate-skeleton <image> [--out keypoints.json]");
|
|
37511
|
-
if (args.out && existsSync57(
|
|
37785
|
+
if (args.out && existsSync57(path79.resolve(args.out)) && !args.force) {
|
|
37512
37786
|
throw new UsageError(`${args.out} already exists; pass --force to replace it`);
|
|
37513
37787
|
}
|
|
37514
|
-
loadEnvFiles(
|
|
37788
|
+
loadEnvFiles(path79.dirname(path79.resolve(args.manifest)));
|
|
37515
37789
|
loadEnvFiles(process.cwd());
|
|
37516
|
-
const bytes = await readFile52(
|
|
37790
|
+
const bytes = await readFile52(path79.resolve(image));
|
|
37517
37791
|
const metadata = imageMetadata(bytes);
|
|
37518
37792
|
if (!metadata) throw new UsageError(`${image} is not a readable PNG or JPEG`);
|
|
37519
37793
|
if (args.custom) return estimateCustom(args, image, bytes, metadata);
|
|
@@ -37526,7 +37800,7 @@ async function runEstimateSkeleton(args) {
|
|
|
37526
37800
|
const frames = args.frames ?? DEFAULT_SCAFFOLD_FRAMES;
|
|
37527
37801
|
const json2 = JSON.stringify(scaffoldSkeletonSet(res.keypoints, frames), null, 2);
|
|
37528
37802
|
if (args.out) {
|
|
37529
|
-
await
|
|
37803
|
+
await writeFile33(path79.resolve(args.out), json2 + "\n");
|
|
37530
37804
|
log(` wrote ${args.out}: the estimated pose and ${frames} frames to edit`);
|
|
37531
37805
|
log(` preview it with: pixelkiln skeleton-preview ${args.out} --from ${image}`);
|
|
37532
37806
|
} else {
|
|
@@ -37561,7 +37835,7 @@ async function estimateCustom(args, image, bytes, metadata) {
|
|
|
37561
37835
|
const json2 = JSON.stringify(scaffoldSkeletonSet(res.keypoints, frames, { rig: res.rig, kind: res.kind }), null, 2);
|
|
37562
37836
|
const extra = res.rig.filter((joint) => !joint.estimate).map((joint) => joint.name);
|
|
37563
37837
|
if (args.out) {
|
|
37564
|
-
await
|
|
37838
|
+
await writeFile33(path79.resolve(args.out), json2 + "\n");
|
|
37565
37839
|
log(` wrote ${args.out}: a ${res.kind ?? "custom"} rig of ${res.rig.length} joints and ${frames} frames to edit`);
|
|
37566
37840
|
if (extra.length) log(` joints beyond the 18: ${extra.slice(0, 12).join(", ")}${extra.length > 12 ? ", \u2026" : ""}`);
|
|
37567
37841
|
log(` preview it with: pixelkiln skeleton-preview ${args.out} --from ${image}`);
|
|
@@ -37575,8 +37849,8 @@ async function runSkeletonPreview(args) {
|
|
|
37575
37849
|
let sourceFile;
|
|
37576
37850
|
let label;
|
|
37577
37851
|
if (target.endsWith(".json")) {
|
|
37578
|
-
keypointsFile =
|
|
37579
|
-
sourceFile = args.from ?
|
|
37852
|
+
keypointsFile = path79.resolve(target);
|
|
37853
|
+
sourceFile = args.from ? path79.resolve(args.from) : void 0;
|
|
37580
37854
|
label = target;
|
|
37581
37855
|
} else {
|
|
37582
37856
|
const loaded = await loadManifest(args.manifest);
|
|
@@ -37588,7 +37862,7 @@ async function runSkeletonPreview(args) {
|
|
|
37588
37862
|
);
|
|
37589
37863
|
}
|
|
37590
37864
|
keypointsFile = spec.revision.keypointsFile;
|
|
37591
|
-
sourceFile = args.from ?
|
|
37865
|
+
sourceFile = args.from ? path79.resolve(args.from) : spec.revision.sourceFile;
|
|
37592
37866
|
label = `${spec.styleId}/${spec.assetId}`;
|
|
37593
37867
|
}
|
|
37594
37868
|
if (!existsSync57(keypointsFile)) throw new UsageError(`Keypoints file does not exist yet: ${keypointsFile}`);
|
|
@@ -37609,10 +37883,10 @@ async function runSkeletonPreview(args) {
|
|
|
37609
37883
|
source = decodePng(bytes);
|
|
37610
37884
|
}
|
|
37611
37885
|
}
|
|
37612
|
-
const out =
|
|
37613
|
-
await
|
|
37886
|
+
const out = path79.resolve(args.out ?? keypointsFile.replace(/\.json$/, "") + ".preview.png");
|
|
37887
|
+
await writeFile33(out, renderSkeletonSheet(set, { source }));
|
|
37614
37888
|
log(` ${label}: ${set.frames.length} frames after the starting pose`);
|
|
37615
|
-
const shown2 =
|
|
37889
|
+
const shown2 = path79.relative(process.cwd(), out);
|
|
37616
37890
|
log(` wrote ${shown2.startsWith("..") ? out : shown2}`);
|
|
37617
37891
|
}
|
|
37618
37892
|
|
|
@@ -37658,15 +37932,15 @@ async function runTools(args) {
|
|
|
37658
37932
|
}
|
|
37659
37933
|
|
|
37660
37934
|
// src/cli/commands/workspace.ts
|
|
37661
|
-
import
|
|
37935
|
+
import path80 from "path";
|
|
37662
37936
|
import { existsSync as existsSync58 } from "fs";
|
|
37663
37937
|
async function runWorkspace(args) {
|
|
37664
|
-
const workspacePath =
|
|
37665
|
-
const dir =
|
|
37938
|
+
const workspacePath = path80.resolve(args.workspace ?? "pixelkiln.workspace.json");
|
|
37939
|
+
const dir = path80.dirname(workspacePath);
|
|
37666
37940
|
if (args.subcommand === "add") {
|
|
37667
|
-
const manifestPath =
|
|
37941
|
+
const manifestPath = path80.resolve(args.target);
|
|
37668
37942
|
const loadedTarget = await loadManifest(manifestPath);
|
|
37669
|
-
const lockPath = args.explicitLock ?
|
|
37943
|
+
const lockPath = args.explicitLock ? path80.resolve(args.explicitLock) : path80.join(path80.dirname(manifestPath), "pixelkiln.lock.json");
|
|
37670
37944
|
const ws = await loadWorkspace(workspacePath);
|
|
37671
37945
|
const id = args.name ?? loadedTarget.manifest.name;
|
|
37672
37946
|
if (ws.projects.some((p) => p.id === id)) {
|
|
@@ -37686,7 +37960,7 @@ async function runWorkspace(args) {
|
|
|
37686
37960
|
...args.account ? { account: args.account } : {}
|
|
37687
37961
|
};
|
|
37688
37962
|
await saveWorkspace(workspacePath, { version: 1, projects: [...ws.projects, project2] });
|
|
37689
|
-
log(` registered "${id}" in ${
|
|
37963
|
+
log(` registered "${id}" in ${path80.relative(process.cwd(), workspacePath)}`);
|
|
37690
37964
|
log(` manifest: ${project2.manifest}`);
|
|
37691
37965
|
log(` lock: ${project2.lock}`);
|
|
37692
37966
|
if (!existsSync58(lockPath)) {
|
|
@@ -37698,7 +37972,7 @@ async function runWorkspace(args) {
|
|
|
37698
37972
|
}
|
|
37699
37973
|
if (args.subcommand === "remove") {
|
|
37700
37974
|
const ws = await loadWorkspace(workspacePath);
|
|
37701
|
-
const resolvedTarget =
|
|
37975
|
+
const resolvedTarget = path80.resolve(args.target);
|
|
37702
37976
|
const match = ws.projects.find(
|
|
37703
37977
|
(p) => p.id === args.target || resolveProject(dir, p).manifestPath === resolvedTarget
|
|
37704
37978
|
);
|
|
@@ -37709,7 +37983,7 @@ async function runWorkspace(args) {
|
|
|
37709
37983
|
version: 1,
|
|
37710
37984
|
projects: ws.projects.filter((p) => p !== match)
|
|
37711
37985
|
});
|
|
37712
|
-
log(` removed "${match.id}" from ${
|
|
37986
|
+
log(` removed "${match.id}" from ${path80.relative(process.cwd(), workspacePath)}`);
|
|
37713
37987
|
return;
|
|
37714
37988
|
}
|
|
37715
37989
|
if (args.subcommand === "list") {
|
|
@@ -37721,9 +37995,9 @@ async function runWorkspace(args) {
|
|
|
37721
37995
|
if (args.json) {
|
|
37722
37996
|
log(JSON.stringify({ version: 1, workspace: workspacePath, projects: ws.projects, diagnostics }, null, 2));
|
|
37723
37997
|
} else if (!ws.projects.length) {
|
|
37724
|
-
log(` no projects registered in ${
|
|
37998
|
+
log(` no projects registered in ${path80.relative(process.cwd(), workspacePath)}`);
|
|
37725
37999
|
} else {
|
|
37726
|
-
log(` ${ws.projects.length} project(s) in ${
|
|
38000
|
+
log(` ${ws.projects.length} project(s) in ${path80.relative(process.cwd(), workspacePath)}:`);
|
|
37727
38001
|
for (const p of ws.projects) {
|
|
37728
38002
|
log(` ${p.id.padEnd(24)} ${p.manifest.padEnd(40)} (${p.provider}${p.account ? `, ${p.account}` : ""})`);
|
|
37729
38003
|
}
|
|
@@ -37741,7 +38015,7 @@ async function runWorkspace(args) {
|
|
|
37741
38015
|
if (args.json) {
|
|
37742
38016
|
log(JSON.stringify({ ...report, workspace: workspacePath }, null, 2));
|
|
37743
38017
|
} else {
|
|
37744
|
-
log(` workspace: ${
|
|
38018
|
+
log(` workspace: ${path80.relative(process.cwd(), workspacePath)}`);
|
|
37745
38019
|
for (const p of report.projects) {
|
|
37746
38020
|
if (p.error) {
|
|
37747
38021
|
log(`
|
|
@@ -37845,6 +38119,7 @@ var RUNNERS = {
|
|
|
37845
38119
|
"estimate-skeleton": runEstimateSkeleton,
|
|
37846
38120
|
anchors: runAnchors,
|
|
37847
38121
|
redraw: runRedraw,
|
|
38122
|
+
layer: runLayer,
|
|
37848
38123
|
"skeleton-preview": runSkeletonPreview,
|
|
37849
38124
|
unzoom: runUnzoom,
|
|
37850
38125
|
pixelate: runPixelate,
|