<commit_before>/*!
 * Toastify js 1.9.3
 * https://github.com/apvarun/toastify-js
 * @license MIT licensed
 *
 * Copyright (C) 2018 Varun A P
 */

/**
 * Options used for Toastify
 * @typedef {Object} ToastifyConfigurationObject
 * @property {string} text - Message to be displayed in the toast
 * @property {Element} node - Provide a node to be mounted inside the toast. node takes higher precedence over text
 * @property {number} duration - Duration for which the toast should be displayed. -1 for permanent toast
 * @property {string|Element} selector - CSS ID Selector on which the toast should be added
 * @property {url} destination - URL to which the browser should be navigated on click of the toast
 * @property {boolean} newWindow - Decides whether the destination should be opened in a new window or not
 * @property {boolean} close - To show the close icon or not
 * @property {string} gravity - To show the toast from top or bottom
 * @property {string} position - To show the toast on left or right
 * @property {string} backgroundColor - Sets the background color of the toast
 * @property {url} avatar - Image/icon to be shown before text
 * @property {string} className - Ability to provide custom class name for further customization
 * @property {boolean} stopOnFocus - To stop timer when hovered over the toast (Only if duration is set)
 * @property {Function} callback - Invoked when the toast is dismissed
 * @property {Function} onClick - Invoked when the toast is clicked
 * @property {Object} offset - Ability to add some offset to axis
 */

class Toastify {

    constructor(options) {
      /**
       * The version of Toastify
       * @type {string}
       * @public
       */
      this.version = "1.9.3";

      /**
       * The configuration object to configure Toastify
       * @type {ToastifyConfigurationObject}
       * @public
       */
      this.options = {};

      /**
       * The element that is the Toast
       * @type {Element}
       * @public
       */
      this.toastElement = null;

      /**
       * The root element that contains all the toasts
       * @type {Element}
       * @private
       */
      this._rootElement = document.body;

      this._init(options);
    }

    /**
     * Display the toast
     * @public
     */
    showToast() {
      // Creating the DOM object for the toast
      this.toastElement = this._buildToast();

      // Getting the root element to with the toast needs to be added
      if (typeof this.options.selector === "string") {
        this._rootElement = document.getElementById(this.options.selector);
      } else if (this.options.selector instanceof HTMLElement) {
        this._rootElement = this.options.selector;
      } else {
        this._rootElement = document.body;
      }

      // Validating if root element is present in DOM
      if (!this._rootElement) {
        throw "Root element is not defined";
      }

      // Adding the DOM element
      this._rootElement.insertBefore(this.toastElement, this._rootElement.firstChild);

      // Repositioning the toasts in case multiple toasts are present
      this._reposition();

      if (this.options.duration > 0) {
        this.toastElement.timeOutValue = window.setTimeout(
          () => {
            // Remove the toast from DOM
            this._removeElement(this.toastElement);
          },
          this.options.duration
        ); // Binding `this` for function invocation
      }

      // Supporting function chaining
      return this;
    }

    /**
     * Hide the toast
     * @public
     */
    hideToast() {
      if (this.toastElement.timeOutValue) {
        clearTimeout(this.toastElement.timeOutValue);
      }
      this._removeElement(this.toastElement);
    }

    /**
     * Init the Toastify class
     * @param {ToastifyConfigurationObject} options - The configuration object to configure Toastify
     * @param {string} [options.text=Hi there!] - Message to be displayed in the toast
     * @param {Element} [options.node] - Provide a node to be mounted inside the toast. node takes higher precedence over text
     * @param {number} [options.duration=3000] - Duration for which the toast should be displayed. -1 for permanent toast
     * @param {string} [options.selector] - CSS Selector on which the toast should be added
     * @param {url} [options.destination] - URL to which the browser should be navigated on click of the toast
     * @param {boolean} [options.newWindow=false] - Decides whether the destination should be opened in a new window or not
     * @param {boolean} [options.close=false] - To show the close icon or not
     * @param {string} [options.gravity=toastify-top] - To show the toast from top or bottom
     * @param {string} [options.position=right] - To show the toast on left or right
     * @param {string} [options.backgroundColor] - Sets the background color of the toast
     * @param {url} [options.avatar] - Image/icon to be shown before text
     * @param {string} [options.className] - Ability to provide custom class name for further customization
     * @param {boolean} [options.stopOnFocus] - To stop timer when hovered over the toast (Only if duration is set)
     * @param {Function} [options.callback] - Invoked when the toast is dismissed
     * @param {Function} [options.onClick] - Invoked when the toast is clicked
     * @param {Object} [options.offset] - Ability to add some offset to axis
     * @private
     */
    _init(options) {

      // Setting defaults
      this.options = Object.assign({
        text: "Hi there!",
        node: undefined,
        duration: 3000,
        selector: undefined,
        callback: function() {},
        destination: undefined,
        newWindow: false,
        close: false,
        gravity: "toastify-top",
        position: "right",
        backgroundColor: undefined,
        avatar: "",
        className: "",
        stopOnFocus: undefined,
        onClick: undefined,
        offset: {
          x: 0,
          y: 0
        }
      }, options);
      this.toastElement = null;

      this.options.gravity = options.gravity === "bottom" ? "toastify-bottom" : "toastify-top"; // toast position - top or bottom
      this.options.stopOnFocus = options.stopOnFocus === undefined ? true : options.stopOnFocus; // stop timeout on focus

    }

    /**
     * Build the Toastify element
     * @returns {Element}
     * @private
     */
    _buildToast() {
      // Validating if the options are defined
      if (!this.options) {
        throw "Toastify is not initialized";
      }

      // Creating the DOM object
      let divElement = document.createElement("div");
      divElement.className = "toastify on " + this.options.className;

      // Positioning toast to left or right or center (default right)
      divElement.className += " toastify-" + this.options.position;

      // Assigning gravity of element
      divElement.className += " " + this.options.gravity;

      if (this.options.backgroundColor) {
        divElement.style.background = this.options.backgroundColor;
      }

      // Adding the toast message/node
      if (this.options.node && this.options.node.nodeType === Node.ELEMENT_NODE) {
        // If we have a valid node, we insert it
        divElement.appendChild(this.options.node)
      } else {
        //TODO: Prevent/Warn of XSS issues with innerHTML
        divElement.innerHTML = this.options.text;

        if (this.options.avatar !== "") {
          var avatarElement = document.createElement("img");
          avatarElement.src = this.options.avatar;

          avatarElement.className = "toastify-avatar";

          if (this.options.position == "left") {
            // Adding close icon on the left of content
            divElement.appendChild(avatarElement);
          } else {
            // Adding close icon on the right of content
            divElement.insertAdjacentElement("afterbegin", avatarElement);
          }
        }
      }

      // Adding a close icon to the toast
      if (this.options.close === true) {
        // Create a span for close element
        let closeElement = document.createElement("span");
        closeElement.innerHTML = "✖";

        closeElement.className = "toast-close";

        // Triggering the removal of toast from DOM on close click
        closeElement.addEventListener(
          "click",
          (event) => {
            event.stopPropagation();
            this._removeElement(this.toastElement);
            window.clearTimeout(this.toastElement.timeOutValue);
          }
        );

        //Calculating screen width
        var width = window.innerWidth > 0 ? window.innerWidth : screen.width;

        // Adding the close icon to the toast element
        // Display on the right if screen width is less than or equal to 360px
        if ((this.options.position == "left") && width > 360) {
          // Adding close icon on the left of content
          divElement.insertAdjacentElement("afterbegin", closeElement);
        } else {
          // Adding close icon on the right of content
          divElement.appendChild(closeElement);
        }
      }

      // Clear timeout while toast is focused
      if (this.options.stopOnFocus && this.options.duration > 0) {
        // stop countdown
        divElement.addEventListener(
          "mouseover",
          (event) => {
            window.clearTimeout(divElement.timeOutValue);
          }
        )
        // add back the timeout
        divElement.addEventListener(
          "mouseleave",
          () => {
            divElement.timeOutValue = window.setTimeout(
              () => {
                // Remove the toast from DOM
                this._removeElement(divElement);
              },
              this.options.duration
            )
          }
        )
      }

      // Adding an on-click destination path
      if (typeof this.options.destination !== "undefined") {
        divElement.addEventListener(
          "click",
          (event) => {
            event.stopPropagation();
            if (this.options.newWindow === true) {
              window.open(this.options.destination, "_blank");
            } else {
              window.location = this.options.destination;
            }
          }
        );
      }

      if (typeof this.options.onClick === "function" && typeof this.options.destination === "undefined") {
        divElement.addEventListener(
          "click",
          (event) => {
            event.stopPropagation();
            this.options.onClick();
          }
        );
      }

      // Adding offset
      if (typeof this.options.offset === "object") {

        var x = getAxisOffsetAValue("x", this.options);
        var y = getAxisOffsetAValue("y", this.options);

        var xOffset = this.options.position == "left" ? x : "-" + x;
        var yOffset = this.options.gravity == "toastify-top" ? y : "-" + y;

        divElement.style.transform = "translate(" + xOffset + "," + yOffset + ")";

      }

      // Returning the generated element
      return divElement;
    }

