Skip to content

Commit 61ff99e

Browse files
committed
Reapply "Merge branch 'main' into feat/make-fps-updates-activatable-at-runtime"
This reverts commit 38e9158.
1 parent 38e9158 commit 61ff99e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1083
-455
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ COPY .npmrc .npmrc
99
COPY package.json package.json
1010

1111
# Install PNPM
12-
RUN corepack prepare && corepack enable
12+
RUN corepack enable && corepack prepare [email protected] --activate
1313

1414
# Get pnpm to install the version of Node declared in .npmrc
1515
RUN pnpm exec ls

examples/common/constructTestRow.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,15 @@ import { waitForLoadedDimensions } from './utils.js';
2222

2323
const CONTAINER_SIZE = 200;
2424
const PADDING = 20;
25+
const POSITION = null;
2526

2627
export interface TestRowOptions {
2728
renderer: RendererMain;
2829
rowNode: INode;
2930
containerSize?: number;
31+
containerHeight?: number;
3032
padding?: number;
33+
descriptionPosition?: 'top' | 'bottom';
3134
}
3235

3336
export async function constructTestRow(
@@ -38,28 +41,36 @@ export async function constructTestRow(
3841
renderer,
3942
rowNode,
4043
containerSize = CONTAINER_SIZE,
44+
containerHeight = containerSize,
4145
padding = PADDING,
46+
descriptionPosition = POSITION,
4247
} = options;
4348
let curX = 0;
4449
const curY = 0;
4550
for (const testNode of testNodes) {
51+
let textPos =
52+
descriptionPosition === 'top'
53+
? 0
54+
: descriptionPosition === 'bottom'
55+
? containerHeight + padding
56+
: containerHeight / 2;
4657
if (typeof testNode === 'string') {
4758
const dimensions = await waitForLoadedDimensions(
4859
renderer.createTextNode({
49-
mountY: 0.5,
60+
mountY: descriptionPosition ? 1 : 0.5,
5061
x: curX,
51-
y: containerSize / 2,
62+
y: textPos,
5263
text: testNode,
5364
parent: rowNode,
5465
}),
5566
);
56-
curX += dimensions.width + padding;
67+
curX += descriptionPosition ? 0 : dimensions.width + padding;
5768
} else {
5869
const container = renderer.createNode({
5970
parent: rowNode,
6071
color: 0xffffffff,
6172
width: containerSize,
62-
height: containerSize,
73+
height: containerHeight,
6374
clipping: true,
6475
x: curX,
6576
y: curY,
@@ -68,5 +79,5 @@ export async function constructTestRow(
6879
curX += containerSize + padding;
6980
}
7081
}
71-
return curY + containerSize;
82+
return curY + containerHeight;
7283
}

examples/tests/text-wordbreak.ts

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
import type { ITextNodeProps, RendererMain } from '@lightningjs/renderer';
2+
import type { ExampleSettings } from '../common/ExampleSettings.js';
3+
import { paginateTestRows, type TestRow } from '../common/paginateTestRows.js';
4+
import { PageContainer } from '../common/PageContainer.js';
5+
import { constructTestRow } from '../common/constructTestRow.js';
6+
7+
export async function automation(settings: ExampleSettings) {
8+
// Snapshot all the pages
9+
await (await test(settings)).snapshotPages();
10+
}
11+
12+
export default async function test(settings: ExampleSettings) {
13+
const { renderer } = settings;
14+
const pageContainer = new PageContainer(settings, {
15+
width: renderer.settings.appWidth,
16+
height: renderer.settings.appHeight,
17+
title: 'Text wordBreak',
18+
});
19+
20+
await paginateTestRows(pageContainer, [
21+
...generateWordBreakTest(renderer, 'sdf', 4),
22+
...generateWordBreakTest(renderer, 'sdf', 3),
23+
...generateWordBreakTest(renderer, 'sdf', 2),
24+
...generateWordBreakTest(renderer, 'sdf', 1),
25+
]);
26+
27+
return pageContainer;
28+
}
29+
30+
const containerSize = 555;
31+
const containerHeight = 200;
32+
const descriptionPosition = 'top';
33+
const NODE_PROPS = {
34+
x: 0,
35+
y: 0,
36+
color: 0x000000ff,
37+
text: `This is a long and Honorificabilitudinitatibus califragilisticexpialidocious Taumatawhakatangihangakoauauotamateaturipukakapikimaungahoronukupokaiwhenuakitanatahu`,
38+
fontFamily: 'Ubuntu',
39+
textRendererOverride: 'sdf',
40+
fontSize: 20,
41+
contain: 'width',
42+
width: containerSize,
43+
height: containerHeight,
44+
wordBreak: 'normal',
45+
} satisfies Partial<ITextNodeProps>;
46+
47+
function generateWordBreakTest(
48+
renderer: RendererMain,
49+
textRenderer: 'canvas' | 'sdf',
50+
maxLines: number,
51+
): TestRow[] {
52+
const text1 = `'wordBreak: normal' - which is the default.`;
53+
const text2 = `'wordBreak: breakAll'`;
54+
const text3 = `'wordBreak: breakWord'`;
55+
56+
return [
57+
{
58+
title: maxLines < 4 ? `${text1} Maxlines set to ${maxLines}` : text1,
59+
content: async (rowNode) => {
60+
const nodeProps = {
61+
...NODE_PROPS,
62+
textRendererOverride: textRenderer,
63+
} satisfies Partial<ITextNodeProps>;
64+
65+
return await constructTestRow(
66+
{
67+
renderer,
68+
rowNode,
69+
containerSize,
70+
descriptionPosition,
71+
containerHeight,
72+
},
73+
[
74+
'Renderer: sdf',
75+
renderer.createTextNode({
76+
...nodeProps,
77+
maxLines,
78+
textRendererOverride: 'sdf',
79+
}),
80+
'Renderer: canvas',
81+
renderer.createTextNode({
82+
...nodeProps,
83+
maxLines,
84+
textRendererOverride: 'canvas',
85+
}),
86+
],
87+
);
88+
},
89+
},
90+
{
91+
title: maxLines < 4 ? `${text2} and maxlines set to ${maxLines}` : text2,
92+
content: async (rowNode) => {
93+
const nodeProps = {
94+
...NODE_PROPS,
95+
textRendererOverride: textRenderer,
96+
} satisfies Partial<ITextNodeProps>;
97+
98+
return await constructTestRow(
99+
{
100+
renderer,
101+
rowNode,
102+
containerSize,
103+
descriptionPosition,
104+
containerHeight,
105+
},
106+
[
107+
'Renderer: sdf',
108+
renderer.createTextNode({
109+
...nodeProps,
110+
maxLines,
111+
wordBreak: 'break-all',
112+
textRendererOverride: 'sdf',
113+
}),
114+
'Renderer: canvas',
115+
renderer.createTextNode({
116+
...nodeProps,
117+
maxLines,
118+
wordBreak: 'break-all',
119+
textRendererOverride: 'canvas',
120+
}),
121+
],
122+
);
123+
},
124+
},
125+
{
126+
title: maxLines < 4 ? `${text3} and maxlines set to ${maxLines}` : text3,
127+
content: async (rowNode) => {
128+
const nodeProps = {
129+
...NODE_PROPS,
130+
textRendererOverride: textRenderer,
131+
} satisfies Partial<ITextNodeProps>;
132+
133+
return await constructTestRow(
134+
{
135+
renderer,
136+
rowNode,
137+
containerSize,
138+
descriptionPosition,
139+
containerHeight,
140+
},
141+
[
142+
'Renderer: sdf',
143+
renderer.createTextNode({
144+
...nodeProps,
145+
maxLines,
146+
wordBreak: 'break-word',
147+
textRendererOverride: 'sdf',
148+
}),
149+
'Renderer: canvas',
150+
renderer.createTextNode({
151+
...nodeProps,
152+
maxLines,
153+
wordBreak: 'break-word',
154+
textRendererOverride: 'canvas',
155+
}),
156+
],
157+
);
158+
},
159+
},
160+
] satisfies TestRow[];
161+
}

exports/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export * from '../src/core/renderers/CoreShaderNode.js';
5959
export * from '../src/core/shaders/templates/BorderTemplate.js';
6060
export * from '../src/core/shaders/templates/HolePunchTemplate.js';
6161
export * from '../src/core/shaders/templates/RoundedTemplate.js';
62+
export * from '../src/core/shaders/templates/ShadowTemplate.js';
6263
export * from '../src/core/shaders/templates/LinearGradientTemplate.js';
6364
export * from '../src/core/shaders/templates/RadialGradientTemplate.js';
6465

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@lightningjs/renderer",
3-
"version": "3.0.0-beta1",
3+
"version": "3.0.0-beta5",
44
"description": "Lightning 3 Renderer",
55
"type": "module",
66
"main": "./dist/exports/index.js",
@@ -14,7 +14,6 @@
1414
"./inspector": "./dist/exports/inspector.js"
1515
},
1616
"scripts": {
17-
"preinstall": "node scripts/please-use-pnpm.js",
1817
"start": "cd examples && pnpm start",
1918
"start:prod": "cd examples && pnpm start:prod",
2019
"build": "tsc --build",
@@ -88,6 +87,6 @@
8887
"engines": {
8988
"npm": ">= 10.0.0",
9089
"pnpm": ">= 8.9.2",
91-
"node": ">= 20.9.0"
90+
"node": ">= 18.0.0"
9291
}
9392
}

scripts/please-use-pnpm.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/core/CoreNode.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ describe('set color()', () => {
6262
y: 0,
6363
zIndex: 0,
6464
zIndexLocked: 0,
65-
preventCleanup: false,
6665
strictBounds: false,
6766
};
6867

0 commit comments

Comments
 (0)