mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-19 10:17:23 -05:00
committed by
GitHub
parent
339e40063a
commit
0cdbfbeb30
9
.gitignore
vendored
9
.gitignore
vendored
@@ -141,3 +141,12 @@ coverage/
|
||||
|
||||
# junit xml for test results
|
||||
test_results
|
||||
|
||||
# pyscript.core
|
||||
pyscript.core/coverage/
|
||||
pyscript.core/node_modules/
|
||||
pyscript.core/cjs/
|
||||
!pyscript.core/cjs/package.json
|
||||
pyscript.core/min.js
|
||||
pyscript.core/esm/worker/xworker.js
|
||||
pyscript.core/types/
|
||||
|
||||
@@ -38,6 +38,7 @@ repos:
|
||||
rev: v2.2.4
|
||||
hooks:
|
||||
- id: codespell # See 'pyproject.toml' for args
|
||||
exclude: \.js\.map$
|
||||
additional_dependencies:
|
||||
- tomli
|
||||
|
||||
|
||||
@@ -3,3 +3,8 @@ ISSUE_TEMPLATE
|
||||
package-lock.json
|
||||
docs
|
||||
examples/panel.html
|
||||
pyscript.core/micropython/
|
||||
pyscript.core/pyscript/
|
||||
pyscript.core/types/
|
||||
pyscript.core/esm/worker/xworker.js
|
||||
pyscript.core/min.js
|
||||
|
||||
3
pyscript.core/.gitignore
vendored
3
pyscript.core/.gitignore
vendored
@@ -1,9 +1,8 @@
|
||||
.DS_Store
|
||||
.nyc_output
|
||||
*.log
|
||||
coverage/
|
||||
node_modules/
|
||||
cjs/
|
||||
!cjs/package.json
|
||||
min.js
|
||||
esm/worker/xworker.js
|
||||
types/
|
||||
|
||||
@@ -1,120 +1,33 @@
|
||||
# pyscript
|
||||
# @pyscript/core
|
||||
|
||||
[](https://github.com/WebReflection/python/actions/workflows/node.js.yml) [](https://coveralls.io/github/WebReflection/python?branch=api)
|
||||
|
||||
---
|
||||
|
||||
## API
|
||||
|
||||
Please check the PR around current API and help me out changing or improving it, thank you!
|
||||
https://github.com/WebReflection/python/blob/c50ab771ffb14d2fbb499219d67200cf02e0cd5f/API.md
|
||||
|
||||
---
|
||||
|
||||
### Development
|
||||
## Development
|
||||
|
||||
The working folder (source code of truth) is the `./esm` one, while the `./cjs` is populated as dual module and to test (but it's 1:1 code, no trnaspilation except for imports/exports).
|
||||
|
||||
Please be sure the following line is prsent in your `.git/hooks/pre-commit` file to always test and check coverage before committing.
|
||||
```sh
|
||||
# install all dependencies needed by core
|
||||
npm i
|
||||
```
|
||||
|
||||
### Build / Artifacts
|
||||
|
||||
This project requires some automatic artifact creation to:
|
||||
|
||||
* create a _Worker_ as a _Blob_ based on the same code used by this repo
|
||||
* create automatically the list of runtimes available via the module
|
||||
* create the `min.js` file used by most integration tests
|
||||
* create a sha256 version of the Blob content for CSP cases
|
||||
|
||||
Accordingly, to build latest project:
|
||||
|
||||
```sh
|
||||
exec npx c8 --100 npm test > /dev/null
|
||||
# create all artifacts needed to test core
|
||||
npm run build
|
||||
|
||||
# optionally spin a server with CORS, COOP, and COEP enabled
|
||||
npm run server
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
The goal of this repository is to explore a few _PyScript_ related topics, such as:
|
||||
|
||||
- **bootstrap time**: do we need to do everything we currently do by default?
|
||||
- **ESM / npm module**: why are we still attaching things to the global?
|
||||
- **dependencies**: do we need to include a whole _TOML_ v0.4 parser by default?
|
||||
- **DX / UX**: what if we simplify most pain points we already know while solving all problems we also will or already have moving forward?
|
||||
- **YAGNI**: thoughts about current features that look more like a workaround
|
||||
|
||||
Following each topic is discussed with findings, ideas, and proof of concepts.
|
||||
|
||||
## Bootstrap Time
|
||||
|
||||
Once bundled, the current PoC weigths **2.7K** (~1K compressed) as opposite of current _pyscript.js_ which is **1.2MB** (~230K compressed).
|
||||
By no mean the current PoC can replace all _pyscript.js_ features, but I believe a smaller and better architected core could help creating even more projects around our offer.
|
||||
|
||||
**Notable findings**
|
||||
|
||||
- even if no `<py-config>` is defined, we include a whole TOML library and we import _micropip_, _pyparsing_ and _pypackaging_ for an "_Hello World_"
|
||||
- there's a lot of code which only goal is to handle _HTML_ issues with parsed content and entities and _IDs_. This PoC never uses, neither needs, _IDs_ at all and it makes any target avilable within the Python code instead of needing to have discoverable _IDs_ (see recent MR around _IDs_ in Shadow DOM too) ... should we re-consider the need for _IDs_ and drop all the code around this topic in the (hopefully) near future?
|
||||
- there's no need to normalize any _python_ output with the usage of `<script>` because if the indentation is not broken the interpreter works just fine (this is extra code we could just remove from our codebase)
|
||||
- despite our possible improvements around previous point, the "_elephant in the room_" is _pyodide_ initialization time. We can save bandwidth and some millisencods but the main thread is blocked for ~1.5 seconds when _pyodide_ kicks in. Is there anything we can do to at least move its initialization elsewhere? (e.g. _Worker_)
|
||||
- adding a _cache all_ strategy for an extremely simple _Service Worker_ made bootstrap time predictable, either via this PoC or via _pyscript_. Is there any particular reason we are not using a _Service Worker_ everywhere we offer or demo _pyscript_?
|
||||
- once initialized, both _pyodide_ and _micropython_ expose the version ... why do we attach a version before loading these runtimes?
|
||||
|
||||
## As ESM / `npm` module
|
||||
|
||||
Both _pyscript_, current _micropython_ file, and (IIRC) _pyodide_ leak something on the _global_ context. Not only this is generally considered a bad practice but it also plays badly with the idea that multiple interpreters _could_ coexist in the same page (already possible with this PoC).
|
||||
|
||||
Not being a module also means we don't get to benefit from easy install and all _CDNs_ that for free would allow any developer to use our offer in the wild, including local projects bootstrapped via all the usual/common Web related tools.
|
||||
|
||||
What would it take to actually use _pyscript_ as a module or why are we still using these fairly outdated and problematic/conflicting practices instead?
|
||||
|
||||
## Dependencies
|
||||
|
||||
We all agree that _TOML_ is likely the preferred choice for Python users to setup the environment but it's not clear why we need to embed a 3rd party fork that parses the whole _TOML_ standard within our code out of the box, or why we do initialize a package manager when it's not even needed, asking the core to download extra stuff by default even for cases such stuff was not desired nor required.
|
||||
|
||||
Accordingly, if there's no particular reason I am not aware about, should we include via dynamic `import` the _TOML_ parser **and** botstrap `micropip` and the rest only if the config exists and not by default?
|
||||
|
||||
If it has to be there by default, why isn't the package manager already embedded within _pyodide_ or _micropython_ (`mip`) and initialized internally?
|
||||
|
||||
Last, but not least, as our config consist of 3 or 4 fields and nothing else, do we really need a whole TOML 3rd party parer instead of a super-simple one that just gets the job done, in case we want to embed that in core? Reading _config_'s specs it feels like we're slightly overdoing it in there and we also have issues with the config order (which btw could also be the case for JSON configurations).
|
||||
|
||||
## DX / UX
|
||||
|
||||
We currently have (imho) some hard to explain limitation around _pyscript_, most notably:
|
||||
|
||||
- we have a `<py-config>` custom element where only a single one can be used and everything else is ignored. The reasons for this (I am guessing) are:
|
||||
- we have a single interpreter at the time ... but how would this scale when multiple interpreteres are wanted/desired?
|
||||
- there's no relation between a `<py-config>` and a `<py-script>` element ... even their definition order on the page doesn't matter so that if multiple `<py-script>` on a page have as last node a `<py-config>` they all follow that rule, making it impossible to grant either runtime or config per each `<py-script>`. Aren't we trapped by this decoupling of components that are, in fact, strongly coupled and constrained by such _implicit_ coupling? What's the plan forward here?
|
||||
- in all our live examples but 2 all we need is *a single `<py-script>` tag and, occasionally, a single `<py-config>` tag and I wonder if this is effectily the main use-case to address, while the need for multiple `<py-script>` that all share same config and environment look like needed only to display results in different places of the page, something easy to address via IDs when elements are well known or via the `js.document.querySelector(...)` API we expose through *pyodide* and *micropython*. Shouldn't we instead find a better way to relate same env when more `<py-script>` are meant, so that we bootstrap only one *main* env and we refer to such *env\* via attributes?
|
||||
- there's no way to display Python results within `<py-script>` custom element if this is within unexpected places: tables, trs, tds, options, sources, and what's not, current PoC offers an escape hatch to assign the target at runtime without any of the caveats we have with custom elements
|
||||
- we recently introduced `py-*` events for any node but that implicitly blocks multiple runtimes per page ... should we find a compromise/solution to this, since the `env` attribute could be used as `py-env` target too?
|
||||
|
||||
The current PoC couple _env_ and _config_ through a single component, isolating every script, runtime, and environment from each other.
|
||||
|
||||
Not only that, multiple _python scripts_ can share the same configuration whenever that's desired and in multiple pages or different parts of the page but these don't necessarily need to share the same environment.
|
||||
|
||||
The current PoC indeed allows multiple config and multiple interpreters (_pyodide_ or _micropython_) per page, downloading each only once but initializing these per each _script_ when desired.
|
||||
|
||||
A unique identifier, that is not an ID, could also relate each script to the same env as it's done now (shared _pyodide_ runtime across all _py-script_ tags) but that'd be an extra feature, not the default, and it can be orchestrated explicitly, example
|
||||
|
||||
```html
|
||||
<script type="py" config="shared-demo.toml">
|
||||
from js import document
|
||||
# target here is the related current script node
|
||||
document.currentScript.target.textContent = 'a'
|
||||
</script>
|
||||
<hr />
|
||||
<script type="py" env="shared-env">
|
||||
# this env shares nothing with the previous/default one
|
||||
from js import document
|
||||
# target here is the related current script node
|
||||
# which is different from the previous one
|
||||
document.currentScript.target.textContent = 'b'
|
||||
</script>
|
||||
<hr />
|
||||
<script type="py" env="shared-env">
|
||||
# this env shares globals only with the previous script
|
||||
from js import document
|
||||
# target here is the related current script node
|
||||
# which is also again different from the previous one
|
||||
document.currentScript.target.textContent = 'c'
|
||||
</script>
|
||||
```
|
||||
|
||||
I (personally) believe that optionally coupling _env_, _config_, and _runtime_ to each single script provides the base to distribute _pyscript_ components in the wild and without ever causing issues, so in few words this is not only a more robust and clean approach to what we have already, where two 3rd party _pyscript_ components can't coexist within the same page because of the points previously mentioned, but it's way more expicit than having multiple `<py-config>` potentially ignored by the page because one was already present / parsed / used within another component that landed before.
|
||||
|
||||
## YAGNI
|
||||
|
||||
This is a super-personal take around current _pyscript_ state of affairs:
|
||||
|
||||
- the splash screen reminds me good'ol days with Flash Player ... ideally we should have a fast boostrap that makes such practice irrelevant
|
||||
- the `interpreters` in the config, when only a config can run, is weird to say the least ... it's theoretically an array of details, with names and stuff, and I think nobody cares about it ... the current `runtime` attribute looks much easier to explain and reason about, plus, as previously mentioned, is confined within the _script_ that is running current python code
|
||||
- the whole TOML parser for our explicit use case looks like replace-able with a single RegExp or a split line loop (see https://github.com/WebReflection/basic-toml#readme)
|
||||
- plugins should never be embedded out of the box ... we might want to provide a list of plugins via a `plugins` attribute and handle these ourselves but I think that having a `@pyscript/core` module any plugin can use to register itself would be better at scale and architecture
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
import { getBuffer } from "../fetch-utils.js";
|
||||
import { absoluteURL } from "../utils.js";
|
||||
|
||||
/**
|
||||
* Trim code only if it's a single line that prettier or other tools might have modified.
|
||||
* @param {string} code code that might be a single line
|
||||
* @returns {strong}
|
||||
*/
|
||||
export const clean = (code) =>
|
||||
code.replace(/^[^\r\n]+$/, (line) => line.trim());
|
||||
|
||||
// REQUIRES INTEGRATION TEST
|
||||
/* c8 ignore start */
|
||||
export const io = new WeakMap();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { fetchPaths, stdio, writeFile } from "./_utils.js";
|
||||
import { clean, fetchPaths, stdio, writeFile } from "./_utils.js";
|
||||
|
||||
const type = "micropython";
|
||||
|
||||
@@ -20,8 +20,8 @@ export default {
|
||||
if (config.fetch) await fetchPaths(this, runtime, config.fetch);
|
||||
return runtime;
|
||||
},
|
||||
run: (runtime, code) => runtime.runPython(code),
|
||||
runAsync: (runtime, code) => runtime.runPythonAsync(code),
|
||||
run: (runtime, code) => runtime.runPython(clean(code)),
|
||||
runAsync: (runtime, code) => runtime.runPythonAsync(clean(code)),
|
||||
runEvent(runtime, code, key) {
|
||||
return this.run(
|
||||
runtime,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { fetchPaths, stdio, writeFile } from "./_utils.js";
|
||||
import { clean, fetchPaths, stdio, writeFile } from "./_utils.js";
|
||||
|
||||
const type = "pyodide";
|
||||
|
||||
@@ -26,8 +26,8 @@ export default {
|
||||
}
|
||||
return runtime;
|
||||
},
|
||||
run: (runtime, code) => runtime.runPython(code),
|
||||
runAsync: (runtime, code) => runtime.runPythonAsync(code),
|
||||
run: (runtime, code) => runtime.runPython(clean(code)),
|
||||
runAsync: (runtime, code) => runtime.runPythonAsync(clean(code)),
|
||||
runEvent(runtime, code, key) {
|
||||
return this.run(
|
||||
runtime,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { fetchPaths } from "./_utils.js";
|
||||
import { clean, fetchPaths } from "./_utils.js";
|
||||
|
||||
const type = "ruby";
|
||||
|
||||
@@ -32,8 +32,8 @@ export default {
|
||||
if (config.fetch) await fetchPaths(this, runtime, config.fetch);
|
||||
return runtime;
|
||||
},
|
||||
run: (runtime, code) => runtime.eval(code),
|
||||
runAsync: (runtime, code) => runtime.evalAsync(code),
|
||||
run: (runtime, code) => runtime.eval(clean(code)),
|
||||
runAsync: (runtime, code) => runtime.evalAsync(clean(code)),
|
||||
runEvent(runtime, code, key) {
|
||||
return this.run(
|
||||
runtime,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { fetchPaths, stdio, writeFileShim } from "./_utils.js";
|
||||
import { clean, fetchPaths, stdio, writeFileShim } from "./_utils.js";
|
||||
|
||||
const type = "wasmoon";
|
||||
|
||||
@@ -24,8 +24,8 @@ export default {
|
||||
if (config.fetch) await fetchPaths(this, runtime, config.fetch);
|
||||
return runtime;
|
||||
},
|
||||
run: (runtime, code) => runtime.doStringSync(code),
|
||||
runAsync: (runtime, code) => runtime.doString(code),
|
||||
run: (runtime, code) => runtime.doStringSync(clean(code)),
|
||||
runAsync: (runtime, code) => runtime.doString(clean(code)),
|
||||
runEvent(runtime, code, key) {
|
||||
runtime.global.set("event", globalThis.__events.get(key));
|
||||
return this.run(runtime, code);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
7010
pyscript.core/package-lock.json
generated
7010
pyscript.core/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -5,7 +5,7 @@
|
||||
"main": "./cjs/index.js",
|
||||
"types": "./types/index.d.ts",
|
||||
"scripts": {
|
||||
"server": "npx static-handler --cors .",
|
||||
"server": "npx static-handler --cors --coep --coop .",
|
||||
"build": "npm run rollup:xworker && npm run rollup:min && eslint esm/ && npm run ts && npm run cjs && npm run test",
|
||||
"cjs": "ascjs --no-default esm cjs",
|
||||
"rollup:min": "rollup --config rollup/min.config.js",
|
||||
@@ -27,11 +27,11 @@
|
||||
"@rollup/plugin-terser": "^0.4.3",
|
||||
"ascjs": "^5.0.1",
|
||||
"c8": "^7.14.0",
|
||||
"eslint": "^8.41.0",
|
||||
"eslint": "^8.42.0",
|
||||
"linkedom": "^0.14.26",
|
||||
"rollup": "^3.23.0",
|
||||
"static-handler": "^0.3.2",
|
||||
"typescript": "^5.0.4"
|
||||
"rollup": "^3.23.1",
|
||||
"static-handler": "^0.4.0",
|
||||
"typescript": "^5.1.3"
|
||||
},
|
||||
"module": "./esm/index.js",
|
||||
"type": "module",
|
||||
@@ -48,6 +48,6 @@
|
||||
"basic-devtools": "^0.1.6"
|
||||
},
|
||||
"worker": {
|
||||
"blob": "sha256-gI4kK2AXlU8ZeNni68iQv7KcVZlHjloKCe2H3Ah7ePE="
|
||||
"blob": "sha256-kYwW0+fdul6LFbjoFeqku+pa9ARFxRtfmeM6zF53zLo="
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ const createRuntimes = () => {
|
||||
// generate the output to append at the end of the file
|
||||
const output = [];
|
||||
for (const runtime of runtimes)
|
||||
output.push(`import ${runtime} from './runtime/${runtime}.js';`);
|
||||
output.push(`import ${runtime} from "./runtime/${runtime}.js";`);
|
||||
output.push(
|
||||
`for (const runtime of [${runtimes.join(", ")}]) register(runtime);`,
|
||||
);
|
||||
|
||||
@@ -20,7 +20,7 @@ for (const file of readdirSync(WORKERS_DIR)) {
|
||||
hash.update(js);
|
||||
const json = require(PACKAGE_JSON);
|
||||
json.worker = { blob: "sha256-" + hash.digest("base64") };
|
||||
writeFileSync(PACKAGE_JSON, JSON.stringify(json, null, " "));
|
||||
writeFileSync(PACKAGE_JSON, JSON.stringify(json, null, " ") + "\n");
|
||||
writeFileSync(
|
||||
join(WORKERS_DIR, "xworker.js"),
|
||||
`/* c8 ignore next */\nexport default () => new Worker(URL.createObjectURL(new Blob([${js}],{type:'application/javascript'})),{type:'module'});`,
|
||||
|
||||
3
pyscript.core/types/fetch-utils.d.ts
vendored
3
pyscript.core/types/fetch-utils.d.ts
vendored
@@ -1,3 +0,0 @@
|
||||
export function getBuffer(response: Response): Promise<ArrayBuffer>;
|
||||
export function getJSON(response: Response): Promise<any>;
|
||||
export function getText(response: Response): Promise<string>;
|
||||
5
pyscript.core/types/index.d.ts
vendored
5
pyscript.core/types/index.d.ts
vendored
@@ -1,5 +0,0 @@
|
||||
export { registerPlugin } from "./plugins.js";
|
||||
export const XWorker: (
|
||||
url: string,
|
||||
options?: import("./worker/class.js").WorkerOptions,
|
||||
) => Worker;
|
||||
2
pyscript.core/types/loader.d.ts
vendored
2
pyscript.core/types/loader.d.ts
vendored
@@ -1,2 +0,0 @@
|
||||
export function getRuntime(id: string, config?: string): Promise<any>;
|
||||
export function getRuntimeID(type: string, version?: string): string;
|
||||
61
pyscript.core/types/plugins.d.ts
vendored
61
pyscript.core/types/plugins.d.ts
vendored
@@ -1,61 +0,0 @@
|
||||
export const PLUGINS_SELECTORS: any[];
|
||||
export function handlePlugin(node: Element): void;
|
||||
export function registerPlugin(name: string, options: PluginOptions): void;
|
||||
/**
|
||||
* plugin configuration
|
||||
*/
|
||||
export type Runtime = {
|
||||
/**
|
||||
* the runtime type
|
||||
*/
|
||||
type: string;
|
||||
/**
|
||||
* the bootstrapped runtime
|
||||
*/
|
||||
runtime: object;
|
||||
/**
|
||||
* an XWorker constructor that defaults to same runtime on the Worker.
|
||||
*/
|
||||
XWorker: (url: string, options?: object) => Worker;
|
||||
/**
|
||||
* a cloned config used to bootstrap the runtime
|
||||
*/
|
||||
config: object;
|
||||
/**
|
||||
* an utility to run code within the runtime
|
||||
*/
|
||||
run: (code: string) => any;
|
||||
/**
|
||||
* an utility to run code asynchronously within the runtime
|
||||
*/
|
||||
runAsync: (code: string) => Promise<any>;
|
||||
/**
|
||||
* an utility to write a file in the virtual FS, if available
|
||||
*/
|
||||
writeFile: (path: string, data: ArrayBuffer) => void;
|
||||
};
|
||||
/**
|
||||
* plugin configuration
|
||||
*/
|
||||
export type PluginOptions = {
|
||||
/**
|
||||
* the runtime/interpreter type to receive
|
||||
*/
|
||||
type: string;
|
||||
/**
|
||||
* the optional runtime version to use
|
||||
*/
|
||||
version?: string;
|
||||
/**
|
||||
* the optional config to use within such runtime
|
||||
*/
|
||||
config?: string;
|
||||
/**
|
||||
* the optional environment to use
|
||||
*/
|
||||
env?: string;
|
||||
/**
|
||||
* the callback that will be invoked once
|
||||
*/
|
||||
onRuntimeReady: (node: Element, runtime: Runtime) => void;
|
||||
};
|
||||
14
pyscript.core/types/runtime/_utils.d.ts
vendored
14
pyscript.core/types/runtime/_utils.d.ts
vendored
@@ -1,14 +0,0 @@
|
||||
export const io: WeakMap<object, any>;
|
||||
export function stdio(init: any): {
|
||||
stderr: (...args: any[]) => any;
|
||||
stdout: (...args: any[]) => any;
|
||||
get(engine: any): Promise<any>;
|
||||
};
|
||||
export function writeFile(FS: any, path: any, buffer: any): any;
|
||||
export function writeFileShim(FS: any, path: any, buffer: any): any;
|
||||
export const base: WeakMap<object, any>;
|
||||
export function fetchPaths(
|
||||
module: any,
|
||||
runtime: any,
|
||||
config_fetch: any,
|
||||
): Promise<any[]>;
|
||||
28
pyscript.core/types/runtime/micropython.d.ts
vendored
28
pyscript.core/types/runtime/micropython.d.ts
vendored
@@ -1,28 +0,0 @@
|
||||
declare namespace _default {
|
||||
const type: string[];
|
||||
function module(): string;
|
||||
function engine(
|
||||
{
|
||||
loadMicroPython,
|
||||
}: {
|
||||
loadMicroPython: any;
|
||||
},
|
||||
config: any,
|
||||
url: any,
|
||||
): Promise<any>;
|
||||
function run(runtime: any, code: any): any;
|
||||
function runAsync(runtime: any, code: any): any;
|
||||
function runEvent(runtime: any, code: any, key: any): any;
|
||||
function runWorker(runtime: any, code: any, xworker: any): any;
|
||||
function runWorkerAsync(runtime: any, code: any, xworker: any): any;
|
||||
function writeFile(
|
||||
{
|
||||
FS,
|
||||
}: {
|
||||
FS: any;
|
||||
},
|
||||
path: any,
|
||||
buffer: any,
|
||||
): any;
|
||||
}
|
||||
export default _default;
|
||||
27
pyscript.core/types/runtime/pyodide.d.ts
vendored
27
pyscript.core/types/runtime/pyodide.d.ts
vendored
@@ -1,27 +0,0 @@
|
||||
declare namespace _default {
|
||||
const type: string[];
|
||||
function module(version?: string): string;
|
||||
function engine(
|
||||
{
|
||||
loadPyodide,
|
||||
}: {
|
||||
loadPyodide: any;
|
||||
},
|
||||
config: any,
|
||||
): Promise<any>;
|
||||
function run(runtime: any, code: any): any;
|
||||
function runAsync(runtime: any, code: any): any;
|
||||
function runEvent(runtime: any, code: any, key: any): any;
|
||||
function runWorker(runtime: any, code: any, xworker: any): any;
|
||||
function runWorkerAsync(runtime: any, code: any, xworker: any): any;
|
||||
function writeFile(
|
||||
{
|
||||
FS,
|
||||
}: {
|
||||
FS: any;
|
||||
},
|
||||
path: any,
|
||||
buffer: any,
|
||||
): any;
|
||||
}
|
||||
export default _default;
|
||||
21
pyscript.core/types/runtime/ruby.d.ts
vendored
21
pyscript.core/types/runtime/ruby.d.ts
vendored
@@ -1,21 +0,0 @@
|
||||
declare namespace _default {
|
||||
const experimental: boolean;
|
||||
const type: string[];
|
||||
function module(version?: string): string;
|
||||
function engine(
|
||||
{
|
||||
DefaultRubyVM,
|
||||
}: {
|
||||
DefaultRubyVM: any;
|
||||
},
|
||||
config: any,
|
||||
url: any,
|
||||
): Promise<any>;
|
||||
function run(runtime: any, code: any): any;
|
||||
function runAsync(runtime: any, code: any): any;
|
||||
function runEvent(runtime: any, code: any, key: any): any;
|
||||
function runWorker(runtime: any, code: any, xworker: any): any;
|
||||
function runWorkerAsync(runtime: any, code: any, xworker: any): any;
|
||||
function writeFile(): never;
|
||||
}
|
||||
export default _default;
|
||||
35
pyscript.core/types/runtime/wasmoon.d.ts
vendored
35
pyscript.core/types/runtime/wasmoon.d.ts
vendored
@@ -1,35 +0,0 @@
|
||||
declare namespace _default {
|
||||
const type: string[];
|
||||
function module(version?: string): string;
|
||||
function engine(
|
||||
{
|
||||
LuaFactory,
|
||||
LuaLibraries,
|
||||
}: {
|
||||
LuaFactory: any;
|
||||
LuaLibraries: any;
|
||||
},
|
||||
config: any,
|
||||
): Promise<any>;
|
||||
function run(runtime: any, code: any): any;
|
||||
function runAsync(runtime: any, code: any): any;
|
||||
function runEvent(runtime: any, code: any, key: any): any;
|
||||
function runWorker(runtime: any, code: any, xworker: any): any;
|
||||
function runWorkerAsync(runtime: any, code: any, xworker: any): any;
|
||||
function writeFile(
|
||||
{
|
||||
cmodule: {
|
||||
module: { FS },
|
||||
},
|
||||
}: {
|
||||
cmodule: {
|
||||
module: {
|
||||
FS: any;
|
||||
};
|
||||
};
|
||||
},
|
||||
path: any,
|
||||
buffer: any,
|
||||
): any;
|
||||
}
|
||||
export default _default;
|
||||
9
pyscript.core/types/runtimes.d.ts
vendored
9
pyscript.core/types/runtimes.d.ts
vendored
@@ -1,9 +0,0 @@
|
||||
/** @type {Map<string, object>} */
|
||||
export const registry: Map<string, object>;
|
||||
/** @type {Map<string, object>} */
|
||||
export const configs: Map<string, object>;
|
||||
/** @type {string[]} */
|
||||
export const selectors: string[];
|
||||
/** @type {string[]} */
|
||||
export const prefixes: string[];
|
||||
export const runtime: Map<any, any>;
|
||||
9
pyscript.core/types/script-handler.d.ts
vendored
9
pyscript.core/types/script-handler.d.ts
vendored
@@ -1,9 +0,0 @@
|
||||
export const runtimes: Map<any, any>;
|
||||
export function getDetails(
|
||||
type: any,
|
||||
id: any,
|
||||
name: any,
|
||||
version: any,
|
||||
config: any,
|
||||
): any;
|
||||
export function handle(script: HTMLScriptElement): Promise<void>;
|
||||
1
pyscript.core/types/toml.d.ts
vendored
1
pyscript.core/types/toml.d.ts
vendored
@@ -1 +0,0 @@
|
||||
export function parse(text: string): object;
|
||||
37
pyscript.core/types/utils.d.ts
vendored
37
pyscript.core/types/utils.d.ts
vendored
@@ -1,37 +0,0 @@
|
||||
export const isArray: (arg: any) => arg is any[];
|
||||
export const assign: {
|
||||
<T extends {}, U>(target: T, source: U): T & U;
|
||||
<T_1 extends {}, U_1, V>(
|
||||
target: T_1,
|
||||
source1: U_1,
|
||||
source2: V,
|
||||
): T_1 & U_1 & V;
|
||||
<T_2 extends {}, U_2, V_1, W>(
|
||||
target: T_2,
|
||||
source1: U_2,
|
||||
source2: V_1,
|
||||
source3: W,
|
||||
): T_2 & U_2 & V_1 & W;
|
||||
(target: object, ...sources: any[]): any;
|
||||
};
|
||||
export const create: {
|
||||
(o: object): any;
|
||||
(o: object, properties: PropertyDescriptorMap & ThisType<any>): any;
|
||||
};
|
||||
export const defineProperty: <T>(
|
||||
o: T,
|
||||
p: PropertyKey,
|
||||
attributes: PropertyDescriptor & ThisType<any>,
|
||||
) => T;
|
||||
export const all: {
|
||||
<T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>[]>;
|
||||
<T_1 extends [] | readonly unknown[]>(
|
||||
values: T_1,
|
||||
): Promise<{ -readonly [P in keyof T_1]: Awaited<T_1[P]> }>;
|
||||
};
|
||||
export const resolve: {
|
||||
(): Promise<void>;
|
||||
<T>(value: T): Promise<Awaited<T>>;
|
||||
<T_1>(value: T_1 | PromiseLike<T_1>): Promise<Awaited<T_1>>;
|
||||
};
|
||||
export function absoluteURL(path: any, base?: string): string;
|
||||
21
pyscript.core/types/worker/class.d.ts
vendored
21
pyscript.core/types/worker/class.d.ts
vendored
@@ -1,21 +0,0 @@
|
||||
declare function _default(
|
||||
...args: any[]
|
||||
): (url: string, options?: WorkerOptions) => Worker;
|
||||
export default _default;
|
||||
/**
|
||||
* plugin configuration
|
||||
*/
|
||||
export type WorkerOptions = {
|
||||
/**
|
||||
* the runtime/interpreter type to use
|
||||
*/
|
||||
type: string;
|
||||
/**
|
||||
* the optional runtime version to use
|
||||
*/
|
||||
version?: string;
|
||||
/**
|
||||
* the optional config to use within such runtime
|
||||
*/
|
||||
config?: string;
|
||||
};
|
||||
2
pyscript.core/types/worker/xworker.d.ts
vendored
2
pyscript.core/types/worker/xworker.d.ts
vendored
@@ -1,2 +0,0 @@
|
||||
declare function _default(): Worker;
|
||||
export default _default;
|
||||
Reference in New Issue
Block a user