@xyo-network/previous-hash-store-storage 2.104.0 → 2.104.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -47,10 +47,8 @@ var StoragePreviousHashStore = class _StoragePreviousHashStore {
47
47
  _storage;
48
48
  _type = _StoragePreviousHashStore.DefaultStorageType;
49
49
  constructor(opts) {
50
- if (opts?.namespace)
51
- this._namespace = opts.namespace;
52
- if (opts?.type)
53
- this._type = opts.type;
50
+ if (opts?.namespace) this._namespace = opts.namespace;
51
+ if (opts?.type) this._type = opts.type;
54
52
  this._storage = import_store2.default[this.type].namespace(this.namespace);
55
53
  }
56
54
  get namespace() {
@@ -60,8 +58,7 @@ var StoragePreviousHashStore = class _StoragePreviousHashStore {
60
58
  return this._type;
61
59
  }
62
60
  get storage() {
63
- if (!this?._storage)
64
- this._storage = import_store2.default[this.type].namespace(this.namespace);
61
+ if (!this?._storage) this._storage = import_store2.default[this.type].namespace(this.namespace);
65
62
  return this._storage;
66
63
  }
67
64
  async getItem(address) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts","../../src/StoragePreviousHashStore.ts"],"sourcesContent":["export * from './StoragePreviousHashStore'\n","import { Address, Hash } from '@xylabs/hex'\nimport { PreviousHashStore } from '@xyo-network/previous-hash-store-model'\nimport store, { StoreBase } from 'store2'\n\nexport type Storage = 'local' | 'session' | 'page'\n\nexport type StoragePreviousHashOpts = {\n namespace?: string\n type?: Storage\n}\n\nexport class StoragePreviousHashStore implements PreviousHashStore {\n static readonly DefaultNamespace = 'xyo-previous-hash-store'\n static readonly DefaultStorageType: Storage = 'local'\n private _namespace = StoragePreviousHashStore.DefaultNamespace\n private _storage: StoreBase | undefined\n private _type: Storage = StoragePreviousHashStore.DefaultStorageType\n\n constructor(opts?: StoragePreviousHashOpts) {\n if (opts?.namespace) this._namespace = opts.namespace\n if (opts?.type) this._type = opts.type\n this._storage = store[this.type].namespace(this.namespace)\n }\n\n get namespace() {\n return this._namespace\n }\n\n get type(): Storage {\n return this._type\n }\n\n private get storage(): StoreBase {\n if (!this?._storage) this._storage = store[this.type].namespace(this.namespace)\n return this._storage\n }\n\n async getItem(address: Address): Promise<Hash | null> {\n const value = await this.storage.get(address)\n return value ?? null\n }\n async removeItem(address: Address): Promise<void> {\n await this.storage.remove(address)\n }\n async setItem(address: Address, previousHash: Hash): Promise<void> {\n await this.storage.set(address, previousHash)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;ACEA,oBAAiC;AAS1B,IAAMA,2BAAN,MAAMA,0BAAAA;EATb,OASaA;;;EACX,OAAgBC,mBAAmB;EACnC,OAAgBC,qBAA8B;EACtCC,aAAaH,0BAAyBC;EACtCG;EACAC,QAAiBL,0BAAyBE;EAElDI,YAAYC,MAAgC;AAC1C,QAAIA,MAAMC;AAAW,WAAKL,aAAaI,KAAKC;AAC5C,QAAID,MAAME;AAAM,WAAKJ,QAAQE,KAAKE;AAClC,SAAKL,WAAWM,cAAAA,QAAM,KAAKD,IAAI,EAAED,UAAU,KAAKA,SAAS;EAC3D;EAEA,IAAIA,YAAY;AACd,WAAO,KAAKL;EACd;EAEA,IAAIM,OAAgB;AAClB,WAAO,KAAKJ;EACd;EAEA,IAAYM,UAAqB;AAC/B,QAAI,CAAC,MAAMP;AAAU,WAAKA,WAAWM,cAAAA,QAAM,KAAKD,IAAI,EAAED,UAAU,KAAKA,SAAS;AAC9E,WAAO,KAAKJ;EACd;EAEA,MAAMQ,QAAQC,SAAwC;AACpD,UAAMC,QAAQ,MAAM,KAAKH,QAAQI,IAAIF,OAAAA;AACrC,WAAOC,SAAS;EAClB;EACA,MAAME,WAAWH,SAAiC;AAChD,UAAM,KAAKF,QAAQM,OAAOJ,OAAAA;EAC5B;EACA,MAAMK,QAAQL,SAAkBM,cAAmC;AACjE,UAAM,KAAKR,QAAQS,IAAIP,SAASM,YAAAA;EAClC;AACF;","names":["StoragePreviousHashStore","DefaultNamespace","DefaultStorageType","_namespace","_storage","_type","constructor","opts","namespace","type","store","storage","getItem","address","value","get","removeItem","remove","setItem","previousHash","set"]}
1
+ {"version":3,"sources":["../../src/index.ts","../../src/StoragePreviousHashStore.ts"],"sourcesContent":["export * from './StoragePreviousHashStore'\n","import { Address, Hash } from '@xylabs/hex'\nimport { PreviousHashStore } from '@xyo-network/previous-hash-store-model'\nimport store, { StoreBase } from 'store2'\n\nexport type Storage = 'local' | 'session' | 'page'\n\nexport type StoragePreviousHashOpts = {\n namespace?: string\n type?: Storage\n}\n\nexport class StoragePreviousHashStore implements PreviousHashStore {\n static readonly DefaultNamespace = 'xyo-previous-hash-store'\n static readonly DefaultStorageType: Storage = 'local'\n private _namespace = StoragePreviousHashStore.DefaultNamespace\n private _storage: StoreBase | undefined\n private _type: Storage = StoragePreviousHashStore.DefaultStorageType\n\n constructor(opts?: StoragePreviousHashOpts) {\n if (opts?.namespace) this._namespace = opts.namespace\n if (opts?.type) this._type = opts.type\n this._storage = store[this.type].namespace(this.namespace)\n }\n\n get namespace() {\n return this._namespace\n }\n\n get type(): Storage {\n return this._type\n }\n\n private get storage(): StoreBase {\n if (!this?._storage) this._storage = store[this.type].namespace(this.namespace)\n return this._storage\n }\n\n async getItem(address: Address): Promise<Hash | null> {\n const value = await this.storage.get(address)\n return value ?? null\n }\n async removeItem(address: Address): Promise<void> {\n await this.storage.remove(address)\n }\n async setItem(address: Address, previousHash: Hash): Promise<void> {\n await this.storage.set(address, previousHash)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;ACEA,oBAAiC;AAS1B,IAAMA,2BAAN,MAAMA,0BAAAA;EATb,OASaA;;;EACX,OAAgBC,mBAAmB;EACnC,OAAgBC,qBAA8B;EACtCC,aAAaH,0BAAyBC;EACtCG;EACAC,QAAiBL,0BAAyBE;EAElDI,YAAYC,MAAgC;AAC1C,QAAIA,MAAMC,UAAW,MAAKL,aAAaI,KAAKC;AAC5C,QAAID,MAAME,KAAM,MAAKJ,QAAQE,KAAKE;AAClC,SAAKL,WAAWM,cAAAA,QAAM,KAAKD,IAAI,EAAED,UAAU,KAAKA,SAAS;EAC3D;EAEA,IAAIA,YAAY;AACd,WAAO,KAAKL;EACd;EAEA,IAAIM,OAAgB;AAClB,WAAO,KAAKJ;EACd;EAEA,IAAYM,UAAqB;AAC/B,QAAI,CAAC,MAAMP,SAAU,MAAKA,WAAWM,cAAAA,QAAM,KAAKD,IAAI,EAAED,UAAU,KAAKA,SAAS;AAC9E,WAAO,KAAKJ;EACd;EAEA,MAAMQ,QAAQC,SAAwC;AACpD,UAAMC,QAAQ,MAAM,KAAKH,QAAQI,IAAIF,OAAAA;AACrC,WAAOC,SAAS;EAClB;EACA,MAAME,WAAWH,SAAiC;AAChD,UAAM,KAAKF,QAAQM,OAAOJ,OAAAA;EAC5B;EACA,MAAMK,QAAQL,SAAkBM,cAAmC;AACjE,UAAM,KAAKR,QAAQS,IAAIP,SAASM,YAAAA;EAClC;AACF;","names":["StoragePreviousHashStore","DefaultNamespace","DefaultStorageType","_namespace","_storage","_type","constructor","opts","namespace","type","store","storage","getItem","address","value","get","removeItem","remove","setItem","previousHash","set"]}
@@ -13,10 +13,8 @@ var StoragePreviousHashStore = class _StoragePreviousHashStore {
13
13
  _storage;
14
14
  _type = _StoragePreviousHashStore.DefaultStorageType;
15
15
  constructor(opts) {
16
- if (opts?.namespace)
17
- this._namespace = opts.namespace;
18
- if (opts?.type)
19
- this._type = opts.type;
16
+ if (opts?.namespace) this._namespace = opts.namespace;
17
+ if (opts?.type) this._type = opts.type;
20
18
  this._storage = store[this.type].namespace(this.namespace);
21
19
  }
22
20
  get namespace() {
@@ -26,8 +24,7 @@ var StoragePreviousHashStore = class _StoragePreviousHashStore {
26
24
  return this._type;
27
25
  }
28
26
  get storage() {
29
- if (!this?._storage)
30
- this._storage = store[this.type].namespace(this.namespace);
27
+ if (!this?._storage) this._storage = store[this.type].namespace(this.namespace);
31
28
  return this._storage;
32
29
  }
33
30
  async getItem(address) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/StoragePreviousHashStore.ts"],"sourcesContent":["import { Address, Hash } from '@xylabs/hex'\nimport { PreviousHashStore } from '@xyo-network/previous-hash-store-model'\nimport store, { StoreBase } from 'store2'\n\nexport type Storage = 'local' | 'session' | 'page'\n\nexport type StoragePreviousHashOpts = {\n namespace?: string\n type?: Storage\n}\n\nexport class StoragePreviousHashStore implements PreviousHashStore {\n static readonly DefaultNamespace = 'xyo-previous-hash-store'\n static readonly DefaultStorageType: Storage = 'local'\n private _namespace = StoragePreviousHashStore.DefaultNamespace\n private _storage: StoreBase | undefined\n private _type: Storage = StoragePreviousHashStore.DefaultStorageType\n\n constructor(opts?: StoragePreviousHashOpts) {\n if (opts?.namespace) this._namespace = opts.namespace\n if (opts?.type) this._type = opts.type\n this._storage = store[this.type].namespace(this.namespace)\n }\n\n get namespace() {\n return this._namespace\n }\n\n get type(): Storage {\n return this._type\n }\n\n private get storage(): StoreBase {\n if (!this?._storage) this._storage = store[this.type].namespace(this.namespace)\n return this._storage\n }\n\n async getItem(address: Address): Promise<Hash | null> {\n const value = await this.storage.get(address)\n return value ?? null\n }\n async removeItem(address: Address): Promise<void> {\n await this.storage.remove(address)\n }\n async setItem(address: Address, previousHash: Hash): Promise<void> {\n await this.storage.set(address, previousHash)\n }\n}\n"],"mappings":";;;;AAEA,OAAOA,WAA0B;AAS1B,IAAMC,2BAAN,MAAMA,0BAAAA;EATb,OASaA;;;EACX,OAAgBC,mBAAmB;EACnC,OAAgBC,qBAA8B;EACtCC,aAAaH,0BAAyBC;EACtCG;EACAC,QAAiBL,0BAAyBE;EAElDI,YAAYC,MAAgC;AAC1C,QAAIA,MAAMC;AAAW,WAAKL,aAAaI,KAAKC;AAC5C,QAAID,MAAME;AAAM,WAAKJ,QAAQE,KAAKE;AAClC,SAAKL,WAAWM,MAAM,KAAKD,IAAI,EAAED,UAAU,KAAKA,SAAS;EAC3D;EAEA,IAAIA,YAAY;AACd,WAAO,KAAKL;EACd;EAEA,IAAIM,OAAgB;AAClB,WAAO,KAAKJ;EACd;EAEA,IAAYM,UAAqB;AAC/B,QAAI,CAAC,MAAMP;AAAU,WAAKA,WAAWM,MAAM,KAAKD,IAAI,EAAED,UAAU,KAAKA,SAAS;AAC9E,WAAO,KAAKJ;EACd;EAEA,MAAMQ,QAAQC,SAAwC;AACpD,UAAMC,QAAQ,MAAM,KAAKH,QAAQI,IAAIF,OAAAA;AACrC,WAAOC,SAAS;EAClB;EACA,MAAME,WAAWH,SAAiC;AAChD,UAAM,KAAKF,QAAQM,OAAOJ,OAAAA;EAC5B;EACA,MAAMK,QAAQL,SAAkBM,cAAmC;AACjE,UAAM,KAAKR,QAAQS,IAAIP,SAASM,YAAAA;EAClC;AACF;","names":["store","StoragePreviousHashStore","DefaultNamespace","DefaultStorageType","_namespace","_storage","_type","constructor","opts","namespace","type","store","storage","getItem","address","value","get","removeItem","remove","setItem","previousHash","set"]}
1
+ {"version":3,"sources":["../../src/StoragePreviousHashStore.ts"],"sourcesContent":["import { Address, Hash } from '@xylabs/hex'\nimport { PreviousHashStore } from '@xyo-network/previous-hash-store-model'\nimport store, { StoreBase } from 'store2'\n\nexport type Storage = 'local' | 'session' | 'page'\n\nexport type StoragePreviousHashOpts = {\n namespace?: string\n type?: Storage\n}\n\nexport class StoragePreviousHashStore implements PreviousHashStore {\n static readonly DefaultNamespace = 'xyo-previous-hash-store'\n static readonly DefaultStorageType: Storage = 'local'\n private _namespace = StoragePreviousHashStore.DefaultNamespace\n private _storage: StoreBase | undefined\n private _type: Storage = StoragePreviousHashStore.DefaultStorageType\n\n constructor(opts?: StoragePreviousHashOpts) {\n if (opts?.namespace) this._namespace = opts.namespace\n if (opts?.type) this._type = opts.type\n this._storage = store[this.type].namespace(this.namespace)\n }\n\n get namespace() {\n return this._namespace\n }\n\n get type(): Storage {\n return this._type\n }\n\n private get storage(): StoreBase {\n if (!this?._storage) this._storage = store[this.type].namespace(this.namespace)\n return this._storage\n }\n\n async getItem(address: Address): Promise<Hash | null> {\n const value = await this.storage.get(address)\n return value ?? null\n }\n async removeItem(address: Address): Promise<void> {\n await this.storage.remove(address)\n }\n async setItem(address: Address, previousHash: Hash): Promise<void> {\n await this.storage.set(address, previousHash)\n }\n}\n"],"mappings":";;;;AAEA,OAAOA,WAA0B;AAS1B,IAAMC,2BAAN,MAAMA,0BAAAA;EATb,OASaA;;;EACX,OAAgBC,mBAAmB;EACnC,OAAgBC,qBAA8B;EACtCC,aAAaH,0BAAyBC;EACtCG;EACAC,QAAiBL,0BAAyBE;EAElDI,YAAYC,MAAgC;AAC1C,QAAIA,MAAMC,UAAW,MAAKL,aAAaI,KAAKC;AAC5C,QAAID,MAAME,KAAM,MAAKJ,QAAQE,KAAKE;AAClC,SAAKL,WAAWM,MAAM,KAAKD,IAAI,EAAED,UAAU,KAAKA,SAAS;EAC3D;EAEA,IAAIA,YAAY;AACd,WAAO,KAAKL;EACd;EAEA,IAAIM,OAAgB;AAClB,WAAO,KAAKJ;EACd;EAEA,IAAYM,UAAqB;AAC/B,QAAI,CAAC,MAAMP,SAAU,MAAKA,WAAWM,MAAM,KAAKD,IAAI,EAAED,UAAU,KAAKA,SAAS;AAC9E,WAAO,KAAKJ;EACd;EAEA,MAAMQ,QAAQC,SAAwC;AACpD,UAAMC,QAAQ,MAAM,KAAKH,QAAQI,IAAIF,OAAAA;AACrC,WAAOC,SAAS;EAClB;EACA,MAAME,WAAWH,SAAiC;AAChD,UAAM,KAAKF,QAAQM,OAAOJ,OAAAA;EAC5B;EACA,MAAMK,QAAQL,SAAkBM,cAAmC;AACjE,UAAM,KAAKR,QAAQS,IAAIP,SAASM,YAAAA;EAClC;AACF;","names":["store","StoragePreviousHashStore","DefaultNamespace","DefaultStorageType","_namespace","_storage","_type","constructor","opts","namespace","type","store","storage","getItem","address","value","get","removeItem","remove","setItem","previousHash","set"]}
@@ -47,10 +47,8 @@ var StoragePreviousHashStore = class _StoragePreviousHashStore {
47
47
  _storage;
48
48
  _type = _StoragePreviousHashStore.DefaultStorageType;
49
49
  constructor(opts) {
50
- if (opts?.namespace)
51
- this._namespace = opts.namespace;
52
- if (opts?.type)
53
- this._type = opts.type;
50
+ if (opts?.namespace) this._namespace = opts.namespace;
51
+ if (opts?.type) this._type = opts.type;
54
52
  this._storage = import_store2.default[this.type].namespace(this.namespace);
55
53
  }
56
54
  get namespace() {
@@ -60,8 +58,7 @@ var StoragePreviousHashStore = class _StoragePreviousHashStore {
60
58
  return this._type;
61
59
  }
62
60
  get storage() {
63
- if (!this?._storage)
64
- this._storage = import_store2.default[this.type].namespace(this.namespace);
61
+ if (!this?._storage) this._storage = import_store2.default[this.type].namespace(this.namespace);
65
62
  return this._storage;
66
63
  }
67
64
  async getItem(address) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts","../../src/StoragePreviousHashStore.ts"],"sourcesContent":["export * from './StoragePreviousHashStore'\n","import { Address, Hash } from '@xylabs/hex'\nimport { PreviousHashStore } from '@xyo-network/previous-hash-store-model'\nimport store, { StoreBase } from 'store2'\n\nexport type Storage = 'local' | 'session' | 'page'\n\nexport type StoragePreviousHashOpts = {\n namespace?: string\n type?: Storage\n}\n\nexport class StoragePreviousHashStore implements PreviousHashStore {\n static readonly DefaultNamespace = 'xyo-previous-hash-store'\n static readonly DefaultStorageType: Storage = 'local'\n private _namespace = StoragePreviousHashStore.DefaultNamespace\n private _storage: StoreBase | undefined\n private _type: Storage = StoragePreviousHashStore.DefaultStorageType\n\n constructor(opts?: StoragePreviousHashOpts) {\n if (opts?.namespace) this._namespace = opts.namespace\n if (opts?.type) this._type = opts.type\n this._storage = store[this.type].namespace(this.namespace)\n }\n\n get namespace() {\n return this._namespace\n }\n\n get type(): Storage {\n return this._type\n }\n\n private get storage(): StoreBase {\n if (!this?._storage) this._storage = store[this.type].namespace(this.namespace)\n return this._storage\n }\n\n async getItem(address: Address): Promise<Hash | null> {\n const value = await this.storage.get(address)\n return value ?? null\n }\n async removeItem(address: Address): Promise<void> {\n await this.storage.remove(address)\n }\n async setItem(address: Address, previousHash: Hash): Promise<void> {\n await this.storage.set(address, previousHash)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;ACEA,oBAAiC;AAS1B,IAAMA,2BAAN,MAAMA,0BAAAA;EATb,OASaA;;;EACX,OAAgBC,mBAAmB;EACnC,OAAgBC,qBAA8B;EACtCC,aAAaH,0BAAyBC;EACtCG;EACAC,QAAiBL,0BAAyBE;EAElDI,YAAYC,MAAgC;AAC1C,QAAIA,MAAMC;AAAW,WAAKL,aAAaI,KAAKC;AAC5C,QAAID,MAAME;AAAM,WAAKJ,QAAQE,KAAKE;AAClC,SAAKL,WAAWM,cAAAA,QAAM,KAAKD,IAAI,EAAED,UAAU,KAAKA,SAAS;EAC3D;EAEA,IAAIA,YAAY;AACd,WAAO,KAAKL;EACd;EAEA,IAAIM,OAAgB;AAClB,WAAO,KAAKJ;EACd;EAEA,IAAYM,UAAqB;AAC/B,QAAI,CAAC,MAAMP;AAAU,WAAKA,WAAWM,cAAAA,QAAM,KAAKD,IAAI,EAAED,UAAU,KAAKA,SAAS;AAC9E,WAAO,KAAKJ;EACd;EAEA,MAAMQ,QAAQC,SAAwC;AACpD,UAAMC,QAAQ,MAAM,KAAKH,QAAQI,IAAIF,OAAAA;AACrC,WAAOC,SAAS;EAClB;EACA,MAAME,WAAWH,SAAiC;AAChD,UAAM,KAAKF,QAAQM,OAAOJ,OAAAA;EAC5B;EACA,MAAMK,QAAQL,SAAkBM,cAAmC;AACjE,UAAM,KAAKR,QAAQS,IAAIP,SAASM,YAAAA;EAClC;AACF;","names":["StoragePreviousHashStore","DefaultNamespace","DefaultStorageType","_namespace","_storage","_type","constructor","opts","namespace","type","store","storage","getItem","address","value","get","removeItem","remove","setItem","previousHash","set"]}
1
+ {"version":3,"sources":["../../src/index.ts","../../src/StoragePreviousHashStore.ts"],"sourcesContent":["export * from './StoragePreviousHashStore'\n","import { Address, Hash } from '@xylabs/hex'\nimport { PreviousHashStore } from '@xyo-network/previous-hash-store-model'\nimport store, { StoreBase } from 'store2'\n\nexport type Storage = 'local' | 'session' | 'page'\n\nexport type StoragePreviousHashOpts = {\n namespace?: string\n type?: Storage\n}\n\nexport class StoragePreviousHashStore implements PreviousHashStore {\n static readonly DefaultNamespace = 'xyo-previous-hash-store'\n static readonly DefaultStorageType: Storage = 'local'\n private _namespace = StoragePreviousHashStore.DefaultNamespace\n private _storage: StoreBase | undefined\n private _type: Storage = StoragePreviousHashStore.DefaultStorageType\n\n constructor(opts?: StoragePreviousHashOpts) {\n if (opts?.namespace) this._namespace = opts.namespace\n if (opts?.type) this._type = opts.type\n this._storage = store[this.type].namespace(this.namespace)\n }\n\n get namespace() {\n return this._namespace\n }\n\n get type(): Storage {\n return this._type\n }\n\n private get storage(): StoreBase {\n if (!this?._storage) this._storage = store[this.type].namespace(this.namespace)\n return this._storage\n }\n\n async getItem(address: Address): Promise<Hash | null> {\n const value = await this.storage.get(address)\n return value ?? null\n }\n async removeItem(address: Address): Promise<void> {\n await this.storage.remove(address)\n }\n async setItem(address: Address, previousHash: Hash): Promise<void> {\n await this.storage.set(address, previousHash)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;ACEA,oBAAiC;AAS1B,IAAMA,2BAAN,MAAMA,0BAAAA;EATb,OASaA;;;EACX,OAAgBC,mBAAmB;EACnC,OAAgBC,qBAA8B;EACtCC,aAAaH,0BAAyBC;EACtCG;EACAC,QAAiBL,0BAAyBE;EAElDI,YAAYC,MAAgC;AAC1C,QAAIA,MAAMC,UAAW,MAAKL,aAAaI,KAAKC;AAC5C,QAAID,MAAME,KAAM,MAAKJ,QAAQE,KAAKE;AAClC,SAAKL,WAAWM,cAAAA,QAAM,KAAKD,IAAI,EAAED,UAAU,KAAKA,SAAS;EAC3D;EAEA,IAAIA,YAAY;AACd,WAAO,KAAKL;EACd;EAEA,IAAIM,OAAgB;AAClB,WAAO,KAAKJ;EACd;EAEA,IAAYM,UAAqB;AAC/B,QAAI,CAAC,MAAMP,SAAU,MAAKA,WAAWM,cAAAA,QAAM,KAAKD,IAAI,EAAED,UAAU,KAAKA,SAAS;AAC9E,WAAO,KAAKJ;EACd;EAEA,MAAMQ,QAAQC,SAAwC;AACpD,UAAMC,QAAQ,MAAM,KAAKH,QAAQI,IAAIF,OAAAA;AACrC,WAAOC,SAAS;EAClB;EACA,MAAME,WAAWH,SAAiC;AAChD,UAAM,KAAKF,QAAQM,OAAOJ,OAAAA;EAC5B;EACA,MAAMK,QAAQL,SAAkBM,cAAmC;AACjE,UAAM,KAAKR,QAAQS,IAAIP,SAASM,YAAAA;EAClC;AACF;","names":["StoragePreviousHashStore","DefaultNamespace","DefaultStorageType","_namespace","_storage","_type","constructor","opts","namespace","type","store","storage","getItem","address","value","get","removeItem","remove","setItem","previousHash","set"]}
@@ -13,10 +13,8 @@ var StoragePreviousHashStore = class _StoragePreviousHashStore {
13
13
  _storage;
14
14
  _type = _StoragePreviousHashStore.DefaultStorageType;
15
15
  constructor(opts) {
16
- if (opts?.namespace)
17
- this._namespace = opts.namespace;
18
- if (opts?.type)
19
- this._type = opts.type;
16
+ if (opts?.namespace) this._namespace = opts.namespace;
17
+ if (opts?.type) this._type = opts.type;
20
18
  this._storage = store[this.type].namespace(this.namespace);
21
19
  }
22
20
  get namespace() {
@@ -26,8 +24,7 @@ var StoragePreviousHashStore = class _StoragePreviousHashStore {
26
24
  return this._type;
27
25
  }
28
26
  get storage() {
29
- if (!this?._storage)
30
- this._storage = store[this.type].namespace(this.namespace);
27
+ if (!this?._storage) this._storage = store[this.type].namespace(this.namespace);
31
28
  return this._storage;
32
29
  }
33
30
  async getItem(address) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/StoragePreviousHashStore.ts"],"sourcesContent":["import { Address, Hash } from '@xylabs/hex'\nimport { PreviousHashStore } from '@xyo-network/previous-hash-store-model'\nimport store, { StoreBase } from 'store2'\n\nexport type Storage = 'local' | 'session' | 'page'\n\nexport type StoragePreviousHashOpts = {\n namespace?: string\n type?: Storage\n}\n\nexport class StoragePreviousHashStore implements PreviousHashStore {\n static readonly DefaultNamespace = 'xyo-previous-hash-store'\n static readonly DefaultStorageType: Storage = 'local'\n private _namespace = StoragePreviousHashStore.DefaultNamespace\n private _storage: StoreBase | undefined\n private _type: Storage = StoragePreviousHashStore.DefaultStorageType\n\n constructor(opts?: StoragePreviousHashOpts) {\n if (opts?.namespace) this._namespace = opts.namespace\n if (opts?.type) this._type = opts.type\n this._storage = store[this.type].namespace(this.namespace)\n }\n\n get namespace() {\n return this._namespace\n }\n\n get type(): Storage {\n return this._type\n }\n\n private get storage(): StoreBase {\n if (!this?._storage) this._storage = store[this.type].namespace(this.namespace)\n return this._storage\n }\n\n async getItem(address: Address): Promise<Hash | null> {\n const value = await this.storage.get(address)\n return value ?? null\n }\n async removeItem(address: Address): Promise<void> {\n await this.storage.remove(address)\n }\n async setItem(address: Address, previousHash: Hash): Promise<void> {\n await this.storage.set(address, previousHash)\n }\n}\n"],"mappings":";;;;AAEA,OAAOA,WAA0B;AAS1B,IAAMC,2BAAN,MAAMA,0BAAAA;EATb,OASaA;;;EACX,OAAgBC,mBAAmB;EACnC,OAAgBC,qBAA8B;EACtCC,aAAaH,0BAAyBC;EACtCG;EACAC,QAAiBL,0BAAyBE;EAElDI,YAAYC,MAAgC;AAC1C,QAAIA,MAAMC;AAAW,WAAKL,aAAaI,KAAKC;AAC5C,QAAID,MAAME;AAAM,WAAKJ,QAAQE,KAAKE;AAClC,SAAKL,WAAWM,MAAM,KAAKD,IAAI,EAAED,UAAU,KAAKA,SAAS;EAC3D;EAEA,IAAIA,YAAY;AACd,WAAO,KAAKL;EACd;EAEA,IAAIM,OAAgB;AAClB,WAAO,KAAKJ;EACd;EAEA,IAAYM,UAAqB;AAC/B,QAAI,CAAC,MAAMP;AAAU,WAAKA,WAAWM,MAAM,KAAKD,IAAI,EAAED,UAAU,KAAKA,SAAS;AAC9E,WAAO,KAAKJ;EACd;EAEA,MAAMQ,QAAQC,SAAwC;AACpD,UAAMC,QAAQ,MAAM,KAAKH,QAAQI,IAAIF,OAAAA;AACrC,WAAOC,SAAS;EAClB;EACA,MAAME,WAAWH,SAAiC;AAChD,UAAM,KAAKF,QAAQM,OAAOJ,OAAAA;EAC5B;EACA,MAAMK,QAAQL,SAAkBM,cAAmC;AACjE,UAAM,KAAKR,QAAQS,IAAIP,SAASM,YAAAA;EAClC;AACF;","names":["store","StoragePreviousHashStore","DefaultNamespace","DefaultStorageType","_namespace","_storage","_type","constructor","opts","namespace","type","store","storage","getItem","address","value","get","removeItem","remove","setItem","previousHash","set"]}
1
+ {"version":3,"sources":["../../src/StoragePreviousHashStore.ts"],"sourcesContent":["import { Address, Hash } from '@xylabs/hex'\nimport { PreviousHashStore } from '@xyo-network/previous-hash-store-model'\nimport store, { StoreBase } from 'store2'\n\nexport type Storage = 'local' | 'session' | 'page'\n\nexport type StoragePreviousHashOpts = {\n namespace?: string\n type?: Storage\n}\n\nexport class StoragePreviousHashStore implements PreviousHashStore {\n static readonly DefaultNamespace = 'xyo-previous-hash-store'\n static readonly DefaultStorageType: Storage = 'local'\n private _namespace = StoragePreviousHashStore.DefaultNamespace\n private _storage: StoreBase | undefined\n private _type: Storage = StoragePreviousHashStore.DefaultStorageType\n\n constructor(opts?: StoragePreviousHashOpts) {\n if (opts?.namespace) this._namespace = opts.namespace\n if (opts?.type) this._type = opts.type\n this._storage = store[this.type].namespace(this.namespace)\n }\n\n get namespace() {\n return this._namespace\n }\n\n get type(): Storage {\n return this._type\n }\n\n private get storage(): StoreBase {\n if (!this?._storage) this._storage = store[this.type].namespace(this.namespace)\n return this._storage\n }\n\n async getItem(address: Address): Promise<Hash | null> {\n const value = await this.storage.get(address)\n return value ?? null\n }\n async removeItem(address: Address): Promise<void> {\n await this.storage.remove(address)\n }\n async setItem(address: Address, previousHash: Hash): Promise<void> {\n await this.storage.set(address, previousHash)\n }\n}\n"],"mappings":";;;;AAEA,OAAOA,WAA0B;AAS1B,IAAMC,2BAAN,MAAMA,0BAAAA;EATb,OASaA;;;EACX,OAAgBC,mBAAmB;EACnC,OAAgBC,qBAA8B;EACtCC,aAAaH,0BAAyBC;EACtCG;EACAC,QAAiBL,0BAAyBE;EAElDI,YAAYC,MAAgC;AAC1C,QAAIA,MAAMC,UAAW,MAAKL,aAAaI,KAAKC;AAC5C,QAAID,MAAME,KAAM,MAAKJ,QAAQE,KAAKE;AAClC,SAAKL,WAAWM,MAAM,KAAKD,IAAI,EAAED,UAAU,KAAKA,SAAS;EAC3D;EAEA,IAAIA,YAAY;AACd,WAAO,KAAKL;EACd;EAEA,IAAIM,OAAgB;AAClB,WAAO,KAAKJ;EACd;EAEA,IAAYM,UAAqB;AAC/B,QAAI,CAAC,MAAMP,SAAU,MAAKA,WAAWM,MAAM,KAAKD,IAAI,EAAED,UAAU,KAAKA,SAAS;AAC9E,WAAO,KAAKJ;EACd;EAEA,MAAMQ,QAAQC,SAAwC;AACpD,UAAMC,QAAQ,MAAM,KAAKH,QAAQI,IAAIF,OAAAA;AACrC,WAAOC,SAAS;EAClB;EACA,MAAME,WAAWH,SAAiC;AAChD,UAAM,KAAKF,QAAQM,OAAOJ,OAAAA;EAC5B;EACA,MAAMK,QAAQL,SAAkBM,cAAmC;AACjE,UAAM,KAAKR,QAAQS,IAAIP,SAASM,YAAAA;EAClC;AACF;","names":["store","StoragePreviousHashStore","DefaultNamespace","DefaultStorageType","_namespace","_storage","_type","constructor","opts","namespace","type","store","storage","getItem","address","value","get","removeItem","remove","setItem","previousHash","set"]}
@@ -28,10 +28,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  mod
29
29
  ));
30
30
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
31
- var __publicField = (obj, key, value) => {
32
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
33
- return value;
34
- };
31
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
35
32
 
36
33
  // src/index.ts
37
34
  var src_exports = {};
@@ -47,10 +44,8 @@ var _StoragePreviousHashStore = class _StoragePreviousHashStore {
47
44
  _storage;
48
45
  _type = _StoragePreviousHashStore.DefaultStorageType;
49
46
  constructor(opts) {
50
- if (opts == null ? void 0 : opts.namespace)
51
- this._namespace = opts.namespace;
52
- if (opts == null ? void 0 : opts.type)
53
- this._type = opts.type;
47
+ if (opts == null ? void 0 : opts.namespace) this._namespace = opts.namespace;
48
+ if (opts == null ? void 0 : opts.type) this._type = opts.type;
54
49
  this._storage = import_store2.default[this.type].namespace(this.namespace);
55
50
  }
56
51
  get namespace() {
@@ -60,8 +55,7 @@ var _StoragePreviousHashStore = class _StoragePreviousHashStore {
60
55
  return this._type;
61
56
  }
62
57
  get storage() {
63
- if (!(this == null ? void 0 : this._storage))
64
- this._storage = import_store2.default[this.type].namespace(this.namespace);
58
+ if (!(this == null ? void 0 : this._storage)) this._storage = import_store2.default[this.type].namespace(this.namespace);
65
59
  return this._storage;
66
60
  }
67
61
  async getItem(address) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts","../../src/StoragePreviousHashStore.ts"],"sourcesContent":["export * from './StoragePreviousHashStore'\n","import { Address, Hash } from '@xylabs/hex'\nimport { PreviousHashStore } from '@xyo-network/previous-hash-store-model'\nimport store, { StoreBase } from 'store2'\n\nexport type Storage = 'local' | 'session' | 'page'\n\nexport type StoragePreviousHashOpts = {\n namespace?: string\n type?: Storage\n}\n\nexport class StoragePreviousHashStore implements PreviousHashStore {\n static readonly DefaultNamespace = 'xyo-previous-hash-store'\n static readonly DefaultStorageType: Storage = 'local'\n private _namespace = StoragePreviousHashStore.DefaultNamespace\n private _storage: StoreBase | undefined\n private _type: Storage = StoragePreviousHashStore.DefaultStorageType\n\n constructor(opts?: StoragePreviousHashOpts) {\n if (opts?.namespace) this._namespace = opts.namespace\n if (opts?.type) this._type = opts.type\n this._storage = store[this.type].namespace(this.namespace)\n }\n\n get namespace() {\n return this._namespace\n }\n\n get type(): Storage {\n return this._type\n }\n\n private get storage(): StoreBase {\n if (!this?._storage) this._storage = store[this.type].namespace(this.namespace)\n return this._storage\n }\n\n async getItem(address: Address): Promise<Hash | null> {\n const value = await this.storage.get(address)\n return value ?? null\n }\n async removeItem(address: Address): Promise<void> {\n await this.storage.remove(address)\n }\n async setItem(address: Address, previousHash: Hash): Promise<void> {\n await this.storage.set(address, previousHash)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;ACEA,oBAAiC;AAS1B,IAAMA,4BAAN,MAAMA,0BAAAA;EAGHC,aAAaD,0BAAyBE;EACtCC;EACAC,QAAiBJ,0BAAyBK;EAElDC,YAAYC,MAAgC;AAC1C,QAAIA,6BAAMC;AAAW,WAAKP,aAAaM,KAAKC;AAC5C,QAAID,6BAAME;AAAM,WAAKL,QAAQG,KAAKE;AAClC,SAAKN,WAAWO,cAAAA,QAAM,KAAKD,IAAI,EAAED,UAAU,KAAKA,SAAS;EAC3D;EAEA,IAAIA,YAAY;AACd,WAAO,KAAKP;EACd;EAEA,IAAIQ,OAAgB;AAClB,WAAO,KAAKL;EACd;EAEA,IAAYO,UAAqB;AAC/B,QAAI,EAAC,6BAAMR;AAAU,WAAKA,WAAWO,cAAAA,QAAM,KAAKD,IAAI,EAAED,UAAU,KAAKA,SAAS;AAC9E,WAAO,KAAKL;EACd;EAEA,MAAMS,QAAQC,SAAwC;AACpD,UAAMC,QAAQ,MAAM,KAAKH,QAAQI,IAAIF,OAAAA;AACrC,WAAOC,SAAS;EAClB;EACA,MAAME,WAAWH,SAAiC;AAChD,UAAM,KAAKF,QAAQM,OAAOJ,OAAAA;EAC5B;EACA,MAAMK,QAAQL,SAAkBM,cAAmC;AACjE,UAAM,KAAKR,QAAQS,IAAIP,SAASM,YAAAA;EAClC;AACF;AApCanB;AACX,cADWA,2BACKE,oBAAmB;AACnC,cAFWF,2BAEKK,sBAA8B;AAFzC,IAAML,2BAAN;","names":["StoragePreviousHashStore","_namespace","DefaultNamespace","_storage","_type","DefaultStorageType","constructor","opts","namespace","type","store","storage","getItem","address","value","get","removeItem","remove","setItem","previousHash","set"]}
1
+ {"version":3,"sources":["../../src/index.ts","../../src/StoragePreviousHashStore.ts"],"sourcesContent":["export * from './StoragePreviousHashStore'\n","import { Address, Hash } from '@xylabs/hex'\nimport { PreviousHashStore } from '@xyo-network/previous-hash-store-model'\nimport store, { StoreBase } from 'store2'\n\nexport type Storage = 'local' | 'session' | 'page'\n\nexport type StoragePreviousHashOpts = {\n namespace?: string\n type?: Storage\n}\n\nexport class StoragePreviousHashStore implements PreviousHashStore {\n static readonly DefaultNamespace = 'xyo-previous-hash-store'\n static readonly DefaultStorageType: Storage = 'local'\n private _namespace = StoragePreviousHashStore.DefaultNamespace\n private _storage: StoreBase | undefined\n private _type: Storage = StoragePreviousHashStore.DefaultStorageType\n\n constructor(opts?: StoragePreviousHashOpts) {\n if (opts?.namespace) this._namespace = opts.namespace\n if (opts?.type) this._type = opts.type\n this._storage = store[this.type].namespace(this.namespace)\n }\n\n get namespace() {\n return this._namespace\n }\n\n get type(): Storage {\n return this._type\n }\n\n private get storage(): StoreBase {\n if (!this?._storage) this._storage = store[this.type].namespace(this.namespace)\n return this._storage\n }\n\n async getItem(address: Address): Promise<Hash | null> {\n const value = await this.storage.get(address)\n return value ?? null\n }\n async removeItem(address: Address): Promise<void> {\n await this.storage.remove(address)\n }\n async setItem(address: Address, previousHash: Hash): Promise<void> {\n await this.storage.set(address, previousHash)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;ACEA,oBAAiC;AAS1B,IAAMA,4BAAN,MAAMA,0BAAAA;EAGHC,aAAaD,0BAAyBE;EACtCC;EACAC,QAAiBJ,0BAAyBK;EAElDC,YAAYC,MAAgC;AAC1C,QAAIA,6BAAMC,UAAW,MAAKP,aAAaM,KAAKC;AAC5C,QAAID,6BAAME,KAAM,MAAKL,QAAQG,KAAKE;AAClC,SAAKN,WAAWO,cAAAA,QAAM,KAAKD,IAAI,EAAED,UAAU,KAAKA,SAAS;EAC3D;EAEA,IAAIA,YAAY;AACd,WAAO,KAAKP;EACd;EAEA,IAAIQ,OAAgB;AAClB,WAAO,KAAKL;EACd;EAEA,IAAYO,UAAqB;AAC/B,QAAI,EAAC,6BAAMR,UAAU,MAAKA,WAAWO,cAAAA,QAAM,KAAKD,IAAI,EAAED,UAAU,KAAKA,SAAS;AAC9E,WAAO,KAAKL;EACd;EAEA,MAAMS,QAAQC,SAAwC;AACpD,UAAMC,QAAQ,MAAM,KAAKH,QAAQI,IAAIF,OAAAA;AACrC,WAAOC,SAAS;EAClB;EACA,MAAME,WAAWH,SAAiC;AAChD,UAAM,KAAKF,QAAQM,OAAOJ,OAAAA;EAC5B;EACA,MAAMK,QAAQL,SAAkBM,cAAmC;AACjE,UAAM,KAAKR,QAAQS,IAAIP,SAASM,YAAAA;EAClC;AACF;AApCanB;AACX,cADWA,2BACKE,oBAAmB;AACnC,cAFWF,2BAEKK,sBAA8B;AAFzC,IAAML,2BAAN;","names":["StoragePreviousHashStore","_namespace","DefaultNamespace","_storage","_type","DefaultStorageType","constructor","opts","namespace","type","store","storage","getItem","address","value","get","removeItem","remove","setItem","previousHash","set"]}
@@ -1,10 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
4
- var __publicField = (obj, key, value) => {
5
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
6
- return value;
7
- };
4
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
8
5
 
9
6
  // src/StoragePreviousHashStore.ts
10
7
  import store from "store2";
@@ -13,10 +10,8 @@ var _StoragePreviousHashStore = class _StoragePreviousHashStore {
13
10
  _storage;
14
11
  _type = _StoragePreviousHashStore.DefaultStorageType;
15
12
  constructor(opts) {
16
- if (opts == null ? void 0 : opts.namespace)
17
- this._namespace = opts.namespace;
18
- if (opts == null ? void 0 : opts.type)
19
- this._type = opts.type;
13
+ if (opts == null ? void 0 : opts.namespace) this._namespace = opts.namespace;
14
+ if (opts == null ? void 0 : opts.type) this._type = opts.type;
20
15
  this._storage = store[this.type].namespace(this.namespace);
21
16
  }
22
17
  get namespace() {
@@ -26,8 +21,7 @@ var _StoragePreviousHashStore = class _StoragePreviousHashStore {
26
21
  return this._type;
27
22
  }
28
23
  get storage() {
29
- if (!(this == null ? void 0 : this._storage))
30
- this._storage = store[this.type].namespace(this.namespace);
24
+ if (!(this == null ? void 0 : this._storage)) this._storage = store[this.type].namespace(this.namespace);
31
25
  return this._storage;
32
26
  }
33
27
  async getItem(address) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/StoragePreviousHashStore.ts"],"sourcesContent":["import { Address, Hash } from '@xylabs/hex'\nimport { PreviousHashStore } from '@xyo-network/previous-hash-store-model'\nimport store, { StoreBase } from 'store2'\n\nexport type Storage = 'local' | 'session' | 'page'\n\nexport type StoragePreviousHashOpts = {\n namespace?: string\n type?: Storage\n}\n\nexport class StoragePreviousHashStore implements PreviousHashStore {\n static readonly DefaultNamespace = 'xyo-previous-hash-store'\n static readonly DefaultStorageType: Storage = 'local'\n private _namespace = StoragePreviousHashStore.DefaultNamespace\n private _storage: StoreBase | undefined\n private _type: Storage = StoragePreviousHashStore.DefaultStorageType\n\n constructor(opts?: StoragePreviousHashOpts) {\n if (opts?.namespace) this._namespace = opts.namespace\n if (opts?.type) this._type = opts.type\n this._storage = store[this.type].namespace(this.namespace)\n }\n\n get namespace() {\n return this._namespace\n }\n\n get type(): Storage {\n return this._type\n }\n\n private get storage(): StoreBase {\n if (!this?._storage) this._storage = store[this.type].namespace(this.namespace)\n return this._storage\n }\n\n async getItem(address: Address): Promise<Hash | null> {\n const value = await this.storage.get(address)\n return value ?? null\n }\n async removeItem(address: Address): Promise<void> {\n await this.storage.remove(address)\n }\n async setItem(address: Address, previousHash: Hash): Promise<void> {\n await this.storage.set(address, previousHash)\n }\n}\n"],"mappings":";;;;;;;;;AAEA,OAAOA,WAA0B;AAS1B,IAAMC,4BAAN,MAAMA,0BAAAA;EAGHC,aAAaD,0BAAyBE;EACtCC;EACAC,QAAiBJ,0BAAyBK;EAElDC,YAAYC,MAAgC;AAC1C,QAAIA,6BAAMC;AAAW,WAAKP,aAAaM,KAAKC;AAC5C,QAAID,6BAAME;AAAM,WAAKL,QAAQG,KAAKE;AAClC,SAAKN,WAAWO,MAAM,KAAKD,IAAI,EAAED,UAAU,KAAKA,SAAS;EAC3D;EAEA,IAAIA,YAAY;AACd,WAAO,KAAKP;EACd;EAEA,IAAIQ,OAAgB;AAClB,WAAO,KAAKL;EACd;EAEA,IAAYO,UAAqB;AAC/B,QAAI,EAAC,6BAAMR;AAAU,WAAKA,WAAWO,MAAM,KAAKD,IAAI,EAAED,UAAU,KAAKA,SAAS;AAC9E,WAAO,KAAKL;EACd;EAEA,MAAMS,QAAQC,SAAwC;AACpD,UAAMC,QAAQ,MAAM,KAAKH,QAAQI,IAAIF,OAAAA;AACrC,WAAOC,SAAS;EAClB;EACA,MAAME,WAAWH,SAAiC;AAChD,UAAM,KAAKF,QAAQM,OAAOJ,OAAAA;EAC5B;EACA,MAAMK,QAAQL,SAAkBM,cAAmC;AACjE,UAAM,KAAKR,QAAQS,IAAIP,SAASM,YAAAA;EAClC;AACF;AApCanB;AACX,cADWA,2BACKE,oBAAmB;AACnC,cAFWF,2BAEKK,sBAA8B;AAFzC,IAAML,2BAAN;","names":["store","StoragePreviousHashStore","_namespace","DefaultNamespace","_storage","_type","DefaultStorageType","constructor","opts","namespace","type","store","storage","getItem","address","value","get","removeItem","remove","setItem","previousHash","set"]}
1
+ {"version":3,"sources":["../../src/StoragePreviousHashStore.ts"],"sourcesContent":["import { Address, Hash } from '@xylabs/hex'\nimport { PreviousHashStore } from '@xyo-network/previous-hash-store-model'\nimport store, { StoreBase } from 'store2'\n\nexport type Storage = 'local' | 'session' | 'page'\n\nexport type StoragePreviousHashOpts = {\n namespace?: string\n type?: Storage\n}\n\nexport class StoragePreviousHashStore implements PreviousHashStore {\n static readonly DefaultNamespace = 'xyo-previous-hash-store'\n static readonly DefaultStorageType: Storage = 'local'\n private _namespace = StoragePreviousHashStore.DefaultNamespace\n private _storage: StoreBase | undefined\n private _type: Storage = StoragePreviousHashStore.DefaultStorageType\n\n constructor(opts?: StoragePreviousHashOpts) {\n if (opts?.namespace) this._namespace = opts.namespace\n if (opts?.type) this._type = opts.type\n this._storage = store[this.type].namespace(this.namespace)\n }\n\n get namespace() {\n return this._namespace\n }\n\n get type(): Storage {\n return this._type\n }\n\n private get storage(): StoreBase {\n if (!this?._storage) this._storage = store[this.type].namespace(this.namespace)\n return this._storage\n }\n\n async getItem(address: Address): Promise<Hash | null> {\n const value = await this.storage.get(address)\n return value ?? null\n }\n async removeItem(address: Address): Promise<void> {\n await this.storage.remove(address)\n }\n async setItem(address: Address, previousHash: Hash): Promise<void> {\n await this.storage.set(address, previousHash)\n }\n}\n"],"mappings":";;;;;;AAEA,OAAOA,WAA0B;AAS1B,IAAMC,4BAAN,MAAMA,0BAAAA;EAGHC,aAAaD,0BAAyBE;EACtCC;EACAC,QAAiBJ,0BAAyBK;EAElDC,YAAYC,MAAgC;AAC1C,QAAIA,6BAAMC,UAAW,MAAKP,aAAaM,KAAKC;AAC5C,QAAID,6BAAME,KAAM,MAAKL,QAAQG,KAAKE;AAClC,SAAKN,WAAWO,MAAM,KAAKD,IAAI,EAAED,UAAU,KAAKA,SAAS;EAC3D;EAEA,IAAIA,YAAY;AACd,WAAO,KAAKP;EACd;EAEA,IAAIQ,OAAgB;AAClB,WAAO,KAAKL;EACd;EAEA,IAAYO,UAAqB;AAC/B,QAAI,EAAC,6BAAMR,UAAU,MAAKA,WAAWO,MAAM,KAAKD,IAAI,EAAED,UAAU,KAAKA,SAAS;AAC9E,WAAO,KAAKL;EACd;EAEA,MAAMS,QAAQC,SAAwC;AACpD,UAAMC,QAAQ,MAAM,KAAKH,QAAQI,IAAIF,OAAAA;AACrC,WAAOC,SAAS;EAClB;EACA,MAAME,WAAWH,SAAiC;AAChD,UAAM,KAAKF,QAAQM,OAAOJ,OAAAA;EAC5B;EACA,MAAMK,QAAQL,SAAkBM,cAAmC;AACjE,UAAM,KAAKR,QAAQS,IAAIP,SAASM,YAAAA;EAClC;AACF;AApCanB;AACX,cADWA,2BACKE,oBAAmB;AACnC,cAFWF,2BAEKK,sBAA8B;AAFzC,IAAML,2BAAN;","names":["store","StoragePreviousHashStore","_namespace","DefaultNamespace","_storage","_type","DefaultStorageType","constructor","opts","namespace","type","store","storage","getItem","address","value","get","removeItem","remove","setItem","previousHash","set"]}
package/package.json CHANGED
@@ -12,12 +12,12 @@
12
12
  "description": "Primary SDK for using XYO Protocol 2.0",
13
13
  "dependencies": {
14
14
  "@xylabs/hex": "^3.5.1",
15
- "@xyo-network/previous-hash-store-model": "~2.104.0",
15
+ "@xyo-network/previous-hash-store-model": "~2.104.1",
16
16
  "store2": "^2.14.3"
17
17
  },
18
18
  "devDependencies": {
19
- "@xylabs/ts-scripts-yarn3": "^3.10.4",
20
- "@xylabs/tsconfig": "^3.10.4",
19
+ "@xylabs/ts-scripts-yarn3": "^3.11.2",
20
+ "@xylabs/tsconfig": "^3.11.2",
21
21
  "typescript": "^5.4.5",
22
22
  "uuid": "^9.0.1"
23
23
  },
@@ -59,6 +59,6 @@
59
59
  },
60
60
  "sideEffects": false,
61
61
  "types": "dist/node/index.d.ts",
62
- "version": "2.104.0",
62
+ "version": "2.104.1",
63
63
  "type": "module"
64
64
  }