pixelkiln 0.99.0 → 0.101.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 CHANGED
@@ -1335,6 +1335,12 @@ function specHash(spec, styleImageHashes, providerOptionIdentity = spec.provider
1335
1335
  tileType: spec.tileType,
1336
1336
  tileView: spec.tileView,
1337
1337
  tileFeature: spec.tileFeature,
1338
+ // `tiles` shape options added in November 2026, each only when set.
1339
+ buildingRoofProfile: spec.buildingRoofProfile,
1340
+ tileElevation: spec.tileElevation,
1341
+ tileStepSlope: spec.tileStepSlope,
1342
+ tileBoundaryAmplitude: spec.tileBoundaryAmplitude,
1343
+ tileBoundarySeed: spec.tileBoundarySeed,
1338
1344
  outlineMode: spec.outlineMode,
1339
1345
  isometricTileSize: spec.isometricTileSize,
1340
1346
  isometricTileShape: spec.isometricTileShape,
@@ -1360,6 +1366,8 @@ function specHash(spec, styleImageHashes, providerOptionIdentity = spec.provider
1360
1366
  terrainEnhance: spec.terrainEnhance,
1361
1367
  terrainPlatformThickness: spec.terrainPlatformThickness,
1362
1368
  // Reference images enter as their bytes' hashes, never their paths.
1369
+ // The starting image by its bytes, with its strength only when set.
1370
+ initImage: spec.initImage ? { sha256: spec.initImage.sha256, strength: spec.initImage.strength } : void 0,
1363
1371
  terrainReferences: spec.terrainReferences && Object.keys(spec.terrainReferences).length ? Object.fromEntries(
1364
1372
  ["lower", "upper", "transition"].flatMap((side) => {
1365
1373
  const reference = spec.terrainReferences[side];
@@ -2361,6 +2369,33 @@ var StyleObjectSchema = z.object({
2361
2369
  * Wall storey height as its own camera angle in degrees (5-90),
2362
2370
  * decoupled from the ground's pitch. */
2363
2371
  buildingWallAngle: z.number().min(5).max(90).optional(),
2372
+ /**
2373
+ * `tileFeature: "building"` with `buildingLayout: "materials"` only. The
2374
+ * shape of the roof pieces' edges: `gable` (a straight slope, the API
2375
+ * default) or `round` (curved).
2376
+ */
2377
+ buildingRoofProfile: z.enum(["gable", "round"]).optional(),
2378
+ /**
2379
+ * `tileFeature: "tileset"` on square_topdown, isometric or oblique tiles.
2380
+ * Terrain height in pixels, 0 to 12: raises the first terrain into a
2381
+ * plateau with a cliff face down to the second. The API refuses a height
2382
+ * that does not fit the tile's top face and wall at its size and view.
2383
+ */
2384
+ tileElevation: z.number().int().min(0).max(12).optional(),
2385
+ /**
2386
+ * `tileFeature: "tileset"` with `tileElevation` above 0. How far the drop
2387
+ * spreads sideways: 0 a cliff straight down (the default) to 2 a gentle
2388
+ * slope.
2389
+ */
2390
+ tileStepSlope: z.number().min(0).max(2).optional(),
2391
+ /**
2392
+ * `tileFeature: "tileset"` only. How far the border between the terrains
2393
+ * meanders instead of running straight, 0 (the default) to 0.3. Tiles
2394
+ * still connect seamlessly.
2395
+ */
2396
+ tileBoundaryAmplitude: z.number().min(0).max(0.3).optional(),
2397
+ /** `tileFeature: "tileset"` with `tileBoundaryAmplitude`. Which meander: another number gives a different border. */
2398
+ tileBoundarySeed: z.number().int().min(0).optional(),
2364
2399
  /**
2365
2400
  * `tiles` generator only. How tile edges are drawn.
2366
2401
  *
@@ -2889,6 +2924,17 @@ var AssetSchema = z.object({
2889
2924
  * (a sword hand, a parted fringe) comes out the other way round.
2890
2925
  */
2891
2926
  mirror: z.string().min(1).optional(),
2927
+ /**
2928
+ * `pixflux`, `map` and `isometricTile` styles: a PNG to start the drawing
2929
+ * from, relative to the manifest. PixelLab reworks it toward the prompt
2930
+ * instead of starting from nothing.
2931
+ */
2932
+ initImage: z.string().min(1).optional(),
2933
+ /**
2934
+ * With `initImage`: how strongly the starting image holds, 1 to 999.
2935
+ * PixelLab's default is 300.
2936
+ */
2937
+ initImageStrength: z.number().int().min(1).max(999).optional(),
2892
2938
  /**
2893
2939
  * `terrain` styles only: a PNG per terrain for PixelLab to take that
2894
2940
  * terrain's look from, paths relative to the manifest. Top-down sets
@@ -2952,6 +2998,13 @@ var AssetSchema = z.object({
2952
2998
  path: [shapes[1]]
2953
2999
  });
2954
3000
  }
3001
+ if (asset.initImageStrength !== void 0 && !asset.initImage) {
3002
+ context.addIssue({
3003
+ code: z.ZodIssueCode.custom,
3004
+ message: "initImageStrength sets how strongly initImage holds; add an initImage or drop it",
3005
+ path: ["initImageStrength"]
3006
+ });
3007
+ }
2955
3008
  for (const shape of ["derive", "external"]) {
2956
3009
  if (asset[shape] && (asset.source || Object.keys(asset.sourceByStyle).length)) {
2957
3010
  context.addIssue({
@@ -7664,6 +7717,10 @@ var PixelLabClient = class {
7664
7717
  if (args.outline) body.outline = args.outline;
7665
7718
  if (args.shading) body.shading = args.shading;
7666
7719
  if (args.detail) body.detail = args.detail;
7720
+ if (args.initImage) {
7721
+ body.init_image = { type: "base64", base64: args.initImage.base64, format: args.initImage.format };
7722
+ if (args.initImageStrength != null) body.init_image_strength = args.initImageStrength;
7723
+ }
7667
7724
  if (args.seed != null) body.seed = args.seed;
7668
7725
  if (args.scene) {
7669
7726
  const encode = (image) => ({ type: "base64", base64: image.base64, format: image.format });
@@ -7706,6 +7763,11 @@ var PixelLabClient = class {
7706
7763
  if (args.buildingFloorDescription) body.building_floor_description = args.buildingFloorDescription;
7707
7764
  if (args.buildingFloor2Description) body.building_floor2_description = args.buildingFloor2Description;
7708
7765
  if (args.buildingWallAngle != null) body.building_wall_angle = args.buildingWallAngle;
7766
+ if (args.roofProfile) body.roof_profile = args.roofProfile;
7767
+ if (args.elevation != null) body.elevation = args.elevation;
7768
+ if (args.stepSlope != null) body.step_slope = args.stepSlope;
7769
+ if (args.boundaryAmplitude != null) body.boundary_amplitude = args.boundaryAmplitude;
7770
+ if (args.boundarySeed != null) body.boundary_seed = args.boundarySeed;
7709
7771
  if (args.outlineMode) body.outline_mode = args.outlineMode;
7710
7772
  if (args.seed != null) body.seed = args.seed;
7711
7773
  if (args.styleImages?.length) body.style_images = args.styleImages;
@@ -7832,6 +7894,10 @@ var PixelLabClient = class {
7832
7894
  if (args.outline) body.outline = args.outline;
7833
7895
  if (args.shading) body.shading = args.shading;
7834
7896
  if (args.detail) body.detail = args.detail;
7897
+ if (args.initImage) {
7898
+ body.init_image = { type: "base64", base64: args.initImage.base64, format: args.initImage.format };
7899
+ if (args.initImageStrength != null) body.init_image_strength = args.initImageStrength;
7900
+ }
7835
7901
  if (args.seed != null) body.seed = args.seed;
7836
7902
  return validateResponse(
7837
7903
  IsometricTileSubmitSchema,
@@ -7956,6 +8022,10 @@ var PixelLabClient = class {
7956
8022
  if (args.paletteSwatchBase64) {
7957
8023
  body.color_image = { type: "base64", base64: args.paletteSwatchBase64, format: "png" };
7958
8024
  }
8025
+ if (args.initImage) {
8026
+ body.init_image = { type: "base64", base64: args.initImage.base64, format: args.initImage.format };
8027
+ if (args.initImageStrength != null) body.init_image_strength = args.initImageStrength;
8028
+ }
7959
8029
  if (args.seed != null) body.seed = args.seed;
7960
8030
  const res = validateResponse(
7961
8031
  PixfluxResponseSchema,
@@ -10304,6 +10374,7 @@ var PixelLabProvider = class _PixelLabProvider {
10304
10374
  `vfx sprite ${sprite.file} is ${sprite.width}x${sprite.height}; PixelLab's VFX artist takes up to ${VFX_ARTIST_MAX_SPRITE}x${VFX_ARTIST_MAX_SPRITE} (crop or pad it; never rescale pixel art)`
10305
10375
  );
10306
10376
  }
10377
+ if (spec.generator === "tiles") this.validateTileOptions(spec);
10307
10378
  const members = spec.revision?.sourceMembers;
10308
10379
  if (spec.revision && members && !MEMBER_SET_REVISION_MODES.includes(spec.revision.mode)) {
10309
10380
  throw new Error(
@@ -10575,6 +10646,31 @@ var PixelLabProvider = class _PixelLabProvider {
10575
10646
  );
10576
10647
  }
10577
10648
  }
10649
+ /** Where `/create-tiles-pro`'s newer shape options apply; elsewhere the API ignores or refuses them. */
10650
+ validateTileOptions(spec) {
10651
+ const tilesetOnly = {
10652
+ tileElevation: spec.tileElevation,
10653
+ tileStepSlope: spec.tileStepSlope,
10654
+ tileBoundaryAmplitude: spec.tileBoundaryAmplitude,
10655
+ tileBoundarySeed: spec.tileBoundarySeed
10656
+ };
10657
+ const set = Object.entries(tilesetOnly).filter(([, value]) => value != null).map(([field]) => field);
10658
+ if (set.length && spec.tileFeature !== "tileset") {
10659
+ throw new Error(`PixelLab tiles: ${set.join(", ")} shape a connectable terrain set; set tileFeature: "tileset"`);
10660
+ }
10661
+ if (spec.tileElevation != null && spec.tileElevation > 0 && spec.tileType && !["square_topdown", "isometric", "oblique"].includes(spec.tileType)) {
10662
+ throw new Error(`PixelLab tiles: tileElevation raises a plateau on square_topdown, isometric or oblique tiles, not "${spec.tileType}"`);
10663
+ }
10664
+ if (spec.tileStepSlope != null && !(spec.tileElevation != null && spec.tileElevation > 0)) {
10665
+ throw new Error("PixelLab tiles: tileStepSlope spreads the drop of a raised terrain; set tileElevation above 0");
10666
+ }
10667
+ if (spec.tileBoundarySeed != null && spec.tileBoundaryAmplitude == null) {
10668
+ throw new Error("PixelLab tiles: tileBoundarySeed picks tileBoundaryAmplitude's meander; set both or neither");
10669
+ }
10670
+ if (spec.buildingRoofProfile && !(spec.tileFeature === "building" && spec.buildingLayout === "materials")) {
10671
+ throw new Error(`PixelLab tiles: buildingRoofProfile shapes a building kit's roof pieces; set tileFeature: "building" with buildingLayout: "materials"`);
10672
+ }
10673
+ }
10578
10674
  /** `/create-tileset`'s own rules, beyond the enums both terrain endpoints share. */
10579
10675
  validateTopDownTerrain(spec) {
10580
10676
  if (spec.terrainShapeStyle && spec.terrainMode === "pro") {
@@ -11440,7 +11536,8 @@ var PixelLabProvider = class _PixelLabProvider {
11440
11536
  height: spec.height,
11441
11537
  noBackground: spec.noBackground,
11442
11538
  paletteSwatchBase64: swatch,
11443
- seed: spec.seed
11539
+ seed: spec.seed,
11540
+ ...await initImageArgs(spec)
11444
11541
  });
11445
11542
  const jobId = randomUUID3();
11446
11543
  writeFileSync(path16.join(_PixelLabProvider.cacheDir(), `${jobId}.png`), png);
@@ -11464,6 +11561,11 @@ var PixelLabProvider = class _PixelLabProvider {
11464
11561
  buildingFloorDescription: spec.buildingFloorDescription,
11465
11562
  buildingFloor2Description: spec.buildingFloor2Description,
11466
11563
  buildingWallAngle: spec.buildingWallAngle,
11564
+ roofProfile: spec.buildingRoofProfile,
11565
+ elevation: spec.tileElevation,
11566
+ stepSlope: spec.tileStepSlope,
11567
+ boundaryAmplitude: spec.tileBoundaryAmplitude,
11568
+ boundarySeed: spec.tileBoundarySeed,
11467
11569
  outlineMode: spec.outlineMode,
11468
11570
  seed: spec.seed,
11469
11571
  // TilesProStyleImage is flat and wants the reference's real dimensions,
@@ -11553,7 +11655,8 @@ var PixelLabProvider = class _PixelLabProvider {
11553
11655
  outline: spec.outline,
11554
11656
  shading: spec.shading,
11555
11657
  detail: spec.detail,
11556
- seed: spec.seed
11658
+ seed: spec.seed,
11659
+ ...await initImageArgs(spec)
11557
11660
  });
11558
11661
  return { jobId: res2.tile_id, metadata: { backgroundJobId: res2.background_job_id } };
11559
11662
  }
@@ -11597,6 +11700,7 @@ var PixelLabProvider = class _PixelLabProvider {
11597
11700
  shading: spec.shading,
11598
11701
  detail: spec.detail,
11599
11702
  seed: spec.seed,
11703
+ ...await initImageArgs(spec),
11600
11704
  scene: spec.scene ? mapScenePayload(spec) : void 0
11601
11705
  });
11602
11706
  return { jobId: res.object_id, metadata: { backgroundJobId: res.background_job_id } };
@@ -12725,6 +12829,16 @@ function sendsTargetPalette(spec) {
12725
12829
  return false;
12726
12830
  }
12727
12831
  }
12832
+ async function initImageArgs(spec) {
12833
+ const init = spec.initImage;
12834
+ if (!init) return {};
12835
+ if (!existsSync11(init.file)) throw new Error(`init image is missing: ${init.file}`);
12836
+ const bytes = readFileSync2(init.file);
12837
+ if (sha256(bytes) !== init.sha256) {
12838
+ throw new Error(`init image changed after the manifest was resolved: ${init.file}; run the command again`);
12839
+ }
12840
+ return { initImage: { base64: bytes.toString("base64"), format: "png" }, ...init.strength == null ? {} : { initImageStrength: init.strength } };
12841
+ }
12728
12842
  async function terrainReferenceImage(spec, side) {
12729
12843
  const reference = spec.terrainReferences?.[side];
12730
12844
  if (!reference) return void 0;
@@ -14584,6 +14698,11 @@ async function resolveSpecs(loaded, filter) {
14584
14698
  buildingFloorDescription: generator === "tiles" ? style.buildingFloorDescription : void 0,
14585
14699
  buildingFloor2Description: generator === "tiles" ? style.buildingFloor2Description : void 0,
14586
14700
  buildingWallAngle: generator === "tiles" ? style.buildingWallAngle : void 0,
14701
+ buildingRoofProfile: generator === "tiles" ? style.buildingRoofProfile : void 0,
14702
+ tileElevation: generator === "tiles" ? style.tileElevation : void 0,
14703
+ tileStepSlope: generator === "tiles" ? style.tileStepSlope : void 0,
14704
+ tileBoundaryAmplitude: generator === "tiles" ? style.tileBoundaryAmplitude : void 0,
14705
+ tileBoundarySeed: generator === "tiles" ? style.tileBoundarySeed : void 0,
14587
14706
  outlineMode: generator === "tiles" ? style.outlineMode : void 0,
14588
14707
  terrainLowerDescription: generator === "terrain" ? terrainLowerDescription : void 0,
14589
14708
  terrainUpperDescription: generator === "terrain" ? terrainUpperDescription : void 0,
@@ -15045,6 +15164,23 @@ async function resolveSpecs(loaded, filter) {
15045
15164
  }
15046
15165
  resolved.terrainConnect = links;
15047
15166
  }
15167
+ if (asset.initImage) {
15168
+ if (!["pixflux", "map", "isometricTile"].includes(resolved.generator)) {
15169
+ throw new Error(
15170
+ `assets.${assetId}.initImage: a starting image is taken by pixflux, map and isometricTile styles; style "${styleId}" uses "${resolved.generator}"`
15171
+ );
15172
+ }
15173
+ const file = path18.resolve(root, asset.initImage);
15174
+ const image = await optionalRevisionImage(file, "init image", "png");
15175
+ if (!image) throw new Error(`assets.${assetId}.initImage: ${asset.initImage} is missing or not a PNG`);
15176
+ resolved.initImage = {
15177
+ file,
15178
+ sha256: image?.hash ?? null,
15179
+ width: image?.width ?? null,
15180
+ height: image?.height ?? null,
15181
+ ...asset.initImageStrength == null ? {} : { strength: asset.initImageStrength }
15182
+ };
15183
+ }
15048
15184
  if (asset.terrainReferences) {
15049
15185
  if (resolved.generator !== "terrain") {
15050
15186
  throw new Error(`assets.${assetId}.terrainReferences: only a terrain set takes terrain references; style "${styleId}" uses "${resolved.generator}"`);