<commit_before>/*
 * Copyright (C) 2015 Actor LLC. <https://actor.im>
 */

package im.actor.core.js;

import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArray;
import com.google.gwt.user.client.Event;

import im.actor.core.Configuration;
import im.actor.core.Messenger;
import im.actor.core.api.rpc.ResponseLoadArchived;
import im.actor.core.entity.Avatar;
import im.actor.core.entity.Contact;
import im.actor.core.entity.Dialog;
import im.actor.core.entity.FileReference;
import im.actor.core.entity.Message;
import im.actor.core.entity.Peer;
import im.actor.core.entity.PeerType;
import im.actor.core.entity.SearchEntity;
import im.actor.core.entity.content.FastThumb;
import im.actor.core.js.entity.JsBlockedUser;
import im.actor.core.js.entity.JsCall;
import im.actor.core.js.entity.JsCounter;
import im.actor.core.js.entity.JsDialogGroup;
import im.actor.core.js.entity.JsEventBusCallback;
import im.actor.core.js.entity.JsOnlineGroup;
import im.actor.core.js.entity.JsOnlineUser;
import im.actor.core.js.entity.JsSearchEntity;
import im.actor.core.js.entity.JsSticker;
import im.actor.core.js.modules.JsFilesModule;
import im.actor.core.js.modules.JsBindingModule;
import im.actor.core.js.modules.JsBindedValue;
import im.actor.core.js.entity.JsContact;
import im.actor.core.js.entity.JsDialog;
import im.actor.core.js.entity.JsGroup;
import im.actor.core.js.entity.JsMessage;
import im.actor.core.js.entity.JsPeer;
import im.actor.core.js.entity.JsPeerInfo;
import im.actor.core.js.entity.JsTyping;
import im.actor.core.js.entity.JsUser;
import im.actor.core.js.entity.Placeholders;
import im.actor.core.js.images.JsImageResize;
import im.actor.core.js.images.JsResizeListener;
import im.actor.core.js.modules.JsIdleModule;
import im.actor.core.js.providers.electron.JsElectronApp;
import im.actor.core.js.providers.electron.JsElectronListener;
import im.actor.core.js.providers.notification.JsChromePush;
import im.actor.core.js.providers.notification.JsSafariPush;
import im.actor.core.js.providers.notification.PushSubscribeResult;
import im.actor.core.network.RpcCallback;
import im.actor.core.viewmodel.ConversationVM;
import im.actor.core.viewmodel.GroupVM;
import im.actor.core.viewmodel.UserVM;
import im.actor.runtime.Log;
import im.actor.runtime.Runtime;
import im.actor.runtime.Storage;
import im.actor.runtime.crypto.Base64Utils;
import im.actor.runtime.js.JsFileSystemProvider;
import im.actor.runtime.js.fs.JsBlob;
import im.actor.runtime.js.fs.JsFile;
import im.actor.runtime.js.mvvm.JsDisplayList;
import im.actor.runtime.mvvm.Value;
import im.actor.runtime.mvvm.ValueChangedListener;
import im.actor.runtime.threading.ThreadDispatcher;

public class JsMessenger extends Messenger {

    private static final String TAG = "JsMessenger";
    private static JsMessenger instance = null;

    public static JsMessenger getInstance() {
        return instance;
    }

    private JsIdleModule jsIdleModule;
    private JsBindingModule jsBindingModule;
    private JsFilesModule filesModule;
    private JsFileSystemProvider fileSystemProvider;
    private boolean isElectron;