    /**
     * Remove the toast from the DOM
     * @param {Element} toastElement
     */
    _removeElement(toastElement) {
      // Hiding the element
      toastElement.className = toastElement.className.replace(" on", "");

      // Removing the element from DOM after transition end
      window.setTimeout(
        () => {
          // remove options node if any
          if (this.options.node && this.options.node.parentNode) {
            this.options.node.parentNode.removeChild(this.options.node);
          }

          // Remove the elemenf from the DOM, only when the parent node was not removed before.
          if (toastElement.parentNode) {
            toastElement.parentNode.removeChild(toastElement);
          }

          // Calling the callback function
          this.options.callback.call(toastElement);

          // Repositioning the toasts again
          this._reposition();
        },
        400
      ); // Binding `this` for function invocation
    }

    /**
     * Position the toast on the DOM
     * @private
     */
    _reposition() {

      // Top margins with gravity
      let topLeftOffsetSize = {
        top: 15,
        bottom: 15,
      };
      let topRightOffsetSize = {
        top: 15,
        bottom: 15,
      };
      let offsetSize = {
        top: 15,
        bottom: 15,
      };

      // Get all toast messages that have been added to the container (selector)
      let allToasts = this._rootElement.getElementsByClassName("toastify");

      let classUsed;

      // Modifying the position of each toast element
      for (let i = 0; i < allToasts.length; i++) {
        // Getting the applied gravity
        if (allToasts[i].classList.contains("toastify-top") === true) {
          classUsed = "toastify-top";
        } else {
          classUsed = "toastify-bottom";
        }

        let height = allToasts[i].offsetHeight;
        classUsed = classUsed.substr(9, classUsed.length - 1)
        // Spacing between toasts
        let offset = 15;

        let width = window.innerWidth > 0 ? window.innerWidth : screen.width;

        // Show toast in center if screen with less than or qual to 360px
        if (width <= 360) {
          // Setting the position
          allToasts[i].style[classUsed] = offsetSize[classUsed] + "px";

          offsetSize[classUsed] += height + offset;
        } else {
          if (allToasts[i].classList.contains("toastify-left") === true) {
            // Setting the position
            allToasts[i].style[classUsed] = topLeftOffsetSize[classUsed] + "px";

            topLeftOffsetSize[classUsed] += height + offset;
          } else {
            // Setting the position
            allToasts[i].style[classUsed] = topRightOffsetSize[classUsed] + "px";

            topRightOffsetSize[classUsed] += height + offset;
          }
        }
      }
    }

  }

  /**
   * Helper function to get offset
   * @param {string} axis - 'x' or 'y'
   * @param {ToastifyConfigurationObject} options - The options object containing the offset object
   */
  function getAxisOffsetAValue(axis, options) {

    if (options.offset[axis]) {
      if (isNaN(options.offset[axis])) {
        return options.offset[axis];
      } else {
        return options.offset[axis] + 'px';
      }
    }

    return '0px';

  }

  // Returning the Toastify function to be assigned to the window object/module
  function StartToastifyInstance(options) {
    return new Toastify(options);
  }

  export default StartToastifyInstance;<commit_msg>Use template strings and bring in private function<commit_after>/*!
 * Toastify js 1.9.3
 * https://github.com/apvarun/toastify-js
 * @license MIT licensed
 *
 * Copyright (C) 2018 Varun A P
 */

/**
 * Options used for Toastify
 * @typedef {Object} ToastifyConfigurationObject
 * @property {string} text - Message to be displayed in the toast
 * @property {Element} node - Provide a node to be mounted inside the toast. node takes higher precedence over text
 * @property {number} duration - Duration for which the toast should be displayed. -1 for permanent toast
 * @property {string|Element} selector - CSS ID Selector on which the toast should be added
 * @property {url} destination - URL to which the browser should be navigated on click of the toast
 * @property {boolean} newWindow - Decides whether the destination should be opened in a new window or not
 * @property {boolean} close - To show the close icon or not
 * @property {string} gravity - To show the toast from top or bottom
 * @property {string} position - To show the toast on left or right
 * @property {string} backgroundColor - Sets the background color of the toast
 * @property {url} avatar - Image/icon to be shown before text
 * @property {string} className - Ability to provide custom class name for further customization
 * @property {boolean} stopOnFocus - To stop timer when hovered over the toast (Only if duration is set)
 * @property {Function} callback - Invoked when the toast is dismissed
 * @property {Function} onClick - Invoked when the toast is clicked
 * @property {Object} offset - Ability to add some offset to axis
 */

class Toastify {

    constructor(options) {
      /**
       * The version of Toastify
       * @type {string}
       * @public
       */
      this.version = "1.9.3";

      /**
       * The configuration object to configure Toastify
       * @type {ToastifyConfigurationObject}
       * @public
       */
      this.options = {};

      /**
       * The element that is the Toast
       * @type {Element}
       * @public
       */
      this.toastElement = null;

      /**
       * The root element that contains all the toasts
       * @type {Element}
       * @private
       */
      this._rootElement = document.body;

      this._init(options);
    }

    /**
     * Display the toast
     * @public
     */
    showToast() {
      // Creating the DOM object for the toast
      this.toastElement = this._buildToast();

      // Getting the root element to with the toast needs to be added
      if (typeof this.options.selector === "string") {
        this._rootElement = document.getElementById(this.options.selector);
      } else if (this.options.selector instanceof HTMLElement) {
        this._rootElement = this.options.selector;
      } else {
        this._rootElement = document.body;
      }

      // Validating if root element is present in DOM
      if (!this._rootElement) {
        throw "Root element is not defined";
      }

      // Adding the DOM element
      this._rootElement.insertBefore(this.toastElement, this._rootElement.firstChild);

      // Repositioning the toasts in case multiple toasts are present
      this._reposition();

      if (this.options.duration > 0) {
        this.toastElement.timeOutValue = window.setTimeout(
          () => {
            // Remove the toast from DOM
            this._removeElement(this.toastElement);
          },
          this.options.duration
        ); // Binding `this` for function invocation
      }

      // Supporting function chaining
      return this;
    }

    /**
     * Hide the toast
     * @public
     */
    hideToast() {
      if (this.toastElement.timeOutValue) {
        clearTimeout(this.toastElement.timeOutValue);
      }
      this._removeElement(this.toastElement);
    }

    /**
     * Init the Toastify class
     * @param {ToastifyConfigurationObject} options - The configuration object to configure Toastify
     * @param {string} [options.text=Hi there!] - Message to be displayed in the toast
     * @param {Element} [options.node] - Provide a node to be mounted inside the toast. node takes higher precedence over text
     * @param {number} [options.duration=3000] - Duration for which the toast should be displayed. -1 for permanent toast
     * @param {string} [options.selector] - CSS Selector on which the toast should be added
     * @param {url} [options.destination] - URL to which the browser should be navigated on click of the toast
     * @param {boolean} [options.newWindow=false] - Decides whether the destination should be opened in a new window or not
     * @param {boolean} [options.close=false] - To show the close icon or not
     * @param {string} [options.gravity=toastify-top] - To show the toast from top or bottom
     * @param {string} [options.position=right] - To show the toast on left or right
     * @param {string} [options.backgroundColor] - Sets the background color of the toast
     * @param {url} [options.avatar] - Image/icon to be shown before text
     * @param {string} [options.className] - Ability to provide custom class name for further customization
     * @param {boolean} [options.stopOnFocus] - To stop timer when hovered over the toast (Only if duration is set)
     * @param {Function} [options.callback] - Invoked when the toast is dismissed
     * @param {Function} [options.onClick] - Invoked when the toast is clicked
     * @param {Object} [options.offset] - Ability to add some offset to axis
     * @private
     */
    _init(options) {

      // Setting defaults
      this.options = Object.assign({
        text: "Hi there!",
        node: undefined,
        duration: 3000,
        selector: undefined,
        callback: function() {},
        destination: undefined,
        newWindow: false,
        close: false,
        gravity: "toastify-top",
        position: "right",
        backgroundColor: undefined,
        avatar: "",
        className: "",
        stopOnFocus: undefined,
        onClick: undefined,
        offset: {
          x: 0,
          y: 0
        }
      }, options);
      this.toastElement = null;

      this.options.gravity = options.gravity === "bottom" ? "toastify-bottom" : "toastify-top"; // toast position - top or bottom
      this.options.stopOnFocus = options.stopOnFocus === undefined ? true : options.stopOnFocus; // stop timeout on focus

    }

