10000 Fix #2220 - Delay plugins resolution due Safari 17.6 greedy resolution · WebReflection/pyscript@004b17d · GitHub
[go: up one dir, main page]

Skip to content

Commit 004b17d

Browse files
committed
Fix pyscript#2220 - Delay plugins resolution due Safari 17.6 greedy resolution
1 parent fe580cd commit 004b17d

File tree

7 files changed

+102
-84
lines changed

7 files changed

+102
-84
lines changed

core/package-lock.json

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

core/package.json

Lines changed: 5 additions & 5 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.12",
44
"type": "module",
55
"description": "PyScript",
66
"module": "./index.js",
@@ -63,13 +63,13 @@
6363
"add-promise-listener": "^0.1.3",
6464
"basic-devtools": "^0.1.6",
6565
"polyscript": "^0.16.3",
66-
"sabayon": "^0.5.2",
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,11 +81,11 @@
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",
9090
"rollup": "^4.24.0",
9191
"rollup-plugin-postcss": "^4.0.2",

core/src/config.js

Lines changed: 17 additions & 17 deletions
< 10000 button class="Button Button--iconOnly Button--invisible" aria-label="More options" id=":R14dtlab:" aria-haspopup="true" aria-expanded="false" tabindex="0">
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);

0 commit comments

Comments
 (0)
0