<commit_before>BrowserWindow       = require "browser-window"
{Emitter}           = require "event-kit"

module.exports = class AppWindow extends Emitter
    _opts           : null
    browserWindow   : null

    constructor     : (options = {}) ->
        super

        @_opts = options
        global.app.addWindow(@)

        @setupWindow()

    setupWindow     : ->
        @browserWindow = w = new BrowserWindow(@_opts)
        w.loadUrl(@_opts.url) if @_opts.url?

        if @_opts.devMode
            w.openDevTools {detach: true}

        return

    handleEvents    : ->
        console.log @browserWindow.on "closed", @dispose.bind(@)

        if @_opts.devMode
            @browserWindow.webContents.on "did-start-loading", =>
                try @_electronConnect = require('electron-connect').client.create(@browserWindow)
                @browserWindow.webContents.executeJavaScript "try{require('electron-connect').client.create();}catch(e){}"

        return

<commit_msg>AppWindow now handling self events correctly<commit_after>BrowserWindow       = require "browser-window"
{Emitter}           = require "event-kit"

module.exports = class AppWindow extends Emitter
    _opts           : null
    browserWindow   : null

    constructor     : (options = {}) ->
        super

        @_opts = options
        global.app.addWindow(@)

        @setupWindow()
        @handleEvents()

    setupWindow     : ->
        @browserWindow = w = new BrowserWindow(@_opts)
        w.loadUrl(@_opts.url) if @_opts.url?

        if @_opts.devMode
            w.openDevTools {detach: true}

        return

    handleEvents    : ->
        @browserWindow.on "closed", @dispose.bind(@)
        @browserWindow.on "focus", =>
            global.app.setLastFocusedWindow @

        if @_opts.devMode
            @browserWindow.webContents.on "did-start-loading", =>
                try @_electronConnect = require('electron-connect').client.create(@browserWindow)
                @browserWindow.webContents.executeJavaScript "try{require('electron-connect').client.create();}catch(e){}"

        return


{'fraction_non_alphanumeric': 0.11675367821547224, 'fraction_numerical': 0.0, 'mean_word_length': 2.169924812030075, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '4376406', 'n_tokens_mistral': 603, 'n_tokens_neox': 571, 'n_words': 110}