    /**
     * Build the Toastify element
     * @returns {Element}
     * @private
     */
    _buildToast() {
      // Validating if the options are defined
      if (!this.options) {
        throw "Toastify is not initialized";
      }

      // Creating the DOM object
      let divElement = document.createElement("div");
      divElement.className = `toastify on ${this.options.className}`;

      // Positioning toast to left or right or center (default right)
      divElement.className += ` toastify-${this.options.position}`;

      // Assigning gravity of element
      divElement.className += ` ${this.options.gravity}`;

      if (this.options.backgroundColor) {
        divElement.style.background = this.options.backgroundColor;
      }

      // Adding the toast message/node
      if (this.options.node && this.options.node.nodeType === Node.ELEMENT_NODE) {
        // If we have a valid node, we insert it
        divElement.appendChild(this.options.node)
      } else {
        //TODO: Prevent/Warn of XSS issues with innerHTML
        divElement.innerHTML = this.options.text;

        if (this.options.avatar !== "") {
          var avatarElement = document.createElement("img");
          avatarElement.src = this.options.avatar;

          avatarElement.className = "toastify-avatar";

          if (this.options.position == "left") {
            // Adding close icon on the left of content
            divElement.appendChild(avatarElement);
          } else {
            // Adding close icon on the right of content
            divElement.insertAdjacentElement("afterbegin", avatarElement);
          }
        }
      }

      // Adding a close icon to the toast
      if (this.options.close === true) {
        // Create a span for close element
        let closeElement = document.createElement("span");
        closeElement.innerHTML = "✖";

        closeElement.className = "toast-close";

        // Triggering the removal of toast from DOM on close click
        closeElement.addEventListener(
          "click",
          (event) => {
            event.stopPropagation();
            this._removeElement(this.toastElement);
            window.clearTimeout(this.toastElement.timeOutValue);
          }
        );

        //Calculating screen width
        var width = window.innerWidth > 0 ? window.innerWidth : screen.width;

        // Adding the close icon to the toast element
        // Display on the right if screen width is less than or equal to 360px
        if ((this.options.position == "left") && width > 360) {
          // Adding close icon on the left of content
          divElement.insertAdjacentElement("afterbegin", closeElement);
        } else {
          // Adding close icon on the right of content
          divElement.appendChild(closeElement);
        }
      }

      // Clear timeout while toast is focused
      if (this.options.stopOnFocus && this.options.duration > 0) {
        // stop countdown
        divElement.addEventListener(
          "mouseover",
          (event) => {
            window.clearTimeout(divElement.timeOutValue);
          }
        )
        // add back the timeout
        divElement.addEventListener(
          "mouseleave",
          () => {
            divElement.timeOutValue = window.setTimeout(
              () => {
                // Remove the toast from DOM
                this._removeElement(divElement);
              },
              this.options.duration
            )
          }
        )
      }

      // Adding an on-click destination path
      if (typeof this.options.destination !== "undefined") {
        divElement.addEventListener(
          "click",
          (event) => {
            event.stopPropagation();
            if (this.options.newWindow === true) {
              window.open(this.options.destination, "_blank");
            } else {
              window.location = this.options.destination;
            }
          }
        );
      }

      if (typeof this.options.onClick === "function" && typeof this.options.destination === "undefined") {
        divElement.addEventListener(
          "click",
          (event) => {
            event.stopPropagation();
            this.options.onClick();
          }
        );
      }

      // Adding offset
      if (typeof this.options.offset === "object") {

        var x = this._getAxisOffsetAValue("x", this.options);
        var y = this._getAxisOffsetAValue("y", this.options);

        var xOffset = this.options.position == "left" ? x : "-" + x;
        var yOffset = this.options.gravity == "toastify-top" ? y : "-" + y;

        divElement.style.transform = "translate(" + xOffset + "," + yOffset + ")";

      }

      // Returning the generated element
      return divElement;
    }

    /**
     * Remove the toast from the DOM
     * @param {Element} toastElement
     */
    _removeElement(toastElement) {
      // Hiding the element
      toastElement.className = toastElement.className.replace(" on", "");

      // Removing the element from DOM after transition end
      window.setTimeout(
        () => {
          // remove options node if any
          if (this.options.node && this.options.node.parentNode) {
            this.options.node.parentNode.removeChild(this.options.node);
          }

          // Remove the elemenf from the DOM, only when the parent node was not removed before.
          if (toastElement.parentNode) {
            toastElement.parentNode.removeChild(toastElement);
          }

          // Calling the callback function
          this.options.callback.call(toastElement);

          // Repositioning the toasts again
          this._reposition();
        },
        400
      ); // Binding `this` for function invocation
    }

    /**
     * Position the toast on the DOM
     * @private
     */
    _reposition() {

      // Top margins with gravity
      let topLeftOffsetSize = {
        top: 15,
        bottom: 15,
      };
      let topRightOffsetSize = {
        top: 15,
        bottom: 15,
      };
      let offsetSize = {
        top: 15,
        bottom: 15,
      };

      // Get all toast messages that have been added to the container (selector)
      let allToasts = this._rootElement.getElementsByClassName("toastify");

      let classUsed;

      // Modifying the position of each toast element
      for (let i = 0; i < allToasts.length; i++) {
        // Getting the applied gravity
        if (allToasts[i].classList.contains("toastify-top") === true) {
          classUsed = "toastify-top";
        } else {
          classUsed = "toastify-bottom";
        }

        let height = allToasts[i].offsetHeight;
        classUsed = classUsed.substr(9, classUsed.length - 1)
        // Spacing between toasts
        let offset = 15;

        let width = window.innerWidth > 0 ? window.innerWidth : screen.width;

        // Show toast in center if screen with less than or qual to 360px
        if (width <= 360) {
          // Setting the position
          allToasts[i].style[classUsed] = `${offsetSize[classUsed]}px`;

          offsetSize[classUsed] += height + offset;
        } else {
          if (allToasts[i].classList.contains("toastify-left") === true) {
            // Setting the position
            allToasts[i].style[classUsed] = `${topLeftOffsetSize[classUsed]}px`;

            topLeftOffsetSize[classUsed] += height + offset;
          } else {
            // Setting the position
            allToasts[i].style[classUsed] = `${topRightOffsetSize[classUsed]}px`;

            topRightOffsetSize[classUsed] += height + offset;
          }
        }
      }
    }

    /**
     * Helper function to get offset
     * @param {string} axis - 'x' or 'y'
     * @param {ToastifyConfigurationObject} options - The options object containing the offset object
     */
    _getAxisOffsetAValue(axis, options) {

      if (options.offset[axis]) {
        if (isNaN(options.offset[axis])) {
          return options.offset[axis];
        } else {
          return `${options.offset[axis]}px`;
        }
      }

      return '0px';

    }

  }

  // Returning the Toastify function to be assigned to the window object/module
  function StartToastifyInstance(options) {
    return new Toastify(options);
  }

  export default StartToastifyInstance;<|endoftext|>


<commit_before>// Application Configuration.
//
// Please see the /docs/APPLICATION_CONFIG.md documentation for more info.
//
// Note: all file/folder paths should be relative to the project root. The
// absolute paths should be resolved during runtime by our build tools/server.

import { getStringEnvVar, getIntEnvVar } from './internals/environmentVars';
import filterObject from './internals/filterObject';

// This protects us from accidentally including this configuration in our
// client bundle. That would be a big NO NO to do. :)
if (process.env.IS_CLIENT) {
  throw new Error("You shouldn't be importing the `./config` directly into your 'client' or 'shared' source as the configuration object will get included in your client bundle. Not a safe move! Instead, use the `safeConfigGet` helper function (located at `./src/shared/utils/config`) within the 'client' or 'shared' source files to reference configuration values in a safe manner.");
}

