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.cjs CHANGED
@@ -1260,6 +1260,33 @@ var StyleObjectSchema = import_zod.z.object({
1260
1260
  * Wall storey height as its own camera angle in degrees (5-90),
1261
1261
  * decoupled from the ground's pitch. */
1262
1262
  buildingWallAngle: import_zod.z.number().min(5).max(90).optional(),
1263
+ /**
1264
+ * `tileFeature: "building"` with `buildingLayout: "materials"` only. The
1265
+ * shape of the roof pieces' edges: `gable` (a straight slope, the API
1266
+ * default) or `round` (curved).
1267
+ */
1268
+ buildingRoofProfile: import_zod.z.enum(["gable", "round"]).optional(),
1269
+ /**
1270
+ * `tileFeature: "tileset"` on square_topdown, isometric or oblique tiles.
1271
+ * Terrain height in pixels, 0 to 12: raises the first terrain into a
1272
+ * plateau with a cliff face down to the second. The API refuses a height
1273
+ * that does not fit the tile's top face and wall at its size and view.
1274
+ */
1275
+ tileElevation: import_zod.z.number().int().min(0).max(12).optional(),
1276
+ /**
1277
+ * `tileFeature: "tileset"` with `tileElevation` above 0. How far the drop
1278
+ * spreads sideways: 0 a cliff straight down (the default) to 2 a gentle
1279
+ * slope.
1280
+ */
1281
+ tileStepSlope: import_zod.z.number().min(0).max(2).optional(),
1282
+ /**
1283
+ * `tileFeature: "tileset"` only. How far the border between the terrains
1284
+ * meanders instead of running straight, 0 (the default) to 0.3. Tiles
1285
+ * still connect seamlessly.
1286
+ */
1287
+ tileBoundaryAmplitude: import_zod.z.number().min(0).max(0.3).optional(),
1288
+ /** `tileFeature: "tileset"` with `tileBoundaryAmplitude`. Which meander: another number gives a different border. */
1289
+ tileBoundarySeed: import_zod.z.number().int().min(0).optional(),
1263
1290
  /**
1264
1291
  * `tiles` generator only. How tile edges are drawn.
1265
1292
  *
@@ -1788,6 +1815,17 @@ var AssetSchema = import_zod.z.object({
1788
1815
  * (a sword hand, a parted fringe) comes out the other way round.
1789
1816
  */
1790
1817
  mirror: import_zod.z.string().min(1).optional(),
1818
+ /**
1819
+ * `pixflux`, `map` and `isometricTile` styles: a PNG to start the drawing
1820
+ * from, relative to the manifest. PixelLab reworks it toward the prompt
1821
+ * instead of starting from nothing.
1822
+ */
1823
+ initImage: import_zod.z.string().min(1).optional(),
1824
+ /**
1825
+ * With `initImage`: how strongly the starting image holds, 1 to 999.
1826
+ * PixelLab's default is 300.
1827
+ */
1828
+ initImageStrength: import_zod.z.number().int().min(1).max(999).optional(),
1791
1829
  /**
1792
1830
  * `terrain` styles only: a PNG per terrain for PixelLab to take that
1793
1831
  * terrain's look from, paths relative to the manifest. Top-down sets
@@ -1851,6 +1889,13 @@ var AssetSchema = import_zod.z.object({
1851
1889
  path: [shapes[1]]
1852
1890
  });
1853
1891
  }
1892
+ if (asset.initImageStrength !== void 0 && !asset.initImage) {
1893
+ context.addIssue({
1894
+ code: import_zod.z.ZodIssueCode.custom,
1895
+ message: "initImageStrength sets how strongly initImage holds; add an initImage or drop it",
1896
+ path: ["initImageStrength"]
1897
+ });
1898
+ }
1854
1899
  for (const shape of ["derive", "external"]) {
1855
1900
  if (asset[shape] && (asset.source || Object.keys(asset.sourceByStyle).length)) {
1856
1901
  context.addIssue({
@@ -2967,6 +3012,10 @@ var PixelLabClient = class {
2967
3012
  if (args.outline) body.outline = args.outline;
2968
3013
  if (args.shading) body.shading = args.shading;
2969
3014
  if (args.detail) body.detail = args.detail;
3015
+ if (args.initImage) {
3016
+ body.init_image = { type: "base64", base64: args.initImage.base64, format: args.initImage.format };
3017
+ if (args.initImageStrength != null) body.init_image_strength = args.initImageStrength;
3018
+ }
2970
3019
  if (args.seed != null) body.seed = args.seed;
2971
3020
  if (args.scene) {
2972
3021
  const encode = (image) => ({ type: "base64", base64: image.base64, format: image.format });
@@ -3009,6 +3058,11 @@ var PixelLabClient = class {
3009
3058
  if (args.buildingFloorDescription) body.building_floor_description = args.buildingFloorDescription;
3010
3059
  if (args.buildingFloor2Description) body.building_floor2_description = args.buildingFloor2Description;
3011
3060
  if (args.buildingWallAngle != null) body.building_wall_angle = args.buildingWallAngle;
3061
+ if (args.roofProfile) body.roof_profile = args.roofProfile;
3062
+ if (args.elevation != null) body.elevation = args.elevation;
3063
+ if (args.stepSlope != null) body.step_slope = args.stepSlope;
3064
+ if (args.boundaryAmplitude != null) body.boundary_amplitude = args.boundaryAmplitude;
3065
+ if (args.boundarySeed != null) body.boundary_seed = args.boundarySeed;
3012
3066
  if (args.outlineMode) body.outline_mode = args.outlineMode;
3013
3067
  if (args.seed != null) body.seed = args.seed;
3014
3068
  if (args.styleImages?.length) body.style_images = args.styleImages;
@@ -3135,6 +3189,10 @@ var PixelLabClient = class {
3135
3189
  if (args.outline) body.outline = args.outline;
3136
3190
  if (args.shading) body.shading = args.shading;
3137
3191
  if (args.detail) body.detail = args.detail;
3192
+ if (args.initImage) {
3193
+ body.init_image = { type: "base64", base64: args.initImage.base64, format: args.initImage.format };
3194
+ if (args.initImageStrength != null) body.init_image_strength = args.initImageStrength;
3195
+ }
3138
3196
  if (args.seed != null) body.seed = args.seed;
3139
3197
  return validateResponse(
3140
3198
  IsometricTileSubmitSchema,
@@ -3259,6 +3317,10 @@ var PixelLabClient = class {
3259
3317
  if (args.paletteSwatchBase64) {
3260
3318
  body.color_image = { type: "base64", base64: args.paletteSwatchBase64, format: "png" };
3261
3319
  }
3320
+ if (args.initImage) {
3321
+ body.init_image = { type: "base64", base64: args.initImage.base64, format: args.initImage.format };
3322
+ if (args.initImageStrength != null) body.init_image_strength = args.initImageStrength;
3323
+ }
3262
3324
  if (args.seed != null) body.seed = args.seed;
3263
3325
  const res = validateResponse(
3264
3326
  PixfluxResponseSchema,
@@ -5057,6 +5119,12 @@ function specHash(spec, styleImageHashes, providerOptionIdentity = spec.provider
5057
5119
  tileType: spec.tileType,
5058
5120
  tileView: spec.tileView,
5059
5121
  tileFeature: spec.tileFeature,
5122
+ // `tiles` shape options added in November 2026, each only when set.
5123
+ buildingRoofProfile: spec.buildingRoofProfile,
5124
+ tileElevation: spec.tileElevation,
5125
+ tileStepSlope: spec.tileStepSlope,
5126
+ tileBoundaryAmplitude: spec.tileBoundaryAmplitude,
5127
+ tileBoundarySeed: spec.tileBoundarySeed,
5060
5128
  outlineMode: spec.outlineMode,
5061
5129
  isometricTileSize: spec.isometricTileSize,
5062
5130
  isometricTileShape: spec.isometricTileShape,
@@ -5082,6 +5150,8 @@ function specHash(spec, styleImageHashes, providerOptionIdentity = spec.provider
5082
5150
  terrainEnhance: spec.terrainEnhance,
5083
5151
  terrainPlatformThickness: spec.terrainPlatformThickness,
5084
5152
  // Reference images enter as their bytes' hashes, never their paths.
5153
+ // The starting image by its bytes, with its strength only when set.
5154
+ initImage: spec.initImage ? { sha256: spec.initImage.sha256, strength: spec.initImage.strength } : void 0,
5085
5155
  terrainReferences: spec.terrainReferences && Object.keys(spec.terrainReferences).length ? Object.fromEntries(
5086
5156
  ["lower", "upper", "transition"].flatMap((side) => {
5087
5157
  const reference = spec.terrainReferences[side];
@@ -6387,6 +6457,7 @@ var PixelLabProvider = class _PixelLabProvider {
6387
6457
  `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)`
6388
6458
  );
6389
6459
  }
6460
+ if (spec.generator === "tiles") this.validateTileOptions(spec);
6390
6461
  const members = spec.revision?.sourceMembers;
6391
6462
  if (spec.revision && members && !MEMBER_SET_REVISION_MODES.includes(spec.revision.mode)) {
6392
6463
  throw new Error(
@@ -6658,6 +6729,31 @@ var PixelLabProvider = class _PixelLabProvider {
6658
6729
  );
6659
6730
  }
6660
6731
  }
6732
+ /** Where `/create-tiles-pro`'s newer shape options apply; elsewhere the API ignores or refuses them. */
6733
+ validateTileOptions(spec) {
6734
+ const tilesetOnly = {
6735
+ tileElevation: spec.tileElevation,
6736
+ tileStepSlope: spec.tileStepSlope,
6737
+ tileBoundaryAmplitude: spec.tileBoundaryAmplitude,
6738
+ tileBoundarySeed: spec.tileBoundarySeed
6739
+ };
6740
+ const set = Object.entries(tilesetOnly).filter(([, value]) => value != null).map(([field]) => field);
6741
+ if (set.length && spec.tileFeature !== "tileset") {
6742
+ throw new Error(`PixelLab tiles: ${set.join(", ")} shape a connectable terrain set; set tileFeature: "tileset"`);
6743
+ }
6744
+ if (spec.tileElevation != null && spec.tileElevation > 0 && spec.tileType && !["square_topdown", "isometric", "oblique"].includes(spec.tileType)) {
6745
+ throw new Error(`PixelLab tiles: tileElevation raises a plateau on square_topdown, isometric or oblique tiles, not "${spec.tileType}"`);
6746
+ }
6747
+ if (spec.tileStepSlope != null && !(spec.tileElevation != null && spec.tileElevation > 0)) {
6748
+ throw new Error("PixelLab tiles: tileStepSlope spreads the drop of a raised terrain; set tileElevation above 0");
6749
+ }
6750
+ if (spec.tileBoundarySeed != null && spec.tileBoundaryAmplitude == null) {
6751
+ throw new Error("PixelLab tiles: tileBoundarySeed picks tileBoundaryAmplitude's meander; set both or neither");
6752
+ }
6753
+ if (spec.buildingRoofProfile && !(spec.tileFeature === "building" && spec.buildingLayout === "materials")) {
6754
+ throw new Error(`PixelLab tiles: buildingRoofProfile shapes a building kit's roof pieces; set tileFeature: "building" with buildingLayout: "materials"`);
6755
+ }
6756
+ }
6661
6757
  /** `/create-tileset`'s own rules, beyond the enums both terrain endpoints share. */
6662
6758
  validateTopDownTerrain(spec) {
6663
6759
  if (spec.terrainShapeStyle && spec.terrainMode === "pro") {
@@ -7523,7 +7619,8 @@ var PixelLabProvider = class _PixelLabProvider {
7523
7619
  height: spec.height,
7524
7620
  noBackground: spec.noBackground,
7525
7621
  paletteSwatchBase64: swatch,
7526
- seed: spec.seed
7622
+ seed: spec.seed,
7623
+ ...await initImageArgs(spec)
7527
7624
  });
7528
7625
  const jobId = (0, import_node_crypto2.randomUUID)();
7529
7626
  (0, import_node_fs4.writeFileSync)(import_node_path3.default.join(_PixelLabProvider.cacheDir(), `${jobId}.png`), png);
@@ -7547,6 +7644,11 @@ var PixelLabProvider = class _PixelLabProvider {
7547
7644
  buildingFloorDescription: spec.buildingFloorDescription,
7548
7645
  buildingFloor2Description: spec.buildingFloor2Description,
7549
7646
  buildingWallAngle: spec.buildingWallAngle,
7647
+ roofProfile: spec.buildingRoofProfile,
7648
+ elevation: spec.tileElevation,
7649
+ stepSlope: spec.tileStepSlope,
7650
+ boundaryAmplitude: spec.tileBoundaryAmplitude,
7651
+ boundarySeed: spec.tileBoundarySeed,
7550
7652
  outlineMode: spec.outlineMode,
7551
7653
  seed: spec.seed,
7552
7654
  // TilesProStyleImage is flat and wants the reference's real dimensions,
@@ -7636,7 +7738,8 @@ var PixelLabProvider = class _PixelLabProvider {
7636
7738
  outline: spec.outline,
7637
7739
  shading: spec.shading,
7638
7740
  detail: spec.detail,
7639
- seed: spec.seed
7741
+ seed: spec.seed,
7742
+ ...await initImageArgs(spec)
7640
7743
  });
7641
7744
  return { jobId: res2.tile_id, metadata: { backgroundJobId: res2.background_job_id } };
7642
7745
  }
@@ -7680,6 +7783,7 @@ var PixelLabProvider = class _PixelLabProvider {
7680
7783
  shading: spec.shading,
7681
7784
  detail: spec.detail,
7682
7785
  seed: spec.seed,
7786
+ ...await initImageArgs(spec),
7683
7787
  scene: spec.scene ? mapScenePayload(spec) : void 0
7684
7788
  });
7685
7789
  return { jobId: res.object_id, metadata: { backgroundJobId: res.background_job_id } };
@@ -8808,6 +8912,16 @@ function sendsTargetPalette(spec) {
8808
8912
  return false;
8809
8913
  }
8810
8914
  }
