pixelkiln 0.113.0 → 0.115.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 +840 -514
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +696 -435
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +49 -1
- package/dist/index.d.ts +49 -1
- package/dist/index.js +690 -432
- package/dist/index.js.map +1 -1
- package/docs/CLI.md +2 -0
- package/docs/TILES.md +53 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -284,24 +284,24 @@ var AssetVfxSchema = z.object({
|
|
|
284
284
|
spriteFrames: z.number().int().min(1).max(32).optional(),
|
|
285
285
|
spriteFps: z.number().int().min(1).max(60).optional()
|
|
286
286
|
}).strict().superRefine((vfx, context) => {
|
|
287
|
-
for (const
|
|
288
|
-
if (vfx[
|
|
287
|
+
for (const key3 of ["spriteFrames", "spriteFps"]) {
|
|
288
|
+
if (vfx[key3] === void 0) continue;
|
|
289
289
|
if (vfx.description === void 0) {
|
|
290
|
-
context.addIssue({ code: z.ZodIssueCode.custom, message: `${
|
|
290
|
+
context.addIssue({ code: z.ZodIssueCode.custom, message: `${key3} describes the sprite sent to PixelLab's VFX artist; add a description`, path: [key3] });
|
|
291
291
|
} else if (!vfx.sprite) {
|
|
292
|
-
context.addIssue({ code: z.ZodIssueCode.custom, message: `${
|
|
292
|
+
context.addIssue({ code: z.ZodIssueCode.custom, message: `${key3} describes a sprite strip; add a sprite`, path: [key3] });
|
|
293
293
|
}
|
|
294
294
|
}
|
|
295
295
|
if (vfx.spriteFps !== void 0 && vfx.sprite && vfx.description !== void 0 && (vfx.spriteFrames ?? 1) < 2) {
|
|
296
296
|
context.addIssue({ code: z.ZodIssueCode.custom, message: "spriteFps is the speed of a sprite strip; set spriteFrames to 2 or more", path: ["spriteFps"] });
|
|
297
297
|
}
|
|
298
298
|
if (vfx.description !== void 0) {
|
|
299
|
-
for (const
|
|
300
|
-
if (vfx[
|
|
299
|
+
for (const key3 of ["preset", "recipe", "parts", "fps"]) {
|
|
300
|
+
if (vfx[key3] !== void 0) {
|
|
301
301
|
context.addIssue({
|
|
302
302
|
code: z.ZodIssueCode.custom,
|
|
303
|
-
message: `a vfx description goes to PixelLab's VFX artist, which takes no ${
|
|
304
|
-
path: [
|
|
303
|
+
message: `a vfx description goes to PixelLab's VFX artist, which takes no ${key3}; use a description or the workbench's preset/recipe/parts/fps, not both`,
|
|
304
|
+
path: [key3]
|
|
305
305
|
});
|
|
306
306
|
}
|
|
307
307
|
}
|
|
@@ -549,18 +549,18 @@ var CharacterAnimationSchema = z.object({
|
|
|
549
549
|
context.addIssue({ code: z.ZodIssueCode.custom, message: "a skeleton-v3 loop from a sentence takes 3 to 15 frames", path: ["frames"] });
|
|
550
550
|
}
|
|
551
551
|
const mode2 = animation.mode ?? (animation.template ? "template" : "v3");
|
|
552
|
-
for (const
|
|
553
|
-
if (animation[
|
|
552
|
+
for (const key3 of ["startFrame", "endFrame", "enhancePrompt"]) {
|
|
553
|
+
if (animation[key3] !== void 0 && mode2 !== "v3") {
|
|
554
554
|
context.addIssue({
|
|
555
555
|
code: z.ZodIssueCode.custom,
|
|
556
|
-
message: `${
|
|
557
|
-
path: [
|
|
556
|
+
message: `${key3} is for v3 loops; a ${mode2} loop ${mode2 === "template" || mode2 === "skeleton-v3" ? `starts from the character's rotation and ${animation.template ? "follows its template" : "animates its sentence"}` : "takes neither"}`,
|
|
557
|
+
path: [key3]
|
|
558
558
|
});
|
|
559
559
|
}
|
|
560
560
|
}
|
|
561
|
-
for (const
|
|
562
|
-
if (animation[
|
|
563
|
-
context.addIssue({ code: z.ZodIssueCode.custom, message: `${
|
|
561
|
+
for (const key3 of ["outline", "shading", "detail"]) {
|
|
562
|
+
if (animation[key3] !== void 0 && mode2 !== "template") {
|
|
563
|
+
context.addIssue({ code: z.ZodIssueCode.custom, message: `${key3} overrides apply to template loops only`, path: [key3] });
|
|
564
564
|
}
|
|
565
565
|
}
|
|
566
566
|
if (animation.template && animation.mode && animation.mode !== "template" && animation.mode !== "skeleton-v3") {
|
|
@@ -4422,13 +4422,13 @@ var PixelLabClient = class {
|
|
|
4422
4422
|
}
|
|
4423
4423
|
};
|
|
4424
4424
|
function clientFromEnv() {
|
|
4425
|
-
const
|
|
4426
|
-
if (!
|
|
4425
|
+
const key3 = process.env.PIXELLAB_API_KEY;
|
|
4426
|
+
if (!key3) {
|
|
4427
4427
|
throw new Error(
|
|
4428
4428
|
"PIXELLAB_API_KEY is not set.\nLooked in the environment, and in .env.local / .env beside the manifest and in the current directory."
|
|
4429
4429
|
);
|
|
4430
4430
|
}
|
|
4431
|
-
return new PixelLabClient(
|
|
4431
|
+
return new PixelLabClient(key3);
|
|
4432
4432
|
}
|
|
4433
4433
|
|
|
4434
4434
|
// src/open.ts
|
|
@@ -4768,14 +4768,14 @@ function extractPalette(png, topN = 8, alphaThreshold = 128) {
|
|
|
4768
4768
|
const alpha = png.pixels[i + 3];
|
|
4769
4769
|
if (alpha < alphaThreshold) continue;
|
|
4770
4770
|
opaque2++;
|
|
4771
|
-
const
|
|
4772
|
-
counts.set(
|
|
4771
|
+
const key3 = png.pixels[i] << 16 | png.pixels[i + 1] << 8 | png.pixels[i + 2];
|
|
4772
|
+
counts.set(key3, (counts.get(key3) ?? 0) + 1);
|
|
4773
4773
|
}
|
|
4774
4774
|
if (opaque2 === 0) return [];
|
|
4775
|
-
return [...counts.entries()].sort((a, b) => b[1] - a[1]).slice(0, topN).map(([
|
|
4776
|
-
r:
|
|
4777
|
-
g:
|
|
4778
|
-
b:
|
|
4775
|
+
return [...counts.entries()].sort((a, b) => b[1] - a[1]).slice(0, topN).map(([key3, n]) => ({
|
|
4776
|
+
r: key3 >> 16 & 255,
|
|
4777
|
+
g: key3 >> 8 & 255,
|
|
4778
|
+
b: key3 & 255,
|
|
4779
4779
|
weight: n / opaque2
|
|
4780
4780
|
}));
|
|
4781
4781
|
}
|
|
@@ -5404,13 +5404,13 @@ var PixelLabMcpClient = class {
|
|
|
5404
5404
|
}
|
|
5405
5405
|
};
|
|
5406
5406
|
function mcpClientFromEnv() {
|
|
5407
|
-
const
|
|
5408
|
-
if (!
|
|
5407
|
+
const key3 = process.env.PIXELLAB_API_KEY;
|
|
5408
|
+
if (!key3) {
|
|
5409
5409
|
throw new Error(
|
|
5410
5410
|
"PIXELLAB_API_KEY is not set.\nLooked in the environment, and in .env.local / .env beside the manifest and in the current directory."
|
|
5411
5411
|
);
|
|
5412
5412
|
}
|
|
5413
|
-
return new PixelLabMcpClient(
|
|
5413
|
+
return new PixelLabMcpClient(key3);
|
|
5414
5414
|
}
|
|
5415
5415
|
|
|
5416
5416
|
// src/pixellab-vfx.ts
|
|
@@ -5731,27 +5731,27 @@ function vfxArtistFiles(raw) {
|
|
|
5731
5731
|
const urlOf = (value) => {
|
|
5732
5732
|
if (typeof value === "string") return /^https?:\/\//i.test(value) ? value : null;
|
|
5733
5733
|
if (!value || typeof value !== "object") return null;
|
|
5734
|
-
for (const
|
|
5735
|
-
const url = value[
|
|
5734
|
+
for (const key3 of ["url", "download_url", "href"]) {
|
|
5735
|
+
const url = value[key3];
|
|
5736
5736
|
if (typeof url === "string" && /^https?:\/\//i.test(url)) return url;
|
|
5737
5737
|
}
|
|
5738
5738
|
return null;
|
|
5739
5739
|
};
|
|
5740
|
-
const nameOf = (value, url,
|
|
5740
|
+
const nameOf = (value, url, key3) => {
|
|
5741
5741
|
if (value && typeof value === "object") {
|
|
5742
5742
|
for (const field of ["name", "filename", "file"]) {
|
|
5743
5743
|
const name = value[field];
|
|
5744
5744
|
if (typeof name === "string" && name) return name;
|
|
5745
5745
|
}
|
|
5746
5746
|
}
|
|
5747
|
-
if (
|
|
5747
|
+
if (key3 && /\.[a-z0-9]+$/i.test(key3)) return key3;
|
|
5748
5748
|
return decodeURIComponent(new URL(url).pathname.split("/").pop() ?? "");
|
|
5749
5749
|
};
|
|
5750
5750
|
const entries = Array.isArray(raw) ? raw.map((value) => [void 0, value]) : raw && typeof raw === "object" ? Object.entries(raw) : [];
|
|
5751
5751
|
const files = [];
|
|
5752
|
-
for (const [
|
|
5752
|
+
for (const [key3, value] of entries) {
|
|
5753
5753
|
const url = urlOf(value);
|
|
5754
|
-
if (url) files.push({ name: nameOf(value, url,
|
|
5754
|
+
if (url) files.push({ name: nameOf(value, url, key3), url });
|
|
5755
5755
|
}
|
|
5756
5756
|
return files;
|
|
5757
5757
|
}
|
|
@@ -5854,14 +5854,14 @@ async function makeVfxWithArtist(client2, opts) {
|
|
|
5854
5854
|
`);
|
|
5855
5855
|
written.atlas = paths.atlas;
|
|
5856
5856
|
}
|
|
5857
|
-
for (const [file, target,
|
|
5857
|
+
for (const [file, target, key3] of [
|
|
5858
5858
|
[result.gif, paths.gif, "gif"],
|
|
5859
5859
|
[result.gamePack, paths.gamePack, "gamePack"],
|
|
5860
5860
|
[result.normals, paths.normals, "normals"]
|
|
5861
5861
|
]) {
|
|
5862
5862
|
if (!file) continue;
|
|
5863
5863
|
await writeFile(target, await client2.download(file.url));
|
|
5864
|
-
written[
|
|
5864
|
+
written[key3] = target;
|
|
5865
5865
|
}
|
|
5866
5866
|
const facts = vfxArtistFrameFacts(result, atlas);
|
|
5867
5867
|
const usage = job.usage ?? null;
|
|
@@ -5887,7 +5887,7 @@ async function makeVfxWithArtist(client2, opts) {
|
|
|
5887
5887
|
anchor: result.anchor,
|
|
5888
5888
|
parts: result.parts,
|
|
5889
5889
|
files: Object.fromEntries(
|
|
5890
|
-
["sheet", "gif", "atlas", "gamePack", "normals"].filter((
|
|
5890
|
+
["sheet", "gif", "atlas", "gamePack", "normals"].filter((key3) => written[key3]).map((key3) => [key3, path.basename(written[key3])])
|
|
5891
5891
|
),
|
|
5892
5892
|
quotedGenerations: submitted.quoted_generations ?? null,
|
|
5893
5893
|
usage,
|
|
@@ -5912,8 +5912,8 @@ async function makeVfxWithArtist(client2, opts) {
|
|
|
5912
5912
|
};
|
|
5913
5913
|
}
|
|
5914
5914
|
function vfxJobFailure(done) {
|
|
5915
|
-
for (const
|
|
5916
|
-
const value = done?.[
|
|
5915
|
+
for (const key3 of ["error", "detail", "message"]) {
|
|
5916
|
+
const value = done?.[key3];
|
|
5917
5917
|
if (typeof value === "string" && value) return `: ${value}`;
|
|
5918
5918
|
}
|
|
5919
5919
|
return "";
|
|
@@ -5948,8 +5948,8 @@ function isSensitiveSourceUrl(value) {
|
|
|
5948
5948
|
return false;
|
|
5949
5949
|
}
|
|
5950
5950
|
if (parsed.username || parsed.password) return true;
|
|
5951
|
-
for (const
|
|
5952
|
-
const normalized =
|
|
5951
|
+
for (const key3 of parsed.searchParams.keys()) {
|
|
5952
|
+
const normalized = key3.toLowerCase();
|
|
5953
5953
|
if (SENSITIVE_QUERY_KEYS.has(normalized) || normalized.includes("credential") || normalized.includes("signature") || normalized.includes("security-token") || normalized.includes("token")) return true;
|
|
5954
5954
|
}
|
|
5955
5955
|
return false;
|
|
@@ -6407,7 +6407,7 @@ var DEFAULT_KEY = "#00ffff";
|
|
|
6407
6407
|
var KEY_SATURATION = 0.85;
|
|
6408
6408
|
function keySkin(png, options = {}) {
|
|
6409
6409
|
const image = decodePng(png);
|
|
6410
|
-
const
|
|
6410
|
+
const key3 = parseHex(options.key ?? DEFAULT_KEY);
|
|
6411
6411
|
const skin = options.skin?.map((hex2) => parseHex(hex2));
|
|
6412
6412
|
const reach = (options.tolerance ?? 0) ** 2;
|
|
6413
6413
|
const outlineBelow = options.outlineBelow ?? 46;
|
|
@@ -6422,14 +6422,14 @@ function keySkin(png, options = {}) {
|
|
|
6422
6422
|
if (!skin.some((c) => (c.r - r) ** 2 + (c.g - g) ** 2 + (c.b - b) ** 2 <= reach)) continue;
|
|
6423
6423
|
} else if (brightest < outlineBelow) continue;
|
|
6424
6424
|
const tint = (channel) => Math.floor(brightest * (1 - KEY_SATURATION + KEY_SATURATION * channel / 255));
|
|
6425
|
-
out[i] = tint(
|
|
6426
|
-
out[i + 1] = tint(
|
|
6427
|
-
out[i + 2] = tint(
|
|
6425
|
+
out[i] = tint(key3.r);
|
|
6426
|
+
out[i + 1] = tint(key3.g);
|
|
6427
|
+
out[i + 2] = tint(key3.b);
|
|
6428
6428
|
}
|
|
6429
6429
|
return encodeRgbaPng(image.width, image.height, out);
|
|
6430
6430
|
}
|
|
6431
|
-
function isKeyColor(r, g, b,
|
|
6432
|
-
const target = parseHex(
|
|
6431
|
+
function isKeyColor(r, g, b, key3 = DEFAULT_KEY) {
|
|
6432
|
+
const target = parseHex(key3);
|
|
6433
6433
|
const want = hsv(target.r, target.g, target.b).h;
|
|
6434
6434
|
const { h, s, v } = hsv(r, g, b);
|
|
6435
6435
|
const apart = Math.abs(h - want);
|
|
@@ -7032,22 +7032,22 @@ async function writeLockWhileHeld(file, lock) {
|
|
|
7032
7032
|
}
|
|
7033
7033
|
const dirty = dirtyPatches.get(lock) ?? /* @__PURE__ */ new Map();
|
|
7034
7034
|
const snapshot = /* @__PURE__ */ new Map();
|
|
7035
|
-
for (const [
|
|
7035
|
+
for (const [key3, patch] of dirty) snapshot.set(key3, { ...patch });
|
|
7036
7036
|
const merged = { ...disk.entries };
|
|
7037
|
-
for (const [
|
|
7038
|
-
const local = lock.entries[
|
|
7037
|
+
for (const [key3, patch] of snapshot) {
|
|
7038
|
+
const local = lock.entries[key3];
|
|
7039
7039
|
if (!local) continue;
|
|
7040
|
-
merged[
|
|
7040
|
+
merged[key3] = merged[key3] ? { ...merged[key3], ...patch } : local;
|
|
7041
7041
|
}
|
|
7042
|
-
for (const [
|
|
7043
|
-
if (!merged[
|
|
7042
|
+
for (const [key3, entry] of Object.entries(lock.entries)) {
|
|
7043
|
+
if (!merged[key3]) merged[key3] = entry;
|
|
7044
7044
|
}
|
|
7045
7045
|
const deletes = dirtyDeletes.get(lock);
|
|
7046
7046
|
const deleteSnapshot = deletes ? new Set(deletes) : /* @__PURE__ */ new Set();
|
|
7047
|
-
for (const
|
|
7047
|
+
for (const key3 of deleteSnapshot) delete merged[key3];
|
|
7048
7048
|
const sorted = {};
|
|
7049
|
-
for (const
|
|
7050
|
-
sorted[
|
|
7049
|
+
for (const key3 of Object.keys(merged).sort()) {
|
|
7050
|
+
sorted[key3] = merged[key3];
|
|
7051
7051
|
}
|
|
7052
7052
|
const tmp = `${file}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
|
|
7053
7053
|
try {
|
|
@@ -7058,48 +7058,48 @@ async function writeLockWhileHeld(file, lock) {
|
|
|
7058
7058
|
}
|
|
7059
7059
|
const currentDirty = dirtyPatches.get(lock);
|
|
7060
7060
|
if (currentDirty) {
|
|
7061
|
-
for (const [
|
|
7062
|
-
const current = currentDirty.get(
|
|
7061
|
+
for (const [key3, patch] of snapshot) {
|
|
7062
|
+
const current = currentDirty.get(key3);
|
|
7063
7063
|
if (!current) continue;
|
|
7064
7064
|
for (const [field, value] of Object.entries(patch)) {
|
|
7065
7065
|
if (Object.is(current[field], value)) {
|
|
7066
7066
|
delete current[field];
|
|
7067
7067
|
}
|
|
7068
7068
|
}
|
|
7069
|
-
if (Object.keys(current).length === 0) currentDirty.delete(
|
|
7069
|
+
if (Object.keys(current).length === 0) currentDirty.delete(key3);
|
|
7070
7070
|
}
|
|
7071
7071
|
}
|
|
7072
7072
|
const stillDirty = dirtyDeletes.get(lock);
|
|
7073
7073
|
if (stillDirty) {
|
|
7074
|
-
for (const
|
|
7074
|
+
for (const key3 of deleteSnapshot) stillDirty.delete(key3);
|
|
7075
7075
|
if (stillDirty.size === 0) dirtyDeletes.delete(lock);
|
|
7076
7076
|
}
|
|
7077
7077
|
const localAfterWrite = lock.entries;
|
|
7078
7078
|
lock.entries = { ...merged };
|
|
7079
|
-
for (const [
|
|
7080
|
-
const base = lock.entries[
|
|
7081
|
-
if (base) lock.entries[
|
|
7079
|
+
for (const [key3, patch] of currentDirty ?? []) {
|
|
7080
|
+
const base = lock.entries[key3] ?? localAfterWrite[key3];
|
|
7081
|
+
if (base) lock.entries[key3] = { ...base, ...patch };
|
|
7082
7082
|
}
|
|
7083
7083
|
}
|
|
7084
|
-
function upsert(lock,
|
|
7085
|
-
dirtyDeletes.get(lock)?.delete(
|
|
7086
|
-
const existing = lock.entries[
|
|
7084
|
+
function upsert(lock, key3, patch) {
|
|
7085
|
+
dirtyDeletes.get(lock)?.delete(key3);
|
|
7086
|
+
const existing = lock.entries[key3];
|
|
7087
7087
|
const next = { ...existing, ...patch };
|
|
7088
|
-
lock.entries[
|
|
7088
|
+
lock.entries[key3] = next;
|
|
7089
7089
|
let dirty = dirtyPatches.get(lock);
|
|
7090
7090
|
if (!dirty) {
|
|
7091
7091
|
dirty = /* @__PURE__ */ new Map();
|
|
7092
7092
|
dirtyPatches.set(lock, dirty);
|
|
7093
7093
|
}
|
|
7094
|
-
dirty.set(
|
|
7094
|
+
dirty.set(key3, { ...dirty.get(key3) ?? {}, ...patch });
|
|
7095
7095
|
return next;
|
|
7096
7096
|
}
|
|
7097
|
-
function remove(lock,
|
|
7098
|
-
if (!lock.entries[
|
|
7099
|
-
delete lock.entries[
|
|
7097
|
+
function remove(lock, key3) {
|
|
7098
|
+
if (!lock.entries[key3]) return false;
|
|
7099
|
+
delete lock.entries[key3];
|
|
7100
7100
|
const patches = dirtyPatches.get(lock);
|
|
7101
7101
|
if (patches) {
|
|
7102
|
-
patches.delete(
|
|
7102
|
+
patches.delete(key3);
|
|
7103
7103
|
if (patches.size === 0) dirtyPatches.delete(lock);
|
|
7104
7104
|
}
|
|
7105
7105
|
let deletes = dirtyDeletes.get(lock);
|
|
@@ -7107,7 +7107,7 @@ function remove(lock, key2) {
|
|
|
7107
7107
|
deletes = /* @__PURE__ */ new Set();
|
|
7108
7108
|
dirtyDeletes.set(lock, deletes);
|
|
7109
7109
|
}
|
|
7110
|
-
deletes.add(
|
|
7110
|
+
deletes.add(key3);
|
|
7111
7111
|
return true;
|
|
7112
7112
|
}
|
|
7113
7113
|
var FILE_LOCK_TIMEOUT_MS = 1e4;
|
|
@@ -7207,8 +7207,8 @@ function currentEntryOutputPath(entry, spec, index) {
|
|
|
7207
7207
|
function normalizeLockOutputPaths(lock, specs) {
|
|
7208
7208
|
const byKey = new Map(specs.map((spec) => [lockKey(spec.styleId, spec.assetId), spec]));
|
|
7209
7209
|
let changed = 0;
|
|
7210
|
-
for (const [
|
|
7211
|
-
const spec = byKey.get(
|
|
7210
|
+
for (const [key3, entry] of Object.entries(lock.entries)) {
|
|
7211
|
+
const spec = byKey.get(key3);
|
|
7212
7212
|
if (!spec) continue;
|
|
7213
7213
|
let entryChanged = false;
|
|
7214
7214
|
const outputs = entry.outputs.map((output, index) => {
|
|
@@ -7219,7 +7219,7 @@ function normalizeLockOutputPaths(lock, specs) {
|
|
|
7219
7219
|
entryChanged = true;
|
|
7220
7220
|
return { ...output, path: portable };
|
|
7221
7221
|
});
|
|
7222
|
-
if (entryChanged) upsert(lock,
|
|
7222
|
+
if (entryChanged) upsert(lock, key3, { outputs });
|
|
7223
7223
|
}
|
|
7224
7224
|
return changed;
|
|
7225
7225
|
}
|
|
@@ -7250,8 +7250,8 @@ function resolveSpecEntryOutputs(entry, spec) {
|
|
|
7250
7250
|
}
|
|
7251
7251
|
function resolveStyleOutputs(lock, styleId, manifestDir) {
|
|
7252
7252
|
const prefix = `${styleId}/`;
|
|
7253
|
-
return Object.entries(lock.entries).filter(([
|
|
7254
|
-
([
|
|
7253
|
+
return Object.entries(lock.entries).filter(([key3]) => key3.startsWith(prefix)).sort(([a], [b]) => a.localeCompare(b)).flatMap(
|
|
7254
|
+
([key3, entry]) => resolveEntryOutputs(entry, key3.slice(prefix.length), manifestDir)
|
|
7255
7255
|
);
|
|
7256
7256
|
}
|
|
7257
7257
|
function selectEntryOutput(entry, role) {
|
|
@@ -7335,8 +7335,8 @@ function quantize(png, palette) {
|
|
|
7335
7335
|
pixels[i + 2] = 0;
|
|
7336
7336
|
continue;
|
|
7337
7337
|
}
|
|
7338
|
-
const
|
|
7339
|
-
let nearest = nearestOf.get(
|
|
7338
|
+
const key3 = pixels[i] << 16 | pixels[i + 1] << 8 | pixels[i + 2];
|
|
7339
|
+
let nearest = nearestOf.get(key3);
|
|
7340
7340
|
if (!nearest) {
|
|
7341
7341
|
const pixel = { r: pixels[i], g: pixels[i + 1], b: pixels[i + 2] };
|
|
7342
7342
|
nearest = colors[0];
|
|
@@ -7349,7 +7349,7 @@ function quantize(png, palette) {
|
|
|
7349
7349
|
distance = candidateDistance;
|
|
7350
7350
|
}
|
|
7351
7351
|
}
|
|
7352
|
-
nearestOf.set(
|
|
7352
|
+
nearestOf.set(key3, nearest);
|
|
7353
7353
|
}
|
|
7354
7354
|
if (pixels[i] !== nearest.r || pixels[i + 1] !== nearest.g || pixels[i + 2] !== nearest.b) changed++;
|
|
7355
7355
|
pixels[i] = nearest.r;
|
|
@@ -7455,7 +7455,7 @@ async function deriveMirror(spec, lock, lockPath, opts = {}) {
|
|
|
7455
7455
|
const log = opts.onProgress ?? (() => {
|
|
7456
7456
|
});
|
|
7457
7457
|
const mirror = spec.mirror;
|
|
7458
|
-
const
|
|
7458
|
+
const key3 = lockKey(spec.styleId, spec.assetId);
|
|
7459
7459
|
const sourceKey = lockKey(spec.styleId, mirror.sourceAssetId);
|
|
7460
7460
|
const source = lock.entries[sourceKey];
|
|
7461
7461
|
if (!source || source.status !== "downloaded" || !source.outputs.length) {
|
|
@@ -7487,7 +7487,7 @@ async function deriveMirror(spec, lock, lockPath, opts = {}) {
|
|
|
7487
7487
|
}
|
|
7488
7488
|
const sourceMetadata = source.providerMetadata?.[source.provider] ?? {};
|
|
7489
7489
|
const character = spec.character;
|
|
7490
|
-
const entry = upsert(lock,
|
|
7490
|
+
const entry = upsert(lock, key3, {
|
|
7491
7491
|
styleId: spec.styleId,
|
|
7492
7492
|
assetId: spec.assetId,
|
|
7493
7493
|
specHash: spec.specHash,
|
|
@@ -7530,7 +7530,7 @@ async function deriveMirror(spec, lock, lockPath, opts = {}) {
|
|
|
7530
7530
|
postprocess: postprocessFor(spec)
|
|
7531
7531
|
});
|
|
7532
7532
|
await saveLock(lockPath, lock);
|
|
7533
|
-
log(` mirror ${
|
|
7533
|
+
log(` mirror ${key3} \u2190 ${sourceKey} (${written.length} file${written.length === 1 ? "" : "s"} flipped, no generation cost)`);
|
|
7534
7534
|
return entry;
|
|
7535
7535
|
}
|
|
7536
7536
|
|
|
@@ -7538,14 +7538,14 @@ async function deriveMirror(spec, lock, lockPath, opts = {}) {
|
|
|
7538
7538
|
function heldFrames(spec, lock) {
|
|
7539
7539
|
const frames = [];
|
|
7540
7540
|
for (const source of spec.character.layer.sources) {
|
|
7541
|
-
const
|
|
7542
|
-
const entry = lock.entries[
|
|
7541
|
+
const key3 = lockKey(source.spec.styleId, source.spec.assetId);
|
|
7542
|
+
const entry = lock.entries[key3];
|
|
7543
7543
|
if (!entry || entry.status !== "downloaded" || !entry.outputs.length) {
|
|
7544
|
-
throw new Error(`held item source ${
|
|
7544
|
+
throw new Error(`held item source ${key3} has no downloaded frames`);
|
|
7545
7545
|
}
|
|
7546
7546
|
for (const [index, output] of entry.outputs.entries()) {
|
|
7547
7547
|
const direction = isDirection(output.role) ? output.role : source.spec.character?.animation?.direction;
|
|
7548
|
-
if (!direction) throw new Error(`cannot tell which way ${
|
|
7548
|
+
if (!direction) throw new Error(`cannot tell which way ${key3} frame ${output.role ?? index} faces`);
|
|
7549
7549
|
frames.push({
|
|
7550
7550
|
assetId: source.assetId,
|
|
7551
7551
|
role: output.role ?? String(index).padStart(2, "0"),
|
|
@@ -7614,7 +7614,7 @@ async function heldItemAsset(spec, lock, lockPath, opts = {}) {
|
|
|
7614
7614
|
});
|
|
7615
7615
|
const layer = spec.character.layer;
|
|
7616
7616
|
const attach = layer.attach;
|
|
7617
|
-
const
|
|
7617
|
+
const key3 = lockKey(spec.styleId, spec.assetId);
|
|
7618
7618
|
const frames = heldFrames(spec, lock);
|
|
7619
7619
|
const placed = await placeHeldFrames(spec, frames);
|
|
7620
7620
|
const outputs = [];
|
|
@@ -7631,7 +7631,7 @@ async function heldItemAsset(spec, lock, lockPath, opts = {}) {
|
|
|
7631
7631
|
outputs.push({ path: portableOutputPath(target, spec.root), sha256: sha256(bytes), role, mediaType: MediaType.PNG });
|
|
7632
7632
|
}
|
|
7633
7633
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
7634
|
-
const entry = upsert(lock,
|
|
7634
|
+
const entry = upsert(lock, key3, {
|
|
7635
7635
|
styleId: spec.styleId,
|
|
7636
7636
|
assetId: spec.assetId,
|
|
7637
7637
|
specHash: spec.specHash,
|
|
@@ -7670,7 +7670,7 @@ async function heldItemAsset(spec, lock, lockPath, opts = {}) {
|
|
|
7670
7670
|
postprocess: void 0
|
|
7671
7671
|
});
|
|
7672
7672
|
await saveLock(lockPath, lock);
|
|
7673
|
-
log(` attach ${
|
|
7673
|
+
log(` attach ${key3} (${frames.length} frame${frames.length === 1 ? "" : "s"}, ${attach.joint}, no generation cost)`);
|
|
7674
7674
|
if (clipped) log(` ${clipped} item pixel${clipped === 1 ? "" : "s"} fell outside the canvas; raise layer.padding above ${layer.padding} to keep them`);
|
|
7675
7675
|
return entry;
|
|
7676
7676
|
}
|
|
@@ -10141,8 +10141,8 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
10141
10141
|
billed
|
|
10142
10142
|
};
|
|
10143
10143
|
};
|
|
10144
|
-
for (const
|
|
10145
|
-
const list = done[
|
|
10144
|
+
for (const key3 of ["frame_urls", "frames", "images"]) {
|
|
10145
|
+
const list = done[key3];
|
|
10146
10146
|
if (!Array.isArray(list) || !list.length) continue;
|
|
10147
10147
|
const urls = [];
|
|
10148
10148
|
for (const [index, item] of list.entries()) {
|
|
@@ -10197,15 +10197,15 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
10197
10197
|
const billed = billedFromUsage(job.usage);
|
|
10198
10198
|
const done = job.last_response ?? {};
|
|
10199
10199
|
const urlKeys = ["image_url", "download_url", "url", "output_url"];
|
|
10200
|
-
for (const
|
|
10201
|
-
const url = done[
|
|
10200
|
+
for (const key3 of urlKeys) {
|
|
10201
|
+
const url = done[key3];
|
|
10202
10202
|
if (typeof url === "string" && url) {
|
|
10203
10203
|
return { status: "ready", objectId: jobId, sourceUrl: url, sources: [{ url }], billed };
|
|
10204
10204
|
}
|
|
10205
10205
|
}
|
|
10206
10206
|
const imageKeys = ["image", "output_image", "result_image", "edited_image"];
|
|
10207
|
-
for (const
|
|
10208
|
-
const candidate = done[
|
|
10207
|
+
for (const key3 of imageKeys) {
|
|
10208
|
+
const candidate = done[key3];
|
|
10209
10209
|
const base64 = extractBase64(candidate);
|
|
10210
10210
|
if (base64) {
|
|
10211
10211
|
const file = path7.join(_PixelLabProvider.cacheDir(), `${jobId}.png`);
|
|
@@ -10674,7 +10674,7 @@ function requirePixelLabOption(generator, name, value, allowed) {
|
|
|
10674
10674
|
}
|
|
10675
10675
|
}
|
|
10676
10676
|
function tilesInIndexOrder(urls) {
|
|
10677
|
-
return Object.entries(urls).map(([
|
|
10677
|
+
return Object.entries(urls).map(([key3, url]) => ({ index: Number(key3.replace(/^tile_/, "")), url })).filter((tile) => Number.isFinite(tile.index)).sort((a, b) => a.index - b.index);
|
|
10678
10678
|
}
|
|
10679
10679
|
function firstUrl(urls) {
|
|
10680
10680
|
if (!urls) return null;
|
|
@@ -11307,8 +11307,8 @@ var ScenarioClient = class {
|
|
|
11307
11307
|
throw new Error(`${missing.join(" and ")} ${missing.length > 1 ? "are" : "is"} not set`);
|
|
11308
11308
|
}
|
|
11309
11309
|
const url = new URL(`${this.baseUrl.replace(/\/$/, "")}${pathname}`);
|
|
11310
|
-
for (const [
|
|
11311
|
-
if (value2 != null) url.searchParams.set(
|
|
11310
|
+
for (const [key3, value2] of Object.entries(query)) {
|
|
11311
|
+
if (value2 != null) url.searchParams.set(key3, value2);
|
|
11312
11312
|
}
|
|
11313
11313
|
const auth = Buffer.from(`${this.apiKey}:${this.apiSecret}`).toString("base64");
|
|
11314
11314
|
const response = await this.request(url, {
|
|
@@ -11548,12 +11548,12 @@ function readUploadCache() {
|
|
|
11548
11548
|
return {};
|
|
11549
11549
|
}
|
|
11550
11550
|
}
|
|
11551
|
-
function writeUploadCache(
|
|
11551
|
+
function writeUploadCache(key3, assetId) {
|
|
11552
11552
|
try {
|
|
11553
11553
|
const file = uploadCachePath();
|
|
11554
11554
|
mkdirSync2(path8.dirname(file), { recursive: true });
|
|
11555
11555
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
11556
|
-
writeFileSync2(tmp, JSON.stringify({ ...readUploadCache(), [
|
|
11556
|
+
writeFileSync2(tmp, JSON.stringify({ ...readUploadCache(), [key3]: assetId }));
|
|
11557
11557
|
renameSync(tmp, file);
|
|
11558
11558
|
} catch {
|
|
11559
11559
|
}
|
|
@@ -11603,9 +11603,9 @@ function validateParameters(parameters) {
|
|
|
11603
11603
|
if (!parameters || typeof parameters !== "object" || Array.isArray(parameters)) {
|
|
11604
11604
|
throw new Error("Scenario parameters must be a JSON object");
|
|
11605
11605
|
}
|
|
11606
|
-
for (const
|
|
11607
|
-
if (PROTECTED_PARAMETERS.has(
|
|
11608
|
-
throw new Error(`Scenario parameters.${
|
|
11606
|
+
for (const key3 of Object.keys(parameters)) {
|
|
11607
|
+
if (PROTECTED_PARAMETERS.has(key3)) {
|
|
11608
|
+
throw new Error(`Scenario parameters.${key3} is managed by PixelKiln and cannot be overridden`);
|
|
11609
11609
|
}
|
|
11610
11610
|
}
|
|
11611
11611
|
assertJsonValue(parameters, "Scenario parameters");
|
|
@@ -11628,8 +11628,8 @@ function assertJsonValue(value, label, seen = /* @__PURE__ */ new Set()) {
|
|
|
11628
11628
|
if (Array.isArray(value)) {
|
|
11629
11629
|
value.forEach((item, index) => assertJsonValue(item, `${label}[${index}]`, seen));
|
|
11630
11630
|
} else {
|
|
11631
|
-
for (const [
|
|
11632
|
-
assertJsonValue(item, `${label}.${
|
|
11631
|
+
for (const [key3, item] of Object.entries(value)) {
|
|
11632
|
+
assertJsonValue(item, `${label}.${key3}`, seen);
|
|
11633
11633
|
}
|
|
11634
11634
|
}
|
|
11635
11635
|
seen.delete(value);
|
|
@@ -11730,8 +11730,8 @@ function numericRecord(value) {
|
|
|
11730
11730
|
throw new Error("Scenario returned invalid cost details");
|
|
11731
11731
|
}
|
|
11732
11732
|
const out = {};
|
|
11733
|
-
for (const [
|
|
11734
|
-
out[
|
|
11733
|
+
for (const [key3, amount] of Object.entries(value)) {
|
|
11734
|
+
out[key3] = finiteNonnegative(amount, `Scenario returned invalid cost detail "${key3}"`);
|
|
11735
11735
|
}
|
|
11736
11736
|
return out;
|
|
11737
11737
|
}
|
|
@@ -12337,7 +12337,7 @@ function parseOptions(value) {
|
|
|
12337
12337
|
"workflow",
|
|
12338
12338
|
"workflowSha256"
|
|
12339
12339
|
]);
|
|
12340
|
-
const extra = Object.keys(value).filter((
|
|
12340
|
+
const extra = Object.keys(value).filter((key3) => !allowed.has(key3));
|
|
12341
12341
|
if (extra.length) throw new Error(`Unknown ComfyUI option(s): ${extra.join(", ")}`);
|
|
12342
12342
|
const workflowFile = requiredString(value.workflowFile, "workflowFile");
|
|
12343
12343
|
const outputNodeId = requiredString(value.outputNodeId, "outputNodeId");
|
|
@@ -12373,7 +12373,7 @@ function parseOptions(value) {
|
|
|
12373
12373
|
}
|
|
12374
12374
|
function parseFrames(value) {
|
|
12375
12375
|
if (!isObject(value)) throw new Error("ComfyUI frames must be an object");
|
|
12376
|
-
const extra = Object.keys(value).filter((
|
|
12376
|
+
const extra = Object.keys(value).filter((key3) => key3 !== "vary" && key3 !== "seedStep");
|
|
12377
12377
|
if (extra.length) throw new Error(`Unknown ComfyUI frames field(s): ${extra.join(", ")}`);
|
|
12378
12378
|
const vary = requiredString(value.vary, "frames.vary");
|
|
12379
12379
|
const seedStep = value.seedStep ?? 0;
|
|
@@ -12391,7 +12391,7 @@ function resolvedOptions(spec) {
|
|
|
12391
12391
|
}
|
|
12392
12392
|
function parseBinding(value, name) {
|
|
12393
12393
|
if (!isObject(value)) throw new Error(`ComfyUI bindings.${name} must be an object`);
|
|
12394
|
-
const extra = Object.keys(value).filter((
|
|
12394
|
+
const extra = Object.keys(value).filter((key3) => key3 !== "nodeId" && key3 !== "input");
|
|
12395
12395
|
if (extra.length) throw new Error(`Unknown ComfyUI bindings.${name} field(s): ${extra.join(", ")}`);
|
|
12396
12396
|
return {
|
|
12397
12397
|
nodeId: requiredString(value.nodeId, `bindings.${name}.nodeId`),
|
|
@@ -12656,7 +12656,7 @@ function canonical(value) {
|
|
|
12656
12656
|
if (Array.isArray(value)) return value.map(canonical);
|
|
12657
12657
|
if (!isObject(value)) return value;
|
|
12658
12658
|
return Object.fromEntries(
|
|
12659
|
-
Object.keys(value).sort().map((
|
|
12659
|
+
Object.keys(value).sort().map((key3) => [key3, canonical(value[key3])])
|
|
12660
12660
|
);
|
|
12661
12661
|
}
|
|
12662
12662
|
|
|
@@ -13316,10 +13316,10 @@ function culpritEntries(message6) {
|
|
|
13316
13316
|
const match = /^ {2}(assets|styles)\.([^.:\s]+)[.:]/.exec(line);
|
|
13317
13317
|
if (!match) continue;
|
|
13318
13318
|
const kind = match[1] === "styles" ? "style" : "asset";
|
|
13319
|
-
const
|
|
13320
|
-
const entry = found.get(
|
|
13319
|
+
const key3 = `${kind}:${match[2]}`;
|
|
13320
|
+
const entry = found.get(key3) ?? { kind, id: match[2], issues: [] };
|
|
13321
13321
|
entry.issues.push(line.trim());
|
|
13322
|
-
found.set(
|
|
13322
|
+
found.set(key3, entry);
|
|
13323
13323
|
}
|
|
13324
13324
|
return [...found.values()];
|
|
13325
13325
|
}
|
|
@@ -14509,8 +14509,8 @@ async function resolveSpecs(loaded, filter) {
|
|
|
14509
14509
|
byOutput.set(file, owner);
|
|
14510
14510
|
};
|
|
14511
14511
|
for (const spec of specs) {
|
|
14512
|
-
const
|
|
14513
|
-
claimOutput(spec.outFile,
|
|
14512
|
+
const key3 = `${spec.styleId}/${spec.assetId}`;
|
|
14513
|
+
claimOutput(spec.outFile, key3);
|
|
14514
14514
|
if (spec.quality) {
|
|
14515
14515
|
if (spec.generator === "frames") {
|
|
14516
14516
|
const frameInputs = Object.values(spec.providerInputs ?? {}).find(Array.isArray);
|
|
@@ -14525,11 +14525,11 @@ async function resolveSpecs(loaded, filter) {
|
|
|
14525
14525
|
count,
|
|
14526
14526
|
MediaType.PNG
|
|
14527
14527
|
),
|
|
14528
|
-
`${
|
|
14528
|
+
`${key3} quality ${role}`
|
|
14529
14529
|
);
|
|
14530
14530
|
}
|
|
14531
14531
|
} else {
|
|
14532
|
-
claimOutput(spec.quality.outFile, `${
|
|
14532
|
+
claimOutput(spec.quality.outFile, `${key3} quality output`);
|
|
14533
14533
|
}
|
|
14534
14534
|
}
|
|
14535
14535
|
}
|
|
@@ -14811,8 +14811,8 @@ import path12 from "path";
|
|
|
14811
14811
|
function loadEnvFiles(dir) {
|
|
14812
14812
|
const loaded = [];
|
|
14813
14813
|
for (const [file, vars] of envFiles(dir)) {
|
|
14814
|
-
for (const [
|
|
14815
|
-
if (!(
|
|
14814
|
+
for (const [key3, value] of Object.entries(vars)) {
|
|
14815
|
+
if (!(key3 in process.env)) process.env[key3] = value;
|
|
14816
14816
|
}
|
|
14817
14817
|
loaded.push(file);
|
|
14818
14818
|
}
|
|
@@ -14837,14 +14837,14 @@ function parseEnv(contents) {
|
|
|
14837
14837
|
if (!line || line.startsWith("#")) continue;
|
|
14838
14838
|
const eq = line.indexOf("=");
|
|
14839
14839
|
if (eq <= 0) continue;
|
|
14840
|
-
const
|
|
14841
|
-
if (!
|
|
14840
|
+
const key3 = line.slice(0, eq).replace(/^export\s+/, "").trim();
|
|
14841
|
+
if (!key3 || key3 in vars) continue;
|
|
14842
14842
|
let value = line.slice(eq + 1).trim();
|
|
14843
14843
|
const quote = value[0];
|
|
14844
14844
|
if ((quote === '"' || quote === "'") && value.endsWith(quote) && value.length >= 2) {
|
|
14845
14845
|
value = value.slice(1, -1);
|
|
14846
14846
|
}
|
|
14847
|
-
vars[
|
|
14847
|
+
vars[key3] = value;
|
|
14848
14848
|
}
|
|
14849
14849
|
return vars;
|
|
14850
14850
|
}
|
|
@@ -14910,9 +14910,9 @@ function canonical2(value) {
|
|
|
14910
14910
|
if (Array.isArray(value)) return value.map(canonical2);
|
|
14911
14911
|
if (typeof value === "object") {
|
|
14912
14912
|
const sorted = {};
|
|
14913
|
-
for (const
|
|
14914
|
-
const item = value[
|
|
14915
|
-
if (item !== void 0) sorted[
|
|
14913
|
+
for (const key3 of Object.keys(value).sort()) {
|
|
14914
|
+
const item = value[key3];
|
|
14915
|
+
if (item !== void 0) sorted[key3] = canonical2(item);
|
|
14916
14916
|
}
|
|
14917
14917
|
return sorted;
|
|
14918
14918
|
}
|
|
@@ -15899,18 +15899,18 @@ async function qualitySource(spec, lock) {
|
|
|
15899
15899
|
}
|
|
15900
15900
|
async function inspectQualityProfile(spec, lock) {
|
|
15901
15901
|
if (!spec.quality) return null;
|
|
15902
|
-
const
|
|
15902
|
+
const key3 = lockKey(spec.styleId, spec.assetId);
|
|
15903
15903
|
const output = spec.quality.outFile;
|
|
15904
15904
|
const record = qualityRecordPath(output);
|
|
15905
15905
|
const source = await qualitySource(spec, lock);
|
|
15906
15906
|
if (!source.items) {
|
|
15907
|
-
return { key:
|
|
15907
|
+
return { key: key3, state: "blocked", reason: source.reason, source: null, output, record };
|
|
15908
15908
|
}
|
|
15909
15909
|
const sourcePaths = source.items.map((item) => item.path);
|
|
15910
15910
|
const expectedOutputs = spec.generator === "frames" ? source.items.map((item, index) => qualityFrameOutputPath(output, item.role, index)) : [output];
|
|
15911
15911
|
if (!existsSync12(record)) {
|
|
15912
15912
|
return {
|
|
15913
|
-
key:
|
|
15913
|
+
key: key3,
|
|
15914
15914
|
state: "needs-refinement",
|
|
15915
15915
|
reason: "no refinement record",
|
|
15916
15916
|
source: sourcePaths[0],
|
|
@@ -15929,7 +15929,7 @@ async function inspectQualityProfile(spec, lock) {
|
|
|
15929
15929
|
const contractChanged = JSON.stringify(check.sources.map((item) => path16.resolve(item))) !== JSON.stringify(sourcePaths.map((item) => path16.resolve(item))) || JSON.stringify(check.outputs.map((item) => path16.resolve(item))) !== JSON.stringify(expectedOutputs.map((item) => path16.resolve(item))) || JSON.stringify(check.options.palette.colors) !== JSON.stringify(expectedPalette) || check.options.nativeGrid.revision !== expectedRevision || check.options.audit.thresholds.minGridConfidence !== spec.quality.minGridConfidence || check.options.audit.thresholds.minTransparency !== expectedTransparency || (expectedFrameSet ? !check.options.frameSet || check.options.frameSet.fps !== expectedFrameSet.fps || check.options.frameSet.count !== expectedFrameSet.count || JSON.stringify(check.options.frameSet.roles) !== JSON.stringify(expectedFrameSet.roles) : check.options.frameSet !== void 0);
|
|
15930
15930
|
if (contractChanged) {
|
|
15931
15931
|
return {
|
|
15932
|
-
key:
|
|
15932
|
+
key: key3,
|
|
15933
15933
|
state: "needs-refinement",
|
|
15934
15934
|
reason: "quality profile changed",
|
|
15935
15935
|
source: sourcePaths[0],
|
|
@@ -15941,7 +15941,7 @@ async function inspectQualityProfile(spec, lock) {
|
|
|
15941
15941
|
}
|
|
15942
15942
|
if (!check.current || !check.auditSafe) {
|
|
15943
15943
|
return {
|
|
15944
|
-
key:
|
|
15944
|
+
key: key3,
|
|
15945
15945
|
state: "needs-refinement",
|
|
15946
15946
|
reason: check.reasons.filter((reason) => reason !== "human 1\xD7 review is pending").join("; ") || "refinement record is stale",
|
|
15947
15947
|
source: sourcePaths[0],
|
|
@@ -15953,7 +15953,7 @@ async function inspectQualityProfile(spec, lock) {
|
|
|
15953
15953
|
}
|
|
15954
15954
|
if (!check.approved) {
|
|
15955
15955
|
return {
|
|
15956
|
-
key:
|
|
15956
|
+
key: key3,
|
|
15957
15957
|
state: "needs-approval",
|
|
15958
15958
|
reason: "automated checks passed; human 1\xD7 review is pending",
|
|
15959
15959
|
source: sourcePaths[0],
|
|
@@ -15964,7 +15964,7 @@ async function inspectQualityProfile(spec, lock) {
|
|
|
15964
15964
|
};
|
|
15965
15965
|
}
|
|
15966
15966
|
return {
|
|
15967
|
-
key:
|
|
15967
|
+
key: key3,
|
|
15968
15968
|
state: "approved",
|
|
15969
15969
|
reason: "refined output and human approval are current",
|
|
15970
15970
|
source: sourcePaths[0],
|
|
@@ -15975,7 +15975,7 @@ async function inspectQualityProfile(spec, lock) {
|
|
|
15975
15975
|
};
|
|
15976
15976
|
} catch (error) {
|
|
15977
15977
|
return {
|
|
15978
|
-
key:
|
|
15978
|
+
key: key3,
|
|
15979
15979
|
state: "needs-refinement",
|
|
15980
15980
|
reason: `invalid refinement record: ${error instanceof Error ? error.message : String(error)}`,
|
|
15981
15981
|
source: sourcePaths[0],
|
|
@@ -16327,10 +16327,10 @@ async function requireRevisionReady(spec, lock) {
|
|
|
16327
16327
|
if (inspection && !inspection.ready) throw new Error(inspection.reason);
|
|
16328
16328
|
}
|
|
16329
16329
|
async function inspectParent(spec, lock, seen) {
|
|
16330
|
-
const
|
|
16331
|
-
if (seen.has(
|
|
16330
|
+
const key3 = lockKey(spec.styleId, spec.assetId);
|
|
16331
|
+
if (seen.has(key3)) return { ready: false, reason: `revision dependency cycle at ${key3}` };
|
|
16332
16332
|
const nextSeen = new Set(seen);
|
|
16333
|
-
nextSeen.add(
|
|
16333
|
+
nextSeen.add(key3);
|
|
16334
16334
|
if (spec.mirror) {
|
|
16335
16335
|
const inputs = await inspectMirror(spec, lock, nextSeen);
|
|
16336
16336
|
if (!inputs.ready) return inputs;
|
|
@@ -16376,7 +16376,7 @@ async function inspectParent(spec, lock, seen) {
|
|
|
16376
16376
|
const source = path17.resolve(spec.root, spec.source);
|
|
16377
16377
|
return existsSync13(source) ? { ready: true, reason: "declared source is present" } : { ready: false, reason: `declared source is missing: ${spec.source}` };
|
|
16378
16378
|
}
|
|
16379
|
-
const entry = lock.entries[
|
|
16379
|
+
const entry = lock.entries[key3];
|
|
16380
16380
|
if (!entry) return { ready: false, reason: "parent is not in the lockfile" };
|
|
16381
16381
|
if (entry.specHash !== spec.specHash) {
|
|
16382
16382
|
return { ready: false, reason: "parent generation spec is stale" };
|
|
@@ -16460,15 +16460,15 @@ function resumeCommandForStatus(status) {
|
|
|
16460
16460
|
function resumeActions(specs, lock) {
|
|
16461
16461
|
const grouped = /* @__PURE__ */ new Map();
|
|
16462
16462
|
for (const spec of specs) {
|
|
16463
|
-
const
|
|
16464
|
-
const entry = lock.entries[
|
|
16463
|
+
const key3 = lockKey(spec.styleId, spec.assetId);
|
|
16464
|
+
const entry = lock.entries[key3];
|
|
16465
16465
|
if (!entry || entry.specHash !== spec.specHash) continue;
|
|
16466
16466
|
if (entry.submissionComplete === false) continue;
|
|
16467
16467
|
const command = resumeCommandForStatus(entry.status) ?? (entry.status === "downloaded" && entry.outputs.length && !postprocessCurrent(entry, spec) ? "fetch" : null);
|
|
16468
16468
|
if (!command) continue;
|
|
16469
16469
|
if (command === "poll" && !entry.jobId) continue;
|
|
16470
16470
|
if (command === "pick" && !entry.reviewObjectId) continue;
|
|
16471
|
-
grouped.set(command, [...grouped.get(command) ?? [],
|
|
16471
|
+
grouped.set(command, [...grouped.get(command) ?? [], key3]);
|
|
16472
16472
|
}
|
|
16473
16473
|
return ["poll", "pick", "fetch"].flatMap((command) => {
|
|
16474
16474
|
const keys = grouped.get(command);
|
|
@@ -16478,8 +16478,8 @@ function resumeActions(specs, lock) {
|
|
|
16478
16478
|
async function buildPlan(specs, lock, opts = {}) {
|
|
16479
16479
|
const items = [];
|
|
16480
16480
|
for (const spec of specs) {
|
|
16481
|
-
const
|
|
16482
|
-
const entry = lock.entries[
|
|
16481
|
+
const key3 = lockKey(spec.styleId, spec.assetId);
|
|
16482
|
+
const entry = lock.entries[key3];
|
|
16483
16483
|
let state;
|
|
16484
16484
|
let reason;
|
|
16485
16485
|
const changedConnection = entry ? changedTerrainConnection(spec, entry, lock) : null;
|
|
@@ -16594,7 +16594,7 @@ async function buildPlan(specs, lock, opts = {}) {
|
|
|
16594
16594
|
reason = "up to date";
|
|
16595
16595
|
}
|
|
16596
16596
|
const quality = await inspectQualityProfile(spec, lock);
|
|
16597
|
-
items.push({ spec, key:
|
|
16597
|
+
items.push({ spec, key: key3, state, reason, ...quality ? { quality } : {} });
|
|
16598
16598
|
}
|
|
16599
16599
|
const isActionable = (i) => i.state === "missing" || i.state === "stale" || i.state === "failed";
|
|
16600
16600
|
const stateOf = new Map(items.map((i) => [i.key, i.state]));
|
|
@@ -16718,11 +16718,11 @@ async function openProject(manifestPath = "pixelkiln.manifest.json", opts = {})
|
|
|
16718
16718
|
reload: () => openProject(absolute, { ...opts, env: false }),
|
|
16719
16719
|
providers: () => [...new Set(specs.map((spec) => spec.provider))].sort(),
|
|
16720
16720
|
provider: (id, mode2 = "online") => {
|
|
16721
|
-
const
|
|
16722
|
-
let adapter = adapters.get(
|
|
16721
|
+
const key3 = `${mode2}:${id}`;
|
|
16722
|
+
let adapter = adapters.get(key3);
|
|
16723
16723
|
if (!adapter) {
|
|
16724
16724
|
adapter = createProvider(id, mode2);
|
|
16725
|
-
adapters.set(
|
|
16725
|
+
adapters.set(key3, adapter);
|
|
16726
16726
|
}
|
|
16727
16727
|
return adapter;
|
|
16728
16728
|
}
|
|
@@ -16901,9 +16901,9 @@ function canonical3(value) {
|
|
|
16901
16901
|
if (Array.isArray(value)) return value.map(canonical3);
|
|
16902
16902
|
if (typeof value === "object") {
|
|
16903
16903
|
const sorted = {};
|
|
16904
|
-
for (const
|
|
16905
|
-
const item = value[
|
|
16906
|
-
if (item !== void 0) sorted[
|
|
16904
|
+
for (const key3 of Object.keys(value).sort()) {
|
|
16905
|
+
const item = value[key3];
|
|
16906
|
+
if (item !== void 0) sorted[key3] = canonical3(item);
|
|
16907
16907
|
}
|
|
16908
16908
|
return sorted;
|
|
16909
16909
|
}
|
|
@@ -17042,7 +17042,7 @@ function renderStyle(style, destination, cwd) {
|
|
|
17042
17042
|
if (typeof value === "string") return value.replaceAll(RECIPE_DIR_TOKEN, portableDir);
|
|
17043
17043
|
if (Array.isArray(value)) return value.map(replace);
|
|
17044
17044
|
if (value && typeof value === "object") {
|
|
17045
|
-
return Object.fromEntries(Object.entries(value).map(([
|
|
17045
|
+
return Object.fromEntries(Object.entries(value).map(([key3, item]) => [key3, replace(item)]));
|
|
17046
17046
|
}
|
|
17047
17047
|
return value;
|
|
17048
17048
|
};
|
|
@@ -17110,10 +17110,10 @@ function mergePalettes(palettes, topN = 24) {
|
|
|
17110
17110
|
const totals = /* @__PURE__ */ new Map();
|
|
17111
17111
|
for (const palette of palettes) {
|
|
17112
17112
|
for (const color of palette) {
|
|
17113
|
-
const
|
|
17114
|
-
const existing = totals.get(
|
|
17113
|
+
const key3 = `${color.r},${color.g},${color.b}`;
|
|
17114
|
+
const existing = totals.get(key3);
|
|
17115
17115
|
if (existing) existing.weight += color.weight;
|
|
17116
|
-
else totals.set(
|
|
17116
|
+
else totals.set(key3, { ...color });
|
|
17117
17117
|
}
|
|
17118
17118
|
}
|
|
17119
17119
|
const merged = [...totals.values()].sort((a, b) => b.weight - a.weight).slice(0, topN);
|
|
@@ -17785,7 +17785,7 @@ function tilesetSheetReadings(width, height) {
|
|
|
17785
17785
|
}
|
|
17786
17786
|
function chooseTilesetSheetReading(file, width, height, tileSize) {
|
|
17787
17787
|
const readings = tilesetSheetReadings(width, height);
|
|
17788
|
-
const
|
|
17788
|
+
const describe2 = (reading) => `${reading.tileSize}px tiles (${reading.layout === "compact" ? "4 wide" : "8 wide"})`;
|
|
17789
17789
|
if (readings.length === 0) {
|
|
17790
17790
|
throw new Error(
|
|
17791
17791
|
`${file} is ${width}x${height}, not a PixelLab tileset sheet: it takes a square sheet 4 or 8 tiles wide (or twice as tall, for a set with transitions) of 16, 24, 32, 48 or 64px tiles`
|
|
@@ -17794,13 +17794,13 @@ function chooseTilesetSheetReading(file, width, height, tileSize) {
|
|
|
17794
17794
|
if (tileSize === void 0) {
|
|
17795
17795
|
if (readings.length > 1) {
|
|
17796
17796
|
throw new Error(
|
|
17797
|
-
`${file} is ${width}x${height}, which reads as ${readings.map(
|
|
17797
|
+
`${file} is ${width}x${height}, which reads as ${readings.map(describe2).join(" or ")}; say which with --size ${readings.map((reading) => reading.tileSize).join(" or --size ")}`
|
|
17798
17798
|
);
|
|
17799
17799
|
}
|
|
17800
17800
|
return readings[0];
|
|
17801
17801
|
}
|
|
17802
17802
|
const chosen = readings.find((reading) => reading.tileSize === tileSize);
|
|
17803
|
-
if (!chosen) throw new Error(`${file} is ${width}x${height}, which holds ${readings.map(
|
|
17803
|
+
if (!chosen) throw new Error(`${file} is ${width}x${height}, which holds ${readings.map(describe2).join(" or ")}, not ${tileSize}px tiles`);
|
|
17804
17804
|
return chosen;
|
|
17805
17805
|
}
|
|
17806
17806
|
function readPng(bytes, file) {
|
|
@@ -18369,7 +18369,7 @@ function listCodexEffects(lib) {
|
|
|
18369
18369
|
...entry,
|
|
18370
18370
|
loopSeconds: def.loop,
|
|
18371
18371
|
params: Object.fromEntries(
|
|
18372
|
-
Object.entries(def.params ?? {}).map(([
|
|
18372
|
+
Object.entries(def.params ?? {}).map(([key3, param]) => [key3, { label: param.en ?? key3, min: param.min, max: param.max, value: param.value }])
|
|
18373
18373
|
)
|
|
18374
18374
|
};
|
|
18375
18375
|
});
|
|
@@ -18410,19 +18410,19 @@ function checkCodexRecipe(lib, recipe) {
|
|
|
18410
18410
|
if (hue !== void 0 && (typeof hue !== "number" || !Number.isFinite(hue) || hue < -360 || hue > 360)) {
|
|
18411
18411
|
throw new UsageError(`codex hue is degrees from -360 to 360, got ${JSON.stringify(hue)}`);
|
|
18412
18412
|
}
|
|
18413
|
-
for (const [
|
|
18414
|
-
const param = info.params[
|
|
18413
|
+
for (const [key3, value] of Object.entries(params)) {
|
|
18414
|
+
const param = info.params[key3];
|
|
18415
18415
|
if (!param) {
|
|
18416
18416
|
const known = Object.keys(info.params);
|
|
18417
|
-
throw new UsageError(`${recipe.effect} has no parameter "${
|
|
18417
|
+
throw new UsageError(`${recipe.effect} has no parameter "${key3}"${known.length ? `; it has ${known.join(", ")}` : " (it takes none)"}`);
|
|
18418
18418
|
}
|
|
18419
18419
|
if (typeof value !== "number" || !Number.isFinite(value) || value < param.min || value > param.max) {
|
|
18420
|
-
throw new UsageError(`${recipe.effect} ${
|
|
18420
|
+
throw new UsageError(`${recipe.effect} ${key3} is a number from ${param.min} to ${param.max}, got ${JSON.stringify(value)}`);
|
|
18421
18421
|
}
|
|
18422
18422
|
}
|
|
18423
|
-
for (const [
|
|
18424
|
-
if (!CODEX_TUNE_KEYS.includes(
|
|
18425
|
-
if (typeof value !== "number" || !Number.isFinite(value)) throw new UsageError(`tune ${
|
|
18423
|
+
for (const [key3, value] of Object.entries(tune)) {
|
|
18424
|
+
if (!CODEX_TUNE_KEYS.includes(key3)) throw new UsageError(`unknown tune knob "${key3}"; they are ${CODEX_TUNE_KEYS.join(", ")}`);
|
|
18425
|
+
if (typeof value !== "number" || !Number.isFinite(value)) throw new UsageError(`tune ${key3} is a number, got ${JSON.stringify(value)}`);
|
|
18426
18426
|
}
|
|
18427
18427
|
return info;
|
|
18428
18428
|
}
|
|
@@ -18508,12 +18508,12 @@ async function readCodexRecipe(file, opts = {}) {
|
|
|
18508
18508
|
}
|
|
18509
18509
|
const recipe = { effect: raw.effect };
|
|
18510
18510
|
if (raw.camera !== void 0) recipe.camera = raw.camera;
|
|
18511
|
-
for (const
|
|
18512
|
-
for (const
|
|
18513
|
-
const value = raw[
|
|
18511
|
+
for (const key3 of ["fps", "margin", "hue"]) if (raw[key3] !== void 0) recipe[key3] = raw[key3];
|
|
18512
|
+
for (const key3 of ["params", "tune"]) {
|
|
18513
|
+
const value = raw[key3];
|
|
18514
18514
|
if (value === void 0) continue;
|
|
18515
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error(`${file}: a codex recipe's ${
|
|
18516
|
-
recipe[
|
|
18515
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error(`${file}: a codex recipe's ${key3} is an object`);
|
|
18516
|
+
recipe[key3] = value;
|
|
18517
18517
|
}
|
|
18518
18518
|
const library = record ? parsed.library : void 0;
|
|
18519
18519
|
return {
|
|
@@ -18668,8 +18668,8 @@ function measureDecodedImageQuality(png, digest2) {
|
|
|
18668
18668
|
const index = offset / 4;
|
|
18669
18669
|
const x = index % png.width;
|
|
18670
18670
|
const y = Math.floor(index / png.width);
|
|
18671
|
-
const
|
|
18672
|
-
const hasSameNeighbor = x > 0 && pixelKey(png.pixels, offset - 4) ===
|
|
18671
|
+
const key3 = pixelKey(png.pixels, offset);
|
|
18672
|
+
const hasSameNeighbor = x > 0 && pixelKey(png.pixels, offset - 4) === key3 || x + 1 < png.width && pixelKey(png.pixels, offset + 4) === key3 || y > 0 && pixelKey(png.pixels, offset - png.width * 4) === key3 || y + 1 < png.height && pixelKey(png.pixels, offset + png.width * 4) === key3;
|
|
18673
18673
|
if (!hasSameNeighbor) {
|
|
18674
18674
|
isolated++;
|
|
18675
18675
|
}
|
|
@@ -19051,10 +19051,10 @@ async function loadCache(path53) {
|
|
|
19051
19051
|
}
|
|
19052
19052
|
async function saveCache(path53, cache) {
|
|
19053
19053
|
const sorted = {};
|
|
19054
|
-
for (const
|
|
19055
|
-
const hash = cache.hashes[
|
|
19056
|
-
if (!isSha256Hash(hash)) throw new Error(`Refusing to cache invalid SHA-256 for ${
|
|
19057
|
-
sorted[
|
|
19054
|
+
for (const key3 of Object.keys(cache.hashes).sort()) {
|
|
19055
|
+
const hash = cache.hashes[key3];
|
|
19056
|
+
if (!isSha256Hash(hash)) throw new Error(`Refusing to cache invalid SHA-256 for ${key3}`);
|
|
19057
|
+
sorted[key3] = hash;
|
|
19058
19058
|
}
|
|
19059
19059
|
await mkdir12(pathModule.dirname(pathModule.resolve(path53)), { recursive: true });
|
|
19060
19060
|
const tmp = `${path53}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
|
|
@@ -19067,12 +19067,12 @@ async function saveCache(path53, cache) {
|
|
|
19067
19067
|
}
|
|
19068
19068
|
function pruneCache(cache, liveIds, namespace = "") {
|
|
19069
19069
|
let removed = 0;
|
|
19070
|
-
for (const
|
|
19071
|
-
const owned = namespace ?
|
|
19070
|
+
for (const key3 of Object.keys(cache.hashes)) {
|
|
19071
|
+
const owned = namespace ? key3.startsWith(namespace) : !key3.includes(":");
|
|
19072
19072
|
if (!owned) continue;
|
|
19073
|
-
const id = namespace ?
|
|
19073
|
+
const id = namespace ? key3.slice(namespace.length) : key3;
|
|
19074
19074
|
if (!liveIds.has(id)) {
|
|
19075
|
-
delete cache.hashes[
|
|
19075
|
+
delete cache.hashes[key3];
|
|
19076
19076
|
removed++;
|
|
19077
19077
|
}
|
|
19078
19078
|
}
|
|
@@ -19098,15 +19098,15 @@ async function fetchAssets(provider, specs, lock, lockPath, opts = {}) {
|
|
|
19098
19098
|
const specByKey = new Map(specs.map((s) => [lockKey(s.styleId, s.assetId), s]));
|
|
19099
19099
|
normalizeLockOutputPaths(lock, specs);
|
|
19100
19100
|
const cacheDir = opts.cacheDir === false ? null : path29.resolve(opts.cacheDir ?? path29.join(path29.dirname(lockPath), ".pixelkiln", "cache"));
|
|
19101
|
-
const pending = Object.entries(lock.entries).filter(([
|
|
19102
|
-
if (e.provider !== provider.id || !specByKey.has(
|
|
19103
|
-
if (specByKey.get(
|
|
19104
|
-
if (specByKey.get(
|
|
19105
|
-
if (specByKey.get(
|
|
19101
|
+
const pending = Object.entries(lock.entries).filter(([key3, e]) => {
|
|
19102
|
+
if (e.provider !== provider.id || !specByKey.has(key3)) return false;
|
|
19103
|
+
if (specByKey.get(key3)?.mirror) return false;
|
|
19104
|
+
if (specByKey.get(key3)?.derive || specByKey.get(key3)?.external) return false;
|
|
19105
|
+
if (specByKey.get(key3) && isHeldItem(specByKey.get(key3))) return false;
|
|
19106
19106
|
if (e.status === "selected" || e.status === "download-failed") return true;
|
|
19107
19107
|
if (e.status !== "downloaded") return false;
|
|
19108
19108
|
if (opts.refresh) return e.outputs.length > 0 && Boolean(e.sourceUrls?.length || e.sourceUrl);
|
|
19109
|
-
const spec = specByKey.get(
|
|
19109
|
+
const spec = specByKey.get(key3);
|
|
19110
19110
|
if (spec && e.specHash === spec.specHash && e.outputs.length && !postprocessCurrent(e, spec)) {
|
|
19111
19111
|
return Boolean(opts.force) || e.outputs.every((output) => {
|
|
19112
19112
|
const file = resolveOutputPath(output.path, spec.root);
|
|
@@ -19129,15 +19129,15 @@ async function fetchAssets(provider, specs, lock, lockPath, opts = {}) {
|
|
|
19129
19129
|
for (; ; ) {
|
|
19130
19130
|
const next = pending[cursor++];
|
|
19131
19131
|
if (!next) return;
|
|
19132
|
-
const [
|
|
19133
|
-
const spec = specByKey.get(
|
|
19132
|
+
const [key3, entry] = next;
|
|
19133
|
+
const spec = specByKey.get(key3);
|
|
19134
19134
|
if (!spec) {
|
|
19135
|
-
log(` skip ${
|
|
19135
|
+
log(` skip ${key3} (not in current manifest)`);
|
|
19136
19136
|
result.skipped++;
|
|
19137
19137
|
continue;
|
|
19138
19138
|
}
|
|
19139
19139
|
if (entry.specHash !== spec.specHash) {
|
|
19140
|
-
log(` skip ${
|
|
19140
|
+
log(` skip ${key3} (source belongs to a stale spec)`);
|
|
19141
19141
|
result.skipped++;
|
|
19142
19142
|
continue;
|
|
19143
19143
|
}
|
|
@@ -19154,16 +19154,16 @@ async function fetchAssets(provider, specs, lock, lockPath, opts = {}) {
|
|
|
19154
19154
|
});
|
|
19155
19155
|
} catch (err) {
|
|
19156
19156
|
const message6 = err instanceof Error ? err.message : String(err);
|
|
19157
|
-
upsert(lock,
|
|
19157
|
+
upsert(lock, key3, { status: "download-failed", error: `download failed: ${message6}` });
|
|
19158
19158
|
result.failed++;
|
|
19159
|
-
log(` FAILED ${
|
|
19159
|
+
log(` FAILED ${key3}: ${message6}`);
|
|
19160
19160
|
await saveLock(lockPath, lock);
|
|
19161
19161
|
continue;
|
|
19162
19162
|
}
|
|
19163
19163
|
if (current === null) {
|
|
19164
|
-
upsert(lock,
|
|
19164
|
+
upsert(lock, key3, { status: "download-failed", error: `download failed: ${entry.objectId} no longer exists upstream` });
|
|
19165
19165
|
result.failed++;
|
|
19166
|
-
log(` FAILED ${
|
|
19166
|
+
log(` FAILED ${key3}: ${entry.objectId} no longer exists upstream`);
|
|
19167
19167
|
await saveLock(lockPath, lock);
|
|
19168
19168
|
continue;
|
|
19169
19169
|
}
|
|
@@ -19176,7 +19176,7 @@ async function fetchAssets(provider, specs, lock, lockPath, opts = {}) {
|
|
|
19176
19176
|
}
|
|
19177
19177
|
}
|
|
19178
19178
|
if (!sources.length) {
|
|
19179
|
-
upsert(lock,
|
|
19179
|
+
upsert(lock, key3, {
|
|
19180
19180
|
status: "download-failed",
|
|
19181
19181
|
error: "no persisted source URL to download; poll the job again if it still exists upstream"
|
|
19182
19182
|
});
|
|
@@ -19193,11 +19193,11 @@ async function fetchAssets(provider, specs, lock, lockPath, opts = {}) {
|
|
|
19193
19193
|
const parentSpec = spec.character?.parentSpec;
|
|
19194
19194
|
const parentEntry = parentSpec ? lock.entries[lockKey(parentSpec.styleId, parentSpec.assetId)] : void 0;
|
|
19195
19195
|
if (!parentSpec || !parentEntry?.outputs.length) {
|
|
19196
|
-
throw new Error(`cannot clean ${
|
|
19196
|
+
throw new Error(`cannot clean ${key3}: ${wanted.despeckle.of} has no downloaded rotations to judge against`);
|
|
19197
19197
|
}
|
|
19198
19198
|
for (let index = 0; index < parentEntry.outputs.length; index++) {
|
|
19199
19199
|
const file = currentEntryOutputPath(parentEntry, parentSpec, index);
|
|
19200
|
-
if (!existsSync25(file)) throw new Error(`cannot clean ${
|
|
19200
|
+
if (!existsSync25(file)) throw new Error(`cannot clean ${key3}: ${wanted.despeckle.of}'s rotation is missing on disk: ${file}`);
|
|
19201
19201
|
reference.push(await readFile18(file));
|
|
19202
19202
|
}
|
|
19203
19203
|
}
|
|
@@ -19318,7 +19318,7 @@ async function fetchAssets(provider, specs, lock, lockPath, opts = {}) {
|
|
|
19318
19318
|
mediaType,
|
|
19319
19319
|
...rawHash ? { raw: rawHash } : {}
|
|
19320
19320
|
});
|
|
19321
|
-
upsert(lock,
|
|
19321
|
+
upsert(lock, key3, { outputs: mergeOutputs(entry.outputs, outputs) });
|
|
19322
19322
|
await saveLock(lockPath, lock);
|
|
19323
19323
|
await rename7(tmp, target);
|
|
19324
19324
|
wrote = true;
|
|
@@ -19327,13 +19327,13 @@ async function fetchAssets(provider, specs, lock, lockPath, opts = {}) {
|
|
|
19327
19327
|
if (opts.refresh && !wrote) {
|
|
19328
19328
|
if (rotated) {
|
|
19329
19329
|
const persistent = sources.filter((source) => shouldPersistSourceUrl(source.url));
|
|
19330
|
-
upsert(lock,
|
|
19330
|
+
upsert(lock, key3, { sourceUrl: persistent[0]?.url ?? null, sourceUrls: persistent });
|
|
19331
19331
|
}
|
|
19332
19332
|
result.unchanged = (result.unchanged ?? 0) + 1;
|
|
19333
19333
|
continue;
|
|
19334
19334
|
}
|
|
19335
19335
|
const persistentSources = sources.filter((source) => shouldPersistSourceUrl(source.url));
|
|
19336
|
-
upsert(lock,
|
|
19336
|
+
upsert(lock, key3, {
|
|
19337
19337
|
status: "downloaded",
|
|
19338
19338
|
provider: provider.id,
|
|
19339
19339
|
outputs,
|
|
@@ -19350,13 +19350,13 @@ async function fetchAssets(provider, specs, lock, lockPath, opts = {}) {
|
|
|
19350
19350
|
result.downloaded++;
|
|
19351
19351
|
} catch (err) {
|
|
19352
19352
|
const message6 = err instanceof Error ? err.message : String(err);
|
|
19353
|
-
upsert(lock,
|
|
19353
|
+
upsert(lock, key3, {
|
|
19354
19354
|
status: "download-failed",
|
|
19355
19355
|
outputs: mergeOutputs(entry.outputs, outputs),
|
|
19356
19356
|
error: `download failed: ${message6}`
|
|
19357
19357
|
});
|
|
19358
19358
|
result.failed++;
|
|
19359
|
-
log(` FAILED ${
|
|
19359
|
+
log(` FAILED ${key3}: ${message6}`);
|
|
19360
19360
|
}
|
|
19361
19361
|
await saveLock(lockPath, lock);
|
|
19362
19362
|
}
|
|
@@ -19405,8 +19405,8 @@ async function pushTags(provider, specs, lock, opts = {}) {
|
|
|
19405
19405
|
});
|
|
19406
19406
|
const specByKey = new Map(specs.map((s) => [lockKey(s.styleId, s.assetId), s]));
|
|
19407
19407
|
let tagged = 0;
|
|
19408
|
-
for (const [
|
|
19409
|
-
const spec = specByKey.get(
|
|
19408
|
+
for (const [key3, entry] of Object.entries(lock.entries)) {
|
|
19409
|
+
const spec = specByKey.get(key3);
|
|
19410
19410
|
if (!spec || entry.provider !== provider.id || !entry.objectId) continue;
|
|
19411
19411
|
if (entry.generator === "pixflux" || entry.generator === "vfx") continue;
|
|
19412
19412
|
if (!provider.setTags) return tagged;
|
|
@@ -19414,7 +19414,7 @@ async function pushTags(provider, specs, lock, opts = {}) {
|
|
|
19414
19414
|
await provider.setTags(entry.objectId, spec.tags, entry.generator);
|
|
19415
19415
|
tagged++;
|
|
19416
19416
|
} catch (err) {
|
|
19417
|
-
log(` tag failed ${
|
|
19417
|
+
log(` tag failed ${key3}: ${err instanceof Error ? err.message : String(err)}`);
|
|
19418
19418
|
}
|
|
19419
19419
|
}
|
|
19420
19420
|
return tagged;
|
|
@@ -19500,15 +19500,15 @@ function pickHistory(entry, selector) {
|
|
|
19500
19500
|
return matches[0];
|
|
19501
19501
|
}
|
|
19502
19502
|
async function revertGeneration(provider, spec, lock, lockPath, opts) {
|
|
19503
|
-
const
|
|
19504
|
-
const entry = lock.entries[
|
|
19505
|
-
if (!entry) throw new Error(`${
|
|
19503
|
+
const key3 = lockKey(spec.styleId, spec.assetId);
|
|
19504
|
+
const entry = lock.entries[key3];
|
|
19505
|
+
if (!entry) throw new Error(`${key3} is not in the lockfile`);
|
|
19506
19506
|
if (entry.status !== "downloaded") {
|
|
19507
|
-
throw new Error(`${
|
|
19507
|
+
throw new Error(`${key3} is ${entry.status}; finish or fetch the current generation before restoring an older one`);
|
|
19508
19508
|
}
|
|
19509
19509
|
const { index, generation } = pickHistory(entry, opts.generation);
|
|
19510
19510
|
if (generation.provider !== provider.id) {
|
|
19511
|
-
throw new Error(`${
|
|
19511
|
+
throw new Error(`${key3}'s previous generation #${index} came from ${generation.provider}, not ${provider.id}`);
|
|
19512
19512
|
}
|
|
19513
19513
|
for (let i = 0; i < entry.outputs.length; i++) {
|
|
19514
19514
|
const file = currentEntryOutputPath(entry, spec, i);
|
|
@@ -19523,7 +19523,7 @@ async function revertGeneration(provider, spec, lock, lockPath, opts) {
|
|
|
19523
19523
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
19524
19524
|
const remaining = (entry.history ?? []).filter((_, i) => i !== index - 1);
|
|
19525
19525
|
const history = [retireGeneration(entry, now), ...remaining];
|
|
19526
|
-
upsert(lock,
|
|
19526
|
+
upsert(lock, key3, {
|
|
19527
19527
|
specHash: generation.specHash,
|
|
19528
19528
|
generator: generation.generator,
|
|
19529
19529
|
tileFeature: generation.tileFeature,
|
|
@@ -19814,7 +19814,7 @@ function packStyle(lock, styleId, manifestDir, options = {}) {
|
|
|
19814
19814
|
return { ...packed2, atlas: { ...packed2.atlas, style: styleId } };
|
|
19815
19815
|
}
|
|
19816
19816
|
const prefix = `${styleId}/`;
|
|
19817
|
-
const entries = Object.entries(lock.entries).filter(([
|
|
19817
|
+
const entries = Object.entries(lock.entries).filter(([key3]) => key3.startsWith(prefix));
|
|
19818
19818
|
const sources = options.sources ?? {};
|
|
19819
19819
|
if (!entries.length && !Object.keys(sources).length) {
|
|
19820
19820
|
throw new Error(
|
|
@@ -19833,8 +19833,8 @@ function packStyle(lock, styleId, manifestDir, options = {}) {
|
|
|
19833
19833
|
return parent ? layerSources(parent, seen.add(id)) : void 0;
|
|
19834
19834
|
};
|
|
19835
19835
|
const layered = [];
|
|
19836
|
-
for (const [
|
|
19837
|
-
const id =
|
|
19836
|
+
for (const [key3, entry] of entries) {
|
|
19837
|
+
const id = key3.slice(prefix.length);
|
|
19838
19838
|
locked.add(id);
|
|
19839
19839
|
let outputs = resolveEntryOutputs(entry, id, manifestDir);
|
|
19840
19840
|
const source = sources[id];
|
|
@@ -19925,14 +19925,14 @@ function mountSprites(placements, options) {
|
|
|
19925
19925
|
}
|
|
19926
19926
|
const byCell = /* @__PURE__ */ new Map();
|
|
19927
19927
|
for (const p of placements) {
|
|
19928
|
-
const
|
|
19929
|
-
const owner = byCell.get(
|
|
19928
|
+
const key3 = `${p.cell[0]},${p.cell[1]}`;
|
|
19929
|
+
const owner = byCell.get(key3);
|
|
19930
19930
|
if (owner) {
|
|
19931
19931
|
throw new Error(
|
|
19932
|
-
`mountSprites: "${p.id}" and "${owner}" both claim cell ${
|
|
19932
|
+
`mountSprites: "${p.id}" and "${owner}" both claim cell ${key3}; a cell has exactly one owner`
|
|
19933
19933
|
);
|
|
19934
19934
|
}
|
|
19935
|
-
byCell.set(
|
|
19935
|
+
byCell.set(key3, p.id);
|
|
19936
19936
|
}
|
|
19937
19937
|
const loaded = [];
|
|
19938
19938
|
const skipped = [];
|
|
@@ -20063,13 +20063,130 @@ function mountStyle(lock, styleId, manifestDir, mount, cells, sources = {}, outp
|
|
|
20063
20063
|
};
|
|
20064
20064
|
}
|
|
20065
20065
|
|
|
20066
|
+
// src/pipeline/connected-sets.ts
|
|
20067
|
+
var key2 = (spec) => `${spec.styleId}/${spec.assetId}`;
|
|
20068
|
+
var SIDES = ["lower", "upper"];
|
|
20069
|
+
function describe(prompt, side) {
|
|
20070
|
+
const parsed = prompt ? parseTerrainDescriptions(prompt) : null;
|
|
20071
|
+
const text = parsed?.[side];
|
|
20072
|
+
if (!text) return void 0;
|
|
20073
|
+
const clause = text.split(/[,;.]/)[0].replace(/\s+/g, " ").trim().toLowerCase();
|
|
20074
|
+
return clause ? clause.slice(0, 32).trim() : void 0;
|
|
20075
|
+
}
|
|
20076
|
+
function sideOf(name, terrainTypes) {
|
|
20077
|
+
const index = terrainTypes.indexOf(name);
|
|
20078
|
+
if (index === 0) return "lower";
|
|
20079
|
+
if (index === 1) return "upper";
|
|
20080
|
+
if (name === "transition") return "upper";
|
|
20081
|
+
throw new Error(`a tile corner is "${name}", which is not one of the set's terrains (${terrainTypes.join(", ")})`);
|
|
20082
|
+
}
|
|
20083
|
+
function mergeConnectedTerrain(members, manifestDir) {
|
|
20084
|
+
const ids = members.map((member) => member.spec.assetId);
|
|
20085
|
+
if (members.length < 2) throw new Error("a connected tileset needs at least two sets");
|
|
20086
|
+
for (const { spec } of members) {
|
|
20087
|
+
if (spec.terrainOrientation === "sidescroller") {
|
|
20088
|
+
throw new Error(
|
|
20089
|
+
`${key2(spec)} is a sidescroller set, which connects only its platform; export it on its own, without --merge-connected`
|
|
20090
|
+
);
|
|
20091
|
+
}
|
|
20092
|
+
}
|
|
20093
|
+
const tileTypes = new Set(members.map((member) => member.spec.tileType ?? ""));
|
|
20094
|
+
if (tileTypes.size > 1) {
|
|
20095
|
+
throw new Error(`connected sets ${ids.join(", ")} use different tile shapes; export them one at a time`);
|
|
20096
|
+
}
|
|
20097
|
+
const parent = /* @__PURE__ */ new Map();
|
|
20098
|
+
const find = (node) => {
|
|
20099
|
+
if (!parent.has(node)) parent.set(node, node);
|
|
20100
|
+
const above = parent.get(node);
|
|
20101
|
+
if (above === node) return node;
|
|
20102
|
+
const root = find(above);
|
|
20103
|
+
parent.set(node, root);
|
|
20104
|
+
return root;
|
|
20105
|
+
};
|
|
20106
|
+
const nodeOf = (assetId, side) => `${assetId}:${side}`;
|
|
20107
|
+
for (const { spec } of members) {
|
|
20108
|
+
for (const side of SIDES) {
|
|
20109
|
+
const other = spec.terrainConnect?.[side];
|
|
20110
|
+
if (other) parent.set(find(nodeOf(spec.assetId, side)), find(nodeOf(other.assetId, other.terrain)));
|
|
20111
|
+
}
|
|
20112
|
+
}
|
|
20113
|
+
const indexOfClass = /* @__PURE__ */ new Map();
|
|
20114
|
+
const names = [];
|
|
20115
|
+
const taken = /* @__PURE__ */ new Set();
|
|
20116
|
+
const defining = /* @__PURE__ */ new Map();
|
|
20117
|
+
for (const { spec } of members) {
|
|
20118
|
+
for (const side of SIDES) {
|
|
20119
|
+
const root = find(nodeOf(spec.assetId, side));
|
|
20120
|
+
if (!indexOfClass.has(root)) {
|
|
20121
|
+
indexOfClass.set(root, names.length);
|
|
20122
|
+
names.push("");
|
|
20123
|
+
}
|
|
20124
|
+
if (!spec.terrainConnect?.[side] && !defining.has(root)) defining.set(root, nodeOf(spec.assetId, side));
|
|
20125
|
+
}
|
|
20126
|
+
}
|
|
20127
|
+
for (const [root, index] of indexOfClass) {
|
|
20128
|
+
const node = defining.get(root) ?? root;
|
|
20129
|
+
const [assetId, side] = node.split(":");
|
|
20130
|
+
const member = members.find((candidate) => candidate.spec.assetId === assetId);
|
|
20131
|
+
const base = describe(member.spec.prompt, side) ?? `${assetId}_${side}`;
|
|
20132
|
+
let name = base;
|
|
20133
|
+
for (let n = 2; taken.has(name); n++) name = `${base} ${n}`;
|
|
20134
|
+
taken.add(name);
|
|
20135
|
+
names[index] = name;
|
|
20136
|
+
}
|
|
20137
|
+
const tiles = [];
|
|
20138
|
+
const providerRules = {};
|
|
20139
|
+
for (const { spec, entry } of members) {
|
|
20140
|
+
const metadata = entry.providerMetadata?.[entry.provider];
|
|
20141
|
+
const terrainTypes = Array.isArray(metadata?.terrainTypes) ? metadata.terrainTypes.filter((item) => typeof item === "string") : [];
|
|
20142
|
+
const terrainTiles = Array.isArray(metadata?.terrainTiles) ? metadata.terrainTiles : [];
|
|
20143
|
+
if (terrainTypes.length < 2 || !terrainTiles.length) {
|
|
20144
|
+
throw new Error(`${key2(spec)} has no terrain tile data; regenerate it before merging`);
|
|
20145
|
+
}
|
|
20146
|
+
providerRules[spec.assetId] = metadata;
|
|
20147
|
+
let outputs = resolveSpecEntryOutputs(entry, spec);
|
|
20148
|
+
if (!outputs.length) throw new Error(`${key2(spec)} has no downloaded outputs`);
|
|
20149
|
+
if (spec.source && sourceIsStem(spec.source, entry, manifestDir)) {
|
|
20150
|
+
outputs = outputs.map((output) => ({ ...output, absolutePath: sourceOutputPath(spec.source, entry, output.index, manifestDir) }));
|
|
20151
|
+
}
|
|
20152
|
+
for (const output of outputs) {
|
|
20153
|
+
const tile = (output.role ? terrainTiles.find((item) => isRecord2(item) && item.role === output.role) : void 0) ?? terrainTiles[output.index];
|
|
20154
|
+
if (!isRecord2(tile) || !isRecord2(tile.corners)) continue;
|
|
20155
|
+
const corner = (position) => {
|
|
20156
|
+
const name = tile.corners && tile.corners[position];
|
|
20157
|
+
if (typeof name !== "string") throw new Error(`${key2(spec)}: ${output.role ?? output.index} has no ${position} corner`);
|
|
20158
|
+
return indexOfClass.get(find(nodeOf(spec.assetId, sideOf(name, terrainTypes))));
|
|
20159
|
+
};
|
|
20160
|
+
tiles.push({
|
|
20161
|
+
id: `${spec.assetId}/${output.role ?? `tile-${String(output.index).padStart(2, "0")}`}`,
|
|
20162
|
+
assetId: spec.assetId,
|
|
20163
|
+
path: output.absolutePath,
|
|
20164
|
+
corners: [corner("NW"), corner("NE"), corner("SW"), corner("SE")]
|
|
20165
|
+
});
|
|
20166
|
+
}
|
|
20167
|
+
}
|
|
20168
|
+
if (!tiles.length) throw new Error(`connected sets ${ids.join(", ")} have no tiles with corner data`);
|
|
20169
|
+
return { assets: ids, terrains: names, tiles, tileType: members[0].spec.tileType, providerRules };
|
|
20170
|
+
}
|
|
20171
|
+
function tileCorners(rules, tile) {
|
|
20172
|
+
if (tile.corners) return tile.corners;
|
|
20173
|
+
if (rules.ruleType !== "corner" || tile.bitmask === void 0) return null;
|
|
20174
|
+
const mask = tile.bitmask;
|
|
20175
|
+
const corner = (bit) => (mask & 1 << bit) !== 0 ? 0 : 1;
|
|
20176
|
+
return [corner(3), corner(2), corner(1), corner(0)];
|
|
20177
|
+
}
|
|
20178
|
+
var TERRAIN_PALETTE = ["#5ab552", "#4c78a8", "#e0a458", "#a0522d", "#9b6bd1", "#d9534f", "#4fb8b8", "#8c8c8c"];
|
|
20179
|
+
var terrainColor = (index) => TERRAIN_PALETTE[index % TERRAIN_PALETTE.length];
|
|
20180
|
+
function isRecord2(value) {
|
|
20181
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
20182
|
+
}
|
|
20183
|
+
|
|
20066
20184
|
// src/pipeline/ldtk-export.ts
|
|
20067
20185
|
import { createHash as createHash6 } from "crypto";
|
|
20068
20186
|
var LDTK_JSON_VERSION = "1.5.3";
|
|
20069
20187
|
var FIRST = 1;
|
|
20070
20188
|
var SECOND = 2;
|
|
20071
|
-
var
|
|
20072
|
-
var DEMO_HEIGHT = 9;
|
|
20189
|
+
var DEMO_SIZE = { small: [12, 9], large: [16, 12] };
|
|
20073
20190
|
function ldtkRuleMatches(rule, grid, cx, cy) {
|
|
20074
20191
|
const radius = Math.floor(rule.size / 2);
|
|
20075
20192
|
for (let py = 0; py < rule.size; py++) {
|
|
@@ -20115,6 +20232,14 @@ function ldtkPattern(rules, mask) {
|
|
|
20115
20232
|
pattern[3] = value(3);
|
|
20116
20233
|
return pattern;
|
|
20117
20234
|
}
|
|
20235
|
+
function ldtkCornerPattern(corners) {
|
|
20236
|
+
const pattern = new Array(9).fill(0);
|
|
20237
|
+
pattern[4] = corners[0] + 1;
|
|
20238
|
+
pattern[5] = corners[1] + 1;
|
|
20239
|
+
pattern[7] = corners[2] + 1;
|
|
20240
|
+
pattern[8] = corners[3] + 1;
|
|
20241
|
+
return pattern;
|
|
20242
|
+
}
|
|
20118
20243
|
function resolveLdtkTiles(rules, grid) {
|
|
20119
20244
|
const out = [];
|
|
20120
20245
|
for (let cy = 0; cy < grid.height; cy++) {
|
|
@@ -20125,16 +20250,16 @@ function resolveLdtkTiles(rules, grid) {
|
|
|
20125
20250
|
}
|
|
20126
20251
|
return out;
|
|
20127
20252
|
}
|
|
20128
|
-
function demoGrid(rules, wanted) {
|
|
20253
|
+
function demoGrid(rules, wanted, width, height) {
|
|
20129
20254
|
let best = null;
|
|
20130
20255
|
let bestCovered = -1;
|
|
20131
20256
|
for (let seed = 1; seed <= 400; seed++) {
|
|
20132
20257
|
let state = seed * 2654435761 >>> 0;
|
|
20133
|
-
const cells = Array.from({ length:
|
|
20258
|
+
const cells = Array.from({ length: width * height }, () => {
|
|
20134
20259
|
state = Math.imul(state, 1664525) + 1013904223 >>> 0;
|
|
20135
20260
|
return (state >>> 16) % 100 < 52 ? FIRST : SECOND;
|
|
20136
20261
|
});
|
|
20137
|
-
const grid = { width
|
|
20262
|
+
const grid = { width, height, cells };
|
|
20138
20263
|
const covered = new Set(resolveLdtkTiles(rules, grid).map((hit) => hit.rule.uid)).size;
|
|
20139
20264
|
if (covered > bestCovered) {
|
|
20140
20265
|
best = grid;
|
|
@@ -20144,7 +20269,63 @@ function demoGrid(rules, wanted) {
|
|
|
20144
20269
|
}
|
|
20145
20270
|
return best;
|
|
20146
20271
|
}
|
|
20147
|
-
|
|
20272
|
+
function constrainedDemoGrid(rules, combos, count, outside, width, height) {
|
|
20273
|
+
const stride = width + 1;
|
|
20274
|
+
const comboList = [...combos].map((combo) => combo.split(",").map(Number));
|
|
20275
|
+
let best = null;
|
|
20276
|
+
let bestCovered = -1;
|
|
20277
|
+
for (let seed = 1; seed <= 600; seed++) {
|
|
20278
|
+
let state = seed * 2654435761 >>> 0;
|
|
20279
|
+
const random = () => {
|
|
20280
|
+
state = Math.imul(state, 1664525) + 1013904223 >>> 0;
|
|
20281
|
+
return (state >>> 8) / 16777216;
|
|
20282
|
+
};
|
|
20283
|
+
const vertices = new Array(stride * (height + 1)).fill(0);
|
|
20284
|
+
for (let x = 0; x <= width; x++) vertices[height * stride + x] = outside;
|
|
20285
|
+
for (let y = 0; y <= height; y++) vertices[y * stride + width] = outside;
|
|
20286
|
+
const at2 = (x, y) => vertices[y * stride + x];
|
|
20287
|
+
const comboAt = (x, y) => {
|
|
20288
|
+
if (x < 0 || y < 0 || x >= width || y >= height) return void 0;
|
|
20289
|
+
const painted = [at2(x, y), at2(x + 1, y), at2(x, y + 1), at2(x + 1, y + 1)];
|
|
20290
|
+
if (!comboList.some((combo) => combo.every((terrain, corner) => !painted[corner] || painted[corner] === terrain + 1))) return null;
|
|
20291
|
+
return painted.every(Boolean) ? painted.map((value) => value - 1).join(",") : void 0;
|
|
20292
|
+
};
|
|
20293
|
+
const around = (x, y) => [comboAt(x - 1, y - 1), comboAt(x, y - 1), comboAt(x - 1, y), comboAt(x, y)];
|
|
20294
|
+
const seen = /* @__PURE__ */ new Set();
|
|
20295
|
+
let ok = true;
|
|
20296
|
+
for (let y = 0; y < height && ok; y++) {
|
|
20297
|
+
for (let x = 0; x < width && ok; x++) {
|
|
20298
|
+
const options = [];
|
|
20299
|
+
for (let value = 1; value <= count; value++) {
|
|
20300
|
+
vertices[y * stride + x] = value;
|
|
20301
|
+
const made = around(x, y);
|
|
20302
|
+
if (made.includes(null)) continue;
|
|
20303
|
+
options.push({ value, fresh: made.filter((combo) => combo !== void 0 && !seen.has(combo)).length });
|
|
20304
|
+
}
|
|
20305
|
+
if (!options.length) {
|
|
20306
|
+
ok = false;
|
|
20307
|
+
break;
|
|
20308
|
+
}
|
|
20309
|
+
const best2 = Math.max(...options.map((option) => option.fresh));
|
|
20310
|
+
const pool = best2 > 0 && random() < 0.85 ? options.filter((option) => option.fresh === best2) : options;
|
|
20311
|
+
vertices[y * stride + x] = pool[Math.floor(random() * pool.length)].value;
|
|
20312
|
+
for (const combo of around(x, y)) if (combo) seen.add(combo);
|
|
20313
|
+
}
|
|
20314
|
+
}
|
|
20315
|
+
if (!ok) continue;
|
|
20316
|
+
const cells = [];
|
|
20317
|
+
for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) cells.push(at2(x, y));
|
|
20318
|
+
const grid = { width, height, cells };
|
|
20319
|
+
const covered = new Set(resolveLdtkTiles(rules, grid).map((hit) => hit.rule.uid)).size;
|
|
20320
|
+
if (covered > bestCovered) {
|
|
20321
|
+
best = grid;
|
|
20322
|
+
bestCovered = covered;
|
|
20323
|
+
}
|
|
20324
|
+
if (covered >= rules.length) break;
|
|
20325
|
+
}
|
|
20326
|
+
if (!best) throw new Error("ldtk export could not paint a preview level for these connected sets");
|
|
20327
|
+
return best;
|
|
20328
|
+
}
|
|
20148
20329
|
function buildLdtk(generic, tileType) {
|
|
20149
20330
|
const rules = generic.rules;
|
|
20150
20331
|
if (!rules || rules.ruleType === "outline") {
|
|
@@ -20162,20 +20343,27 @@ function buildLdtk(generic, tileType) {
|
|
|
20162
20343
|
const corner = rules.ruleType === "corner";
|
|
20163
20344
|
const base = identifier(generic.name.replace("/", "_"), "Tileset");
|
|
20164
20345
|
const name = base.charAt(0).toUpperCase() + base.slice(1);
|
|
20165
|
-
const
|
|
20346
|
+
const merged = rules.terrains.length > 2;
|
|
20347
|
+
const terrainNames = merged ? rules.terrains : [rules.terrains[0] ?? "feature", rules.terrains[1] ?? "background"];
|
|
20348
|
+
const [demoWidth, demoHeight] = merged ? DEMO_SIZE.large : DEMO_SIZE.small;
|
|
20166
20349
|
const columns = generic.sheet.columns;
|
|
20167
20350
|
const rows = Math.ceil(generic.tiles.length / columns);
|
|
20168
|
-
const
|
|
20351
|
+
const byAdjacency = /* @__PURE__ */ new Map();
|
|
20169
20352
|
for (const tile of generic.tiles) {
|
|
20170
|
-
|
|
20171
|
-
|
|
20172
|
-
|
|
20173
|
-
|
|
20353
|
+
const corners = corner ? tileCorners(rules, tile) : null;
|
|
20354
|
+
if (corner ? !corners : tile.bitmask === void 0) continue;
|
|
20355
|
+
const adjacency = corners ? corners.join(",") : String(tile.bitmask);
|
|
20356
|
+
const known = byAdjacency.get(adjacency);
|
|
20357
|
+
if (known) known.ids.push(tile.id);
|
|
20358
|
+
else byAdjacency.set(adjacency, { pattern: corners ? ldtkCornerPattern(corners) : ldtkPattern(rules, tile.bitmask), ids: [tile.id] });
|
|
20359
|
+
}
|
|
20360
|
+
if (!byAdjacency.size) throw new Error("ldtk export found no tiles with adjacency rules; use --format generic");
|
|
20361
|
+
const outside = merged ? FIRST : SECOND;
|
|
20174
20362
|
const tilesetUid = 1;
|
|
20175
20363
|
const sourceUid = 2;
|
|
20176
20364
|
const autoUid = 3;
|
|
20177
20365
|
const groupUid = 4;
|
|
20178
|
-
const ruleList = [...
|
|
20366
|
+
const ruleList = [...byAdjacency.values()].map(({ pattern, ids }, index) => ({
|
|
20179
20367
|
uid: 5 + index,
|
|
20180
20368
|
active: true,
|
|
20181
20369
|
size: 3,
|
|
@@ -20183,7 +20371,7 @@ function buildLdtk(generic, tileType) {
|
|
|
20183
20371
|
alpha: 1,
|
|
20184
20372
|
chance: 1,
|
|
20185
20373
|
breakOnMatch: true,
|
|
20186
|
-
pattern
|
|
20374
|
+
pattern,
|
|
20187
20375
|
flipX: false,
|
|
20188
20376
|
flipY: false,
|
|
20189
20377
|
xModulo: 1,
|
|
@@ -20200,7 +20388,7 @@ function buildLdtk(generic, tileType) {
|
|
|
20200
20388
|
tileMode: "Single",
|
|
20201
20389
|
pivotX: 0,
|
|
20202
20390
|
pivotY: 0,
|
|
20203
|
-
outOfBoundsValue:
|
|
20391
|
+
outOfBoundsValue: outside,
|
|
20204
20392
|
invalidated: false,
|
|
20205
20393
|
perlinActive: false,
|
|
20206
20394
|
perlinSeed: 1,
|
|
@@ -20214,9 +20402,10 @@ function buildLdtk(generic, tileType) {
|
|
|
20214
20402
|
return tile ? { tilesetUid, x: tile.x, y: tile.y, w: tile.width, h: tile.height } : null;
|
|
20215
20403
|
};
|
|
20216
20404
|
const full = (1 << rules.arity) - 1;
|
|
20217
|
-
const representative = (terrain) => generic.tiles.find((tile) => tile.bitmask === (terrain === 0 ? full : 0))?.id;
|
|
20405
|
+
const representative = (terrain) => corner ? generic.tiles.find((tile) => tileCorners(rules, tile)?.every((value) => value === terrain))?.id : generic.tiles.find((tile) => tile.bitmask === (terrain === 0 ? full : 0))?.id;
|
|
20218
20406
|
const shift = corner ? -Math.floor(grid / 2) : 0;
|
|
20219
20407
|
const sourceName = `${name}_${corner ? "corners" : "cells"}`;
|
|
20408
|
+
const paintList = terrainNames.map((terrainName, index) => `${terrainName} (${index + 1})`).join(", ");
|
|
20220
20409
|
const autoName = name;
|
|
20221
20410
|
const layerBase = {
|
|
20222
20411
|
guideGridWid: 0,
|
|
@@ -20245,16 +20434,16 @@ function buildLdtk(generic, tileType) {
|
|
|
20245
20434
|
identifier: sourceName,
|
|
20246
20435
|
type: "IntGrid",
|
|
20247
20436
|
uid: sourceUid,
|
|
20248
|
-
doc:
|
|
20249
|
-
uiColor:
|
|
20437
|
+
doc: `Paint ${paintList}. ` + (corner ? "Each cell is a corner where four tiles meet, so it is drawn half a tile up and left of the tiles it controls." : "Each tile looks at its own cell and the four around it."),
|
|
20438
|
+
uiColor: terrainColor(0).toUpperCase(),
|
|
20250
20439
|
...layerBase,
|
|
20251
20440
|
renderInWorldView: true,
|
|
20252
20441
|
pxOffsetX: shift,
|
|
20253
20442
|
pxOffsetY: shift,
|
|
20254
|
-
intGridValues:
|
|
20255
|
-
value,
|
|
20256
|
-
identifier: identifier(
|
|
20257
|
-
color:
|
|
20443
|
+
intGridValues: terrainNames.map((terrainName, index) => ({
|
|
20444
|
+
value: index + 1,
|
|
20445
|
+
identifier: identifier(terrainName, `terrain${index + 1}`),
|
|
20446
|
+
color: terrainColor(index).toUpperCase(),
|
|
20258
20447
|
tile: tileRect(representative(index)),
|
|
20259
20448
|
groupUid: 0
|
|
20260
20449
|
})),
|
|
@@ -20267,8 +20456,8 @@ function buildLdtk(generic, tileType) {
|
|
|
20267
20456
|
identifier: autoName,
|
|
20268
20457
|
type: "AutoLayer",
|
|
20269
20458
|
uid: autoUid,
|
|
20270
|
-
doc: `Drawn by rules from ${sourceName}: one rule for each way the two terrains can meet.`,
|
|
20271
|
-
uiColor:
|
|
20459
|
+
doc: `Drawn by rules from ${sourceName}: one rule for each way the ${merged ? "terrains" : "two terrains"} can meet.`,
|
|
20460
|
+
uiColor: terrainColor(1).toUpperCase(),
|
|
20272
20461
|
...layerBase,
|
|
20273
20462
|
renderInWorldView: true,
|
|
20274
20463
|
pxOffsetX: 0,
|
|
@@ -20289,14 +20478,21 @@ function buildLdtk(generic, tileType) {
|
|
|
20289
20478
|
}],
|
|
20290
20479
|
autoSourceLayerDefUid: sourceUid
|
|
20291
20480
|
};
|
|
20292
|
-
const level =
|
|
20481
|
+
const level = merged ? constrainedDemoGrid(
|
|
20482
|
+
ruleList,
|
|
20483
|
+
new Set(generic.tiles.flatMap((tile) => tile.corners ? [tile.corners.join(",")] : [])),
|
|
20484
|
+
terrainNames.length,
|
|
20485
|
+
outside,
|
|
20486
|
+
demoWidth,
|
|
20487
|
+
demoHeight
|
|
20488
|
+
) : demoGrid(ruleList, ruleList.length, demoWidth, demoHeight);
|
|
20293
20489
|
const hits = resolveLdtkTiles(ruleList, level);
|
|
20294
20490
|
const tileAt = (id) => ({ x: id % columns * grid, y: Math.floor(id / columns) * grid });
|
|
20295
20491
|
const instanceBase = (layerDef, offset) => ({
|
|
20296
20492
|
__identifier: layerDef.identifier,
|
|
20297
20493
|
__type: layerDef.__type,
|
|
20298
|
-
__cWid:
|
|
20299
|
-
__cHei:
|
|
20494
|
+
__cWid: demoWidth,
|
|
20495
|
+
__cHei: demoHeight,
|
|
20300
20496
|
__gridSize: grid,
|
|
20301
20497
|
__opacity: 1,
|
|
20302
20498
|
__pxTotalOffsetX: offset,
|
|
@@ -20334,8 +20530,8 @@ function buildLdtk(generic, tileType) {
|
|
|
20334
20530
|
worldLayout: "LinearHorizontal",
|
|
20335
20531
|
worldGridWidth: 256,
|
|
20336
20532
|
worldGridHeight: 256,
|
|
20337
|
-
defaultLevelWidth:
|
|
20338
|
-
defaultLevelHeight:
|
|
20533
|
+
defaultLevelWidth: demoWidth * grid,
|
|
20534
|
+
defaultLevelHeight: demoHeight * grid,
|
|
20339
20535
|
defaultPivotX: 0,
|
|
20340
20536
|
defaultPivotY: 0,
|
|
20341
20537
|
defaultGridSize: grid,
|
|
@@ -20375,7 +20571,7 @@ function buildLdtk(generic, tileType) {
|
|
|
20375
20571
|
tags: [],
|
|
20376
20572
|
tagsSourceEnumUid: null,
|
|
20377
20573
|
enumTags: [],
|
|
20378
|
-
customData: generic.tiles.filter((tile) => tile.bitmask !== void 0).map((tile) => ({ tileId: tile.id, data: `mask=${tile.bitmask}` })),
|
|
20574
|
+
customData: generic.tiles.filter((tile) => tile.bitmask !== void 0 || tile.corners !== void 0).map((tile) => ({ tileId: tile.id, data: tile.corners ? `corners=${tile.corners.join(",")}` : `mask=${tile.bitmask}` })),
|
|
20379
20575
|
savedSelections: [],
|
|
20380
20576
|
cachedPixelData: null
|
|
20381
20577
|
}],
|
|
@@ -20391,8 +20587,8 @@ function buildLdtk(generic, tileType) {
|
|
|
20391
20587
|
worldX: -1,
|
|
20392
20588
|
worldY: -1,
|
|
20393
20589
|
worldDepth: 0,
|
|
20394
|
-
pxWid:
|
|
20395
|
-
pxHei:
|
|
20590
|
+
pxWid: demoWidth * grid,
|
|
20591
|
+
pxHei: demoHeight * grid,
|
|
20396
20592
|
__bgColor: "#474B67",
|
|
20397
20593
|
bgColor: null,
|
|
20398
20594
|
useAutoIdentifier: false,
|
|
@@ -20413,7 +20609,7 @@ function buildLdtk(generic, tileType) {
|
|
|
20413
20609
|
src: [tileAt(hit.tile).x, tileAt(hit.tile).y],
|
|
20414
20610
|
f: 0,
|
|
20415
20611
|
t: hit.tile,
|
|
20416
|
-
d: [hit.rule.uid, hit.cy *
|
|
20612
|
+
d: [hit.rule.uid, hit.cy * demoWidth + hit.cx],
|
|
20417
20613
|
a: 1
|
|
20418
20614
|
}))
|
|
20419
20615
|
},
|
|
@@ -20433,16 +20629,16 @@ function buildLdtk(generic, tileType) {
|
|
|
20433
20629
|
|
|
20434
20630
|
// src/pipeline/tileset-export.ts
|
|
20435
20631
|
function normalizeTileRules(raw) {
|
|
20436
|
-
if (!
|
|
20632
|
+
if (!isRecord3(raw)) return null;
|
|
20437
20633
|
const ruleType = raw.rule_type;
|
|
20438
20634
|
const arity = raw.arity;
|
|
20439
20635
|
if (ruleType !== "edge" && ruleType !== "corner" && ruleType !== "outline") return null;
|
|
20440
20636
|
if (arity !== 4 && arity !== 6) return null;
|
|
20441
20637
|
const masks = {};
|
|
20442
|
-
if (
|
|
20443
|
-
for (const [
|
|
20444
|
-
const index = tileIndex(
|
|
20445
|
-
const mask = typeof value === "number" ? value :
|
|
20638
|
+
if (isRecord3(raw.tiles)) {
|
|
20639
|
+
for (const [key3, value] of Object.entries(raw.tiles)) {
|
|
20640
|
+
const index = tileIndex(key3);
|
|
20641
|
+
const mask = typeof value === "number" ? value : isRecord3(value) && typeof value.bitmask === "number" ? value.bitmask : isRecord3(value) && typeof value.mask === "number" ? value.mask : null;
|
|
20446
20642
|
if (index !== null && mask !== null && Number.isInteger(mask) && mask >= 0) masks[index] = mask;
|
|
20447
20643
|
}
|
|
20448
20644
|
}
|
|
@@ -20458,12 +20654,12 @@ function normalizeTileRules(raw) {
|
|
|
20458
20654
|
};
|
|
20459
20655
|
}
|
|
20460
20656
|
function normalizeTerrainTiles(metadata) {
|
|
20461
|
-
if (!
|
|
20657
|
+
if (!isRecord3(metadata) || !Array.isArray(metadata.terrainTiles)) return null;
|
|
20462
20658
|
const terrains = Array.isArray(metadata.terrainTypes) ? metadata.terrainTypes.filter((item) => typeof item === "string") : [];
|
|
20463
20659
|
if (terrains.length < 2) return null;
|
|
20464
20660
|
const masks = {};
|
|
20465
20661
|
metadata.terrainTiles.forEach((tile, index) => {
|
|
20466
|
-
if (!
|
|
20662
|
+
if (!isRecord3(tile) || !isRecord3(tile.corners)) return;
|
|
20467
20663
|
const corners = tile.corners;
|
|
20468
20664
|
const bit = (corner) => corners[corner] === terrains[0] ? 1 : 0;
|
|
20469
20665
|
masks[index] = bit("NW") << 3 | bit("NE") << 2 | bit("SW") << 1 | bit("SE");
|
|
@@ -20495,13 +20691,13 @@ function exportTileset(entry, spec, options) {
|
|
|
20495
20691
|
);
|
|
20496
20692
|
}
|
|
20497
20693
|
const metadata = entry.providerMetadata?.[entry.provider];
|
|
20498
|
-
const rawRules =
|
|
20694
|
+
const rawRules = isRecord3(metadata) ? metadata.tileRules : void 0;
|
|
20499
20695
|
const terrainRules = normalizeTerrainTiles(metadata);
|
|
20500
20696
|
const rules = normalizeTileRules(rawRules) ?? terrainRules;
|
|
20501
|
-
const providerRules =
|
|
20697
|
+
const providerRules = isRecord3(rawRules) ? rawRules : terrainRules ? metadata : null;
|
|
20502
20698
|
const frames = packed.atlas.frames;
|
|
20503
20699
|
const generic = buildGeneric(
|
|
20504
|
-
spec,
|
|
20700
|
+
{ name: `${spec.styleId}/${spec.assetId}`, style: spec.styleId, asset: spec.assetId },
|
|
20505
20701
|
options.imageName,
|
|
20506
20702
|
packed.atlas,
|
|
20507
20703
|
frames,
|
|
@@ -20538,6 +20734,9 @@ function exportTileset(entry, spec, options) {
|
|
|
20538
20734
|
"godot export does not yet map edge/side adjacency onto an isometric or oblique tile's diagonal peering bits safely; use --format generic or --format tiled"
|
|
20539
20735
|
);
|
|
20540
20736
|
}
|
|
20737
|
+
return renderTileset(generic, packed, spec.tileType, options);
|
|
20738
|
+
}
|
|
20739
|
+
function renderTileset(generic, packed, tileType, options) {
|
|
20541
20740
|
if (options.format === "tiled") {
|
|
20542
20741
|
return {
|
|
20543
20742
|
png: packed.png,
|
|
@@ -20551,7 +20750,7 @@ function exportTileset(entry, spec, options) {
|
|
|
20551
20750
|
return {
|
|
20552
20751
|
png: packed.png,
|
|
20553
20752
|
extension: ".ldtk",
|
|
20554
|
-
document: buildLdtk(generic,
|
|
20753
|
+
document: buildLdtk(generic, tileType),
|
|
20555
20754
|
generic,
|
|
20556
20755
|
sources: packed.sources
|
|
20557
20756
|
};
|
|
@@ -20559,23 +20758,67 @@ function exportTileset(entry, spec, options) {
|
|
|
20559
20758
|
return {
|
|
20560
20759
|
png: packed.png,
|
|
20561
20760
|
extension: ".tres",
|
|
20562
|
-
document: buildGodot(generic,
|
|
20761
|
+
document: buildGodot(generic, tileType),
|
|
20563
20762
|
generic,
|
|
20564
20763
|
sources: packed.sources
|
|
20565
20764
|
};
|
|
20566
20765
|
}
|
|
20567
|
-
function
|
|
20766
|
+
function exportMergedTilesets(members, options) {
|
|
20767
|
+
const merged = mergeConnectedTerrain(members, options.manifestDir);
|
|
20768
|
+
const packed = packSprites(
|
|
20769
|
+
merged.tiles.map((tile) => ({ id: tile.id, path: tile.path })),
|
|
20770
|
+
{ columns: options.columns, order: "input" }
|
|
20771
|
+
);
|
|
20772
|
+
if (packed.skipped.length) {
|
|
20773
|
+
throw new Error(
|
|
20774
|
+
`Cannot export ${merged.assets.join(" + ")}: ` + packed.skipped.map((item) => `${item.id}: ${item.reason}`).join("; ")
|
|
20775
|
+
);
|
|
20776
|
+
}
|
|
20777
|
+
const rules = {
|
|
20778
|
+
ruleType: "corner",
|
|
20779
|
+
arity: 4,
|
|
20780
|
+
terrains: merged.terrains,
|
|
20781
|
+
masks: {},
|
|
20782
|
+
corners: Object.fromEntries(merged.tiles.map((tile, index) => [index, tile.corners])),
|
|
20783
|
+
raw: merged.providerRules
|
|
20784
|
+
};
|
|
20785
|
+
const styleId = members[0].spec.styleId;
|
|
20786
|
+
const asset = merged.assets.join("+");
|
|
20787
|
+
const generic = buildGeneric(
|
|
20788
|
+
{ name: `${styleId}/${asset}`, style: styleId, asset, sets: merged.assets },
|
|
20789
|
+
options.imageName,
|
|
20790
|
+
packed.atlas,
|
|
20791
|
+
packed.atlas.frames,
|
|
20792
|
+
merged.providerRules,
|
|
20793
|
+
rules,
|
|
20794
|
+
new Map(merged.tiles.map((tile, index) => [tile.id, index]))
|
|
20795
|
+
);
|
|
20796
|
+
if (options.format === "generic") {
|
|
20797
|
+
return {
|
|
20798
|
+
png: packed.png,
|
|
20799
|
+
extension: ".json",
|
|
20800
|
+
document: JSON.stringify(generic, null, 2) + "\n",
|
|
20801
|
+
generic,
|
|
20802
|
+
sources: packed.sources
|
|
20803
|
+
};
|
|
20804
|
+
}
|
|
20805
|
+
assertUniformTiles(generic);
|
|
20806
|
+
return renderTileset(generic, packed, merged.tileType, options);
|
|
20807
|
+
}
|
|
20808
|
+
function buildGeneric(identity2, imageName, atlas, frames, providerRules, rules, indexOf) {
|
|
20568
20809
|
return {
|
|
20569
20810
|
format: "pixelkiln-tileset",
|
|
20570
20811
|
version: 1,
|
|
20571
|
-
name:
|
|
20572
|
-
style:
|
|
20573
|
-
asset:
|
|
20812
|
+
name: identity2.name,
|
|
20813
|
+
style: identity2.style,
|
|
20814
|
+
asset: identity2.asset,
|
|
20815
|
+
...identity2.sets ? { sets: identity2.sets } : {},
|
|
20574
20816
|
image: imageName,
|
|
20575
20817
|
tile: { ...atlas.cell },
|
|
20576
20818
|
sheet: { ...atlas.sheet, columns: atlas.columns },
|
|
20577
20819
|
tiles: frames.map((frame, index) => {
|
|
20578
|
-
const sourceIndex = tileIndex(frame.id) ?? index;
|
|
20820
|
+
const sourceIndex = indexOf?.get(frame.id) ?? tileIndex(frame.id) ?? index;
|
|
20821
|
+
const corners = rules?.corners?.[sourceIndex];
|
|
20579
20822
|
return {
|
|
20580
20823
|
id: index,
|
|
20581
20824
|
sourceIndex,
|
|
@@ -20585,7 +20828,8 @@ function buildGeneric(spec, imageName, atlas, frames, providerRules, rules) {
|
|
|
20585
20828
|
width: frame.width,
|
|
20586
20829
|
height: frame.height,
|
|
20587
20830
|
...rules?.masks[sourceIndex] !== void 0 ? { bitmask: rules.masks[sourceIndex] } : {},
|
|
20588
|
-
|
|
20831
|
+
...corners ? { corners } : {},
|
|
20832
|
+
stampOnly: rules ? rules.masks[sourceIndex] === void 0 && !corners : true
|
|
20589
20833
|
};
|
|
20590
20834
|
}),
|
|
20591
20835
|
providerRules,
|
|
@@ -20617,25 +20861,28 @@ function buildTiled(generic) {
|
|
|
20617
20861
|
tile: representativeTile(generic, 0),
|
|
20618
20862
|
colors: terrainNames.map((name, index) => ({
|
|
20619
20863
|
name,
|
|
20620
|
-
color: index
|
|
20864
|
+
color: terrainColor(index),
|
|
20621
20865
|
tile: representativeTile(generic, index),
|
|
20622
20866
|
probability: 1
|
|
20623
20867
|
})),
|
|
20624
20868
|
properties: rules.connectivity ? [{ name: "pixelkiln:connectivity", type: "string", value: rules.connectivity }] : [],
|
|
20625
|
-
wangtiles: generic.tiles.filter((tile) => tile.bitmask !== void 0).map((tile) => ({ tileid: tile.id, wangid: tiledWangId(rules, tile
|
|
20869
|
+
wangtiles: generic.tiles.filter((tile) => tile.bitmask !== void 0 || tile.corners !== void 0).map((tile) => ({ tileid: tile.id, wangid: tiledWangId(rules, tile) }))
|
|
20626
20870
|
}];
|
|
20627
20871
|
return tiled;
|
|
20628
20872
|
}
|
|
20629
|
-
function tiledWangId(rules,
|
|
20630
|
-
const
|
|
20631
|
-
if (
|
|
20632
|
-
|
|
20873
|
+
function tiledWangId(rules, tile) {
|
|
20874
|
+
const corners = tileCorners(rules, tile);
|
|
20875
|
+
if (corners) {
|
|
20876
|
+
const [nw, ne, sw, se] = corners;
|
|
20877
|
+
return [0, ne + 1, 0, se + 1, 0, sw + 1, 0, nw + 1];
|
|
20633
20878
|
}
|
|
20879
|
+
const mask = tile.bitmask;
|
|
20880
|
+
const bitColor = (bit) => (mask & 1 << bit) !== 0 ? 1 : 2;
|
|
20634
20881
|
return [bitColor(0), 0, bitColor(1), 0, bitColor(2), 0, bitColor(3), 0];
|
|
20635
20882
|
}
|
|
20636
|
-
function buildGodot(generic,
|
|
20883
|
+
function buildGodot(generic, tileType) {
|
|
20637
20884
|
const rules = generic.rules;
|
|
20638
|
-
const shape = godotTileShape(
|
|
20885
|
+
const shape = godotTileShape(tileType ?? "isometric");
|
|
20639
20886
|
const lines = [
|
|
20640
20887
|
`[gd_resource type="TileSet" load_steps=3 format=3]`,
|
|
20641
20888
|
"",
|
|
@@ -20649,8 +20896,8 @@ function buildGodot(generic, spec) {
|
|
|
20649
20896
|
const x = tile.id % generic.sheet.columns;
|
|
20650
20897
|
const y = Math.floor(tile.id / generic.sheet.columns);
|
|
20651
20898
|
lines.push(`${x}:${y}/0 = 0`);
|
|
20652
|
-
if (!rules || tile.bitmask === void 0 || rules.ruleType === "outline") continue;
|
|
20653
|
-
const values = godotTerrainBits(rules, tile
|
|
20899
|
+
if (!rules || tile.bitmask === void 0 && tile.corners === void 0 || rules.ruleType === "outline") continue;
|
|
20900
|
+
const values = godotTerrainBits(rules, tile, shape);
|
|
20654
20901
|
lines.push(`${x}:${y}/0/terrain_set = 0`);
|
|
20655
20902
|
lines.push(`${x}:${y}/0/terrain = ${dominantTerrain(values)}`);
|
|
20656
20903
|
for (const [side, value] of Object.entries(values)) {
|
|
@@ -20664,32 +20911,23 @@ function buildGodot(generic, spec) {
|
|
|
20664
20911
|
lines.push(`terrain_set_0/mode = ${rules.ruleType === "corner" ? 1 : 2}`);
|
|
20665
20912
|
for (const [index, name] of terrainNamesFor(rules).entries()) {
|
|
20666
20913
|
lines.push(`terrain_set_0/terrain_${index}/name = ${JSON.stringify(name)}`);
|
|
20667
|
-
lines.push(
|
|
20668
|
-
`terrain_set_0/terrain_${index}/color = ` + (index === 0 ? "Color(0.3529, 0.7098, 0.3216, 1)" : "Color(0.298, 0.4706, 0.6588, 1)")
|
|
20669
|
-
);
|
|
20914
|
+
lines.push(`terrain_set_0/terrain_${index}/color = ${godotColor(terrainColor(index))}`);
|
|
20670
20915
|
}
|
|
20671
20916
|
}
|
|
20672
20917
|
lines.push(`sources/0 = SubResource("TileSetAtlasSource_pixelkiln")`, "");
|
|
20673
20918
|
return lines.join("\n");
|
|
20674
20919
|
}
|
|
20675
|
-
function godotTerrainBits(rules,
|
|
20676
|
-
const
|
|
20677
|
-
if (
|
|
20920
|
+
function godotTerrainBits(rules, tile, shape) {
|
|
20921
|
+
const corners = tileCorners(rules, tile);
|
|
20922
|
+
if (corners) {
|
|
20923
|
+
const [nw, ne, sw, se] = corners;
|
|
20678
20924
|
if (shape === 1) {
|
|
20679
|
-
return {
|
|
20680
|
-
top_corner: terrain(3),
|
|
20681
|
-
right_corner: terrain(2),
|
|
20682
|
-
left_corner: terrain(1),
|
|
20683
|
-
bottom_corner: terrain(0)
|
|
20684
|
-
};
|
|
20925
|
+
return { top_corner: nw, right_corner: ne, left_corner: sw, bottom_corner: se };
|
|
20685
20926
|
}
|
|
20686
|
-
return {
|
|
20687
|
-
top_left_corner: terrain(3),
|
|
20688
|
-
top_right_corner: terrain(2),
|
|
20689
|
-
bottom_left_corner: terrain(1),
|
|
20690
|
-
bottom_right_corner: terrain(0)
|
|
20691
|
-
};
|
|
20927
|
+
return { top_left_corner: nw, top_right_corner: ne, bottom_left_corner: sw, bottom_right_corner: se };
|
|
20692
20928
|
}
|
|
20929
|
+
const mask = tile.bitmask;
|
|
20930
|
+
const terrain = (bit) => (mask & 1 << bit) !== 0 ? 0 : 1;
|
|
20693
20931
|
return {
|
|
20694
20932
|
top_side: terrain(0),
|
|
20695
20933
|
right_side: terrain(1),
|
|
@@ -20698,8 +20936,17 @@ function godotTerrainBits(rules, mask, shape) {
|
|
|
20698
20936
|
};
|
|
20699
20937
|
}
|
|
20700
20938
|
function dominantTerrain(values) {
|
|
20701
|
-
const
|
|
20702
|
-
|
|
20939
|
+
const counts = /* @__PURE__ */ new Map();
|
|
20940
|
+
for (const value of Object.values(values)) counts.set(value, (counts.get(value) ?? 0) + 1);
|
|
20941
|
+
let best = 0;
|
|
20942
|
+
let bestCount = -1;
|
|
20943
|
+
for (const [terrain, count] of [...counts].sort(([a], [b]) => a - b)) {
|
|
20944
|
+
if (count > bestCount) {
|
|
20945
|
+
best = terrain;
|
|
20946
|
+
bestCount = count;
|
|
20947
|
+
}
|
|
20948
|
+
}
|
|
20949
|
+
return best;
|
|
20703
20950
|
}
|
|
20704
20951
|
function godotTileShape(tileType) {
|
|
20705
20952
|
if (tileType === "isometric" || tileType === "oblique") return 1;
|
|
@@ -20708,13 +20955,21 @@ function godotTileShape(tileType) {
|
|
|
20708
20955
|
}
|
|
20709
20956
|
function representativeTile(generic, terrainIndex) {
|
|
20710
20957
|
const rules = generic.rules;
|
|
20958
|
+
if (rules.ruleType === "corner") {
|
|
20959
|
+
return generic.tiles.find((tile) => tileCorners(rules, tile)?.every((corner) => corner === terrainIndex))?.id ?? -1;
|
|
20960
|
+
}
|
|
20711
20961
|
const full = (1 << rules.arity) - 1;
|
|
20712
20962
|
const wanted = terrainIndex === 0 ? full : 0;
|
|
20713
20963
|
return generic.tiles.find((tile) => tile.bitmask === wanted)?.id ?? -1;
|
|
20714
20964
|
}
|
|
20715
20965
|
function terrainNamesFor(rules) {
|
|
20966
|
+
if (rules.terrains.length > 2) return rules.terrains;
|
|
20716
20967
|
return [rules.terrains[0] ?? "feature", rules.terrains[1] ?? "background"];
|
|
20717
20968
|
}
|
|
20969
|
+
function godotColor(hex2) {
|
|
20970
|
+
const channel = (at2) => Number((parseInt(hex2.slice(at2, at2 + 2), 16) / 255).toFixed(4));
|
|
20971
|
+
return `Color(${channel(1)}, ${channel(3)}, ${channel(5)}, 1)`;
|
|
20972
|
+
}
|
|
20718
20973
|
function assertUniformTiles(generic) {
|
|
20719
20974
|
const mismatched = generic.tiles.filter(
|
|
20720
20975
|
(tile) => tile.width !== generic.tile.width || tile.height !== generic.tile.height
|
|
@@ -20725,11 +20980,11 @@ function assertUniformTiles(generic) {
|
|
|
20725
20980
|
);
|
|
20726
20981
|
}
|
|
20727
20982
|
}
|
|
20728
|
-
function tileIndex(
|
|
20729
|
-
const match =
|
|
20983
|
+
function tileIndex(key3) {
|
|
20984
|
+
const match = key3.match(/(?:^|[_-])(\d+)$/);
|
|
20730
20985
|
return match ? Number(match[1]) : null;
|
|
20731
20986
|
}
|
|
20732
|
-
function
|
|
20987
|
+
function isRecord3(value) {
|
|
20733
20988
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
20734
20989
|
}
|
|
20735
20990
|
|
|
@@ -20941,8 +21196,8 @@ async function submit(provider, loaded, items, lock, lockPath, opts = {}) {
|
|
|
20941
21196
|
}
|
|
20942
21197
|
}
|
|
20943
21198
|
}
|
|
20944
|
-
for (const { spec, key:
|
|
20945
|
-
const estimate = estimates.get(
|
|
21199
|
+
for (const { spec, key: key3 } of items) {
|
|
21200
|
+
const estimate = estimates.get(key3);
|
|
20946
21201
|
if (spec.batch?.role === "member") {
|
|
20947
21202
|
continue;
|
|
20948
21203
|
}
|
|
@@ -20956,7 +21211,7 @@ async function submit(provider, loaded, items, lock, lockPath, opts = {}) {
|
|
|
20956
21211
|
} catch (err) {
|
|
20957
21212
|
const message6 = err instanceof Error ? err.message : String(err);
|
|
20958
21213
|
failed++;
|
|
20959
|
-
upsert(lock,
|
|
21214
|
+
upsert(lock, key3, {
|
|
20960
21215
|
styleId: spec.styleId,
|
|
20961
21216
|
assetId: spec.assetId,
|
|
20962
21217
|
specHash: spec.specHash,
|
|
@@ -20966,13 +21221,13 @@ async function submit(provider, loaded, items, lock, lockPath, opts = {}) {
|
|
|
20966
21221
|
height: spec.height,
|
|
20967
21222
|
status: "failed",
|
|
20968
21223
|
error: message6,
|
|
20969
|
-
outputs: lock.entries[
|
|
21224
|
+
outputs: lock.entries[key3]?.outputs ?? [],
|
|
20970
21225
|
cost: 0,
|
|
20971
21226
|
costUnit: spec.costUnit,
|
|
20972
21227
|
provider: provider.id
|
|
20973
21228
|
});
|
|
20974
21229
|
await saveLock(lockPath, lock);
|
|
20975
|
-
log(` FAILED ${
|
|
21230
|
+
log(` FAILED ${key3}: ${message6}`);
|
|
20976
21231
|
}
|
|
20977
21232
|
continue;
|
|
20978
21233
|
}
|
|
@@ -20984,11 +21239,11 @@ async function submit(provider, loaded, items, lock, lockPath, opts = {}) {
|
|
|
20984
21239
|
const missing = (spec.batch.memberAssetIds ?? []).filter((id) => !byKey.has(lockKey(spec.styleId, id)));
|
|
20985
21240
|
if (missing.length) {
|
|
20986
21241
|
throw new Error(
|
|
20987
|
-
`${
|
|
21242
|
+
`${key3}: batch member(s) ${missing.join(", ")} must be submitted in the same run as this leader; run without --only, or include every sibling`
|
|
20988
21243
|
);
|
|
20989
21244
|
}
|
|
20990
21245
|
}
|
|
20991
|
-
const previousEntry = lock.entries[
|
|
21246
|
+
const previousEntry = lock.entries[key3];
|
|
20992
21247
|
const resumesCheckpoint = Boolean(
|
|
20993
21248
|
previousEntry?.specHash === spec.specHash && previousEntry.provider === provider.id && previousEntry.generator === spec.generator && previousEntry.submissionComplete === false && previousEntry.jobId
|
|
20994
21249
|
);
|
|
@@ -21018,9 +21273,9 @@ async function submit(provider, loaded, items, lock, lockPath, opts = {}) {
|
|
|
21018
21273
|
const leaderGroup = motionLeader ? recordedAnimationGroup(lock.entries[lockKey(motionLeader.spec.styleId, motionLeader.spec.assetId)]) : void 0;
|
|
21019
21274
|
const motionGroup = leaderGroup?.animationGroupId && leaderGroup.animationName ? { animationGroupId: leaderGroup.animationGroupId, animationName: leaderGroup.animationName } : void 0;
|
|
21020
21275
|
if (motionLeader && !motionGroup) {
|
|
21021
|
-
log(` ${
|
|
21276
|
+
log(` ${key3}: ${motionLeader.assetId} has no animation group recorded; drawing this direction on its own`);
|
|
21022
21277
|
}
|
|
21023
|
-
upsert(lock,
|
|
21278
|
+
upsert(lock, key3, {
|
|
21024
21279
|
styleId: spec.styleId,
|
|
21025
21280
|
assetId: spec.assetId,
|
|
21026
21281
|
specHash: spec.specHash,
|
|
@@ -21132,8 +21387,8 @@ async function submit(provider, loaded, items, lock, lockPath, opts = {}) {
|
|
|
21132
21387
|
...previousMetadata ? { previousMetadata } : {},
|
|
21133
21388
|
checkpoint: async (checkpoint) => {
|
|
21134
21389
|
if (!checkpoint.jobId) throw new Error("Provider checkpoint returned an empty job id");
|
|
21135
|
-
const entry = lock.entries[
|
|
21136
|
-
upsert(lock,
|
|
21390
|
+
const entry = lock.entries[key3];
|
|
21391
|
+
upsert(lock, key3, {
|
|
21137
21392
|
jobId: checkpoint.jobId,
|
|
21138
21393
|
submissionComplete: checkpoint.complete,
|
|
21139
21394
|
reviewObjectId: checkpoint.complete && (spec.generator === "frames" || estimate.candidates > 1 && !spec.tileFeature) ? checkpoint.jobId : null,
|
|
@@ -21150,41 +21405,41 @@ async function submit(provider, loaded, items, lock, lockPath, opts = {}) {
|
|
|
21150
21405
|
await saveLock(lockPath, lock);
|
|
21151
21406
|
}
|
|
21152
21407
|
});
|
|
21153
|
-
upsert(lock,
|
|
21408
|
+
upsert(lock, key3, {
|
|
21154
21409
|
jobId,
|
|
21155
21410
|
submissionComplete: true,
|
|
21156
21411
|
// A multi-candidate generator routes through review; record the parent
|
|
21157
21412
|
// so `pick` knows where to look.
|
|
21158
21413
|
reviewObjectId: spec.generator === "frames" || estimate.candidates > 1 && !spec.tileFeature ? jobId : null,
|
|
21159
21414
|
status: "processing",
|
|
21160
|
-
providerMetadata: metadata ? { ...lock.entries[
|
|
21415
|
+
providerMetadata: metadata ? { ...lock.entries[key3].providerMetadata, [provider.id]: metadata } : lock.entries[key3].providerMetadata
|
|
21161
21416
|
});
|
|
21162
21417
|
inFlight.set(jobId, spec);
|
|
21163
21418
|
submitted++;
|
|
21164
21419
|
spent += estimate.amount;
|
|
21165
|
-
writeBatchMembers(spec,
|
|
21420
|
+
writeBatchMembers(spec, key3, null);
|
|
21166
21421
|
log(
|
|
21167
|
-
` ${
|
|
21422
|
+
` ${key3} \u2192 ${jobId} (${spec.width}x${spec.height}` + (estimate.candidates > 1 ? `, ${estimate.candidates} ${spec.tileFeature ? "outputs" : "candidates"}` : "") + `, ${estimate.amount})`
|
|
21168
21423
|
);
|
|
21169
21424
|
} catch (err) {
|
|
21170
21425
|
const message6 = err instanceof Error ? err.message : String(err);
|
|
21171
|
-
const entry = lock.entries[
|
|
21426
|
+
const entry = lock.entries[key3];
|
|
21172
21427
|
if (entry.jobId && entry.submissionComplete === true) {
|
|
21173
|
-
upsert(lock,
|
|
21428
|
+
upsert(lock, key3, { status: "processing", error: null });
|
|
21174
21429
|
inFlight.set(entry.jobId, spec);
|
|
21175
21430
|
submitted++;
|
|
21176
21431
|
spent += estimate.amount;
|
|
21177
|
-
writeBatchMembers(spec,
|
|
21178
|
-
log(` ${
|
|
21432
|
+
writeBatchMembers(spec, key3, null);
|
|
21433
|
+
log(` ${key3} \u2192 ${entry.jobId} (recovered from completed checkpoint)`);
|
|
21179
21434
|
} else {
|
|
21180
21435
|
failed++;
|
|
21181
|
-
upsert(lock,
|
|
21436
|
+
upsert(lock, key3, {
|
|
21182
21437
|
status: "failed",
|
|
21183
21438
|
error: message6,
|
|
21184
21439
|
cost: entry.jobId ? estimate.amount : 0
|
|
21185
21440
|
});
|
|
21186
|
-
writeBatchMembers(spec,
|
|
21187
|
-
log(` FAILED ${
|
|
21441
|
+
writeBatchMembers(spec, key3, message6);
|
|
21442
|
+
log(` FAILED ${key3}: ${message6}`);
|
|
21188
21443
|
}
|
|
21189
21444
|
}
|
|
21190
21445
|
await saveLock(lockPath, lock);
|
|
@@ -21215,14 +21470,14 @@ async function poll(provider, lock, lockPath, opts = {}) {
|
|
|
21215
21470
|
const selectedKeys = opts.specs ? new Set(specByKey.keys()) : null;
|
|
21216
21471
|
const result = { review: 0, completed: 0, failed: 0, stillRunning: 0 };
|
|
21217
21472
|
const incompleteSubmissions = Object.entries(lock.entries).filter(
|
|
21218
|
-
([
|
|
21473
|
+
([key3, entry]) => entry.provider === provider.id && (!selectedKeys || selectedKeys.has(key3)) && entry.jobId && entry.submissionComplete === false && (entry.status === "pending" || entry.status === "processing")
|
|
21219
21474
|
);
|
|
21220
|
-
for (const [
|
|
21221
|
-
log(` incomplete submission ${
|
|
21475
|
+
for (const [key3] of incompleteSubmissions) {
|
|
21476
|
+
log(` incomplete submission ${key3}; rerun \`pixelkiln submit\` to resume`);
|
|
21222
21477
|
}
|
|
21223
21478
|
result.stillRunning = incompleteSubmissions.length;
|
|
21224
21479
|
const pending = () => Object.entries(lock.entries).filter(
|
|
21225
|
-
([
|
|
21480
|
+
([key3, e]) => e.provider === provider.id && (!selectedKeys || selectedKeys.has(key3)) && e.jobId && e.submissionComplete !== false && (e.status === "pending" || e.status === "processing")
|
|
21226
21481
|
);
|
|
21227
21482
|
while (pending().length > 0) {
|
|
21228
21483
|
if (Date.now() - started > timeout) {
|
|
@@ -21230,16 +21485,16 @@ async function poll(provider, lock, lockPath, opts = {}) {
|
|
|
21230
21485
|
log(` timed out with ${result.stillRunning} job(s) still running; re-run \`poll\` to resume`);
|
|
21231
21486
|
break;
|
|
21232
21487
|
}
|
|
21233
|
-
for (const [
|
|
21488
|
+
for (const [key3, entry] of pending()) {
|
|
21234
21489
|
try {
|
|
21235
|
-
const currentSpec = specByKey.get(
|
|
21490
|
+
const currentSpec = specByKey.get(key3);
|
|
21236
21491
|
const state = await provider.poll(entry.jobId, entry.generator, {
|
|
21237
21492
|
tileFeature: entry.tileFeature ?? currentSpec?.tileFeature,
|
|
21238
21493
|
spec: currentSpec,
|
|
21239
21494
|
metadata: entry.providerMetadata?.[provider.id]
|
|
21240
21495
|
});
|
|
21241
21496
|
if (state.status === "review" || state.status === "review-set") {
|
|
21242
|
-
upsert(lock,
|
|
21497
|
+
upsert(lock, key3, {
|
|
21243
21498
|
status: "review",
|
|
21244
21499
|
reviewObjectId: entry.jobId,
|
|
21245
21500
|
providerMetadata: state.metadata ? {
|
|
@@ -21253,11 +21508,11 @@ async function poll(provider, lock, lockPath, opts = {}) {
|
|
|
21253
21508
|
});
|
|
21254
21509
|
result.review++;
|
|
21255
21510
|
log(
|
|
21256
|
-
state.status === "review-set" ? ` review ${
|
|
21511
|
+
state.status === "review-set" ? ` review ${key3} (${state.frameUrls.length} ordered frames)` : ` review ${key3} (${state.candidateUrls.length} candidates)`
|
|
21257
21512
|
);
|
|
21258
21513
|
} else if (state.status === "ready") {
|
|
21259
21514
|
const sourceUrls = state.sources?.length ? state.sources : state.sourceUrl ? [{ url: state.sourceUrl }] : [];
|
|
21260
|
-
upsert(lock,
|
|
21515
|
+
upsert(lock, key3, {
|
|
21261
21516
|
status: "selected",
|
|
21262
21517
|
objectId: state.objectId,
|
|
21263
21518
|
sourceUrl: sourceUrls[0]?.url ?? null,
|
|
@@ -21273,14 +21528,14 @@ async function poll(provider, lock, lockPath, opts = {}) {
|
|
|
21273
21528
|
billed: state.billed ?? entry.billed
|
|
21274
21529
|
});
|
|
21275
21530
|
result.completed++;
|
|
21276
|
-
log(` ready ${
|
|
21531
|
+
log(` ready ${key3}`);
|
|
21277
21532
|
} else if (state.status === "failed") {
|
|
21278
|
-
upsert(lock,
|
|
21533
|
+
upsert(lock, key3, { status: "failed", error: state.error });
|
|
21279
21534
|
result.failed++;
|
|
21280
|
-
log(` FAILED ${
|
|
21535
|
+
log(` FAILED ${key3}: ${state.error}`);
|
|
21281
21536
|
}
|
|
21282
21537
|
} catch (err) {
|
|
21283
|
-
log(` error polling ${
|
|
21538
|
+
log(` error polling ${key3}: ${err instanceof Error ? err.message : String(err)}`);
|
|
21284
21539
|
}
|
|
21285
21540
|
}
|
|
21286
21541
|
await saveLock(lockPath, lock);
|
|
@@ -21405,14 +21660,14 @@ async function doctor(loaded, specs, lock, lockPath, opts = {}) {
|
|
|
21405
21660
|
const outputOwners = /* @__PURE__ */ new Map();
|
|
21406
21661
|
const duplicateOutputs = [];
|
|
21407
21662
|
const specByKey = new Map(specs.map((spec) => [`${spec.styleId}/${spec.assetId}`, spec]));
|
|
21408
|
-
for (const [
|
|
21663
|
+
for (const [key3, entry] of Object.entries(lock.entries)) {
|
|
21409
21664
|
for (let index = 0; index < entry.outputs.length; index++) {
|
|
21410
21665
|
const output = entry.outputs[index];
|
|
21411
|
-
const spec = specByKey.get(
|
|
21666
|
+
const spec = specByKey.get(key3);
|
|
21412
21667
|
const absolute = spec ? currentEntryOutputPath(entry, spec, index) : resolveOutputPath(output.path, path34.dirname(lockPath));
|
|
21413
21668
|
const owner = outputOwners.get(absolute);
|
|
21414
|
-
if (owner && owner !==
|
|
21415
|
-
outputOwners.set(absolute,
|
|
21669
|
+
if (owner && owner !== key3) duplicateOutputs.push(`${output.path} (${owner}, ${key3})`);
|
|
21670
|
+
outputOwners.set(absolute, key3);
|
|
21416
21671
|
}
|
|
21417
21672
|
}
|
|
21418
21673
|
if (duplicateOutputs.length) {
|
|
@@ -21429,12 +21684,12 @@ async function doctor(loaded, specs, lock, lockPath, opts = {}) {
|
|
|
21429
21684
|
const invalidState = [];
|
|
21430
21685
|
const staleMapUrls = [];
|
|
21431
21686
|
const now = Date.now();
|
|
21432
|
-
for (const [
|
|
21687
|
+
for (const [key3, entry] of Object.entries(lock.entries)) {
|
|
21433
21688
|
if ((entry.status === "pending" || entry.status === "processing") && !entry.jobId) {
|
|
21434
|
-
invalidState.push(`${
|
|
21689
|
+
invalidState.push(`${key3} (${entry.status} without job id)`);
|
|
21435
21690
|
}
|
|
21436
21691
|
if (entry.status === "review" && !entry.reviewObjectId) {
|
|
21437
|
-
invalidState.push(`${
|
|
21692
|
+
invalidState.push(`${key3} (review without review object id)`);
|
|
21438
21693
|
}
|
|
21439
21694
|
if (entry.status !== "selected" && entry.status !== "download-failed") continue;
|
|
21440
21695
|
const hasSource = Boolean(entry.sourceUrl || entry.sourceUrls?.length);
|
|
@@ -21449,9 +21704,9 @@ async function doctor(loaded, specs, lock, lockPath, opts = {}) {
|
|
|
21449
21704
|
break;
|
|
21450
21705
|
}
|
|
21451
21706
|
}
|
|
21452
|
-
if (!hasSource && !hasCache) stranded.push(
|
|
21707
|
+
if (!hasSource && !hasCache) stranded.push(key3);
|
|
21453
21708
|
if (entry.generator === "map" && entry.submittedAt && now - Date.parse(entry.submittedAt) > 8 * 60 * 60 * 1e3) {
|
|
21454
|
-
staleMapUrls.push(
|
|
21709
|
+
staleMapUrls.push(key3);
|
|
21455
21710
|
}
|
|
21456
21711
|
}
|
|
21457
21712
|
add(
|
|
@@ -21609,14 +21864,14 @@ async function adopt(provider, specs, lock, lockPath, opts = {}) {
|
|
|
21609
21864
|
if (!hits?.length) continue;
|
|
21610
21865
|
matchedRemote.add(obj.id);
|
|
21611
21866
|
for (const spec of hits) {
|
|
21612
|
-
const
|
|
21613
|
-
const existing = lock.entries[
|
|
21867
|
+
const key3 = lockKey(spec.styleId, spec.assetId);
|
|
21868
|
+
const existing = lock.entries[key3];
|
|
21614
21869
|
if (existing?.objectId && existing.objectId !== obj.id) {
|
|
21615
|
-
ambiguous.push(`${
|
|
21870
|
+
ambiguous.push(`${key3}: already mapped to ${existing.objectId}, also matches ${obj.id}`);
|
|
21616
21871
|
continue;
|
|
21617
21872
|
}
|
|
21618
21873
|
const durableSource = shouldPersistSourceUrl(url) ? url : null;
|
|
21619
|
-
upsert(lock,
|
|
21874
|
+
upsert(lock, key3, {
|
|
21620
21875
|
styleId: spec.styleId,
|
|
21621
21876
|
assetId: spec.assetId,
|
|
21622
21877
|
// Deliberately the CURRENT spec hash: adoption declares "the file on
|
|
@@ -21643,7 +21898,7 @@ async function adopt(provider, specs, lock, lockPath, opts = {}) {
|
|
|
21643
21898
|
provider: provider.id
|
|
21644
21899
|
});
|
|
21645
21900
|
matched++;
|
|
21646
|
-
log(` adopted ${
|
|
21901
|
+
log(` adopted ${key3} \u2190 ${obj.id}`);
|
|
21647
21902
|
}
|
|
21648
21903
|
}
|
|
21649
21904
|
}
|
|
@@ -21667,15 +21922,15 @@ async function tagAdopted(provider, specs, lock, opts = {}) {
|
|
|
21667
21922
|
});
|
|
21668
21923
|
const specByKey = new Map(specs.map((s) => [lockKey(s.styleId, s.assetId), s]));
|
|
21669
21924
|
let count = 0;
|
|
21670
|
-
for (const [
|
|
21671
|
-
const spec = specByKey.get(
|
|
21925
|
+
for (const [key3, entry] of Object.entries(lock.entries)) {
|
|
21926
|
+
const spec = specByKey.get(key3);
|
|
21672
21927
|
if (!spec || !entry.objectId) continue;
|
|
21673
21928
|
if (!provider.setTags) return count;
|
|
21674
21929
|
try {
|
|
21675
21930
|
await provider.setTags(entry.objectId, spec.tags, entry.generator);
|
|
21676
21931
|
count++;
|
|
21677
21932
|
} catch (err) {
|
|
21678
|
-
log(` tag failed ${
|
|
21933
|
+
log(` tag failed ${key3}: ${err instanceof Error ? err.message : String(err)}`);
|
|
21679
21934
|
}
|
|
21680
21935
|
}
|
|
21681
21936
|
return count;
|
|
@@ -21752,18 +22007,18 @@ async function importLocal(specs, lock, lockPath, opts = {}) {
|
|
|
21752
22007
|
const imported = [];
|
|
21753
22008
|
const skipped = [];
|
|
21754
22009
|
for (const spec of specs) {
|
|
21755
|
-
const
|
|
22010
|
+
const key3 = lockKey(spec.styleId, spec.assetId);
|
|
21756
22011
|
const reason = unimportable(spec);
|
|
21757
22012
|
if (reason) {
|
|
21758
|
-
skipped.push({ key:
|
|
22013
|
+
skipped.push({ key: key3, reason });
|
|
21759
22014
|
continue;
|
|
21760
22015
|
}
|
|
21761
22016
|
if (!existsSync31(spec.outFile)) {
|
|
21762
|
-
skipped.push({ key:
|
|
22017
|
+
skipped.push({ key: key3, reason: `no file at ${spec.outFile}` });
|
|
21763
22018
|
continue;
|
|
21764
22019
|
}
|
|
21765
|
-
if (lock.entries[
|
|
21766
|
-
skipped.push({ key:
|
|
22020
|
+
if (lock.entries[key3] && !opts.force) {
|
|
22021
|
+
skipped.push({ key: key3, reason: "already in the lockfile (use --force to replace it)" });
|
|
21767
22022
|
continue;
|
|
21768
22023
|
}
|
|
21769
22024
|
let patch;
|
|
@@ -21772,20 +22027,20 @@ async function importLocal(specs, lock, lockPath, opts = {}) {
|
|
|
21772
22027
|
bytes = await readFile21(spec.outFile);
|
|
21773
22028
|
patch = buildImportedEntry(spec, bytes, { ...opts, rawSha256 }, /* @__PURE__ */ new Date());
|
|
21774
22029
|
} catch (error) {
|
|
21775
|
-
skipped.push({ key:
|
|
22030
|
+
skipped.push({ key: key3, reason: `invalid PNG: ${error instanceof Error ? error.message : String(error)}` });
|
|
21776
22031
|
continue;
|
|
21777
22032
|
}
|
|
21778
22033
|
if (opts.dryRun) {
|
|
21779
|
-
imported.push({ key:
|
|
22034
|
+
imported.push({ key: key3, entry: patch });
|
|
21780
22035
|
continue;
|
|
21781
22036
|
}
|
|
21782
|
-
const existing = lock.entries[
|
|
22037
|
+
const existing = lock.entries[key3];
|
|
21783
22038
|
const history = existing?.outputs[0]?.sha256 === sha256(bytes) ? existing.history : historyAfterReplacing(existing, opts.historyLimit ?? DEFAULT_HISTORY_LIMIT, patch.downloadedAt ?? (/* @__PURE__ */ new Date()).toISOString());
|
|
21784
22039
|
if (cacheDir) {
|
|
21785
22040
|
await cacheMedia(cacheDir, bytes, MediaType.PNG);
|
|
21786
22041
|
if (rawBytes) await cacheMedia(cacheDir, rawBytes, MediaType.PNG);
|
|
21787
22042
|
}
|
|
21788
|
-
imported.push({ key:
|
|
22043
|
+
imported.push({ key: key3, entry: upsert(lock, key3, {
|
|
21789
22044
|
...patch,
|
|
21790
22045
|
// An import replaces the whole record: clear what the entry held that
|
|
21791
22046
|
// an import never has, or a regenerated entry would keep stale links.
|
|
@@ -21799,7 +22054,7 @@ async function importLocal(specs, lock, lockPath, opts = {}) {
|
|
|
21799
22054
|
async function reportSpecHashes(specs, lock) {
|
|
21800
22055
|
const reports = [];
|
|
21801
22056
|
for (const spec of specs) {
|
|
21802
|
-
const
|
|
22057
|
+
const key3 = lockKey(spec.styleId, spec.assetId);
|
|
21803
22058
|
let bytes = null;
|
|
21804
22059
|
if (existsSync31(spec.outFile)) bytes = await readFile21(spec.outFile);
|
|
21805
22060
|
let wouldImport = null;
|
|
@@ -21810,11 +22065,11 @@ async function reportSpecHashes(specs, lock) {
|
|
|
21810
22065
|
wouldImport = null;
|
|
21811
22066
|
}
|
|
21812
22067
|
}
|
|
21813
|
-
const entry = lock.entries[
|
|
22068
|
+
const entry = lock.entries[key3];
|
|
21814
22069
|
const fileSha256 = bytes ? sha256(bytes) : null;
|
|
21815
22070
|
const outputSha256 = entry?.outputs[0]?.sha256 ?? null;
|
|
21816
22071
|
reports.push({
|
|
21817
|
-
key:
|
|
22072
|
+
key: key3,
|
|
21818
22073
|
specHash: spec.specHash,
|
|
21819
22074
|
file: spec.outFile,
|
|
21820
22075
|
fileSha256,
|
|
@@ -22458,11 +22713,11 @@ async function prepareReview(provider, lock, opts = {}) {
|
|
|
22458
22713
|
const prefix = opts.routePrefix ?? "";
|
|
22459
22714
|
const providerUrls = /* @__PURE__ */ new Map();
|
|
22460
22715
|
const groups = [];
|
|
22461
|
-
for (const [
|
|
22462
|
-
if (entry.provider !== provider.id || selectedKeys && !selectedKeys.has(
|
|
22716
|
+
for (const [key3, entry] of Object.entries(lock.entries)) {
|
|
22717
|
+
if (entry.provider !== provider.id || selectedKeys && !selectedKeys.has(key3)) continue;
|
|
22463
22718
|
if (entry.status !== "review" || !entry.reviewObjectId) continue;
|
|
22464
22719
|
try {
|
|
22465
|
-
const spec = specByKey.get(
|
|
22720
|
+
const spec = specByKey.get(key3);
|
|
22466
22721
|
const state = await provider.poll(entry.reviewObjectId, entry.generator, { spec, metadata: entry.providerMetadata?.[provider.id] });
|
|
22467
22722
|
if (state.status !== "review" && state.status !== "review-set" || (state.status === "review" ? !state.candidateUrls.length : !state.frameUrls.length)) continue;
|
|
22468
22723
|
const urls = state.status === "review" ? state.candidateUrls : state.frameUrls;
|
|
@@ -22494,9 +22749,9 @@ async function prepareReview(provider, lock, opts = {}) {
|
|
|
22494
22749
|
reviewAssets.set(currentRoute, { path: current.path, contentType: current.contentType });
|
|
22495
22750
|
}
|
|
22496
22751
|
for (const [route, asset] of frameAssets) reviewAssets.set(route, asset);
|
|
22497
|
-
providerUrls.set(
|
|
22752
|
+
providerUrls.set(key3, urls);
|
|
22498
22753
|
groups.push({
|
|
22499
|
-
key:
|
|
22754
|
+
key: key3,
|
|
22500
22755
|
assetId: entry.assetId,
|
|
22501
22756
|
styleId: entry.styleId,
|
|
22502
22757
|
prompt: entry.prompt,
|
|
@@ -22526,7 +22781,7 @@ async function prepareReview(provider, lock, opts = {}) {
|
|
|
22526
22781
|
...entry.batch?.index != null ? { recommendedIndex: entry.batch.index } : {}
|
|
22527
22782
|
});
|
|
22528
22783
|
} catch (err) {
|
|
22529
|
-
log(` could not load candidates for ${
|
|
22784
|
+
log(` could not load candidates for ${key3}: ${err instanceof Error ? err.message : String(err)}`);
|
|
22530
22785
|
}
|
|
22531
22786
|
}
|
|
22532
22787
|
if (groups.length === 0) return null;
|
|
@@ -22538,18 +22793,18 @@ async function prepareReview(provider, lock, opts = {}) {
|
|
|
22538
22793
|
apply: async (body, lockPath) => {
|
|
22539
22794
|
const { selections } = body;
|
|
22540
22795
|
let selected = 0;
|
|
22541
|
-
for (const { key:
|
|
22542
|
-
const group = byKey.get(
|
|
22543
|
-
const entry = lock.entries[
|
|
22796
|
+
for (const { key: key3, index } of selections) {
|
|
22797
|
+
const group = byKey.get(key3);
|
|
22798
|
+
const entry = lock.entries[key3];
|
|
22544
22799
|
if (!group || !entry?.reviewObjectId) continue;
|
|
22545
22800
|
if (!Number.isInteger(index) || index < 0 || index >= group.frameUrls.length) continue;
|
|
22546
22801
|
if (group.mode === "frame-set") {
|
|
22547
|
-
const spec = specByKey.get(
|
|
22802
|
+
const spec = specByKey.get(key3);
|
|
22548
22803
|
const state = await provider.poll(entry.reviewObjectId, entry.generator, { spec, metadata: entry.providerMetadata?.[provider.id] });
|
|
22549
22804
|
if (state.status !== "review-set") {
|
|
22550
|
-
throw new Error(`Frame set ${
|
|
22805
|
+
throw new Error(`Frame set ${key3} is no longer ready for review`);
|
|
22551
22806
|
}
|
|
22552
|
-
upsert(lock,
|
|
22807
|
+
upsert(lock, key3, {
|
|
22553
22808
|
status: "selected",
|
|
22554
22809
|
objectId: state.objectId,
|
|
22555
22810
|
candidateIndex: null,
|
|
@@ -22565,7 +22820,7 @@ async function prepareReview(provider, lock, opts = {}) {
|
|
|
22565
22820
|
} : entry.providerMetadata
|
|
22566
22821
|
});
|
|
22567
22822
|
selected++;
|
|
22568
|
-
log(` accepted ${
|
|
22823
|
+
log(` accepted ${key3} \u2192 ${state.sources.length} ordered frames`);
|
|
22569
22824
|
continue;
|
|
22570
22825
|
}
|
|
22571
22826
|
const { objectId, sourceUrl, metadata } = await requireSelectCandidate(provider)(
|
|
@@ -22574,11 +22829,11 @@ async function prepareReview(provider, lock, opts = {}) {
|
|
|
22574
22829
|
`asset:${entry.assetId}`,
|
|
22575
22830
|
entry.generator
|
|
22576
22831
|
);
|
|
22577
|
-
upsert(lock,
|
|
22832
|
+
upsert(lock, key3, {
|
|
22578
22833
|
status: "selected",
|
|
22579
22834
|
objectId,
|
|
22580
22835
|
candidateIndex: index,
|
|
22581
|
-
sourceUrl: sourceUrl ?? providerUrls.get(
|
|
22836
|
+
sourceUrl: sourceUrl ?? providerUrls.get(key3)?.[index] ?? null,
|
|
22582
22837
|
sourceUrls: [],
|
|
22583
22838
|
provider: provider.id,
|
|
22584
22839
|
providerMetadata: metadata ? {
|
|
@@ -22590,7 +22845,7 @@ async function prepareReview(provider, lock, opts = {}) {
|
|
|
22590
22845
|
} : entry.providerMetadata
|
|
22591
22846
|
});
|
|
22592
22847
|
selected++;
|
|
22593
|
-
log(` picked ${
|
|
22848
|
+
log(` picked ${key3} \u2192 candidate ${index + 1}`);
|
|
22594
22849
|
}
|
|
22595
22850
|
await saveLock(lockPath, lock);
|
|
22596
22851
|
return { selected, skipped: groups.length - selected };
|
|
@@ -23241,9 +23496,9 @@ function styleProvider(raw, styleId, seen = /* @__PURE__ */ new Set()) {
|
|
|
23241
23496
|
seen.add(styleId);
|
|
23242
23497
|
return style.extends ? styleProvider(raw, style.extends, seen) : raw.provider ?? "pixellab";
|
|
23243
23498
|
}
|
|
23244
|
-
function setOrDelete(target,
|
|
23245
|
-
if (value === null || value === void 0) delete target[
|
|
23246
|
-
else target[
|
|
23499
|
+
function setOrDelete(target, key3, value) {
|
|
23500
|
+
if (value === null || value === void 0) delete target[key3];
|
|
23501
|
+
else target[key3] = value;
|
|
23247
23502
|
}
|
|
23248
23503
|
function assetStyles(raw, asset) {
|
|
23249
23504
|
const own = Array.isArray(asset.styles) ? asset.styles : [];
|
|
@@ -23485,21 +23740,21 @@ function handEditMembers(loaded, spec, lock, editPath) {
|
|
|
23485
23740
|
return [{ role: null, path: editPath, base: bases?.[0]?.path ?? null }];
|
|
23486
23741
|
}
|
|
23487
23742
|
function refuseUneditable(spec) {
|
|
23488
|
-
const
|
|
23743
|
+
const key3 = `${spec.styleId}/${spec.assetId}`;
|
|
23489
23744
|
if (spec.derive) {
|
|
23490
23745
|
const from = spec.derive.source.kind === "asset" ? spec.derive.source.assetId : spec.derive.source.file;
|
|
23491
23746
|
throw new ManifestEditError(
|
|
23492
|
-
`${
|
|
23747
|
+
`${key3} is derived from ${from} (${spec.derive.transform}), so it has no hand edit of its own; edit its source, or change the derive transform in the manifest`
|
|
23493
23748
|
);
|
|
23494
23749
|
}
|
|
23495
23750
|
if (spec.external) {
|
|
23496
23751
|
throw new ManifestEditError(
|
|
23497
|
-
`${
|
|
23752
|
+
`${key3} is built outside pixelkiln (${spec.external.builder}); change it there, then run pixelkiln adopt --local --force to record the new file`
|
|
23498
23753
|
);
|
|
23499
23754
|
}
|
|
23500
23755
|
if (spec.mirror) {
|
|
23501
23756
|
throw new ManifestEditError(
|
|
23502
|
-
`${
|
|
23757
|
+
`${key3} is a flip of ${spec.mirror.sourceAssetId}, so it has no hand edit of its own; edit ${spec.mirror.sourceAssetId} and flip it again`
|
|
23503
23758
|
);
|
|
23504
23759
|
}
|
|
23505
23760
|
}
|
|
@@ -24279,8 +24534,8 @@ async function adoptModelExport(model, opts = {}) {
|
|
|
24279
24534
|
for (const [index, material] of (exported.document.json.materials ?? []).entries()) {
|
|
24280
24535
|
for (const slot of slots) {
|
|
24281
24536
|
const image = slotImage(exported.document, index, slot);
|
|
24282
|
-
const
|
|
24283
|
-
if (material.name && image !== void 0 && !exportedByName.has(
|
|
24537
|
+
const key3 = `${material.name}\0${slot}`;
|
|
24538
|
+
if (material.name && image !== void 0 && !exportedByName.has(key3)) exportedByName.set(key3, image);
|
|
24284
24539
|
}
|
|
24285
24540
|
}
|
|
24286
24541
|
let document = original.document;
|
|
@@ -24499,16 +24754,16 @@ function poseNodes(document, pose) {
|
|
|
24499
24754
|
const values = readAccessor(document, sampler.output);
|
|
24500
24755
|
const width = path53 === "rotation" ? 4 : 3;
|
|
24501
24756
|
const cubic = sampler.interpolation === "CUBICSPLINE";
|
|
24502
|
-
const valueAt = (
|
|
24757
|
+
const valueAt = (key4) => Array.from(values.data.subarray((cubic ? key4 * 3 + 1 : key4) * width, (cubic ? key4 * 3 + 1 : key4) * width + width));
|
|
24503
24758
|
const last = times.length - 1;
|
|
24504
24759
|
const time = Math.min(Math.max(pose.time, times[0] ?? 0), times[last] ?? 0);
|
|
24505
|
-
let
|
|
24506
|
-
while (
|
|
24507
|
-
let value = valueAt(
|
|
24508
|
-
if (
|
|
24509
|
-
const span = times[
|
|
24510
|
-
const f = span > 0 ? (time - times[
|
|
24511
|
-
const next = valueAt(
|
|
24760
|
+
let key3 = 0;
|
|
24761
|
+
while (key3 < last && times[key3 + 1] <= time) key3++;
|
|
24762
|
+
let value = valueAt(key3);
|
|
24763
|
+
if (key3 < last && sampler.interpolation !== "STEP" && !cubic) {
|
|
24764
|
+
const span = times[key3 + 1] - times[key3];
|
|
24765
|
+
const f = span > 0 ? (time - times[key3]) / span : 0;
|
|
24766
|
+
const next = valueAt(key3 + 1);
|
|
24512
24767
|
const sign = path53 === "rotation" && value.reduce((sum, v, k) => sum + v * next[k], 0) < 0 ? -1 : 1;
|
|
24513
24768
|
value = value.map((v, k) => v * (1 - f) + next[k] * sign * f);
|
|
24514
24769
|
}
|
|
@@ -25816,14 +26071,14 @@ async function createSkeletonAnimation(manifestPath, request) {
|
|
|
25816
26071
|
}
|
|
25817
26072
|
}
|
|
25818
26073
|
async function updateSkeletonKeypoints(ctx, request) {
|
|
25819
|
-
const
|
|
25820
|
-
const spec = ctx.specs.find((candidate) => lockKey(candidate.styleId, candidate.assetId) ===
|
|
25821
|
-
if (!spec) throw new ManifestEditError(`"${
|
|
26074
|
+
const key3 = lockKey(request.styleId, request.assetId);
|
|
26075
|
+
const spec = ctx.specs.find((candidate) => lockKey(candidate.styleId, candidate.assetId) === key3);
|
|
26076
|
+
if (!spec) throw new ManifestEditError(`"${key3}" is not declared by the manifest`);
|
|
25822
26077
|
const file = spec.revision?.mode === "animate-skeleton" ? spec.revision.keypointsFile : void 0;
|
|
25823
|
-
if (!file) throw new ManifestEditError(`${
|
|
26078
|
+
if (!file) throw new ManifestEditError(`${key3} is not an animate-skeleton revision`);
|
|
25824
26079
|
const relative = path46.relative(ctx.loaded.root, file);
|
|
25825
26080
|
if (relative.startsWith("..") || path46.isAbsolute(relative)) {
|
|
25826
|
-
throw new ManifestEditError(`${
|
|
26081
|
+
throw new ManifestEditError(`${key3}'s keypoints file is outside the project; edit it by hand`);
|
|
25827
26082
|
}
|
|
25828
26083
|
const current = existsSync41(file) ? sha256(await readFile32(file)) : null;
|
|
25829
26084
|
if (current !== request.expectedSha256) {
|
|
@@ -26317,8 +26572,8 @@ async function buildGallerySnapshot(opts) {
|
|
|
26317
26572
|
} catch {
|
|
26318
26573
|
}
|
|
26319
26574
|
for (const planItem of plan.items) {
|
|
26320
|
-
const { spec, key:
|
|
26321
|
-
const entry = lock.entries[
|
|
26575
|
+
const { spec, key: key3 } = planItem;
|
|
26576
|
+
const entry = lock.entries[key3];
|
|
26322
26577
|
const asset = loaded.manifest.assets[spec.assetId] ?? null;
|
|
26323
26578
|
let outputs;
|
|
26324
26579
|
let edit = null;
|
|
@@ -26390,9 +26645,9 @@ async function buildGallerySnapshot(opts) {
|
|
|
26390
26645
|
}
|
|
26391
26646
|
const quality = planItem.quality ? await describeQuality(media, root, planItem.quality) : null;
|
|
26392
26647
|
items.push({
|
|
26393
|
-
id:
|
|
26648
|
+
id: key3,
|
|
26394
26649
|
project: null,
|
|
26395
|
-
key:
|
|
26650
|
+
key: key3,
|
|
26396
26651
|
styleId: spec.styleId,
|
|
26397
26652
|
assetId: spec.assetId,
|
|
26398
26653
|
declared: true,
|
|
@@ -26450,8 +26705,8 @@ async function buildGallerySnapshot(opts) {
|
|
|
26450
26705
|
});
|
|
26451
26706
|
}
|
|
26452
26707
|
const shown = new Set(items.map((item) => item.key));
|
|
26453
|
-
for (const [
|
|
26454
|
-
if (shown.has(
|
|
26708
|
+
for (const [key3, entry] of Object.entries(lock.entries)) {
|
|
26709
|
+
if (shown.has(key3)) continue;
|
|
26455
26710
|
if (isDeclared(loaded, entry.styleId, entry.assetId)) continue;
|
|
26456
26711
|
if (!matchesFilter(filter, entry.styleId, entry.assetId)) continue;
|
|
26457
26712
|
const outputs = await Promise.all(
|
|
@@ -26460,9 +26715,9 @@ async function buildGallerySnapshot(opts) {
|
|
|
26460
26715
|
)
|
|
26461
26716
|
);
|
|
26462
26717
|
items.push({
|
|
26463
|
-
id:
|
|
26718
|
+
id: key3,
|
|
26464
26719
|
project: null,
|
|
26465
|
-
key:
|
|
26720
|
+
key: key3,
|
|
26466
26721
|
styleId: entry.styleId,
|
|
26467
26722
|
assetId: entry.assetId,
|
|
26468
26723
|
declared: false,
|
|
@@ -26563,7 +26818,7 @@ async function buildGallerySnapshot(opts) {
|
|
|
26563
26818
|
} : null,
|
|
26564
26819
|
tags: style?.tags ?? [],
|
|
26565
26820
|
extends: typeof rawStyle?.extends === "string" ? rawStyle.extends : null,
|
|
26566
|
-
ownFields: rawStyle ? Object.keys(rawStyle).filter((
|
|
26821
|
+
ownFields: rawStyle ? Object.keys(rawStyle).filter((key3) => key3 !== "extends") : [],
|
|
26567
26822
|
items: styleItems.length,
|
|
26568
26823
|
spendByUnit: spend,
|
|
26569
26824
|
regenerate: {
|
|
@@ -27087,7 +27342,7 @@ function createGalleryEditorHandlers(opts = {}) {
|
|
|
27087
27342
|
}
|
|
27088
27343
|
return checking;
|
|
27089
27344
|
};
|
|
27090
|
-
const
|
|
27345
|
+
const describe2 = (status) => ({
|
|
27091
27346
|
...status,
|
|
27092
27347
|
pixelorama: pin.pixelorama,
|
|
27093
27348
|
protocol: pin.protocol,
|
|
@@ -27097,7 +27352,7 @@ function createGalleryEditorHandlers(opts = {}) {
|
|
|
27097
27352
|
});
|
|
27098
27353
|
return {
|
|
27099
27354
|
release: pin.release,
|
|
27100
|
-
status: async () =>
|
|
27355
|
+
status: async () => describe2(verified ?? await check()),
|
|
27101
27356
|
install: async () => {
|
|
27102
27357
|
if (!running) {
|
|
27103
27358
|
error = null;
|
|
@@ -27124,7 +27379,7 @@ function createGalleryEditorHandlers(opts = {}) {
|
|
|
27124
27379
|
running = null;
|
|
27125
27380
|
});
|
|
27126
27381
|
}
|
|
27127
|
-
return
|
|
27382
|
+
return describe2(verified ?? await check());
|
|
27128
27383
|
},
|
|
27129
27384
|
file: async (release, name) => {
|
|
27130
27385
|
if (!pin.release || release !== pin.release) return null;
|
|
@@ -27523,7 +27778,7 @@ function createGenerateHandlers(opts) {
|
|
|
27523
27778
|
const busy = /* @__PURE__ */ new Map();
|
|
27524
27779
|
for (const job of jobs.values()) {
|
|
27525
27780
|
if (job.phase === "done" || job.phase === "failed") continue;
|
|
27526
|
-
for (const
|
|
27781
|
+
for (const key3 of job.keys) busy.set(`${job.project ?? ""}:${key3}`, job.id);
|
|
27527
27782
|
}
|
|
27528
27783
|
return busy;
|
|
27529
27784
|
};
|
|
@@ -27566,7 +27821,7 @@ function createGenerateHandlers(opts) {
|
|
|
27566
27821
|
});
|
|
27567
27822
|
say(job, `${providerId}: ${res.completed} completed, ${res.review} awaiting review, ${res.failed} failed, ${res.stillRunning} still running`);
|
|
27568
27823
|
}
|
|
27569
|
-
job.review = specs.map((spec) => lockKey(spec.styleId, spec.assetId)).filter((
|
|
27824
|
+
job.review = specs.map((spec) => lockKey(spec.styleId, spec.assetId)).filter((key3) => ctx.lock.entries[key3]?.status === "review");
|
|
27570
27825
|
job.phase = "fetching";
|
|
27571
27826
|
for (const [providerId, providerSpecs] of groupByRecordedProvider(specs, ctx.lock)) {
|
|
27572
27827
|
const provider = opts.providerFor(job.project ?? void 0, providerId);
|
|
@@ -27651,7 +27906,7 @@ function createGenerateHandlers(opts) {
|
|
|
27651
27906
|
job.finishedAt = null;
|
|
27652
27907
|
const next = await opts.loadProject(job.project ?? void 0);
|
|
27653
27908
|
const byKey = new Map(next.specs.map((spec) => [lockKey(spec.styleId, spec.assetId), spec]));
|
|
27654
|
-
const nextSpecs = job.keys.map((
|
|
27909
|
+
const nextSpecs = job.keys.map((key3) => byKey.get(key3)).filter((spec) => Boolean(spec));
|
|
27655
27910
|
const plan = await buildPlan(nextSpecs, next.lock);
|
|
27656
27911
|
if (!plan.actionable.length) return finish();
|
|
27657
27912
|
for (const group of plan.groups) {
|
|
@@ -27718,21 +27973,21 @@ function createGenerateHandlers(opts) {
|
|
|
27718
27973
|
const ctx = await opts.loadProject(request.project);
|
|
27719
27974
|
const byKey = new Map(ctx.specs.map((spec) => [lockKey(spec.styleId, spec.assetId), spec]));
|
|
27720
27975
|
const specs = [];
|
|
27721
|
-
for (const
|
|
27722
|
-
const spec = byKey.get(
|
|
27723
|
-
if (!spec) throw new GenerateRequestError(`"${
|
|
27976
|
+
for (const key3 of request.keys) {
|
|
27977
|
+
const spec = byKey.get(key3);
|
|
27978
|
+
if (!spec) throw new GenerateRequestError(`"${key3}" is not declared by the manifest`);
|
|
27724
27979
|
specs.push(spec);
|
|
27725
27980
|
}
|
|
27726
27981
|
const busy = busyKeys();
|
|
27727
|
-
for (const
|
|
27728
|
-
const holder = busy.get(`${request.project ?? ""}:${
|
|
27729
|
-
if (holder) throw new GenerateRequestError(`"${
|
|
27982
|
+
for (const key3 of request.keys) {
|
|
27983
|
+
const holder = busy.get(`${request.project ?? ""}:${key3}`);
|
|
27984
|
+
if (holder) throw new GenerateRequestError(`"${key3}" is already being worked on by job ${holder}`, 409);
|
|
27730
27985
|
}
|
|
27731
27986
|
if (request.restore) {
|
|
27732
|
-
for (const
|
|
27733
|
-
const entry = ctx.lock.entries[
|
|
27987
|
+
for (const key3 of request.keys) {
|
|
27988
|
+
const entry = ctx.lock.entries[key3];
|
|
27734
27989
|
if (!entry || entry.status !== "downloaded" || !entry.outputs.length) {
|
|
27735
|
-
throw new GenerateRequestError(`"${
|
|
27990
|
+
throw new GenerateRequestError(`"${key3}" has no downloaded output recorded to restore`);
|
|
27736
27991
|
}
|
|
27737
27992
|
}
|
|
27738
27993
|
}
|
|
@@ -27975,10 +28230,10 @@ function groupOrphansByStyle(orphans, manifest, siblings = []) {
|
|
|
27975
28230
|
}
|
|
27976
28231
|
const sibling = siblings.find((s) => matchStyleByPattern(o.prompt, s.manifest));
|
|
27977
28232
|
if (sibling) {
|
|
27978
|
-
const
|
|
27979
|
-
const list = elsewhere.get(
|
|
28233
|
+
const key3 = `${sibling.label}: ${matchStyleByPattern(o.prompt, sibling.manifest)}`;
|
|
28234
|
+
const list = elsewhere.get(key3) ?? [];
|
|
27980
28235
|
list.push(o);
|
|
27981
|
-
elsewhere.set(
|
|
28236
|
+
elsewhere.set(key3, list);
|
|
27982
28237
|
continue;
|
|
27983
28238
|
}
|
|
27984
28239
|
if (ownStyleIds.length <= 1 && ownStyleIds[0]) matched.get(ownStyleIds[0]).push(o);
|
|
@@ -28676,6 +28931,7 @@ export {
|
|
|
28676
28931
|
expandObject,
|
|
28677
28932
|
expectedOutputPath,
|
|
28678
28933
|
exportAssetFile,
|
|
28934
|
+
exportMergedTilesets,
|
|
28679
28935
|
exportOutPath,
|
|
28680
28936
|
exportTileset,
|
|
28681
28937
|
fallbackOutputRole,
|
|
@@ -28885,9 +29141,11 @@ export {
|
|
|
28885
29141
|
summarize,
|
|
28886
29142
|
tagAdopted,
|
|
28887
29143
|
targetPaletteBody,
|
|
29144
|
+
terrainColor,
|
|
28888
29145
|
terrainCost,
|
|
28889
29146
|
terrainSettings,
|
|
28890
29147
|
terrainTileCount,
|
|
29148
|
+
tileCorners,
|
|
28891
29149
|
tileFeatureOutputCount,
|
|
28892
29150
|
tileVariationCount,
|
|
28893
29151
|
tilesCost,
|