Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var minimongo = require('minimongo');
var IndexedDb = minimongo.IndexedDb;
var db = new IndexedDb({namespace: "baqend"}, () => {
});
var className;
var CACHE_NAME = 'trillo-v1';
var PREFIX = location.origin;
var REFRESH = 60000; // Bloom filter refresh rate
var bloomFilter;
var bloomFilterReady = false;
self.addEventListener('install', event => {
// Bypass the waiting lifecycle stage,
// just in case there's an older version of this SW registration.
event.waitUntil(self.skipWaiting());
});
new minimongo.MemoryDb({namespace: this.namespace}, localDb => {
const hybridDb = new minimongo.HybridDb(localDb, this.remoteDb);
let type;
if (localDb instanceof minimongo.IndexedDb) {
type = 'IndexedDb';
} else if (localDb instanceof minimongo.LocalStorageDb) {
type = 'LocalStorageDb';
} else if (localDb instanceof minimongo.MemoryDb) {
type = 'MemoryDb';
} else if (localDb instanceof minimongo.WebSQLDb) {
type = 'WebSQLDb';
} else {
throw new Error('Can\'t identify db');
}
this.hybridDb = hybridDb;
resolve(hybridDb, type)
}, reject);
});
'use strict';
const Observable = require('../observable');
const message = require('../message');
const Message = require('../connector/Message');
const StatusCode = Message.StatusCode;
const minimongo = require('minimongo');
const IndexedDb = minimongo.IndexedDb;
let savedObjectsCollection = 'savedObjectsCollection';
let deletedObjectsCollection = 'deletedObjectsCollection';
/**
* @alias OfflineService
*/
class OfflineService {
/**
* @param {EntityManager} entityManager The EntityManager which of this offlineService instance
*/
constructor(entityManager) {
this.entityManager = entityManager;
this.entityManagerFactory = entityManager.entityManagerFactory;
this.online = new Observable((observer) => {