8915
+ async function initImageArgs(spec) {
8916
+ const init = spec.initImage;
8917
+ if (!init) return {};
8918
+ if (!(0, import_node_fs4.existsSync)(init.file)) throw new Error(`init image is missing: ${init.file}`);
8919
+ const bytes = (0, import_node_fs4.readFileSync)(init.file);
8920
+ if (sha256(bytes) !== init.sha256) {
8921
+ throw new Error(`init image changed after the manifest was resolved: ${init.file}; run the command again`);
8922
+ }
8923
+ return { initImage: { base64: bytes.toString("base64"), format: "png" }, ...init.strength == null ? {} : { initImageStrength: init.strength } };
8924
+ }
8811
8925
  async function terrainReferenceImage(spec, side) {
8812
8926
  const reference = spec.terrainReferences?.[side];
8813
8927
  if (!reference) return void 0;
@@ -12085,6 +12199,11 @@ async function resolveSpecs(loaded, filter) {
12085
12199
  buildingFloorDescription: generator === "tiles" ? style.buildingFloorDescription : void 0,
12086
12200
  buildingFloor2Description: generator === "tiles" ? style.buildingFloor2Description : void 0,
12087
12201
  buildingWallAngle: generator === "tiles" ? style.buildingWallAngle : void 0,
12202
+ buildingRoofProfile: generator === "tiles" ? style.buildingRoofProfile : void 0,
12203
+ tileElevation: generator === "tiles" ? style.tileElevation : void 0,
12204
+ tileStepSlope: generator === "tiles" ? style.tileStepSlope : void 0,
12205
+ tileBoundaryAmplitude: generator === "tiles" ? style.tileBoundaryAmplitude : void 0,
12206
+ tileBoundarySeed: generator === "tiles" ? style.tileBoundarySeed : void 0,
12088
12207
  outlineMode: generator === "tiles" ? style.outlineMode : void 0,
12089
12208
  terrainLowerDescription: generator === "terrain" ? terrainLowerDescription : void 0,
12090
12209
  terrainUpperDescription: generator === "terrain" ? terrainUpperDescription : void 0,
@@ -12546,6 +12665,23 @@ async function resolveSpecs(loaded, filter) {
12546
12665
  }
12547
12666
  resolved.terrainConnect = links;
12548
12667
  }
12668
+ if (asset.initImage) {
12669
+ if (!["pixflux", "map", "isometricTile"].includes(resolved.generator)) {
12670
+ throw new Error(
12671
+ `assets.${assetId}.initImage: a starting image is taken by pixflux, map and isometricTile styles; style "${styleId}" uses "${resolved.generator}"`
12672
+ );
12673
+ }
12674
+ const file = import_node_path8.default.resolve(root, asset.initImage);
12675
+ const image = await optionalRevisionImage(file, "init image", "png");
12676
+ if (!image) throw new Error(`assets.${assetId}.initImage: ${asset.initImage} is missing or not a PNG`);
12677
+ resolved.initImage = {
12678
+ file,
12679
+ sha256: image?.hash ?? null,
12680
+ width: image?.width ?? null,
12681
+ height: image?.height ?? null,
12682
+ ...asset.initImageStrength == null ? {} : { strength: asset.initImageStrength }
12683
+ };
12684
+ }
12549
12685
  if (asset.terrainReferences) {
12550
12686
  if (resolved.generator !== "terrain") {
12551
12687
  throw new Error(`assets.${assetId}.terrainReferences: only a terrain set takes terrain references; style "${styleId}" uses "${resolved.generator}"`);