mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-21 11:15:36 -05:00
More plugins: splashscreen and importmap (#938)
This PR move codes from main.ts into two new plugins: - splashscreen (formerly known as py-loader) - importmap The old setting config.autoclose_loader is still supported but deprecated; the new setting is config.splashscreen.autoclose. Moreover, it does a small refactoring around UserError: now UserErrors are correctly caught even if they are raised from within afterRuntimeLoad.
This commit is contained in:
@@ -46,10 +46,8 @@ export function showWarning(msg: string, messageType: "text" | "html" = "text"):
|
||||
}
|
||||
|
||||
export function handleFetchError(e: Error, singleFile: string) {
|
||||
//Should we still export full error contents to console?
|
||||
// XXX: What happens if I make a typo? i.e. a web server is being used but a file
|
||||
// that doesn't exist is being accessed. We should cover this case as well.
|
||||
console.warn(`Caught an error in fetchPaths:\r\n ${e.toString()}`);
|
||||
// XXX: inspecting the error message to understand what happened is very
|
||||
// fragile. We need a better solution.
|
||||
let errorContent: string;
|
||||
if (e.message.includes('Failed to fetch')) {
|
||||
errorContent = `<p>PyScript: Access to local files
|
||||
@@ -66,11 +64,7 @@ export function handleFetchError(e: Error, singleFile: string) {
|
||||
} else {
|
||||
errorContent = `<p>PyScript encountered an error while loading from file: ${e.message} </p>`;
|
||||
}
|
||||
// We need to create the banner because `handleFetchError` is called before we
|
||||
// use withUserErrorHandler in main.js we are also disabling the log message
|
||||
// because it will be logged by the uncaught exception in promise.
|
||||
_createAlertBanner(errorContent, "error", "html", false);
|
||||
throw new UserError(errorContent);
|
||||
throw new UserError(errorContent, "html");
|
||||
}
|
||||
|
||||
export function readTextFromPath(path: string) {
|
||||
|
||||
Reference in New Issue
Block a user