const config = {
  // The host on which the server should run.
  host: getStringEnvVar('SERVER_HOST', 'localhost'), // localhost

  // The port on which the server should run.
  port: getIntEnvVar('PORT', 1337),

  // The port on which the client bundle development server should run.
  clientDevServerPort: getIntEnvVar('CLIENT_DEVSERVER_PORT', 7331),

  // This is an example environment variable which is consumed within the
  // './client.js' config.  See there for more details.
  welcomeMessage: getStringEnvVar('WELCOME_MSG', 'Hello world!'),

  // Disable server side rendering?
  disableSSR: false,

  // How long should we set the browser cache for the served assets?
  // Don't worry, we add hashes to the files, so if they change the new files
  // will be served to browsers.
  // We are using the "ms" format to set the length.
  // @see https://www.npmjs.com/package/ms
  browserCacheMaxAge: '365d',

  // Path to the public assets that will be served off the root of the
  // HTTP server.
  publicAssetsPath: './public',

  // Where does our build output live?
  buildOutputPath: './build',

  // Should we optimize production builds (i.e. minify etc).
  // Sometimes you don't want this to happen to aid in debugging complex
  // problems.  Having this configuration flag here allows you to quickly
  // toggle the feature.
  optimizeProductionBuilds: true,

  // Do you want to included source maps (will be served as seperate files)
  // for production builds?
  includeSourceMapsForProductionBuilds: false,

  // Path to the shared src between the bundles.
  bundlesSharedSrcPath: './src/shared',

  // These extensions are tried when resolving src files for our bundles..
  bundleSrcTypes: ['js', 'jsx', 'json'],

  // Additional asset types to be supported for our bundles.
  // i.e. you can import the following file types within your source and the
  // webpack bundling process will bundle them with your source and create
  // URLs for them that can be resolved at runtime.
  bundleAssetTypes: [
    'jpg',
    'jpeg',
    'png',
    'gif',
    'ico',
    'eot',
    'svg',
    'ttf',
    'woff',
    'woff2',
    'otf',
  ],

  // What should we name the json output file that webpack generates
  // containing details of all output files for a bundle?
  bundleAssetsFileName: 'assets.json',

  // Extended configuration for the Content Security Policy (CSP)
  // @see src/server/middleware/security for more info.
  cspExtensions: {
    childSrc: [],
    connectSrc: [],
    defaultSrc: [],
    fontSrc: [],
    imgSrc: [],
    mediaSrc: [],
    manifestSrc: [],
    objectSrc: [],
    scriptSrc: [],
    styleSrc: [],
  },

  // node_modules are not included in any bundles that target "node" as a runtime
  // (i.e. the server bundle).
  // The node_modules may however contain files that will need to be processed by
  // one of our webpack loaders.
  // Add any required file types to the list below.
  nodeBundlesIncludeNodeModuleFileTypes: [
    /\.(eot|woff|woff2|ttf|otf)$/,
    /\.(svg|png|jpg|jpeg|gif|ico)$/,
    /\.(mp4|mp3|ogg|swf|webp)$/,
    /\.(css|scss|sass|sss|less)$/,
  ],

  // Note: you can only have a single service worker instance.  Our service
  // worker implementation is bound to the "client" and "server" bundles.
  // It includes the "client" bundle assets, as well as the public folder assets,
  // and it is served by the "server" bundle.
  serviceWorker: {
    // Enabled?
    enabled: true,
    // Service worker name
    fileName: 'sw.js',
    // Paths to the public assets which should be included within our
    // service worker. Relative to our public folder path, and accepts glob
    // syntax.
    includePublicAssets: [
      // NOTE: This will include ALL of our public folder assets.  We do
      // a glob pull of them and then map them to /foo paths as all the
      // public folder assets get served off the root of our application.
      // You may or may not want to be including these assets.  Feel free
      // to remove this or instead include only a very specific set of
      // assets.
      './**/*',
    ],
    // Path to the template used by HtmlWebpackPlugin to generate an offline
    // page that will be used by the service worker to render our application
    // offline.
    offlinePageTemplate: './tools/webpack/offlinePage',
    // Offline page file name.
    offlinePageFileName: 'offline.html',
  },

  // We use the polyfill.io service which provides the polyfills that a
  // client needs, which is far more optimal than the large output
  // generated by babel-polyfill.
  // Note: we have to keep this seperate from our "htmlPage" configuration
  // as the polyfill needs to be loaded BEFORE any of our other javascript
  // gets parsed.
  polyfillIO: {
    enabled: true,
    url: 'https://cdn.polyfill.io/v2/polyfill.min.js',
  },

  // Configuration for the HTML pages (headers/titles/scripts/css/etc).
  // We make use of react-helmet to consume the values below.
  // @see https://github.com/nfl/react-helmet
  htmlPage: {
    htmlAttributes: { lang: 'en' },
    titleTemplate: 'React, Universally - %s',
    defaultTitle: 'The Internet Home of Brett Snaidero',
    meta: [
      {
        name: 'description',
        content: 'Designer and front-end developer.',
      },
      // Default content encoding.
      { name: 'charset', content: 'utf-8' },
      // @see http://bit.ly/2f8IaqJ
      { 'http-equiv': 'X-UA-Compatible', content: 'IE=edge' },
      // This is important to signify your application is mobile responsive!
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      // Providing a theme color is good if you are doing a progressive
      // web application.
      { name: 'theme-color', content: '#2b2b2b' },
    ],
    links: [
      // When building a progressive web application you need to supply
      // a manifest.json as well as a variety of icon types. This can be
      // tricky. Luckily there is a service to help you with this.
      // http://realfavicongenerator.net/
      { rel: 'apple-touch-icon', sizes: '180x180', href: '/apple-touch-icon.png' },
      { rel: 'icon', type: 'image/png', href: '/favicon-32x32.png', sizes: '32x32' },
      { rel: 'icon', type: 'image/png', href: '/favicon-16x16.png', sizes: '16x16' },
      { rel: 'mask-icon', href: '/safari-pinned-tab.svg', color: '#00a9d9' },
      // Make sure you update your manifest.json to match your application.
      { rel: 'manifest', href: '/manifest.json' },
    ],
    scripts: [
      // Example:
      // { src: 'http://include.com/pathtojs.js', type: 'text/javascript' },
    ],
  },

  bundles: {
    client: {
      // Src entry file.
      srcEntryFile: './src/client/index.js',

      // Src paths.
      srcPaths: [
        './src/client',
        './src/shared',
        // The service worker offline page generation needs access to the
        // config folder.  Don't worry we have guards within the config files
        // to ensure they never get included in a client bundle.
        './config',
      ],

      // Where does the client bundle output live?
      outputPath: './build/client',

      // What is the public http path at which we must serve the bundle from?
      webPath: '/client/',

      // Configuration settings for the development vendor DLL.  This will be created
      // by our development server and provides an improved dev experience
      // by decreasing the number of modules that webpack needs to process
      // for every rebuild of our client bundle.  It by default uses the
      // dependencies configured in package.json however you can customise
      // which of these dependencies are excluded, whilst also being able to
      // specify the inclusion of additional modules below.
      devVendorDLL: {
        // Enabled?
        enabled: true,

        // Specify any dependencies that you would like to include in the
        // Vendor DLL.
        //
        // NOTE: It is also possible that some modules require specific
        // webpack loaders in order to be processed (e.g. CSS/SASS etc).
        // For these cases you don't want to include them in the Vendor DLL.
        include: [
          'code-split-component',
          'react',
          'react-dom',
          'react-helmet',
          'react-router',
        ],

        // The name of the vendor DLL.
        name: '__dev_vendor_dll__',
      },
    },

    server: {
      // Src entry file.
      srcEntryFile: './src/server/index.js',

      // Src paths.
      srcPaths: [
        './src/server',
        './src/shared',
        './config',
      ],

      // Where does the server bundle output live?
      outputPath: './build/server',
    },
  },

  additionalNodeBundles: {
    // NOTE: The webpack configuration and build scripts have been built so
    // that you can add arbitrary additional node bundle configurations here.
    //
    // A common requirement for larger projects is to add additional "node"
    // target bundles (e.g an APi server endpoint). Therefore flexibility has been
    // baked into our webpack config factory to allow for this.
    //
    // Simply define additional configurations similar to below.  The development
    // server will manage starting them up for you.  The only requirement is that
    // within the entry for each bundle you create and return the "express"
    // listener.
    /*
    apiServer: {
      srcEntryFile: './src/api/index.js',
      srcPaths: [
        './src/api',
        './src/shared',
        './config',
      ],
      outputPath: './build/api',
    }
    */
  },

  // These plugin definitions provide you with advanced hooks into customising
  // the project without having to reach into the internals of the tools.
  //
  // We have decided to create this plugin approach so that you can come to
  // a centralised configuration folder to do most of your application
  // configuration adjustments.  Additionally it helps to make merging
  // from the origin starter kit a bit easier.
  plugins: {
    // This plugin allows you to provide final adjustments your babel
    // configurations for each bundle before they get processed.
    //
    // This function will be called once for each for your bundles.  It will be
    // provided the current webpack config, as well as the buildOptions which
    // detail which bundle and mode is being targetted for the current function run.
    babelConfig: (babelConfig, buildOptions) => {
      // eslint-disable-next-line no-unused-vars
      const { target, mode } = buildOptions;

      // Example
      /*
      if (target === 'server' && mode === 'development') {
        babelConfig.presets.push('foo');
      }
     */

      return babelConfig;
    },

    // This plugin allows you to provide final adjustments your webpack
    // configurations for each bundle before they get processed.
    //
    // I would recommend looking at the "webpack-merge" module to help you with
    // merging modifications to each config.
    //
    // This function will be called once for each for your bundles.  It will be
    // provided the current webpack config, as well as the buildOptions which
    // detail which bundle and mode is being targetted for the current function run.
    webpackConfig: (webpackConfig, buildOptions) => {
      // eslint-disable-next-line no-unused-vars
      const { target, mode } = buildOptions;

      // Example:
      /*
      if (target === 'server' && mode === 'development') {
        webpackConfig.plugins.push(new MyCoolWebpackPlugin());
      }
      */

      // Debugging/Logging Example:
      /*
      if (target === 'server') {
        console.log(JSON.stringify(webpackConfig, null, 4));
      }
      */

      return webpackConfig;
    },
  },
};

// Export the client configuration object.
export const clientConfig = filterObject(
  // We will filter our full application configuration object...
  config,
  // using the rules below in order to create our filtered client configuration
  // object.
  //
  // This object will be bound to the window.__CLIENT_CONFIG__
  // property which is where client code should be referencing it from.
  // As we generally have shared code between our node/browser code we have
  // created a helper function in "./src/shared/utils/config" that you can used
  // to request config values from.  It will make sure that either the
  // application config file is used (i.e. this file), or the
  // window.__CLIENT_CONFIG__ is used.  This avoids boilerplate throughout your
  // shared code.  We recommend using this helper anytime you need a config
  // value within either the "client" or "shared" folder (i.e. any folders
  // that contain code which will end up in the browser).
  //
  // This is a filter that will be applied to our configuration in order to
  // determine which of our configuration values will be provided to the client
  // bundle.
  //
  // For security reasons you wouldn't want to make all of the configuration values
  // accessible by client bundles as these values would essentially be getting
  // transported over the wire to user's browsers.  There are however cases
  // where you may want to expose one or two of the values within a client bundle.
  //
  // This filter object must match the shape of the configuration object, however
  // you need not specify every property that is defined within the configuration
  // object.  Simply define the properties you would like to be included in the
  // client config, supplying a truthy value to them in order to ensure they
  // get included in the client bundle.
  {
    // This is here as an example showing that you can expose environment
    // variables too.
    welcomeMessage: true,
    // We only need to expose the enabled flag of the service worker.
    serviceWorker: {
      enabled: true,
    },
    // We need to expose all the polyfill.io settings.
    polyfillIO: true,
    // We need to expose all the htmlPage settings.
    htmlPage: true,
    additionalNodeBundles: true,
  },
);

