@iflix/events-receiver-client
Advanced tools
Comparing version 1.0.0-beta.10 to 1.0.1
@@ -20,2 +20,2 @@ import { createQueue } from './queue'; | ||
export declare type EventQueuer = ReturnType<typeof createQueue>; | ||
export declare function createClient({ buffer: bufferOptions, submitUrl, client: clientInfo }: ClientOptions): EventQueuer; | ||
export declare function createClient({ buffer: bufferOptions, submitUrl, client: clientInfo }: ClientOptions): Promise<EventQueuer>; |
@@ -38,5 +38,5 @@ "use strict"; | ||
}); | ||
function createBuffer(options) { | ||
async function createBuffer(options) { | ||
var _a; | ||
if (idb_1.idbAvailable()) { | ||
if (await idb_1.idbAvailable()) { | ||
return new IndexedDbBuffer_1.IndexedDbBuffer((_a = options) === null || _a === void 0 ? void 0 : _a.indexedDb); | ||
@@ -48,3 +48,3 @@ } | ||
} | ||
function createClient({ buffer: bufferOptions, submitUrl, client: clientInfo }) { | ||
async function createClient({ buffer: bufferOptions, submitUrl, client: clientInfo }) { | ||
const send = sender_1.createSender({ | ||
@@ -60,3 +60,3 @@ submitUrl, | ||
send, | ||
buffer: createBuffer(bufferOptions) | ||
buffer: await createBuffer(bufferOptions) | ||
}); | ||
@@ -63,0 +63,0 @@ return queueEvent; |
declare type Transactor<T> = (store: IDBObjectStore) => T; | ||
export declare function idbAvailable(): boolean; | ||
export declare function idbAvailable(): Promise<boolean>; | ||
export declare class IdbKv { | ||
@@ -4,0 +4,0 @@ db: Promise<IDBDatabase>; |
@@ -44,4 +44,13 @@ "use strict"; | ||
} | ||
function idbAvailable() { | ||
return typeof indexedDB !== 'undefined'; | ||
async function idbAvailable() { | ||
// we need to try open db to test if it is available as it can be blocked | ||
try { | ||
if (typeof indexedDB === 'undefined') | ||
return false; | ||
const testdb = new IdbKv('availabilityTest', 'availabilityTest'); | ||
await testdb.db; | ||
return true; | ||
} | ||
catch (e) { } | ||
return false; | ||
} | ||
@@ -48,0 +57,0 @@ exports.idbAvailable = idbAvailable; |
@@ -42,4 +42,14 @@ "use strict"; | ||
exports.StorageMap = StorageMap; | ||
function isLocalStorageAvailable() { | ||
try { | ||
if (typeof localStorage === 'undefined') | ||
return false; | ||
localStorage.getItem('availabilityTestItem'); | ||
return true; | ||
} | ||
catch (e) { } | ||
return false; | ||
} | ||
function tryCreateLocalStorageMap(ttlSeconds) { | ||
if (typeof localStorage === 'undefined') { | ||
if (!isLocalStorageAvailable()) { | ||
return undefined; | ||
@@ -46,0 +56,0 @@ } |
{ | ||
"name": "@iflix/events-receiver-client", | ||
"version": "1.0.0-beta.10", | ||
"version": "1.0.1", | ||
"description": "Decodes (and encodes) user tokens", | ||
@@ -5,0 +5,0 @@ "main": "built/src/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
70274
1135
1
2