<commit_before>import { Module } from 'vuex'
import { RouteConfig, NavigationGuard } from 'vue-router'
import Vue, { VueConstructor } from 'vue'
import rootStore from '@vue-storefront/store'
import router from '@vue-storefront/core/router'
import { merge } from 'lodash-es'

function extendRouter (routes?: RouteConfig[], beforeEach?: NavigationGuard, afterEach?: NavigationGuard): void {
  if (routes) router.addRoutes(routes)
  if (beforeEach) router.beforeEach(beforeEach)
  if (afterEach) router.afterEach(afterEach)
}

function extendStore (key, store) {
  let registeredStores: any = rootStore
  // Merge Vuex modules inc ase of conflicting keys with existing ones
  if (registeredStores._modules.root._children[key]) {
    rootStore.registerModule(key, merge(store, registeredStores._modules.root._children[key]._rawModule))
  } else {
    rootStore.registerModule(key, store)
  }
}

export interface VueStorefrontModuleConfig {
  key: string;
  store?: Module<any, any>;
  router?: { routes?: RouteConfig[], beforeEach?: NavigationGuard, afterEach?: NavigationGuard },
  beforeRegistration?: (Vue: VueConstructor, config: Object) => void,
  afterRegistration?: (Vue: VueConstructor, config: Object) => void,
}

export class VueStorefrontModule {
  constructor (
    private _c: VueStorefrontModuleConfig
  ) { }
  /**
   * Registers module in app with before/after hooks, store and router.
   * Should be called inside an apps entry point available for both server and client.
   */<commit_msg>commented extendstore bahevior, typed extendstore<commit_after>import { Module } from 'vuex'
import { RouteConfig, NavigationGuard } from 'vue-router'
import Vue, { VueConstructor } from 'vue'
import rootStore from '@vue-storefront/store'
import router from '@vue-storefront/core/router'
import { merge } from 'lodash-es'

export interface VueStorefrontModuleConfig {
  key: string;
  store?: Module<any, any>;
  router?: { routes?: RouteConfig[], beforeEach?: NavigationGuard, afterEach?: NavigationGuard },
  beforeRegistration?: (Vue: VueConstructor, config: Object) => void,
  afterRegistration?: (Vue: VueConstructor, config: Object) => void,
}

function extendRouter (routes?: RouteConfig[], beforeEach?: NavigationGuard, afterEach?: NavigationGuard): void {
  if (routes) router.addRoutes(routes)
  if (beforeEach) router.beforeEach(beforeEach)
  if (afterEach) router.afterEach(afterEach)
}

function extendStore (key: string, store: Module<any, any>) : void {
  let registeredStores: any = rootStore
  // Merge stores with conflicting keys
  if (registeredStores._modules.root._children[key]) {
    rootStore.registerModule(key, merge(store, registeredStores._modules.root._children[key]._rawModule))
  } else {
    rootStore.registerModule(key, store)
  }
}

export class VueStorefrontModule {
  constructor (
    private _c: VueStorefrontModuleConfig
  ) { }
  /**
   * Registers module in app with before/after hooks, store and router.
   * Should be called inside an apps entry point available for both server and client.
   */
{'fraction_non_alphanumeric': 0.10946745562130178, 'fraction_numerical': 0.0, 'mean_word_length': 5.184959349593496, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 10, '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': '4699840', 'n_tokens_mistral': 893, 'n_tokens_neox': 879, 'n_words': 260}