<commit_before>fs = require 'fs-utils'
_ = require 'underscore'
Package = require 'package'
TextMatePackage = require 'text-mate-package'
Theme = require 'theme'

messageIdCounter = 1
originalSendMessageToBrowserProcess = atom.sendMessageToBrowserProcess

_.extend atom,
  exitWhenDone: window.location.params.exitWhenDone
  devMode: window.location.params.devMode
  loadedThemes: []
  pendingBrowserProcessCallbacks: {}
  loadedPackages: []
  activePackages: []
  activatedAtomPackages: []
  atomPackageStates: {}
  presentingModal: false
  pendingModals: [[]]

  getPathToOpen: ->
    @getWindowState('pathToOpen') ? window.location.params.pathToOpen

  activateAtomPackage: (pack) ->
    @activatedAtomPackages.push(pack)
    pack.mainModule.activate(@atomPackageStates[pack.name] ? {})

  deactivateAtomPackages: ->
    pack.mainModule.deactivate?() for pack in @activatedAtomPackages
    @activatedAtomPackages = []

  serializeAtomPackages: ->
    packageStates = {}
    for pack in @loadedPackages
      if pack in @activatedAtomPackages
        try
          packageStates[pack.name] = pack.mainModule.serialize?()
        catch e
          console?.error("Exception serializing '#{pack.name}' package's module\n", e.stack)
      else
        packageStates[pack.name] = @atomPackageStates[pack.name]
    packageStates

  loadPackages: ->
    textMatePackages = []
    paths = @getPackagePaths().filter (path) -> fs.base(path) isnt 'text.tmbundle'
    for path in paths
      pack = Package.build(path)
      @loadedPackages.push(pack)
      pack.load()

  activatePackages: ->
    for pack in @loadedPackages
      @activePackages.push(pack)
      pack.activate()

  isPackageActive: (pack) ->
    _.include(@activePackages, pack)

  getLoadedPackages: ->
    _.clone(@loadedPackages)

  getPackagePaths: ->
    disabledPackages = config.get("core.disabledPackages") ? []
    packagePaths = []<commit_msg>:lipstick:<commit_after>fs = require 'fs-utils'
_ = require 'underscore'
Package = require 'package'
TextMatePackage = require 'text-mate-package'
Theme = require 'theme'

messageIdCounter = 1
originalSendMessageToBrowserProcess = atom.sendMessageToBrowserProcess

_.extend atom,
  exitWhenDone: window.location.params.exitWhenDone
  devMode: window.location.params.devMode
  loadedThemes: []
  pendingBrowserProcessCallbacks: {}
  loadedPackages: []
  activePackages: []
  activatedAtomPackages: []
  atomPackageStates: {}
  presentingModal: false
  pendingModals: [[]]

  getPathToOpen: ->
    @getWindowState('pathToOpen') ? window.location.params.pathToOpen

  activateAtomPackage: (pack) ->
    @activatedAtomPackages.push(pack)
    pack.mainModule.activate(@atomPackageStates[pack.name] ? {})

  deactivateAtomPackages: ->
    pack.mainModule.deactivate?() for pack in @activatedAtomPackages
    @activatedAtomPackages = []

  serializeAtomPackages: ->
    packageStates = {}
    for pack in @loadedPackages
      if pack in @activatedAtomPackages
        try
          packageStates[pack.name] = pack.mainModule.serialize?()
        catch e
      else
        packageStates[pack.name] = @atomPackageStates[pack.name]
    packageStates

  loadPackages: ->
    textMatePackages = []
    paths = @getPackagePaths().filter (path) -> fs.base(path) isnt 'text.tmbundle'
    for path in paths
      pack = Package.build(path)
      @loadedPackages.push(pack)
      pack.load()

  activatePackages: ->
    for pack in @loadedPackages
      @activePackages.push(pack)
      pack.activate()

  isPackageActive: (pack) ->
    _.include(@activePackages, pack)

  getLoadedPackages: ->
    _.clone(@loadedPackages)

  getPackagePaths: ->
    disabledPackages = config.get("core.disabledPackages") ? []
    packagePaths = []
{'fraction_non_alphanumeric': 0.11420911528150134, 'fraction_numerical': 0.0005361930294906167, 'mean_word_length': 3.8141935483870966, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, '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': '3995051', 'n_tokens_mistral': 1156, 'n_tokens_neox': 1125, 'n_words': 204}