mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-22 03:35:31 -05:00
* add tests to verify if we show an error banner when users load from latest * add deprecation manager to take care of showing a notification in case script src is being loaded from latest * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * make sure deprecation warning also register onWorker * restore tests for banner in worker * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * add a wait selector when testing banner since worker seems to take too long to render in CI * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix test_deprecate_loading_scripts_from_latest: I think that the previous failure was because we actually TRIED to execute the js from latest/core.js and it conflicted with our local copy. But to trigger the warning is enough to have a script pointing to pyscript.net/latest, there is no need to execute it: modify it with type="ignore-me" and an URL which doesn't exist. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Antonio Cuni <anto.cuni@gmail.com>
28 lines
848 B
JavaScript
28 lines
848 B
JavaScript
// PyScript Derepcations Plugin
|
|
import { hooks } from "../core.js";
|
|
import { notify } from "./error.js";
|
|
|
|
// react lazily on PyScript bootstrap
|
|
hooks.main.onReady.add(checkDeprecations);
|
|
hooks.main.onWorker.add(checkDeprecations);
|
|
|
|
/**
|
|
* Check that there are no scripts loading from pyscript.net/latest
|
|
*/
|
|
function checkDeprecations() {
|
|
const scripts = document.querySelectorAll("script");
|
|
for (const script of scripts) checkLoadingScriptsFromLatest(script.src);
|
|
}
|
|
|
|
/**
|
|
* Check if src being loaded from pyscript.net/latest and display a notification if true
|
|
* * @param {string} src
|
|
*/
|
|
function checkLoadingScriptsFromLatest(src) {
|
|
if (/\/pyscript\.net\/latest/.test(src)) {
|
|
notify(
|
|
"Loading scripts from latest is deprecated and will be removed soon. Please use a specific version instead.",
|
|
);
|
|
}
|
|
}
|