pixelkiln 0.111.0 → 0.112.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.cjs
CHANGED
|
@@ -20555,6 +20555,374 @@ function mountStyle(lock, styleId, manifestDir, mount, cells, sources = {}, outp
|
|
|
20555
20555
|
};
|
|
20556
20556
|
}
|
|
20557
20557
|
|
|
20558
|
+
// src/pipeline/ldtk-export.ts
|
|
20559
|
+
var import_node_crypto8 = require("crypto");
|
|
20560
|
+
var LDTK_JSON_VERSION = "1.5.3";
|
|
20561
|
+
var FIRST = 1;
|
|
20562
|
+
var SECOND = 2;
|
|
20563
|
+
var DEMO_WIDTH = 12;
|
|
20564
|
+
var DEMO_HEIGHT = 9;
|
|
20565
|
+
function ldtkRuleMatches(rule, grid, cx, cy) {
|
|
20566
|
+
const radius = Math.floor(rule.size / 2);
|
|
20567
|
+
for (let py = 0; py < rule.size; py++) {
|
|
20568
|
+
for (let px = 0; px < rule.size; px++) {
|
|
20569
|
+
const wanted = rule.pattern[px + py * rule.size];
|
|
20570
|
+
if (wanted === 0) continue;
|
|
20571
|
+
const x = cx + px - radius;
|
|
20572
|
+
const y = cy + py - radius;
|
|
20573
|
+
const inside2 = x >= 0 && y >= 0 && x < grid.width && y < grid.height;
|
|
20574
|
+
const value = inside2 ? grid.cells[y * grid.width + x] : rule.outOfBoundsValue;
|
|
20575
|
+
if (wanted > 0 && value !== wanted) return false;
|
|
20576
|
+
if (wanted < 0 && value === -wanted) return false;
|
|
20577
|
+
}
|
|
20578
|
+
}
|
|
20579
|
+
return true;
|
|
20580
|
+
}
|
|
20581
|
+
function iid(...parts) {
|
|
20582
|
+
const hex2 = (0, import_node_crypto8.createHash)("sha256").update(parts.join("\0")).digest("hex");
|
|
20583
|
+
return `${hex2.slice(0, 8)}-${hex2.slice(8, 12)}-4${hex2.slice(13, 16)}-8${hex2.slice(17, 20)}-${hex2.slice(20, 32)}`;
|
|
20584
|
+
}
|
|
20585
|
+
function identifier(text, fallback) {
|
|
20586
|
+
const slug3 = text.replace(/[^A-Za-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
20587
|
+
return /^[A-Za-z]/.test(slug3) ? slug3 : slug3 ? `${fallback}_${slug3}` : fallback;
|
|
20588
|
+
}
|
|
20589
|
+
function dominantValue(mask) {
|
|
20590
|
+
const first = [0, 1, 2, 3].filter((bit) => (mask & 1 << bit) !== 0).length;
|
|
20591
|
+
return first * 2 >= 4 ? FIRST : SECOND;
|
|
20592
|
+
}
|
|
20593
|
+
function ldtkPattern(rules, mask) {
|
|
20594
|
+
const value = (bit) => (mask & 1 << bit) !== 0 ? FIRST : SECOND;
|
|
20595
|
+
const pattern = new Array(9).fill(0);
|
|
20596
|
+
if (rules.ruleType === "corner") {
|
|
20597
|
+
pattern[4] = value(3);
|
|
20598
|
+
pattern[5] = value(2);
|
|
20599
|
+
pattern[7] = value(1);
|
|
20600
|
+
pattern[8] = value(0);
|
|
20601
|
+
return pattern;
|
|
20602
|
+
}
|
|
20603
|
+
pattern[4] = dominantValue(mask);
|
|
20604
|
+
pattern[1] = value(0);
|
|
20605
|
+
pattern[5] = value(1);
|
|
20606
|
+
pattern[7] = value(2);
|
|
20607
|
+
pattern[3] = value(3);
|
|
20608
|
+
return pattern;
|
|
20609
|
+
}
|
|
20610
|
+
function resolveLdtkTiles(rules, grid) {
|
|
20611
|
+
const out = [];
|
|
20612
|
+
for (let cy = 0; cy < grid.height; cy++) {
|
|
20613
|
+
for (let cx = 0; cx < grid.width; cx++) {
|
|
20614
|
+
const rule = rules.find((candidate) => ldtkRuleMatches(candidate, grid, cx, cy));
|
|
20615
|
+
if (rule) out.push({ cx, cy, rule, tile: rule.tileRectsIds[(cx * 7 + cy * 13) % rule.tileRectsIds.length][0] });
|
|
20616
|
+
}
|
|
20617
|
+
}
|
|
20618
|
+
return out;
|
|
20619
|
+
}
|
|
20620
|
+
function demoGrid(rules, wanted) {
|
|
20621
|
+
let best = null;
|
|
20622
|
+
let bestCovered = -1;
|
|
20623
|
+
for (let seed = 1; seed <= 400; seed++) {
|
|
20624
|
+
let state = seed * 2654435761 >>> 0;
|
|
20625
|
+
const cells = Array.from({ length: DEMO_WIDTH * DEMO_HEIGHT }, () => {
|
|
20626
|
+
state = Math.imul(state, 1664525) + 1013904223 >>> 0;
|
|
20627
|
+
return (state >>> 16) % 100 < 52 ? FIRST : SECOND;
|
|
20628
|
+
});
|
|
20629
|
+
const grid = { width: DEMO_WIDTH, height: DEMO_HEIGHT, cells };
|
|
20630
|
+
const covered = new Set(resolveLdtkTiles(rules, grid).map((hit) => hit.rule.uid)).size;
|
|
20631
|
+
if (covered > bestCovered) {
|
|
20632
|
+
best = grid;
|
|
20633
|
+
bestCovered = covered;
|
|
20634
|
+
}
|
|
20635
|
+
if (covered >= wanted) break;
|
|
20636
|
+
}
|
|
20637
|
+
return best;
|
|
20638
|
+
}
|
|
20639
|
+
var TERRAIN_COLORS = ["#5AB552", "#4C78A8"];
|
|
20640
|
+
function buildLdtk(generic, tileType) {
|
|
20641
|
+
const rules = generic.rules;
|
|
20642
|
+
if (!rules || rules.ruleType === "outline") {
|
|
20643
|
+
throw new Error("ldtk export needs recognized corner or edge adjacency rules; use --format generic");
|
|
20644
|
+
}
|
|
20645
|
+
if (tileType === void 0 || tileType === "isometric" || tileType === "oblique" || tileType === "hex" || tileType === "hex_pointy") {
|
|
20646
|
+
throw new Error(
|
|
20647
|
+
`ldtk export needs square tiles on an orthogonal grid, and this set is ${tileType ?? "isometric"}; use --format generic or --format tiled`
|
|
20648
|
+
);
|
|
20649
|
+
}
|
|
20650
|
+
const grid = generic.tile.width;
|
|
20651
|
+
if (generic.tile.width !== generic.tile.height) {
|
|
20652
|
+
throw new Error(`ldtk grids are square; these tiles are ${generic.tile.width}x${generic.tile.height}`);
|
|
20653
|
+
}
|
|
20654
|
+
const corner = rules.ruleType === "corner";
|
|
20655
|
+
const base = identifier(generic.name.replace("/", "_"), "Tileset");
|
|
20656
|
+
const name = base.charAt(0).toUpperCase() + base.slice(1);
|
|
20657
|
+
const terrainNames = [rules.terrains[0] ?? "feature", rules.terrains[1] ?? "background"];
|
|
20658
|
+
const columns = generic.sheet.columns;
|
|
20659
|
+
const rows = Math.ceil(generic.tiles.length / columns);
|
|
20660
|
+
const byMask = /* @__PURE__ */ new Map();
|
|
20661
|
+
for (const tile of generic.tiles) {
|
|
20662
|
+
if (tile.bitmask === void 0) continue;
|
|
20663
|
+
byMask.set(tile.bitmask, [...byMask.get(tile.bitmask) ?? [], tile.id]);
|
|
20664
|
+
}
|
|
20665
|
+
if (!byMask.size) throw new Error("ldtk export found no tiles with adjacency masks; use --format generic");
|
|
20666
|
+
const tilesetUid = 1;
|
|
20667
|
+
const sourceUid = 2;
|
|
20668
|
+
const autoUid = 3;
|
|
20669
|
+
const groupUid = 4;
|
|
20670
|
+
const ruleList = [...byMask.entries()].map(([mask, ids], index) => ({
|
|
20671
|
+
uid: 5 + index,
|
|
20672
|
+
active: true,
|
|
20673
|
+
size: 3,
|
|
20674
|
+
tileRectsIds: ids.map((id) => [id]),
|
|
20675
|
+
alpha: 1,
|
|
20676
|
+
chance: 1,
|
|
20677
|
+
breakOnMatch: true,
|
|
20678
|
+
pattern: ldtkPattern(rules, mask),
|
|
20679
|
+
flipX: false,
|
|
20680
|
+
flipY: false,
|
|
20681
|
+
xModulo: 1,
|
|
20682
|
+
yModulo: 1,
|
|
20683
|
+
xOffset: 0,
|
|
20684
|
+
yOffset: 0,
|
|
20685
|
+
tileXOffset: 0,
|
|
20686
|
+
tileYOffset: 0,
|
|
20687
|
+
tileRandomXMin: 0,
|
|
20688
|
+
tileRandomXMax: 0,
|
|
20689
|
+
tileRandomYMin: 0,
|
|
20690
|
+
tileRandomYMax: 0,
|
|
20691
|
+
checker: "None",
|
|
20692
|
+
tileMode: "Single",
|
|
20693
|
+
pivotX: 0,
|
|
20694
|
+
pivotY: 0,
|
|
20695
|
+
outOfBoundsValue: SECOND,
|
|
20696
|
+
invalidated: false,
|
|
20697
|
+
perlinActive: false,
|
|
20698
|
+
perlinSeed: 1,
|
|
20699
|
+
perlinScale: 0.2,
|
|
20700
|
+
perlinOctaves: 2
|
|
20701
|
+
}));
|
|
20702
|
+
const levelUid = 5 + ruleList.length;
|
|
20703
|
+
const nextUid = levelUid + 1;
|
|
20704
|
+
const tileRect = (id) => {
|
|
20705
|
+
const tile = generic.tiles.find((candidate) => candidate.id === id);
|
|
20706
|
+
return tile ? { tilesetUid, x: tile.x, y: tile.y, w: tile.width, h: tile.height } : null;
|
|
20707
|
+
};
|
|
20708
|
+
const full = (1 << rules.arity) - 1;
|
|
20709
|
+
const representative = (terrain) => generic.tiles.find((tile) => tile.bitmask === (terrain === 0 ? full : 0))?.id;
|
|
20710
|
+
const shift = corner ? -Math.floor(grid / 2) : 0;
|
|
20711
|
+
const sourceName = `${name}_${corner ? "corners" : "cells"}`;
|
|
20712
|
+
const autoName = name;
|
|
20713
|
+
const layerBase = {
|
|
20714
|
+
guideGridWid: 0,
|
|
20715
|
+
guideGridHei: 0,
|
|
20716
|
+
displayOpacity: 1,
|
|
20717
|
+
inactiveOpacity: 1,
|
|
20718
|
+
hideInList: false,
|
|
20719
|
+
hideFieldsWhenInactive: false,
|
|
20720
|
+
canSelectWhenInactive: true,
|
|
20721
|
+
parallaxFactorX: 0,
|
|
20722
|
+
parallaxFactorY: 0,
|
|
20723
|
+
parallaxScaling: true,
|
|
20724
|
+
requiredTags: [],
|
|
20725
|
+
excludedTags: [],
|
|
20726
|
+
autoTilesKilledByOtherLayerUid: null,
|
|
20727
|
+
uiFilterTags: [],
|
|
20728
|
+
useAsyncRender: false,
|
|
20729
|
+
tilePivotX: 0,
|
|
20730
|
+
tilePivotY: 0,
|
|
20731
|
+
biomeFieldUid: null,
|
|
20732
|
+
gridSize: grid,
|
|
20733
|
+
tilesetDefUid: tilesetUid
|
|
20734
|
+
};
|
|
20735
|
+
const sourceLayer = {
|
|
20736
|
+
__type: "IntGrid",
|
|
20737
|
+
identifier: sourceName,
|
|
20738
|
+
type: "IntGrid",
|
|
20739
|
+
uid: sourceUid,
|
|
20740
|
+
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.`,
|
|
20741
|
+
uiColor: TERRAIN_COLORS[0],
|
|
20742
|
+
...layerBase,
|
|
20743
|
+
renderInWorldView: true,
|
|
20744
|
+
pxOffsetX: shift,
|
|
20745
|
+
pxOffsetY: shift,
|
|
20746
|
+
intGridValues: [FIRST, SECOND].map((value, index) => ({
|
|
20747
|
+
value,
|
|
20748
|
+
identifier: identifier(terrainNames[index], `terrain${value}`),
|
|
20749
|
+
color: TERRAIN_COLORS[index],
|
|
20750
|
+
tile: tileRect(representative(index)),
|
|
20751
|
+
groupUid: 0
|
|
20752
|
+
})),
|
|
20753
|
+
intGridValuesGroups: [],
|
|
20754
|
+
autoRuleGroups: [],
|
|
20755
|
+
autoSourceLayerDefUid: null
|
|
20756
|
+
};
|
|
20757
|
+
const autoLayer = {
|
|
20758
|
+
__type: "AutoLayer",
|
|
20759
|
+
identifier: autoName,
|
|
20760
|
+
type: "AutoLayer",
|
|
20761
|
+
uid: autoUid,
|
|
20762
|
+
doc: `Drawn by rules from ${sourceName}: one rule for each way the two terrains can meet.`,
|
|
20763
|
+
uiColor: TERRAIN_COLORS[1],
|
|
20764
|
+
...layerBase,
|
|
20765
|
+
renderInWorldView: true,
|
|
20766
|
+
pxOffsetX: 0,
|
|
20767
|
+
pxOffsetY: 0,
|
|
20768
|
+
intGridValues: [],
|
|
20769
|
+
intGridValuesGroups: [],
|
|
20770
|
+
autoRuleGroups: [{
|
|
20771
|
+
uid: groupUid,
|
|
20772
|
+
name: "Borders",
|
|
20773
|
+
color: null,
|
|
20774
|
+
icon: null,
|
|
20775
|
+
active: true,
|
|
20776
|
+
isOptional: false,
|
|
20777
|
+
rules: ruleList,
|
|
20778
|
+
usesWizard: false,
|
|
20779
|
+
requiredBiomeValues: [],
|
|
20780
|
+
biomeRequirementMode: 0
|
|
20781
|
+
}],
|
|
20782
|
+
autoSourceLayerDefUid: sourceUid
|
|
20783
|
+
};
|
|
20784
|
+
const level = demoGrid(ruleList, ruleList.length);
|
|
20785
|
+
const hits = resolveLdtkTiles(ruleList, level);
|
|
20786
|
+
const tileAt = (id) => ({ x: id % columns * grid, y: Math.floor(id / columns) * grid });
|
|
20787
|
+
const instanceBase = (layerDef, offset) => ({
|
|
20788
|
+
__identifier: layerDef.identifier,
|
|
20789
|
+
__type: layerDef.__type,
|
|
20790
|
+
__cWid: DEMO_WIDTH,
|
|
20791
|
+
__cHei: DEMO_HEIGHT,
|
|
20792
|
+
__gridSize: grid,
|
|
20793
|
+
__opacity: 1,
|
|
20794
|
+
__pxTotalOffsetX: offset,
|
|
20795
|
+
__pxTotalOffsetY: offset,
|
|
20796
|
+
__tilesetDefUid: tilesetUid,
|
|
20797
|
+
__tilesetRelPath: generic.image,
|
|
20798
|
+
iid: iid(generic.name, "layer", layerDef.uid),
|
|
20799
|
+
levelId: levelUid,
|
|
20800
|
+
layerDefUid: layerDef.uid,
|
|
20801
|
+
pxOffsetX: 0,
|
|
20802
|
+
pxOffsetY: 0,
|
|
20803
|
+
visible: true,
|
|
20804
|
+
optionalRules: [],
|
|
20805
|
+
seed: 1e3 + layerDef.uid,
|
|
20806
|
+
overrideTilesetUid: null,
|
|
20807
|
+
gridTiles: [],
|
|
20808
|
+
entityInstances: []
|
|
20809
|
+
});
|
|
20810
|
+
const project2 = {
|
|
20811
|
+
__header__: {
|
|
20812
|
+
fileType: "LDtk Project JSON",
|
|
20813
|
+
app: "LDtk",
|
|
20814
|
+
doc: "https://ldtk.io/json",
|
|
20815
|
+
schema: "https://ldtk.io/files/JSON_SCHEMA.json",
|
|
20816
|
+
appAuthor: "Sebastien 'deepnight' Benard",
|
|
20817
|
+
appVersion: LDTK_JSON_VERSION,
|
|
20818
|
+
url: "https://ldtk.io"
|
|
20819
|
+
},
|
|
20820
|
+
iid: iid(generic.name, "project"),
|
|
20821
|
+
jsonVersion: LDTK_JSON_VERSION,
|
|
20822
|
+
appBuildId: 473702,
|
|
20823
|
+
nextUid,
|
|
20824
|
+
identifierStyle: "Capitalize",
|
|
20825
|
+
toc: [],
|
|
20826
|
+
worldLayout: "LinearHorizontal",
|
|
20827
|
+
worldGridWidth: 256,
|
|
20828
|
+
worldGridHeight: 256,
|
|
20829
|
+
defaultLevelWidth: DEMO_WIDTH * grid,
|
|
20830
|
+
defaultLevelHeight: DEMO_HEIGHT * grid,
|
|
20831
|
+
defaultPivotX: 0,
|
|
20832
|
+
defaultPivotY: 0,
|
|
20833
|
+
defaultGridSize: grid,
|
|
20834
|
+
defaultEntityWidth: grid,
|
|
20835
|
+
defaultEntityHeight: grid,
|
|
20836
|
+
bgColor: "#4A5066",
|
|
20837
|
+
defaultLevelBgColor: "#474B67",
|
|
20838
|
+
minifyJson: false,
|
|
20839
|
+
externalLevels: false,
|
|
20840
|
+
exportTiled: false,
|
|
20841
|
+
simplifiedExport: false,
|
|
20842
|
+
imageExportMode: "None",
|
|
20843
|
+
exportLevelBg: true,
|
|
20844
|
+
pngFilePattern: null,
|
|
20845
|
+
backupOnSave: false,
|
|
20846
|
+
backupLimit: 10,
|
|
20847
|
+
backupRelPath: null,
|
|
20848
|
+
levelNamePattern: "%world_Level_%idx",
|
|
20849
|
+
tutorialDesc: null,
|
|
20850
|
+
customCommands: [],
|
|
20851
|
+
flags: ["ExportOldTableOfContentData", "UseMultilinesType"],
|
|
20852
|
+
defs: {
|
|
20853
|
+
layers: [autoLayer, sourceLayer],
|
|
20854
|
+
entities: [],
|
|
20855
|
+
tilesets: [{
|
|
20856
|
+
__cWid: columns,
|
|
20857
|
+
__cHei: rows,
|
|
20858
|
+
identifier: `${name}_tiles`,
|
|
20859
|
+
uid: tilesetUid,
|
|
20860
|
+
relPath: generic.image,
|
|
20861
|
+
embedAtlas: null,
|
|
20862
|
+
pxWid: generic.sheet.width,
|
|
20863
|
+
pxHei: generic.sheet.height,
|
|
20864
|
+
tileGridSize: grid,
|
|
20865
|
+
spacing: 0,
|
|
20866
|
+
padding: 0,
|
|
20867
|
+
tags: [],
|
|
20868
|
+
tagsSourceEnumUid: null,
|
|
20869
|
+
enumTags: [],
|
|
20870
|
+
customData: generic.tiles.filter((tile) => tile.bitmask !== void 0).map((tile) => ({ tileId: tile.id, data: `mask=${tile.bitmask}` })),
|
|
20871
|
+
savedSelections: [],
|
|
20872
|
+
cachedPixelData: null
|
|
20873
|
+
}],
|
|
20874
|
+
enums: [],
|
|
20875
|
+
externalEnums: [],
|
|
20876
|
+
levelFields: []
|
|
20877
|
+
},
|
|
20878
|
+
levels: [{
|
|
20879
|
+
identifier: "Preview",
|
|
20880
|
+
iid: iid(generic.name, "level"),
|
|
20881
|
+
uid: levelUid,
|
|
20882
|
+
// A linear world ignores the position; LDtk itself writes -1 for it.
|
|
20883
|
+
worldX: -1,
|
|
20884
|
+
worldY: -1,
|
|
20885
|
+
worldDepth: 0,
|
|
20886
|
+
pxWid: DEMO_WIDTH * grid,
|
|
20887
|
+
pxHei: DEMO_HEIGHT * grid,
|
|
20888
|
+
__bgColor: "#474B67",
|
|
20889
|
+
bgColor: null,
|
|
20890
|
+
useAutoIdentifier: false,
|
|
20891
|
+
bgRelPath: null,
|
|
20892
|
+
bgPos: null,
|
|
20893
|
+
bgPivotX: 0.5,
|
|
20894
|
+
bgPivotY: 0.5,
|
|
20895
|
+
__smartColor: "#9A9CAB",
|
|
20896
|
+
__bgPos: null,
|
|
20897
|
+
externalRelPath: null,
|
|
20898
|
+
fieldInstances: [],
|
|
20899
|
+
layerInstances: [
|
|
20900
|
+
{
|
|
20901
|
+
...instanceBase(autoLayer, 0),
|
|
20902
|
+
intGridCsv: [],
|
|
20903
|
+
autoLayerTiles: hits.map((hit) => ({
|
|
20904
|
+
px: [hit.cx * grid, hit.cy * grid],
|
|
20905
|
+
src: [tileAt(hit.tile).x, tileAt(hit.tile).y],
|
|
20906
|
+
f: 0,
|
|
20907
|
+
t: hit.tile,
|
|
20908
|
+
d: [hit.rule.uid, hit.cy * DEMO_WIDTH + hit.cx],
|
|
20909
|
+
a: 1
|
|
20910
|
+
}))
|
|
20911
|
+
},
|
|
20912
|
+
{
|
|
20913
|
+
...instanceBase(sourceLayer, shift),
|
|
20914
|
+
intGridCsv: level.cells,
|
|
20915
|
+
autoLayerTiles: []
|
|
20916
|
+
}
|
|
20917
|
+
],
|
|
20918
|
+
__neighbours: []
|
|
20919
|
+
}],
|
|
20920
|
+
worlds: [],
|
|
20921
|
+
dummyWorldIid: iid(generic.name, "world")
|
|
20922
|
+
};
|
|
20923
|
+
return JSON.stringify(project2, null, 2) + "\n";
|
|
20924
|
+
}
|
|
20925
|
+
|
|
20558
20926
|
// src/pipeline/tileset-export.ts
|
|
20559
20927
|
function normalizeTileRules(raw) {
|
|
20560
20928
|
if (!isRecord2(raw)) return null;
|
|
@@ -20671,6 +21039,15 @@ function exportTileset(entry, spec, options) {
|
|
|
20671
21039
|
sources: packed.sources
|
|
20672
21040
|
};
|
|
20673
21041
|
}
|
|
21042
|
+
if (options.format === "ldtk") {
|
|
21043
|
+
return {
|
|
21044
|
+
png: packed.png,
|
|
21045
|
+
extension: ".ldtk",
|
|
21046
|
+
document: buildLdtk(generic, spec.tileType),
|
|
21047
|
+
generic,
|
|
21048
|
+
sources: packed.sources
|
|
21049
|
+
};
|
|
21050
|
+
}
|
|
20674
21051
|
return {
|
|
20675
21052
|
png: packed.png,
|
|
20676
21053
|
extension: ".tres",
|
|
@@ -22744,7 +23121,7 @@ async function runPicker(provider, lock, lockPath, opts = {}) {
|
|
|
22744
23121
|
}
|
|
22745
23122
|
|
|
22746
23123
|
// src/gallery/snapshot.ts
|
|
22747
|
-
var
|
|
23124
|
+
var import_node_crypto10 = require("crypto");
|
|
22748
23125
|
var import_node_fs45 = require("fs");
|
|
22749
23126
|
var import_promises39 = require("fs/promises");
|
|
22750
23127
|
var import_node_path49 = __toESM(require("path"), 1);
|
|
@@ -24511,7 +24888,7 @@ function openInBlender(model, opts = {}) {
|
|
|
24511
24888
|
}
|
|
24512
24889
|
|
|
24513
24890
|
// src/pipeline/model-normals.ts
|
|
24514
|
-
var
|
|
24891
|
+
var import_node_crypto9 = require("crypto");
|
|
24515
24892
|
var import_node_fs39 = require("fs");
|
|
24516
24893
|
var import_promises32 = require("fs/promises");
|
|
24517
24894
|
var import_node_path42 = __toESM(require("path"), 1);
|
|
@@ -25252,7 +25629,7 @@ function modelNormalDir(editFile) {
|
|
|
25252
25629
|
}
|
|
25253
25630
|
function requestKey(png, options) {
|
|
25254
25631
|
const asked = JSON.stringify([options.mode ?? "lite", options.kind ?? null, options.surfaceDetail ?? null, options.detailSoftness ?? null, options.strength ?? null]);
|
|
25255
|
-
return (0,
|
|
25632
|
+
return (0, import_node_crypto9.createHash)("sha256").update(png).update(asked).digest("hex").slice(0, 16);
|
|
25256
25633
|
}
|
|
25257
25634
|
async function prepare(model, opts) {
|
|
25258
25635
|
const fromEdit = (0, import_node_fs39.existsSync)(model.editFile);
|
|
@@ -26206,7 +26583,7 @@ function describeEdit(edit) {
|
|
|
26206
26583
|
// src/gallery/snapshot.ts
|
|
26207
26584
|
var PROJECT_FILE_TYPE = "application/octet-stream";
|
|
26208
26585
|
function galleryMediaId(absolutePath) {
|
|
26209
|
-
return (0,
|
|
26586
|
+
return (0, import_node_crypto10.createHash)("sha256").update(import_node_path49.default.resolve(absolutePath)).digest("hex").slice(0, 24);
|
|
26210
26587
|
}
|
|
26211
26588
|
function galleryMediaRoute(id) {
|
|
26212
26589
|
return `/media/${id}`;
|
|
@@ -27022,7 +27399,7 @@ var EDITOR_PIN = pin_default;
|
|
|
27022
27399
|
var EDITOR_RELEASE_BASE = "https://github.com/gfargo/pixelkiln/releases/download";
|
|
27023
27400
|
|
|
27024
27401
|
// src/editor/install.ts
|
|
27025
|
-
var
|
|
27402
|
+
var import_node_crypto11 = require("crypto");
|
|
27026
27403
|
var import_node_fs47 = require("fs");
|
|
27027
27404
|
var import_promises40 = require("fs/promises");
|
|
27028
27405
|
var import_node_os4 = __toESM(require("os"), 1);
|
|
@@ -27055,7 +27432,7 @@ function editorBaseUrl(pin = EDITOR_PIN) {
|
|
|
27055
27432
|
}
|
|
27056
27433
|
async function sha256Of(file) {
|
|
27057
27434
|
try {
|
|
27058
|
-
return (0,
|
|
27435
|
+
return (0, import_node_crypto11.createHash)("sha256").update(await (0, import_promises40.readFile)(file)).digest("hex");
|
|
27059
27436
|
} catch {
|
|
27060
27437
|
return null;
|
|
27061
27438
|
}
|
|
@@ -27122,7 +27499,7 @@ async function installEditor(opts = {}) {
|
|
|
27122
27499
|
if (bytes.length !== expected.bytes) {
|
|
27123
27500
|
throw new EditorInstallError(`${name}: expected ${expected.bytes} bytes, got ${bytes.length}`, name);
|
|
27124
27501
|
}
|
|
27125
|
-
const digest2 = (0,
|
|
27502
|
+
const digest2 = (0, import_node_crypto11.createHash)("sha256").update(bytes).digest("hex");
|
|
27126
27503
|
if (digest2 !== expected.sha256) {
|
|
27127
27504
|
throw new EditorInstallError(`${name}: sha256 ${digest2.slice(0, 12)}\u2026 does not match the pinned ${expected.sha256.slice(0, 12)}\u2026`, name);
|
|
27128
27505
|
}
|
|
@@ -27265,7 +27642,7 @@ function createGalleryEditorHandlers(opts = {}) {
|
|
|
27265
27642
|
}
|
|
27266
27643
|
|
|
27267
27644
|
// src/gallery/server.ts
|
|
27268
|
-
var
|
|
27645
|
+
var import_node_crypto12 = require("crypto");
|
|
27269
27646
|
var import_node_http2 = require("http");
|
|
27270
27647
|
var import_promises42 = require("fs/promises");
|
|
27271
27648
|
var MAX_EDIT_BYTES = 48 * 1024 * 1024;
|
|
@@ -27295,7 +27672,7 @@ async function readJsonBody(req) {
|
|
|
27295
27672
|
async function serveGallery(opts) {
|
|
27296
27673
|
const log = opts.onProgress ?? (() => {
|
|
27297
27674
|
});
|
|
27298
|
-
const session = opts.edit || opts.generate || opts.editor || opts.skeleton || opts.price ? (0,
|
|
27675
|
+
const session = opts.edit || opts.generate || opts.editor || opts.skeleton || opts.price ? (0, import_node_crypto12.randomBytes)(16).toString("hex") : null;
|
|
27299
27676
|
let media = /* @__PURE__ */ new Map();
|
|
27300
27677
|
let loading = null;
|
|
27301
27678
|
const reviewAssets = /* @__PURE__ */ new Map();
|
|
@@ -27499,7 +27876,7 @@ async function serveGallery(opts) {
|
|
|
27499
27876
|
try {
|
|
27500
27877
|
if (url2.pathname === "/") {
|
|
27501
27878
|
const { snapshot } = await load();
|
|
27502
|
-
const nonce = (0,
|
|
27879
|
+
const nonce = (0, import_node_crypto12.randomBytes)(16).toString("base64");
|
|
27503
27880
|
res.writeHead(200, {
|
|
27504
27881
|
"Content-Type": "text/html; charset=utf-8",
|
|
27505
27882
|
"Cache-Control": "no-store",
|
|
@@ -27574,7 +27951,7 @@ async function serveGallery(opts) {
|
|
|
27574
27951
|
}
|
|
27575
27952
|
|
|
27576
27953
|
// src/gallery/generate.ts
|
|
27577
|
-
var
|
|
27954
|
+
var import_node_crypto13 = require("crypto");
|
|
27578
27955
|
var import_zod17 = require("zod");
|
|
27579
27956
|
var GenerateRequestSchema = import_zod17.z.object({
|
|
27580
27957
|
project: import_zod17.z.string().min(1).optional(),
|
|
@@ -27874,7 +28251,7 @@ function createGenerateHandlers(opts) {
|
|
|
27874
28251
|
}
|
|
27875
28252
|
}
|
|
27876
28253
|
const job = {
|
|
27877
|
-
id: (0,
|
|
28254
|
+
id: (0, import_node_crypto13.randomBytes)(8).toString("hex"),
|
|
27878
28255
|
project: request.project ?? null,
|
|
27879
28256
|
keys: request.keys,
|
|
27880
28257
|
mode: request.refresh ? "refresh" : request.resume ? "resume" : request.restore ? "restore" : request.revert !== void 0 ? "revert" : "generate",
|