@@ -36,10 +36,10 @@ export interface IModuleCollector {
3636export interface IRequestInfoCollector {
3737 getRequestInfo ( context : EventPluginContext ) : IRequestInfo ;
3838}
39- export interface IStorage < T > {
40- save ( path : string , value : T ) : boolean ;
41- get ( path : string ) : T ;
42- getList ( searchPattern ?: string , limit ?: number ) : IStorageItem < T > [ ] ;
39+ export interface IStorage {
40+ save ( path : string , value : any ) : boolean ;
41+ get ( path : string ) : any ;
42+ getList ( searchPattern ?: string , limit ?: number ) : IStorageItem [ ] ;
4343 remove ( path : string ) : void ;
4444}
4545export interface ISubmissionAdapter {
@@ -62,7 +62,7 @@ export interface IConfigurationSettings {
6262 submissionBatchSize ?: number ;
6363 submissionClient ?: ISubmissionClient ;
6464 submissionAdapter ?: ISubmissionAdapter ;
65- storage ?: IStorage < any > ;
65+ storage ?: IStorage ;
6666 queue ?: IEventQueue ;
6767}
6868export declare class SettingsManager {
@@ -143,13 +143,13 @@ export declare class DefaultEventQueue implements IEventQueue {
143143 private processSubmissionResponse ( response , events ) ;
144144 private removeEvents ( events ) ;
145145}
146- export declare class InMemoryStorage < T > implements IStorage < T > {
146+ export declare class InMemoryStorage implements IStorage {
147147 private _items ;
148148 private _maxItems ;
149149 constructor ( maxItems ?: number ) ;
150- save ( path : string , value : T ) : boolean ;
151- get ( path : string ) : T ;
152- getList ( searchPattern ?: string , limit ?: number ) : IStorageItem < T > [ ] ;
150+ save ( path : string , value : any ) : boolean ;
151+ get ( path : string ) : any ;
152+ getList ( searchPattern ?: string , limit ?: number ) : IStorageItem [ ] ;
153153 remove ( path : string ) : void ;
154154}
155155export declare class DefaultSubmissionClient implements ISubmissionClient {
@@ -188,7 +188,7 @@ export declare class Configuration implements IConfigurationSettings {
188188 submissionAdapter : ISubmissionAdapter ;
189189 submissionClient : ISubmissionClient ;
190190 settings : Object ;
191- storage : IStorage < Object > ;
191+ storage : IStorage ;
192192 queue : IEventQueue ;
193193 private _plugins ;
194194 constructor ( configSettings ?: IConfigurationSettings ) ;
@@ -215,6 +215,7 @@ export declare class Configuration implements IConfigurationSettings {
215215 userAgent : string ;
216216 useSessions ( sendHeartbeats ?: boolean ) : void ;
217217 useReferenceIds ( ) : void ;
218+ useLocalStorage ( ) : void ;
218219 useDebugLogger ( ) : void ;
219220 static defaults : IConfigurationSettings ;
220221}
@@ -414,10 +415,10 @@ export declare class DuplicateCheckerPlugin implements IEventPlugin {
414415export interface IError extends IInnerError {
415416 modules ?: IModule [ ] ;
416417}
417- export interface IStorageItem < T > {
418+ export interface IStorageItem {
418419 created : number ;
419420 path : string ;
420- value : T ;
421+ value : any ;
421422}
422423export interface SubmissionCallback {
423424 ( status : number , message : string , data ?: string , headers ?: Object ) : void ;
@@ -442,6 +443,34 @@ export interface IClientConfiguration {
442443 settings : Object ;
443444 version : number ;
444445}
446+ export declare abstract class KeyValueStorageBase implements IStorage {
447+ private maxItems ;
448+ private timestamp ;
449+ private index ;
450+ constructor ( maxItems : any ) ;
451+ save ( path : string , value : any ) : boolean ;
452+ get ( path : string ) : any ;
453+ getList ( searchPattern ?: string , limit ?: number ) : IStorageItem [ ] ;
454+ remove ( path : string ) : void ;
455+ protected abstract write ( key : string , value : string ) : void ;
456+ protected abstract read ( key : string ) : string ;
457+ protected abstract readDate ( key : string ) : number ;
458+ protected abstract delete ( key : string ) : any ;
459+ protected abstract getEntries ( ) : string [ ] ;
460+ protected getKey ( entry : {
461+ name : string ;
462+ timestamp : number ;
463+ } ) : string ;
464+ protected getEntry ( encodedEntry : string ) : {
465+ name : string ;
466+ timestamp : number ;
467+ } ;
468+ private ensureIndex ( ) ;
469+ private loadEntry ( entry ) ;
470+ private findEntry ( path ) ;
471+ private removeEntry ( entry ) ;
472+ private createIndex ( ) ;
473+ }
445474export declare class DefaultErrorParser implements IErrorParser {
446475 parse ( context : EventPluginContext , exception : Error ) : IError ;
447476}
@@ -454,3 +483,14 @@ export declare class DefaultRequestInfoCollector implements IRequestInfoCollecto
454483export declare class DefaultSubmissionAdapter implements ISubmissionAdapter {
455484 sendRequest ( request : SubmissionRequest , callback : SubmissionCallback , isAppExiting ?: boolean ) : void ;
456485}
486+ export declare class BrowserStorage extends KeyValueStorageBase {
487+ private prefix ;
488+ static isAvailable ( ) : boolean ;
489+ constructor ( prefix ?: string , maxItems ?: number , fs ?: any ) ;
490+ write ( key : string , value : string ) : void ;
491+ read ( key : string ) : any ;
492+ readDate ( key : string ) : number ;
493+ delete ( key : string ) : void ;
494+ getEntries ( ) : string [ ] ;
495+ getKey ( entry : any ) : string ;
496+ }
0 commit comments