@bendyline/molen-tooling 0.0.11 → 0.0.13
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/capture/harness.js +682 -293
- package/dist/capture/worldgen-preview.js +396 -298
- package/dist/cli.mjs +2 -2
- package/dist/docs-src/guide/3d-art-guidelines.md +34 -10
- package/dist/docs-src/guide/3d-model-assets.md +27 -2
- package/dist/docs-src/guide/adaptive-performance.md +42 -7
- package/dist/docs-src/guide/aircraft.md +249 -27
- package/dist/docs-src/guide/ambient-life.md +28 -5
- package/dist/docs-src/guide/audio.md +19 -5
- package/dist/docs-src/guide/boats.md +9 -4
- package/dist/docs-src/guide/boost-mode.md +64 -0
- package/dist/docs-src/guide/building-interiors.md +7 -2
- package/dist/docs-src/guide/determinism.md +1 -1
- package/dist/docs-src/guide/dioramas.md +17 -4
- package/dist/docs-src/guide/earth-view.md +225 -24
- package/dist/docs-src/guide/entities.md +87 -5
- package/dist/docs-src/guide/figures.md +31 -7
- package/dist/docs-src/guide/graphics-performance.md +203 -24
- package/dist/docs-src/guide/input.md +34 -1
- package/dist/docs-src/guide/liveries.md +167 -0
- package/dist/docs-src/guide/livery-catalog.md +2659 -0
- package/dist/docs-src/guide/livery-gallery.md +2684 -0
- package/dist/docs-src/guide/medium-fi.md +279 -27
- package/dist/docs-src/guide/navigation.md +5 -2
- package/dist/docs-src/guide/night-lighting.md +96 -0
- package/dist/docs-src/guide/project.md +6 -1
- package/dist/docs-src/guide/recognizable-places.md +6 -0
- package/dist/docs-src/guide/regional-fleets.md +94 -0
- package/dist/docs-src/guide/regional-world.md +19 -6
- package/dist/docs-src/guide/rendering-backends.md +6 -2
- package/dist/docs-src/guide/sky.md +36 -3
- package/dist/docs-src/guide/structure-library.md +4 -1
- package/dist/docs-src/guide/surface-rendering.md +276 -2
- package/dist/docs-src/guide/terrain.md +43 -0
- package/dist/docs-src/guide/typography.md +105 -0
- package/dist/docs-src/guide/vehicle-interiors.md +169 -9
- package/dist/docs-src/guide/vehicles.md +26 -3
- package/dist/docs-src/guide/weather.md +15 -8
- package/dist/docs-src/guide/worldgen.md +100 -13
- package/dist/docs-src/llms.txt +9 -1
- package/dist/docs-src/schemas/README.md +3 -0
- package/dist/docs-src/schemas/archstyle.md +65 -0
- package/dist/docs-src/schemas/components.md +2009 -213
- package/dist/docs-src/schemas/fleet-catalog.md +113 -0
- package/dist/docs-src/schemas/landmark.md +10 -0
- package/dist/docs-src/schemas/matgraph.md +11 -1
- package/dist/docs-src/schemas/pack-source.md +11 -1
- package/dist/docs-src/schemas/pack.md +1 -1
- package/dist/docs-src/schemas/project.md +1 -1
- package/dist/docs-src/schemas/regional-catalog.md +39 -0
- package/dist/docs-src/schemas/scatter.md +36 -0
- package/dist/docs-src/schemas/structure-placement-data.md +753 -0
- package/dist/docs-src/schemas/structure-placement-index.md +87 -0
- package/dist/docs-src/schemas/structure-placements.md +274 -0
- package/dist/docs-src/schemas/transport-network.md +8 -0
- package/dist/docs-src/schemas/types.md +1 -1
- package/dist/docs-src/schemas/worldgen-batch.md +145 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +1 -1
- package/dist/{mcp-BbxqqnD1.mjs → mcp-BXaK46X-.mjs} +1 -1
- package/dist/{ops-b4Pag8U-.mjs → ops-Cm7WNvb9.mjs} +55 -22
- package/dist/templates/city-courier/gen/molen-types.ts +240 -17
- package/dist/templates/city-courier/scripts/molen-scripts.d.ts +240 -17
- package/dist/templates/figures-gallery/test/headless.test.ts +2 -1
- package/dist/templates/index.json +17 -17
- package/dist/templates/skybound/gen/molen-types.ts +240 -17
- package/dist/templates/skybound/scripts/molen-scripts.d.ts +240 -17
- package/dist/templates/top-down-arena/scripts/molen-scripts.d.ts +240 -17
- package/dist/templates/top-down-arena/src/gen/molen-types.ts +240 -17
- package/package.json +13 -13
|
@@ -29,6 +29,7 @@ import { AudioDirector, entitySourceFromWorld, mergeSoundbanks } from "@bendylin
|
|
|
29
29
|
import { diffKeyframes, firstDivergentTick, formatAssertionResults, perTickHashes, runAssertions, runHeadless } from "@bendyline/molen-kernel/testing";
|
|
30
30
|
import { hashJson } from "@bendyline/molen-kernel/determinism";
|
|
31
31
|
import { PMTiles } from "pmtiles";
|
|
32
|
+
import { loadFontLibrary } from "@bendyline/molen-materials/text";
|
|
32
33
|
//#region src/capture-server.ts
|
|
33
34
|
const MIME$1 = {
|
|
34
35
|
".html": "text/html; charset=utf-8",
|
|
@@ -603,6 +604,34 @@ async function playExperience(input) {
|
|
|
603
604
|
}
|
|
604
605
|
}
|
|
605
606
|
//#endregion
|
|
607
|
+
//#region src/file-io.ts
|
|
608
|
+
const WINDOWS_FILE_LOCKS = new Set([
|
|
609
|
+
"EBUSY",
|
|
610
|
+
"EPERM",
|
|
611
|
+
"EACCES",
|
|
612
|
+
"EUNKNOWN",
|
|
613
|
+
"UNKNOWN"
|
|
614
|
+
]);
|
|
615
|
+
/** Retry short-lived Windows scanner/editor locks at the filesystem operation, not the import. */
|
|
616
|
+
async function retryFileOperation(operation) {
|
|
617
|
+
for (let attempt = 0;; attempt++) try {
|
|
618
|
+
return await operation();
|
|
619
|
+
} catch (error) {
|
|
620
|
+
if (process.platform !== "win32" || attempt >= 20 || !WINDOWS_FILE_LOCKS.has(error.code ?? "")) throw error;
|
|
621
|
+
await new Promise((done) => setTimeout(done, Math.min(25 * 2 ** attempt, 250)));
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
/** Replace a file without truncating a destination that another process may have mapped. */
|
|
625
|
+
async function writeFileAtomic(path, data) {
|
|
626
|
+
const temporary = `${path}.${process.pid}.${randomUUID()}.tmp`;
|
|
627
|
+
try {
|
|
628
|
+
await retryFileOperation(() => writeFile(temporary, data));
|
|
629
|
+
await retryFileOperation(() => rename(temporary, path));
|
|
630
|
+
} finally {
|
|
631
|
+
await retryFileOperation(() => rm(temporary, { force: true }));
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
//#endregion
|
|
606
635
|
//#region src/content.ts
|
|
607
636
|
/** Where downloaded packs are cached: $MOLEN_CACHE_DIR, else the XDG cache, else ~/.cache. */
|
|
608
637
|
function packCacheDir() {
|
|
@@ -792,21 +821,24 @@ async function updateProjectFile(path, mutate) {
|
|
|
792
821
|
const lockPath = `${projectPath}.lock`;
|
|
793
822
|
const start = Date.now();
|
|
794
823
|
const staleAfterMs = 3e4;
|
|
795
|
-
const waitLimitMs =
|
|
824
|
+
const waitLimitMs = 3e4;
|
|
796
825
|
for (;;) try {
|
|
797
|
-
const handle = await open(lockPath, "wx");
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
826
|
+
const handle = await retryFileOperation(() => open(lockPath, "wx"));
|
|
827
|
+
try {
|
|
828
|
+
await handle.writeFile(`${JSON.stringify({
|
|
829
|
+
pid: process.pid,
|
|
830
|
+
createdAt: Date.now()
|
|
831
|
+
})}\n`);
|
|
832
|
+
} finally {
|
|
833
|
+
await handle.close();
|
|
834
|
+
}
|
|
803
835
|
break;
|
|
804
836
|
} catch (error) {
|
|
805
837
|
if (error.code !== "EEXIST") throw error;
|
|
806
838
|
try {
|
|
807
839
|
const info = await stat(lockPath);
|
|
808
840
|
if (Date.now() - info.mtimeMs > staleAfterMs) {
|
|
809
|
-
await rm(lockPath, { force: true });
|
|
841
|
+
await retryFileOperation(() => rm(lockPath, { force: true }));
|
|
810
842
|
continue;
|
|
811
843
|
}
|
|
812
844
|
} catch (statError) {
|
|
@@ -816,21 +848,18 @@ async function updateProjectFile(path, mutate) {
|
|
|
816
848
|
if (Date.now() - start > waitLimitMs) throw new Error(`project manifest is locked by another writer: ${lockPath}`);
|
|
817
849
|
await new Promise((r) => setTimeout(r, 25));
|
|
818
850
|
}
|
|
819
|
-
const tmpPath = `${projectPath}.${process.pid}.${randomUUID()}.tmp`;
|
|
820
851
|
try {
|
|
821
|
-
const parsed = validate("project", parseJson(await readFile(projectPath, "utf8")));
|
|
852
|
+
const parsed = validate("project", parseJson(await retryFileOperation(() => readFile(projectPath, "utf8"))));
|
|
822
853
|
if (!parsed.ok) throw new Error(parsed.formatted);
|
|
823
854
|
const manifest = parsed.value;
|
|
855
|
+
const before = JSON.stringify(manifest);
|
|
824
856
|
const next = mutate(manifest) ?? manifest;
|
|
825
857
|
const reparsed = validate("project", JSON.parse(JSON.stringify(next)));
|
|
826
858
|
if (!reparsed.ok) throw new Error(`project.json update produced an invalid manifest:\n${reparsed.formatted}`);
|
|
827
|
-
await
|
|
828
|
-
await writeFile(tmpPath, `${JSON.stringify(reparsed.value, null, 2)}\n`);
|
|
829
|
-
await rename(tmpPath, projectPath);
|
|
859
|
+
if (JSON.stringify(reparsed.value) !== before) await writeFileAtomic(projectPath, `${JSON.stringify(reparsed.value, null, 2)}\n`);
|
|
830
860
|
return reparsed.value;
|
|
831
861
|
} finally {
|
|
832
|
-
await rm(
|
|
833
|
-
await rm(lockPath, { force: true });
|
|
862
|
+
await retryFileOperation(() => rm(lockPath, { force: true }));
|
|
834
863
|
}
|
|
835
864
|
}
|
|
836
865
|
/**
|
|
@@ -1186,7 +1215,7 @@ async function importAsset(input) {
|
|
|
1186
1215
|
if (resolved.warning !== void 0) warnings.push(resolved.warning);
|
|
1187
1216
|
let registeredAssets = {};
|
|
1188
1217
|
if (projectPath !== void 0) {
|
|
1189
|
-
const project = validate("project", parseJson(await readFile(projectPath, "utf8")));
|
|
1218
|
+
const project = validate("project", parseJson(await retryFileOperation(() => readFile(projectPath, "utf8"))));
|
|
1190
1219
|
if (!project.ok) return {
|
|
1191
1220
|
ok: false,
|
|
1192
1221
|
error: project.formatted
|
|
@@ -1214,7 +1243,7 @@ async function importAsset(input) {
|
|
|
1214
1243
|
};
|
|
1215
1244
|
let existing;
|
|
1216
1245
|
try {
|
|
1217
|
-
existing = parseJson(await readFile(sidecarPath, "utf8"));
|
|
1246
|
+
existing = parseJson(await retryFileOperation(() => readFile(sidecarPath, "utf8")));
|
|
1218
1247
|
} catch (error) {
|
|
1219
1248
|
if (error.code !== "ENOENT" && !(error instanceof SyntaxError)) throw error;
|
|
1220
1249
|
}
|
|
@@ -1336,7 +1365,7 @@ async function importAsset(input) {
|
|
|
1336
1365
|
});
|
|
1337
1366
|
await mkdir(dir, { recursive: true });
|
|
1338
1367
|
const glb = await io.writeBinary(doc);
|
|
1339
|
-
await
|
|
1368
|
+
await writeFileAtomic(join(dir, "model.glb"), glb);
|
|
1340
1369
|
let trimeshHeader;
|
|
1341
1370
|
let collisionFile;
|
|
1342
1371
|
if (input.trimesh === true) {
|
|
@@ -1352,7 +1381,7 @@ async function importAsset(input) {
|
|
|
1352
1381
|
});
|
|
1353
1382
|
const encoded = encodeCollisionTrimesh(positions, new Uint32Array(allIndices));
|
|
1354
1383
|
collisionFile = "collision.bin";
|
|
1355
|
-
await
|
|
1384
|
+
await writeFileAtomic(join(dir, collisionFile), encoded.bin);
|
|
1356
1385
|
trimeshHeader = {
|
|
1357
1386
|
bin: collisionFile,
|
|
1358
1387
|
positions: encoded.positions,
|
|
@@ -1396,7 +1425,7 @@ async function importAsset(input) {
|
|
|
1396
1425
|
ok: false,
|
|
1397
1426
|
error: `sidecar failed self-validation:\n${checked.formatted}`
|
|
1398
1427
|
};
|
|
1399
|
-
await
|
|
1428
|
+
await writeFileAtomic(sidecarPath, `${JSON.stringify(checked.value, null, 2)}\n`);
|
|
1400
1429
|
try {
|
|
1401
1430
|
await stat(sidecarPath);
|
|
1402
1431
|
} catch (e) {
|
|
@@ -7730,9 +7759,12 @@ async function landmarkDocs(source) {
|
|
|
7730
7759
|
}
|
|
7731
7760
|
async function withLandmarks(loaded, own, options) {
|
|
7732
7761
|
const source = await providedBy("landmarks", own, options);
|
|
7733
|
-
|
|
7762
|
+
const fontSource = await providedBy("fonts", own, options);
|
|
7763
|
+
const fonts = fontSource ? await loadFontLibrary(await fontSource.pack.readJson(fontSource.path), (path) => fontSource.pack.readJson(fontSource.path.slice(0, fontSource.path.lastIndexOf("/") + 1) + path)) : void 0;
|
|
7764
|
+
return {
|
|
7734
7765
|
...loaded,
|
|
7735
|
-
landmarks: await landmarkDocs(source)
|
|
7766
|
+
...source ? { landmarks: await landmarkDocs(source) } : {},
|
|
7767
|
+
...fonts ? { fonts } : {}
|
|
7736
7768
|
};
|
|
7737
7769
|
}
|
|
7738
7770
|
async function stylePackAt(path) {
|
|
@@ -8310,6 +8342,7 @@ async function previewWorldgenImpl(input) {
|
|
|
8310
8342
|
filesBaseUrl,
|
|
8311
8343
|
assetIndex: stylePackAssetIndex(pack, filesBaseUrl),
|
|
8312
8344
|
landmarks,
|
|
8345
|
+
...loaded.fonts ? { fonts: loaded.fonts } : {},
|
|
8313
8346
|
materialRefs: [...new Set(output.buildings?.groups.map((group) => group.materialRef) ?? [])],
|
|
8314
8347
|
ground: {
|
|
8315
8348
|
y: groundY,
|