@0xsequence/provider 0.0.0-20230726172246 → 0.0.0-20230726184000
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.
|
@@ -654,11 +654,10 @@ class LocalStorage {
|
|
|
654
654
|
}
|
|
655
655
|
window.addEventListener('storage', e => {
|
|
656
656
|
const {
|
|
657
|
-
key
|
|
658
|
-
newValue
|
|
657
|
+
key
|
|
659
658
|
} = e;
|
|
660
659
|
const cb = this.callbacks.filter(c => c.key === key);
|
|
661
|
-
cb.forEach(c => c.cb(
|
|
660
|
+
cb.forEach(c => c.cb(this.getItem(key)));
|
|
662
661
|
});
|
|
663
662
|
}
|
|
664
663
|
getItem(key) {
|
|
@@ -666,9 +665,17 @@ class LocalStorage {
|
|
|
666
665
|
}
|
|
667
666
|
setItem(key, value) {
|
|
668
667
|
window.localStorage.setItem(key, value);
|
|
668
|
+
|
|
669
|
+
// Trigger callbacks
|
|
670
|
+
// NOTICE: the event is not triggered on the same window
|
|
671
|
+
this.callbacks.filter(c => c.key === key).forEach(c => c.cb(value));
|
|
669
672
|
}
|
|
670
673
|
removeItem(key) {
|
|
671
674
|
window.localStorage.removeItem(key);
|
|
675
|
+
|
|
676
|
+
// Trigger callbacks
|
|
677
|
+
// NOTICE: the event is not triggered on the same window
|
|
678
|
+
this.callbacks.filter(c => c.key === key).forEach(c => c.cb(null));
|
|
672
679
|
}
|
|
673
680
|
onItemChange(key, cb) {
|
|
674
681
|
this.callbacks.push({
|
|
@@ -654,11 +654,10 @@ class LocalStorage {
|
|
|
654
654
|
}
|
|
655
655
|
window.addEventListener('storage', e => {
|
|
656
656
|
const {
|
|
657
|
-
key
|
|
658
|
-
newValue
|
|
657
|
+
key
|
|
659
658
|
} = e;
|
|
660
659
|
const cb = this.callbacks.filter(c => c.key === key);
|
|
661
|
-
cb.forEach(c => c.cb(
|
|
660
|
+
cb.forEach(c => c.cb(this.getItem(key)));
|
|
662
661
|
});
|
|
663
662
|
}
|
|
664
663
|
getItem(key) {
|
|
@@ -666,9 +665,17 @@ class LocalStorage {
|
|
|
666
665
|
}
|
|
667
666
|
setItem(key, value) {
|
|
668
667
|
window.localStorage.setItem(key, value);
|
|
668
|
+
|
|
669
|
+
// Trigger callbacks
|
|
670
|
+
// NOTICE: the event is not triggered on the same window
|
|
671
|
+
this.callbacks.filter(c => c.key === key).forEach(c => c.cb(value));
|
|
669
672
|
}
|
|
670
673
|
removeItem(key) {
|
|
671
674
|
window.localStorage.removeItem(key);
|
|
675
|
+
|
|
676
|
+
// Trigger callbacks
|
|
677
|
+
// NOTICE: the event is not triggered on the same window
|
|
678
|
+
this.callbacks.filter(c => c.key === key).forEach(c => c.cb(null));
|
|
672
679
|
}
|
|
673
680
|
onItemChange(key, cb) {
|
|
674
681
|
this.callbacks.push({
|
|
@@ -650,11 +650,10 @@ class LocalStorage {
|
|
|
650
650
|
}
|
|
651
651
|
window.addEventListener('storage', e => {
|
|
652
652
|
const {
|
|
653
|
-
key
|
|
654
|
-
newValue
|
|
653
|
+
key
|
|
655
654
|
} = e;
|
|
656
655
|
const cb = this.callbacks.filter(c => c.key === key);
|
|
657
|
-
cb.forEach(c => c.cb(
|
|
656
|
+
cb.forEach(c => c.cb(this.getItem(key)));
|
|
658
657
|
});
|
|
659
658
|
}
|
|
660
659
|
getItem(key) {
|
|
@@ -662,9 +661,17 @@ class LocalStorage {
|
|
|
662
661
|
}
|
|
663
662
|
setItem(key, value) {
|
|
664
663
|
window.localStorage.setItem(key, value);
|
|
664
|
+
|
|
665
|
+
// Trigger callbacks
|
|
666
|
+
// NOTICE: the event is not triggered on the same window
|
|
667
|
+
this.callbacks.filter(c => c.key === key).forEach(c => c.cb(value));
|
|
665
668
|
}
|
|
666
669
|
removeItem(key) {
|
|
667
670
|
window.localStorage.removeItem(key);
|
|
671
|
+
|
|
672
|
+
// Trigger callbacks
|
|
673
|
+
// NOTICE: the event is not triggered on the same window
|
|
674
|
+
this.callbacks.filter(c => c.key === key).forEach(c => c.cb(null));
|
|
668
675
|
}
|
|
669
676
|
onItemChange(key, cb) {
|
|
670
677
|
this.callbacks.push({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xsequence/provider",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-20230726184000",
|
|
4
4
|
"description": "provider sub-package for Sequence",
|
|
5
5
|
"repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/provider",
|
|
6
6
|
"source": "src/index.ts",
|
|
@@ -11,15 +11,15 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"eventemitter2": "^6.4.5",
|
|
13
13
|
"webextension-polyfill": "^0.10.0",
|
|
14
|
-
"@0xsequence/
|
|
15
|
-
"@0xsequence/core": "0.0.0-
|
|
16
|
-
"@0xsequence/auth": "0.0.0-
|
|
17
|
-
"@0xsequence/
|
|
18
|
-
"@0xsequence/
|
|
19
|
-
"@0xsequence/
|
|
20
|
-
"@0xsequence/
|
|
21
|
-
"@0xsequence/
|
|
22
|
-
"@0xsequence/
|
|
14
|
+
"@0xsequence/account": "0.0.0-20230726184000",
|
|
15
|
+
"@0xsequence/core": "0.0.0-20230726184000",
|
|
16
|
+
"@0xsequence/auth": "0.0.0-20230726184000",
|
|
17
|
+
"@0xsequence/abi": "0.0.0-20230726184000",
|
|
18
|
+
"@0xsequence/network": "0.0.0-20230726184000",
|
|
19
|
+
"@0xsequence/migration": "0.0.0-20230726184000",
|
|
20
|
+
"@0xsequence/relayer": "0.0.0-20230726184000",
|
|
21
|
+
"@0xsequence/utils": "0.0.0-20230726184000",
|
|
22
|
+
"@0xsequence/wallet": "0.0.0-20230726184000"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"ethers": ">=5.5 < 6"
|
package/src/utils.ts
CHANGED
|
@@ -158,9 +158,9 @@ export class LocalStorage implements ItemStore {
|
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
window.addEventListener('storage', (e) => {
|
|
161
|
-
const { key
|
|
161
|
+
const { key } = e
|
|
162
162
|
const cb = this.callbacks.filter((c) => c.key === key)
|
|
163
|
-
cb.forEach((c) => c.cb(
|
|
163
|
+
cb.forEach((c) => c.cb(this.getItem(key!)))
|
|
164
164
|
})
|
|
165
165
|
}
|
|
166
166
|
|
|
@@ -170,10 +170,18 @@ export class LocalStorage implements ItemStore {
|
|
|
170
170
|
|
|
171
171
|
setItem(key: string, value: string): void {
|
|
172
172
|
window.localStorage.setItem(key, value)
|
|
173
|
+
|
|
174
|
+
// Trigger callbacks
|
|
175
|
+
// NOTICE: the event is not triggered on the same window
|
|
176
|
+
this.callbacks.filter((c) => c.key === key).forEach((c) => c.cb(value))
|
|
173
177
|
}
|
|
174
178
|
|
|
175
179
|
removeItem(key: string): void {
|
|
176
180
|
window.localStorage.removeItem(key)
|
|
181
|
+
|
|
182
|
+
// Trigger callbacks
|
|
183
|
+
// NOTICE: the event is not triggered on the same window
|
|
184
|
+
this.callbacks.filter((c) => c.key === key).forEach((c) => c.cb(null))
|
|
177
185
|
}
|
|
178
186
|
|
|
179
187
|
onItemChange(key: string, cb: (value: string | null) => void): () => void {
|