pixelkiln 0.53.0 → 0.53.2

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
@@ -188,6 +188,7 @@ __export(index_exports, {
188
188
  mountStyle: () => mountStyle,
189
189
  normalizeLockOutputPaths: () => normalizeLockOutputPaths,
190
190
  normalizeRefinementPalette: () => normalizeRefinementPalette,
191
+ normalizeTerrainTiles: () => normalizeTerrainTiles,
191
192
  normalizeTileRules: () => normalizeTileRules,
192
193
  openExternal: () => openExternal,
193
194
  openInEditor: () => openInEditor,
@@ -10486,6 +10487,25 @@ function normalizeTileRules(raw) {
10486
10487
  raw
10487
10488
  };
10488
10489
  }
10490
+ function normalizeTerrainTiles(metadata) {
10491
+ if (!isRecord2(metadata) || !Array.isArray(metadata.terrainTiles)) return null;
10492
+ const terrains = Array.isArray(metadata.terrainTypes) ? metadata.terrainTypes.filter((item) => typeof item === "string") : [];
10493
+ if (terrains.length < 2) return null;
10494
+ const masks = {};
10495
+ metadata.terrainTiles.forEach((tile, index) => {
10496
+ if (!isRecord2(tile) || !isRecord2(tile.corners)) return;
10497
+ const corners = tile.corners;
10498
+ const bit = (corner) => corners[corner] === terrains[0] ? 1 : 0;
10499
+ masks[index] = bit("NW") << 3 | bit("NE") << 2 | bit("SW") << 1 | bit("SE");
10500
+ });
10501
+ return {
10502
+ ruleType: "corner",
10503
+ arity: 4,
10504
+ terrains,
10505
+ masks,
10506
+ raw: metadata
10507
+ };
10508
+ }
10489
10509
  function exportTileset(entry, spec, options) {
10490
10510
  let outputs = resolveSpecEntryOutputs(entry, spec);
10491
10511
  if (!outputs.length) throw new Error(`${spec.styleId}/${spec.assetId} has no downloaded outputs`);
@@ -10506,14 +10526,16 @@ function exportTileset(entry, spec, options) {
10506
10526
  }
10507
10527
  const metadata = entry.providerMetadata?.[entry.provider];
10508
10528
  const rawRules = isRecord2(metadata) ? metadata.tileRules : void 0;
10509
- const rules = normalizeTileRules(rawRules);
10529
+ const terrainRules = normalizeTerrainTiles(metadata);
10530
+ const rules = normalizeTileRules(rawRules) ?? terrainRules;
10531
+ const providerRules = isRecord2(rawRules) ? rawRules : terrainRules ? metadata : null;
10510
10532
  const frames = packed.atlas.frames;
10511
10533
  const generic = buildGeneric(
10512
10534
  spec,
10513
10535
  options.imageName,
10514
10536
  packed.atlas,
10515
10537
  frames,
10516
- isRecord2(rawRules) ? rawRules : null,
10538
+ providerRules,
10517
10539
  rules
10518
10540
  );
10519
10541
  if (options.format === "generic") {
@@ -10526,7 +10548,7 @@ function exportTileset(entry, spec, options) {
10526
10548
  };
10527
10549
  }
10528
10550
  assertUniformTiles(generic);
10529
- if ((rawRules !== void 0 || entry.tileFeature) && !rules) {
10551
+ if ((rawRules !== void 0 || entry.tileFeature || entry.generator === "terrain") && !rules) {
10530
10552
  throw new Error(
10531
10553
  `${options.format} export needs recognized adjacency rules; use --format generic to retain this provider rule object without guessing`
10532
10554
  );
@@ -15216,6 +15238,7 @@ async function workspaceStatus(ws, dir) {
15216
15238
  mountStyle,
15217
15239
  normalizeLockOutputPaths,
15218
15240
  normalizeRefinementPalette,
15241
+ normalizeTerrainTiles,
15219
15242
  normalizeTileRules,
15220
15243
  openExternal,
15221
15244
  openInEditor,