Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

piral-blazor

Package Overview
Dependencies
Maintainers
1
Versions
805
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

piral-blazor - npm Package Compare versions

Comparing version 0.12.3-pre.1815 to 0.12.3-pre.1816

lib/internal/Platform/Mono/TimezoneDataFile.d.ts

5

lib/internal/index.js

@@ -108,3 +108,4 @@ "use strict";

Object.assign(window['Blazor']._internal, {
navigationManager: NavigationManager_1.navigationManager,
navigateTo: NavigationManager_1.navigateTo,
navigationManager: tslib_1.__assign(tslib_1.__assign({}, NavigationManager_1.navigationManager), { getUnmarshalledBaseURI: function () { return BINDING.js_string_to_mono_string(NavigationManager_1.navigationManager.getBaseURI()); }, getUnmarshalledLocationHref: function () { return BINDING.js_string_to_mono_string(NavigationManager_1.navigationManager.getLocationHref()); } }),
attachRootComponentToElement: Renderer_2.attachRootComponentToElement,

@@ -117,3 +118,3 @@ renderBatch: function (browserRendererId, batchAddress) {

return [4 /*yield*/, Promise.all([
WebAssemblyResourceLoader_1.WebAssemblyResourceLoader.initAsync(bootConfigResult.bootConfig),
WebAssemblyResourceLoader_1.WebAssemblyResourceLoader.initAsync(bootConfigResult.bootConfig, {}),
WebAssemblyConfigLoader_1.WebAssemblyConfigLoader.initAsync(bootConfigResult),

@@ -120,0 +121,0 @@ ])];

4

lib/internal/Platform/Mono/MonoDebugger.js

@@ -11,2 +11,3 @@ "use strict";

function attachDebuggerHotkey(resourceLoader) {
hasReferencedPdbs = !!resourceLoader.bootConfig.resources.pdb;
// Use the combination shift+alt+D because it isn't used by the major browsers

@@ -18,3 +19,2 @@ // for anything else by default

}
hasReferencedPdbs = !!resourceLoader.bootConfig.resources.pdb;
// Even if debugging isn't enabled, we register the hotkey so we can report why it's not enabled

@@ -27,3 +27,3 @@ document.addEventListener('keydown', function (evt) {

else if (!currentBrowserIsChrome) {
console.error('Currently, only Edge(Chromium) or Chrome is supported for debugging.');
console.error('Currently, only Microsoft Edge (80+), or Google Chrome, are supported for debugging.');
}

@@ -30,0 +30,0 @@ else {

@@ -6,2 +6,3 @@ "use strict";

var MonoDebugger_1 = require("./MonoDebugger");
var TimezoneDataFile_1 = require("./TimezoneDataFile");
var mono_string_get_utf8;

@@ -12,2 +13,24 @@ var mono_wasm_add_assembly;

var maxSafeNumberHighPart = Math.pow(2, 21) - 1; // The high-order int32 from Number.MAX_SAFE_INTEGER
// Memory access helpers
// The implementations are exactly equivalent to what the global getValue(addr, type) function does,
// except without having to parse the 'type' parameter, and with less risk of mistakes at the call site
function getValueI16(ptr) {
return Module.HEAP16[ptr >> 1];
}
function getValueI32(ptr) {
return Module.HEAP32[ptr >> 2];
}
function getValueFloat(ptr) {
return Module.HEAPF32[ptr >> 2];
}
function getValueU64(ptr) {
// There is no Module.HEAPU64, and Module.getValue(..., 'i64') doesn't work because the implementation
// treats 'i64' as being the same as 'i32'. Also we must take care to read both halves as unsigned.
var heapU32Index = ptr >> 2;
var highPart = Module.HEAPU32[heapU32Index + 1];
if (highPart > maxSafeNumberHighPart) {
throw new Error("Cannot read uint64 with high order part " + highPart + ", because the result would exceed Number.MAX_SAFE_INTEGER.");
}
return highPart * uint64HighOrderShift + Module.HEAPU32[heapU32Index];
}
exports.monoPlatform = {

@@ -43,7 +66,7 @@ start: function start(resourceLoader) {

var dataPtr = getArrayDataPointer(array);
var length = Module.getValue(dataPtr, 'i32');
var length = getValueI32(dataPtr);
return new Uint8Array(Module.HEAPU8.buffer, dataPtr + 4, length);
},
getArrayLength: function getArrayLength(array) {
return Module.getValue(getArrayDataPointer(array), 'i32');
return getValueI32(getArrayDataPointer(array));
},

@@ -60,26 +83,18 @@ getArrayEntryPtr: function getArrayEntryPtr(array, index, itemSize) {

readInt16Field: function readHeapInt16(baseAddress, fieldOffset) {
return Module.getValue(baseAddress + (fieldOffset || 0), 'i16');
return getValueI16(baseAddress + (fieldOffset || 0));
},
readInt32Field: function readHeapInt32(baseAddress, fieldOffset) {
return Module.getValue(baseAddress + (fieldOffset || 0), 'i32');
return getValueI32(baseAddress + (fieldOffset || 0));
},
readUint64Field: function readHeapUint64(baseAddress, fieldOffset) {
// Module.getValue(..., 'i64') doesn't work because the implementation treats 'i64' as
// being the same as 'i32'. Also we must take care to read both halves as unsigned.
var address = baseAddress + (fieldOffset || 0);
var heapU32Index = address >> 2;
var highPart = Module.HEAPU32[heapU32Index + 1];
if (highPart > maxSafeNumberHighPart) {
throw new Error("Cannot read uint64 with high order part " + highPart + ", because the result would exceed Number.MAX_SAFE_INTEGER.");
}
return highPart * uint64HighOrderShift + Module.HEAPU32[heapU32Index];
return getValueU64(baseAddress + (fieldOffset || 0));
},
readFloatField: function readHeapFloat(baseAddress, fieldOffset) {
return Module.getValue(baseAddress + (fieldOffset || 0), 'float');
return getValueFloat(baseAddress + (fieldOffset || 0));
},
readObjectField: function readHeapObject(baseAddress, fieldOffset) {
return Module.getValue(baseAddress + (fieldOffset || 0), 'i32');
return getValueI32(baseAddress + (fieldOffset || 0));
},
readStringField: function readHeapObject(baseAddress, fieldOffset, readBoolValueAsString) {
var fieldValue = Module.getValue(baseAddress + (fieldOffset || 0), 'i32');
var fieldValue = getValueI32(baseAddress + (fieldOffset || 0));
if (fieldValue === 0) {

@@ -113,2 +128,3 @@ return null;

var dotnetJsResourceName = Object.keys(resourceLoader.bootConfig.resources.runtime).filter(function (n) { return n.startsWith('dotnet.') && n.endsWith('.js'); })[0];
var dotnetJsContentHash = resourceLoader.bootConfig.resources.runtime[dotnetJsResourceName];
var scriptElem = document.createElement('script');

@@ -119,6 +135,17 @@ scriptElem.src = "_framework/wasm/" + dotnetJsResourceName;

if (resourceLoader.bootConfig.cacheBootResources) {
var contentHash = resourceLoader.bootConfig.resources.runtime[dotnetJsResourceName];
scriptElem.integrity = contentHash;
scriptElem.integrity = dotnetJsContentHash;
scriptElem.crossOrigin = 'anonymous';
}
// Allow overriding the URI from which the dotnet.*.js file is loaded
if (resourceLoader.startOptions.loadBootResource) {
var resourceType = 'dotnetjs';
var customSrc = resourceLoader.startOptions.loadBootResource(resourceType, dotnetJsResourceName, scriptElem.src, dotnetJsContentHash);
if (typeof customSrc === 'string') {
scriptElem.src = customSrc;
}
else if (customSrc) {
// Since we must load this via a <script> tag, it's only valid to supply a URI (and not a Request, say)
throw new Error("For a " + resourceType + " resource, custom loaders must supply a URI string.");
}
}
document.body.appendChild(scriptElem);

@@ -143,19 +170,28 @@ }

var resources = resourceLoader.bootConfig.resources;
var module = {};
var module = (window['Module'] || {});
var suppressMessages = ['DEBUGGING ENABLED'];
module.print = function (line) { return suppressMessages.indexOf(line) < 0 && console.log(line); };
module.printErr = function (line) {
// If anything writes to stderr, treat it as a critical exception. The underlying runtime writes
// to stderr if a truly critical problem occurs outside .NET code. Note that .NET unhandled
// exceptions also reach this, but via a different code path - see dotNetCriticalError below.
console.error(line);
};
module.preRun = [];
module.postRun = [];
module.preRun = module.preRun || [];
module.postRun = module.postRun || [];
module.preloadPlugins = [];
// Begin loading the .dll/.pdb/.wasm files, but don't block here. Let other loading processes run in parallel.
var dotnetWasmResourceName = 'dotnet.wasm';
var assembliesBeingLoaded = resourceLoader.loadResources(resources.assembly, function (filename) { return "_framework/_bin/" + filename; });
var pdbsBeingLoaded = resourceLoader.loadResources(resources.pdb || {}, function (filename) { return "_framework/_bin/" + filename; });
var assembliesBeingLoaded = resourceLoader.loadResources(resources.assembly, function (filename) { return "_framework/_bin/" + filename; }, 'assembly');
var pdbsBeingLoaded = resourceLoader.loadResources(resources.pdb || {}, function (filename) { return "_framework/_bin/" + filename; }, 'pdb');
var wasmBeingLoaded = resourceLoader.loadResource(
/* name */ dotnetWasmResourceName,
/* url */ "_framework/wasm/" + dotnetWasmResourceName,
/* hash */ resourceLoader.bootConfig.resources.runtime[dotnetWasmResourceName]);
/* hash */ resourceLoader.bootConfig.resources.runtime[dotnetWasmResourceName],
/* type */ 'dotnetwasm');
var dotnetTimeZoneResourceName = 'dotnet.timezones.dat';
var timeZoneResource;
if (resourceLoader.bootConfig.resources.runtime.hasOwnProperty(dotnetTimeZoneResourceName)) {
timeZoneResource = resourceLoader.loadResource(dotnetTimeZoneResourceName, "_framework/wasm/" + dotnetTimeZoneResourceName, resourceLoader.bootConfig.resources.runtime[dotnetTimeZoneResourceName], 'timezonedata');
}
// Override the mechanism for fetching the main wasm file so we can connect it to our cache

@@ -186,9 +222,12 @@ module.instantiateWasm = function (imports, successCallback) {

}); })();
return {}; // No exports
return []; // No exports
};
module.preRun.push(function () {
// By now, emscripten should be initialised enough that we can capture these methods for later use
mono_wasm_add_assembly = Module.cwrap('mono_wasm_add_assembly', null, ['string', 'number', 'number']);
mono_string_get_utf8 = Module.cwrap('mono_wasm_string_get_utf8', 'number', ['number']);
mono_wasm_add_assembly = cwrap('mono_wasm_add_assembly', null, ['string', 'number', 'number']);
mono_string_get_utf8 = cwrap('mono_wasm_string_get_utf8', 'number', ['number']);
MONO.loaded_files = [];
if (timeZoneResource) {
loadTimezone(timeZoneResource);
}
// Fetch the assemblies and PDBs in the background, telling Mono to wait until they are loaded

@@ -199,2 +238,5 @@ // Mono requires the assembly filenames to have a '.dll' extension, so supply such names regardless

pdbsBeingLoaded.forEach(function (r) { return addResourceAsAssembly(r, r.name); });
window['Blazor']._internal.dotNetCriticalError = function (message) {
module.printErr(BINDING.conv_string(message) || '(null)');
};
// Wire-up callbacks for satellite assemblies. Blazor will call these as part of the application

@@ -209,3 +251,3 @@ // startup sequence to load satellite assemblies for the application's culture.

.map(function (culture) {
return resourceLoader.loadResources(satelliteResources[culture], function (fileName) { return "_framework/_bin/" + fileName; });
return resourceLoader.loadResources(satelliteResources[culture], function (fileName) { return "_framework/_bin/" + fileName; }, 'assembly');
})

@@ -241,4 +283,5 @@ .reduce(function (previous, next) { return previous.concat(next); }, new Array())

MONO.mono_wasm_setenv('MONO_URI_DOTNETRELATIVEORABSOLUTE', 'true');
var load_runtime = Module.cwrap('mono_wasm_load_runtime', null, ['string', 'number']);
load_runtime(appBinDirName, MonoDebugger_1.hasDebuggingEnabled() ? 1 : 0);
var load_runtime = cwrap('mono_wasm_load_runtime', null, ['string', 'number']);
// -1 enables debugging with logging disabled. 0 disables debugging entirely.
load_runtime(appBinDirName, MonoDebugger_1.hasDebuggingEnabled() ? -1 : 0);
MONO.mono_wasm_runtime_ready();

@@ -256,3 +299,3 @@ attachInteropInvoker();

runDependencyId = "blazor:" + dependency.name;
Module.addRunDependency(runDependencyId);
addRunDependency(runDependencyId);
_a.label = 1;

@@ -276,3 +319,3 @@ case 1:

case 4:
Module.removeRunDependency(runDependencyId);
removeRunDependency(runDependencyId);
return [2 /*return*/];

@@ -319,2 +362,23 @@ }

}
function loadTimezone(timeZoneResource) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var runDependencyId, request, arrayBuffer;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
runDependencyId = "blazor:timezonedata";
addRunDependency(runDependencyId);
return [4 /*yield*/, timeZoneResource.response];
case 1:
request = _a.sent();
return [4 /*yield*/, request.arrayBuffer()];
case 2:
arrayBuffer = _a.sent();
TimezoneDataFile_1.loadTimezoneData(arrayBuffer);
removeRunDependency(runDependencyId);
return [2 /*return*/];
}
});
});
}
function compileWasmModule(wasmResource, imports) {

@@ -321,0 +385,0 @@ return tslib_1.__awaiter(this, void 0, void 0, function () {

import { BootJsonData, ResourceList } from './BootConfig';
import { WebAssemblyStartOptions, WebAssemblyBootResourceType } from './WebAssemblyStartOptions';
export declare class WebAssemblyResourceLoader {
readonly bootConfig: BootJsonData;
readonly cacheIfUsed: Cache | null;
readonly startOptions: Partial<WebAssemblyStartOptions>;
private usedCacheKeys;
private networkLoads;
private cacheLoads;
static initAsync(bootConfig: BootJsonData): Promise<WebAssemblyResourceLoader>;
constructor(bootConfig: BootJsonData, cacheIfUsed: Cache | null);
loadResources(resources: ResourceList, url: (name: string) => string): LoadingResource[];
loadResource(name: string, url: string, contentHash: string): LoadingResource;
static initAsync(bootConfig: BootJsonData, startOptions: Partial<WebAssemblyStartOptions>): Promise<WebAssemblyResourceLoader>;
constructor(bootConfig: BootJsonData, cacheIfUsed: Cache | null, startOptions: Partial<WebAssemblyStartOptions>);
loadResources(resources: ResourceList, url: (name: string) => string, resourceType: WebAssemblyBootResourceType): LoadingResource[];
loadResource(name: string, url: string, contentHash: string, resourceType: WebAssemblyBootResourceType): LoadingResource;
logToConsole(): void;
purgeUnusedCacheEntriesAsync(): Promise<void>;
private loadResourceWithCaching;
private loadResourceWithoutCaching;
private addToCacheAsync;

@@ -16,0 +19,0 @@ }

@@ -8,5 +8,6 @@ "use strict";

var WebAssemblyResourceLoader = /** @class */ (function () {
function WebAssemblyResourceLoader(bootConfig, cacheIfUsed) {
function WebAssemblyResourceLoader(bootConfig, cacheIfUsed, startOptions) {
this.bootConfig = bootConfig;
this.cacheIfUsed = cacheIfUsed;
this.startOptions = startOptions;
this.usedCacheKeys = {};

@@ -16,3 +17,3 @@ this.networkLoads = {};

}
WebAssemblyResourceLoader.initAsync = function (bootConfig) {
WebAssemblyResourceLoader.initAsync = function (bootConfig, startOptions) {
return tslib_1.__awaiter(this, void 0, void 0, function () {

@@ -25,3 +26,3 @@ var cache;

cache = _a.sent();
return [2 /*return*/, new WebAssemblyResourceLoader(bootConfig, cache)];
return [2 /*return*/, new WebAssemblyResourceLoader(bootConfig, cache, startOptions)];
}

@@ -31,16 +32,10 @@ });

};
WebAssemblyResourceLoader.prototype.loadResources = function (resources, url) {
WebAssemblyResourceLoader.prototype.loadResources = function (resources, url, resourceType) {
var _this = this;
return Object.keys(resources).map(function (name) { return _this.loadResource(name, url(name), resources[name]); });
return Object.keys(resources).map(function (name) { return _this.loadResource(name, url(name), resources[name], resourceType); });
};
WebAssemblyResourceLoader.prototype.loadResource = function (name, url, contentHash) {
// Note that if cacheBootResources was explicitly disabled, we also bypass hash checking
// This is to give developers an easy opt-out from the entire caching/validation flow if
// there's anything they don't like about it.
WebAssemblyResourceLoader.prototype.loadResource = function (name, url, contentHash, resourceType) {
var response = this.cacheIfUsed
? this.loadResourceWithCaching(this.cacheIfUsed, name, url, contentHash)
: fetch(url, {
cache: networkFetchCacheMode,
integrity: this.bootConfig.cacheBootResources ? contentHash : undefined,
});
? this.loadResourceWithCaching(this.cacheIfUsed, name, url, contentHash, resourceType)
: this.loadResourceWithoutCaching(name, url, contentHash, resourceType);
return { name: name, url: url, response: response };

@@ -108,3 +103,3 @@ };

};
WebAssemblyResourceLoader.prototype.loadResourceWithCaching = function (cache, name, url, contentHash) {
WebAssemblyResourceLoader.prototype.loadResourceWithCaching = function (cache, name, url, contentHash, resourceType) {
return tslib_1.__awaiter(this, void 0, void 0, function () {

@@ -130,3 +125,3 @@ var cacheKey, cachedResponse, responseBytes, networkResponse;

return [2 /*return*/, cachedResponse];
case 2: return [4 /*yield*/, fetch(url, { cache: networkFetchCacheMode, integrity: contentHash })];
case 2: return [4 /*yield*/, this.loadResourceWithoutCaching(name, url, contentHash, resourceType)];
case 3:

@@ -140,2 +135,23 @@ networkResponse = _a.sent();

};
WebAssemblyResourceLoader.prototype.loadResourceWithoutCaching = function (name, url, contentHash, resourceType) {
// Allow developers to override how the resource is loaded
if (this.startOptions.loadBootResource) {
var customLoadResult = this.startOptions.loadBootResource(resourceType, name, url, contentHash);
if (customLoadResult instanceof Promise) {
// They are supplying an entire custom response, so just use that
return customLoadResult;
}
else if (typeof customLoadResult === 'string') {
// They are supplying a custom URL, so use that with the default fetch behavior
url = customLoadResult;
}
}
// Note that if cacheBootResources was explicitly disabled, we also bypass hash checking
// This is to give developers an easy opt-out from the entire caching/validation flow if
// there's anything they don't like about it.
return fetch(url, {
cache: networkFetchCacheMode,
integrity: this.bootConfig.cacheBootResources ? contentHash : undefined,
});
};
WebAssemblyResourceLoader.prototype.addToCacheAsync = function (cache, name, cacheKey, response) {

@@ -142,0 +158,0 @@ return tslib_1.__awaiter(this, void 0, void 0, function () {

@@ -5,2 +5,3 @@ "use strict";

var Utf8Decoder_1 = require("./Utf8Decoder");
var BinaryDecoder_1 = require("./BinaryDecoder");
var updatedComponentsEntryLength = 4; // Each is a single int32 giving the location of the data

@@ -12,4 +13,2 @@ var referenceFramesEntryLength = 20; // 1 int for frame type, then 16 bytes for type-specific data

var stringTableEntryLength = 4; // Each is an int32 giving the string data location, or -1 for null
var uint64HighPartShift = Math.pow(2, 32);
var maxSafeNumberHighPart = Math.pow(2, 21) - 1; // The high-order int32 from Number.MAX_SAFE_INTEGER
var OutOfProcessRenderBatch = /** @class */ (function () {

@@ -26,16 +25,16 @@ function OutOfProcessRenderBatch(batchData) {

OutOfProcessRenderBatch.prototype.updatedComponents = function () {
return readInt32LE(this.batchData, this.batchData.length - 20); // 5th-from-last int32
return BinaryDecoder_1.readInt32LE(this.batchData, this.batchData.length - 20); // 5th-from-last int32
};
OutOfProcessRenderBatch.prototype.referenceFrames = function () {
return readInt32LE(this.batchData, this.batchData.length - 16); // 4th-from-last int32
return BinaryDecoder_1.readInt32LE(this.batchData, this.batchData.length - 16); // 4th-from-last int32
};
OutOfProcessRenderBatch.prototype.disposedComponentIds = function () {
return readInt32LE(this.batchData, this.batchData.length - 12); // 3rd-from-last int32
return BinaryDecoder_1.readInt32LE(this.batchData, this.batchData.length - 12); // 3rd-from-last int32
};
OutOfProcessRenderBatch.prototype.disposedEventHandlerIds = function () {
return readInt32LE(this.batchData, this.batchData.length - 8); // 2th-from-last int32
return BinaryDecoder_1.readInt32LE(this.batchData, this.batchData.length - 8); // 2th-from-last int32
};
OutOfProcessRenderBatch.prototype.updatedComponentsEntry = function (values, index) {
var tableEntryPos = values + index * updatedComponentsEntryLength;
return readInt32LE(this.batchData, tableEntryPos);
return BinaryDecoder_1.readInt32LE(this.batchData, tableEntryPos);
};

@@ -47,7 +46,7 @@ OutOfProcessRenderBatch.prototype.referenceFramesEntry = function (values, index) {

var entryPos = values + index * disposedComponentIdsEntryLength;
return readInt32LE(this.batchData, entryPos);
return BinaryDecoder_1.readInt32LE(this.batchData, entryPos);
};
OutOfProcessRenderBatch.prototype.disposedEventHandlerIdsEntry = function (values, index) {
var entryPos = values + index * disposedEventHandlerIdsEntryLength;
return readUint64LE(this.batchData, entryPos);
return BinaryDecoder_1.readUint64LE(this.batchData, entryPos);
};

@@ -63,3 +62,3 @@ return OutOfProcessRenderBatch;

// First int32 is componentId
return readInt32LE(this.batchDataUint8, diff);
return BinaryDecoder_1.readInt32LE(this.batchDataUint8, diff);
};

@@ -81,15 +80,15 @@ OutOfProcessRenderTreeDiffReader.prototype.edits = function (diff) {

OutOfProcessRenderTreeEditReader.prototype.editType = function (edit) {
return readInt32LE(this.batchDataUint8, edit); // 1st int
return BinaryDecoder_1.readInt32LE(this.batchDataUint8, edit); // 1st int
};
OutOfProcessRenderTreeEditReader.prototype.siblingIndex = function (edit) {
return readInt32LE(this.batchDataUint8, edit + 4); // 2nd int
return BinaryDecoder_1.readInt32LE(this.batchDataUint8, edit + 4); // 2nd int
};
OutOfProcessRenderTreeEditReader.prototype.newTreeIndex = function (edit) {
return readInt32LE(this.batchDataUint8, edit + 8); // 3rd int
return BinaryDecoder_1.readInt32LE(this.batchDataUint8, edit + 8); // 3rd int
};
OutOfProcessRenderTreeEditReader.prototype.moveToSiblingIndex = function (edit) {
return readInt32LE(this.batchDataUint8, edit + 8); // 3rd int
return BinaryDecoder_1.readInt32LE(this.batchDataUint8, edit + 8); // 3rd int
};
OutOfProcessRenderTreeEditReader.prototype.removedAttributeName = function (edit) {
var stringIndex = readInt32LE(this.batchDataUint8, edit + 12); // 4th int
var stringIndex = BinaryDecoder_1.readInt32LE(this.batchDataUint8, edit + 12); // 4th int
return this.stringReader.readString(stringIndex);

@@ -107,36 +106,36 @@ };

OutOfProcessRenderTreeFrameReader.prototype.frameType = function (frame) {
return readInt32LE(this.batchDataUint8, frame); // 1st int
return BinaryDecoder_1.readInt32LE(this.batchDataUint8, frame); // 1st int
};
OutOfProcessRenderTreeFrameReader.prototype.subtreeLength = function (frame) {
return readInt32LE(this.batchDataUint8, frame + 4); // 2nd int
return BinaryDecoder_1.readInt32LE(this.batchDataUint8, frame + 4); // 2nd int
};
OutOfProcessRenderTreeFrameReader.prototype.elementReferenceCaptureId = function (frame) {
var stringIndex = readInt32LE(this.batchDataUint8, frame + 4); // 2nd int
var stringIndex = BinaryDecoder_1.readInt32LE(this.batchDataUint8, frame + 4); // 2nd int
return this.stringReader.readString(stringIndex);
};
OutOfProcessRenderTreeFrameReader.prototype.componentId = function (frame) {
return readInt32LE(this.batchDataUint8, frame + 8); // 3rd int
return BinaryDecoder_1.readInt32LE(this.batchDataUint8, frame + 8); // 3rd int
};
OutOfProcessRenderTreeFrameReader.prototype.elementName = function (frame) {
var stringIndex = readInt32LE(this.batchDataUint8, frame + 8); // 3rd int
var stringIndex = BinaryDecoder_1.readInt32LE(this.batchDataUint8, frame + 8); // 3rd int
return this.stringReader.readString(stringIndex);
};
OutOfProcessRenderTreeFrameReader.prototype.textContent = function (frame) {
var stringIndex = readInt32LE(this.batchDataUint8, frame + 4); // 2nd int
var stringIndex = BinaryDecoder_1.readInt32LE(this.batchDataUint8, frame + 4); // 2nd int
return this.stringReader.readString(stringIndex);
};
OutOfProcessRenderTreeFrameReader.prototype.markupContent = function (frame) {
var stringIndex = readInt32LE(this.batchDataUint8, frame + 4); // 2nd int
var stringIndex = BinaryDecoder_1.readInt32LE(this.batchDataUint8, frame + 4); // 2nd int
return this.stringReader.readString(stringIndex);
};
OutOfProcessRenderTreeFrameReader.prototype.attributeName = function (frame) {
var stringIndex = readInt32LE(this.batchDataUint8, frame + 4); // 2nd int
var stringIndex = BinaryDecoder_1.readInt32LE(this.batchDataUint8, frame + 4); // 2nd int
return this.stringReader.readString(stringIndex);
};
OutOfProcessRenderTreeFrameReader.prototype.attributeValue = function (frame) {
var stringIndex = readInt32LE(this.batchDataUint8, frame + 8); // 3rd int
var stringIndex = BinaryDecoder_1.readInt32LE(this.batchDataUint8, frame + 8); // 3rd int
return this.stringReader.readString(stringIndex);
};
OutOfProcessRenderTreeFrameReader.prototype.attributeEventHandlerId = function (frame) {
return readUint64LE(this.batchDataUint8, frame + 12); // Bytes 12-19
return BinaryDecoder_1.readUint64LE(this.batchDataUint8, frame + 12); // Bytes 12-19
};

@@ -149,3 +148,3 @@ return OutOfProcessRenderTreeFrameReader;

// Final int gives start position of the string table
this.stringTableStartIndex = readInt32LE(batchDataUint8, batchDataUint8.length - 4);
this.stringTableStartIndex = BinaryDecoder_1.readInt32LE(batchDataUint8, batchDataUint8.length - 4);
}

@@ -158,7 +157,7 @@ OutOfProcessStringReader.prototype.readString = function (index) {

else {
var stringTableEntryPos = readInt32LE(this.batchDataUint8, this.stringTableStartIndex + index * stringTableEntryLength);
var stringTableEntryPos = BinaryDecoder_1.readInt32LE(this.batchDataUint8, this.stringTableStartIndex + index * stringTableEntryLength);
// By default, .NET's BinaryWriter gives LEB128-length-prefixed UTF-8 data.
// This is convenient enough to decode in JavaScript.
var numUtf8Bytes = readLEB128(this.batchDataUint8, stringTableEntryPos);
var charsStart = stringTableEntryPos + numLEB128Bytes(numUtf8Bytes);
var numUtf8Bytes = BinaryDecoder_1.readLEB128(this.batchDataUint8, stringTableEntryPos);
var charsStart = stringTableEntryPos + BinaryDecoder_1.numLEB128Bytes(numUtf8Bytes);
var utf8Data = new Uint8Array(this.batchDataUint8.buffer, this.batchDataUint8.byteOffset + charsStart, numUtf8Bytes);

@@ -176,3 +175,3 @@ return Utf8Decoder_1.decodeUtf8(utf8Data);

// First int is count
return readInt32LE(this.batchDataUint8, arrayRange);
return BinaryDecoder_1.readInt32LE(this.batchDataUint8, arrayRange);
};

@@ -196,3 +195,3 @@ OutOfProcessArrayRangeReader.prototype.values = function (arrayRange) {

// First int is count
return readInt32LE(this.batchDataUint8, arrayBuilderSegment);
return BinaryDecoder_1.readInt32LE(this.batchDataUint8, arrayBuilderSegment);
};

@@ -205,33 +204,2 @@ OutOfProcessArrayBuilderSegmentReader.prototype.values = function (arrayBuilderSegment) {

}());
function readInt32LE(buffer, position) {
return buffer[position] | (buffer[position + 1] << 8) | (buffer[position + 2] << 16) | (buffer[position + 3] << 24);
}
function readUint32LE(buffer, position) {
return (buffer[position] + (buffer[position + 1] << 8) + (buffer[position + 2] << 16) + ((buffer[position + 3] << 24) >>> 0)); // The >>> 0 coerces the value to unsigned
}
function readUint64LE(buffer, position) {
// This cannot be done using bit-shift operators in JavaScript, because
// those all implicitly convert to int32
var highPart = readUint32LE(buffer, position + 4);
if (highPart > maxSafeNumberHighPart) {
throw new Error("Cannot read uint64 with high order part " + highPart + ", because the result would exceed Number.MAX_SAFE_INTEGER.");
}
return highPart * uint64HighPartShift + readUint32LE(buffer, position);
}
function readLEB128(buffer, position) {
var result = 0;
var shift = 0;
for (var index = 0; index < 4; index++) {
var byte = buffer[position + index];
result |= (byte & 127) << shift;
if (byte < 128) {
break;
}
shift += 7;
}
return result;
}
function numLEB128Bytes(value) {
return value < 128 ? 1 : value < 16384 ? 2 : value < 2097152 ? 3 : 4;
}
//# sourceMappingURL=OutOfProcessRenderBatch.js.map

@@ -11,3 +11,2 @@ "use strict";

https://github.com/samthor/fast-text-encoding
License for fast-text-encoding: Apache 2.0

@@ -14,0 +13,0 @@ https://github.com/samthor/fast-text-encoding/blob/master/LICENSE

@@ -6,4 +6,4 @@ import { EventDelegator } from '../Rendering/EventDelegator';

navigateTo: typeof navigateTo;
getBaseURI: () => import("../Platform/Platform").System_String;
getLocationHref: () => import("../Platform/Platform").System_String;
getBaseURI: () => string;
getLocationHref: () => string;
};

@@ -10,0 +10,0 @@ declare function listenForNavigationEvents(callback: (uri: string, intercepted: boolean) => Promise<void>): void;

@@ -15,4 +15,4 @@ "use strict";

navigateTo: navigateTo,
getBaseURI: function () { return BINDING.js_string_to_mono_string(document.baseURI); },
getLocationHref: function () { return BINDING.js_string_to_mono_string(location.href); },
getBaseURI: function () { return document.baseURI; },
getLocationHref: function () { return location.href; },
};

@@ -75,3 +75,3 @@ function listenForNavigationEvents(callback) {

// triggering browser-specific behavior issues.
// For details about what this fixes and why, see https://github.com/aspnet/AspNetCore/pull/10839
// For details about what this fixes and why, see https://github.com/dotnet/aspnetcore/pull/10839
var temporaryUri = uri + '?';

@@ -78,0 +78,0 @@ history.replaceState(null, '', temporaryUri);

{
"name": "piral-blazor",
"version": "0.12.3-pre.1815",
"version": "0.12.3-pre.1816",
"description": "Plugin for integrating Blazor components in Piral.",

@@ -45,3 +45,3 @@ "keywords": [

"dependencies": {
"@dotnet/jsinterop": "3.1.5",
"@dotnet/jsinterop": "3.1.8",
"axios": "^0.19.2",

@@ -51,4 +51,5 @@ "yauzl": "^2.10.0"

"devDependencies": {
"@types/emscripten": "0.0.34",
"piral-core": "^0.12.3-pre.1815"
"@types/emscripten": "^1.39.3",
"@types/jsdom": "11.0.6",
"piral-core": "^0.12.3-pre.1816"
},

@@ -58,3 +59,3 @@ "peerDependencies": {

},
"gitHead": "032de6a264fa27180ef96fb3a6230316ff2d3732"
"gitHead": "14e3ee3b98760dee8a5e305cfb52c981d1a28319"
}
import './globals';
import { setPlatform } from './Environment';
import { Pointer } from './Platform/Platform';
import { navigationManager } from './Services/NavigationManager';
import { navigationManager, navigateTo } from './Services/NavigationManager';
import { BootJsonData, BootConfigResult } from './Platform/BootConfig';

@@ -123,3 +123,8 @@ import { monoPlatform } from './Platform/Mono/MonoPlatform';

Object.assign(window['Blazor']._internal, {
navigationManager,
navigateTo,
navigationManager: {
...navigationManager,
getUnmarshalledBaseURI: () => BINDING.js_string_to_mono_string(navigationManager.getBaseURI()),
getUnmarshalledLocationHref: () => BINDING.js_string_to_mono_string(navigationManager.getLocationHref())
},
attachRootComponentToElement,

@@ -134,3 +139,3 @@ renderBatch(browserRendererId: number, batchAddress: Pointer) {

const [resourceLoader] = await Promise.all([
WebAssemblyResourceLoader.initAsync(bootConfigResult.bootConfig),
WebAssemblyResourceLoader.initAsync(bootConfigResult.bootConfig, {}),
WebAssemblyConfigLoader.initAsync(bootConfigResult),

@@ -137,0 +142,0 @@ ]);

@@ -12,2 +12,4 @@ import { WebAssemblyResourceLoader } from '../WebAssemblyResourceLoader';

export function attachDebuggerHotkey(resourceLoader: WebAssemblyResourceLoader) {
hasReferencedPdbs = !!resourceLoader.bootConfig.resources.pdb;
// Use the combination shift+alt+D because it isn't used by the major browsers

@@ -20,4 +22,2 @@ // for anything else by default

hasReferencedPdbs = !!resourceLoader.bootConfig.resources.pdb;
// Even if debugging isn't enabled, we register the hotkey so we can report why it's not enabled

@@ -29,3 +29,3 @@ document.addEventListener('keydown', (evt) => {

} else if (!currentBrowserIsChrome) {
console.error('Currently, only Edge(Chromium) or Chrome is supported for debugging.');
console.error('Currently, only Microsoft Edge (80+), or Google Chrome, are supported for debugging.');
} else {

@@ -32,0 +32,0 @@ launchDebugger();

import { attachDebuggerHotkey, hasDebuggingEnabled } from './MonoDebugger';
import { WebAssemblyResourceLoader, LoadingResource } from '../WebAssemblyResourceLoader';
import { Platform, System_Array, Pointer, System_Object, System_String } from '../Platform';
import { loadTimezoneData } from './TimezoneDataFile';
import { WebAssemblyBootResourceType } from '../WebAssemblyStartOptions';
declare const Module: EmscriptenModule;
let mono_string_get_utf8: (managedString: System_String) => Pointer;

@@ -11,2 +15,28 @@ let mono_wasm_add_assembly: (name: string, heapAddress: number, length: number) => void;

// Memory access helpers
// The implementations are exactly equivalent to what the global getValue(addr, type) function does,
// except without having to parse the 'type' parameter, and with less risk of mistakes at the call site
function getValueI16(ptr: number) {
return Module.HEAP16[ptr >> 1];
}
function getValueI32(ptr: number) {
return Module.HEAP32[ptr >> 2];
}
function getValueFloat(ptr: number) {
return Module.HEAPF32[ptr >> 2];
}
function getValueU64(ptr: number) {
// There is no Module.HEAPU64, and Module.getValue(..., 'i64') doesn't work because the implementation
// treats 'i64' as being the same as 'i32'. Also we must take care to read both halves as unsigned.
const heapU32Index = ptr >> 2;
const highPart = Module.HEAPU32[heapU32Index + 1];
if (highPart > maxSafeNumberHighPart) {
throw new Error(
`Cannot read uint64 with high order part ${highPart}, because the result would exceed Number.MAX_SAFE_INTEGER.`,
);
}
return highPart * uint64HighOrderShift + Module.HEAPU32[heapU32Index];
}
export const monoPlatform: Platform = {

@@ -50,3 +80,3 @@ start: function start(resourceLoader: WebAssemblyResourceLoader) {

const dataPtr = getArrayDataPointer(array);
const length = Module.getValue(dataPtr, 'i32');
const length = getValueI32(dataPtr);
return new Uint8Array(Module.HEAPU8.buffer, dataPtr + 4, length);

@@ -56,3 +86,3 @@ },

getArrayLength: function getArrayLength(array: System_Array<any>): number {
return Module.getValue(getArrayDataPointer(array), 'i32');
return getValueI32(getArrayDataPointer(array));
},

@@ -76,30 +106,19 @@

readInt16Field: function readHeapInt16(baseAddress: Pointer, fieldOffset?: number): number {
return Module.getValue(((baseAddress as any) as number) + (fieldOffset || 0), 'i16');
return getValueI16(((baseAddress as any) as number) + (fieldOffset || 0));
},
readInt32Field: function readHeapInt32(baseAddress: Pointer, fieldOffset?: number): number {
return Module.getValue(((baseAddress as any) as number) + (fieldOffset || 0), 'i32');
return getValueI32(((baseAddress as any) as number) + (fieldOffset || 0));
},
readUint64Field: function readHeapUint64(baseAddress: Pointer, fieldOffset?: number): number {
// Module.getValue(..., 'i64') doesn't work because the implementation treats 'i64' as
// being the same as 'i32'. Also we must take care to read both halves as unsigned.
const address = ((baseAddress as any) as number) + (fieldOffset || 0);
const heapU32Index = address >> 2;
const highPart = Module.HEAPU32[heapU32Index + 1];
if (highPart > maxSafeNumberHighPart) {
throw new Error(
`Cannot read uint64 with high order part ${highPart}, because the result would exceed Number.MAX_SAFE_INTEGER.`,
);
}
return highPart * uint64HighOrderShift + Module.HEAPU32[heapU32Index];
return getValueU64(((baseAddress as any) as number) + (fieldOffset || 0));
},
readFloatField: function readHeapFloat(baseAddress: Pointer, fieldOffset?: number): number {
return Module.getValue(((baseAddress as any) as number) + (fieldOffset || 0), 'float');
return getValueFloat(((baseAddress as any) as number) + (fieldOffset || 0));
},
readObjectField: function readHeapObject<T extends System_Object>(baseAddress: Pointer, fieldOffset?: number): T {
return (Module.getValue(((baseAddress as any) as number) + (fieldOffset || 0), 'i32') as any) as T;
return (getValueI32(((baseAddress as any) as number) + (fieldOffset || 0)) as any) as T;
},

@@ -112,3 +131,3 @@

): string | null {
const fieldValue = Module.getValue(((baseAddress as any) as number) + (fieldOffset || 0), 'i32');
const fieldValue = getValueI32(((baseAddress as any) as number) + (fieldOffset || 0));
if (fieldValue === 0) {

@@ -149,2 +168,3 @@ return null;

)[0];
const dotnetJsContentHash = resourceLoader.bootConfig.resources.runtime[dotnetJsResourceName];
const scriptElem = document.createElement('script');

@@ -156,7 +176,23 @@ scriptElem.src = `_framework/wasm/${dotnetJsResourceName}`;

if (resourceLoader.bootConfig.cacheBootResources) {
const contentHash = resourceLoader.bootConfig.resources.runtime[dotnetJsResourceName];
scriptElem.integrity = contentHash;
scriptElem.integrity = dotnetJsContentHash;
scriptElem.crossOrigin = 'anonymous';
}
// Allow overriding the URI from which the dotnet.*.js file is loaded
if (resourceLoader.startOptions.loadBootResource) {
const resourceType: WebAssemblyBootResourceType = 'dotnetjs';
const customSrc = resourceLoader.startOptions.loadBootResource(
resourceType,
dotnetJsResourceName,
scriptElem.src,
dotnetJsContentHash,
);
if (typeof customSrc === 'string') {
scriptElem.src = customSrc;
} else if (customSrc) {
// Since we must load this via a <script> tag, it's only valid to supply a URI (and not a Request, say)
throw new Error(`For a ${resourceType} resource, custom loaders must supply a URI string.`);
}
}
document.body.appendChild(scriptElem);

@@ -188,3 +224,3 @@ }

const resources = resourceLoader.bootConfig.resources;
const module = {} as typeof Module;
const module = (window['Module'] || {}) as typeof Module;
const suppressMessages = ['DEBUGGING ENABLED'];

@@ -195,6 +231,9 @@

module.printErr = (line) => {
// If anything writes to stderr, treat it as a critical exception. The underlying runtime writes
// to stderr if a truly critical problem occurs outside .NET code. Note that .NET unhandled
// exceptions also reach this, but via a different code path - see dotNetCriticalError below.
console.error(line);
};
module.preRun = [];
module.postRun = [];
module.preRun = module.preRun || [];
module.postRun = module.postRun || [];
(module as any).preloadPlugins = [];

@@ -207,2 +246,3 @@

(filename) => `_framework/_bin/${filename}`,
'assembly',
);

@@ -212,2 +252,3 @@ const pdbsBeingLoaded = resourceLoader.loadResources(

(filename) => `_framework/_bin/${filename}`,
'pdb',
);

@@ -218,6 +259,18 @@ const wasmBeingLoaded = resourceLoader.loadResource(

/* hash */ resourceLoader.bootConfig.resources.runtime[dotnetWasmResourceName],
/* type */ 'dotnetwasm',
);
const dotnetTimeZoneResourceName = 'dotnet.timezones.dat';
let timeZoneResource: LoadingResource | undefined;
if (resourceLoader.bootConfig.resources.runtime.hasOwnProperty(dotnetTimeZoneResourceName)) {
timeZoneResource = resourceLoader.loadResource(
dotnetTimeZoneResourceName,
`_framework/wasm/${dotnetTimeZoneResourceName}`,
resourceLoader.bootConfig.resources.runtime[dotnetTimeZoneResourceName],
'timezonedata',
);
}
// Override the mechanism for fetching the main wasm file so we can connect it to our cache
(module as any).instantiateWasm = (imports, successCallback): WebAssembly.Exports => {
module.instantiateWasm = (imports, successCallback): Emscripten.WebAssemblyExports => {
(async () => {

@@ -234,3 +287,3 @@ let compiledInstance: WebAssembly.Instance;

})();
return {}; // No exports
return []; // No exports
};

@@ -240,7 +293,10 @@

// By now, emscripten should be initialised enough that we can capture these methods for later use
mono_wasm_add_assembly = Module.cwrap('mono_wasm_add_assembly', null, ['string', 'number', 'number']);
mono_string_get_utf8 = Module.cwrap('mono_wasm_string_get_utf8', 'number', ['number']);
mono_wasm_add_assembly = cwrap('mono_wasm_add_assembly', null, ['string', 'number', 'number']);
mono_string_get_utf8 = cwrap('mono_wasm_string_get_utf8', 'number', ['number']);
MONO.loaded_files = [];
if (timeZoneResource) {
loadTimezone(timeZoneResource);
}
// Fetch the assemblies and PDBs in the background, telling Mono to wait until they are loaded

@@ -252,2 +308,6 @@ // Mono requires the assembly filenames to have a '.dll' extension, so supply such names regardless

window['Blazor']._internal.dotNetCriticalError = (message: System_String) => {
module.printErr(BINDING.conv_string(message) || '(null)');
};
// Wire-up callbacks for satellite assemblies. Blazor will call these as part of the application

@@ -266,3 +326,7 @@ // startup sequence to load satellite assemblies for the application's culture.

.map((culture) =>
resourceLoader.loadResources(satelliteResources[culture], (fileName) => `_framework/_bin/${fileName}`),
resourceLoader.loadResources(
satelliteResources[culture],
(fileName) => `_framework/_bin/${fileName}`,
'assembly',
),
)

@@ -304,4 +368,5 @@ .reduce((previous, next) => previous.concat(next), new Array<LoadingResource>())

MONO.mono_wasm_setenv('MONO_URI_DOTNETRELATIVEORABSOLUTE', 'true');
const load_runtime = Module.cwrap('mono_wasm_load_runtime', null, ['string', 'number']);
load_runtime(appBinDirName, hasDebuggingEnabled() ? 1 : 0);
const load_runtime = cwrap('mono_wasm_load_runtime', null, ['string', 'number']);
// -1 enables debugging with logging disabled. 0 disables debugging entirely.
load_runtime(appBinDirName, hasDebuggingEnabled() ? -1 : 0);
MONO.mono_wasm_runtime_ready();

@@ -316,3 +381,3 @@ attachInteropInvoker();

const runDependencyId = `blazor:${dependency.name}`;
Module.addRunDependency(runDependencyId);
addRunDependency(runDependencyId);

@@ -335,3 +400,3 @@ try {

Module.removeRunDependency(runDependencyId);
removeRunDependency(runDependencyId);
}

@@ -409,2 +474,13 @@ }

async function loadTimezone(timeZoneResource: LoadingResource): Promise<void> {
const runDependencyId = `blazor:timezonedata`;
addRunDependency(runDependencyId);
const request = await timeZoneResource.response;
const arrayBuffer = await request.arrayBuffer();
loadTimezoneData(arrayBuffer);
removeRunDependency(runDependencyId);
}
async function compileWasmModule(wasmResource: LoadingResource, imports: any): Promise<WebAssembly.Instance> {

@@ -411,0 +487,0 @@ // This is the same logic as used in emscripten's generated js. We can't use emscripten's js because

@@ -0,3 +1,4 @@

import { toAbsoluteUri } from '../Services/NavigationManager';
import { BootJsonData, ResourceList } from './BootConfig';
import { toAbsoluteUri } from '../Services/NavigationManager';
import { WebAssemblyStartOptions, WebAssemblyBootResourceType } from './WebAssemblyStartOptions';

@@ -11,24 +12,33 @@ const networkFetchCacheMode = 'no-cache';

static async initAsync(bootConfig: BootJsonData): Promise<WebAssemblyResourceLoader> {
static async initAsync(
bootConfig: BootJsonData,
startOptions: Partial<WebAssemblyStartOptions>,
): Promise<WebAssemblyResourceLoader> {
const cache = await getCacheToUseIfEnabled(bootConfig);
return new WebAssemblyResourceLoader(bootConfig, cache);
return new WebAssemblyResourceLoader(bootConfig, cache, startOptions);
}
constructor(readonly bootConfig: BootJsonData, readonly cacheIfUsed: Cache | null) {}
constructor(
readonly bootConfig: BootJsonData,
readonly cacheIfUsed: Cache | null,
readonly startOptions: Partial<WebAssemblyStartOptions>,
) {}
loadResources(resources: ResourceList, url: (name: string) => string): LoadingResource[] {
return Object.keys(resources).map((name) => this.loadResource(name, url(name), resources[name]));
loadResources(
resources: ResourceList,
url: (name: string) => string,
resourceType: WebAssemblyBootResourceType,
): LoadingResource[] {
return Object.keys(resources).map((name) => this.loadResource(name, url(name), resources[name], resourceType));
}
loadResource(name: string, url: string, contentHash: string): LoadingResource {
// Note that if cacheBootResources was explicitly disabled, we also bypass hash checking
// This is to give developers an easy opt-out from the entire caching/validation flow if
// there's anything they don't like about it.
loadResource(
name: string,
url: string,
contentHash: string,
resourceType: WebAssemblyBootResourceType,
): LoadingResource {
const response = this.cacheIfUsed
? this.loadResourceWithCaching(this.cacheIfUsed, name, url, contentHash)
: fetch(url, {
cache: networkFetchCacheMode,
integrity: this.bootConfig.cacheBootResources ? contentHash : undefined,
});
? this.loadResourceWithCaching(this.cacheIfUsed, name, url, contentHash, resourceType)
: this.loadResourceWithoutCaching(name, url, contentHash, resourceType);

@@ -90,3 +100,9 @@ return { name, url, response };

private async loadResourceWithCaching(cache: Cache, name: string, url: string, contentHash: string) {
private async loadResourceWithCaching(
cache: Cache,
name: string,
url: string,
contentHash: string,
resourceType: WebAssemblyBootResourceType,
) {
// Since we are going to cache the response, we require there to be a content hash for integrity

@@ -110,3 +126,3 @@ // checking. We don't want to cache bad responses. There should always be a hash, because the build

// It's not in the cache. Fetch from network.
const networkResponse = await fetch(url, { cache: networkFetchCacheMode, integrity: contentHash });
const networkResponse = await this.loadResourceWithoutCaching(name, url, contentHash, resourceType);
this.addToCacheAsync(cache, name, cacheKey, networkResponse); // Don't await - add to cache in background

@@ -117,2 +133,29 @@ return networkResponse;

private loadResourceWithoutCaching(
name: string,
url: string,
contentHash: string,
resourceType: WebAssemblyBootResourceType,
): Promise<Response> {
// Allow developers to override how the resource is loaded
if (this.startOptions.loadBootResource) {
const customLoadResult = this.startOptions.loadBootResource(resourceType, name, url, contentHash);
if (customLoadResult instanceof Promise) {
// They are supplying an entire custom response, so just use that
return customLoadResult;
} else if (typeof customLoadResult === 'string') {
// They are supplying a custom URL, so use that with the default fetch behavior
url = customLoadResult;
}
}
// Note that if cacheBootResources was explicitly disabled, we also bypass hash checking
// This is to give developers an easy opt-out from the entire caching/validation flow if
// there's anything they don't like about it.
return fetch(url, {
cache: networkFetchCacheMode,
integrity: this.bootConfig.cacheBootResources ? contentHash : undefined,
});
}
private async addToCacheAsync(cache: Cache, name: string, cacheKey: string, response: Response) {

@@ -119,0 +162,0 @@ // We have to clone in order to put this in the cache *and* not prevent other code from

@@ -18,2 +18,3 @@ import {

import { decodeUtf8 } from './Utf8Decoder';
import { readInt32LE, readUint64LE, readLEB128, numLEB128Bytes } from './BinaryDecoder';

@@ -26,4 +27,2 @@ const updatedComponentsEntryLength = 4; // Each is a single int32 giving the location of the data

const stringTableEntryLength = 4; // Each is an int32 giving the string data location, or -1 for null
const uint64HighPartShift = Math.pow(2, 32);
const maxSafeNumberHighPart = Math.pow(2, 21) - 1; // The high-order int32 from Number.MAX_SAFE_INTEGER

@@ -248,42 +247,1 @@ export class OutOfProcessRenderBatch implements RenderBatch {

}
function readInt32LE(buffer: Uint8Array, position: number): any {
return buffer[position] | (buffer[position + 1] << 8) | (buffer[position + 2] << 16) | (buffer[position + 3] << 24);
}
function readUint32LE(buffer: Uint8Array, position: number): any {
return (
buffer[position] + (buffer[position + 1] << 8) + (buffer[position + 2] << 16) + ((buffer[position + 3] << 24) >>> 0)
); // The >>> 0 coerces the value to unsigned
}
function readUint64LE(buffer: Uint8Array, position: number): any {
// This cannot be done using bit-shift operators in JavaScript, because
// those all implicitly convert to int32
const highPart = readUint32LE(buffer, position + 4);
if (highPart > maxSafeNumberHighPart) {
throw new Error(
`Cannot read uint64 with high order part ${highPart}, because the result would exceed Number.MAX_SAFE_INTEGER.`,
);
}
return highPart * uint64HighPartShift + readUint32LE(buffer, position);
}
function readLEB128(buffer: Uint8Array, position: number) {
let result = 0;
let shift = 0;
for (let index = 0; index < 4; index++) {
const byte = buffer[position + index];
result |= (byte & 127) << shift;
if (byte < 128) {
break;
}
shift += 7;
}
return result;
}
function numLEB128Bytes(value: number) {
return value < 128 ? 1 : value < 16384 ? 2 : value < 2097152 ? 3 : 4;
}

@@ -10,3 +10,2 @@ const nativeDecoder = typeof TextDecoder === 'function' ? new TextDecoder('utf-8') : null;

https://github.com/samthor/fast-text-encoding
License for fast-text-encoding: Apache 2.0

@@ -13,0 +12,0 @@ https://github.com/samthor/fast-text-encoding/blob/master/LICENSE

@@ -15,4 +15,4 @@ import { resetScrollAfterNextBatch } from '../Rendering/Renderer';

navigateTo,
getBaseURI: () => BINDING.js_string_to_mono_string(document.baseURI),
getLocationHref: () => BINDING.js_string_to_mono_string(location.href),
getBaseURI: () => document.baseURI,
getLocationHref: () => location.href,
};

@@ -84,3 +84,3 @@

// triggering browser-specific behavior issues.
// For details about what this fixes and why, see https://github.com/aspnet/AspNetCore/pull/10839
// For details about what this fixes and why, see https://github.com/dotnet/aspnetcore/pull/10839
const temporaryUri = uri + '?';

@@ -87,0 +87,0 @@ history.replaceState(null, '', temporaryUri);

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

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc