@lightningtv/core
Advanced tools
Comparing version 2.2.7 to 2.2.8-beta.1
@@ -28,3 +28,8 @@ import { renderer, createShader } from './lightningInit.js'; | ||
} | ||
const shaderCache = new Map(); | ||
function convertEffectsToShader(styleEffects) { | ||
const cacheKey = JSON.stringify(styleEffects); | ||
if (shaderCache.has(cacheKey)) { | ||
return shaderCache.get(cacheKey); | ||
} | ||
const effects = []; | ||
@@ -36,3 +41,5 @@ for (const [type, props] of Object.entries(styleEffects)) { | ||
} | ||
return createShader('DynamicShader', { effects }); | ||
const shader = createShader('DynamicShader', { effects }); | ||
shaderCache.set(cacheKey, shader); | ||
return shader; | ||
} | ||
@@ -526,14 +533,3 @@ function borderAccessor(direction = '') { | ||
if (node._effects) { | ||
let shader; | ||
// states can change effects so don't use cached shader | ||
if (node.style?.effects && !this._states) { | ||
const effects = node.style.effects; | ||
effects._shader = | ||
effects._shader || convertEffectsToShader(node._effects); | ||
shader = effects._shader; | ||
} | ||
else { | ||
shader = convertEffectsToShader(node._effects); | ||
} | ||
props.shader = shader; | ||
props.shader = convertEffectsToShader(node._effects); | ||
} | ||
@@ -540,0 +536,0 @@ if (isElementText(node)) { |
{ | ||
"name": "@lightningtv/core", | ||
"version": "2.2.7", | ||
"version": "2.2.8-beta.1", | ||
"description": "Lightning TV Core for Universal Renderers", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -70,7 +70,12 @@ import { renderer, createShader } from './lightningInit.js'; | ||
const shaderCache = new Map(); | ||
function convertEffectsToShader( | ||
styleEffects: StyleEffects, | ||
): ShaderController<'DynamicShader'> { | ||
const cacheKey = JSON.stringify(styleEffects); | ||
if (shaderCache.has(cacheKey)) { | ||
return shaderCache.get(cacheKey) as ShaderController<'DynamicShader'>; | ||
} | ||
const effects: EffectDescUnion[] = []; | ||
for (const [type, props] of Object.entries(styleEffects)) { | ||
@@ -81,3 +86,5 @@ if (type !== '_shader') { | ||
} | ||
return createShader('DynamicShader', { effects }); | ||
const shader = createShader('DynamicShader', { effects }); | ||
shaderCache.set(cacheKey, shader); | ||
return shader; | ||
} | ||
@@ -758,13 +765,3 @@ | ||
if (node._effects) { | ||
let shader; | ||
// states can change effects so don't use cached shader | ||
if (node.style?.effects && !this._states) { | ||
const effects = node.style.effects; | ||
effects._shader = | ||
effects._shader || convertEffectsToShader(node._effects); | ||
shader = effects._shader; | ||
} else { | ||
shader = convertEffectsToShader(node._effects); | ||
} | ||
props.shader = shader; | ||
props.shader = convertEffectsToShader(node._effects); | ||
} | ||
@@ -771,0 +768,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
219636
3347
3