API Reference
Modules
- ValidationUtils
Validation Utilities for Nagini
Centralized parameter validation functions used across all components to ensure consistent error handling and type checking.
- ValidationUtils
Validation Utilities for Nagini
Centralized parameter validation functions used across all components to ensure consistent error handling and type checking.
Classes
- BrythonManager
BrythonManager – Minimal backend for Nagini focused on turtle graphics. Provides the same public surface as PyodideManager but runs directly in the main thread with Brython. Input(), packages, and filesystem are NOT supported for now.
- PyodideFileLoader
PyodideFileLoader class for loading files into Pyodide filesystem
- PyodideManagerFS
Static class containing filesystem functionality for PyodideManager
- PyodideManagerInput
Static class containing input handling functionality for PyodideManager
- PyodideManager
Functions
- createBlobWorkerUrl(workerUrl) ⇒
Promise.<string> Create a blob worker URL from a bundled worker script
- createBlobWorker(workerUrl) ⇒
Promise.<Worker> Create a Worker instance using blob URL pattern
- revokeBlobUrl(blobUrl)
Cleanup blob URL to prevent memory leaks
- executeAsync()
Execute Python code with Brython, capturing stdout, stderr and missive. Renamed from brython-executor.js
- createBlobWorkerUrl(workerUrl) ⇒
Promise.<string> Create a blob worker URL from a bundled worker script
- createBlobWorker(workerUrl) ⇒
Promise.<Worker> Create a Worker instance using blob URL pattern
- revokeBlobUrl(blobUrl)
Cleanup blob URL to prevent memory leaks
Typedefs
- FileToLoad :
Object - LoadOptions :
Object - PyodideAPI :
Object - FSOperation :
'writeFile'|'readFile'|'mkdir'|'exists'|'listdir' - FSOperationParams :
Object - FSOperationResult :
Object - ExecutionResult :
Object - FileToLoad :
Object - WorkerMessage :
Object - ExecutionResult :
Object
ValidationUtils
Validation Utilities for Nagini
Centralized parameter validation functions used across all components to ensure consistent error handling and type checking.
- ValidationUtils
- static
- .ValidationUtils
- .validateArray(value, paramName, [component])
- .validateString(value, paramName, [component], [allowEmpty])
- .validateBoolean(value, paramName, [component])
- .validateFunction(value, paramName, [component])
- .validateObject(value, paramName, [component])
- .validateWorker(worker, [component])
- .validatePyodide(pyodide, [component])
- .validateFilesToLoad(filesToLoad, [component])
- .validatePackages(packages, [component])
- .validateNamespace(namespace, [component])
- .validateExecutionParams(filename, code, [namespace], [component])
- .checkDangerousPatterns(code) ⇒
Array.<string> - .validateBackend(backend, [component])
- .validateArray(value, paramName, [component])
- .validateString(value, paramName, [component], [allowEmpty])
- .validateBoolean(value, paramName, [component])
- .validateFunction(value, paramName, [component])
- .validateObject(value, paramName, [component])
- .validateWorker(worker, [component])
- .validatePyodide(pyodide, [component])
- .validateFilesToLoad(filesToLoad, [component])
- .validatePackages(packages, [component])
- .validateNamespace(namespace, [component])
- .validateExecutionParams(filename, code, [namespace], [component])
- .checkDangerousPatterns(code) ⇒
Array.<string> - .validateBackend(backend, [component])
- .ValidationUtils
- .validateArray(value, paramName, [component])
- .validateString(value, paramName, [component], [allowEmpty])
- .validateBoolean(value, paramName, [component])
- .validateFunction(value, paramName, [component])
- .validateObject(value, paramName, [component])
- .validateWorker(worker, [component])
- .validatePyodide(pyodide, [component])
- .validateFilesToLoad(filesToLoad, [component])
- .validatePackages(packages, [component])
- .validateNamespace(namespace, [component])
- .validateExecutionParams(filename, code, [namespace], [component])
- .checkDangerousPatterns(code) ⇒
Array.<string> - .validateBackend(backend, [component])
- .validateArray(value, paramName, [component])
- .validateString(value, paramName, [component], [allowEmpty])
- .validateBoolean(value, paramName, [component])
- .validateFunction(value, paramName, [component])
- .validateObject(value, paramName, [component])
- .validateWorker(worker, [component])
- .validatePyodide(pyodide, [component])
- .validateFilesToLoad(filesToLoad, [component])
- .validatePackages(packages, [component])
- .validateNamespace(namespace, [component])
- .validateExecutionParams(filename, code, [namespace], [component])
- .checkDangerousPatterns(code) ⇒
Array.<string> - .validateBackend(backend, [component])
- .ValidationUtils
- inner
- ~ValidationError :
Object - ~ValidationError :
Object
- ~ValidationError :
- static
ValidationUtils.ValidationUtils
General validation utility class with static methods for parameter validation
Kind: static class of ValidationUtils
- .ValidationUtils
- .validateArray(value, paramName, [component])
- .validateString(value, paramName, [component], [allowEmpty])
- .validateBoolean(value, paramName, [component])
- .validateFunction(value, paramName, [component])
- .validateObject(value, paramName, [component])
- .validateWorker(worker, [component])
- .validatePyodide(pyodide, [component])
- .validateFilesToLoad(filesToLoad, [component])
- .validatePackages(packages, [component])
- .validateNamespace(namespace, [component])
- .validateExecutionParams(filename, code, [namespace], [component])
- .checkDangerousPatterns(code) ⇒
Array.<string> - .validateBackend(backend, [component])
- .validateArray(value, paramName, [component])
- .validateString(value, paramName, [component], [allowEmpty])
- .validateBoolean(value, paramName, [component])
- .validateFunction(value, paramName, [component])
- .validateObject(value, paramName, [component])
- .validateWorker(worker, [component])
- .validatePyodide(pyodide, [component])
- .validateFilesToLoad(filesToLoad, [component])
- .validatePackages(packages, [component])
- .validateNamespace(namespace, [component])
- .validateExecutionParams(filename, code, [namespace], [component])
- .checkDangerousPatterns(code) ⇒
Array.<string> - .validateBackend(backend, [component])
ValidationUtils.validateArray(value, paramName, [component])
Validate that a value is an array
Kind: static method of ValidationUtils
Throws:
ErrorIf value is not an array
| Param | Type | Default | Description |
|---|---|---|---|
| value | any |
Value to validate |
|
| paramName | string |
Parameter name for error messages |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateString(value, paramName, [component], [allowEmpty])
Validate that a value is a string
Kind: static method of ValidationUtils
Throws:
ErrorIf value is not a string or is empty when not allowed
| Param | Type | Default | Description |
|---|---|---|---|
| value | any |
Value to validate |
|
| paramName | string |
Parameter name for error messages |
|
| [component] | string |
"Component" |
Component name for error context |
| [allowEmpty] | boolean |
false |
Whether to allow empty strings |
ValidationUtils.validateBoolean(value, paramName, [component])
Validate that a value is a boolean
Kind: static method of ValidationUtils
Throws:
ErrorIf value is not a boolean
| Param | Type | Default | Description |
|---|---|---|---|
| value | any |
Value to validate |
|
| paramName | string |
Parameter name for error messages |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateFunction(value, paramName, [component])
Validate that a value is a function
Kind: static method of ValidationUtils
Throws:
ErrorIf value is not a function
| Param | Type | Default | Description |
|---|---|---|---|
| value | any |
Value to validate |
|
| paramName | string |
Parameter name for error messages |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateObject(value, paramName, [component])
Validate that a value is an object (not null, not array)
Kind: static method of ValidationUtils
Throws:
ErrorIf value is not a plain object
| Param | Type | Default | Description |
|---|---|---|---|
| value | any |
Value to validate |
|
| paramName | string |
Parameter name for error messages |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateWorker(worker, [component])
Validate Worker instance
Kind: static method of ValidationUtils
Throws:
ErrorIf worker is not valid
| Param | Type | Default | Description |
|---|---|---|---|
| worker | any |
Worker to validate |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validatePyodide(pyodide, [component])
Validate Pyodide instance
Kind: static method of ValidationUtils
Throws:
ErrorIf pyodide is not valid
| Param | Type | Default | Description |
|---|---|---|---|
| pyodide | any |
Pyodide instance to validate |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateFilesToLoad(filesToLoad, [component])
Validate file objects array for FileLoader
Kind: static method of ValidationUtils
Throws:
ErrorIf any file object is invalid
| Param | Type | Default | Description |
|---|---|---|---|
| filesToLoad | Array |
Array of file objects |
|
| [component] | string |
"PyodideFileLoader" |
Component name for error context |
ValidationUtils.validatePackages(packages, [component])
Validate packages array
Kind: static method of ValidationUtils
Throws:
ErrorIf packages array is invalid
| Param | Type | Default | Description |
|---|---|---|---|
| packages | Array |
Array of package names |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateNamespace(namespace, [component])
Validate namespace object (optional parameter)
Kind: static method of ValidationUtils
Throws:
ErrorIf namespace is provided but invalid
| Param | Type | Default | Description |
|---|---|---|---|
| namespace | any |
Namespace to validate |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateExecutionParams(filename, code, [namespace], [component])
Validate execution parameters
Kind: static method of ValidationUtils
Throws:
ErrorIf any parameter is invalid
| Param | Type | Default | Description |
|---|---|---|---|
| filename | string |
Filename for execution |
|
| code | string |
Python code to execute |
|
| [namespace] | any |
Optional namespace |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.checkDangerousPatterns(code) ⇒ Array.<string>
Check for potentially dangerous Python code patterns
Kind: static method of ValidationUtils
Returns: Array.<string> -
Array of dangerous patterns found
| Param | Type | Description |
|---|---|---|
| code | string |
Python code to check |
ValidationUtils.validateBackend(backend, [component])
Validate backend parameter (must be 'pyodide' or <?>)
Kind: static method of ValidationUtils
Throws:
ErrorIf backend is not valid
| Param | Type | Default | Description |
|---|---|---|---|
| backend | string |
Backend to validate |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateArray(value, paramName, [component])
Validate that a value is an array
Kind: static method of ValidationUtils
Throws:
ErrorIf value is not an array
| Param | Type | Default | Description |
|---|---|---|---|
| value | any |
Value to validate |
|
| paramName | string |
Parameter name for error messages |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateString(value, paramName, [component], [allowEmpty])
Validate that a value is a string
Kind: static method of ValidationUtils
Throws:
ErrorIf value is not a string or is empty when not allowed
| Param | Type | Default | Description |
|---|---|---|---|
| value | any |
Value to validate |
|
| paramName | string |
Parameter name for error messages |
|
| [component] | string |
"Component" |
Component name for error context |
| [allowEmpty] | boolean |
false |
Whether to allow empty strings |
ValidationUtils.validateBoolean(value, paramName, [component])
Validate that a value is a boolean
Kind: static method of ValidationUtils
Throws:
ErrorIf value is not a boolean
| Param | Type | Default | Description |
|---|---|---|---|
| value | any |
Value to validate |
|
| paramName | string |
Parameter name for error messages |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateFunction(value, paramName, [component])
Validate that a value is a function
Kind: static method of ValidationUtils
Throws:
ErrorIf value is not a function
| Param | Type | Default | Description |
|---|---|---|---|
| value | any |
Value to validate |
|
| paramName | string |
Parameter name for error messages |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateObject(value, paramName, [component])
Validate that a value is an object (not null, not array)
Kind: static method of ValidationUtils
Throws:
ErrorIf value is not a plain object
| Param | Type | Default | Description |
|---|---|---|---|
| value | any |
Value to validate |
|
| paramName | string |
Parameter name for error messages |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateWorker(worker, [component])
Validate Worker instance
Kind: static method of ValidationUtils
Throws:
ErrorIf worker is not valid
| Param | Type | Default | Description |
|---|---|---|---|
| worker | any |
Worker to validate |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validatePyodide(pyodide, [component])
Validate Pyodide instance
Kind: static method of ValidationUtils
Throws:
ErrorIf pyodide is not valid
| Param | Type | Default | Description |
|---|---|---|---|
| pyodide | any |
Pyodide instance to validate |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateFilesToLoad(filesToLoad, [component])
Validate file objects array for FileLoader
Kind: static method of ValidationUtils
Throws:
ErrorIf any file object is invalid
| Param | Type | Default | Description |
|---|---|---|---|
| filesToLoad | Array |
Array of file objects |
|
| [component] | string |
"PyodideFileLoader" |
Component name for error context |
ValidationUtils.validatePackages(packages, [component])
Validate packages array
Kind: static method of ValidationUtils
Throws:
ErrorIf packages array is invalid
| Param | Type | Default | Description |
|---|---|---|---|
| packages | Array |
Array of package names |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateNamespace(namespace, [component])
Validate namespace object (optional parameter)
Kind: static method of ValidationUtils
Throws:
ErrorIf namespace is provided but invalid
| Param | Type | Default | Description |
|---|---|---|---|
| namespace | any |
Namespace to validate |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateExecutionParams(filename, code, [namespace], [component])
Validate execution parameters
Kind: static method of ValidationUtils
Throws:
ErrorIf any parameter is invalid
| Param | Type | Default | Description |
|---|---|---|---|
| filename | string |
Filename for execution |
|
| code | string |
Python code to execute |
|
| [namespace] | any |
Optional namespace |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.checkDangerousPatterns(code) ⇒ Array.<string>
Check for potentially dangerous Python code patterns
Kind: static method of ValidationUtils
Returns: Array.<string> -
Array of dangerous patterns found
| Param | Type | Description |
|---|---|---|
| code | string |
Python code to check |
ValidationUtils.validateBackend(backend, [component])
Validate backend parameter (must be 'pyodide' or <?>)
Kind: static method of ValidationUtils
Throws:
ErrorIf backend is not valid
| Param | Type | Default | Description |
|---|---|---|---|
| backend | string |
Backend to validate |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.ValidationUtils
General validation utility class with static methods for parameter validation
Kind: static class of ValidationUtils
- .ValidationUtils
- .validateArray(value, paramName, [component])
- .validateString(value, paramName, [component], [allowEmpty])
- .validateBoolean(value, paramName, [component])
- .validateFunction(value, paramName, [component])
- .validateObject(value, paramName, [component])
- .validateWorker(worker, [component])
- .validatePyodide(pyodide, [component])
- .validateFilesToLoad(filesToLoad, [component])
- .validatePackages(packages, [component])
- .validateNamespace(namespace, [component])
- .validateExecutionParams(filename, code, [namespace], [component])
- .checkDangerousPatterns(code) ⇒
Array.<string> - .validateBackend(backend, [component])
- .validateArray(value, paramName, [component])
- .validateString(value, paramName, [component], [allowEmpty])
- .validateBoolean(value, paramName, [component])
- .validateFunction(value, paramName, [component])
- .validateObject(value, paramName, [component])
- .validateWorker(worker, [component])
- .validatePyodide(pyodide, [component])
- .validateFilesToLoad(filesToLoad, [component])
- .validatePackages(packages, [component])
- .validateNamespace(namespace, [component])
- .validateExecutionParams(filename, code, [namespace], [component])
- .checkDangerousPatterns(code) ⇒
Array.<string> - .validateBackend(backend, [component])
ValidationUtils.validateArray(value, paramName, [component])
Validate that a value is an array
Kind: static method of ValidationUtils
Throws:
ErrorIf value is not an array
| Param | Type | Default | Description |
|---|---|---|---|
| value | any |
Value to validate |
|
| paramName | string |
Parameter name for error messages |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateString(value, paramName, [component], [allowEmpty])
Validate that a value is a string
Kind: static method of ValidationUtils
Throws:
ErrorIf value is not a string or is empty when not allowed
| Param | Type | Default | Description |
|---|---|---|---|
| value | any |
Value to validate |
|
| paramName | string |
Parameter name for error messages |
|
| [component] | string |
"Component" |
Component name for error context |
| [allowEmpty] | boolean |
false |
Whether to allow empty strings |
ValidationUtils.validateBoolean(value, paramName, [component])
Validate that a value is a boolean
Kind: static method of ValidationUtils
Throws:
ErrorIf value is not a boolean
| Param | Type | Default | Description |
|---|---|---|---|
| value | any |
Value to validate |
|
| paramName | string |
Parameter name for error messages |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateFunction(value, paramName, [component])
Validate that a value is a function
Kind: static method of ValidationUtils
Throws:
ErrorIf value is not a function
| Param | Type | Default | Description |
|---|---|---|---|
| value | any |
Value to validate |
|
| paramName | string |
Parameter name for error messages |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateObject(value, paramName, [component])
Validate that a value is an object (not null, not array)
Kind: static method of ValidationUtils
Throws:
ErrorIf value is not a plain object
| Param | Type | Default | Description |
|---|---|---|---|
| value | any |
Value to validate |
|
| paramName | string |
Parameter name for error messages |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateWorker(worker, [component])
Validate Worker instance
Kind: static method of ValidationUtils
Throws:
ErrorIf worker is not valid
| Param | Type | Default | Description |
|---|---|---|---|
| worker | any |
Worker to validate |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validatePyodide(pyodide, [component])
Validate Pyodide instance
Kind: static method of ValidationUtils
Throws:
ErrorIf pyodide is not valid
| Param | Type | Default | Description |
|---|---|---|---|
| pyodide | any |
Pyodide instance to validate |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateFilesToLoad(filesToLoad, [component])
Validate file objects array for FileLoader
Kind: static method of ValidationUtils
Throws:
ErrorIf any file object is invalid
| Param | Type | Default | Description |
|---|---|---|---|
| filesToLoad | Array |
Array of file objects |
|
| [component] | string |
"PyodideFileLoader" |
Component name for error context |
ValidationUtils.validatePackages(packages, [component])
Validate packages array
Kind: static method of ValidationUtils
Throws:
ErrorIf packages array is invalid
| Param | Type | Default | Description |
|---|---|---|---|
| packages | Array |
Array of package names |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateNamespace(namespace, [component])
Validate namespace object (optional parameter)
Kind: static method of ValidationUtils
Throws:
ErrorIf namespace is provided but invalid
| Param | Type | Default | Description |
|---|---|---|---|
| namespace | any |
Namespace to validate |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateExecutionParams(filename, code, [namespace], [component])
Validate execution parameters
Kind: static method of ValidationUtils
Throws:
ErrorIf any parameter is invalid
| Param | Type | Default | Description |
|---|---|---|---|
| filename | string |
Filename for execution |
|
| code | string |
Python code to execute |
|
| [namespace] | any |
Optional namespace |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.checkDangerousPatterns(code) ⇒ Array.<string>
Check for potentially dangerous Python code patterns
Kind: static method of ValidationUtils
Returns: Array.<string> -
Array of dangerous patterns found
| Param | Type | Description |
|---|---|---|
| code | string |
Python code to check |
ValidationUtils.validateBackend(backend, [component])
Validate backend parameter (must be 'pyodide' or <?>)
Kind: static method of ValidationUtils
Throws:
ErrorIf backend is not valid
| Param | Type | Default | Description |
|---|---|---|---|
| backend | string |
Backend to validate |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateArray(value, paramName, [component])
Validate that a value is an array
Kind: static method of ValidationUtils
Throws:
ErrorIf value is not an array
| Param | Type | Default | Description |
|---|---|---|---|
| value | any |
Value to validate |
|
| paramName | string |
Parameter name for error messages |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateString(value, paramName, [component], [allowEmpty])
Validate that a value is a string
Kind: static method of ValidationUtils
Throws:
ErrorIf value is not a string or is empty when not allowed
| Param | Type | Default | Description |
|---|---|---|---|
| value | any |
Value to validate |
|
| paramName | string |
Parameter name for error messages |
|
| [component] | string |
"Component" |
Component name for error context |
| [allowEmpty] | boolean |
false |
Whether to allow empty strings |
ValidationUtils.validateBoolean(value, paramName, [component])
Validate that a value is a boolean
Kind: static method of ValidationUtils
Throws:
ErrorIf value is not a boolean
| Param | Type | Default | Description |
|---|---|---|---|
| value | any |
Value to validate |
|
| paramName | string |
Parameter name for error messages |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateFunction(value, paramName, [component])
Validate that a value is a function
Kind: static method of ValidationUtils
Throws:
ErrorIf value is not a function
| Param | Type | Default | Description |
|---|---|---|---|
| value | any |
Value to validate |
|
| paramName | string |
Parameter name for error messages |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateObject(value, paramName, [component])
Validate that a value is an object (not null, not array)
Kind: static method of ValidationUtils
Throws:
ErrorIf value is not a plain object
| Param | Type | Default | Description |
|---|---|---|---|
| value | any |
Value to validate |
|
| paramName | string |
Parameter name for error messages |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateWorker(worker, [component])
Validate Worker instance
Kind: static method of ValidationUtils
Throws:
ErrorIf worker is not valid
| Param | Type | Default | Description |
|---|---|---|---|
| worker | any |
Worker to validate |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validatePyodide(pyodide, [component])
Validate Pyodide instance
Kind: static method of ValidationUtils
Throws:
ErrorIf pyodide is not valid
| Param | Type | Default | Description |
|---|---|---|---|
| pyodide | any |
Pyodide instance to validate |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateFilesToLoad(filesToLoad, [component])
Validate file objects array for FileLoader
Kind: static method of ValidationUtils
Throws:
ErrorIf any file object is invalid
| Param | Type | Default | Description |
|---|---|---|---|
| filesToLoad | Array |
Array of file objects |
|
| [component] | string |
"PyodideFileLoader" |
Component name for error context |
ValidationUtils.validatePackages(packages, [component])
Validate packages array
Kind: static method of ValidationUtils
Throws:
ErrorIf packages array is invalid
| Param | Type | Default | Description |
|---|---|---|---|
| packages | Array |
Array of package names |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateNamespace(namespace, [component])
Validate namespace object (optional parameter)
Kind: static method of ValidationUtils
Throws:
ErrorIf namespace is provided but invalid
| Param | Type | Default | Description |
|---|---|---|---|
| namespace | any |
Namespace to validate |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateExecutionParams(filename, code, [namespace], [component])
Validate execution parameters
Kind: static method of ValidationUtils
Throws:
ErrorIf any parameter is invalid
| Param | Type | Default | Description |
|---|---|---|---|
| filename | string |
Filename for execution |
|
| code | string |
Python code to execute |
|
| [namespace] | any |
Optional namespace |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.checkDangerousPatterns(code) ⇒ Array.<string>
Check for potentially dangerous Python code patterns
Kind: static method of ValidationUtils
Returns: Array.<string> -
Array of dangerous patterns found
| Param | Type | Description |
|---|---|---|
| code | string |
Python code to check |
ValidationUtils.validateBackend(backend, [component])
Validate backend parameter (must be 'pyodide' or <?>)
Kind: static method of ValidationUtils
Throws:
ErrorIf backend is not valid
| Param | Type | Default | Description |
|---|---|---|---|
| backend | string |
Backend to validate |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils~ValidationError : Object
Kind: inner typedef of ValidationUtils
Properties
| Name | Type | Description |
|---|---|---|
| message | string |
Error message |
| component | string |
Component that threw the error |
| parameter | string |
Parameter that failed validation |
ValidationUtils~ValidationError : Object
Kind: inner typedef of ValidationUtils
Properties
| Name | Type | Description |
|---|---|---|
| message | string |
Error message |
| component | string |
Component that threw the error |
| parameter | string |
Parameter that failed validation |
ValidationUtils
Validation Utilities for Nagini
Centralized parameter validation functions used across all components to ensure consistent error handling and type checking.
- ValidationUtils
- static
- .ValidationUtils
- .validateArray(value, paramName, [component])
- .validateString(value, paramName, [component], [allowEmpty])
- .validateBoolean(value, paramName, [component])
- .validateFunction(value, paramName, [component])
- .validateObject(value, paramName, [component])
- .validateWorker(worker, [component])
- .validatePyodide(pyodide, [component])
- .validateFilesToLoad(filesToLoad, [component])
- .validatePackages(packages, [component])
- .validateNamespace(namespace, [component])
- .validateExecutionParams(filename, code, [namespace], [component])
- .checkDangerousPatterns(code) ⇒
Array.<string> - .validateBackend(backend, [component])
- .validateArray(value, paramName, [component])
- .validateString(value, paramName, [component], [allowEmpty])
- .validateBoolean(value, paramName, [component])
- .validateFunction(value, paramName, [component])
- .validateObject(value, paramName, [component])
- .validateWorker(worker, [component])
- .validatePyodide(pyodide, [component])
- .validateFilesToLoad(filesToLoad, [component])
- .validatePackages(packages, [component])
- .validateNamespace(namespace, [component])
- .validateExecutionParams(filename, code, [namespace], [component])
- .checkDangerousPatterns(code) ⇒
Array.<string> - .validateBackend(backend, [component])
- .ValidationUtils
- .validateArray(value, paramName, [component])
- .validateString(value, paramName, [component], [allowEmpty])
- .validateBoolean(value, paramName, [component])
- .validateFunction(value, paramName, [component])
- .validateObject(value, paramName, [component])
- .validateWorker(worker, [component])
- .validatePyodide(pyodide, [component])
- .validateFilesToLoad(filesToLoad, [component])
- .validatePackages(packages, [component])
- .validateNamespace(namespace, [component])
- .validateExecutionParams(filename, code, [namespace], [component])
- .checkDangerousPatterns(code) ⇒
Array.<string> - .validateBackend(backend, [component])
- .validateArray(value, paramName, [component])
- .validateString(value, paramName, [component], [allowEmpty])
- .validateBoolean(value, paramName, [component])
- .validateFunction(value, paramName, [component])
- .validateObject(value, paramName, [component])
- .validateWorker(worker, [component])
- .validatePyodide(pyodide, [component])
- .validateFilesToLoad(filesToLoad, [component])
- .validatePackages(packages, [component])
- .validateNamespace(namespace, [component])
- .validateExecutionParams(filename, code, [namespace], [component])
- .checkDangerousPatterns(code) ⇒
Array.<string> - .validateBackend(backend, [component])
- .ValidationUtils
- inner
- ~ValidationError :
Object - ~ValidationError :
Object
- ~ValidationError :
- static
ValidationUtils.ValidationUtils
General validation utility class with static methods for parameter validation
Kind: static class of ValidationUtils
- .ValidationUtils
- .validateArray(value, paramName, [component])
- .validateString(value, paramName, [component], [allowEmpty])
- .validateBoolean(value, paramName, [component])
- .validateFunction(value, paramName, [component])
- .validateObject(value, paramName, [component])
- .validateWorker(worker, [component])
- .validatePyodide(pyodide, [component])
- .validateFilesToLoad(filesToLoad, [component])
- .validatePackages(packages, [component])
- .validateNamespace(namespace, [component])
- .validateExecutionParams(filename, code, [namespace], [component])
- .checkDangerousPatterns(code) ⇒
Array.<string> - .validateBackend(backend, [component])
- .validateArray(value, paramName, [component])
- .validateString(value, paramName, [component], [allowEmpty])
- .validateBoolean(value, paramName, [component])
- .validateFunction(value, paramName, [component])
- .validateObject(value, paramName, [component])
- .validateWorker(worker, [component])
- .validatePyodide(pyodide, [component])
- .validateFilesToLoad(filesToLoad, [component])
- .validatePackages(packages, [component])
- .validateNamespace(namespace, [component])
- .validateExecutionParams(filename, code, [namespace], [component])
- .checkDangerousPatterns(code) ⇒
Array.<string> - .validateBackend(backend, [component])
ValidationUtils.validateArray(value, paramName, [component])
Validate that a value is an array
Kind: static method of ValidationUtils
Throws:
ErrorIf value is not an array
| Param | Type | Default | Description |
|---|---|---|---|
| value | any |
Value to validate |
|
| paramName | string |
Parameter name for error messages |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateString(value, paramName, [component], [allowEmpty])
Validate that a value is a string
Kind: static method of ValidationUtils
Throws:
ErrorIf value is not a string or is empty when not allowed
| Param | Type | Default | Description |
|---|---|---|---|
| value | any |
Value to validate |
|
| paramName | string |
Parameter name for error messages |
|
| [component] | string |
"Component" |
Component name for error context |
| [allowEmpty] | boolean |
false |
Whether to allow empty strings |
ValidationUtils.validateBoolean(value, paramName, [component])
Validate that a value is a boolean
Kind: static method of ValidationUtils
Throws:
ErrorIf value is not a boolean
| Param | Type | Default | Description |
|---|---|---|---|
| value | any |
Value to validate |
|
| paramName | string |
Parameter name for error messages |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateFunction(value, paramName, [component])
Validate that a value is a function
Kind: static method of ValidationUtils
Throws:
ErrorIf value is not a function
| Param | Type | Default | Description |
|---|---|---|---|
| value | any |
Value to validate |
|
| paramName | string |
Parameter name for error messages |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateObject(value, paramName, [component])
Validate that a value is an object (not null, not array)
Kind: static method of ValidationUtils
Throws:
ErrorIf value is not a plain object
| Param | Type | Default | Description |
|---|---|---|---|
| value | any |
Value to validate |
|
| paramName | string |
Parameter name for error messages |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateWorker(worker, [component])
Validate Worker instance
Kind: static method of ValidationUtils
Throws:
ErrorIf worker is not valid
| Param | Type | Default | Description |
|---|---|---|---|
| worker | any |
Worker to validate |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validatePyodide(pyodide, [component])
Validate Pyodide instance
Kind: static method of ValidationUtils
Throws:
ErrorIf pyodide is not valid
| Param | Type | Default | Description |
|---|---|---|---|
| pyodide | any |
Pyodide instance to validate |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateFilesToLoad(filesToLoad, [component])
Validate file objects array for FileLoader
Kind: static method of ValidationUtils
Throws:
ErrorIf any file object is invalid
| Param | Type | Default | Description |
|---|---|---|---|
| filesToLoad | Array |
Array of file objects |
|
| [component] | string |
"PyodideFileLoader" |
Component name for error context |
ValidationUtils.validatePackages(packages, [component])
Validate packages array
Kind: static method of ValidationUtils
Throws:
ErrorIf packages array is invalid
| Param | Type | Default | Description |
|---|---|---|---|
| packages | Array |
Array of package names |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateNamespace(namespace, [component])
Validate namespace object (optional parameter)
Kind: static method of ValidationUtils
Throws:
ErrorIf namespace is provided but invalid
| Param | Type | Default | Description |
|---|---|---|---|
| namespace | any |
Namespace to validate |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateExecutionParams(filename, code, [namespace], [component])
Validate execution parameters
Kind: static method of ValidationUtils
Throws:
ErrorIf any parameter is invalid
| Param | Type | Default | Description |
|---|---|---|---|
| filename | string |
Filename for execution |
|
| code | string |
Python code to execute |
|
| [namespace] | any |
Optional namespace |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.checkDangerousPatterns(code) ⇒ Array.<string>
Check for potentially dangerous Python code patterns
Kind: static method of ValidationUtils
Returns: Array.<string> -
Array of dangerous patterns found
| Param | Type | Description |
|---|---|---|
| code | string |
Python code to check |
ValidationUtils.validateBackend(backend, [component])
Validate backend parameter (must be 'pyodide' or <?>)
Kind: static method of ValidationUtils
Throws:
ErrorIf backend is not valid
| Param | Type | Default | Description |
|---|---|---|---|
| backend | string |
Backend to validate |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateArray(value, paramName, [component])
Validate that a value is an array
Kind: static method of ValidationUtils
Throws:
ErrorIf value is not an array
| Param | Type | Default | Description |
|---|---|---|---|
| value | any |
Value to validate |
|
| paramName | string |
Parameter name for error messages |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateString(value, paramName, [component], [allowEmpty])
Validate that a value is a string
Kind: static method of ValidationUtils
Throws:
ErrorIf value is not a string or is empty when not allowed
| Param | Type | Default | Description |
|---|---|---|---|
| value | any |
Value to validate |
|
| paramName | string |
Parameter name for error messages |
|
| [component] | string |
"Component" |
Component name for error context |
| [allowEmpty] | boolean |
false |
Whether to allow empty strings |
ValidationUtils.validateBoolean(value, paramName, [component])
Validate that a value is a boolean
Kind: static method of ValidationUtils
Throws:
ErrorIf value is not a boolean
| Param | Type | Default | Description |
|---|---|---|---|
| value | any |
Value to validate |
|
| paramName | string |
Parameter name for error messages |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateFunction(value, paramName, [component])
Validate that a value is a function
Kind: static method of ValidationUtils
Throws:
ErrorIf value is not a function
| Param | Type | Default | Description |
|---|---|---|---|
| value | any |
Value to validate |
|
| paramName | string |
Parameter name for error messages |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateObject(value, paramName, [component])
Validate that a value is an object (not null, not array)
Kind: static method of ValidationUtils
Throws:
ErrorIf value is not a plain object
| Param | Type | Default | Description |
|---|---|---|---|
| value | any |
Value to validate |
|
| paramName | string |
Parameter name for error messages |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateWorker(worker, [component])
Validate Worker instance
Kind: static method of ValidationUtils
Throws:
ErrorIf worker is not valid
| Param | Type | Default | Description |
|---|---|---|---|
| worker | any |
Worker to validate |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validatePyodide(pyodide, [component])
Validate Pyodide instance
Kind: static method of ValidationUtils
Throws:
ErrorIf pyodide is not valid
| Param | Type | Default | Description |
|---|---|---|---|
| pyodide | any |
Pyodide instance to validate |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateFilesToLoad(filesToLoad, [component])
Validate file objects array for FileLoader
Kind: static method of ValidationUtils
Throws:
ErrorIf any file object is invalid
| Param | Type | Default | Description |
|---|---|---|---|
| filesToLoad | Array |
Array of file objects |
|
| [component] | string |
"PyodideFileLoader" |
Component name for error context |
ValidationUtils.validatePackages(packages, [component])
Validate packages array
Kind: static method of ValidationUtils
Throws:
ErrorIf packages array is invalid
| Param | Type | Default | Description |
|---|---|---|---|
| packages | Array |
Array of package names |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateNamespace(namespace, [component])
Validate namespace object (optional parameter)
Kind: static method of ValidationUtils
Throws:
ErrorIf namespace is provided but invalid
| Param | Type | Default | Description |
|---|---|---|---|
| namespace | any |
Namespace to validate |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateExecutionParams(filename, code, [namespace], [component])
Validate execution parameters
Kind: static method of ValidationUtils
Throws:
ErrorIf any parameter is invalid
| Param | Type | Default | Description |
|---|---|---|---|
| filename | string |
Filename for execution |
|
| code | string |
Python code to execute |
|
| [namespace] | any |
Optional namespace |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.checkDangerousPatterns(code) ⇒ Array.<string>
Check for potentially dangerous Python code patterns
Kind: static method of ValidationUtils
Returns: Array.<string> -
Array of dangerous patterns found
| Param | Type | Description |
|---|---|---|
| code | string |
Python code to check |
ValidationUtils.validateBackend(backend, [component])
Validate backend parameter (must be 'pyodide' or <?>)
Kind: static method of ValidationUtils
Throws:
ErrorIf backend is not valid
| Param | Type | Default | Description |
|---|---|---|---|
| backend | string |
Backend to validate |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.ValidationUtils
General validation utility class with static methods for parameter validation
Kind: static class of ValidationUtils
- .ValidationUtils
- .validateArray(value, paramName, [component])
- .validateString(value, paramName, [component], [allowEmpty])
- .validateBoolean(value, paramName, [component])
- .validateFunction(value, paramName, [component])
- .validateObject(value, paramName, [component])
- .validateWorker(worker, [component])
- .validatePyodide(pyodide, [component])
- .validateFilesToLoad(filesToLoad, [component])
- .validatePackages(packages, [component])
- .validateNamespace(namespace, [component])
- .validateExecutionParams(filename, code, [namespace], [component])
- .checkDangerousPatterns(code) ⇒
Array.<string> - .validateBackend(backend, [component])
- .validateArray(value, paramName, [component])
- .validateString(value, paramName, [component], [allowEmpty])
- .validateBoolean(value, paramName, [component])
- .validateFunction(value, paramName, [component])
- .validateObject(value, paramName, [component])
- .validateWorker(worker, [component])
- .validatePyodide(pyodide, [component])
- .validateFilesToLoad(filesToLoad, [component])
- .validatePackages(packages, [component])
- .validateNamespace(namespace, [component])
- .validateExecutionParams(filename, code, [namespace], [component])
- .checkDangerousPatterns(code) ⇒
Array.<string> - .validateBackend(backend, [component])
ValidationUtils.validateArray(value, paramName, [component])
Validate that a value is an array
Kind: static method of ValidationUtils
Throws:
ErrorIf value is not an array
| Param | Type | Default | Description |
|---|---|---|---|
| value | any |
Value to validate |
|
| paramName | string |
Parameter name for error messages |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateString(value, paramName, [component], [allowEmpty])
Validate that a value is a string
Kind: static method of ValidationUtils
Throws:
ErrorIf value is not a string or is empty when not allowed
| Param | Type | Default | Description |
|---|---|---|---|
| value | any |
Value to validate |
|
| paramName | string |
Parameter name for error messages |
|
| [component] | string |
"Component" |
Component name for error context |
| [allowEmpty] | boolean |
false |
Whether to allow empty strings |
ValidationUtils.validateBoolean(value, paramName, [component])
Validate that a value is a boolean
Kind: static method of ValidationUtils
Throws:
ErrorIf value is not a boolean
| Param | Type | Default | Description |
|---|---|---|---|
| value | any |
Value to validate |
|
| paramName | string |
Parameter name for error messages |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateFunction(value, paramName, [component])
Validate that a value is a function
Kind: static method of ValidationUtils
Throws:
ErrorIf value is not a function
| Param | Type | Default | Description |
|---|---|---|---|
| value | any |
Value to validate |
|
| paramName | string |
Parameter name for error messages |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateObject(value, paramName, [component])
Validate that a value is an object (not null, not array)
Kind: static method of ValidationUtils
Throws:
ErrorIf value is not a plain object
| Param | Type | Default | Description |
|---|---|---|---|
| value | any |
Value to validate |
|
| paramName | string |
Parameter name for error messages |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateWorker(worker, [component])
Validate Worker instance
Kind: static method of ValidationUtils
Throws:
ErrorIf worker is not valid
| Param | Type | Default | Description |
|---|---|---|---|
| worker | any |
Worker to validate |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validatePyodide(pyodide, [component])
Validate Pyodide instance
Kind: static method of ValidationUtils
Throws:
ErrorIf pyodide is not valid
| Param | Type | Default | Description |
|---|---|---|---|
| pyodide | any |
Pyodide instance to validate |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateFilesToLoad(filesToLoad, [component])
Validate file objects array for FileLoader
Kind: static method of ValidationUtils
Throws:
ErrorIf any file object is invalid
| Param | Type | Default | Description |
|---|---|---|---|
| filesToLoad | Array |
Array of file objects |
|
| [component] | string |
"PyodideFileLoader" |
Component name for error context |
ValidationUtils.validatePackages(packages, [component])
Validate packages array
Kind: static method of ValidationUtils
Throws:
ErrorIf packages array is invalid
| Param | Type | Default | Description |
|---|---|---|---|
| packages | Array |
Array of package names |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateNamespace(namespace, [component])
Validate namespace object (optional parameter)
Kind: static method of ValidationUtils
Throws:
ErrorIf namespace is provided but invalid
| Param | Type | Default | Description |
|---|---|---|---|
| namespace | any |
Namespace to validate |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateExecutionParams(filename, code, [namespace], [component])
Validate execution parameters
Kind: static method of ValidationUtils
Throws:
ErrorIf any parameter is invalid
| Param | Type | Default | Description |
|---|---|---|---|
| filename | string |
Filename for execution |
|
| code | string |
Python code to execute |
|
| [namespace] | any |
Optional namespace |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.checkDangerousPatterns(code) ⇒ Array.<string>
Check for potentially dangerous Python code patterns
Kind: static method of ValidationUtils
Returns: Array.<string> -
Array of dangerous patterns found
| Param | Type | Description |
|---|---|---|
| code | string |
Python code to check |
ValidationUtils.validateBackend(backend, [component])
Validate backend parameter (must be 'pyodide' or <?>)
Kind: static method of ValidationUtils
Throws:
ErrorIf backend is not valid
| Param | Type | Default | Description |
|---|---|---|---|
| backend | string |
Backend to validate |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateArray(value, paramName, [component])
Validate that a value is an array
Kind: static method of ValidationUtils
Throws:
ErrorIf value is not an array
| Param | Type | Default | Description |
|---|---|---|---|
| value | any |
Value to validate |
|
| paramName | string |
Parameter name for error messages |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateString(value, paramName, [component], [allowEmpty])
Validate that a value is a string
Kind: static method of ValidationUtils
Throws:
ErrorIf value is not a string or is empty when not allowed
| Param | Type | Default | Description |
|---|---|---|---|
| value | any |
Value to validate |
|
| paramName | string |
Parameter name for error messages |
|
| [component] | string |
"Component" |
Component name for error context |
| [allowEmpty] | boolean |
false |
Whether to allow empty strings |
ValidationUtils.validateBoolean(value, paramName, [component])
Validate that a value is a boolean
Kind: static method of ValidationUtils
Throws:
ErrorIf value is not a boolean
| Param | Type | Default | Description |
|---|---|---|---|
| value | any |
Value to validate |
|
| paramName | string |
Parameter name for error messages |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateFunction(value, paramName, [component])
Validate that a value is a function
Kind: static method of ValidationUtils
Throws:
ErrorIf value is not a function
| Param | Type | Default | Description |
|---|---|---|---|
| value | any |
Value to validate |
|
| paramName | string |
Parameter name for error messages |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateObject(value, paramName, [component])
Validate that a value is an object (not null, not array)
Kind: static method of ValidationUtils
Throws:
ErrorIf value is not a plain object
| Param | Type | Default | Description |
|---|---|---|---|
| value | any |
Value to validate |
|
| paramName | string |
Parameter name for error messages |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateWorker(worker, [component])
Validate Worker instance
Kind: static method of ValidationUtils
Throws:
ErrorIf worker is not valid
| Param | Type | Default | Description |
|---|---|---|---|
| worker | any |
Worker to validate |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validatePyodide(pyodide, [component])
Validate Pyodide instance
Kind: static method of ValidationUtils
Throws:
ErrorIf pyodide is not valid
| Param | Type | Default | Description |
|---|---|---|---|
| pyodide | any |
Pyodide instance to validate |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateFilesToLoad(filesToLoad, [component])
Validate file objects array for FileLoader
Kind: static method of ValidationUtils
Throws:
ErrorIf any file object is invalid
| Param | Type | Default | Description |
|---|---|---|---|
| filesToLoad | Array |
Array of file objects |
|
| [component] | string |
"PyodideFileLoader" |
Component name for error context |
ValidationUtils.validatePackages(packages, [component])
Validate packages array
Kind: static method of ValidationUtils
Throws:
ErrorIf packages array is invalid
| Param | Type | Default | Description |
|---|---|---|---|
| packages | Array |
Array of package names |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateNamespace(namespace, [component])
Validate namespace object (optional parameter)
Kind: static method of ValidationUtils
Throws:
ErrorIf namespace is provided but invalid
| Param | Type | Default | Description |
|---|---|---|---|
| namespace | any |
Namespace to validate |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.validateExecutionParams(filename, code, [namespace], [component])
Validate execution parameters
Kind: static method of ValidationUtils
Throws:
ErrorIf any parameter is invalid
| Param | Type | Default | Description |
|---|---|---|---|
| filename | string |
Filename for execution |
|
| code | string |
Python code to execute |
|
| [namespace] | any |
Optional namespace |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils.checkDangerousPatterns(code) ⇒ Array.<string>
Check for potentially dangerous Python code patterns
Kind: static method of ValidationUtils
Returns: Array.<string> -
Array of dangerous patterns found
| Param | Type | Description |
|---|---|---|
| code | string |
Python code to check |
ValidationUtils.validateBackend(backend, [component])
Validate backend parameter (must be 'pyodide' or <?>)
Kind: static method of ValidationUtils
Throws:
ErrorIf backend is not valid
| Param | Type | Default | Description |
|---|---|---|---|
| backend | string |
Backend to validate |
|
| [component] | string |
"Component" |
Component name for error context |
ValidationUtils~ValidationError : Object
Kind: inner typedef of ValidationUtils
Properties
| Name | Type | Description |
|---|---|---|
| message | string |
Error message |
| component | string |
Component that threw the error |
| parameter | string |
Parameter that failed validation |
ValidationUtils~ValidationError : Object
Kind: inner typedef of ValidationUtils
Properties
| Name | Type | Description |
|---|---|---|
| message | string |
Error message |
| component | string |
Component that threw the error |
| parameter | string |
Parameter that failed validation |
BrythonManager
BrythonManager – Minimal backend for Nagini focused on turtle graphics. Provides the same public surface as PyodideManager but runs directly in the main thread with Brython. Input(), packages, and filesystem are NOT supported for now.
PyodideFileLoader
PyodideFileLoader class for loading files into Pyodide filesystem
Kind: global class
- PyodideFileLoader
- new PyodideFileLoader(filesToLoad)
- .loadFiles(pyodide, [options]) ⇒
Promise.<void>
new PyodideFileLoader(filesToLoad)
Create a new PyodideFileLoader instance
Throws:
ErrorIf filesToLoad is not an array or contains invalid objects
| Param | Type | Description |
|---|---|---|
| filesToLoad | Array.<FileToLoad> |
Array of file objects to load |
pyodideFileLoader.loadFiles(pyodide, [options]) ⇒ Promise.<void>
Load files into Pyodide filesystem with retry mechanism
Kind: instance method of PyodideFileLoader
Throws:
ErrorIf file loading fails after all retries
| Param | Type | Description |
|---|---|---|
| pyodide | PyodideAPI |
Pyodide instance |
| [options] | LoadOptions |
Loading options |
PyodideManagerFS
Static class containing filesystem functionality for PyodideManager
Kind: global class
- PyodideManagerFS
- .fs(manager, operation, params) ⇒
Promise.<any> - .writeFile(manager, path, content) ⇒
Promise.<Object> - .readFile(manager, path) ⇒
Promise.<string> - .mkdir(manager, path) ⇒
Promise.<Object> - .exists(manager, path) ⇒
Promise.<boolean> - .listdir(manager, path) ⇒
Promise.<Array.<string>>
- .fs(manager, operation, params) ⇒
PyodideManagerFS.fs(manager, operation, params) ⇒ Promise.<any>
Filesystem operations proxy - main public interface
Kind: static method of PyodideManagerFS
Returns: Promise.<any> -
Operation result
Throws:
ErrorIf operation fails or times out
| Param | Type | Description |
|---|---|---|
| manager | PyodideManager |
Manager instance |
| operation | FSOperation |
FS operation: 'writeFile', 'readFile', 'mkdir', 'exists', 'listdir' |
| params | FSOperationParams |
Operation parameters |
PyodideManagerFS.writeFile(manager, path, content) ⇒ Promise.<Object>
Write file to Pyodide filesystem
Kind: static method of PyodideManagerFS
Returns: Promise.<Object> -
Operation result
| Param | Type | Description |
|---|---|---|
| manager | PyodideManager |
Manager instance |
| path | string |
File path |
| content | string |
File content |
PyodideManagerFS.readFile(manager, path) ⇒ Promise.<string>
Read file from Pyodide filesystem
Kind: static method of PyodideManagerFS
Returns: Promise.<string> -
File content
| Param | Type | Description |
|---|---|---|
| manager | PyodideManager |
Manager instance |
| path | string |
File path |
PyodideManagerFS.mkdir(manager, path) ⇒ Promise.<Object>
Create directory in Pyodide filesystem
Kind: static method of PyodideManagerFS
Returns: Promise.<Object> -
Operation result
| Param | Type | Description |
|---|---|---|
| manager | PyodideManager |
Manager instance |
| path | string |
Directory path |
PyodideManagerFS.exists(manager, path) ⇒ Promise.<boolean>
Check if path exists in Pyodide filesystem
Kind: static method of PyodideManagerFS
Returns: Promise.<boolean> -
True if exists, false otherwise
| Param | Type | Description |
|---|---|---|
| manager | PyodideManager |
Manager instance |
| path | string |
Path to check |
PyodideManagerFS.listdir(manager, path) ⇒ Promise.<Array.<string>>
List directory contents in Pyodide filesystem
Kind: static method of PyodideManagerFS
Returns: Promise.<Array.<string>> -
Array of file/directory names
| Param | Type | Description |
|---|---|---|
| manager | PyodideManager |
Manager instance |
| path | string |
Directory path |
PyodideManagerInput
Static class containing input handling functionality for PyodideManager
Kind: global class
- PyodideManagerInput
- .initializeInputState(manager) ⇒
void - .provideInput(manager, input) ⇒
void - .queueInput(manager, input) ⇒
void - .setInputCallback(manager, callback) ⇒
void - .isWaitingForInput(manager) ⇒
boolean - .getCurrentPrompt(manager) ⇒
string - .handleInputMessage(manager, data) ⇒
void - .resetInputState(manager) ⇒
void
- .initializeInputState(manager) ⇒
PyodideManagerInput.initializeInputState(manager) ⇒ void
Initialize input state for a PyodideManager instance
Kind: static method of PyodideManagerInput
| Param | Type | Description |
|---|---|---|
| manager | PyodideManager |
Manager instance to initialize |
PyodideManagerInput.provideInput(manager, input) ⇒ void
Provide input to Python code that's waiting for input
Kind: static method of PyodideManagerInput
| Param | Type | Description |
|---|---|---|
| manager | PyodideManager |
Manager instance |
| input | string |
The input value to provide |
PyodideManagerInput.queueInput(manager, input) ⇒ void
Queue input for later provision when Python code requests it
Kind: static method of PyodideManagerInput
| Param | Type | Description |
|---|---|---|
| manager | PyodideManager |
Manager instance |
| input | string |
The input value to queue |
PyodideManagerInput.setInputCallback(manager, callback) ⇒ void
Set a callback function to be called when input is required
Kind: static method of PyodideManagerInput
| Param | Type | Description |
|---|---|---|
| manager | PyodideManager |
Manager instance |
| callback | function |
Function to call when input is needed |
PyodideManagerInput.isWaitingForInput(manager) ⇒ boolean
Check if Python code is currently waiting for input
Kind: static method of PyodideManagerInput
Returns: boolean -
True if waiting for input, false otherwise
| Param | Type | Description |
|---|---|---|
| manager | PyodideManager |
Manager instance |
PyodideManagerInput.getCurrentPrompt(manager) ⇒ string
Get the current input prompt if waiting for input
Kind: static method of PyodideManagerInput
Returns: string -
Current input prompt or empty string
| Param | Type | Description |
|---|---|---|
| manager | PyodideManager |
Manager instance |
PyodideManagerInput.handleInputMessage(manager, data) ⇒ void
Handle input-related message from worker
Kind: static method of PyodideManagerInput
| Param | Type | Description |
|---|---|---|
| manager | PyodideManager |
Manager instance |
| data | Object |
Message data from worker |
PyodideManagerInput.resetInputState(manager) ⇒ void
Reset input state (called on execution completion)
Kind: static method of PyodideManagerInput
| Param | Type | Description |
|---|---|---|
| manager | PyodideManager |
Manager instance |
PyodideManager
Kind: global class
- PyodideManager
- new PyodideManager(packages, micropipPackages, filesToLoad, workerPath, [config])
- .worker :
Worker|null - .executionHistory :
Array.<ExecutionResult> - .isReady :
boolean - .packages :
Array.<string> - .micropipPackages :
Array.<string> - .filesToLoad :
Array.<FileToLoad> - .workerPath :
string - .pyodideCdnUrl :
string|undefined - .blobUrl :
string|null - .validateAndFilterPackages(packages) ⇒
Array.<string> - .handleMessage(data) ⇒
void - .setHandleMessage([newHandler]) ⇒
function - .getHandleMessage() ⇒
function - .executeFile(filename, code, [namespace]) ⇒
void - .executeAsync(filename, code, [namespace]) ⇒
Promise.<ExecutionResult> - .clearExecutionHistory() ⇒
void - .destroy() ⇒
void
new PyodideManager(packages, micropipPackages, filesToLoad, workerPath, [config])
Create a new PyodideManager instance
Throws:
ErrorIf any parameter has incorrect type or worker is not bundled
| Param | Type | Default | Description |
|---|---|---|---|
| packages | Array.<string> |
Array of Python package names to install |
|
| micropipPackages | Array.<string> |
Array of Python package names to install with micropip |
|
| filesToLoad | Array.<FileToLoad> |
Array of file objects to load into filesystem |
|
| workerPath | string |
Path to the bundled web worker file (must be worker-dist.js) |
|
| [config] | Object |
{} |
Optional configuration object |
| [config.pyodideCdnUrl] | string |
Custom Pyodide CDN URL (for local/offline use, e.g., Capacitor apps) |
pyodideManager.worker : Worker | null
Web worker instance
Kind: instance property of PyodideManager
pyodideManager.executionHistory : Array.<ExecutionResult>
Execution history with results and metadata
Kind: instance property of PyodideManager
pyodideManager.isReady : boolean
Whether Pyodide is ready for execution
Kind: instance property of PyodideManager
pyodideManager.packages : Array.<string>
Python packages to install during initialization - filtered and validated
Kind: instance property of PyodideManager
pyodideManager.micropipPackages : Array.<string>
Python packages to install with micropip - filtered and validated
Kind: instance property of PyodideManager
pyodideManager.filesToLoad : Array.<FileToLoad>
Files to load into Pyodide filesystem
Kind: instance property of PyodideManager
pyodideManager.workerPath : string
Path to the bundled web worker file
Kind: instance property of PyodideManager
pyodideManager.pyodideCdnUrl : string | undefined
Custom Pyodide CDN URL (for local/offline use)
Kind: instance property of PyodideManager
pyodideManager.blobUrl : string | null
Blob URL for cleanup
Kind: instance property of PyodideManager
pyodideManager.validateAndFilterPackages(packages) ⇒ Array.<string>
Validate and filter Python packages
Kind: instance method of PyodideManager
Returns: Array.<string> -
Validated and filtered package names
| Param | Type | Description |
|---|---|---|
| packages | Array.<string> |
Array of package names to validate |
pyodideManager.handleMessage(data) ⇒ void
Handle messages from the Pyodide worker Updates UI status and manages execution context
Kind: instance method of PyodideManager
| Param | Type | Description |
|---|---|---|
| data | WorkerMessage |
Message from worker |
pyodideManager.setHandleMessage([newHandler]) ⇒ function
Get or set the current message handler
Kind: instance method of PyodideManager
Returns: function -
Current message handler
| Param | Type | Description |
|---|---|---|
| [newHandler] | function |
New message handler to set |
pyodideManager.getHandleMessage() ⇒ function
Get the current message handler
Kind: instance method of PyodideManager
Returns: function -
Current message handler
pyodideManager.executeFile(filename, code, [namespace]) ⇒ void
Execute Python code in the worker with optional namespace isolation
Kind: instance method of PyodideManager
Returns: void -
- No return value, sends message to worker
| Param | Type | Description |
|---|---|---|
| filename | string |
Name for this execution (for tracking and debugging) |
| code | string |
Python code to execute |
| [namespace] | Object | undefined |
Optional namespace object for Python execution |
pyodideManager.executeAsync(filename, code, [namespace]) ⇒ Promise.<ExecutionResult>
Execute Python code asynchronously and return a Promise with the result
Kind: instance method of PyodideManager
Returns: Promise.<ExecutionResult> -
Promise that resolves with execution result
Throws:
ErrorIf manager is not ready or execution times out
| Param | Type | Description |
|---|---|---|
| filename | string |
Name for this execution (for tracking and debugging) |
| code | string |
Python code to execute |
| [namespace] | Object | undefined |
Optional namespace object for Python execution |
pyodideManager.clearExecutionHistory() ⇒ void
Clear execution history context
Kind: instance method of PyodideManager
pyodideManager.destroy() ⇒ void
Cleanup resources and terminate worker Call this when the manager is no longer needed to prevent memory leaks
Kind: instance method of PyodideManager
createBlobWorkerUrl(workerUrl) ⇒ Promise.<string>
Create a blob worker URL from a bundled worker script
Kind: global function
Returns: Promise.<string> -
Blob URL that can be used to create a Worker
Throws:
ErrorIf worker script cannot be fetched
| Param | Type | Description |
|---|---|---|
| workerUrl | string |
URL to the bundled worker script (worker-dist.js) |
createBlobWorker(workerUrl) ⇒ Promise.<Worker>
Create a Worker instance using blob URL pattern
Kind: global function
Returns: Promise.<Worker> -
Web Worker instance created from blob URL
Throws:
ErrorIf worker creation fails
| Param | Type | Description |
|---|---|---|
| workerUrl | string |
URL to the bundled worker script (worker-dist.js) |
revokeBlobUrl(blobUrl)
Cleanup blob URL to prevent memory leaks
Kind: global function
| Param | Type | Description |
|---|---|---|
| blobUrl | string |
Blob URL to revoke |
executeAsync()
Execute Python code with Brython, capturing stdout, stderr and missive. Renamed from brython-executor.js
createBlobWorkerUrl(workerUrl) ⇒ Promise.<string>
Create a blob worker URL from a bundled worker script
Kind: global function
Returns: Promise.<string> -
Blob URL that can be used to create a Worker
Throws:
ErrorIf worker script cannot be fetched
| Param | Type | Description |
|---|---|---|
| workerUrl | string |
URL to the bundled worker script (worker-dist.js) |
createBlobWorker(workerUrl) ⇒ Promise.<Worker>
Create a Worker instance using blob URL pattern
Kind: global function
Returns: Promise.<Worker> -
Web Worker instance created from blob URL
Throws:
ErrorIf worker creation fails
| Param | Type | Description |
|---|---|---|
| workerUrl | string |
URL to the bundled worker script (worker-dist.js) |
revokeBlobUrl(blobUrl)
Cleanup blob URL to prevent memory leaks
Kind: global function
| Param | Type | Description |
|---|---|---|
| blobUrl | string |
Blob URL to revoke |
FileToLoad : Object
Kind: global typedef
Properties
| Name | Type | Description |
|---|---|---|
| url | string |
URL to fetch the file from (supports S3, HTTP, local paths) |
| path | string |
Target path in Pyodide filesystem where file should be saved |
LoadOptions : Object
Kind: global typedef
Properties
| Name | Type | Default | Description |
|---|---|---|---|
| [maxRetries] | number |
3 |
Maximum number of retry attempts for failed downloads |
| [retryDelay] | number |
1000 |
Base delay in milliseconds between retries |
PyodideAPI : Object
Kind: global typedef
Properties
| Name | Type | Description |
|---|---|---|
| FS | Object |
Pyodide filesystem interface |
| FS.writeFile | function |
Write file to filesystem |
| FS.analyzePath | function |
Analyze path existence |
| FS.mkdir | function |
Create directory |
FSOperation : 'writeFile' | 'readFile' | 'mkdir' | 'exists' | 'listdir'
FSOperationParams : Object
Kind: global typedef
Properties
| Name | Type | Description |
|---|---|---|
| path | string |
File or directory path |
| [content] | string |
File content (for writeFile operation) |
FSOperationResult : Object
Kind: global typedef
Properties
| Name | Type | Description |
|---|---|---|
| [success] | boolean |
Whether operation succeeded |
| [content] | string |
File content (for readFile) |
| [exists] | boolean |
Whether file/directory exists |
| [files] | Array.<string> |
Directory contents (for listdir) |
ExecutionResult : Object
Kind: global typedef
Properties
| Name | Type | Description |
|---|---|---|
| filename | string |
Name of the executed file |
| time | number |
Execution time in milliseconds |
| stdout | string |
Standard output from Python execution |
| stderr | string |
Standard error from Python execution |
| missive | Object | null |
Structured JSON data from Python |
| figures | Array.<string> |
Base64 encoded matplotlib figures |
| bokeh_figures | Array.<string> |
JSON strings of Bokeh figures |
| error | Object | null |
JavaScript execution error object |
| timestamp | string |
ISO timestamp of execution |
| [executedWithNamespace] | boolean |
Whether execution used namespace |
FileToLoad : Object
Kind: global typedef
Properties
| Name | Type | Description |
|---|---|---|
| path | string |
Path where file should be saved in filesystem |
| content | string |
File content to write |
| [encoding] | string |
File encoding (default: 'utf8') |
WorkerMessage : Object
Kind: global typedef
Properties
| Name | Type | Description |
|---|---|---|
| type | 'ready' | 'error' | 'warning' | 'info' | 'result' | 'fs_result' | 'fs_error' |
Message type |
| [message] | string |
Message content |
| [error] | string |
Error message |
| [filename] | string |
Filename for execution results |
| [time] | number |
Execution time in milliseconds |
| [stdout] | string |
Standard output |
| [stderr] | string |
Standard error |
| [missive] | Object | null |
Structured data from Python |
| [error] | Object | null |
Execution error object |
| [result] | any |
Filesystem operation result |
ExecutionResult : Object
Kind: global typedef
Properties
| Name | Type | Description |
|---|---|---|
| filename | string |
Name of the executed file |
| time | number |
Execution time in milliseconds |
| stdout | string |
Standard output from Python execution |
| stderr | string |
Standard error from Python execution |
| missive | Object | null |
Structured JSON data from Python |
| error | Object | null |
JavaScript execution error object |
| timestamp | string |
ISO timestamp of execution |
| [executedWithNamespace] | boolean |
Whether execution used namespace |