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/index.js CHANGED
@@ -819,6 +819,33 @@ var StyleObjectSchema = z.object({
819
819
  * Wall storey height as its own camera angle in degrees (5-90),
820
820
  * decoupled from the ground's pitch. */
821
821
  buildingWallAngle: z.number().min(5).max(90).optional(),
822
+ /**
823
+ * `tileFeature: "building"` with `buildingLayout: "materials"` only. The
824
+ * shape of the roof pieces' edges: `gable` (a straight slope, the API
825
+ * default) or `round` (curved).
826
+ */
827
+ buildingRoofProfile: z.enum(["gable", "round"]).optional(),
828
+ /**
829
+ * `tileFeature: "tileset"` on square_topdown, isometric or oblique tiles.
830
+ * Terrain height in pixels, 0 to 12: raises the first terrain into a
831
+ * plateau with a cliff face down to the second. The API refuses a height
832
+ * that does not fit the tile's top face and wall at its size and view.
833
+ */
834
+ tileElevation: z.number().int().min(0).max(12).optional(),
835
+ /**
836
+ * `tileFeature: "tileset"` with `tileElevation` above 0. How far the drop
837
+ * spreads sideways: 0 a cliff straight down (the default) to 2 a gentle
838
+ * slope.
839
+ */
840
+ tileStepSlope: z.number().min(0).max(2).optional(),
841
+ /**
842
+ * `tileFeature: "tileset"` only. How far the border between the terrains
843
+ * meanders instead of running straight, 0 (the default) to 0.3. Tiles
844
+ * still connect seamlessly.
845
+ */
846
+ tileBoundaryAmplitude: z.number().min(0).max(0.3).optional(),
847
+ /** `tileFeature: "tileset"` with `tileBoundaryAmplitude`. Which meander: another number gives a different border. */
848
+ tileBoundarySeed: z.number().int().min(0).optional(),
822
849
  /**
823
850
  * `tiles` generator only. How tile edges are drawn.
824
851
  *
@@ -1347,6 +1374,17 @@ var AssetSchema = z.object({
1347
1374
  * (a sword hand, a parted fringe) comes out the other way round.
1348
1375
  */
1349
1376
  mirror: z.string().min(1).optional(),
1377
+ /**
1378
+ * `pixflux`, `map` and `isometricTile` styles: a PNG to start the drawing
1379
+ * from, relative to the manifest. PixelLab reworks it toward the prompt
1380
+ * instead of starting from nothing.
1381
+ */
1382
+ initImage: z.string().min(1).optional(),
1383
+ /**
1384
+ * With `initImage`: how strongly the starting image holds, 1 to 999.
1385
+ * PixelLab's default is 300.
1386
+ */
1387
+ initImageStrength: z.number().int().min(1).max(999).optional(),
1350
1388
  /**
1351
1389
  * `terrain` styles only: a PNG per terrain for PixelLab to take that
1352
1390
  * terrain's look from, paths relative to the manifest. Top-down sets
@@ -1410,6 +1448,13 @@ var AssetSchema = z.object({
1410
1448
  path: [shapes[1]]
1411
1449
  });
1412
1450
  }
1451
+ if (asset.initImageStrength !== void 0 && !asset.initImage) {
1452
+ context.addIssue({
1453
+ code: z.ZodIssueCode.custom,
1454
+ message: "initImageStrength sets how strongly initImage holds; add an initImage or drop it",
1455
+ path: ["initImageStrength"]
1456
+ });
1457
+ }
1413
1458
  for (const shape of ["derive", "external"]) {
1414
1459
  if (asset[shape] && (asset.source || Object.keys(asset.sourceByStyle).length)) {
1415
1460
  context.addIssue({
@@ -2526,6 +2571,10 @@ var PixelLabClient = class {
2526
2571
  if (args.outline) body.outline = args.outline;
2527
2572
  if (args.shading) body.shading = args.shading;
2528
2573
  if (args.detail) body.detail = args.detail;
2574
+ if (args.initImage) {
2575
+ body.init_image = { type: "base64", base64: args.initImage.base64, format: args.initImage.format };
2576
+ if (args.initImageStrength != null) body.init_image_strength = args.initImageStrength;
2577
+ }
2529
2578
  if (args.seed != null) body.seed = args.seed;
2530
2579
  if (args.scene) {
2531
2580
  const encode = (image) => ({ type: "base64", base64: image.base64, format: image.format });
@@ -2568,6 +2617,11 @@ var PixelLabClient = class {
2568
2617
  if (args.buildingFloorDescription) body.building_floor_description = args.buildingFloorDescription;
2569
2618
  if (args.buildingFloor2Description) body.building_floor2_description = args.buildingFloor2Description;
2570
2619
  if (args.buildingWallAngle != null) body.building_wall_angle = args.buildingWallAngle;
2620
+ if (args.roofProfile) body.roof_profile = args.roofProfile;
2621
+ if (args.elevation != null) body.elevation = args.elevation;
2622
+ if (args.stepSlope != null) body.step_slope = args.stepSlope;
2623
+ if (args.boundaryAmplitude != null) body.boundary_amplitude = args.boundaryAmplitude;
2624
+ if (args.boundarySeed != null) body.boundary_seed = args.boundarySeed;
2571
2625
  if (args.outlineMode) body.outline_mode = args.outlineMode;
2572
2626
  if (args.seed != null) body.seed = args.seed;
2573
2627
  if (args.styleImages?.length) body.style_images = args.styleImages;
@@ -2694,6 +2748,10 @@ var PixelLabClient = class {
2694
2748
  if (args.outline) body.outline = args.outline;
2695
2749
  if (args.shading) body.shading = args.shading;
2696
2750
  if (args.detail) body.detail = args.detail;
2751
+ if (args.initImage) {
2752
+ body.init_image = { type: "base64", base64: args.initImage.base64, format: args.initImage.format };
2753
+ if (args.initImageStrength != null) body.init_image_strength = args.initImageStrength;
2754
+ }
2697
2755
  if (args.seed != null) body.seed = args.seed;
2698
2756
  return validateResponse(
2699
2757
  IsometricTileSubmitSchema,
@@ -2818,6 +2876,10 @@ var PixelLabClient = class {
2818
2876
  if (args.paletteSwatchBase64) {
2819
2877
  body.color_image = { type: "base64", base64: args.paletteSwatchBase64, format: "png" };
2820
2878
  }
2879
+ if (args.initImage) {
2880
+ body.init_image = { type: "base64", base64: args.initImage.base64, format: args.initImage.format };
2881
+ if (args.initImageStrength != null) body.init_image_strength = args.initImageStrength;
2882
+ }
2821
2883
  if (args.seed != null) body.seed = args.seed;
2822
2884
  const res = validateResponse(
2823
2885
  PixfluxResponseSchema,
@@ -4616,6 +4678,12 @@ function specHash(spec, styleImageHashes, providerOptionIdentity = spec.provider
4616
4678
  tileType: spec.tileType,
4617
4679
  tileView: spec.tileView,
4618
4680
  tileFeature: spec.tileFeature,
4681
+ // `tiles` shape options added in November 2026, each only when set.
4682
+ buildingRoofProfile: spec.buildingRoofProfile,
4683
+ tileElevation: spec.tileElevation,
4684
+ tileStepSlope: spec.tileStepSlope,
4685
+ tileBoundaryAmplitude: spec.tileBoundaryAmplitude,
4686
+ tileBoundarySeed: spec.tileBoundarySeed,
4619
4687
  outlineMode: spec.outlineMode,
4620
4688
  isometricTileSize: spec.isometricTileSize,
4621
4689
  isometricTileShape: spec.isometricTileShape,
@@ -4641,6 +4709,8 @@ function specHash(spec, styleImageHashes, providerOptionIdentity = spec.provider
4641
4709
  terrainEnhance: spec.terrainEnhance,
4642
4710
  terrainPlatformThickness: spec.terrainPlatformThickness,
4643
4711
  // Reference images enter as their bytes' hashes, never their paths.
4712
+ // The starting image by its bytes, with its strength only when set.
4713
+ initImage: spec.initImage ? { sha256: spec.initImage.sha256, strength: spec.initImage.strength } : void 0,
4644
4714
  terrainReferences: spec.terrainReferences && Object.keys(spec.terrainReferences).length ? Object.fromEntries(
4645
4715
  ["lower", "upper", "transition"].flatMap((side) => {
4646
4716
  const reference = spec.terrainReferences[side];
@@ -5946,6 +6016,7 @@ var PixelLabProvider = class _PixelLabProvider {
5946
6016
  `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)`
5947
6017
  );
5948
6018
  }
6019
+ if (spec.generator === "tiles") this.validateTileOptions(spec);
5949
6020
  const members = spec.revision?.sourceMembers;
5950
6021
  if (spec.revision && members && !MEMBER_SET_REVISION_MODES.includes(spec.revision.mode)) {
5951
6022
  throw new Error(
@@ -6217,6 +6288,31 @@ var PixelLabProvider = class _PixelLabProvider {
6217
6288
  );
6218
6289
  }
6219
6290
  }
6291
+ /** Where `/create-tiles-pro`'s newer shape options apply; elsewhere the API ignores or refuses them. */
6292
+ validateTileOptions(spec) {
6293
+ const tilesetOnly = {
6294
+ tileElevation: spec.tileElevation,
6295
+ tileStepSlope: spec.tileStepSlope,
6296
+ tileBoundaryAmplitude: spec.tileBoundaryAmplitude,
6297
+ tileBoundarySeed: spec.tileBoundarySeed
6298
+ };
6299
+ const set = Object.entries(tilesetOnly).filter(([, value]) => value != null).map(([field]) => field);
6300
+ if (set.length && spec.tileFeature !== "tileset") {
6301
+ throw new Error(`PixelLab tiles: ${set.join(", ")} shape a connectable terrain set; set tileFeature: "tileset"`);
6302
+ }
6303
+ if (spec.tileElevation != null && spec.tileElevation > 0 && spec.tileType && !["square_topdown", "isometric", "oblique"].includes(spec.tileType)) {
6304
+ throw new Error(`PixelLab tiles: tileElevation raises a plateau on square_topdown, isometric or oblique tiles, not "${spec.tileType}"`);
6305
+ }
6306
+ if (spec.tileStepSlope != null && !(spec.tileElevation != null && spec.tileElevation > 0)) {
6307
+ throw new Error("PixelLab tiles: tileStepSlope spreads the drop of a raised terrain; set tileElevation above 0");
6308
+ }
6309
+ if (spec.tileBoundarySeed != null && spec.tileBoundaryAmplitude == null) {
6310
+ throw new Error("PixelLab tiles: tileBoundarySeed picks tileBoundaryAmplitude's meander; set both or neither");
6311
+ }
6312
+ if (spec.buildingRoofProfile && !(spec.tileFeature === "building" && spec.buildingLayout === "materials")) {
6313
+ throw new Error(`PixelLab tiles: buildingRoofProfile shapes a building kit's roof pieces; set tileFeature: "building" with buildingLayout: "materials"`);
6314
+ }
6315
+ }
6220
6316
  /** `/create-tileset`'s own rules, beyond the enums both terrain endpoints share. */
6221
6317
  validateTopDownTerrain(spec) {
6222
6318
  if (spec.terrainShapeStyle && spec.terrainMode === "pro") {
@@ -7082,7 +7178,8 @@ var PixelLabProvider = class _PixelLabProvider {
7082
7178
  height: spec.height,
7083
7179
  noBackground: spec.noBackground,
7084
7180
  paletteSwatchBase64: swatch,
7085
- seed: spec.seed
7181
+ seed: spec.seed,
7182
+ ...await initImageArgs(spec)
7086
7183
  });
7087
7184
  const jobId = randomUUID();
7088
7185
  writeFileSync(path3.join(_PixelLabProvider.cacheDir(), `${jobId}.png`), png);
@@ -7106,6 +7203,11 @@ var PixelLabProvider = class _PixelLabProvider {
7106
7203
  buildingFloorDescription: spec.buildingFloorDescription,
7107
7204
  buildingFloor2Description: spec.buildingFloor2Description,
7108
7205
  buildingWallAngle: spec.buildingWallAngle,
7206
+ roofProfile: spec.buildingRoofProfile,
7207
+ elevation: spec.tileElevation,
7208
+ stepSlope: spec.tileStepSlope,
7209
+ boundaryAmplitude: spec.tileBoundaryAmplitude,
7210
+ boundarySeed: spec.tileBoundarySeed,
7109
7211
  outlineMode: spec.outlineMode,
7110
7212
  seed: spec.seed,
7111
7213
  // TilesProStyleImage is flat and wants the reference's real dimensions,
@@ -7195,7 +7297,8 @@ var PixelLabProvider = class _PixelLabProvider {
7195
7297
  outline: spec.outline,
7196
7298
  shading: spec.shading,
7197
7299
  detail: spec.detail,
7198
- seed: spec.seed
7300
+ seed: spec.seed,
7301
+ ...await initImageArgs(spec)
7199
7302
  });
7200
7303
  return { jobId: res2.tile_id, metadata: { backgroundJobId: res2.background_job_id } };
7201
7304
  }
@@ -7239,6 +7342,7 @@ var PixelLabProvider = class _PixelLabProvider {
7239
7342
  shading: spec.shading,
7240
7343
  detail: spec.detail,
7241
7344
  seed: spec.seed,
7345
+ ...await initImageArgs(spec),
7242
7346
  scene: spec.scene ? mapScenePayload(spec) : void 0
7243
7347
  });
7244
7348
  return { jobId: res.object_id, metadata: { backgroundJobId: res.background_job_id } };
@@ -8367,6 +8471,16 @@ function sendsTargetPalette(spec) {
8367
8471
  return false;
8368
8472
  }
8369
8473
  }
