Skip to content

Allow PyScript to fully run locally #1805

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ repos:
rev: "v3.0.0-alpha.6"
hooks:
- id: prettier
exclude: pyscript\.core/test|pyscript\.core/dist|pyscript\.core/types|pyscript.core/src/stdlib/pyscript.js|pyscript\.sw/
exclude: pyscript\.core/test|pyscript\.core/dist|pyscript\.core/types|pyscript.core/src/stdlib/pyscript.js|pyscript\.sw/|pyscript.core/src/toml\.js
args: [--tab-width, "4"]

- repo: https://github.com/pycqa/isort
Expand Down
1 change: 1 addition & 0 deletions pyscript.core/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module.exports = {
ecmaVersion: "latest",
sourceType: "module",
},
ignorePatterns: ["toml.js"],
rules: {
"no-implicit-globals": ["error"],
},
Expand Down
139 changes: 76 additions & 63 deletions pyscript.core/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions pyscript.core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pyscript/core",
"version": "0.2.8",
"version": "0.2.9",
"type": "module",
"description": "PyScript",
"module": "./index.js",
Expand All @@ -20,7 +20,7 @@
},
"scripts": {
"server": "npx static-handler --coi .",
"build": "node rollup/stdlib.cjs && node rollup/plugins.cjs && rm -rf dist && rollup --config rollup/core.config.js && eslint src/ && npm run ts",
"build": "node rollup/toml.cjs && node rollup/stdlib.cjs && node rollup/plugins.cjs && rm -rf dist && rollup --config rollup/core.config.js && eslint src/ && npm run ts",
"size": "echo -e \"\\033[1mdist/*.js file size\\033[0m\"; for js in $(ls dist/*.js); do echo -e \"\\033[2m$js:\\033[0m $(cat $js | brotli | wc -c) bytes\"; done",
"ts": "tsc -p ."
},
Expand All @@ -33,14 +33,15 @@
"dependencies": {
"@ungap/with-resolvers": "^0.1.0",
"basic-devtools": "^0.1.6",
"polyscript": "^0.4.13",
"polyscript": "^0.4.20",
"type-checked-collections": "^0.1.7"
},
"devDependencies": {
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-terser": "^0.4.4",
"@webreflection/toml-j0.4": "^1.1.3",
"eslint": "^8.51.0",
"rollup": "^4.0.2",
"rollup": "^4.1.4",
"rollup-plugin-postcss": "^4.0.2",
"rollup-plugin-string": "^3.0.0",
"static-handler": "^0.4.3",
Expand Down
14 changes: 14 additions & 0 deletions pyscript.core/rollup/toml.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const { copyFileSync } = require("node:fs");
const { join } = require("node:path");

copyFileSync(
join(
__dirname,
"..",
"node_modules",
"@webreflection",
"toml-j0.4",
"toml.js",
),
join(__dirname, "..", "src", "toml.js"),
);
3 changes: 1 addition & 2 deletions pyscript.core/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ for (const [TYPE] of TYPES) {
} else if (toml || type === "toml") {
try {
const { parse } = await import(
/* webpackIgnore: true */
"https://cdn.jsdelivr.net/npm/@webreflection/toml-j0.4/toml.js"
/* webpackIgnore: true */ "./toml.js"
);
parsed = parse(text);
} catch (e) {
Expand Down
3 changes: 3 additions & 0 deletions pyscript.core/src/toml.js

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions pyscript.core/types/toml.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*! (c) Jak Wings - MIT */ declare class e extends SyntaxError {
constructor(r: any, { offset: t, line: e, column: n }: {
offset: any;
line: any;
column: any;
});
offset: any;
line: any;
column: any;
}
declare function n(n: any): any;
export { e as SyntaxError, n as parse };