// Export the main config as the default export.
export default config;
<commit_msg>Button hover<commit_after>// Application Configuration.
//
// Please see the /docs/APPLICATION_CONFIG.md documentation for more info.
//
// Note: all file/folder paths should be relative to the project root. The
// absolute paths should be resolved during runtime by our build tools/server.

import { getStringEnvVar, getIntEnvVar } from './internals/environmentVars';
import filterObject from './internals/filterObject';

// This protects us from accidentally including this configuration in our
// client bundle. That would be a big NO NO to do. :)
if (process.env.IS_CLIENT) {
  throw new Error("You shouldn't be importing the `./config` directly into your 'client' or 'shared' source as the configuration object will get included in your client bundle. Not a safe move! Instead, use the `safeConfigGet` helper function (located at `./src/shared/utils/config`) within the 'client' or 'shared' source files to reference configuration values in a safe manner.");
}

const config = {
  // The host on which the server should run.
  host: getStringEnvVar('SERVER_HOST', 'http://brettsnaidero.com/'), // localhost

  // The port on which the server should run.
  port: getIntEnvVar('PORT', 1337),

  // The port on which the client bundle development server should run.
  clientDevServerPort: getIntEnvVar('CLIENT_DEVSERVER_PORT', 7331),

  // This is an example environment variable which is consumed within the
  // './client.js' config.  See there for more details.
  welcomeMessage: getStringEnvVar('WELCOME_MSG', 'Hello world!'),

  // Disable server side rendering?
  disableSSR: false,

  // How long should we set the browser cache for the served assets?
  // Don't worry, we add hashes to the files, so if they change the new files
  // will be served to browsers.
  // We are using the "ms" format to set the length.
  // @see https://www.npmjs.com/package/ms
  browserCacheMaxAge: '365d',

  // Path to the public assets that will be served off the root of the
  // HTTP server.
  publicAssetsPath: './public',

  // Where does our build output live?
  buildOutputPath: './build',

  // Should we optimize production builds (i.e. minify etc).
  // Sometimes you don't want this to happen to aid in debugging complex
  // problems.  Having this configuration flag here allows you to quickly
  // toggle the feature.
  optimizeProductionBuilds: true,

  // Do you want to included source maps (will be served as seperate files)
  // for production builds?
  includeSourceMapsForProductionBuilds: false,

  // Path to the shared src between the bundles.
  bundlesSharedSrcPath: './src/shared',

  // These extensions are tried when resolving src files for our bundles..
  bundleSrcTypes: ['js', 'jsx', 'json'],

  // Additional asset types to be supported for our bundles.
  // i.e. you can import the following file types within your source and the
  // webpack bundling process will bundle them with your source and create
  // URLs for them that can be resolved at runtime.
  bundleAssetTypes: [
    'jpg',
    'jpeg',
    'png',
    'gif',
    'ico',
    'eot',
    'svg',
    'ttf',
    'woff',
    'woff2',
    'otf',
  ],

  // What should we name the json output file that webpack generates
  // containing details of all output files for a bundle?
  bundleAssetsFileName: 'assets.json',

  // Extended configuration for the Content Security Policy (CSP)
  // @see src/server/middleware/security for more info.
  cspExtensions: {
    childSrc: [],
    connectSrc: [],
    defaultSrc: [],
    fontSrc: [],
    imgSrc: [],
    mediaSrc: [],
    manifestSrc: [],
    objectSrc: [],
    scriptSrc: [],
    styleSrc: [],
  },

  // node_modules are not included in any bundles that target "node" as a runtime
  // (i.e. the server bundle).
  // The node_modules may however contain files that will need to be processed by
  // one of our webpack loaders.
  // Add any required file types to the list below.
  nodeBundlesIncludeNodeModuleFileTypes: [
    /\.(eot|woff|woff2|ttf|otf)$/,
    /\.(svg|png|jpg|jpeg|gif|ico)$/,
    /\.(mp4|mp3|ogg|swf|webp)$/,
    /\.(css|scss|sass|sss|less)$/,
  ],

  // Note: you can only have a single service worker instance.  Our service
  // worker implementation is bound to the "client" and "server" bundles.
  // It includes the "client" bundle assets, as well as the public folder assets,
  // and it is served by the "server" bundle.
  serviceWorker: {
    // Enabled?
    enabled: true,
    // Service worker name
    fileName: 'sw.js',
    // Paths to the public assets which should be included within our
    // service worker. Relative to our public folder path, and accepts glob
    // syntax.
    includePublicAssets: [
      // NOTE: This will include ALL of our public folder assets.  We do
      // a glob pull of them and then map them to /foo paths as all the
      // public folder assets get served off the root of our application.
      // You may or may not want to be including these assets.  Feel free
      // to remove this or instead include only a very specific set of
      // assets.
      './**/*',
    ],
    // Path to the template used by HtmlWebpackPlugin to generate an offline
    // page that will be used by the service worker to render our application
    // offline.
    offlinePageTemplate: './tools/webpack/offlinePage',
    // Offline page file name.
    offlinePageFileName: 'offline.html',
  },

  // We use the polyfill.io service which provides the polyfills that a
  // client needs, which is far more optimal than the large output
  // generated by babel-polyfill.
  // Note: we have to keep this seperate from our "htmlPage" configuration
  // as the polyfill needs to be loaded BEFORE any of our other javascript
  // gets parsed.
  polyfillIO: {
    enabled: true,
    url: 'https://cdn.polyfill.io/v2/polyfill.min.js',
  },

  // Configuration for the HTML pages (headers/titles/scripts/css/etc).
  // We make use of react-helmet to consume the values below.
  // @see https://github.com/nfl/react-helmet
  htmlPage: {
    htmlAttributes: { lang: 'en' },
    titleTemplate: 'React, Universally - %s',
    defaultTitle: 'The Internet Home of Brett Snaidero',
    meta: [
      {
        name: 'description',
        content: 'Designer and front-end developer.',
      },
      // Default content encoding.
      { name: 'charset', content: 'utf-8' },
      // @see http://bit.ly/2f8IaqJ
      { 'http-equiv': 'X-UA-Compatible', content: 'IE=edge' },
      // This is important to signify your application is mobile responsive!
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      // Providing a theme color is good if you are doing a progressive
      // web application.
      { name: 'theme-color', content: '#2b2b2b' },
    ],
    links: [
      // When building a progressive web application you need to supply
      // a manifest.json as well as a variety of icon types. This can be
      // tricky. Luckily there is a service to help you with this.
      // http://realfavicongenerator.net/
      { rel: 'apple-touch-icon', sizes: '180x180', href: '/apple-touch-icon.png' },
      { rel: 'icon', type: 'image/png', href: '/favicon-32x32.png', sizes: '32x32' },
      { rel: 'icon', type: 'image/png', href: '/favicon-16x16.png', sizes: '16x16' },
      { rel: 'mask-icon', href: '/safari-pinned-tab.svg', color: '#00a9d9' },
      // Make sure you update your manifest.json to match your application.
      { rel: 'manifest', href: '/manifest.json' },
    ],
    scripts: [
      // Example:
      // { src: 'http://include.com/pathtojs.js', type: 'text/javascript' },
    ],
  },

  bundles: {
    client: {
      // Src entry file.
      srcEntryFile: './src/client/index.js',

      // Src paths.
      srcPaths: [
        './src/client',
        './src/shared',
        // The service worker offline page generation needs access to the
        // config folder.  Don't worry we have guards within the config files
        // to ensure they never get included in a client bundle.
        './config',
      ],

      // Where does the client bundle output live?
      outputPath: './build/client',

      // What is the public http path at which we must serve the bundle from?
      webPath: '/client/',

      // Configuration settings for the development vendor DLL.  This will be created
      // by our development server and provides an improved dev experience
      // by decreasing the number of modules that webpack needs to process
      // for every rebuild of our client bundle.  It by default uses the
      // dependencies configured in package.json however you can customise
      // which of these dependencies are excluded, whilst also being able to
      // specify the inclusion of additional modules below.
      devVendorDLL: {
        // Enabled?
        enabled: true,

        // Specify any dependencies that you would like to include in the
        // Vendor DLL.
        //
        // NOTE: It is also possible that some modules require specific
        // webpack loaders in order to be processed (e.g. CSS/SASS etc).
        // For these cases you don't want to include them in the Vendor DLL.
        include: [
          'code-split-component',
          'react',
          'react-dom',
          'react-helmet',
          'react-router',
        ],

        // The name of the vendor DLL.
        name: '__dev_vendor_dll__',
      },
    },

    server: {
      // Src entry file.
      srcEntryFile: './src/server/index.js',

      // Src paths.
      srcPaths: [
        './src/server',
        './src/shared',
        './config',
      ],

      // Where does the server bundle output live?
      outputPath: './build/server',
    },
  },

  additionalNodeBundles: {
    // NOTE: The webpack configuration and build scripts have been built so
    // that you can add arbitrary additional node bundle configurations here.
    //
    // A common requirement for larger projects is to add additional "node"
    // target bundles (e.g an APi server endpoint). Therefore flexibility has been
    // baked into our webpack config factory to allow for this.
    //
    // Simply define additional configurations similar to below.  The development
    // server will manage starting them up for you.  The only requirement is that
    // within the entry for each bundle you create and return the "express"
    // listener.
    /*
    apiServer: {
      srcEntryFile: './src/api/index.js',
      srcPaths: [
        './src/api',
        './src/shared',
        './config',
      ],
      outputPath: './build/api',
    }
    */
  },

  // These plugin definitions provide you with advanced hooks into customising
  // the project without having to reach into the internals of the tools.
  //
  // We have decided to create this plugin approach so that you can come to
  // a centralised configuration folder to do most of your application
  // configuration adjustments.  Additionally it helps to make merging
  // from the origin starter kit a bit easier.
  plugins: {
    // This plugin allows you to provide final adjustments your babel
    // configurations for each bundle before they get processed.
    //
    // This function will be called once for each for your bundles.  It will be
    // provided the current webpack config, as well as the buildOptions which
    // detail which bundle and mode is being targetted for the current function run.
    babelConfig: (babelConfig, buildOptions) => {
      // eslint-disable-next-line no-unused-vars
      const { target, mode } = buildOptions;

      // Example
      /*
      if (target === 'server' && mode === 'development') {
        babelConfig.presets.push('foo');
      }
     */

      return babelConfig;
    },

    // This plugin allows you to provide final adjustments your webpack
    // configurations for each bundle before they get processed.
    //
    // I would recommend looking at the "webpack-merge" module to help you with
    // merging modifications to each config.
    //
    // This function will be called once for each for your bundles.  It will be
    // provided the current webpack config, as well as the buildOptions which
    // detail which bundle and mode is being targetted for the current function run.
    webpackConfig: (webpackConfig, buildOptions) => {
      // eslint-disable-next-line no-unused-vars
      const { target, mode } = buildOptions;

      // Example:
      /*
      if (target === 'server' && mode === 'development') {
        webpackConfig.plugins.push(new MyCoolWebpackPlugin());
      }
      */

      // Debugging/Logging Example:
      /*
      if (target === 'server') {
        console.log(JSON.stringify(webpackConfig, null, 4));
      }
      */

      return webpackConfig;
    },
  },
};

