<commit_before>/**
 * An execution runtime for editors.
 * @author <NAME>
 * @license MPL 2.0
 * @copyright Mangalam Research Center for Buddhist Languages
 */

import * as Promise from "bluebird";
import * as bluejax from "bluejax";
import { Dexie } from "dexie";
import * as mergeOptions from "merge-options";

import { make as ajax } from "./ajax";
import * as util from "./util";

/**
 * An object representing the runtime environment in which an editor is
 * running. In particular it allows loading external resources.
 */
export class Runtime {
  // tslint:disable-next-line:no-any
  private readonly options: any;

  public readonly ajax: bluejax.AjaxCall;
  public readonly ajax$: bluejax.AjaxCall$;

  // tslint:disable-next-line:no-any
  constructor(options: any) {
    // Make a private deep copy.
    options = mergeOptions({}, options);
    this.options = options;
    const bluejaxOptions = options.bluejaxOptions != null ?
      options.bluejaxOptions : {
      tries: 3,
      delay: 100,
      diagnose: {
        on: true,
        // It would be desirable to support this...
        // serverURL: "/ping",
        knownServers: [
          // tslint:disable:no-http-string
          "http://www.google.com/",
          "http://www.cloudfront.com/",
          // tslint:enable:no-http-string
        ],
      },
    };
    const made = ajax(bluejaxOptions);

    this.ajax = made.ajax;
    this.ajax$ = made.ajax$;<commit_msg>Use the real Options type and make options readable.<commit_after>/**
 * An execution runtime for editors.
 * @author <NAME>
 * @license MPL 2.0
 * @copyright Mangalam Research Center for Buddhist Languages
 */

import * as Promise from "bluebird";
import * as bluejax from "bluejax";
import { Dexie } from "dexie";
import * as mergeOptions from "merge-options";
import { Options } from "./options";

import { make as ajax } from "./ajax";
import * as util from "./util";

/**
 * An object representing the runtime environment in which an editor is
 * running. In particular it allows loading external resources.
 */
export class Runtime {
  readonly options: Options;

  public readonly ajax: bluejax.AjaxCall;
  public readonly ajax$: bluejax.AjaxCall$;

  constructor(options: Options) {
    // Make a deep copy.
    options = mergeOptions({}, options);
    this.options = options;
    const bluejaxOptions = options.bluejaxOptions != null ?
      options.bluejaxOptions : {
      tries: 3,
      delay: 100,
      diagnose: {
        on: true,
        // It would be desirable to support this...
        // serverURL: "/ping",
        knownServers: [
          // tslint:disable:no-http-string
          "http://www.google.com/",
          "http://www.cloudfront.com/",
          // tslint:enable:no-http-string
        ],
      },
    };
    const made = ajax(bluejaxOptions);

    this.ajax = made.ajax;
    this.ajax$ = made.ajax$;
{'fraction_non_alphanumeric': 0.12352532963219987, 'fraction_numerical': 0.004163775156141568, 'mean_word_length': 2.6309823677581865, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2179591', 'n_tokens_mistral': 859, 'n_tokens_neox': 823, 'n_words': 265}