<commit_before>socketio    = require 'socket.io-client'
timm        = require 'timm'
treeLines   = require '../gral/treeLines'
k           = require '../gral/constants'

DEFAULT_CONFIG = {}

#-------------------------------------------------
# ## Extension I/O
#-------------------------------------------------
_fExtensionInitialised = false
_fExtensionReady = false

_extensionInit = (config) ->
  return if _fExtensionInitialised
  _fExtensionInitialised = true
  window.addEventListener 'message', (event) ->
    {source, data: msg} = event
    return if source isnt window
    {data: {src, type, data}} = event
    _extensionRxMsg msg
  _extensionTxMsg {type: 'CONNECT_REQUEST'}

_extensionRxMsg = (msg) ->
  {src, type, data} = msg
  return if src isnt 'DT'
  console.log "[PG] RX #{src}/#{type}", data
  switch type
    when 'CONNECT_REQUEST', 'CONNECT_RESPONSE'
      _fExtensionReady = true
      if type is 'CONNECT_REQUEST' 
        _extensionTxMsg {type: 'CONNECT_RESPONSE'}
        if _fSocketConnected
          _extensionTxMsg {type: 'WS_CONNECTED'}
        else
          _extensionTxMsg {type: 'WS_DISCONNECTED'}
      _extensionTxPendingMsgs()
    else
      _socketTxMsg {type, data}<commit_msg>Stop dumping internal Storyboard messages to the console<commit_after>socketio    = require 'socket.io-client'
timm        = require 'timm'
treeLines   = require '../gral/treeLines'
k           = require '../gral/constants'

DEFAULT_CONFIG = {}

#-------------------------------------------------
# ## Extension I/O
#-------------------------------------------------
_fExtensionInitialised = false
_fExtensionReady = false

_extensionInit = (config) ->
  return if _fExtensionInitialised
  _fExtensionInitialised = true
  window.addEventListener 'message', (event) ->
    {source, data: msg} = event
    return if source isnt window
    {data: {src, type, data}} = event
    _extensionRxMsg msg
  _extensionTxMsg {type: 'CONNECT_REQUEST'}

_extensionRxMsg = (msg) ->
  {src, type, data} = msg
  return if src isnt 'DT'
  ## console.log "[PG] RX #{src}/#{type}", data
  switch type
    when 'CONNECT_REQUEST', 'CONNECT_RESPONSE'
      _fExtensionReady = true
      if type is 'CONNECT_REQUEST' 
        _extensionTxMsg {type: 'CONNECT_RESPONSE'}
        if _fSocketConnected
          _extensionTxMsg {type: 'WS_CONNECTED'}
        else
          _extensionTxMsg {type: 'WS_DISCONNECTED'}
      _extensionTxPendingMsgs()
    else
      _socketTxMsg {type, data}
{'fraction_non_alphanumeric': 0.1778496362166532, 'fraction_numerical': 0.0, 'mean_word_length': 2.36734693877551, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '5976155', 'n_tokens_mistral': 719, 'n_tokens_neox': 732, 'n_words': 190}