<commit_before>(function () {
  
  // initialize the global app reference
  enyo._app = null;
  
  enyo.app = function (inProps) {
    var n = enyo.global[inProps.name], r;
    r = (enyo.global[inProps.name] = new enyo.Application(inProps));
    if (n) for (var p in n) r[p] = n[p];
    return r;
  };
  
  enyo.kind({
    name: "enyo.Application",
    kind: "enyo.Control",
    published: {
      store: false,
      router: false,
      controller: null
    },
    constructor: function (inProps) {
      var c = inProps.classes || "";
      c = inProps.name.toLowerCase() + "-app" + c;
      inProps.classes = c;
      enyo.mixin(this, inProps);
      this.inherited(arguments);
      enyo._app = this;
    },
    create: function () {
      
      // this is an ugly hack that MUST BE RETHOUGHT OUT
      // but its necessary to move the normal create method
      // order until AFTER the `main` method is called...
      this._createArguments = arguments;
    },
    start: function () {
      if (this.main && enyo.isFunction(this.main)) this.main();
      
      // ...and...resume normal create method...
      this.inherited(this._createArguments);
      this.setup();
      this.renderInto(document.body);
      if (this.router) this.router.start();
    },
    setup: function () {
      this.setupRouter();
    },
    setupRouter: function () {
      var r = this.router, c = this.controller;
      if (enyo.isString(r)) r = enyo._getPath(r);
      if (!r) return console.warn("enyo.Application: could not " +
        "find the router `" + this.router + "`");
      r = this.router = new r();
      r.set("controller", c);
    },
    dispatchEvent: function () {
      this.controller.handle.apply(this.controller, arguments);
    },
    handle: function () {
      return enyo._handle.apply(this, arguments);
    }
  });
  
}());<commit_msg>add queue for events attempted before the controller is initialized and flush them once it is ready<commit_after>(function () {
  
  // initialize the global app reference
  enyo._app = null;
  
  enyo.app = function (inProps) {
    var n = enyo.global[inProps.name], r;
    r = (enyo.global[inProps.name] = new enyo.Application(inProps));
    if (n) for (var p in n) r[p] = n[p];
    return r;
  };
  
  enyo.kind({
    name: "enyo.Application",
    kind: "enyo.Control",
    published: {
      store: false,
      router: false,
      controller: null
    },
    _eventQueue: null,
    constructor: function (inProps) {
      var c = inProps.classes || "";
      this._eventQueue = [];
      c = inProps.name.toLowerCase() + "-app" + c;
      inProps.classes = c;
      enyo.mixin(this, inProps);
      this.inherited(arguments);
      enyo._app = this;
    },
    create: function () {
      
      // this is an ugly hack that MUST BE RETHOUGHT OUT
      // but its necessary to move the normal create method
      // order until AFTER the `main` method is called...
      this._createArguments = arguments;
    },
    start: function () {
      if (this.main && enyo.isFunction(this.main)) this.main();
      
      // ...and...resume normal create method...
      this.inherited(this._createArguments);
      this.setup();
      this.renderInto(document.body);
      if (this.router) this.router.start();
    },
    setup: function () {
      this.setupRouter();
    },
    setupRouter: function () {
      var r = this.router, c = this.controller;
      if (enyo.isString(r)) r = enyo._getPath(r);
      if (!r) return console.warn("enyo.Application: could not " +
        "find the router `" + this.router + "`");
      r = this.router = new r();
      r.set("controller", c);
    },
    dispatchEvent: function () {
      if (!this.controller || !this.controller.handle) {
        // queue these...
        this._eventQueue.push(arguments);
        return;
      }
      this.controller.handle.apply(this.controller, arguments);
    },
    controllerChanged: function () {
      this.inherited(arguments);
      var q = this._eventQueue || [], args;
      while (q.length) {
        args = q.shift();
        this.dispatchEvent.apply(this, args);
      }
    },
    handle: function () {
      return enyo._handle.apply(this, arguments);
    }
  });
  
}());
{'fraction_non_alphanumeric': 0.1480691779199242, 'fraction_numerical': 0.0, 'mean_word_length': 2.2377300613496933, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2816892', 'n_tokens_mistral': 1313, 'n_tokens_neox': 1314, 'n_words': 329}