// Export the client configuration object.
export const clientConfig = filterObject(
  // We will filter our full application configuration object...
  config,
  // using the rules below in order to create our filtered client configuration
  // object.
  //
  // This object will be bound to the window.__CLIENT_CONFIG__
  // property which is where client code should be referencing it from.
  // As we generally have shared code between our node/browser code we have
  // created a helper function in "./src/shared/utils/config" that you can used
  // to request config values from.  It will make sure that either the
  // application config file is used (i.e. this file), or the
  // window.__CLIENT_CONFIG__ is used.  This avoids boilerplate throughout your
  // shared code.  We recommend using this helper anytime you need a config
  // value within either the "client" or "shared" folder (i.e. any folders
  // that contain code which will end up in the browser).
  //
  // This is a filter that will be applied to our configuration in order to
  // determine which of our configuration values will be provided to the client
  // bundle.
  //
  // For security reasons you wouldn't want to make all of the configuration values
  // accessible by client bundles as these values would essentially be getting
  // transported over the wire to user's browsers.  There are however cases
  // where you may want to expose one or two of the values within a client bundle.
  //
  // This filter object must match the shape of the configuration object, however
  // you need not specify every property that is defined within the configuration
  // object.  Simply define the properties you would like to be included in the
  // client config, supplying a truthy value to them in order to ensure they
  // get included in the client bundle.
  {
    // This is here as an example showing that you can expose environment
    // variables too.
    welcomeMessage: true,
    // We only need to expose the enabled flag of the service worker.
    serviceWorker: {
      enabled: true,
    },
    // We need to expose all the polyfill.io settings.
    polyfillIO: true,
    // We need to expose all the htmlPage settings.
    htmlPage: true,
    additionalNodeBundles: true,
  },
);

// Export the main config as the default export.
export default config;
<|endoftext|>


<commit_before>'use strict';

goog.provide('Blockly.ClojureScriptOptimized.appshare');

goog.require('Blockly.ClojureScriptOptimizedOptimized');

Blockly.ClojureScriptOptimized['appshare_app'] = function(block) {
  var main_app = Blockly.ClojureScriptOptimized.statementToCode(block, 'main application element');
  var textval = block.getFieldValue('VALUE') ;
  var code = '(defn-ui-component     main   [app] {}\n\
       (div   nil  ' + main_app + ' \"' + textval + '"\n\
    ))  ';
  return code;
};

Blockly.ClojureScriptOptimized['appshare_ui_component'] = function(block) {
  var main_div = Blockly.ClojureScriptOptimized.statementToCode(block, 'main div element');
  var code = '(defn main [app  owner]                                                          \n\
    (reify                                                                                \n\
          om.core/IRender                                                                       \n\
          (render [this]                                                                        \n\
                                                                                \n\
                    (let [                                                                      \n\
                            ui-state   app                                                     \n\
                            path       (om.core/get-state owner :parent-path)                     \n\
                                                                                \n\
                            return-val (webapp.framework.client.coreclient/debug-react          \n\
                                          "main"                                                \n\
                                          owner                                                 \n\
                                          app                                                  \n\
                                          (fn [app]                                            \n\
                                                (om.dom/div nil ' + main_div + '))               \n\
                                          path                                                   \n\
                                          )                                                    \n\
                            ]                                                                   \n\
                      return-val))))';

  return code;
};

Blockly.ClojureScriptOptimized['appshare_div'] = function(block) {
  // TODO: Assemble JavaScript into code variable.

  var value_attributes = Blockly.ClojureScriptOptimized.statementToCode(block, 'ATTRIBUTES');

  var statements_more_elements = Blockly.ClojureScriptOptimized.statementToCode(block, 'more elements');

  var code = ' (om.dom/div  nil ' + value_attributes + ' ' +
      statements_more_elements +
      ') n' ;
  return code;
};

Blockly.ClojureScriptOptimized['appshare_element_attribute'] = function(block) {
  return " {:style {:" + block.getFieldValue('style') + ' \"' + block.getFieldValue('value') + "\"}} ";
};

Blockly.ClojureScriptOptimized['appshare_no_attributes'] = function(block) {
  return "nil";
};

Blockly.ClojureScriptOptimized['appshare_element_text'] = function(block) {
  // TODO: Assemble JavaScript into code variable.

  var value_attributes = ''   + block.getFieldValue('VALUE')

  var code = '\n "' + value_attributes + '" ' + '\n' ;

  return code;
};

Blockly.ClojureScriptOptimized['appshare_element_header'] = function(block) {
  // TODO: Assemble JavaScript into code variable.

  var value_attributes = ''   + block.getFieldValue('VALUE')

  var code = '(om.dom/div  (webapp.framework.client.coreclient/attrs  {:style {:fontSize "3em" :display "inline-block"}}) "' + value_attributes + '"' + ')\n' ;

  return code;
};

Blockly.ClojureScriptOptimized['appshare_element_br'] = function(block) {
  // TODO: Assemble JavaScript into code variable.

  var code = ' (om.dom/div nil "") ' ;

  return code;
};

Blockly.ClojureScriptOptimized['appshare_element_box'] = function(block) {
  // TODO: Assemble JavaScript into code variable.

  var code = ' (om.dom/div  (webapp.framework.client.coreclient/attrs {:style {:border "1px solid black" :width "200px" :height "200px" :display "inline-block"}}) "") ' ;

  return code;
};

Blockly.ClojureScriptOptimized['appshare_element_left_padding'] = function(block) {
  // TODO: Assemble JavaScript into code variable.

  var code = ' (om.dom/div  (webapp.framework.client.coreclient/attrs  {:style {:padding "10px" :display "inline-block"}}) "") ' ;

  return code;
};

Blockly.ClojureScriptOptimized['appshare_element_top_padding'] = function(block) {
  // TODO: Assemble JavaScript into code variable.

  var code = ' (om.dom/div  (webapp.framework.client.coreclient/attrs  {:style {:padding "10px" }}) "") ' ;

  return code;
};

Blockly.ClojureScriptOptimized['appshare_custom_component'] = function(block) {
  // TODO: Assemble JavaScript into code variable.

  var value_attributes = ''   + block.getFieldValue('COMPONENT_NAME');
  var main_div = Blockly.ClojureScriptOptimized.statementToCode(block, 'main div element');
  var code = ' (defn ' + value_attributes +  ' [app  owner]                                      \n\
    (reify                                                                                \n\
          om.core/IRender                                                                       \n\
          (render [this]                                                                        \n\
                                                                                \n\
                    (let [                                                                      \n\
                            ui-state   app                                                      \n\
                            path       (om.core/get-state owner :parent-path)                   \n\
                                                                                \n\
                            return-val (webapp.framework.client.coreclient/debug-react          \n\
                                          "main"                                                \n\
                                          owner                                                 \n\
                                          app                                                   \n\
                                          (fn [app]                                             \n\
                                                (om.dom/div nil ' + main_div + '))              \n\
                                          path                                                  \n\
                                          )                                                     \n\
                            ]                                                                   \n\
                      return-val)))) ';

  return code;
};

