@applitools/rendering-grid-client
Advanced tools
Comparing version 1.1.6 to 1.1.7
{ | ||
"name": "@applitools/rendering-grid-client", | ||
"version": "1.1.6", | ||
"version": "1.1.7", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "src/rendering-grid-client.js", |
'use strict'; | ||
function createResourceCache() { | ||
function add(key, entry, dependencies) { | ||
cache[key] = {value: entry, dependencies}; | ||
function getOrInit(key) { | ||
return cache[key] || (cache[key] = {}); | ||
} | ||
function getValue(key) { | ||
const entry = cache[key]; | ||
return entry ? entry.value : null; | ||
} | ||
function setValue(key, value) { | ||
const entry = getOrInit(key); | ||
entry.value = value; | ||
} | ||
function setDependencies(key, dependencies) { | ||
const entry = getOrInit(key); | ||
entry.dependencies = dependencies; | ||
} | ||
function getWithDependencies(key) { | ||
const entry = cache[key]; | ||
if (!entry) return; | ||
if (!entry || !entry.value) return; | ||
@@ -22,12 +37,8 @@ const ret = {}; | ||
function getResource(key) { | ||
const entry = cache[key]; | ||
return entry ? entry.value : null; | ||
} | ||
const cache = {}; | ||
return { | ||
add, | ||
getResource, | ||
getValue, | ||
setValue, | ||
setDependencies, | ||
getWithDependencies, | ||
@@ -34,0 +45,0 @@ }; |
@@ -5,2 +5,3 @@ 'use strict'; | ||
const {URL} = require('url'); | ||
const isCss = require('./isCss'); | ||
@@ -24,16 +25,2 @@ function fromCacheToRGridResource({url, type, hash, content}) { | ||
function toCacheEntry(rGridResource) { | ||
const contentType = rGridResource.getContentType(); | ||
return { | ||
url: rGridResource.getUrl(), | ||
type: contentType, | ||
hash: rGridResource.getSha256Hash(), | ||
content: isCss(contentType) ? rGridResource.getContent() : undefined, | ||
}; | ||
} | ||
function isCss(contentType) { | ||
return /text\/css/.test(contentType); | ||
} | ||
function makeGetAllResources({resourceCache, fetchResource, extractCssResources}) { | ||
@@ -52,3 +39,3 @@ async function getDependantResources({url, type, value}) { | ||
const rGridResource = fromFetchedToRGridResource(resource); | ||
resourceCache.add(resource.url, toCacheEntry(rGridResource), dependentResources); | ||
resourceCache.setDependencies(resource.url, dependentResources); | ||
return Object.assign({[resource.url]: rGridResource}, fetchedResources); | ||
@@ -55,0 +42,0 @@ } |
@@ -40,3 +40,3 @@ 'use strict'; | ||
resourceUrl = absolutizeUrl(getHrefAttr(node), baseUrl); | ||
const resource = resourceCache.getResource(resourceUrl); | ||
const resource = resourceCache.getValue(resourceUrl); | ||
if (resource) { | ||
@@ -67,3 +67,3 @@ cssText = resource.content.toString(); | ||
const nestedUrl = absolutizeUrl(rule.href, resourceUrl); | ||
const nestedResource = resourceCache.getResource(nestedUrl); | ||
const nestedResource = resourceCache.getValue(nestedUrl); | ||
if (nestedResource) { | ||
@@ -70,0 +70,0 @@ const nestedCssText = getBundledCssFromCssText( |
@@ -128,3 +128,3 @@ 'use strict'; | ||
}); | ||
const renderIds = await renderBatch(renderRequests, renderWrapper); | ||
const renderIds = await renderBatch(renderRequests, renderWrapper, resourceCache); | ||
@@ -131,0 +131,0 @@ if (saveDebugData) { |
'use strict'; | ||
const {RenderStatus} = require('@applitools/eyes.sdk.core'); | ||
const toCacheEntry = require('./toCacheEntry'); | ||
async function renderBatch(renderRequests, wrapper) { | ||
async function renderBatch(renderRequests, wrapper, resourceCache) { | ||
const runningRenders = await wrapper.renderBatch(renderRequests); | ||
@@ -14,2 +15,5 @@ | ||
await wrapper.putResources(renderRequest.getDom(), runningRender); | ||
for (const resource of renderRequest.getResources()) { | ||
resourceCache.setValue(resource.getUrl(), toCacheEntry(resource)); | ||
} | ||
} | ||
@@ -16,0 +20,0 @@ }), |
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
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
40527
29
1115