Dr. Dominik Jain 36cf4f39e1
✨ Apply method Penpot.waitForLayoutUpdate, removing workarounds (#11433)
* MCP server: Update instruction manual to point to method instead of sleep
* MCP plugin: Call waitForLayoutUpdate prior to every code execution
* Composable test suite: Use waitForLayoutUpdate instead of 200ms delay in tests
2026-08-31 14:10:28 +02:00

25 lines
932 B
TypeScript

/**
* Timing utilities for the composable tests.
*/
export class PenpotSync {
/** The fixed settling delay, in milliseconds, used by `awaitPropagation`. */
private static readonly PROPAGATION_MS = 200;
/**
* Waits for component-change propagation to settle. Reads can otherwise race
* ahead of the propagation a preceding edit triggers. This is a pragmatic
* fixed delay; it is intended to be replaced once the Plugin API offers an
* explicit "wait for propagation" primitive.
*/
static awaitPropagation(): Promise<void> {
// @ts-ignore
if (penpot.waitForLayoutUpdate) {
// @ts-ignore
return penpot.waitForLayoutUpdate();
} else {
throw new Error("PenpotSync.awaitPropagation: waitForLayoutUpdate is not available");
return new Promise((resolve) => setTimeout(resolve, PenpotSync.PROPAGATION_MS));
}
}
}