"""
This type stub file was generated by pyright.
"""
import pathlib
from dataclasses import dataclass
from typing import Any, List, Union
from lark import Transformer, v_args
"""
2025-06-03
By Unclcode:
C4A-Script Language Documentation
Feeds Crawl4AI via CrawlerRunConfig(js_code=[ ... ]) – no core modifications.
"""
class C4AScriptError(Exception):
"""Custom error class for C4A-Script compilation errors"""
def __init__(self, message: str, line: int = ..., column: int = ..., error_type: str = ..., details: str = ...) -> None:
...
@classmethod
def from_exception(cls, exc: Exception, script: Union[str, List[str]]) -> C4AScriptError:
"""Create C4AScriptError from another exception"""
...
GRAMMAR = ...
@dataclass
class Cmd:
op: str
args: List[Any]
...
@dataclass
class Proc:
name: str
body: List[Cmd]
...
@v_args(inline=True)
class ASTBuilder(Transformer):
def start(self, *i): # -> list[Any]:
...
def line(self, i):
...
def command(self, i):
...
def wait_cmd(self, rest, timeout=...): # -> Cmd:
...
def go(self, u): # -> Cmd:
...
def reload(self): # -> Cmd:
...
def back(self): # -> Cmd:
...
def forward(self): # -> Cmd:
...
def click(self, *args): # -> Cmd:
...
def double_click(self, *args): # -> Cmd:
...
def right_click(self, *args): # -> Cmd:
...
def coords(self, x, y): # -> tuple[Literal['coords'], int, int]:
...
def move(self, c): # -> Cmd:
...
def drag(self, c1, c2): # -> Cmd:
...
def scroll(self, dir_tok, amt=...): # -> Cmd:
...
def type(self, tok): # -> Cmd:
...
def clear(self, sel): # -> Cmd:
...
def set_input(self, sel, val): # -> Cmd:
...
def press(self, w): # -> Cmd:
...
def key_down(self, w): # -> Cmd:
...
def key_up(self, w): # -> Cmd:
...
def eval_cmd(self, txt): # -> Cmd:
...
def setvar(self, n, v): # -> Cmd:
...
def proc_call(self, n): # -> Cmd:
...
def proc_def(self, n, *body): # -> Proc:
...
def include(self, p): # -> Cmd:
...
def comment(self, *_): # -> Cmd:
...
def if_cmd(self, condition, then_cmd, else_cmd=...): # -> Cmd:
...
def condition(self, cond):
...
def not_cond(self, cond): # -> tuple[Literal['NOT'], Any]:
...
def exists_cond(self, selector): # -> tuple[Literal['EXISTS'], str]:
...
def js_cond(self, expr): # -> tuple[Literal['JS'], str]:
...
def repeat_cmd(self, cmd, count): # -> Cmd:
...
def repeat_count(self, value): # -> str:
...
class Compiler:
def __init__(self, root: pathlib.Path | None = ...) -> None:
...
def compile(self, text: Union[str, List[str]]) -> List[str]:
...
def compile_string(script: Union[str, List[str]], *, root: Union[pathlib.Path, None] = ...) -> List[str]:
"""Compile C4A-Script from string or list of strings to JavaScript.
Args:
script: C4A-Script as a string or list of command strings
root: Root directory for resolving includes (optional)
Returns:
List of JavaScript command strings
Raises:
C4AScriptError: When compilation fails with detailed error information
"""
...
def compile_file(path: pathlib.Path) -> List[str]:
"""Compile C4A-Script from file to JavaScript.
Args:
path: Path to C4A-Script file
Returns:
List of JavaScript command strings
"""
...
def compile_lines(lines: List[str], *, root: Union[pathlib.Path, None] = ...) -> List[str]:
"""Compile C4A-Script from list of lines to JavaScript.
Args:
lines: List of C4A-Script command lines
root: Root directory for resolving includes (optional)
Returns:
List of JavaScript command strings
"""
...
DEMO = ...
if __name__ == "__main__":
...