Stabilize compile by preserving placements unless relayout requested
Some checks are pending
CI / test (push) Waiting to run

This commit is contained in:
Rbanh 2026-02-19 23:41:18 -05:00
parent 77f63a6f80
commit 5f31542cb6
7 changed files with 15 additions and 5 deletions

View File

@ -133,7 +133,7 @@ export function App() {
switch (action.id) {
case "compile":
{
const result = await compile(payload);
const result = await compile(payload, { preserve_placement: true });
actionsApi.setCompileResult(result);
}
break;

View File

@ -2404,9 +2404,9 @@ function layoutAndRouteNative(model, options = {}) {
const renderMode = options.render_mode === "explicit" ? "explicit" : DEFAULT_RENDER_MODE;
const respectLocks = options.respect_locks ?? true;
const autoRotate = options.auto_rotate ?? true;
const preservePlacement = options.preserve_placement === true;
const preservePlacement = options.preserve_placement !== false;
const placed = preservePlacement
? preservePlacedInstances(model, { respectLocks, autoRotate: false })
? preservePlacedInstances(model, { respectLocks, autoRotate })
: placeInstances(model, { respectLocks, autoRotate }).placed;
const placedMap = new Map(placed.map((inst) => [inst.ref, inst]));
const bounds = buildBounds(model, placed);

View File

@ -339,7 +339,12 @@ export function createRequestHandler() {
api_version: API_VERSION,
schema_version: SCHEMA_VERSION,
model: laidOut,
compile: withEnvelopeMeta(compile(laidOut, parsed.options))
compile: withEnvelopeMeta(
compile(laidOut, {
...(parsed.options ?? {}),
preserve_placement: true
})
)
});
} catch (err) {
if (err?.code === "PAYLOAD_TOO_LARGE") {
@ -372,7 +377,12 @@ export function createRequestHandler() {
api_version: API_VERSION,
schema_version: SCHEMA_VERSION,
model: laidOut,
compile: withEnvelopeMeta(compile(laidOut, parsed.options))
compile: withEnvelopeMeta(
compile(laidOut, {
...(parsed.options ?? {}),
preserve_placement: true
})
)
});
} catch (err) {
if (err?.code === "PAYLOAD_TOO_LARGE") {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 244 KiB

After

Width:  |  Height:  |  Size: 244 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 200 KiB

After

Width:  |  Height:  |  Size: 200 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 278 KiB

After

Width:  |  Height:  |  Size: 278 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 198 KiB

After

Width:  |  Height:  |  Size: 191 KiB