8000 Fix #2220 - Delay plugins resolution due Safari 17.6 greedy resolutio… · pyscript/pyscript@9233d5e · GitHub
[go: up one dir, main page]

Skip to content

Commit 9233d5e

Browse files
Fix #2220 - Delay plugins resolution due Safari 17.6 greedy resolution (#2229)
* Fix #2220 - Delay plugins resolution due Safari 17.6 greedy resolution * Fix #2228 - Workaround in Polyscript for lockFileURL
1 parent fe580cd commit 9233d5e

File tree

10 files changed

+225
-164
lines changed

10 files changed

+225
-164
lines changed

core/package-lock.json

Lines changed: 182 additions & 134 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pyscript/core",
3-
"version": "0.6.7",
3+
"version": "0.6.13",
44
"type": "module",
55
"description": "PyScript",
66
"module": "./index.js",
@@ -62,14 +62,14 @@
6262
"@webreflection/idb-map": "^0.3.2",
6363
"add-promise-listener": "^0.1.3",
6464
"basic-devtools": "^0.1.6",
65-
"polyscript": "^0.16.3",
66-
"sabayon": "^0.5.2",
65+
"polyscript": "^0.16.4",
66+
"sabayon": "^0.6.0",
6767
"sticky-module": "^0.1.1",
6868
"to-json-callback": "^0.1.1",
6969
"type-checked-collections": "^0.1.7"
7070
},
7171
"devDependencies": {
72-
"@codemirror/commands": "^6.7.0",
72+
"@codemirror/commands": "^6.7.1",
7373
"@codemirror/lang-python": "^6.1.6",
7474
"@codemirror/language": "^6.10.3",
7575
"@codemirror/state": "^6.4.1",
@@ -81,13 +81,13 @@
8181
"@webreflection/toml-j0.4": "^1.1.3",
8282
"@xterm/addon-fit": "^0.10.0",
8383
"@xterm/addon-web-links": "^0.11.0",
84-
"bun": "^1.1.30",
84+
"bun": "^1.1.33",
8585
"chokidar": "^4.0.1",
8686
"codedent": "^0.1.2",
8787
"codemirror": "^6.0.1",
88-
"eslint": "^9.12.0",
88+
"eslint": "^9.13.0",
8989
"flatted": "^3.3.1",
90-
"rollup": "^4.24.0",
90+
"rollup": "^4.24.2",
9191
"rollup-plugin-postcss": "^4.0.2",
9292
"rollup-plugin-string": "^3.0.0",
9393
"static-handler": "^0.5.3",

core/src/config.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const syntaxError = (type, url, { message }) => {
5656
const configs = new Map();
5757

5858
for (const [TYPE] of TYPES) {
59-
/** @type {Promise<[...any]>} A Promise wrapping any plugins which should be loaded. */
59+
/** @type {() => Promise<[...any]>} A Promise wrapping any plugins which should be loaded. */
6060
let plugins;
6161

6262
/** @type {any} The PyScript configuration parsed from the JSON or TOML object*. May be any of the return types of JSON.parse() or toml-j0.4's parse() ( {number | string | boolean | null | object | Array} ) */
@@ -135,24 +135,24 @@ for (const [TYPE] of TYPES) {
135135

136136
// parse all plugins and optionally ignore only
137137
// those flagged as "undesired" via `!` prefix
138-
const toBeAwaited = [];
139-
for (const [key, value] of Object.entries(allPlugins)) {
140-
if (error) {
141-
if (key === "error") {
142-
// show on page the config is broken, meaning that
143-
// it was not possible to disable error plugin neither
144-
// as that part wasn't correctly parsed anyway
145-
value().then(({ notify }) => notify(error.message));
138+
plugins = async () => {
139+
const toBeAwaited = [];
140+
for (const [key, value] of Object.entries(allPlugins)) {
141+
if (error) {
142+
if (key === "error") {
143+
// show on page the config is broken, meaning that
144+
// it was not possible to disable error plugin neither
145+
// as that part wasn't correctly parsed anyway
146+
value().then(({ notify }) => notify(error.message));
147+
}
148+
} else if (!parsed?.plugins?.includes(`!${key}`)) {
149+
toBeAwaited.push(value().then(({ default: p }) => p));
150+
} else if (key === "error") {
151+
toBeAwaited.push(value().then(({ notOnDOM }) => notOnDOM()));
146152
}
147-
} else if (!parsed?.plugins?.includes(`!${key}`)) {
148-
toBeAwaited.push(value().then(({ default: p }) => p));
149-
} else if (key === "error") {
150-
toBeAwaited.push(value().then(({ notOnDOM }) => notOnDOM()));
151153
}
152-
}
153-
154-
// assign plugins as Promise.all only if needed
155-
plugins = Promise.all(toBeAwaited);
154+
return await Promise.all(toBeAwaited);
155+
};
156156

157157
configs.set(TYPE, { config: parsed, configURL, plugins, error });
158158
}

core/src/core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ for (const [TYPE, interpreter] of TYPES) {
179179
// ensure plugins are bootstrapped already before custom type definition
180180
// NOTE: we cannot top-level await in here as plugins import other utilities
181181
// from core.js itself so that custom definition should not be blocking.
182-
plugins.then(() => {
182+
plugins().then(() => {
183183
// possible early errors sent by polyscript
184184
const errors = new Map();
185185

core/src/plugins/deprecations-manager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// PyScript Derepcations Plugin
2-
import { hooks } from "../core.js";
32
import { notify } from "./error.js";
3+
import { hooks } from "../core.js";
44

55
// react lazily on PyScript bootstrap
66
hooks.main.onReady.add(checkDeprecations);

core/src/plugins/py-terminal/mpy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// PyScript pyodide terminal plugin
2-
import { hooks, inputFailure } from "../../core.js";
32
import { defineProperties } from "polyscript/exports";
3+
import { hooks, inputFailure } from "../../core.js";
44

55
const bootstrapped = new WeakSet();
66

core/src/plugins/py-terminal/py.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// PyScript py-terminal plugin
2-
import { hooks } from "../../core.js";
32
import { defineProperties } from "polyscript/exports";
3+
import { hooks } from "../../core.js";
44

55
const bootstrapped = new WeakSet();
66

core/src/stdlib/pyscript.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/tests/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414
a:hover { opacity: 1; }
1515
</style>
1616
</head>
17-
<body><ul><li><strong><span>javascript</span></strong><ul><li><a href="./javascript/async-listener.html">async-listener<small>.html</small></a></li><li><a href="./javascript/config-url.html">config-url<small>.html</small></a></li><li><a href="./javascript/config_type.html">config_type<small>.html</small></a></li><li><strong><a href="./javascript/fetch/index.html">fetch</a></strong></li><li><a href="./javascript/ffi.html">ffi<small>.html</small></a></li><li><a href="./javascript/hooks.html">hooks<small>.html</small></a></li><li><strong><a href="./javascript/issue-2093/index.html">issue-2093</a></strong></li><li><a href="./javascript/js-storage.html">js-storage<small>.html</small></a></li><li><a href="./javascript/js_modules.html">js_modules<small>.html</small></a></li><li><strong><a href="./javascript/loader/index.html">loader</a></strong></li><li><a href="./javascript/mpy-error.html">mpy-error<small>.html</small></a></li><li><a href="./javascript/mpy-no-error.html">mpy-no-error<small>.html</small></a></li><li><a href="./javascript/mpy.html">mpy<small>.html</small></a></li><li><a href="./javascript/py-terminal-main.html">py-terminal-main<small>.html</small></a></li><li><a href="./javascript/py-terminal-worker.html">py-terminal-worker<small>.html</small></a></li><li><a href="./javascript/py-terminal.html">py-terminal<small>.html</small></a></li><li><a href="./javascript/py-terminals.html">py-terminals<small>.html</small></a></li><li><strong><a href="./javascript/pyodide-cache/index.html">pyodide-cache</a></strong></li><li><a href="./javascript/storage.html">storage<small>.html</small></a></li><li><strong><span>workers</span></strong><ul><li><strong><a href="./javascript/workers/create_named/index.html">create_named</a></strong></li><li><strong><a href="./javascript/workers/mpy/index.html">mpy</a></strong></li><li><strong><a href="./javascript/workers/py/index.html">py</a></strong></li></ul></li></ul></li><li><strong><a href="./manual/index.html">manual</a></strong><ul><li><a href="./manual/all-done.html">all-done<small>.html</small></a></li><li><a href="./manual/async.html">async<small>.html</small></a></li><li><a href="./manual/camera.html">camera<small>.html</small></a></li><li><a href="./manual/click.html">click<small>.html</small></a></li><li><a href="./manual/code-a-part.html">code-a-part<small>.html</small></a></li><li><a href="./manual/combo.html">combo<small>.html</small></a></li><li><a href="./manual/config.html">config<small>.html</small></a></li><li><a href="./manual/create-element.html">create-element<small>.html</small></a></li><li><a href="./manual/dialog.html">dialog<small>.html</small></a></li><li><a href="./manual/display.html">display<small>.html</small></a></li><li><strong><a href="./manual/donkey/index.html">donkey</a></strong></li><li><a href="./manual/error.html">error<small>.html</small></a></li><li><a href="./manual/html-decode.html">html-decode<small>.html</small></a></li><li><a href="./manual/input.html">input<small>.html</small></a></li><li><a href="./manual/interpreter.html">interpreter<small>.html</small></a></li><li><strong><a href="./manual/issue-7015/index.html">issue-7015</a></strong></li><li><a href="./manual/multi.html">multi<small>.html</small></a></li><li><a href="./manual/multiple-editors.html">multiple-editors<small>.html</small></a></li><li><a href="./manual/no-error.html">no-error<small>.html</small></a></li><li><strong><a href="./manual/no_sab/index.html">no_sab</a></strong></li><li><strong><a href="./manual/piratical/index.html">piratical</a></strong></li><li><a href="./manual/py-editor.html">py-editor<small>.html</small></a></li><li><a href="./manual/py-editor-failure.html">py-editor-failure<small>.html</small></a></li><li><strong><a href="./manual/py-terminals/index.html">py-terminals</a></strong><ul><li><a href="./manual/py-terminals/no-repl.html">no-repl<small>.html</small></a></li><li><a href="./manual/py-terminals/repl.html">repl<small>.html</small></a></li></ul></li><li><a href="./manual/py_modules.html">py_modules<small>.html</small></a></li><li><strong><a href="./manual/service-worker/index.html">service-worker</a></strong></li><li><a href="./manual/split-config.html">split-config<small>.html</small></a></li><li><a href="./manual/submit.html">submit<small>.html</small></a></li><li><a href="./manual/target.html">target<small>.html</small></a></li><li><a href="./manual/test_display_HTML.html">test_display_HTML<small>.html</small></a></li><li><a href="./manual/test_when.html">test_when<small>.html</small></a></li><li><a href="./manual/worker.html">worker<small>.html</small></a></li></ul></li><li><strong><a href="./python/index.html">python</a></strong></li></ul></body>
17+
<body><ul><li><strong><span>javascript</span></strong><ul><li><a href="./javascript/async-listener.html">async-listener<small>.html</small></a></li><li><a href="./javascript/config-url.html">config-url<small>.html</small></a></li><li><a href="./javascript/config_type.html">config_type<small>.html</small></a></li><li><strong><a href="./javascript/fetch/index.html">fetch</a></strong></li><li><a href="./javascript/ffi.html">ffi<small>.html</small></a></li><li><a href="./javascript/hooks.html">hooks<small>.html</small></a></li><li><strong><a href="./javascript/issue-2093/index.html">issue-2093</a></strong></li><li><a href="./javascript/js-storage.html">js-storage<small>.html</small></a></li><li><a href="./javascript/js_modules.html">js_modules<small>.html</small></a></li><li><strong><a href="./javascript/loader/index.html">loader</a></strong></li><li><a href="./javascript/mpy-error.html">mpy-error<small>.html</small></a></li><li><a href="./javascript/mpy-no-error.html">mpy-no-error<small>.html</small></a></li><li><a href="./javascript/mpy.html">mpy<small>.html</small></a></li><li><a href="./javascript/py-terminal-main.html">py-terminal-main<small>.html</small></a></li><li><a href="./javascript/py-terminal-worker.html">py-terminal-worker<small>.html</small></a></li><li><a href="./javascript/py-terminal.html">py-terminal<small>.html</small></a></li><li><a href="./javascript/py-terminals.html">py-terminals<small>.html</small></a></li><li><strong><a href="./javascript/pyodide-cache/index.html">pyodide-cache</a></strong></li><li><a href="./javascript/storage.html">storage<small>.html</small></a></li><li><strong><span>workers</span></strong><ul><li><strong><a href="./javascript/workers/create_named/index.html">create_named</a></strong></li><li><strong><a href="./javascript/workers/mpy/index.html">mpy</a></strong></li><li><strong><a href="./javascript/workers/py/index.html">py</a></strong></li></ul></li></ul></li><li><strong><a href="./manual/index.html">manual</a></strong><ul><li><a href="./manual/all-done.html">all-done<small>.html</small></a></li><li><a href="./manual/async.html">async<small>.html</small></a></li><li><a href="./manual/camera.html">camera<small>.html</small></a></li><li><a href="./manual/click.html">click<small>.html</small></a></li><li><a href="./manual/code-a-part.html">code-a-part<small>.html</small></a></li><li><a href="./manual/combo.html">combo<small>.html</small></a></li><li><a href="./manual/config.html">config<small>.html</small></a></li><li><a href="./manual/create-element.html">create-element<small>.html</small></a></li><li><a href="./manual/dialog.html">dialog<small>.html</small></a></li><li><a href="./manual/display.html">display<small>.html</small></a></li><li><strong><a href="./manual/donkey/index.html">donkey</a></strong></li><li><a href="./manual/error.html">error<small>.html</small></a></li><li><a href="./manual/html-decode.html">html-decode<small>.html</small></a></li><li><a href="./manual/input.html">input<small>.html</small></a></li><li><a href="./manual/interpreter.html">interpreter<small>.html</small></a></li><li><strong><a href="./manual/issue-2228/index.html">issue-2228</a></strong></li><li><strong><a href="./manual/issue-7015/index.html">issue-7015</a></strong></li><li><a href="./manual/multi.html">multi<small>.html</small></a></li><li><a href="./manual/multiple-editors.html">multiple-editors<small>.html</small></a></li><li><a href="./manual/no-error.html">no-error<small>.html</small></a></li><li><strong><a href="./manual/no_sab/index.html">no_sab</a></strong></li><li><strong><a href="./manual/piratical/index.html">piratical</a></strong></li><li><a href="./manual/py-editor.html">py-editor<small>.html</small></a></li><li><a href="./manual/py-editor-failure.html">py-editor-failure<small>.html</small></a></li><li><strong><a href="./manual/py-terminals/index.html">py-terminals</a></strong><ul><li><a href="./manual/py-terminals/no-repl.html">no-repl<small>.html</small></a></li><li><a href="./manual/py-terminals/repl.html">repl<small>.html</small></a></li></ul></li><li><a href="./manual/py_modules.html">py_modules<small>.html</small></a></li><li><strong><a href="./manual/service-worker/index.html">service-worker</a></strong></li><li><a href="./manual/split-config.html">split-config<small>.html</small></a></li><li><a href="./manual/submit.html">submit<small>.html</small></a></li><li><a href="./manual/target.html">target<small>.html</small></a></li><li><a href="./manual/test_display_HTML.html">test_display_HTML<small>.html</small></a></li><li><a href="./manual/test_when.html">test_when<small>.html</small></a></li><li><a href="./manual/worker.html">worker<small>.html</small></a></li></ul></li><li><strong><a href="./python/index.html">python</a></strong></li></ul></body>
1818
</html>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width,initial-scale=1.0">
6+
<script type="module" src="../../../dist/core.js"></script>
7+
</head>
8+
<body>
9+
<script type="py" config='{"packages":["jsonpointer==3.0.0"]}'>
10+
print('Hello World')
11+
</script>
12+
</body>
13+
</html>

0 commit comments

Comments
 (0)
0