Added polyscript/service-worker as workaround for missing sabayon (#2334)

* Added polyscript/service-worker as workaround for missing sabayon

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* updated polyscript to its latest

* Updated polyscript one mor time

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Andrea Giammarchi
2025-05-15 18:20:38 +02:00
committed by GitHub
parent 3223a9c7e9
commit b11fb2e893
10 changed files with 1154 additions and 230 deletions

1329
core/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "@pyscript/core",
"version": "0.6.46",
"version": "0.6.51",
"type": "module",
"description": "PyScript",
"module": "./index.js",
@@ -35,6 +35,9 @@
"./storage": {
"import": "./dist/storage.js"
},
"./service-worker": {
"import": "./dist/service-worker.js"
},
"./package.json": "./package.json"
},
"scripts": {
@@ -64,35 +67,35 @@
"dependencies": {
"@ungap/with-resolvers": "^0.1.0",
"@webreflection/idb-map": "^0.3.2",
"@webreflection/utils": "^0.1.0",
"add-promise-listener": "^0.1.3",
"basic-devtools": "^0.1.6",
"polyscript": "^0.17.8",
"sabayon": "^0.7.2",
"polyscript": "^0.17.15",
"sticky-module": "^0.1.1",
"to-json-callback": "^0.1.1",
"type-checked-collections": "^0.1.7"
},
"devDependencies": {
"@codemirror/commands": "^6.8.1",
"@codemirror/lang-python": "^6.1.7",
"@codemirror/lang-python": "^6.2.0",
"@codemirror/language": "^6.11.0",
"@codemirror/state": "^6.5.2",
"@codemirror/view": "^6.36.5",
"@codemirror/view": "^6.36.7",
"@playwright/test": "^1.52.0",
"@rollup/plugin-commonjs": "^28.0.3",
"@rollup/plugin-node-resolve": "^16.0.1",
"@rollup/plugin-terser": "^0.4.4",
"@webreflection/toml-j0.4": "^1.1.3",
"@webreflection/toml-j0.4": "^1.1.4",
"@xterm/addon-fit": "^0.10.0",
"@xterm/addon-web-links": "^0.11.0",
"@xterm/xterm": "^5.5.0",
"bun": "^1.2.10",
"bun": "^1.2.12",
"chokidar": "^4.0.3",
"codedent": "^0.1.2",
"codemirror": "^6.0.1",
"eslint": "^9.25.1",
"eslint": "^9.26.0",
"flatted": "^3.3.3",
"rollup": "^4.40.0",
"rollup": "^4.40.2",
"rollup-plugin-postcss": "^4.0.2",
"rollup-plugin-string": "^3.0.0",
"static-handler": "^0.5.3",

View File

@@ -53,4 +53,15 @@ export default [
sourcemap: true,
},
},
{
input: "./src/service-worker.js",
plugins: plugins.concat(
process.env.NO_MIN
? [nodeResolve(), commonjs()]
: [nodeResolve(), commonjs(), terser()],
),
output: {
file: "./dist/service-worker.js",
},
},
];

View File

@@ -1,3 +1,4 @@
import withResolvers from "@webreflection/utils/with-resolvers";
import TYPES from "./types.js";
const waitForIt = [];
@@ -5,7 +6,7 @@ const waitForIt = [];
for (const [TYPE] of TYPES) {
const selectors = [`script[type="${TYPE}"]`, `${TYPE}-script`];
for (const element of document.querySelectorAll(selectors.join(","))) {
const { promise, resolve } = Promise.withResolvers();
const { promise, resolve } = withResolvers();
waitForIt.push(promise);
element.addEventListener(`${TYPE}:done`, resolve, { once: true });
}

View File

@@ -2,7 +2,7 @@
import "./zero-redirect.js";
import stickyModule from "sticky-module";
import "@ungap/with-resolvers";
import withResolvers from "@webreflection/utils/with-resolvers";
import {
INVALID_CONTENT,
@@ -328,7 +328,7 @@ for (const [TYPE, interpreter] of TYPES) {
class extends HTMLElement {
constructor() {
assign(super(), {
_wrap: Promise.withResolvers(),
_wrap: withResolvers(),
srcCode: "",
executed: false,
});

View File

@@ -1,4 +1,5 @@
import IDBMap from "@webreflection/idb-map";
import withResolvers from "@webreflection/utils/with-resolvers";
import { assign } from "polyscript/exports";
import { $$ } from "basic-devtools";
@@ -26,7 +27,7 @@ export const getFileSystemDirectoryHandle = async (options) => {
);
}
const { promise, resolve, reject } = Promise.withResolvers();
const { promise, resolve, reject } = withResolvers();
const how = { id: "pyscript", mode: "readwrite", ...options };
if (options.hint) how.startIn = options.hint;

View File

@@ -1,4 +1,5 @@
// PyScript py-editor plugin
import withResolvers from "@webreflection/utils/with-resolvers";
import { Hook, XWorker, dedent, defineProperties } from "polyscript/exports";
import { TYPES, offline_interpreter, relative_url, stdlib } from "../core.js";
import { notify } from "./error.js";
@@ -99,7 +100,7 @@ async function execute({ currentTarget }) {
}
const { sync } = xworker;
const { promise, resolve } = Promise.withResolvers();
const { promise, resolve } = withResolvers();
envs.set(env, promise);
sync.revoke = () => {
URL.revokeObjectURL(srcLink);

View File

@@ -1,4 +1,5 @@
// PyScript pyodide terminal plugin
import withResolvers from "@webreflection/utils/with-resolvers";
import { defineProperties } from "polyscript/exports";
import { hooks, inputFailure } from "../../core.js";
@@ -146,7 +147,7 @@ export default async (element) => {
// frees the worker on \r
sync.pyterminal_read = (buffer) => {
terminal.write(buffer);
promisedChunks = Promise.withResolvers();
promisedChunks = withResolvers();
return promisedChunks.promise;
};

View File

@@ -0,0 +1 @@
import "polyscript/service-worker";

View File

@@ -1,14 +1,14 @@
import { ArrayBuffer, TypedArray } from "sabayon/shared";
import IDBMapSync from "@webreflection/idb-map/sync";
import { parse, stringify } from "flatted";
const { isView } = ArrayBuffer;
const to_idb = (value) => {
if (value == null) return stringify(["null", 0]);
/* eslint-disable no-fallthrough */
switch (typeof value) {
case "object": {
if (value instanceof TypedArray)
return stringify(["memoryview", [...value]]);
if (isView(value)) return stringify(["memoryview", [...value]]);
if (value instanceof ArrayBuffer)
return stringify(["bytearray", [...new Uint8Array(value)]]);
}