Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Use Playwright's base image
FROM mcr.microsoft.com/playwright:v1.55.0-jammy
FROM mcr.microsoft.com/playwright:v1.56.1-jammy

# Set the working directory
WORKDIR /work
Expand Down
20 changes: 20 additions & 0 deletions examples/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import type {
NodeTextLoadedPayload,
INode,
ITextNode,
RendererMain,
} from '@lightningjs/renderer';

export async function waitForLoadedDimensions(
Expand All @@ -37,3 +38,22 @@ export async function waitForLoadedDimensions(
});
});
}

export async function waitUntilIdle(renderer: RendererMain): Promise<boolean> {
return new Promise((resolve, reject) => {
if (renderer === undefined) {
reject(false);
return;
}
const done = () => {
renderer.off('idle', onRendererIdle);
};

const onRendererIdle = () => {
done();
resolve(true);
};

renderer.on('idle', onRendererIdle);
});
}
9 changes: 5 additions & 4 deletions examples/tests/text-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,9 @@ class BoxedText extends EventEmitter implements BoxedTextProps {
this.node = renderer.createNode({
x: props.x,
y: props.y,
colorTop: props.boxColor1,
colorBottom: props.boxColor2,
color: 0xff0000ff,
// colorTop: props.boxColor1,
// colorBottom: props.boxColor2,
shader: renderer.createShader('RoundedRectangle', {
radius: 10,
}),
Expand All @@ -222,9 +223,9 @@ class BoxedText extends EventEmitter implements BoxedTextProps {
};

private layout(textDimensions: Dimensions) {
this.node.w = textDimensions.width + BUTTON_PADDING * 2;
this.node.w = textDimensions.w + BUTTON_PADDING * 2;
this.node.h = textDimensions.h + BUTTON_PADDING * 2;
this.textNode.x = this.node.w / 2 - textDimensions.width / 2;
this.textNode.x = this.node.w / 2 - textDimensions.w / 2;
this.textNode.y = this.node.h / 2 - textDimensions.h / 2;
this.textNode.alpha = 1;
this.emit('afterLayout');
Expand Down
6 changes: 3 additions & 3 deletions examples/tests/text-layout-consistency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ export default async function test({ renderer, testRoot }: ExampleSettings) {
let i = 0;
const mutations = [
() => {
canvasText.w = sdfText.w = background.w = 250;
canvasText.maxWidth = sdfText.maxWidth = background.w = 250;
},
() => {
canvasText.w = sdfText.w = background.w = 350;
canvasText.maxWidth = sdfText.maxWidth = background.w = 350;
},
() => {
canvasText.w = sdfText.w = background.w = 500;
canvasText.maxWidth = sdfText.maxWidth = background.w = 500;
},
];

Expand Down
18 changes: 9 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/core/text-rendering/CanvasFontHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ export const isFontLoaded = (fontFamily: string): boolean => {
* @param node
*/
export const waitingForFont = (fontFamily: string, node: CoreTextNode) => {
if (nodesWaitingForFont[fontFamily] === undefined) {
return;
}
nodesWaitingForFont[fontFamily]![node.id] = node;
};

Expand Down
3 changes: 3 additions & 0 deletions src/core/text-rendering/SdfFontHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,9 @@ export const loadFont = async (
* @param {CoreTextNode} node - Node that was waiting for the font
*/
export const waitingForFont = (fontFamily: string, node: CoreTextNode) => {
if (nodesWaitingForFont[fontFamily] === undefined) {
return;
}
nodesWaitingForFont[fontFamily]![node.id] = node;
};

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion visual-regression/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@types/pixelmatch": "^5.2.6",
"@types/pngjs": "^6.0.5",
"@types/yargs": "^17.0.31",
"playwright": "^1.55.0",
"playwright": "^1.56.1",
"wait-port": "^1.1.0"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion visual-regression/src/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export function compareBuffers(
diff.data,
width,
height,
{ threshold: 0.1 }, // Adjust threshold for sensitivity
{ threshold: 0.8 }, // Adjust threshold for sensitivity
);

const doesMatch = count === 0;
Expand Down