///
///
export interface VorpleOptions {
container?: string | JQuery;
}
export declare type VorpleEventCategory = "init" | "expectCommand" | "submitCommand" | "expectKeypress" | "submitKeypress" | "quit";
export interface VorpleEventMetadata {
type: VorpleEventCategory;
event?: KeyboardEvent | MouseEvent;
input?: string | number;
mouseClick?: boolean;
original?: string | number;
silent?: boolean;
userAction?: boolean;
}
export declare type VorpleEventListener = (meta: VorpleEventMetadata) => Promise | unknown;
/**
* Registers a listener for an event.
*
* @see https://vorple-if.com/docs/listeners.html
* @since 3.2.0
*
* @param eventNames The event name or an array of event names where to add the listener
* @param listener The listener to register
* @returns Returns a function that can be called to remove the listeners.
*/
export declare function addEventListener(eventNames: VorpleEventCategory | VorpleEventCategory[], listener: VorpleEventListener): () => void;
/**
* Checks that the library's version matches the given version range.
* See https://github.com/npm/node-semver#ranges for the full syntax.
*
* @example
* If the library version is e.g. 3.2.8 the following return true:
*
* ```
* vorple.checkVersion("3.2")
* vorple.checkVersion(">=3.2.8")
* vorple.checkVersion("<3.3")
* vorple.checkVersion("3.2.8 || >=4")
* vorple.checkVersion("3.1 - 3.2")
* vorple.checkVersion("~3.2.5")
* ```
*
* The following return false:
*
* ```
* vorple.checkVersion(">=4.0")
* vorple.checkVersion("<3.2.8")
* vorple.checkVersion("~3.2.9")
* ```
*
* @param versionRange The version range to check
* @returns True if version matches the given range, false otherwise.
* @since 3.2.8
*/
export declare function checkVersion(versionRange: string): boolean;
/**
* Evaluates JavaScript code and writes the return value and its type to the
* virtual filesystem for the story file to read.
*
* @param code JavaScript code to evaluate
*/
export declare function evaluate(code: string): void;
/**
* Returns the Inform version, detected at handshake.
* Before the handshake the value is undefined.
*
* @since 3.2.0
*/
export declare function getInformVersion(): 6 | 7 | undefined;
/**
* Initializes and starts Vorple.
*
* @returns The function returns a promise that's resolved when the init event has triggered and the virtual filesystem
* has started. The promise won't wait for the story file to load.
*/
export declare function init(): Promise;
/**
* Removes a registered event listener.
*
* @param eventNames The event name or an array of event names from where to remove the listener.
* Leaving this parameter out completely (i.e. passing the listener function as the first and only parameter)
* removes the listener from all events where it's been registered.
* @param listener The listener to remove
* @returns Returns true if the listener was removed from at least one event.
* @since 3.2.0
*/
export declare function removeEventListener(eventNames: VorpleEventCategory | VorpleEventCategory[], listener: VorpleEventListener): boolean;
/**
* Require a minimum version of Vorple. Minor updates are accepted if
* they're not specified in the request. In other words, if version "3.1"
* is requested, then any Vorple version below 3.2 (3.1, 3.1.1, 3.1.2 etc)
* will pass. If version "3" is requested, every version 3.x.x will pass.
*
* If an optional callback is passed to the function, it will be run with
* one boolean parameter: true if version matches, false otherwise.
* Otherwise an error is thrown if the version doesn't match.
*
* @param requiredVersion The minimum version of Vorple that's required
* @param callback If an optional callback function is passed, it will be run with
* one boolean parameter: true if version matches, false otherwise. If a callback
* isn't provided, this function throws an error if the version doesn't match.
* @returns Returns true if version matches.
* @deprecated Deprecated since 3.2.8 in favor of the more versatile [[checkVersion]].
* The equivalent of e.g. `vorple.requireVersion("3.2")` is `vorple.checkVersion(">=3.2")`.
*/
export declare function requireVersion(requiredVersion: string, callback?: (versionMatches: boolean) => void): boolean;
/**
* Sets the Inform version.
*
* @param version
* @since 3.2.0
* @internal
*/
export declare function setInformVersion(version: 6 | 7): void;
/**
* Runs all custom event listeners for the given event.
*
* @param eventName Event to remove
* @param meta Event metadata
* @since 3.2.0
* @internal
*/
export declare function triggerEvent(eventName: VorpleEventCategory, meta?: Partial): Promise;