Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* global THREE */
import mitt from 'mitt'
import store from 'utils/store'
import config from 'config'
import prng from 'utils/prng'
const emitter = mitt()
const DISTVIEW = config.viewDistance // chunk side
const CHUNKSIZE = config.chunkSize
const CHUNKDISTFROMCENTER = (DISTVIEW - 1) / 2
const CHUNKCENTER = CHUNKSIZE / 2 + 0.5
// const WALKMAPCENTER = CHUNKSIZE * ((DISTVIEW - 1) / 2) + (CHUNKSIZE - 1) / 2
let chunksPool = []
let currentMiddleChunk = null
let loadedChunks = {}
let walkMap = []
let prevPos = [0, 0]
let domDebug
if (config.locDebug) {
domDebug = document.createElement('pre')
domDebug.style.zIndex = 10000
});
/* Custom Layer API attributes:
- id: string
- type: "custom"
*/
this.id = id;
this.type = 'custom';
this.metadata = null;
this._state = 'init';
this._visible = true;
this._isLoaded = false;
this._matrix = null;
this._fireUpdateOnNextRender = false;
this._emitter = mitt();
this._oldDataframes = new Set();
this._renderLayer = new RenderLayer();
this._atomicChangeUID = 0;
this.update(source, viz);
}
constructor() {
Object.assign(this, mitt());
port.onMessage.addListener(message => {
switch (message.type) {
case 'dataUpdate':
this.emit('dataUpdate');
break;
case 'reRender':
this.emit('reRender', message.nodes);
break;
case 'initNodes':
this.emit('initNodes', message.nodes);
break;
case 'currNodeChange':
this.emit('currNodeChange', message.uuid);
break;
case 'pageReload':
import mitt from 'mitt'
const emitter = mitt()
export const emitterMiddleware = store => next => action => {
let result = next(action)
emitter.emit(action.type, {
state: store.getState(),
action
})
return result
}
export default emitter
constructor() {
if(!this.isSupport){
console.warn('Your browser don\'t support orientation API ');
return;
}
window.addEventListener('deviceorientation', this._control.bind(this), false);
this._emitter = new Mitt();
this._deviceProp = {
start: {},
first: true
}
}
get isSupport() {
export default (root, opts = {}) => {
/**
* Emitter
*/
const events = mitt()
/**
* Merge options with defaults
*/
const config = merge({
content: (root.querySelector('.js-content') || root).innerHTML,
resize: true,
placeholder: true,
offsets: [],
close: Array.prototype.slice.call(document.querySelectorAll('.js-promobarClose')),
lifespan: 1
}, opts)
if (!config.content){ return error.content() }
/**
constructor() {
super();
this._bus = new mitt();
this._manager = new Manager(this._bus);
this._manager.mount();
}
function synchronizeFactory (getHttp, getInterval, getSync, getId, logger) {
const emitter = mitt()
const synchronize = messageId => {
const url = UrlBuilder('api/v2/sdk/sync')
.param('last_received_comment_id', messageId)
.build()
return getHttp()
.get(url)
.then(resp => {
const results = resp.body.results
const messages = results.comments
const lastMessageId = results.meta.last_received_comment_id
messages.sort((a, b) => a.id - b.id)
return Promise.resolve({
lastMessageId,
messages,
interval: getInterval()
const removeLeft = () => {
lText.updateLabel('');
leftPress = null;
setButtonVisibility('left', false);
};
const removeRight = () => {
rText.updateLabel('');
rightPress = null;
setButtonVisibility('right', false);
};
let currentParam;
const controllers = Object.assign(
emitter(),
{
update(param) {
if (param === currentParam) return;
currentParam = param;
const { left, right, removeOnPress } = param || {};
if (left) {
lText.updateLabel(left.text);
if (left.onPress) {
setButtonVisibility('left', true);
}
leftPress = () => {
if (left.removeOnPress || removeOnPress) {
removeLeft();
}
if (removeOnPress) {
removeRight();
export default () => {
let self = emitter();
self.data = {};
self.subscribe = fn => {
self.on('change', fn);
};
self.unsubscribe = fn => {
self.off('change', fn);
};
self.getState = () => self.data;
self.setState = state => {
for (let i in state) if (state.hasOwnProperty(i)) {
self.data[i] = state[i];