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/index.js
CHANGED
|
@@ -6855,10 +6855,10 @@ function despeckle(png, options) {
|
|
|
6855
6855
|
for (const still of options.reference) {
|
|
6856
6856
|
const { pixels } = decodePng(still);
|
|
6857
6857
|
for (let i = 0; i < pixels.length; i += 4) {
|
|
6858
|
-
if (pixels[i + 3] === 0
|
|
6858
|
+
if (pixels[i + 3] === 0) continue;
|
|
6859
6859
|
const rgb = pixels[i] << 16 | pixels[i + 1] << 8 | pixels[i + 2];
|
|
6860
6860
|
palette.set(rgb, (palette.get(rgb) ?? 0) + 1);
|
|
6861
|
-
total++;
|
|
6861
|
+
if (!outline(pixels, i)) total++;
|
|
6862
6862
|
}
|
|
6863
6863
|
}
|
|
6864
6864
|
if (!total) throw new Error("the reference stills have no opaque pixels that are not outline");
|
|
@@ -6918,7 +6918,7 @@ function despeckle(png, options) {
|
|
|
6918
6918
|
const strange = run.filter(([x, y]) => foreign(at(image, x, y))).length / run.length > 0.5;
|
|
6919
6919
|
let debris;
|
|
6920
6920
|
const exposed = run.some(([x, y]) => STEPS.some(([dx, dy]) => open(x + dx, y + dy)));
|
|
6921
|
-
if (strange &&
|
|
6921
|
+
if (strange && run.length > limb) {
|
|
6922
6922
|
debris = false;
|
|
6923
6923
|
limbs.add(index);
|
|
6924
6924
|
} else if (exposed) {
|
|
@@ -6953,6 +6953,7 @@ function despeckle(png, options) {
|
|
|
6953
6953
|
if (src[at(image, x, y) + 3] > 0 && out[at(image, x, y) + 3] === 0) frontier.push([x, y]);
|
|
6954
6954
|
}
|
|
6955
6955
|
}
|
|
6956
|
+
const seeds = frontier.length;
|
|
6956
6957
|
for (let n = 0; n < frontier.length; n++) {
|
|
6957
6958
|
const [fx, fy] = frontier[n];
|
|
6958
6959
|
for (let dy = -1; dy <= 1; dy++) {
|
|
@@ -6976,6 +6977,31 @@ function despeckle(png, options) {
|
|
|
6976
6977
|
}
|
|
6977
6978
|
}
|
|
6978
6979
|
}
|
|
6980
|
+
const chained = new Set(frontier.slice(seeds).map(([x, y]) => local(x, y)));
|
|
6981
|
+
const visited = /* @__PURE__ */ new Set();
|
|
6982
|
+
for (const [sx, sy] of frontier.slice(seeds)) {
|
|
6983
|
+
if (visited.has(local(sx, sy))) continue;
|
|
6984
|
+
const group = [[sx, sy]];
|
|
6985
|
+
visited.add(local(sx, sy));
|
|
6986
|
+
for (let n = 0; n < group.length; n++) {
|
|
6987
|
+
const [gx, gy] = group[n];
|
|
6988
|
+
for (let dy = -1; dy <= 1; dy++) {
|
|
6989
|
+
for (let dx = -1; dx <= 1; dx++) {
|
|
6990
|
+
const x = gx + dx;
|
|
6991
|
+
const y = gy + dy;
|
|
6992
|
+
if (!inside(cell, x, y) || visited.has(local(x, y)) || !chained.has(local(x, y))) continue;
|
|
6993
|
+
visited.add(local(x, y));
|
|
6994
|
+
group.push([x, y]);
|
|
6995
|
+
}
|
|
6996
|
+
}
|
|
6997
|
+
}
|
|
6998
|
+
if (group.length <= limb) continue;
|
|
6999
|
+
for (const [x, y] of group) {
|
|
7000
|
+
const i = at(image, x, y);
|
|
7001
|
+
src.copy(out, i, i, i + 4);
|
|
7002
|
+
removed--;
|
|
7003
|
+
}
|
|
7004
|
+
}
|
|
6979
7005
|
}
|
|
6980
7006
|
return { png: encodeRgbaPng(image.width, image.height, out), removed };
|
|
6981
7007
|
}
|
|
@@ -7779,10 +7805,13 @@ function applyPostprocess(bytes, mediaType, record, reference = [], role) {
|
|
|
7779
7805
|
if (mediaType !== MediaType.PNG || !record?.palette && !record?.despeckle && !record?.offset) return { bytes, changed: false };
|
|
7780
7806
|
let out = bytes;
|
|
7781
7807
|
let removed = 0;
|
|
7808
|
+
let opaque2 = 0;
|
|
7782
7809
|
if (record.despeckle) {
|
|
7783
7810
|
if (!reference.length) throw new Error(`cleaning needs the rotations of ${record.despeckle.of}, and none were given`);
|
|
7784
7811
|
const cleaned = despeckle(out, { reference });
|
|
7785
7812
|
if (cleaned.removed) {
|
|
7813
|
+
const { pixels } = decodePng(out);
|
|
7814
|
+
for (let i = 3; i < pixels.length; i += 4) if (pixels[i] > 0) opaque2++;
|
|
7786
7815
|
out = cleaned.png;
|
|
7787
7816
|
removed = cleaned.removed;
|
|
7788
7817
|
}
|
|
@@ -7806,8 +7835,9 @@ function applyPostprocess(bytes, mediaType, record, reference = [], role) {
|
|
|
7806
7835
|
}
|
|
7807
7836
|
}
|
|
7808
7837
|
if (!removed && !snapped && !moved) return { bytes, changed: false };
|
|
7809
|
-
return { bytes: out, changed: true, ...removed ? { removed } : {}, ...snapped ? { snapped } : {}, ...moved ? { moved } : {} };
|
|
7838
|
+
return { bytes: out, changed: true, ...removed ? { removed, opaque: opaque2 } : {}, ...snapped ? { snapped } : {}, ...moved ? { moved } : {} };
|
|
7810
7839
|
}
|
|
7840
|
+
var CLEAN_DAMAGE_SHARE = 0.03;
|
|
7811
7841
|
|
|
7812
7842
|
// src/pipeline/mirror.ts
|
|
7813
7843
|
function mirrorSourceHash(source) {
|
|
@@ -17072,10 +17102,15 @@ async function buildPlan(specs, lock, opts = {}) {
|
|
|
17072
17102
|
} else if (spec.mirror && entry.status === "downloaded" && entry.outputs.some((_output, index) => !existsSync14(currentEntryOutputPath(entry, spec, index)))) {
|
|
17073
17103
|
state = "stale";
|
|
17074
17104
|
reason = "mirror output missing on disk; flip it again (no generation cost)";
|
|
17075
|
-
} else if (
|
|
17105
|
+
} else if (
|
|
17106
|
+
// A mirror carries its source's character shape, but it is a flip of
|
|
17107
|
+
// the source's files: whether it is current is the check above, never
|
|
17108
|
+
// the outfit or layer rule its source answers to (#418).
|
|
17109
|
+
!spec.mirror && spec.character?.kind === "outfit" && entry.outfit?.sourceSha256 !== mirrorSourceHash(lock.entries[lockKey(spec.styleId, spec.character.parentAssetId)] ?? { outputs: [] })
|
|
17110
|
+
) {
|
|
17076
17111
|
state = "stale";
|
|
17077
17112
|
reason = `outfit source ${spec.character.parentAssetId} changed; re-clothe the loop again`;
|
|
17078
|
-
} else if (spec.character?.kind === "layer" && changedLayerSource(spec, entry, lock)) {
|
|
17113
|
+
} else if (!spec.mirror && spec.character?.kind === "layer" && changedLayerSource(spec, entry, lock)) {
|
|
17079
17114
|
state = "stale";
|
|
17080
17115
|
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`;
|
|
17081
17116
|
} else if (isHeldItem(spec) && entry.status === "downloaded" && entry.outputs.some((_output, index) => !existsSync14(currentEntryOutputPath(entry, spec, index)))) {
|
|
@@ -17143,6 +17178,7 @@ async function buildPlan(specs, lock, opts = {}) {
|
|
|
17143
17178
|
}
|
|
17144
17179
|
const isActionable = (i) => i.state === "missing" || i.state === "stale" || i.state === "failed";
|
|
17145
17180
|
const stateOf = new Map(items.map((i) => [i.key, i.state]));
|
|
17181
|
+
const waiting = /* @__PURE__ */ new Set();
|
|
17146
17182
|
for (const item of items) {
|
|
17147
17183
|
if (!isActionable(item)) continue;
|
|
17148
17184
|
for (const parent of dependencies(item.spec)) {
|
|
@@ -17151,11 +17187,35 @@ async function buildPlan(specs, lock, opts = {}) {
|
|
|
17151
17187
|
if (parentState && isActionable({ state: parentState })) {
|
|
17152
17188
|
item.state = "blocked";
|
|
17153
17189
|
item.reason = `parent ${parentKey} is being generated in this run; this follows in the next wave`;
|
|
17190
|
+
waiting.add(item.key);
|
|
17154
17191
|
break;
|
|
17155
17192
|
}
|
|
17156
17193
|
if ((item.spec.mirror || item.spec.derive || isHeldItem(item.spec)) && (parentState === "recoverable" || parentState === "in-flight")) {
|
|
17157
17194
|
item.state = "blocked";
|
|
17158
17195
|
item.reason = `mirror source ${parentKey} is ${parentState}; this follows in the next wave`;
|
|
17196
|
+
waiting.add(item.key);
|
|
17197
|
+
break;
|
|
17198
|
+
}
|
|
17199
|
+
}
|
|
17200
|
+
}
|
|
17201
|
+
const byKey = new Map(items.map((i) => [i.key, i]));
|
|
17202
|
+
for (let changed = true; changed; ) {
|
|
17203
|
+
changed = false;
|
|
17204
|
+
for (const item of items) {
|
|
17205
|
+
if (item.state !== "blocked" || waiting.has(item.key)) continue;
|
|
17206
|
+
for (const parent of dependencies(item.spec)) {
|
|
17207
|
+
const parentKey = lockKey(parent.styleId, parent.assetId);
|
|
17208
|
+
const parentItem = byKey.get(parentKey);
|
|
17209
|
+
if (!parentItem || !item.reason.includes(`${parentKey} is not ready`)) continue;
|
|
17210
|
+
if (isActionable(parentItem)) {
|
|
17211
|
+
item.reason = `waits for ${parentKey}, which this run generates first; follows in a later wave (${item.reason})`;
|
|
17212
|
+
} else if (waiting.has(parentKey)) {
|
|
17213
|
+
item.reason = `waits for ${parentKey}, which itself follows in a later wave of this run (${item.reason})`;
|
|
17214
|
+
} else {
|
|
17215
|
+
continue;
|
|
17216
|
+
}
|
|
17217
|
+
waiting.add(item.key);
|
|
17218
|
+
changed = true;
|
|
17159
17219
|
break;
|
|
17160
17220
|
}
|
|
17161
17221
|
}
|
|
@@ -19872,6 +19932,9 @@ async function fetchAssets(provider, specs, lock, lockPath, opts = {}) {
|
|
|
19872
19932
|
if (processed.changed) rawHash = sha256(raw);
|
|
19873
19933
|
if (processed.moved?.clipped) log(` moved ${path29.relative(process.cwd(), target)}: ${processed.moved.clipped} pixels fell off the canvas; raise layer.padding to keep them`);
|
|
19874
19934
|
if (processed.removed) log(` cleaned ${path29.relative(process.cwd(), target)} (${processed.removed} ghost pixels)`);
|
|
19935
|
+
if (processed.removed && processed.opaque && processed.removed > processed.opaque * CLEAN_DAMAGE_SHARE) {
|
|
19936
|
+
log(` warning: cleaning took ${processed.removed} of ${processed.opaque} opaque pixels (${(100 * processed.removed / processed.opaque).toFixed(1)}%) from ${path29.relative(process.cwd(), target)}; check the frame for holes, and set clean: false then fetch to restore the provider's bytes`);
|
|
19937
|
+
}
|
|
19875
19938
|
if (processed.snapped) log(` snapped ${path29.relative(process.cwd(), target)} to ${wanted.palette.colors.length} colours`);
|
|
19876
19939
|
}
|
|
19877
19940
|
if (cacheDir) await cacheMedia(cacheDir, buf, mediaType);
|