    public JsMessenger(Configuration configuration) {
        super(configuration);
        fileSystemProvider = (JsFileSystemProvider) Storage.getFileSystemRuntime();
        filesModule = new JsFilesModule(modules);
        jsBindingModule = new JsBindingModule(this, filesModule, modules);
        isElectron = JsElectronApp.isElectron();

        ThreadDispatcher.pushDispatcher(Runtime::postToMainThread);

        jsIdleModule = new JsIdleModule(this, modules);

        if (isElectron()) {
            JsElectronApp.subscribe("window", new JsElectronListener() {
                @Override
                public void onEvent(String content) {
                    if ("focus".equals(content)) {
                        jsIdleModule.onVisible();
                    } else if ("blur".equals(content)) {
                        jsIdleModule.onHidden();
                    }
                }
            });
        }

        if (isElectron) {
            getGlobalState().getGlobalTempCounter().subscribe(new ValueChangedListener<Integer>() {
                @Override
                public void onChanged(Integer val, Value<Integer> valueModel) {
                    if (val == null || val == 0) {
                        JsElectronApp.hideNewMessages();
                    } else {
                        JsElectronApp.updateBadge(val);<commit_msg>feat(js): Adding electron logging<commit_after>/*
 * Copyright (C) 2015 Actor LLC. <https://actor.im>
 */

package im.actor.core.js;

import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArray;
import com.google.gwt.user.client.Event;

import im.actor.core.Configuration;
import im.actor.core.Messenger;
import im.actor.core.api.rpc.ResponseLoadArchived;
import im.actor.core.entity.Avatar;
import im.actor.core.entity.Contact;
import im.actor.core.entity.Dialog;
import im.actor.core.entity.FileReference;
import im.actor.core.entity.Message;
import im.actor.core.entity.Peer;
import im.actor.core.entity.PeerType;
import im.actor.core.entity.SearchEntity;
import im.actor.core.entity.content.FastThumb;
import im.actor.core.js.entity.JsBlockedUser;
import im.actor.core.js.entity.JsCall;
import im.actor.core.js.entity.JsCounter;
import im.actor.core.js.entity.JsDialogGroup;
import im.actor.core.js.entity.JsEventBusCallback;
import im.actor.core.js.entity.JsOnlineGroup;
import im.actor.core.js.entity.JsOnlineUser;
import im.actor.core.js.entity.JsSearchEntity;
import im.actor.core.js.entity.JsSticker;
import im.actor.core.js.modules.JsFilesModule;
import im.actor.core.js.modules.JsBindingModule;
import im.actor.core.js.modules.JsBindedValue;
import im.actor.core.js.entity.JsContact;
import im.actor.core.js.entity.JsDialog;
import im.actor.core.js.entity.JsGroup;
import im.actor.core.js.entity.JsMessage;
import im.actor.core.js.entity.JsPeer;
import im.actor.core.js.entity.JsPeerInfo;
import im.actor.core.js.entity.JsTyping;
import im.actor.core.js.entity.JsUser;
import im.actor.core.js.entity.Placeholders;
import im.actor.core.js.images.JsImageResize;
import im.actor.core.js.images.JsResizeListener;
import im.actor.core.js.modules.JsIdleModule;
import im.actor.core.js.providers.electron.JsElectronApp;
import im.actor.core.js.providers.electron.JsElectronListener;
import im.actor.core.js.providers.notification.JsChromePush;
import im.actor.core.js.providers.notification.JsSafariPush;
import im.actor.core.js.providers.notification.PushSubscribeResult;
import im.actor.core.network.RpcCallback;
import im.actor.core.viewmodel.ConversationVM;
import im.actor.core.viewmodel.GroupVM;
import im.actor.core.viewmodel.UserVM;
import im.actor.runtime.Log;
import im.actor.runtime.Runtime;
import im.actor.runtime.Storage;
import im.actor.runtime.crypto.Base64Utils;
import im.actor.runtime.js.JsFileSystemProvider;
import im.actor.runtime.js.fs.JsBlob;
import im.actor.runtime.js.fs.JsFile;
import im.actor.runtime.js.mvvm.JsDisplayList;
import im.actor.runtime.mvvm.Value;
import im.actor.runtime.mvvm.ValueChangedListener;
import im.actor.runtime.threading.ThreadDispatcher;

public class JsMessenger extends Messenger {

    private static final String TAG = "JsMessenger";
    private static JsMessenger instance = null;

    public static JsMessenger getInstance() {
        return instance;
    }

    private JsIdleModule jsIdleModule;
    private JsBindingModule jsBindingModule;
    private JsFilesModule filesModule;
    private JsFileSystemProvider fileSystemProvider;
    private boolean isElectron;

    public JsMessenger(Configuration configuration) {
        super(configuration);
        fileSystemProvider = (JsFileSystemProvider) Storage.getFileSystemRuntime();
        filesModule = new JsFilesModule(modules);
        jsBindingModule = new JsBindingModule(this, filesModule, modules);
        isElectron = JsElectronApp.isElectron();

        ThreadDispatcher.pushDispatcher(Runtime::postToMainThread);

        jsIdleModule = new JsIdleModule(this, modules);

        if (isElectron()) {
            Log.d(TAG, "Init Electron IPC");
            JsElectronApp.subscribe("window", new JsElectronListener() {
                @Override
                public void onEvent(String content) {
                    Log.d(TAG, "On Window " + content);
                    if ("focus".equals(content)) {
                        jsIdleModule.onVisible();
                    } else if ("blur".equals(content)) {
                        jsIdleModule.onHidden();
                    }
                }
            });
        }

        if (isElectron) {
            getGlobalState().getGlobalTempCounter().subscribe(new ValueChangedListener<Integer>() {
                @Override
                public void onChanged(Integer val, Value<Integer> valueModel) {
                    if (val == null || val == 0) {
                        JsElectronApp.hideNewMessages();
                    } else {
                        JsElectronApp.updateBadge(val);
{'fraction_non_alphanumeric': 0.11134292302624355, 'fraction_numerical': 0.0015372790161414297, 'mean_word_length': 3.4429268292682926, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, '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': '5155897', 'n_tokens_mistral': 2857, 'n_tokens_neox': 2733, 'n_words': 454}