mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-21 11:15:36 -05:00
Prepared for the first publish (#1620)
This commit is contained in:
committed by
GitHub
parent
8a01a56e51
commit
c96f5912df
@@ -47,7 +47,7 @@ repos:
|
|||||||
rev: "v3.0.0-alpha.6"
|
rev: "v3.0.0-alpha.6"
|
||||||
hooks:
|
hooks:
|
||||||
- id: prettier
|
- id: prettier
|
||||||
exclude: pyscript\.next/test|pyscript\.next/core.*
|
exclude: pyscript\.next/test|pyscript\.next/core.*|pyscript\.next/types/
|
||||||
args: [--tab-width, "4"]
|
args: [--tab-width, "4"]
|
||||||
|
|
||||||
- repo: https://github.com/pre-commit/mirrors-eslint
|
- repo: https://github.com/pre-commit/mirrors-eslint
|
||||||
|
|||||||
3
pyscript.next/README.md
Normal file
3
pyscript.next/README.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# PyScript Next
|
||||||
|
|
||||||
|
Work in progress @ https://github.com/pyscript/pyscript/tree/next
|
||||||
@@ -20,7 +20,8 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"server": "npx static-handler --cors --coep --coop --corp .",
|
"server": "npx static-handler --cors --coep --coop --corp .",
|
||||||
"build": "rollup --config rollup/core.config.js && rollup --config rollup/core-css.config.js"
|
"build": "rollup --config rollup/core.config.js && rollup --config rollup/core-css.config.js && npm run ts",
|
||||||
|
"ts": "tsc -p ."
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "Anaconda Inc.",
|
"author": "Anaconda Inc.",
|
||||||
|
|||||||
@@ -193,6 +193,12 @@ class PyScriptElement extends HTMLElement {
|
|||||||
|
|
||||||
customElements.define("py-script", PyScriptElement);
|
customElements.define("py-script", PyScriptElement);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A `Worker` facade able to bootstrap on the worker thread only a PyScript module.
|
||||||
|
* @param {string} file the python file to run ina worker.
|
||||||
|
* @param {{config?: string | object, async?: boolean}} [options] optional configuration for the worker.
|
||||||
|
* @returns {Worker & {sync: ProxyHandler<object>}}
|
||||||
|
*/
|
||||||
export function PyWorker(file, options) {
|
export function PyWorker(file, options) {
|
||||||
// this propagates pyscript worker hooks without needing a pyscript
|
// this propagates pyscript worker hooks without needing a pyscript
|
||||||
// bootstrap + it passes arguments and enforces `pyodide`
|
// bootstrap + it passes arguments and enforces `pyodide`
|
||||||
|
|||||||
12
pyscript.next/tsconfig.json
Normal file
12
pyscript.next/tsconfig.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"module": "ES2022",
|
||||||
|
"target": "ES2022",
|
||||||
|
"moduleResolution": "Classic",
|
||||||
|
"allowJs": true,
|
||||||
|
"declaration": true,
|
||||||
|
"emitDeclarationOnly": true,
|
||||||
|
"declarationDir": "types"
|
||||||
|
},
|
||||||
|
"include": ["src/core.js"]
|
||||||
|
}
|
||||||
28
pyscript.next/types/core.d.ts
vendored
Normal file
28
pyscript.next/types/core.d.ts
vendored
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
/**
|
||||||
|
* A `Worker` facade able to bootstrap on the worker thread only a PyScript module.
|
||||||
|
* @param {string} file the python file to run ina worker.
|
||||||
|
* @param {{config?: string | object, async?: boolean}} [options] optional configuration for the worker.
|
||||||
|
* @returns {Worker & {sync: ProxyHandler<object>}}
|
||||||
|
*/
|
||||||
|
export function PyWorker(
|
||||||
|
file: string,
|
||||||
|
options?: {
|
||||||
|
config?: string | object;
|
||||||
|
async?: boolean;
|
||||||
|
},
|
||||||
|
): Worker & {
|
||||||
|
sync: ProxyHandler<object>;
|
||||||
|
};
|
||||||
|
export namespace hooks {
|
||||||
|
let onBeforeRun: Set<Function>;
|
||||||
|
let onBeforeRunAync: Set<Function>;
|
||||||
|
let onAfterRun: Set<Function>;
|
||||||
|
let onAfterRunAsync: Set<Function>;
|
||||||
|
let onInterpreterReady: Set<Function>;
|
||||||
|
let codeBeforeRunWorker: Set<string>;
|
||||||
|
let codeBeforeRunWorkerAsync: Set<string>;
|
||||||
|
let codeAfterRunWorker: Set<string>;
|
||||||
|
let codeAfterRunWorkerAsync: Set<string>;
|
||||||
|
}
|
||||||
|
declare let config: any;
|
||||||
|
export {};
|
||||||
32
pyscript.next/types/exceptions.d.ts
vendored
Normal file
32
pyscript.next/types/exceptions.d.ts
vendored
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
export function _createAlertBanner(
|
||||||
|
message: any,
|
||||||
|
level: any,
|
||||||
|
messageType?: string,
|
||||||
|
logMessage?: boolean,
|
||||||
|
): void;
|
||||||
|
export namespace ErrorCode {
|
||||||
|
let GENERIC: string;
|
||||||
|
let FETCH_ERROR: string;
|
||||||
|
let FETCH_NAME_ERROR: string;
|
||||||
|
let FETCH_UNAUTHORIZED_ERROR: string;
|
||||||
|
let FETCH_FORBIDDEN_ERROR: string;
|
||||||
|
let FETCH_NOT_FOUND_ERROR: string;
|
||||||
|
let FETCH_SERVER_ERROR: string;
|
||||||
|
let FETCH_UNAVAILABLE_ERROR: string;
|
||||||
|
let BAD_CONFIG: string;
|
||||||
|
let MICROPIP_INSTALL_ERROR: string;
|
||||||
|
let BAD_PLUGIN_FILE_EXTENSION: string;
|
||||||
|
let NO_DEFAULT_EXPORT: string;
|
||||||
|
let TOP_LEVEL_AWAIT: string;
|
||||||
|
}
|
||||||
|
export class UserError extends Error {
|
||||||
|
constructor(errorCode: any, message?: string, messageType?: string);
|
||||||
|
errorCode: any;
|
||||||
|
messageType: string;
|
||||||
|
}
|
||||||
|
export class FetchError extends UserError {
|
||||||
|
constructor(errorCode: any, message: any);
|
||||||
|
}
|
||||||
|
export class InstallError extends UserError {
|
||||||
|
constructor(errorCode: any, message: any);
|
||||||
|
}
|
||||||
10
pyscript.next/types/fetch.d.ts
vendored
Normal file
10
pyscript.next/types/fetch.d.ts
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
/**
|
||||||
|
* This is a fetch wrapper that handles any non 200 responses and throws a
|
||||||
|
* FetchError with the right ErrorCode. This is useful because our FetchError
|
||||||
|
* will automatically create an alert banner.
|
||||||
|
*
|
||||||
|
* @param {string} url - URL to fetch
|
||||||
|
* @param {Request} [options] - options to pass to fetch
|
||||||
|
* @returns {Promise<Response>}
|
||||||
|
*/
|
||||||
|
export function robustFetch(url: string, options?: Request): Promise<Response>;
|
||||||
Reference in New Issue
Block a user