pixelkiln 0.99.0 → 0.100.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 +64 -2
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +64 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +78 -0
- package/dist/index.d.ts +78 -0
- package/dist/index.js +64 -2
- package/dist/index.js.map +1 -1
- package/docs/ENDPOINTS.md +30 -3
- package/docs/MANIFEST.md +39 -0
- package/package.json +1 -1
- package/schema/manifest.schema.json +9 -0
package/dist/cli.js
CHANGED
|
@@ -1360,6 +1360,8 @@ function specHash(spec, styleImageHashes, providerOptionIdentity = spec.provider
|
|
|
1360
1360
|
terrainEnhance: spec.terrainEnhance,
|
|
1361
1361
|
terrainPlatformThickness: spec.terrainPlatformThickness,
|
|
1362
1362
|
// Reference images enter as their bytes' hashes, never their paths.
|
|
1363
|
+
// The starting image by its bytes, with its strength only when set.
|
|
1364
|
+
initImage: spec.initImage ? { sha256: spec.initImage.sha256, strength: spec.initImage.strength } : void 0,
|
|
1363
1365
|
terrainReferences: spec.terrainReferences && Object.keys(spec.terrainReferences).length ? Object.fromEntries(
|
|
1364
1366
|
["lower", "upper", "transition"].flatMap((side) => {
|
|
1365
1367
|
const reference = spec.terrainReferences[side];
|
|
@@ -2889,6 +2891,17 @@ var AssetSchema = z.object({
|
|
|
2889
2891
|
* (a sword hand, a parted fringe) comes out the other way round.
|
|
2890
2892
|
*/
|
|
2891
2893
|
mirror: z.string().min(1).optional(),
|
|
2894
|
+
/**
|
|
2895
|
+
* `pixflux`, `map` and `isometricTile` styles: a PNG to start the drawing
|
|
2896
|
+
* from, relative to the manifest. PixelLab reworks it toward the prompt
|
|
2897
|
+
* instead of starting from nothing.
|
|
2898
|
+
*/
|
|
2899
|
+
initImage: z.string().min(1).optional(),
|
|
2900
|
+
/**
|
|
2901
|
+
* With `initImage`: how strongly the starting image holds, 1 to 999.
|
|
2902
|
+
* PixelLab's default is 300.
|
|
2903
|
+
*/
|
|
2904
|
+
initImageStrength: z.number().int().min(1).max(999).optional(),
|
|
2892
2905
|
/**
|
|
2893
2906
|
* `terrain` styles only: a PNG per terrain for PixelLab to take that
|
|
2894
2907
|
* terrain's look from, paths relative to the manifest. Top-down sets
|
|
@@ -2952,6 +2965,13 @@ var AssetSchema = z.object({
|
|
|
2952
2965
|
path: [shapes[1]]
|
|
2953
2966
|
});
|
|
2954
2967
|
}
|
|
2968
|
+
if (asset.initImageStrength !== void 0 && !asset.initImage) {
|
|
2969
|
+
context.addIssue({
|
|
2970
|
+
code: z.ZodIssueCode.custom,
|
|
2971
|
+
message: "initImageStrength sets how strongly initImage holds; add an initImage or drop it",
|
|
2972
|
+
path: ["initImageStrength"]
|
|
2973
|
+
});
|
|
2974
|
+
}
|
|
2955
2975
|
for (const shape of ["derive", "external"]) {
|
|
2956
2976
|
if (asset[shape] && (asset.source || Object.keys(asset.sourceByStyle).length)) {
|
|
2957
2977
|
context.addIssue({
|
|
@@ -7664,6 +7684,10 @@ var PixelLabClient = class {
|
|
|
7664
7684
|
if (args.outline) body.outline = args.outline;
|
|
7665
7685
|
if (args.shading) body.shading = args.shading;
|
|
7666
7686
|
if (args.detail) body.detail = args.detail;
|
|
7687
|
+
if (args.initImage) {
|
|
7688
|
+
body.init_image = { type: "base64", base64: args.initImage.base64, format: args.initImage.format };
|
|
7689
|
+
if (args.initImageStrength != null) body.init_image_strength = args.initImageStrength;
|
|
7690
|
+
}
|
|
7667
7691
|
if (args.seed != null) body.seed = args.seed;
|
|
7668
7692
|
if (args.scene) {
|
|
7669
7693
|
const encode = (image) => ({ type: "base64", base64: image.base64, format: image.format });
|
|
@@ -7832,6 +7856,10 @@ var PixelLabClient = class {
|
|
|
7832
7856
|
if (args.outline) body.outline = args.outline;
|
|
7833
7857
|
if (args.shading) body.shading = args.shading;
|
|
7834
7858
|
if (args.detail) body.detail = args.detail;
|
|
7859
|
+
if (args.initImage) {
|
|
7860
|
+
body.init_image = { type: "base64", base64: args.initImage.base64, format: args.initImage.format };
|
|
7861
|
+
if (args.initImageStrength != null) body.init_image_strength = args.initImageStrength;
|
|
7862
|
+
}
|
|
7835
7863
|
if (args.seed != null) body.seed = args.seed;
|
|
7836
7864
|
return validateResponse(
|
|
7837
7865
|
IsometricTileSubmitSchema,
|
|
@@ -7956,6 +7984,10 @@ var PixelLabClient = class {
|
|
|
7956
7984
|
if (args.paletteSwatchBase64) {
|
|
7957
7985
|
body.color_image = { type: "base64", base64: args.paletteSwatchBase64, format: "png" };
|
|
7958
7986
|
}
|
|
7987
|
+
if (args.initImage) {
|
|
7988
|
+
body.init_image = { type: "base64", base64: args.initImage.base64, format: args.initImage.format };
|
|
7989
|
+
if (args.initImageStrength != null) body.init_image_strength = args.initImageStrength;
|
|
7990
|
+
}
|
|
7959
7991
|
if (args.seed != null) body.seed = args.seed;
|
|
7960
7992
|
const res = validateResponse(
|
|
7961
7993
|
PixfluxResponseSchema,
|
|
@@ -11440,7 +11472,8 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
11440
11472
|
height: spec.height,
|
|
11441
11473
|
noBackground: spec.noBackground,
|
|
11442
11474
|
paletteSwatchBase64: swatch,
|
|
11443
|
-
seed: spec.seed
|
|
11475
|
+
seed: spec.seed,
|
|
11476
|
+
...await initImageArgs(spec)
|
|
11444
11477
|
});
|
|
11445
11478
|
const jobId = randomUUID3();
|
|
11446
11479
|
writeFileSync(path16.join(_PixelLabProvider.cacheDir(), `${jobId}.png`), png);
|
|
@@ -11553,7 +11586,8 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
11553
11586
|
outline: spec.outline,
|
|
11554
11587
|
shading: spec.shading,
|
|
11555
11588
|
detail: spec.detail,
|
|
11556
|
-
seed: spec.seed
|
|
11589
|
+
seed: spec.seed,
|
|
11590
|
+
...await initImageArgs(spec)
|
|
11557
11591
|
});
|
|
11558
11592
|
return { jobId: res2.tile_id, metadata: { backgroundJobId: res2.background_job_id } };
|
|
11559
11593
|
}
|
|
@@ -11597,6 +11631,7 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
11597
11631
|
shading: spec.shading,
|
|
11598
11632
|
detail: spec.detail,
|
|
11599
11633
|
seed: spec.seed,
|
|
11634
|
+
...await initImageArgs(spec),
|
|
11600
11635
|
scene: spec.scene ? mapScenePayload(spec) : void 0
|
|
11601
11636
|
});
|
|
11602
11637
|
return { jobId: res.object_id, metadata: { backgroundJobId: res.background_job_id } };
|
|
@@ -12725,6 +12760,16 @@ function sendsTargetPalette(spec) {
|
|
|
12725
12760
|
return false;
|
|
12726
12761
|
}
|
|
12727
12762
|
}
|
|
12763
|
+
async function initImageArgs(spec) {
|
|
12764
|
+
const init = spec.initImage;
|
|
12765
|
+
if (!init) return {};
|
|
12766
|
+
if (!existsSync11(init.file)) throw new Error(`init image is missing: ${init.file}`);
|
|
12767
|
+
const bytes = readFileSync2(init.file);
|
|
12768
|
+
if (sha256(bytes) !== init.sha256) {
|
|
12769
|
+
throw new Error(`init image changed after the manifest was resolved: ${init.file}; run the command again`);
|
|
12770
|
+
}
|
|
12771
|
+
return { initImage: { base64: bytes.toString("base64"), format: "png" }, ...init.strength == null ? {} : { initImageStrength: init.strength } };
|
|
12772
|
+
}
|
|
12728
12773
|
async function terrainReferenceImage(spec, side) {
|
|
12729
12774
|
const reference = spec.terrainReferences?.[side];
|
|
12730
12775
|
if (!reference) return void 0;
|
|
@@ -15045,6 +15090,23 @@ async function resolveSpecs(loaded, filter) {
|
|
|
15045
15090
|
}
|
|
15046
15091
|
resolved.terrainConnect = links;
|
|
15047
15092
|
}
|
|
15093
|
+
if (asset.initImage) {
|
|
15094
|
+
if (!["pixflux", "map", "isometricTile"].includes(resolved.generator)) {
|
|
15095
|
+
throw new Error(
|
|
15096
|
+
`assets.${assetId}.initImage: a starting image is taken by pixflux, map and isometricTile styles; style "${styleId}" uses "${resolved.generator}"`
|
|
15097
|
+
);
|
|
15098
|
+
}
|
|
15099
|
+
const file = path18.resolve(root, asset.initImage);
|
|
15100
|
+
const image = await optionalRevisionImage(file, "init image", "png");
|
|
15101
|
+
if (!image) throw new Error(`assets.${assetId}.initImage: ${asset.initImage} is missing or not a PNG`);
|
|
15102
|
+
resolved.initImage = {
|
|
15103
|
+
file,
|
|
15104
|
+
sha256: image?.hash ?? null,
|
|
15105
|
+
width: image?.width ?? null,
|
|
15106
|
+
height: image?.height ?? null,
|
|
15107
|
+
...asset.initImageStrength == null ? {} : { strength: asset.initImageStrength }
|
|
15108
|
+
};
|
|
15109
|
+
}
|
|
15048
15110
|
if (asset.terrainReferences) {
|
|
15049
15111
|
if (resolved.generator !== "terrain") {
|
|
15050
15112
|
throw new Error(`assets.${assetId}.terrainReferences: only a terrain set takes terrain references; style "${styleId}" uses "${resolved.generator}"`);
|