<commit_before>import Mixin from '@ember/object/mixin';
import Component from '@ember/component';
import HotReplacementComponent from 'ember-cli-hot-loader/components/hot-replacement-component';
import { get, computed } from '@ember/object';
import config from 'ember-get-config';
import { captureTemplateOptions } from 'ember-cli-hot-loader/utils/clear-container-cache';

function removeOriginalFromParsedName (parsedName) {
  parsedName.fullName = parsedName.fullName.replace(/-original$/, '');
  parsedName.fullNameWithoutType = parsedName.fullNameWithoutType.replace(/-original$/, '');
  parsedName.name= parsedName.name.replace(/-original$/, '');
}

function shouldIgnoreTemplate (parsedName) {
  return parsedName.fullName.match(/template:components\//) && !parsedName.fullName.match(/\-original$/); // eslint-disable-line
}

export default Mixin.create({
  resolveOther (parsedName) {
    captureTemplateOptions(parsedName);

    if (parsedName.type === 'template' && shouldIgnoreTemplate(parsedName)) {
      return;
    }

    const resolved = this._super(...arguments);
    if (parsedName.type === 'component') {
      const excluded = get(this, 'excluded');
      if (excluded.some((name) => name === parsedName.name)) {
        return this._super(parsedName);
      }
      if (resolved) {
        return this._resolveComponent(resolved, parsedName);
      }
      if (this._resolveOriginalTemplateForComponent(parsedName)) {
        return this._resolveComponent(Component.extend(), parsedName);
      }
      if (parsedName.fullName.match(/\-original$/)) { // eslint-disable-line
        removeOriginalFromParsedName(parsedName);
        return this._super(parsedName);
      }
    }

    return resolved;
  },
  resolveTemplate (parsedName) {
    if (shouldIgnoreTemplate(parsedName)) {
      return;
    }

    removeOriginalFromParsedName(parsedName);
    return this._super(...arguments);
  },
  _resolveComponent (resolved, parsedName) {
    return HotReplacementComponent.createClass(resolved, parsedName);
  },
  _resolveOriginalTemplateForComponent (parsedName) {
    const templateFullName = `template:components/${parsedName.fullNameWithoutType}-original`;
    const templateParsedName = this.parseName(templateFullName);
    return this.resolveTemplate(templateParsedName) || this.resolveOther(templateParsedName);
  },
  excluded: computed(function() {
    const exclude = config['ember-cli-hot-loader']['excluded'];
    return exclude || [];<commit_msg>BUG: fixed hot reload exclude for users w/out config<commit_after>import Mixin from '@ember/object/mixin';
import Component from '@ember/component';
import HotReplacementComponent from 'ember-cli-hot-loader/components/hot-replacement-component';
import { get, computed } from '@ember/object';
import config from 'ember-get-config';
import { captureTemplateOptions } from 'ember-cli-hot-loader/utils/clear-container-cache';

function removeOriginalFromParsedName (parsedName) {
  parsedName.fullName = parsedName.fullName.replace(/-original$/, '');
  parsedName.fullNameWithoutType = parsedName.fullNameWithoutType.replace(/-original$/, '');
  parsedName.name= parsedName.name.replace(/-original$/, '');
}

function shouldIgnoreTemplate (parsedName) {
  return parsedName.fullName.match(/template:components\//) && !parsedName.fullName.match(/\-original$/); // eslint-disable-line
}

export default Mixin.create({
  resolveOther (parsedName) {
    captureTemplateOptions(parsedName);

    if (parsedName.type === 'template' && shouldIgnoreTemplate(parsedName)) {
      return;
    }

    const resolved = this._super(...arguments);
    if (parsedName.type === 'component') {
      const excluded = get(this, 'excluded');
      if (excluded.some((name) => name === parsedName.name)) {
        return this._super(parsedName);
      }
      if (resolved) {
        return this._resolveComponent(resolved, parsedName);
      }
      if (this._resolveOriginalTemplateForComponent(parsedName)) {
        return this._resolveComponent(Component.extend(), parsedName);
      }
      if (parsedName.fullName.match(/\-original$/)) { // eslint-disable-line
        removeOriginalFromParsedName(parsedName);
        return this._super(parsedName);
      }
    }

    return resolved;
  },
  resolveTemplate (parsedName) {
    if (shouldIgnoreTemplate(parsedName)) {
      return;
    }

    removeOriginalFromParsedName(parsedName);
    return this._super(...arguments);
  },
  _resolveComponent (resolved, parsedName) {
    return HotReplacementComponent.createClass(resolved, parsedName);
  },
  _resolveOriginalTemplateForComponent (parsedName) {
    const templateFullName = `template:components/${parsedName.fullNameWithoutType}-original`;
    const templateParsedName = this.parseName(templateFullName);
    return this.resolveTemplate(templateParsedName) || this.resolveOther(templateParsedName);
  },
  excluded: computed(function() {
    const configuration = config['ember-cli-hot-loader'];
    return configuration ? (configuration['excluded'] || []) : [];
{'fraction_non_alphanumeric': 0.13269765593961064, 'fraction_numerical': 0.0, 'mean_word_length': 4.288865546218488, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3933891', 'n_tokens_mistral': 1392, 'n_tokens_neox': 1424, 'n_words': 245}