@fluid-topics/ft-app-context 1.3.12 → 1.3.13
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.
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Optional } from "@fluid-topics/ft-wc-utils";
|
|
2
|
+
export declare class GuestLocalStorage<T> {
|
|
3
|
+
private readonly storeListeners;
|
|
4
|
+
store(key: string, value: T): void;
|
|
5
|
+
get(key: string): Optional<T>;
|
|
6
|
+
addStoreListener(keySupplier: () => string, onStore: () => unknown): void;
|
|
7
|
+
clearStoreListeners(): void;
|
|
8
|
+
private isAuthenticated;
|
|
9
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ftAppInfoStore } from "../redux-stores/FtAppInfoStore";
|
|
2
|
+
export class GuestLocalStorage {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.storeListeners = [];
|
|
5
|
+
}
|
|
6
|
+
store(key, value) {
|
|
7
|
+
if (this.isAuthenticated()) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const newValue = JSON.stringify(value);
|
|
11
|
+
window.localStorage.setItem(key, newValue);
|
|
12
|
+
window.dispatchEvent(new StorageEvent("storage", {
|
|
13
|
+
key: key,
|
|
14
|
+
newValue,
|
|
15
|
+
storageArea: window.localStorage,
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
get(key) {
|
|
19
|
+
var _a, _b;
|
|
20
|
+
if (this.isAuthenticated()) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
return (_b = JSON.parse((_a = window.localStorage.getItem(key)) !== null && _a !== void 0 ? _a : "null")) !== null && _b !== void 0 ? _b : undefined;
|
|
24
|
+
}
|
|
25
|
+
addStoreListener(keySupplier, onStore) {
|
|
26
|
+
const storeListener = (e) => {
|
|
27
|
+
if (e.key === keySupplier() && !this.isAuthenticated()) {
|
|
28
|
+
onStore();
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
this.storeListeners.push(storeListener);
|
|
32
|
+
window.addEventListener("storage", storeListener);
|
|
33
|
+
}
|
|
34
|
+
clearStoreListeners() {
|
|
35
|
+
this.storeListeners.forEach((storeListener) => window.removeEventListener("storage", storeListener));
|
|
36
|
+
this.storeListeners.length = 0;
|
|
37
|
+
}
|
|
38
|
+
isAuthenticated() {
|
|
39
|
+
const session = ftAppInfoStore.getState().session;
|
|
40
|
+
return Boolean(session === null || session === void 0 ? void 0 : session.sessionAuthenticated);
|
|
41
|
+
}
|
|
42
|
+
}
|
package/build/services/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-topics/ft-app-context",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.13",
|
|
4
4
|
"description": "Global application context for Fluid Topics integrations",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Lit"
|
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
"url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@fluid-topics/ft-wc-utils": "1.3.
|
|
22
|
+
"@fluid-topics/ft-wc-utils": "1.3.13",
|
|
23
23
|
"lit": "3.1.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@fluid-topics/public-api": "1.0.100"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "3f7e281a9fee6f1df464e79064f917e1feec3253"
|
|
29
29
|
}
|