<commit_before>{CompositeDisposable} = require 'atom'
etch = require 'etch'

PaneItem = require './util/pane-item'
Loading = require './util/loading'
progress = require './util/progress'
Tooltip = require './util/tooltip'
block = require './editor/block'
highlights = require './editor/highlights'
Result = require './editor/result'
Docs = require './editor/docs'
Console = require './console/console'
Stepper = require './debugger/stepper'
breakpoints = require './debugger/breakpoints'
PlotPane = require './plots/pane'
DocPane = require('./docs/docpane')
InkTerminal = require('./console2/console')
{Pannable} = require './plots/canopy'
katex = require('./util/katexify')
profiler = require './plots/profiler'
Workspace = require './workspace/workspace'
Linter  = require './linter/linter'
tree = require './tree'
goto = require './util/gotodef'

module.exports = Ink =
  activate: ->
    etch.setScheduler(atom.views)
    mod.activate() for mod in [PaneItem, Result, Docs, Console, PlotPane, InkTerminal, Linter]

  deactivate: ->
    # pkg = atom.packages.getActivePackage 'ink'
    # localStorage.setItem pkg.getCanDeferMainModuleRequireStorageKey(), false
    mod.deactivate() for mod in [PaneItem, Result, Docs, Console, PlotPane, InkTerminal, Linter]

  consumeStatusBar: (bar) ->
    progress.consumeStatusBar bar

  provide: ->
    util:
      focusEditorPane: () -> PaneItem.focusEditorPane()
    highlight: (ed, start, end, clas) =>
      block.highlight ed, start, end, clas
    Loading: Loading
    progress: progress
    Result: Result
    Console: Console
    Stepper: Stepper
    breakpoints: breakpoints
    Workspace: Workspace
    PlotPane: PlotPane
    DocPane: DocPane
    Pannable: Pannable
    highlights: highlights
    tree: tree
    InlineDoc: Docs
    goto: goto
    Tooltip: Tooltip
    Profiler: profiler
    Opener: require('./util/opener')
    KaTeX: katex
    InkTerminal: InkTerminal
    Linter: Linter
    matchHighlighter: require './util/matchHighlighter'
    ansiToHTML: require './util/ansitohtml'<commit_msg>try to lazily load as much as possible<commit_after>{CompositeDisposable} = require 'atom'
etch = require 'etch'
{once} = require 'underscore-plus'

# these need to be loaded first so deserialization works fine
PaneItem = require './util/pane-item'
Console = require './console/console'
PlotPane = require './plots/pane'
DocPane = require('./docs/docpane')
InkTerminal = require('./console2/console')
Workspace = require './workspace/workspace'
Linter  = require './linter/linter'

exportables =
  PaneItem: => PaneItem
  Console: => Console
  PlotPane: => PlotPane
  DocPane: => DocPane
  InkTerminal: => InkTerminal
  Workspace: => Workspace
  Linter : => Linter
  Loading: once(=> require './util/loading')
  progress: once(=> require './util/progress')
  Tooltip: once(=> require './util/tooltip')
  block: once(=> require './editor/block')
  highlights: once(=> require './editor/highlights')
  Result: once(=> require './editor/result')
  InlineDoc: once(=> require './editor/docs')
  Stepper: once(=> require './debugger/stepper')
  breakpoints: once(=> require './debugger/breakpoints')
  Pannable: once(=> require('./plots/canopy').Pannable)
  KaTeX: once(=> require('./util/katexify'))
  profiler: once(=> require './plots/profiler')
  tree: once(=> require './tree')
  goto: once(=> require './util/gotodef')
  Opener: once(=> require('./util/opener'))
  matchHighlighter: once(=> require './util/matchHighlighter')
  ansiToHTML: once(=> require './util/ansitohtml')

module.exports = Ink =
  activate: ->
    etch.setScheduler(atom.views)
    mod.activate() for mod in [exportables.PaneItem(), exportables.Result(), exportables.InlineDoc(), exportables.Console(), exportables.PlotPane(), exportables.InkTerminal(), exportables.Linter()]

  deactivate: ->
    # pkg = atom.packages.getActivePackage 'ink'
    # localStorage.setItem pkg.getCanDeferMainModuleRequireStorageKey(), exportables.false()
    mod.deactivate() for mod in [exportables.PaneItem(), exportables.Result(), exportables.InlineDoc(), exportables.Console(), exportables.PlotPane(), exportables.InkTerminal(), exportables.Linter()]

  consumeStatusBar: (bar) ->
    exportables.progress().consumeStatusBar bar

  provide: ->
    obj =
      util:
        focusEditorPane: () -> exportables.PaneItem().focusEditorPane()
      highlight: (ed, start, end, clas) =>
        exportables.block().highlight ed, start, end, clas

    for key, val of exportables
      do (val) ->
        Object.defineProperty(obj, key, {
          get: -> val()
        })
    obj
{'fraction_non_alphanumeric': 0.14687909209951985, 'fraction_numerical': 0.00043649061545176777, 'mean_word_length': 3.9279569892473116, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 41, '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': '601735', 'n_tokens_mistral': 1425, 'n_tokens_neox': 1410, 'n_words': 351}