mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-21 19:25:35 -05:00
PyScript Core Documentation (#1560)
This commit is contained in:
committed by
GitHub
parent
bf6470c046
commit
9121071ba3
@@ -46,7 +46,7 @@ export const handleCustomType = (node) => {
|
||||
version,
|
||||
config,
|
||||
env,
|
||||
onRuntimeReady,
|
||||
onInterpreterReady,
|
||||
} = options;
|
||||
const name = getRuntimeID(runtime, version);
|
||||
const id = env || `${name}${config ? `|${config}` : ""}`;
|
||||
@@ -67,7 +67,7 @@ export const handleCustomType = (node) => {
|
||||
onAfterRunAsync,
|
||||
} = options;
|
||||
|
||||
const hooks = new Hook(options);
|
||||
const hooks = new Hook(interpreter, options);
|
||||
|
||||
const XWorker = function XWorker(...args) {
|
||||
return Worker.apply(hooks, args);
|
||||
@@ -121,7 +121,7 @@ export const handleCustomType = (node) => {
|
||||
|
||||
resolve(resolved);
|
||||
|
||||
onRuntimeReady?.(resolved, node);
|
||||
onInterpreterReady?.(resolved, node);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -134,17 +134,17 @@ export const handleCustomType = (node) => {
|
||||
const registry = new Map();
|
||||
|
||||
/**
|
||||
* @typedef {Object} PluginOptions custom configuration
|
||||
* @typedef {Object} CustomOptions custom configuration
|
||||
* @prop {'pyodide' | 'micropython' | 'wasmoon' | 'ruby-wasm-wasi'} interpreter the interpreter to use
|
||||
* @prop {string} [version] the optional interpreter version to use
|
||||
* @prop {string} [config] the optional config to use within such interpreter
|
||||
* @prop {(environment: object, node: Element) => void} [onRuntimeReady] the callback that will be invoked once
|
||||
* @prop {(environment: object, node: Element) => void} [onInterpreterReady] the callback that will be invoked once
|
||||
*/
|
||||
|
||||
/**
|
||||
* Allows custom types and components on the page to receive interpreters to execute any code
|
||||
* @param {string} type the unique `<script type="...">` identifier
|
||||
* @param {PluginOptions} options the custom type configuration
|
||||
* @param {CustomOptions} options the custom type configuration
|
||||
*/
|
||||
export const define = (type, options) => {
|
||||
if (defaultRegistry.has(type) || registry.has(type))
|
||||
|
||||
Reference in New Issue
Block a user