Skip to content

Commit 1104c2b

Browse files
Rename
1 parent 21eabd3 commit 1104c2b

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/Components/Web.JS/src/Platform/WebAssemblyResourceLoader.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ export class WebAssemblyResourceLoader {
4848
// Try to load from cache
4949
const cachedResponse = await this.cache.match(cacheKey);
5050
if (cachedResponse) {
51-
const transferredBytes = parseInt(cachedResponse.headers.get('content-length') || '0');
52-
this.cacheLoads[name] = { transferredBytes };
51+
const responseBytes = parseInt(cachedResponse.headers.get('content-length') || '0');
52+
this.cacheLoads[name] = { responseBytes };
5353
return { response: cachedResponse, isNetworkResponse: false };
5454
}
5555

@@ -74,21 +74,21 @@ export class WebAssemblyResourceLoader {
7474
logToConsole() {
7575
const cacheLoadsEntries = Object.values(this.cacheLoads);
7676
const networkLoadsEntries = Object.values(this.networkLoads);
77-
const cacheTransferredBytes = countTotalBytes(cacheLoadsEntries);
78-
const networkTransferredBytes = countTotalBytes(networkLoadsEntries);
79-
const totalTransferredBytes = cacheTransferredBytes + networkTransferredBytes;
77+
const cacheResponseBytes = countTotalBytes(cacheLoadsEntries);
78+
const networkResponseBytes = countTotalBytes(networkLoadsEntries);
79+
const totalResponseBytes = cacheResponseBytes + networkResponseBytes;
8080
const linkerDisabledWarning = this.bootConfig.linkerEnabled ? '%c' : '\n%cThis application was built with linking (tree shaking) disabled. Published applications will be significantly smaller.';
8181

82-
console.groupCollapsed(`%cblazor%c Loaded ${toDataSizeString(totalTransferredBytes)} resources${linkerDisabledWarning}`, 'background: purple; color: white; padding: 1px 3px; border-radius: 3px;', 'font-weight: bold;', 'font-weight: normal;');
82+
console.groupCollapsed(`%cblazor%c Loaded ${toDataSizeString(totalResponseBytes)} resources${linkerDisabledWarning}`, 'background: purple; color: white; padding: 1px 3px; border-radius: 3px;', 'font-weight: bold;', 'font-weight: normal;');
8383

8484
if (cacheLoadsEntries.length) {
85-
console.groupCollapsed(`Loaded ${toDataSizeString(cacheTransferredBytes)} resources from cache`);
85+
console.groupCollapsed(`Loaded ${toDataSizeString(cacheResponseBytes)} resources from cache`);
8686
console.table(this.cacheLoads);
8787
console.groupEnd();
8888
}
8989

9090
if (networkLoadsEntries.length) {
91-
console.groupCollapsed(`Loaded ${toDataSizeString(networkTransferredBytes)} resources from network`);
91+
console.groupCollapsed(`Loaded ${toDataSizeString(networkResponseBytes)} resources from network`);
9292
console.table(this.networkLoads);
9393
console.groupEnd();
9494
}
@@ -117,20 +117,20 @@ export class WebAssemblyResourceLoader {
117117
// only done on a 'best effort' basis. Even if we do receive an entry, some of its
118118
// properties may be blanked out if it was a CORS request.
119119
const performanceEntry = getPerformanceEntry(networkResponse.url);
120-
const transferredBytes = (performanceEntry && performanceEntry.encodedBodySize) || undefined;
121-
this.networkLoads[name] = { transferredBytes };
120+
const responseBytes = (performanceEntry && performanceEntry.encodedBodySize) || undefined;
121+
this.networkLoads[name] = { responseBytes };
122122

123123
// crypto.subtle is only enabled on localhost and HTTPS origins
124124
// We only write to the cache if we can validate the content hashes
125125
if (typeof crypto !== 'undefined' && !!crypto.subtle) {
126126
await assertContentHashMatchesAsync(name, responseBuffer, expectedContentHash);
127127

128-
// Build a custom response object so we can track extra data such as transferredBytes
128+
// Build a custom response object so we can track extra data such as responseBytes
129129
// We can't rely on the server sending content-length (ASP.NET Core doesn't by default)
130130
await this.cache.put(cacheKey, new Response(responseBuffer, {
131131
headers: {
132132
'content-type': networkResponse.headers.get('content-type') || '',
133-
'content-length': (transferredBytes || networkResponse.headers.get('content-length') || '').toString()
133+
'content-length': (responseBytes || networkResponse.headers.get('content-length') || '').toString()
134134
}
135135
}));
136136
}
@@ -140,7 +140,7 @@ export class WebAssemblyResourceLoader {
140140
}
141141

142142
function countTotalBytes(loads: LoadLogEntry[]) {
143-
return loads.reduce((prev, item) => prev + (item.transferredBytes || 0), 0);
143+
return loads.reduce((prev, item) => prev + (item.responseBytes || 0), 0);
144144
}
145145

146146
function toDataSizeString(byteCount: number) {
@@ -182,7 +182,7 @@ interface ResourceGroups {
182182
}
183183

184184
interface LoadLogEntry {
185-
transferredBytes: number | undefined;
185+
responseBytes: number | undefined;
186186
}
187187

188188
export interface LoadingResource {

0 commit comments

Comments
 (0)