mirror of
https://github.com/penpot/penpot.git
synced 2026-11-20 00:50:34 +00:00
* 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
25 lines
932 B
TypeScript
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));
|
|
}
|
|
}
|
|
}
|