diff --git a/src/core/renderers/canvas/internal/C2DShaderUtils.ts b/src/core/renderers/canvas/internal/C2DShaderUtils.ts index 8ea71a6e..7864438f 100644 --- a/src/core/renderers/canvas/internal/C2DShaderUtils.ts +++ b/src/core/renderers/canvas/internal/C2DShaderUtils.ts @@ -27,6 +27,8 @@ import { } from '../shaders/UnsupportedShader.js'; import { formatRgba, parseColorRgba } from './ColorUtils.js'; +type Direction = 'Top' | 'Right' | 'Bottom' | 'Left'; + /** * Extract `RoundedRectangle` shader radius to apply as a clipping */ @@ -56,7 +58,7 @@ export function getRadius(quad: QuadOptions): RadiusEffectProps['radius'] { * Extract `RoundedRectangle` shader radius to apply as a clipping */ export function getBorder( quad: QuadOptions, - direction: '' | 'Top' | 'Right' | 'Bottom' | 'Left' = '', + direction: '' | Direction = '', ): BorderEffectProps | undefined { if (quad.shader instanceof UnsupportedShader) { const shType = quad.shader.shType; @@ -65,15 +67,12 @@ export function getBorder( | EffectDescUnion[] | undefined; - if (effects) { + if (effects && effects.length) { const effect = effects.find((effect: EffectDescUnion) => { - return effect.type === `border${direction}` && effect?.props; + return effect.type === `border${direction}` && effect.props; }); - return ( - (effect && effect.type === `border${direction}` && effect.props) || - undefined - ); + return effect && effect.props; } } } @@ -89,7 +88,7 @@ export function strokeLine( height: number, lineWidth = 0, color: number | undefined, - direction: 'Top' | 'Right' | 'Bottom' | 'Left', + direction: Direction, ) { if (!lineWidth) { return; diff --git a/src/core/renderers/webgl/WebGlCoreCtxTexture.ts b/src/core/renderers/webgl/WebGlCoreCtxTexture.ts index d3bf6ed9..085210cc 100644 --- a/src/core/renderers/webgl/WebGlCoreCtxTexture.ts +++ b/src/core/renderers/webgl/WebGlCoreCtxTexture.ts @@ -88,7 +88,10 @@ export class WebGlCoreCtxTexture extends CoreContextTexture { this._nativeCtxTexture = this.createNativeCtxTexture(); if (this._nativeCtxTexture === null) { this._state = 'failed'; - this.textureSource.setState('failed', new Error('Could not create WebGL Texture')); + this.textureSource.setState( + 'failed', + new Error('Could not create WebGL Texture'), + ); console.error('Could not create WebGL Texture'); return; }