pixelkiln 0.111.0 → 0.113.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 +382 -5
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +389 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +384 -7
- package/dist/index.js.map +1 -1
- package/docs/CLI.md +4 -4
- package/docs/TILES.md +47 -3
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -30943,7 +30943,7 @@ declare function mountStyle(lock: Lock, styleId: string, manifestDir: string, mo
|
|
|
30943
30943
|
cellHeight: number;
|
|
30944
30944
|
}, cells: Record<string, [number, number]>, sources?: Record<string, string>, outputRoles?: Record<string, string>): MountedSheet;
|
|
30945
30945
|
|
|
30946
|
-
type TilesetFormat = "generic" | "tiled" | "godot";
|
|
30946
|
+
type TilesetFormat = "generic" | "tiled" | "godot" | "ldtk";
|
|
30947
30947
|
interface NormalizedTileRules {
|
|
30948
30948
|
ruleType: "edge" | "corner" | "outline";
|
|
30949
30949
|
arity: 4 | 6;
|
|
@@ -30987,7 +30987,7 @@ interface GenericTileset {
|
|
|
30987
30987
|
}
|
|
30988
30988
|
interface TilesetExport {
|
|
30989
30989
|
png: Buffer;
|
|
30990
|
-
extension: ".json" | ".tsj" | ".tres";
|
|
30990
|
+
extension: ".json" | ".tsj" | ".tres" | ".ldtk";
|
|
30991
30991
|
document: string;
|
|
30992
30992
|
generic: GenericTileset;
|
|
30993
30993
|
sources: PackedSource[];
|
|
@@ -31010,7 +31010,7 @@ declare function normalizeTileRules(raw: unknown): NormalizedTileRules | null;
|
|
|
31010
31010
|
* "first terrain".
|
|
31011
31011
|
*/
|
|
31012
31012
|
declare function normalizeTerrainTiles(metadata: unknown): NormalizedTileRules | null;
|
|
31013
|
-
/** Build an atlas plus generic, Tiled TSJ,
|
|
31013
|
+
/** Build an atlas plus generic, Tiled TSJ, Godot 4 TileSet, or LDtk project metadata. */
|
|
31014
31014
|
declare function exportTileset(entry: LockEntry, spec: ResolvedSpec, options: TilesetExportOptions): TilesetExport;
|
|
31015
31015
|
|
|
31016
31016
|
interface SubmitOptions {
|
package/dist/index.d.ts
CHANGED
|
@@ -30943,7 +30943,7 @@ declare function mountStyle(lock: Lock, styleId: string, manifestDir: string, mo
|
|
|
30943
30943
|
cellHeight: number;
|
|
30944
30944
|
}, cells: Record<string, [number, number]>, sources?: Record<string, string>, outputRoles?: Record<string, string>): MountedSheet;
|
|
30945
30945
|
|
|
30946
|
-
type TilesetFormat = "generic" | "tiled" | "godot";
|
|
30946
|
+
type TilesetFormat = "generic" | "tiled" | "godot" | "ldtk";
|
|
30947
30947
|
interface NormalizedTileRules {
|
|
30948
30948
|
ruleType: "edge" | "corner" | "outline";
|
|
30949
30949
|
arity: 4 | 6;
|
|
@@ -30987,7 +30987,7 @@ interface GenericTileset {
|
|
|
30987
30987
|
}
|
|
30988
30988
|
interface TilesetExport {
|
|
30989
30989
|
png: Buffer;
|
|
30990
|
-
extension: ".json" | ".tsj" | ".tres";
|
|
30990
|
+
extension: ".json" | ".tsj" | ".tres" | ".ldtk";
|
|
30991
30991
|
document: string;
|
|
30992
30992
|
generic: GenericTileset;
|
|
30993
30993
|
sources: PackedSource[];
|
|
@@ -31010,7 +31010,7 @@ declare function normalizeTileRules(raw: unknown): NormalizedTileRules | null;
|
|
|
31010
31010
|
* "first terrain".
|
|
31011
31011
|
*/
|
|
31012
31012
|
declare function normalizeTerrainTiles(metadata: unknown): NormalizedTileRules | null;
|
|
31013
|
-
/** Build an atlas plus generic, Tiled TSJ,
|
|
31013
|
+
/** Build an atlas plus generic, Tiled TSJ, Godot 4 TileSet, or LDtk project metadata. */
|
|
31014
31014
|
declare function exportTileset(entry: LockEntry, spec: ResolvedSpec, options: TilesetExportOptions): TilesetExport;
|
|
31015
31015
|
|
|
31016
31016
|
interface SubmitOptions {
|
package/dist/index.js
CHANGED
|
@@ -20063,6 +20063,374 @@ function mountStyle(lock, styleId, manifestDir, mount, cells, sources = {}, outp
|
|
|
20063
20063
|
};
|
|
20064
20064
|
}
|
|
20065
20065
|
|
|
20066
|
+
// src/pipeline/ldtk-export.ts
|
|
20067
|
+
import { createHash as createHash6 } from "crypto";
|
|
20068
|
+
var LDTK_JSON_VERSION = "1.5.3";
|
|
20069
|
+
var FIRST = 1;
|
|
20070
|
+
var SECOND = 2;
|
|
20071
|
+
var DEMO_WIDTH = 12;
|
|
20072
|
+
var DEMO_HEIGHT = 9;
|
|
20073
|
+
function ldtkRuleMatches(rule, grid, cx, cy) {
|
|
20074
|
+
const radius = Math.floor(rule.size / 2);
|
|
20075
|
+
for (let py = 0; py < rule.size; py++) {
|
|
20076
|
+
for (let px = 0; px < rule.size; px++) {
|
|
20077
|
+
const wanted = rule.pattern[px + py * rule.size];
|
|
20078
|
+
if (wanted === 0) continue;
|
|
20079
|
+
const x = cx + px - radius;
|
|
20080
|
+
const y = cy + py - radius;
|
|
20081
|
+
const inside2 = x >= 0 && y >= 0 && x < grid.width && y < grid.height;
|
|
20082
|
+
const value = inside2 ? grid.cells[y * grid.width + x] : rule.outOfBoundsValue;
|
|
20083
|
+
if (wanted > 0 && value !== wanted) return false;
|
|
20084
|
+
if (wanted < 0 && value === -wanted) return false;
|
|
20085
|
+
}
|
|
20086
|
+
}
|
|
20087
|
+
return true;
|
|
20088
|
+
}
|
|
20089
|
+
function iid(...parts) {
|
|
20090
|
+
const hex2 = createHash6("sha256").update(parts.join("\0")).digest("hex");
|
|
20091
|
+
return `${hex2.slice(0, 8)}-${hex2.slice(8, 12)}-4${hex2.slice(13, 16)}-8${hex2.slice(17, 20)}-${hex2.slice(20, 32)}`;
|
|
20092
|
+
}
|
|
20093
|
+
function identifier(text, fallback) {
|
|
20094
|
+
const slug3 = text.replace(/[^A-Za-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
20095
|
+
return /^[A-Za-z]/.test(slug3) ? slug3 : slug3 ? `${fallback}_${slug3}` : fallback;
|
|
20096
|
+
}
|
|
20097
|
+
function dominantValue(mask) {
|
|
20098
|
+
const first = [0, 1, 2, 3].filter((bit) => (mask & 1 << bit) !== 0).length;
|
|
20099
|
+
return first * 2 >= 4 ? FIRST : SECOND;
|
|
20100
|
+
}
|
|
20101
|
+
function ldtkPattern(rules, mask) {
|
|
20102
|
+
const value = (bit) => (mask & 1 << bit) !== 0 ? FIRST : SECOND;
|
|
20103
|
+
const pattern = new Array(9).fill(0);
|
|
20104
|
+
if (rules.ruleType === "corner") {
|
|
20105
|
+
pattern[4] = value(3);
|
|
20106
|
+
pattern[5] = value(2);
|
|
20107
|
+
pattern[7] = value(1);
|
|
20108
|
+
pattern[8] = value(0);
|
|
20109
|
+
return pattern;
|
|
20110
|
+
}
|
|
20111
|
+
pattern[4] = dominantValue(mask);
|
|
20112
|
+
pattern[1] = value(0);
|
|
20113
|
+
pattern[5] = value(1);
|
|
20114
|
+
pattern[7] = value(2);
|
|
20115
|
+
pattern[3] = value(3);
|
|
20116
|
+
return pattern;
|
|
20117
|
+
}
|
|
20118
|
+
function resolveLdtkTiles(rules, grid) {
|
|
20119
|
+
const out = [];
|
|
20120
|
+
for (let cy = 0; cy < grid.height; cy++) {
|
|
20121
|
+
for (let cx = 0; cx < grid.width; cx++) {
|
|
20122
|
+
const rule = rules.find((candidate) => ldtkRuleMatches(candidate, grid, cx, cy));
|
|
20123
|
+
if (rule) out.push({ cx, cy, rule, tile: rule.tileRectsIds[(cx * 7 + cy * 13) % rule.tileRectsIds.length][0] });
|
|
20124
|
+
}
|
|
20125
|
+
}
|
|
20126
|
+
return out;
|
|
20127
|
+
}
|
|
20128
|
+
function demoGrid(rules, wanted) {
|
|
20129
|
+
let best = null;
|
|
20130
|
+
let bestCovered = -1;
|
|
20131
|
+
for (let seed = 1; seed <= 400; seed++) {
|
|
20132
|
+
let state = seed * 2654435761 >>> 0;
|
|
20133
|
+
const cells = Array.from({ length: DEMO_WIDTH * DEMO_HEIGHT }, () => {
|
|
20134
|
+
state = Math.imul(state, 1664525) + 1013904223 >>> 0;
|
|
20135
|
+
return (state >>> 16) % 100 < 52 ? FIRST : SECOND;
|
|
20136
|
+
});
|
|
20137
|
+
const grid = { width: DEMO_WIDTH, height: DEMO_HEIGHT, cells };
|
|
20138
|
+
const covered = new Set(resolveLdtkTiles(rules, grid).map((hit) => hit.rule.uid)).size;
|
|
20139
|
+
if (covered > bestCovered) {
|
|
20140
|
+
best = grid;
|
|
20141
|
+
bestCovered = covered;
|
|
20142
|
+
}
|
|
20143
|
+
if (covered >= wanted) break;
|
|
20144
|
+
}
|
|
20145
|
+
return best;
|
|
20146
|
+
}
|
|
20147
|
+
var TERRAIN_COLORS = ["#5AB552", "#4C78A8"];
|
|
20148
|
+
function buildLdtk(generic, tileType) {
|
|
20149
|
+
const rules = generic.rules;
|
|
20150
|
+
if (!rules || rules.ruleType === "outline") {
|
|
20151
|
+
throw new Error("ldtk export needs recognized corner or edge adjacency rules; use --format generic");
|
|
20152
|
+
}
|
|
20153
|
+
if (tileType === void 0 || tileType === "isometric" || tileType === "oblique" || tileType === "hex" || tileType === "hex_pointy") {
|
|
20154
|
+
throw new Error(
|
|
20155
|
+
`ldtk export needs square tiles on an orthogonal grid, and this set is ${tileType ?? "isometric"}; use --format generic or --format tiled`
|
|
20156
|
+
);
|
|
20157
|
+
}
|
|
20158
|
+
const grid = generic.tile.width;
|
|
20159
|
+
if (generic.tile.width !== generic.tile.height) {
|
|
20160
|
+
throw new Error(`ldtk grids are square; these tiles are ${generic.tile.width}x${generic.tile.height}`);
|
|
20161
|
+
}
|
|
20162
|
+
const corner = rules.ruleType === "corner";
|
|
20163
|
+
const base = identifier(generic.name.replace("/", "_"), "Tileset");
|
|
20164
|
+
const name = base.charAt(0).toUpperCase() + base.slice(1);
|
|
20165
|
+
const terrainNames = [rules.terrains[0] ?? "feature", rules.terrains[1] ?? "background"];
|
|
20166
|
+
const columns = generic.sheet.columns;
|
|
20167
|
+
const rows = Math.ceil(generic.tiles.length / columns);
|
|
20168
|
+
const byMask = /* @__PURE__ */ new Map();
|
|
20169
|
+
for (const tile of generic.tiles) {
|
|
20170
|
+
if (tile.bitmask === void 0) continue;
|
|
20171
|
+
byMask.set(tile.bitmask, [...byMask.get(tile.bitmask) ?? [], tile.id]);
|
|
20172
|
+
}
|
|
20173
|
+
if (!byMask.size) throw new Error("ldtk export found no tiles with adjacency masks; use --format generic");
|
|
20174
|
+
const tilesetUid = 1;
|
|
20175
|
+
const sourceUid = 2;
|
|
20176
|
+
const autoUid = 3;
|
|
20177
|
+
const groupUid = 4;
|
|
20178
|
+
const ruleList = [...byMask.entries()].map(([mask, ids], index) => ({
|
|
20179
|
+
uid: 5 + index,
|
|
20180
|
+
active: true,
|
|
20181
|
+
size: 3,
|
|
20182
|
+
tileRectsIds: ids.map((id) => [id]),
|
|
20183
|
+
alpha: 1,
|
|
20184
|
+
chance: 1,
|
|
20185
|
+
breakOnMatch: true,
|
|
20186
|
+
pattern: ldtkPattern(rules, mask),
|
|
20187
|
+
flipX: false,
|
|
20188
|
+
flipY: false,
|
|
20189
|
+
xModulo: 1,
|
|
20190
|
+
yModulo: 1,
|
|
20191
|
+
xOffset: 0,
|
|
20192
|
+
yOffset: 0,
|
|
20193
|
+
tileXOffset: 0,
|
|
20194
|
+
tileYOffset: 0,
|
|
20195
|
+
tileRandomXMin: 0,
|
|
20196
|
+
tileRandomXMax: 0,
|
|
20197
|
+
tileRandomYMin: 0,
|
|
20198
|
+
tileRandomYMax: 0,
|
|
20199
|
+
checker: "None",
|
|
20200
|
+
tileMode: "Single",
|
|
20201
|
+
pivotX: 0,
|
|
20202
|
+
pivotY: 0,
|
|
20203
|
+
outOfBoundsValue: SECOND,
|
|
20204
|
+
invalidated: false,
|
|
20205
|
+
perlinActive: false,
|
|
20206
|
+
perlinSeed: 1,
|
|
20207
|
+
perlinScale: 0.2,
|
|
20208
|
+
perlinOctaves: 2
|
|
20209
|
+
}));
|
|
20210
|
+
const levelUid = 5 + ruleList.length;
|
|
20211
|
+
const nextUid = levelUid + 1;
|
|
20212
|
+
const tileRect = (id) => {
|
|
20213
|
+
const tile = generic.tiles.find((candidate) => candidate.id === id);
|
|
20214
|
+
return tile ? { tilesetUid, x: tile.x, y: tile.y, w: tile.width, h: tile.height } : null;
|
|
20215
|
+
};
|
|
20216
|
+
const full = (1 << rules.arity) - 1;
|
|
20217
|
+
const representative = (terrain) => generic.tiles.find((tile) => tile.bitmask === (terrain === 0 ? full : 0))?.id;
|
|
20218
|
+
const shift = corner ? -Math.floor(grid / 2) : 0;
|
|
20219
|
+
const sourceName = `${name}_${corner ? "corners" : "cells"}`;
|
|
20220
|
+
const autoName = name;
|
|
20221
|
+
const layerBase = {
|
|
20222
|
+
guideGridWid: 0,
|
|
20223
|
+
guideGridHei: 0,
|
|
20224
|
+
displayOpacity: 1,
|
|
20225
|
+
inactiveOpacity: 1,
|
|
20226
|
+
hideInList: false,
|
|
20227
|
+
hideFieldsWhenInactive: false,
|
|
20228
|
+
canSelectWhenInactive: true,
|
|
20229
|
+
parallaxFactorX: 0,
|
|
20230
|
+
parallaxFactorY: 0,
|
|
20231
|
+
parallaxScaling: true,
|
|
20232
|
+
requiredTags: [],
|
|
20233
|
+
excludedTags: [],
|
|
20234
|
+
autoTilesKilledByOtherLayerUid: null,
|
|
20235
|
+
uiFilterTags: [],
|
|
20236
|
+
useAsyncRender: false,
|
|
20237
|
+
tilePivotX: 0,
|
|
20238
|
+
tilePivotY: 0,
|
|
20239
|
+
biomeFieldUid: null,
|
|
20240
|
+
gridSize: grid,
|
|
20241
|
+
tilesetDefUid: tilesetUid
|
|
20242
|
+
};
|
|
20243
|
+
const sourceLayer = {
|
|
20244
|
+
__type: "IntGrid",
|
|
20245
|
+
identifier: sourceName,
|
|
20246
|
+
type: "IntGrid",
|
|
20247
|
+
uid: sourceUid,
|
|
20248
|
+
doc: corner ? `Paint ${terrainNames[0]} (1) and ${terrainNames[1]} (2). Each cell is a corner where four tiles meet, so it is drawn half a tile up and left of the tiles it controls.` : `Paint ${terrainNames[0]} (1) and ${terrainNames[1]} (2). Each tile looks at its own cell and the four around it.`,
|
|
20249
|
+
uiColor: TERRAIN_COLORS[0],
|
|
20250
|
+
...layerBase,
|
|
20251
|
+
renderInWorldView: true,
|
|
20252
|
+
pxOffsetX: shift,
|
|
20253
|
+
pxOffsetY: shift,
|
|
20254
|
+
intGridValues: [FIRST, SECOND].map((value, index) => ({
|
|
20255
|
+
value,
|
|
20256
|
+
identifier: identifier(terrainNames[index], `terrain${value}`),
|
|
20257
|
+
color: TERRAIN_COLORS[index],
|
|
20258
|
+
tile: tileRect(representative(index)),
|
|
20259
|
+
groupUid: 0
|
|
20260
|
+
})),
|
|
20261
|
+
intGridValuesGroups: [],
|
|
20262
|
+
autoRuleGroups: [],
|
|
20263
|
+
autoSourceLayerDefUid: null
|
|
20264
|
+
};
|
|
20265
|
+
const autoLayer = {
|
|
20266
|
+
__type: "AutoLayer",
|
|
20267
|
+
identifier: autoName,
|
|
20268
|
+
type: "AutoLayer",
|
|
20269
|
+
uid: autoUid,
|
|
20270
|
+
doc: `Drawn by rules from ${sourceName}: one rule for each way the two terrains can meet.`,
|
|
20271
|
+
uiColor: TERRAIN_COLORS[1],
|
|
20272
|
+
...layerBase,
|
|
20273
|
+
renderInWorldView: true,
|
|
20274
|
+
pxOffsetX: 0,
|
|
20275
|
+
pxOffsetY: 0,
|
|
20276
|
+
intGridValues: [],
|
|
20277
|
+
intGridValuesGroups: [],
|
|
20278
|
+
autoRuleGroups: [{
|
|
20279
|
+
uid: groupUid,
|
|
20280
|
+
name: "Borders",
|
|
20281
|
+
color: null,
|
|
20282
|
+
icon: null,
|
|
20283
|
+
active: true,
|
|
20284
|
+
isOptional: false,
|
|
20285
|
+
rules: ruleList,
|
|
20286
|
+
usesWizard: false,
|
|
20287
|
+
requiredBiomeValues: [],
|
|
20288
|
+
biomeRequirementMode: 0
|
|
20289
|
+
}],
|
|
20290
|
+
autoSourceLayerDefUid: sourceUid
|
|
20291
|
+
};
|
|
20292
|
+
const level = demoGrid(ruleList, ruleList.length);
|
|
20293
|
+
const hits = resolveLdtkTiles(ruleList, level);
|
|
20294
|
+
const tileAt = (id) => ({ x: id % columns * grid, y: Math.floor(id / columns) * grid });
|
|
20295
|
+
const instanceBase = (layerDef, offset) => ({
|
|
20296
|
+
__identifier: layerDef.identifier,
|
|
20297
|
+
__type: layerDef.__type,
|
|
20298
|
+
__cWid: DEMO_WIDTH,
|
|
20299
|
+
__cHei: DEMO_HEIGHT,
|
|
20300
|
+
__gridSize: grid,
|
|
20301
|
+
__opacity: 1,
|
|
20302
|
+
__pxTotalOffsetX: offset,
|
|
20303
|
+
__pxTotalOffsetY: offset,
|
|
20304
|
+
__tilesetDefUid: tilesetUid,
|
|
20305
|
+
__tilesetRelPath: generic.image,
|
|
20306
|
+
iid: iid(generic.name, "layer", layerDef.uid),
|
|
20307
|
+
levelId: levelUid,
|
|
20308
|
+
layerDefUid: layerDef.uid,
|
|
20309
|
+
pxOffsetX: 0,
|
|
20310
|
+
pxOffsetY: 0,
|
|
20311
|
+
visible: true,
|
|
20312
|
+
optionalRules: [],
|
|
20313
|
+
seed: 1e3 + layerDef.uid,
|
|
20314
|
+
overrideTilesetUid: null,
|
|
20315
|
+
gridTiles: [],
|
|
20316
|
+
entityInstances: []
|
|
20317
|
+
});
|
|
20318
|
+
const project2 = {
|
|
20319
|
+
__header__: {
|
|
20320
|
+
fileType: "LDtk Project JSON",
|
|
20321
|
+
app: "LDtk",
|
|
20322
|
+
doc: "https://ldtk.io/json",
|
|
20323
|
+
schema: "https://ldtk.io/files/JSON_SCHEMA.json",
|
|
20324
|
+
appAuthor: "Sebastien 'deepnight' Benard",
|
|
20325
|
+
appVersion: LDTK_JSON_VERSION,
|
|
20326
|
+
url: "https://ldtk.io"
|
|
20327
|
+
},
|
|
20328
|
+
iid: iid(generic.name, "project"),
|
|
20329
|
+
jsonVersion: LDTK_JSON_VERSION,
|
|
20330
|
+
appBuildId: 473702,
|
|
20331
|
+
nextUid,
|
|
20332
|
+
identifierStyle: "Capitalize",
|
|
20333
|
+
toc: [],
|
|
20334
|
+
worldLayout: "LinearHorizontal",
|
|
20335
|
+
worldGridWidth: 256,
|
|
20336
|
+
worldGridHeight: 256,
|
|
20337
|
+
defaultLevelWidth: DEMO_WIDTH * grid,
|
|
20338
|
+
defaultLevelHeight: DEMO_HEIGHT * grid,
|
|
20339
|
+
defaultPivotX: 0,
|
|
20340
|
+
defaultPivotY: 0,
|
|
20341
|
+
defaultGridSize: grid,
|
|
20342
|
+
defaultEntityWidth: grid,
|
|
20343
|
+
defaultEntityHeight: grid,
|
|
20344
|
+
bgColor: "#4A5066",
|
|
20345
|
+
defaultLevelBgColor: "#474B67",
|
|
20346
|
+
minifyJson: false,
|
|
20347
|
+
externalLevels: false,
|
|
20348
|
+
exportTiled: false,
|
|
20349
|
+
simplifiedExport: false,
|
|
20350
|
+
imageExportMode: "None",
|
|
20351
|
+
exportLevelBg: true,
|
|
20352
|
+
pngFilePattern: null,
|
|
20353
|
+
backupOnSave: false,
|
|
20354
|
+
backupLimit: 10,
|
|
20355
|
+
backupRelPath: null,
|
|
20356
|
+
levelNamePattern: "%world_Level_%idx",
|
|
20357
|
+
tutorialDesc: null,
|
|
20358
|
+
customCommands: [],
|
|
20359
|
+
flags: ["ExportOldTableOfContentData", "UseMultilinesType"],
|
|
20360
|
+
defs: {
|
|
20361
|
+
layers: [autoLayer, sourceLayer],
|
|
20362
|
+
entities: [],
|
|
20363
|
+
tilesets: [{
|
|
20364
|
+
__cWid: columns,
|
|
20365
|
+
__cHei: rows,
|
|
20366
|
+
identifier: `${name}_tiles`,
|
|
20367
|
+
uid: tilesetUid,
|
|
20368
|
+
relPath: generic.image,
|
|
20369
|
+
embedAtlas: null,
|
|
20370
|
+
pxWid: generic.sheet.width,
|
|
20371
|
+
pxHei: generic.sheet.height,
|
|
20372
|
+
tileGridSize: grid,
|
|
20373
|
+
spacing: 0,
|
|
20374
|
+
padding: 0,
|
|
20375
|
+
tags: [],
|
|
20376
|
+
tagsSourceEnumUid: null,
|
|
20377
|
+
enumTags: [],
|
|
20378
|
+
customData: generic.tiles.filter((tile) => tile.bitmask !== void 0).map((tile) => ({ tileId: tile.id, data: `mask=${tile.bitmask}` })),
|
|
20379
|
+
savedSelections: [],
|
|
20380
|
+
cachedPixelData: null
|
|
20381
|
+
}],
|
|
20382
|
+
enums: [],
|
|
20383
|
+
externalEnums: [],
|
|
20384
|
+
levelFields: []
|
|
20385
|
+
},
|
|
20386
|
+
levels: [{
|
|
20387
|
+
identifier: "Preview",
|
|
20388
|
+
iid: iid(generic.name, "level"),
|
|
20389
|
+
uid: levelUid,
|
|
20390
|
+
// A linear world ignores the position; LDtk itself writes -1 for it.
|
|
20391
|
+
worldX: -1,
|
|
20392
|
+
worldY: -1,
|
|
20393
|
+
worldDepth: 0,
|
|
20394
|
+
pxWid: DEMO_WIDTH * grid,
|
|
20395
|
+
pxHei: DEMO_HEIGHT * grid,
|
|
20396
|
+
__bgColor: "#474B67",
|
|
20397
|
+
bgColor: null,
|
|
20398
|
+
useAutoIdentifier: false,
|
|
20399
|
+
bgRelPath: null,
|
|
20400
|
+
bgPos: null,
|
|
20401
|
+
bgPivotX: 0.5,
|
|
20402
|
+
bgPivotY: 0.5,
|
|
20403
|
+
__smartColor: "#9A9CAB",
|
|
20404
|
+
__bgPos: null,
|
|
20405
|
+
externalRelPath: null,
|
|
20406
|
+
fieldInstances: [],
|
|
20407
|
+
layerInstances: [
|
|
20408
|
+
{
|
|
20409
|
+
...instanceBase(autoLayer, 0),
|
|
20410
|
+
intGridCsv: [],
|
|
20411
|
+
autoLayerTiles: hits.map((hit) => ({
|
|
20412
|
+
px: [hit.cx * grid, hit.cy * grid],
|
|
20413
|
+
src: [tileAt(hit.tile).x, tileAt(hit.tile).y],
|
|
20414
|
+
f: 0,
|
|
20415
|
+
t: hit.tile,
|
|
20416
|
+
d: [hit.rule.uid, hit.cy * DEMO_WIDTH + hit.cx],
|
|
20417
|
+
a: 1
|
|
20418
|
+
}))
|
|
20419
|
+
},
|
|
20420
|
+
{
|
|
20421
|
+
...instanceBase(sourceLayer, shift),
|
|
20422
|
+
intGridCsv: level.cells,
|
|
20423
|
+
autoLayerTiles: []
|
|
20424
|
+
}
|
|
20425
|
+
],
|
|
20426
|
+
__neighbours: []
|
|
20427
|
+
}],
|
|
20428
|
+
worlds: [],
|
|
20429
|
+
dummyWorldIid: iid(generic.name, "world")
|
|
20430
|
+
};
|
|
20431
|
+
return JSON.stringify(project2, null, 2) + "\n";
|
|
20432
|
+
}
|
|
20433
|
+
|
|
20066
20434
|
// src/pipeline/tileset-export.ts
|
|
20067
20435
|
function normalizeTileRules(raw) {
|
|
20068
20436
|
if (!isRecord2(raw)) return null;
|
|
@@ -20179,6 +20547,15 @@ function exportTileset(entry, spec, options) {
|
|
|
20179
20547
|
sources: packed.sources
|
|
20180
20548
|
};
|
|
20181
20549
|
}
|
|
20550
|
+
if (options.format === "ldtk") {
|
|
20551
|
+
return {
|
|
20552
|
+
png: packed.png,
|
|
20553
|
+
extension: ".ldtk",
|
|
20554
|
+
document: buildLdtk(generic, spec.tileType),
|
|
20555
|
+
generic,
|
|
20556
|
+
sources: packed.sources
|
|
20557
|
+
};
|
|
20558
|
+
}
|
|
20182
20559
|
return {
|
|
20183
20560
|
png: packed.png,
|
|
20184
20561
|
extension: ".tres",
|
|
@@ -22252,7 +22629,7 @@ async function runPicker(provider, lock, lockPath, opts = {}) {
|
|
|
22252
22629
|
}
|
|
22253
22630
|
|
|
22254
22631
|
// src/gallery/snapshot.ts
|
|
22255
|
-
import { createHash as
|
|
22632
|
+
import { createHash as createHash8 } from "crypto";
|
|
22256
22633
|
import { existsSync as existsSync42 } from "fs";
|
|
22257
22634
|
import { readFile as readFile34, stat as stat5 } from "fs/promises";
|
|
22258
22635
|
import path48 from "path";
|
|
@@ -24019,7 +24396,7 @@ function openInBlender(model, opts = {}) {
|
|
|
24019
24396
|
}
|
|
24020
24397
|
|
|
24021
24398
|
// src/pipeline/model-normals.ts
|
|
24022
|
-
import { createHash as
|
|
24399
|
+
import { createHash as createHash7 } from "crypto";
|
|
24023
24400
|
import { existsSync as existsSync36 } from "fs";
|
|
24024
24401
|
import { mkdir as mkdir16, readdir as readdir6, readFile as readFile28, writeFile as writeFile19 } from "fs/promises";
|
|
24025
24402
|
import path41 from "path";
|
|
@@ -24760,7 +25137,7 @@ function modelNormalDir(editFile) {
|
|
|
24760
25137
|
}
|
|
24761
25138
|
function requestKey(png, options) {
|
|
24762
25139
|
const asked = JSON.stringify([options.mode ?? "lite", options.kind ?? null, options.surfaceDetail ?? null, options.detailSoftness ?? null, options.strength ?? null]);
|
|
24763
|
-
return
|
|
25140
|
+
return createHash7("sha256").update(png).update(asked).digest("hex").slice(0, 16);
|
|
24764
25141
|
}
|
|
24765
25142
|
async function prepare(model, opts) {
|
|
24766
25143
|
const fromEdit = existsSync36(model.editFile);
|
|
@@ -25714,7 +26091,7 @@ function describeEdit(edit) {
|
|
|
25714
26091
|
// src/gallery/snapshot.ts
|
|
25715
26092
|
var PROJECT_FILE_TYPE = "application/octet-stream";
|
|
25716
26093
|
function galleryMediaId(absolutePath) {
|
|
25717
|
-
return
|
|
26094
|
+
return createHash8("sha256").update(path48.resolve(absolutePath)).digest("hex").slice(0, 24);
|
|
25718
26095
|
}
|
|
25719
26096
|
function galleryMediaRoute(id) {
|
|
25720
26097
|
return `/media/${id}`;
|
|
@@ -26530,7 +26907,7 @@ var EDITOR_PIN = pin_default;
|
|
|
26530
26907
|
var EDITOR_RELEASE_BASE = "https://github.com/gfargo/pixelkiln/releases/download";
|
|
26531
26908
|
|
|
26532
26909
|
// src/editor/install.ts
|
|
26533
|
-
import { createHash as
|
|
26910
|
+
import { createHash as createHash9 } from "crypto";
|
|
26534
26911
|
import { existsSync as existsSync44 } from "fs";
|
|
26535
26912
|
import { mkdir as mkdir20, readFile as readFile35, rename as rename13, rm as rm13, stat as stat6, writeFile as writeFile25 } from "fs/promises";
|
|
26536
26913
|
import os3 from "os";
|
|
@@ -26563,7 +26940,7 @@ function editorBaseUrl(pin = EDITOR_PIN) {
|
|
|
26563
26940
|
}
|
|
26564
26941
|
async function sha256Of(file) {
|
|
26565
26942
|
try {
|
|
26566
|
-
return
|
|
26943
|
+
return createHash9("sha256").update(await readFile35(file)).digest("hex");
|
|
26567
26944
|
} catch {
|
|
26568
26945
|
return null;
|
|
26569
26946
|
}
|
|
@@ -26630,7 +27007,7 @@ async function installEditor(opts = {}) {
|
|
|
26630
27007
|
if (bytes.length !== expected.bytes) {
|
|
26631
27008
|
throw new EditorInstallError(`${name}: expected ${expected.bytes} bytes, got ${bytes.length}`, name);
|
|
26632
27009
|
}
|
|
26633
|
-
const digest2 =
|
|
27010
|
+
const digest2 = createHash9("sha256").update(bytes).digest("hex");
|
|
26634
27011
|
if (digest2 !== expected.sha256) {
|
|
26635
27012
|
throw new EditorInstallError(`${name}: sha256 ${digest2.slice(0, 12)}\u2026 does not match the pinned ${expected.sha256.slice(0, 12)}\u2026`, name);
|
|
26636
27013
|
}
|