<commit_before>var naf = require('../NafIndex');
var componentHelper = require('../ComponentHelper');
var Compressor = require('../Compressor');
var bind = AFRAME.utils.bind;

AFRAME.registerComponent('networked', {
  schema: {
    template: {default: ''},
    showLocalTemplate: {default: true},

    networkId: {default: ''},
    owner: {default: ''}
  },

  init: function() {
    var data = this.data;
    var wasCreatedByNetwork = this.wasCreatedByNetwork();

    this.onConnected = bind(this.onConnected, this);
    this.onSyncAll = bind(this.onSyncAll, this);
    this.syncDirty = bind(this.syncDirty, this);
    this.networkUpdateHandler = bind(this.networkUpdateHandler, this);

    this.cachedData = {};
    this.initNetworkParent();

    if (data.networkId === '') {
      this.el.setAttribute(this.name, {networkId: NAF.utils.createNetworkId()});
    }

    if (data.template != '') {
      this.initTemplate();
    }

    if (wasCreatedByNetwork) {
      this.firstUpdate();
      this.attachLerp();
    }
    else {
      this.registerEntity(data.networkId);
    }

    if (this.data.owner === '') {
      this.setNetworkIdWhenConnected();
      // Only send the initial sync if we are connected. Otherwise this gets sent when the dataChannel is opened with each peer.
      // Note that this only works because the reliable messages are sent over a single websocket connection.
      // If they are sent over a different transport this check may need to change
      if (NAF.connection.isConnected()) {
        this.waitForTemplate(() => {
          this.syncAll();
        });
      }
    }

    document.body.dispatchEvent(this.entityCreatedEvent());
  },

  wasCreatedByNetwork: function() {
    return !!this.el.firstUpdateData;
  },

  initNetworkParent: function() {
    var parentEl = this.el.parentElement;
    if (parentEl.hasOwnProperty('components') && parentEl.components.hasOwnProperty('networked')) {
      this.parent = parentEl;<commit_msg>dont cache data<commit_after>var naf = require('../NafIndex');
var componentHelper = require('../ComponentHelper');
var Compressor = require('../Compressor');
var bind = AFRAME.utils.bind;

AFRAME.registerComponent('networked', {
  schema: {
    template: {default: ''},
    showLocalTemplate: {default: true},

    networkId: {default: ''},
    owner: {default: ''}
  },

  init: function() {
    var wasCreatedByNetwork = this.wasCreatedByNetwork();

    this.onConnected = bind(this.onConnected, this);
    this.onSyncAll = bind(this.onSyncAll, this);
    this.syncDirty = bind(this.syncDirty, this);
    this.networkUpdateHandler = bind(this.networkUpdateHandler, this);

    this.cachedData = {};
    this.initNetworkParent();

    if (this.data.networkId === '') {
      this.el.setAttribute(this.name, {networkId: NAF.utils.createNetworkId()});
    }

    if (this.data.template != '') {
      this.initTemplate();
    }

    if (wasCreatedByNetwork) {
      this.firstUpdate();
      this.attachLerp();
    }
    else {
      this.registerEntity(this.data.networkId);
    }

    if (this.data.owner === '') {
      this.setNetworkIdWhenConnected();
      // Only send the initial sync if we are connected. Otherwise this gets sent when the dataChannel is opened with each peer.
      // Note that this only works because the reliable messages are sent over a single websocket connection.
      // If they are sent over a different transport this check may need to change
      if (NAF.connection.isConnected()) {
        this.waitForTemplate(() => {
          this.syncAll();
        });
      }
    }

    document.body.dispatchEvent(this.entityCreatedEvent());
  },

  wasCreatedByNetwork: function() {
    return !!this.el.firstUpdateData;
  },

  initNetworkParent: function() {
    var parentEl = this.el.parentElement;
    if (parentEl.hasOwnProperty('components') && parentEl.components.hasOwnProperty('networked')) {
      this.parent = parentEl;
{'fraction_non_alphanumeric': 0.13628273582506992, 'fraction_numerical': 0.0, 'mean_word_length': 3.171792152704136, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '4982594', 'n_tokens_mistral': 1159, 'n_tokens_neox': 1133, 'n_words': 262}