pixelkiln 0.148.0 → 0.148.1
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 +69 -6
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +69 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +69 -6
- package/dist/index.js.map +1 -1
- package/docs/CHARACTERS.md +13 -3
- package/docs/PAPERDOLL.md +24 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -4677,10 +4677,10 @@ function despeckle(png, options) {
|
|
|
4677
4677
|
for (const still of options.reference) {
|
|
4678
4678
|
const { pixels } = decodePng(still);
|
|
4679
4679
|
for (let i = 0; i < pixels.length; i += 4) {
|
|
4680
|
-
if (pixels[i + 3] === 0
|
|
4680
|
+
if (pixels[i + 3] === 0) continue;
|
|
4681
4681
|
const rgb = pixels[i] << 16 | pixels[i + 1] << 8 | pixels[i + 2];
|
|
4682
4682
|
palette.set(rgb, (palette.get(rgb) ?? 0) + 1);
|
|
4683
|
-
total++;
|
|
4683
|
+
if (!outline(pixels, i)) total++;
|
|
4684
4684
|
}
|
|
4685
4685
|
}
|
|
4686
4686
|
if (!total) throw new Error("the reference stills have no opaque pixels that are not outline");
|
|
@@ -4740,7 +4740,7 @@ function despeckle(png, options) {
|
|
|
4740
4740
|
const strange = run.filter(([x, y]) => foreign(at(image, x, y))).length / run.length > 0.5;
|
|
4741
4741
|
let debris;
|
|
4742
4742
|
const exposed = run.some(([x, y]) => STEPS.some(([dx, dy]) => open2(x + dx, y + dy)));
|
|
4743
|
-
if (strange &&
|
|
4743
|
+
if (strange && run.length > limb) {
|
|
4744
4744
|
debris = false;
|
|
4745
4745
|
limbs.add(index);
|
|
4746
4746
|
} else if (exposed) {
|
|
@@ -4775,6 +4775,7 @@ function despeckle(png, options) {
|
|
|
4775
4775
|
if (src[at(image, x, y) + 3] > 0 && out[at(image, x, y) + 3] === 0) frontier.push([x, y]);
|
|
4776
4776
|
}
|
|
4777
4777
|
}
|
|
4778
|
+
const seeds = frontier.length;
|
|
4778
4779
|
for (let n = 0; n < frontier.length; n++) {
|
|
4779
4780
|
const [fx, fy] = frontier[n];
|
|
4780
4781
|
for (let dy = -1; dy <= 1; dy++) {
|
|
@@ -4798,6 +4799,31 @@ function despeckle(png, options) {
|
|
|
4798
4799
|
}
|
|
4799
4800
|
}
|
|
4800
4801
|
}
|
|
4802
|
+
const chained = new Set(frontier.slice(seeds).map(([x, y]) => local(x, y)));
|
|
4803
|
+
const visited = /* @__PURE__ */ new Set();
|
|
4804
|
+
for (const [sx, sy] of frontier.slice(seeds)) {
|
|
4805
|
+
if (visited.has(local(sx, sy))) continue;
|
|
4806
|
+
const group = [[sx, sy]];
|
|
4807
|
+
visited.add(local(sx, sy));
|
|
4808
|
+
for (let n = 0; n < group.length; n++) {
|
|
4809
|
+
const [gx, gy] = group[n];
|
|
4810
|
+
for (let dy = -1; dy <= 1; dy++) {
|
|
4811
|
+
for (let dx = -1; dx <= 1; dx++) {
|
|
4812
|
+
const x = gx + dx;
|
|
4813
|
+
const y = gy + dy;
|
|
4814
|
+
if (!inside(cell, x, y) || visited.has(local(x, y)) || !chained.has(local(x, y))) continue;
|
|
4815
|
+
visited.add(local(x, y));
|
|
4816
|
+
group.push([x, y]);
|
|
4817
|
+
}
|
|
4818
|
+
}
|
|
4819
|
+
}
|
|
4820
|
+
if (group.length <= limb) continue;
|
|
4821
|
+
for (const [x, y] of group) {
|
|
4822
|
+
const i = at(image, x, y);
|
|
4823
|
+
src.copy(out, i, i, i + 4);
|
|
4824
|
+
removed--;
|
|
4825
|
+
}
|
|
4826
|
+
}
|
|
4801
4827
|
}
|
|
4802
4828
|
return { png: encodeRgbaPng(image.width, image.height, out), removed };
|
|
4803
4829
|
}
|
|
@@ -5214,10 +5240,13 @@ function applyPostprocess(bytes, mediaType, record, reference = [], role) {
|
|
|
5214
5240
|
if (mediaType !== MediaType.PNG || !record?.palette && !record?.despeckle && !record?.offset) return { bytes, changed: false };
|
|
5215
5241
|
let out = bytes;
|
|
5216
5242
|
let removed = 0;
|
|
5243
|
+
let opaque2 = 0;
|
|
5217
5244
|
if (record.despeckle) {
|
|
5218
5245
|
if (!reference.length) throw new Error(`cleaning needs the rotations of ${record.despeckle.of}, and none were given`);
|
|
5219
5246
|
const cleaned = despeckle(out, { reference });
|
|
5220
5247
|
if (cleaned.removed) {
|
|
5248
|
+
const { pixels } = decodePng(out);
|
|
5249
|
+
for (let i = 3; i < pixels.length; i += 4) if (pixels[i] > 0) opaque2++;
|
|
5221
5250
|
out = cleaned.png;
|
|
5222
5251
|
removed = cleaned.removed;
|
|
5223
5252
|
}
|
|
@@ -5241,8 +5270,9 @@ function applyPostprocess(bytes, mediaType, record, reference = [], role) {
|
|
|
5241
5270
|
}
|
|
5242
5271
|
}
|
|
5243
5272
|
if (!removed && !snapped && !moved) return { bytes, changed: false };
|
|
5244
|
-
return { bytes: out, changed: true, ...removed ? { removed } : {}, ...snapped ? { snapped } : {}, ...moved ? { moved } : {} };
|
|
5273
|
+
return { bytes: out, changed: true, ...removed ? { removed, opaque: opaque2 } : {}, ...snapped ? { snapped } : {}, ...moved ? { moved } : {} };
|
|
5245
5274
|
}
|
|
5275
|
+
var CLEAN_DAMAGE_SHARE = 0.03;
|
|
5246
5276
|
|
|
5247
5277
|
// src/pipeline/mirror.ts
|
|
5248
5278
|
function mirrorSourceHash(source) {
|
|
@@ -7592,10 +7622,15 @@ async function buildPlan(specs, lock, opts = {}) {
|
|
|
7592
7622
|
} else if (spec.mirror && entry.status === "downloaded" && entry.outputs.some((_output, index) => !existsSync7(currentEntryOutputPath(entry, spec, index)))) {
|
|
7593
7623
|
state = "stale";
|
|
7594
7624
|
reason = "mirror output missing on disk; flip it again (no generation cost)";
|
|
7595
|
-
} else if (
|
|
7625
|
+
} else if (
|
|
7626
|
+
// A mirror carries its source's character shape, but it is a flip of
|
|
7627
|
+
// the source's files: whether it is current is the check above, never
|
|
7628
|
+
// the outfit or layer rule its source answers to (#418).
|
|
7629
|
+
!spec.mirror && spec.character?.kind === "outfit" && entry.outfit?.sourceSha256 !== mirrorSourceHash(lock.entries[lockKey(spec.styleId, spec.character.parentAssetId)] ?? { outputs: [] })
|
|
7630
|
+
) {
|
|
7596
7631
|
state = "stale";
|
|
7597
7632
|
reason = `outfit source ${spec.character.parentAssetId} changed; re-clothe the loop again`;
|
|
7598
|
-
} else if (spec.character?.kind === "layer" && changedLayerSource(spec, entry, lock)) {
|
|
7633
|
+
} else if (!spec.mirror && spec.character?.kind === "layer" && changedLayerSource(spec, entry, lock)) {
|
|
7599
7634
|
state = "stale";
|
|
7600
7635
|
reason = isHeldItem(spec) ? `layer source ${changedLayerSource(spec, entry, lock)} changed; place the item again (no generation cost)` : `layer source ${changedLayerSource(spec, entry, lock)} changed; dress the frames again`;
|
|
7601
7636
|
} else if (isHeldItem(spec) && entry.status === "downloaded" && entry.outputs.some((_output, index) => !existsSync7(currentEntryOutputPath(entry, spec, index)))) {
|
|
@@ -7663,6 +7698,7 @@ async function buildPlan(specs, lock, opts = {}) {
|
|
|
7663
7698
|
}
|
|
7664
7699
|
const isActionable = (i) => i.state === "missing" || i.state === "stale" || i.state === "failed";
|
|
7665
7700
|
const stateOf = new Map(items.map((i) => [i.key, i.state]));
|
|
7701
|
+
const waiting = /* @__PURE__ */ new Set();
|
|
7666
7702
|
for (const item of items) {
|
|
7667
7703
|
if (!isActionable(item)) continue;
|
|
7668
7704
|
for (const parent of dependencies(item.spec)) {
|
|
@@ -7671,11 +7707,35 @@ async function buildPlan(specs, lock, opts = {}) {
|
|
|
7671
7707
|
if (parentState && isActionable({ state: parentState })) {
|
|
7672
7708
|
item.state = "blocked";
|
|
7673
7709
|
item.reason = `parent ${parentKey} is being generated in this run; this follows in the next wave`;
|
|
7710
|
+
waiting.add(item.key);
|
|
7674
7711
|
break;
|
|
7675
7712
|
}
|
|
7676
7713
|
if ((item.spec.mirror || item.spec.derive || isHeldItem(item.spec)) && (parentState === "recoverable" || parentState === "in-flight")) {
|
|
7677
7714
|
item.state = "blocked";
|
|
7678
7715
|
item.reason = `mirror source ${parentKey} is ${parentState}; this follows in the next wave`;
|
|
7716
|
+
waiting.add(item.key);
|
|
7717
|
+
break;
|
|
7718
|
+
}
|
|
7719
|
+
}
|
|
7720
|
+
}
|
|
7721
|
+
const byKey = new Map(items.map((i) => [i.key, i]));
|
|
7722
|
+
for (let changed = true; changed; ) {
|
|
7723
|
+
changed = false;
|
|
7724
|
+
for (const item of items) {
|
|
7725
|
+
if (item.state !== "blocked" || waiting.has(item.key)) continue;
|
|
7726
|
+
for (const parent of dependencies(item.spec)) {
|
|
7727
|
+
const parentKey = lockKey(parent.styleId, parent.assetId);
|
|
7728
|
+
const parentItem = byKey.get(parentKey);
|
|
7729
|
+
if (!parentItem || !item.reason.includes(`${parentKey} is not ready`)) continue;
|
|
7730
|
+
if (isActionable(parentItem)) {
|
|
7731
|
+
item.reason = `waits for ${parentKey}, which this run generates first; follows in a later wave (${item.reason})`;
|
|
7732
|
+
} else if (waiting.has(parentKey)) {
|
|
7733
|
+
item.reason = `waits for ${parentKey}, which itself follows in a later wave of this run (${item.reason})`;
|
|
7734
|
+
} else {
|
|
7735
|
+
continue;
|
|
7736
|
+
}
|
|
7737
|
+
waiting.add(item.key);
|
|
7738
|
+
changed = true;
|
|
7679
7739
|
break;
|
|
7680
7740
|
}
|
|
7681
7741
|
}
|
|
@@ -18479,6 +18539,9 @@ async function fetchAssets(provider, specs, lock, lockPath, opts = {}) {
|
|
|
18479
18539
|
if (processed.changed) rawHash = sha256(raw);
|
|
18480
18540
|
if (processed.moved?.clipped) log2(` moved ${path20.relative(process.cwd(), target)}: ${processed.moved.clipped} pixels fell off the canvas; raise layer.padding to keep them`);
|
|
18481
18541
|
if (processed.removed) log2(` cleaned ${path20.relative(process.cwd(), target)} (${processed.removed} ghost pixels)`);
|
|
18542
|
+
if (processed.removed && processed.opaque && processed.removed > processed.opaque * CLEAN_DAMAGE_SHARE) {
|
|
18543
|
+
log2(` warning: cleaning took ${processed.removed} of ${processed.opaque} opaque pixels (${(100 * processed.removed / processed.opaque).toFixed(1)}%) from ${path20.relative(process.cwd(), target)}; check the frame for holes, and set clean: false then fetch to restore the provider's bytes`);
|
|
18544
|
+
}
|
|
18482
18545
|
if (processed.snapped) log2(` snapped ${path20.relative(process.cwd(), target)} to ${wanted.palette.colors.length} colours`);
|
|
18483
18546
|
}
|
|
18484
18547
|
if (cacheDir) await cacheMedia(cacheDir, buf, mediaType);
|