Blockly.ClojureScriptOptimized['appshare_call_custom_component'] = function(block) {
  // TODO: Assemble JavaScript into code variable.

  var value_attributes = ''   + block.getFieldValue('COMPONENT_NAME_VALUE');
  var code = '(om.dom/div (webapp.framework.client.coreclient/attrs {:style {:display "inline-block"}}) (webapp.framework.client.coreclient/component-fn  ' + value_attributes + '  app     []   [])) ';
//code = '(om.dom/div nil " - ")';

  return code;
};

var tttt=0;

Blockly.ClojureScriptOptimized['appshare_db_component'] = function(block) {
  //var code = '(realtime select id, field1  from test {}  (<-- ))' ;
  //(sql-parser  "select" ~@select-args)
  var table_name = ''   + block.getFieldValue('VALUE');
  var field_names = ''   + block.getFieldValue('DB_FIELDS');
  var statements_more_elements = Blockly.ClojureScriptOptimized.statementToCode(block, 'more elements');

  tttt ++;
  var code = '(let                                                                                \n\
                [relative-path-id2   (str (cljs-uuid-utils.core/make-random-uuid))                  \n\
                relative-path-id   ' + tttt + '                                                     \n\
                 data                                                                               \n\
                 (webapp.framework.client.coreclient/data-window-fn                                 \n\
                   (clojure.core/merge                                                              \n\
                     {:relative-path [relative-path-id]}                                            \n\
                     (if                                                                            \n\
                       select-id                                                                    \n\
                       (merge                                                                       \n\
                         {:fields [' + field_names + ' ],                                           \n\
                          :db-table "' + table_name +  '",                                          \n\
                          :relative-path [relative-path-id],                                        \n\
                          :params nil,                                                              \n\
                          :realtime true,                                                           \n\
                          :data-source :' + table_name +  '}                                        \n\
                         {:relative-path                                                            \n\
                          (conj                                                                     \n\
                            (conj                                                                   \n\
                              (get                                                                  \n\
                                {:fields [ ' + field_names + ' ],                                   \n\
                                 :db-table "' + table_name +  '",                                   \n\
                                 :relative-path [relative-path-id],                                 \n\
                                 :params nil,                                                       \n\
                                 :data-source :' + table_name +  '}                                 \n\
                                :relative-path)                                                     \n\
                              :values)                                                              \n\
                            select-id)})                                                            \n\
                       {:fields [ ' + field_names + ' ],                                            \n\
                        :db-table "' + table_name +  '",                                            \n\
                          :realtime true,                                                           \n\
                        :relative-path [relative-path-id],                                          \n\
                        :params nil,                                                                \n\
                        :data-source :' + table_name +  '}))                                        \n\
                   {:start 1, :end 20}                                                              \n\
                   ui-component-name                                                                \n\
                   path                                                                             \n\
                   ui-state)                                                                        \n\
                 data-order                                                                         \n\
                 (-> data :order)]                                                                  \n\
                                                                                \n\
  (om.dom/div                                                                                \n\
    nil                                                                                \n\
    (apply                                                                                \n\
         om.dom/div nil                                                                             \n\
         (map                                                                                \n\
     (fn [record-id]                                                                                \n\
                    (let                                                                            \n\
                      [relative-path                                                                \n\
                        (:relative-path                                                             \n\
                               (if                                                                  \n\
                                 select-id                                                          \n\
                                   (merge                                                           \n\
                                   {:fields [' + field_names + ' ],                                 \n\
                                    :db-table "' + table_name +  '",                                \n\
                          :realtime true,                                                           \n\
                                    :relative-path [relative-path-id],                              \n\
                                    :params nil,                                                    \n\
                                    :data-source :' + table_name +  '}                              \n\
                                   {:relative-path                                                  \n\
                                    (conj                                                           \n\
                                      (conj                                                         \n\
                                        (get                                                        \n\
                                          {:fields [' + field_names + ' ],                          \n\
                                           :db-table "' + table_name +  '",                         \n\
                                           :relative-path [relative-path-id],                       \n\
                                           :params nil,                                             \n\
                                           :data-source :' + table_name +  '}                       \n\
                                          :relative-path)                                           \n\
                                        :values)                                                    \n\
                                      select-id)})                                                  \n\
                  {:fields [' + field_names + ' ],                                                  \n\
                                  :db-table "' + table_name +  '",                                  \n\
                          :realtime true,                                                           \n\
                                  :relative-path [relative-path-id],                                \n\
                                  :params nil,                                                      \n\
                                  :data-source :' + table_name +  '}))                              \n\
                             record                                                                 \n\
                             (get (-> data :values) record-id)                                      \n\
                             select-id                                                              \n\
                             (get-in record [:value :id])]                                          \n\
                            (if (clojure.core/get record :value) (om.dom/div {} (om.dom/div nil     \n\
                             " " ' + statements_more_elements + '                                   \n\
                            )))))                                                                  \n\
      (map                                                                                \n\
        (fn [x] (get data-order x))                                                                 \n\
        (range (:start {:start 1, :end 20})                                                         \n\
               (inc (min (:end {:start 1, :end 20}) (-> data :count))))))))) ';

  //console.log(code);
  return code;
};

Blockly.ClojureScriptOptimized['appshare_db_field'] = function(block) {
  var value_attributes = ''   + block.getFieldValue('VALUE');
  var code = ' (webapp.framework.client.coreclient/<---fn   record  :' + value_attributes +  '  path  relative-path  )   ' + ' ';
  return code;
};

Blockly.ClojureScriptOptimized['appshare_show_tables'] = function(block) {
  var code = ' (om.dom/div  nil                                                                                \n\
                   (apply                                                                                \n\
                         om.dom/div nil                                                                                \n\
                         (map                                                                                \n\
                             (fn [table-name]                                                                           \n\
                                 (om.dom/div nil (str table-name)))                                                     \n\
                            (get-in @webapp.framework.client.system-globals/app-state [:ui :table-list])                \n\
         ))) ';
  return code;
};

Blockly.ClojureScriptOptimized['appshare_input_field'] = function(block) {
  var code = ' (om.dom/input {:style {:marginBottom "20px"} :placeholder  "Enter a new todo here"}            \n\
                               ) ';
  return code;
};
<commit_msg>Input field can detect which key pressed<commit_after>'use strict';

goog.provide('Blockly.ClojureScriptOptimized.appshare');

goog.require('Blockly.ClojureScriptOptimizedOptimized');

Blockly.ClojureScriptOptimized['appshare_app'] = function(block) {
  var main_app = Blockly.ClojureScriptOptimized.statementToCode(block, 'main application element');
  var textval = block.getFieldValue('VALUE') ;
  var code = '(defn-ui-component     main   [app] {}\n\
       (div   nil  ' + main_app + ' \"' + textval + '"\n\
    ))  ';
  return code;
};

Blockly.ClojureScriptOptimized['appshare_ui_component'] = function(block) {
  var main_div = Blockly.ClojureScriptOptimized.statementToCode(block, 'main div element');
  var code = '(defn main [app  owner]                                                          \n\
    (reify                                                                                \n\
          om.core/IRender                                                                       \n\
          (render [this]                                                                        \n\
                                                                                \n\
                    (let [                                                                      \n\
                            ui-state   app                                                     \n\
                            path       (om.core/get-state owner :parent-path)                     \n\
                                                                                \n\
                            return-val (webapp.framework.client.coreclient/debug-react          \n\
                                          "main"                                                \n\
                                          owner                                                 \n\
                                          app                                                  \n\
                                          (fn [app]                                            \n\
                                                (om.dom/div nil ' + main_div + '))               \n\
                                          path                                                   \n\
                                          )                                                    \n\
                            ]                                                                   \n\
                      return-val))))';

  return code;
};

Blockly.ClojureScriptOptimized['appshare_div'] = function(block) {
  // TODO: Assemble JavaScript into code variable.

  var value_attributes = Blockly.ClojureScriptOptimized.statementToCode(block, 'ATTRIBUTES');

  var statements_more_elements = Blockly.ClojureScriptOptimized.statementToCode(block, 'more elements');

  var code = ' (om.dom/div  nil ' + value_attributes + ' ' +
      statements_more_elements +
      ') n' ;
  return code;
};

Blockly.ClojureScriptOptimized['appshare_element_attribute'] = function(block) {
  return " {:style {:" + block.getFieldValue('style') + ' \"' + block.getFieldValue('value') + "\"}} ";
};

Blockly.ClojureScriptOptimized['appshare_no_attributes'] = function(block) {
  return "nil";
};

Blockly.ClojureScriptOptimized['appshare_element_text'] = function(block) {
  // TODO: Assemble JavaScript into code variable.

  var value_attributes = ''   + block.getFieldValue('VALUE')

  var code = '\n "' + value_attributes + '" ' + '\n' ;

  return code;
};

Blockly.ClojureScriptOptimized['appshare_element_header'] = function(block) {
  // TODO: Assemble JavaScript into code variable.

  var value_attributes = ''   + block.getFieldValue('VALUE')

  var code = '(om.dom/div  (webapp.framework.client.coreclient/attrs  {:style {:fontSize "3em" :display "inline-block"}}) "' + value_attributes + '"' + ')\n' ;

  return code;
};

