Source: application_api.js

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

     Copyright (C) 2022-2026 Visual Topology Ltd

     Licensed under the MIT License
*/

var hyrrokkin = hyrrokkin || {};

hyrrokkin.api_home_url = document.currentScript.src.split("/").slice(0,-1).join("/");

hyrrokkin.ApplicationApi = class {

    /**
     * Create a hyrrokkin application view
     */
    constructor() {
        this.system = new hyrrokkin.ApplicationSystem();
    }

    /**
     * Set the language to be used for a package, use where the package defines localisation bundles
     *
     * @param {string} package_id
     * @param {string} language
     */
    set_package_language(package_id, language) {
        this.system.set_package_language(package_id, language);
    }

    /**
     * Initialise hyrrokkin application
     *
     * @param {string} application_id - the id of the application
     * @param {string} element_id - the name of the document element into which the application will be loaded
     * @param {Object} application_details - a JSON loaded definition of the application layout and cells
     * @param {Object} options - various options to customise hyrrokkin
     * @param {Object} plugins - various plugins to customise hyrrokkin
     */
    async init(application_id, element_id, application_details, options, model) {
        await this.system.init(application_id, element_id, application_details, options, model);
    }

    open() {
        this.system.open();
    }
}


 /**
  * Asynchronous function to create a hyrrokkin application widget
  *
  * @param {string} application_id - the id of the application
  * @param {string} element_id - the name of the document element into which the application will be loaded
  * @param {Object} application_details - a JSON loaded definition of the application layout and cells
  * @param {Object} options - various options to customise hyrrokkin
  * @param {Object} model - model implementation
  */
hyrrokkin.start_application = async function(application_id, element_id, application_details, options, model) {
    let hyrrokkin_instance = new hyrrokkin.ApplicationApi();
    await hyrrokkin_instance.init(application_id, element_id, application_details, options, model);
    return hyrrokkin_instance;
}