Source: page/page_interface.js

/*   Skadi - A visual modelling tool for constructing directed graphs.

     Copyright (C) 2022-2024 Visual Topology Ltd

     Licensed under the MIT License
*/

var skadi = skadi || {};

/**
 * A callback that is called when a connection is established between the page and the node or configuration with which it is associated
 *
 * @callback skadi.PageInterface.connectedCallback
 */

/**
 * any value that can be serialised to or from JSON
 * @typedef JSONSerialisable
 */

/**
 * @callback skadi.PageInterface.messageReceivedCallback
 *
 * @param @param {...(string|ArrayBuffer|JSONSerialisable)} the message received, may be in multiple parts
 */

/**
 * An interface describing methods that the skadi.page instance provides.
 *
 * @interface
 * @type {skadi.PageInterface}
 */
skadi.PageInterface = class {

    /**
     * set a handler that is called when the page is connected to the node or configuration with which it is associated
     *
     * this handler will be called shortly after the page is loaded
     *
     * @param {skadi.PageInterface.connectedCallback} handler
     */
    set_connection_handler(handler) {
    }

    /**
     * set a handler that is called when a message is received from the node or configuration
     *
     * @param {skadi.PageInterface.messageReceivedCallback} handler
     */
    set_message_handler(handler) {
    }

    /**
     * Get the user's currently selected language code for the package.  Returns "" if no localisation is defined for the package.
     *
     * @return {string} language code (eg "jp") for selected localisation or ""
     */
    get_language() {
    }

    /**
     * localise a string using the package's localisation bundles and the user's currently selected language
     *
     * @param {string} input an input string to be localised
     *
     * @return {string} return the localised string, or the input string if no localisation was performed
     */
    localise_string(input) {
    }

    /**
     * attempt to localise all text found within the document's body which contains strings of the form "{{<key>}}"
     */
    localise_body() {
    }

    /**
     * send a message to the node or configuration
     *
     * @param {...(string|ArrayBuffer|JSONSerialisable)} message_parts
     */
    send_message(...message_parts) {
    }
}