<commit_before>import * as React from 'react'
import * as ReactDOM from 'react-dom'
import { createBrowserHistory } from 'history'
import { App } from '../core/App'
import { RequireList, EntryOpts } from '../bundler/Entrypoint'
import { getBundleRoutes } from './getBundleRoutes'
import { ApplicationContext } from '../core/ApplicationContext'

// Configuration passed from server in ‘magic’ variable
declare const ___process_env_config: NodeJS.ProcessEnv

/**
 * Client entrypoint.
 *
 * Performs initial client app setup and launches the app.
 */
export default function clientEntry(topLevelModules: RequireList, opts: EntryOpts) {
  restoreProcessEnv()
  renderApplication()

  /** Hydrate process.env from magic variable passed through from server */
  function restoreProcessEnv() {
    process.env = ___process_env_config
  }

  /** Construct plugin instances specified in config file */
  function getAppContext() {
    const pluginConfigs = opts.config() || []
    return new ApplicationContext(pluginConfigs)
  }

  /** Start the application and render into DOM  */
  function renderApplication() {
    ReactDOM.render(
      <App
        routes={getBundleRoutes(topLevelModules)}
        history={createBrowserHistory()}
        appContext={getAppContext()}
      />,
      document.getElementById('app')
    )
  }
}<commit_msg>AP-92: Create BrowserPlugin on client entry<commit_after>import * as React from 'react'
import * as ReactDOM from 'react-dom'
import { createBrowserHistory } from 'history'
import { App } from '../core/App'
import { RequireList, EntryOpts } from '../bundler/Entrypoint'
import { getBundleRoutes } from './getBundleRoutes'
import { ApplicationContext } from '../core/ApplicationContext'
import { createBrowserPlugin } from '../plugins/BrowserPlugin/BrowserPlugin';

// Configuration passed from server in ‘magic’ variable
declare const ___process_env_config: NodeJS.ProcessEnv

/**
 * Client entrypoint.
 *
 * Performs initial client app setup and launches the app.
 */
export default function clientEntry(topLevelModules: RequireList, opts: EntryOpts) {
  const history = createBrowserHistory()

  restoreProcessEnv()
  renderApplication()

  /** Hydrate process.env from magic variable passed through from server */
  function restoreProcessEnv() {
    process.env = ___process_env_config
  }

  /** Construct plugin instances specified in config file */
  function getAppContext() {
    const pluginConfigs = opts.config() || []

    return new ApplicationContext([
      ...pluginConfigs,
      createBrowserPlugin({
        history
      })
    ])
  }

  /** Start the application and render into DOM  */
  function renderApplication() {
    ReactDOM.render(
      <App
        routes={getBundleRoutes(topLevelModules)}
        history={history}
        appContext={getAppContext()}
      />,
      document.getElementById('app')
    )
  }
}
{'fraction_non_alphanumeric': 0.10440513354144988, 'fraction_numerical': 0.000693721817551162, 'mean_word_length': 3.774834437086093, 'pattern_counts': {'":': 0, '<': 5, '<?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': '482553', 'n_tokens_mistral': 766, 'n_tokens_neox': 755, 'n_words': 225}