8474
+ async function initImageArgs(spec) {
8475
+ const init = spec.initImage;
8476
+ if (!init) return {};
8477
+ if (!existsSync3(init.file)) throw new Error(`init image is missing: ${init.file}`);
8478
+ const bytes = readFileSync(init.file);
8479
+ if (sha256(bytes) !== init.sha256) {
8480
+ throw new Error(`init image changed after the manifest was resolved: ${init.file}; run the command again`);
8481
+ }
8482
+ return { initImage: { base64: bytes.toString("base64"), format: "png" }, ...init.strength == null ? {} : { initImageStrength: init.strength } };
8483
+ }
8370
8484
  async function terrainReferenceImage(spec, side) {
8371
8485
  const reference = spec.terrainReferences?.[side];
8372
8486
  if (!reference) return void 0;
@@ -11644,6 +11758,11 @@ async function resolveSpecs(loaded, filter) {
11644
11758
  buildingFloorDescription: generator === "tiles" ? style.buildingFloorDescription : void 0,
11645
11759
  buildingFloor2Description: generator === "tiles" ? style.buildingFloor2Description : void 0,
11646
11760
  buildingWallAngle: generator === "tiles" ? style.buildingWallAngle : void 0,
11761
+ buildingRoofProfile: generator === "tiles" ? style.buildingRoofProfile : void 0,
11762
+ tileElevation: generator === "tiles" ? style.tileElevation : void 0,
11763
+ tileStepSlope: generator === "tiles" ? style.tileStepSlope : void 0,
11764
+ tileBoundaryAmplitude: generator === "tiles" ? style.tileBoundaryAmplitude : void 0,
11765
+ tileBoundarySeed: generator === "tiles" ? style.tileBoundarySeed : void 0,
11647
11766
  outlineMode: generator === "tiles" ? style.outlineMode : void 0,
11648
11767
  terrainLowerDescription: generator === "terrain" ? terrainLowerDescription : void 0,
11649
11768
  terrainUpperDescription: generator === "terrain" ? terrainUpperDescription : void 0,
@@ -12105,6 +12224,23 @@ async function resolveSpecs(loaded, filter) {
12105
12224
  }
12106
12225
  resolved.terrainConnect = links;
12107
12226
  }
12227
+ if (asset.initImage) {
12228
+ if (!["pixflux", "map", "isometricTile"].includes(resolved.generator)) {
12229
+ throw new Error(
12230
+ `assets.${assetId}.initImage: a starting image is taken by pixflux, map and isometricTile styles; style "${styleId}" uses "${resolved.generator}"`
12231
+ );
12232
+ }
12233
+ const file = path8.resolve(root, asset.initImage);
12234
+ const image = await optionalRevisionImage(file, "init image", "png");
12235
+ if (!image) throw new Error(`assets.${assetId}.initImage: ${asset.initImage} is missing or not a PNG`);
12236
+ resolved.initImage = {
12237
+ file,
12238
+ sha256: image?.hash ?? null,
12239
+ width: image?.width ?? null,
12240
+ height: image?.height ?? null,
12241
+ ...asset.initImageStrength == null ? {} : { strength: asset.initImageStrength }
12242
+ };
12243
+ }
12108
12244
  if (asset.terrainReferences) {
12109
12245
  if (resolved.generator !== "terrain") {
12110
12246
  throw new Error(`assets.${assetId}.terrainReferences: only a terrain set takes terrain references; style "${styleId}" uses "${resolved.generator}"`);