declare _CRABSOUP_VERSION: string -- Crabsoup Classes declare class CompletedProcess end declare class Environment end declare class NodeRef end declare class Process end declare class RequireEnv end declare class Timezone end -- Crabsoup IPC Classes declare class PluginInstruction function is_exit(self): boolean function is_fail(self): boolean function get_message(self): string end -- Crabsoup APIs declare CSV: { from_string: (string) -> {{string}}, to_list_of_tables: (string) -> {{ [string]: string }}, } declare Date: { Timezone: { [string]: Timezone, Local: Timezone, UTC: Timezone }, rfc2822: string, rfc3339: string, iso8601: string, now_timestamp: () -> number, now_timestamp_frac: () -> number, now_format: (format: string?, tz: (Timezone | string)?) -> string, format: (time: number, format: string?, tz: (Timezone | string)?) -> string, to_timestamp: (time: string, format: (string | {string})?, tz: (Timezone | string)?) -> number, reformat: (time: string, from_format: (string | {string})?, to_format: string?, tz: (Timezone | string)?) -> number, } declare Digest: { md5: (string) -> string, sha1: (string) -> string, sha256: (string) -> string, sha512: (string) -> string, blake2s: (string) -> string, blake2b: (string) -> string, } declare JSON: { from_string: (string) -> any?, to_string: (any?) -> string, pretty_print: (any?) -> string, } declare Log: { error: (...T) -> (), warn: (...T) -> (), warning: (...T) -> (), info: (...T) -> (), debug: (...T) -> (), trace: (...T) -> (), } declare String: { truncate: (str: string, length: number, trailer: string?) -> string, slugify: (string) -> string, slugify_soft: (string) -> string, slugify_ascii: (string) -> string, render_template: (template: string, env: any) -> string, base64_encode: (string) -> string, base64_decode: (string) -> string, url_encode: (str: string, exclude: {string}?) -> string, url_decode: (string) -> string, html_encode: (string) -> string, html_decode: (string) -> string, escape_css: (string) -> string, } declare Sys: { read_file: (path: string) -> string, write_file: (path: string, data: string) -> (), delete_file: (path: string) -> (), copy_file: (src: string, dst: string) -> (), delete_recursive: (path: string) -> (), get_file_size: (path: string) -> number, file_exists: (path: string) -> boolean, is_file: (path: string) -> boolean, is_dir: (path: string) -> boolean, get_file_creation_time: (path: string) -> number, get_file_modification_time: (path: string) -> number, mkdir: (path: string) -> (), list_dir: (path: string) -> {string}, glob: (pattern: string) -> {string}, get_extension: (path: string) -> string?, get_extensions: (path: string) -> {string}, has_extension: (path: string, extension: string) -> boolean, strip_extension: (path: string) -> string, strip_all_extensions: (path: string) -> string, basename: (path: string) -> string, basename_unix: (path: string) -> string, basename_url: (path: string) -> string, dirname: (path: string) -> string, dirname_unix: (path: string) -> string, dirname_url: (path: string) -> string, join_path: (path: string, fragment: string) -> string, join_path_unix: (path: string, fragment: string) -> string, join_url: (path: string, fragment: string) -> string, split_path: (path: string) -> {string}, split_path_unix: (path: string) -> {string}, split_path_url: (path: string) -> {string}, canonicalize: (path: string) -> string, is_unix: () -> boolean, is_windows: () -> boolean, getenv: (name: string, default: string?) -> string?, sleep: (number) -> (), cpu_count: number, } declare Table: { get_key_default: (table: { [K]: V }, key: K, default_value: V) -> V, keys: (value: { [K]: V }) -> {K}, has_value: (table: { [K]: V }, value: V) -> boolean, iter: (func: (K, V) -> (), table: { [K]: V }) -> (), iter_values: (func: (V) -> (), table: { [K]: V }) -> (), iter_ordered: (func: (K, V) -> (), value: { [K]: V }) -> (), iter_values_ordered: (func: (V) -> (), value: { [K]: V }) -> (), fold: (func: (K, V, A) -> A, value: { [K]: V }, initial_value: A) -> A, fold_values: (func: (V, A) -> A, value: { [K]: V }, initial_value: A) -> A, map: (func: (K, V) -> R, value: { [K]: V }) -> { [K]: R }, map_values: (func: (V) -> R, value: { [K]: V }) -> { [K]: R }, filter_map: (func: (K, V) -> boolean, value: { [K]: V }) -> { [K]: V }, filter_list: (func: (V) -> boolean, value: { V }) -> { V }, apply: (func: (K, V) -> V, value: { [K]: V }) -> (), apply_to_values: (func: (V) -> V, value: { [K]: V }) -> (), for_all: (func: (V) -> boolean, table: { [K]: V }) -> boolean, for_any: (func: (V) -> boolean, table: { [K]: V }) -> boolean, take: (value: {T}, count: number) -> {T}, chunks: (value: {T}, size: number) -> {{T}}, length: (value: { [K]: V }) -> number, is_empty: (value: { [K]: V }) -> boolean, deep_clone: (value: { [K]: V }) -> { [K]: V }, } declare TOML: { from_string: (string) -> any?, to_string: (any?) -> string, } declare Value: { repr: (value: T) -> string, repr_compact: (value: T) -> string, is_int: (value: T) -> boolean, is_list: (value: T) -> boolean, } declare YAML: { from_string: (string) -> any?, to_string: (any?) -> string, } -- HTML library type HeadingsTreeADT = { heading: NodeRef, children: {HeadingsTreeADT} } declare HTML: { parse: (text: string, encoding: string?) -> NodeRef, parse_document: (text: string, encoding: string?) -> NodeRef, parse_fragment: (text: string, root_node: string, encoding: string?) -> NodeRef, set_default_encoding: (string) -> (), to_string: (node: NodeRef, encoding: string?) -> string, pretty_print: (node: NodeRef, encoding: string?) -> string, create_document: () -> NodeRef, create_element: (name: string, text: string?) -> NodeRef, create_text: (string) -> NodeRef, select: (node: NodeRef, selector: string) -> {NodeRef}, select_one: (node: NodeRef, selector: string) -> NodeRef?, matches: (node: NodeRef, selector: string) -> boolean, parent: (NodeRef) -> NodeRef?, children: (NodeRef) -> {NodeRef}, ancestors: (NodeRef) -> {NodeRef}, descendants: (NodeRef) -> {NodeRef}, siblings: (NodeRef) -> {NodeRef}, child_count: (NodeRef) -> number, is_empty: (NodeRef) -> boolean, get_tag_name: (NodeRef) -> string, set_tag_name: (node: NodeRef, name: string) -> (), get_attribute: (node: NodeRef, name: string) -> string?, set_attribute: (node: NodeRef, name: string, value: string) -> (), append_attribute: (node: NodeRef, name: string, value: string) -> (), delete_attribute: (node: NodeRef, name: string) -> (), list_attributes: (NodeRef) -> {string}, clear_attributes: (NodeRef) -> (), get_classes: (NodeRef) -> {string}, has_class: (node: NodeRef, name: string) -> boolean, add_class: (node: NodeRef, name: string) -> (), remove_class: (node: NodeRef, name: string) -> (), inner_html: (NodeRef) -> string, inner_text: (NodeRef) -> string, strip_tags: (NodeRef) -> string, replace_element: (from: NodeRef, with: NodeRef) -> (), replace_content: (parent: NodeRef, child: NodeRef) -> (), delete: (NodeRef) -> (), delete_element: (NodeRef) -> (), wrap: (elem: NodeRef, with: NodeRef) -> (), swap: (NodeRef, NodeRef) -> (), append: (parent: NodeRef, child: NodeRef) -> (), append_child: (parent: NodeRef, child: NodeRef) -> (), prepend: (parent: NodeRef, child: NodeRef) -> (), prepend_child: (parent: NodeRef, child: NodeRef) -> (), insert_before: (target: NodeRef, node: NodeRef) -> (), insert_after: (target: NodeRef, node: NodeRef) -> (), delete_content: (NodeRef) -> (), unwrap: (NodeRef) -> (), get_heading_level: (node: NodeRef) -> number, get_headings_tree: (node: NodeRef) -> HeadingsTreeADT, is_comment: (NodeRef) -> boolean, is_doctype: (NodeRef) -> boolean, is_document: (NodeRef) -> boolean, is_element: (NodeRef) -> boolean, is_text: (NodeRef) -> boolean, clone: (NodeRef) -> NodeRef, } -- Process library type CommandInfo = { [number]: string, shell: string?, current_directory: string?, env: { [string]: string }?, stdin: string?, capture_stdout: boolean?, capture_stdout: boolean?, } declare Process: { run: (CommandInfo) -> (), try_run: (CommandInfo) -> number, run_output: (CommandInfo) -> string, spawn: (CommandInfo) -> Process, is_completed: (Process) -> boolean, wait_on: (Process) -> CompletedProcess, wait_on_yield: (Process) -> CompletedProcess, check_status: (CompletedProcess) -> (), status: (CompletedProcess) -> number, get_stdout: (CompletedProcess) -> string, get_stderr: (CompletedProcess) -> string, } declare Regex: { match: (string, string) -> boolean, find_all: (string, string) -> {string}, replace: (string, string, string) -> string, replace_all: (string, string, string) -> string, split: (string, string) -> {string}, escape: (string) -> string, } -- Plugin library declare Plugin: { fail: (T?) -> never, exit: (T?) -> never, require_version: (version: string) -> (), soupault_version: () -> string, crabsoup_version: () -> string, -- Plugin API env_standalone: Environment, env_plugin: Environment, create_require_env: (sources_path: string, env: Environment) -> RequireEnv, load_plugin: (ctx: RequireEnv, name: string, source: string, allowed_globals: { string }?) -> (globals: { [string]: any }?, name_tag: string?) -> thread, require_add_preload: (ctx: RequireEnv, name: string, value: any) -> (), require_set_strict: (ctx: RequireEnv) -> (), create_require_func: (ctx: RequireEnv) -> (name: string) -> any, traceback: (any?) -> string, } declare require: (name: string) -> any declare require_env: RequireEnv -- String loading functions declare function dofile(filename: string, mode: string?, env: { [string]: any }?): any declare function load(src: string | () -> string, chunkname: string?, mode: string?, env: { [string]: any }?): (((A...) -> any)?, string?) declare function loadstring(src: string, chunkname: string?, mode: string?, env: { [string]: any }?): (((A...) -> any)?, string?) declare function loadfile(filename: string, mode: string?, env: { [string]: any }?): (((A...) -> any)?, string?) -- Standard library extensions declare string: typeof(string) & { trim: (s: string) -> string, startswith: (s: string, prefix: string) -> boolean, endswith: (s: string, prefix: string) -> boolean, } declare math: typeof(math) & { isnan: (n: number) -> boolean, isinf: (n: number) -> boolean, isfinite: (n: number) -> boolean, } declare table: typeof(table) & { pop: (t: {T}) -> T, } declare unreachable: (T...) -> never