Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
recordSourceOptions: CacheOptions = {},
storeOptions: {
persistOptions?: CacheOptionsStore;
gcScheduler?: Scheduler;
operationLoader?: OperationLoader;
getDataID?: any; // do not use
} = {},
offlineStoreOptions: CacheOptions = {},
): RelayModernEnvironment {
let idbStore: CacheOptions;
let idbRecords: CacheOptions;
let idbOffline: CacheOptions;
const { gcScheduler, operationLoader, getDataID, persistOptions } = storeOptions;
if (typeof window !== 'undefined') {
const { name = 'relay', onUpgrade, version } = idbOptions;
const idbStorages: ICacheStorage[] = IDBStorage.create({
name,
storeNames: ['store', 'records', 'offline'],
onUpgrade,
version,
});
idbStore = {
storage: idbStorages[0],
serialize: false,
prefix: null,
...persistOptions,
};
idbRecords = {
storage: idbStorages[1],
serialize: false,
let promiseRestore;
const {
disablePersist = !persistOptions,
version = -1,
key = 'root', // TODO verify
whitelist = undefined,
blacklist = undefined,
mutateKeys = undefined,
mutateValues = undefined,
migrate = (s: any, v: number) => Promise.resolve(s),
stateReconciler = (s: any, o: any, r: any, c: any) => s,
} = persistOptions || {};
const prefix = `persist:${key}`;
const reduxPersistKey = `redux-persist`;
const migrateReduxPersistKey = mutateKeysLayer(
(key) => (key === `${prefix}.${reduxPersistKey}` ? prefix : key),
(key) => (key === prefix ? `${prefix}.${reduxPersistKey}` : key),
);
const internalMutateKeys = [migrateReduxPersistKey, prefixLayer(prefix)];
if (whitelist) {
internalMutateKeys.push(filterKeys((key) => whitelist.includes(key)));
}
if (blacklist) {
internalMutateKeys.push(filterKeys((key) => !blacklist.includes(key)));
}
const customMutateKeys = mutateKeys ? internalMutateKeys.concat(mutateKeys) : internalMutateKeys;
const cache: ICache = new Cache({
disablePersist,
prefix: null,
version = -1,
key = 'root', // TODO verify
whitelist = undefined,
blacklist = undefined,
mutateKeys = undefined,
mutateValues = undefined,
migrate = (s: any, v: number) => Promise.resolve(s),
stateReconciler = (s: any, o: any, r: any, c: any) => s,
} = persistOptions || {};
const prefix = `persist:${key}`;
const reduxPersistKey = `redux-persist`;
const migrateReduxPersistKey = mutateKeysLayer(
(key) => (key === `${prefix}.${reduxPersistKey}` ? prefix : key),
(key) => (key === prefix ? `${prefix}.${reduxPersistKey}` : key),
);
const internalMutateKeys = [migrateReduxPersistKey, prefixLayer(prefix)];
if (whitelist) {
internalMutateKeys.push(filterKeys((key) => whitelist.includes(key)));
}
if (blacklist) {
internalMutateKeys.push(filterKeys((key) => !blacklist.includes(key)));
}
const customMutateKeys = mutateKeys ? internalMutateKeys.concat(mutateKeys) : internalMutateKeys;
const cache: ICache = new Cache({
disablePersist,
prefix: null,
mutateKeys: customMutateKeys,
mutateValues,
initialState: preloadedState,
mergeState: async (originalRestoredState = {}, initialState = {}) => {
console.log(idbStorages);
const CacheLocalIDBNO = new Cache({
prefix: null,
serialize: false,
storage: idbStorageNo[0],
});
const CacheLocalIDB = new Cache({
layers: [filterNoPersistReplace],
serialize: false,
storage: idbStorages[0],
});
const CacheLocalIDB2 = new Cache({
layers: [filterPersistReplace],
serialize: false,
storage: idbStorages[1],
});
const CacheLocalDisable = new Cache({
disablePersist: true
});
const App = () => {
return
const StyledApp = styled.div`
display: flex;
justify-content: center;
flex-direction: column-reverse;
`;
const filterPersistReplace: ILayer = filterKeys(key => key.includes("replace"));
const filterNoPersistReplace: ILayer = filterKeys(key => !key.includes("replace"));
const CacheLocal = new Cache({
layers: [filterNoPersistReplace],
});
const CacheLocalNew = new Cache({
errorHandling: (error) => {
console.log("error", error);
return true;
},
layers: [filterPersistReplace],
prefix: 'cachenew',
});
const CacheSessionNew = new Cache({
prefix: 'cachenew',
webStorage: 'session'
});
const idbStorages: CacheStorage[] = IDBStorage.create( {
name: "cache",
onUpgrade: (db, oldv, newv, transaction) => {
const filterNoPersistReplace: ILayer = filterKeys(key => !key.includes("replace"));
const CacheLocal = new Cache({
layers: [filterNoPersistReplace],
});
const CacheLocalNew = new Cache({
errorHandling: (error) => {
console.log("error", error);
return true;
},
layers: [filterPersistReplace],
prefix: 'cachenew',
});
const CacheSessionNew = new Cache({
prefix: 'cachenew',
webStorage: 'session'
});
const idbStorages: CacheStorage[] = IDBStorage.create( {
name: "cache",
onUpgrade: (db, oldv, newv, transaction) => {
console.log("onUpgrade", db, oldv, newv, transaction);
},
storeNames: ["persist", "persist2"],
version: 1,
});
const idbStorageNo: CacheStorage[] = IDBStorage.create( {
name: "nocache",
-moz-osx-font-smoothing: grayscale;
font-weight: 300;
}
`
const StyledApp = styled.div`
display: flex;
justify-content: center;
flex-direction: column-reverse;
`;
const filterPersistReplace: ILayer = filterKeys(key => key.includes("replace"));
const filterNoPersistReplace: ILayer = filterKeys(key => !key.includes("replace"));
const CacheLocal = new Cache({
layers: [filterNoPersistReplace],
});
const CacheLocalNew = new Cache({
errorHandling: (error) => {
console.log("error", error);
return true;
},
layers: [filterPersistReplace],
prefix: 'cachenew',
});
const CacheSessionNew = new Cache({
prefix: 'cachenew',
webStorage: 'session'
});
storeNames: ["persist"],
version: 1,
});
console.log(idbStorages[0]);
console.log(idbStorages);
const CacheLocalIDBNO = new Cache({
prefix: null,
serialize: false,
storage: idbStorageNo[0],
});
const CacheLocalIDB = new Cache({
layers: [filterNoPersistReplace],
serialize: false,
storage: idbStorages[0],
});
const CacheLocalIDB2 = new Cache({
layers: [filterPersistReplace],
serialize: false,
storage: idbStorages[1],
});
const CacheLocalDisable = new Cache({
disablePersist: true
});
const CacheLocalNew = new Cache({
errorHandling: (error) => {
console.log("error", error);
return true;
},
layers: [filterPersistReplace],
prefix: 'cachenew',
});
const CacheSessionNew = new Cache({
prefix: 'cachenew',
webStorage: 'session'
});
const idbStorages: CacheStorage[] = IDBStorage.create( {
name: "cache",
onUpgrade: (db, oldv, newv, transaction) => {
console.log("onUpgrade", db, oldv, newv, transaction);
},
storeNames: ["persist", "persist2"],
version: 1,
});
const idbStorageNo: CacheStorage[] = IDBStorage.create( {
name: "nocache",
onUpgrade: (db, oldv, newv, transaction) => {
console.log("onUpgrade", db, oldv, newv, transaction);
},
storeNames: ["persist"],
version: 1,
const CacheSessionNew = new Cache({
prefix: 'cachenew',
webStorage: 'session'
});
const idbStorages: CacheStorage[] = IDBStorage.create( {
name: "cache",
onUpgrade: (db, oldv, newv, transaction) => {
console.log("onUpgrade", db, oldv, newv, transaction);
},
storeNames: ["persist", "persist2"],
version: 1,
});
const idbStorageNo: CacheStorage[] = IDBStorage.create( {
name: "nocache",
onUpgrade: (db, oldv, newv, transaction) => {
console.log("onUpgrade", db, oldv, newv, transaction);
},
storeNames: ["persist"],
version: 1,
});
console.log(idbStorages[0]);
console.log(idbStorages);
const CacheLocalIDBNO = new Cache({
prefix: null,
serialize: false,