Blockly.ClojureScriptOptimized['appshare_element_br'] = function(block) {
  // TODO: Assemble JavaScript into code variable.

  var code = ' (om.dom/div nil "") ' ;

  return code;
};

Blockly.ClojureScriptOptimized['appshare_element_box'] = function(block) {
  // TODO: Assemble JavaScript into code variable.

  var code = ' (om.dom/div  (webapp.framework.client.coreclient/attrs {:style {:border "1px solid black" :width "200px" :height "200px" :display "inline-block"}}) "") ' ;

  return code;
};

Blockly.ClojureScriptOptimized['appshare_element_left_padding'] = function(block) {
  // TODO: Assemble JavaScript into code variable.

  var code = ' (om.dom/div  (webapp.framework.client.coreclient/attrs  {:style {:padding "10px" :display "inline-block"}}) "") ' ;

  return code;
};

Blockly.ClojureScriptOptimized['appshare_element_top_padding'] = function(block) {
  // TODO: Assemble JavaScript into code variable.

  var code = ' (om.dom/div  (webapp.framework.client.coreclient/attrs  {:style {:padding "10px" }}) "") ' ;

  return code;
};

Blockly.ClojureScriptOptimized['appshare_custom_component'] = function(block) {
  // TODO: Assemble JavaScript into code variable.

  var value_attributes = ''   + block.getFieldValue('COMPONENT_NAME');
  var main_div = Blockly.ClojureScriptOptimized.statementToCode(block, 'main div element');
  var code = ' (defn ' + value_attributes +  ' [app  owner]                                      \n\
    (reify                                                                                \n\
          om.core/IRender                                                                       \n\
          (render [this]                                                                        \n\
                                                                                \n\
                    (let [                                                                      \n\
                            ui-state   app                                                      \n\
                            path       (om.core/get-state owner :parent-path)                   \n\
                                                                                \n\
                            return-val (webapp.framework.client.coreclient/debug-react          \n\
                                          "main"                                                \n\
                                          owner                                                 \n\
                                          app                                                   \n\
                                          (fn [app]                                             \n\
                                                (om.dom/div nil ' + main_div + '))              \n\
                                          path                                                  \n\
                                          )                                                     \n\
                            ]                                                                   \n\
                      return-val)))) ';

  return code;
};

Blockly.ClojureScriptOptimized['appshare_call_custom_component'] = function(block) {
  // TODO: Assemble JavaScript into code variable.

  var value_attributes = ''   + block.getFieldValue('COMPONENT_NAME_VALUE');
  var code = '(om.dom/div (webapp.framework.client.coreclient/attrs {:style {:display "inline-block"}}) (webapp.framework.client.coreclient/component-fn  ' + value_attributes + '  app     []   [])) ';
//code = '(om.dom/div nil " - ")';

  return code;
};

var tttt=0;

Blockly.ClojureScriptOptimized['appshare_db_component'] = function(block) {
  //var code = '(realtime select id, field1  from test {}  (<-- ))' ;
  //(sql-parser  "select" ~@select-args)
  var table_name = ''   + block.getFieldValue('VALUE');
  var field_names = ''   + block.getFieldValue('DB_FIELDS');
  var statements_more_elements = Blockly.ClojureScriptOptimized.statementToCode(block, 'more elements');

  tttt ++;
  var code = '(let                                                                                \n\
                [relative-path-id2   (str (cljs-uuid-utils.core/make-random-uuid))                  \n\
                relative-path-id   ' + tttt + '                                                     \n\
                 data                                                                               \n\
                 (webapp.framework.client.coreclient/data-window-fn                                 \n\
                   (clojure.core/merge                                                              \n\
                     {:relative-path [relative-path-id]}                                            \n\
                     (if                                                                            \n\
                       select-id                                                                    \n\
                       (merge                                                                       \n\
                         {:fields [' + field_names + ' ],                                           \n\
                          :db-table "' + table_name +  '",                                          \n\
                          :relative-path [relative-path-id],                                        \n\
                          :params nil,                                                              \n\
                          :realtime true,                                                           \n\
                          :data-source :' + table_name +  '}                                        \n\
                         {:relative-path                                                            \n\
                          (conj                                                                     \n\
                            (conj                                                                   \n\
                              (get                                                                  \n\
                                {:fields [ ' + field_names + ' ],                                   \n\
                                 :db-table "' + table_name +  '",                                   \n\
                                 :relative-path [relative-path-id],                                 \n\
                                 :params nil,                                                       \n\
                                 :data-source :' + table_name +  '}                                 \n\
                                :relative-path)                                                     \n\
                              :values)                                                              \n\
                            select-id)})                                                            \n\
                       {:fields [ ' + field_names + ' ],                                            \n\
                        :db-table "' + table_name +  '",                                            \n\
                          :realtime true,                                                           \n\
                        :relative-path [relative-path-id],                                          \n\
                        :params nil,                                                                \n\
                        :data-source :' + table_name +  '}))                                        \n\
                   {:start 1, :end 20}                                                              \n\
                   ui-component-name                                                                \n\
                   path                                                                             \n\
                   ui-state)                                                                        \n\
                 data-order                                                                         \n\
                 (-> data :order)]                                                                  \n\
                                                                                \n\
  (om.dom/div                                                                                \n\
    nil                                                                                \n\
    (apply                                                                                \n\
         om.dom/div nil                                                                             \n\
         (map                                                                                \n\
     (fn [record-id]                                                                                \n\
                    (let                                                                            \n\
                      [relative-path                                                                \n\
                        (:relative-path                                                             \n\
                               (if                                                                  \n\
                                 select-id                                                          \n\
                                   (merge                                                           \n\
                                   {:fields [' + field_names + ' ],                                 \n\
                                    :db-table "' + table_name +  '",                                \n\
                          :realtime true,                                                           \n\
                                    :relative-path [relative-path-id],                              \n\
                                    :params nil,                                                    \n\
                                    :data-source :' + table_name +  '}                              \n\
                                   {:relative-path                                                  \n\
                                    (conj                                                           \n\
                                      (conj                                                         \n\
                                        (get                                                        \n\
                                          {:fields [' + field_names + ' ],                          \n\
                                           :db-table "' + table_name +  '",                         \n\
                                           :relative-path [relative-path-id],                       \n\
                                           :params nil,                                             \n\
                                           :data-source :' + table_name +  '}                       \n\
                                          :relative-path)                                           \n\
                                        :values)                                                    \n\
                                      select-id)})                                                  \n\
                  {:fields [' + field_names + ' ],                                                  \n\
                                  :db-table "' + table_name +  '",                                  \n\
                          :realtime true,                                                           \n\
                                  :relative-path [relative-path-id],                                \n\
                                  :params nil,                                                      \n\
                                  :data-source :' + table_name +  '}))                              \n\
                             record                                                                 \n\
                             (get (-> data :values) record-id)                                      \n\
                             select-id                                                              \n\
                             (get-in record [:value :id])]                                          \n\
                            (if (clojure.core/get record :value) (om.dom/div {} (om.dom/div nil     \n\
                             " " ' + statements_more_elements + '                                   \n\
                            )))))                                                                  \n\
      (map                                                                                \n\
        (fn [x] (get data-order x))                                                                 \n\
        (range (:start {:start 1, :end 20})                                                         \n\
               (inc (min (:end {:start 1, :end 20}) (-> data :count))))))))) ';

  //console.log(code);
  return code;
};

Blockly.ClojureScriptOptimized['appshare_db_field'] = function(block) {
  var value_attributes = ''   + block.getFieldValue('VALUE');
  var code = ' (webapp.framework.client.coreclient/<---fn   record  :' + value_attributes +  '  path  relative-path  )   ' + ' ';
  return code;
};

Blockly.ClojureScriptOptimized['appshare_show_tables'] = function(block) {
  var code = ' (om.dom/div  nil                                                                                \n\
                   (apply                                                                                \n\
                         om.dom/div nil                                                                                \n\
                         (map                                                                                \n\
                             (fn [table-name]                                                                           \n\
                                 (om.dom/div nil (str table-name)))                                                     \n\
                            (get-in @webapp.framework.client.system-globals/app-state [:ui :table-list])                \n\
         ))) ';
  return code;
};

Blockly.ClojureScriptOptimized['appshare_input_field'] = function(block) {
  var code = ' (om.dom/input (webapp.framework.client.coreclient/attrs{                                                  \n\
                              :onChange    (fn [event] (js/alert (str (.. event -target -value  ) " pressed")))          \n\
                              :style        {:marginBottom "20px"}                                                       \n\
                              :placeholder  "Enter a new todo here"                                                      \n\
                             }) "") ';
  return code;
};
<|endoftext|>


<commit_before>/*
  uses the config file to filter out unecessary information from the req and res
  snapshots

  TODO: make sure this function is being used in initTracking & trackState
*/

const config = require('./../default.config.js');

function filterSnapshot(snapshot, reX) {
  if (reX !== 'req' && reX !== 'res') throw new Error('bad input in filterSnapshot');
  const result = {};
  const paths = (reX === 'req' ? config.reqWatch : config.resWatch);

  paths.forEach(path => {
    Object.keys(snapshot).forEach(key => {
      if (path.indexOf(key) === 0) {
        const pathArr = path.split('.');

      }
    })
  })

  })

}
<commit_msg>Delete filterSnapshot.js<commit_after><|endoftext|>