monoidentity 0.31.7 → 0.31.8

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.
package/dist/index.js CHANGED
@@ -10,7 +10,8 @@ const loginSchema = object({
10
10
  });
11
11
  const LOGIN_RECOGNIZED_PATH = ".local/login.encjson";
12
12
  const getLoginRecognized = () => {
13
- const login = storageClient()[LOGIN_RECOGNIZED_PATH];
13
+ const client = storageClient();
14
+ const login = client[LOGIN_RECOGNIZED_PATH];
14
15
  if (!login) throw new Error("No login found");
15
16
  return parse$1(loginSchema, JSON.parse(decode(login)));
16
17
  };
@@ -32,9 +33,9 @@ const openHub = (path) => {
32
33
  const relog = () => openHub(MONOIDENTITY_APP_ID);
33
34
  const getStorage = (realm) => {
34
35
  const prefix = `.${realm}/${MONOIDENTITY_APP_ID}/`;
35
- return storageClient((key) => `${prefix}${key}.devalue`, (key) => key.startsWith(prefix) ? key.slice(prefix.length, -8) : void 0, stringify, parse);
36
+ return storageClient((key) => `${prefix}${key}.devalue`, (key) => key.startsWith(prefix) ? key.slice(prefix.length, -".devalue".length) : undefined, stringify, parse);
36
37
  };
37
- const getScopedFS = (dir) => storageClient((key) => `${dir}/${key}`, (key) => key.startsWith(dir + "/") ? key.slice(dir.length + 1) : void 0);
38
+ const getScopedFS = (dir) => storageClient((key) => `${dir}/${key}`, (key) => key.startsWith(dir + "/") ? key.slice(dir.length + 1) : undefined);
38
39
 
39
40
  //#endregion
40
41
  export { STORAGE_EVENT, SYNC_REQUEST_EVENT, storageClient as _storageClient, getLoginRecognized, getScopedFS, getStorage, openHub, relog, setLoginRecognized };
@@ -3,10 +3,14 @@ import { setLoginRecognized } from "./index.js";
3
3
  //#region src/receive-callback.ts
4
4
  const params = new URLSearchParams(location.hash.slice(1));
5
5
  const monoidentityloginrecognized = params.get("monoidentityloginrecognized");
6
- if (monoidentityloginrecognized) setLoginRecognized(monoidentityloginrecognized);
6
+ if (monoidentityloginrecognized) {
7
+ setLoginRecognized(monoidentityloginrecognized);
8
+ }
7
9
  const loaded = Boolean(params.size);
8
- if (loaded) history.replaceState(null, "", location.pathname);
9
- const monoidentitysync = params.get("monoidentitysync") || void 0;
10
+ if (loaded) {
11
+ history.replaceState(null, "", location.pathname);
12
+ }
13
+ const monoidentitysync = params.get("monoidentitysync") || undefined;
10
14
 
11
15
  //#endregion
12
16
  export { loaded, monoidentitysync };
@@ -31,12 +31,14 @@ const storageClient = (prefix, unprefix, serialize, deserialize, isSyncContext =
31
31
  if (prefix) {
32
32
  const oldPrefix = prefix;
33
33
  prefix = (key) => `monoidentity/${oldPrefix(key)}`;
34
- } else prefix = (key) => `monoidentity/${key}`;
34
+ } else {
35
+ prefix = (key) => `monoidentity/${key}`;
36
+ }
35
37
  const getScopedKeys = () => {
36
38
  const keys = [];
37
39
  for (const key in localStorage) {
38
40
  if (!key.startsWith("monoidentity/")) continue;
39
- let scopedKey = key.slice(13);
41
+ let scopedKey = key.slice("monoidentity/".length);
40
42
  if (unprefix) {
41
43
  const unprefixed = unprefix(scopedKey);
42
44
  if (!unprefixed) continue;
@@ -48,10 +50,12 @@ const storageClient = (prefix, unprefix, serialize, deserialize, isSyncContext =
48
50
  };
49
51
  return new Proxy({}, {
50
52
  get(_, key) {
51
- if (typeof key == "symbol") return void 0;
52
- if (key == "sync") return async (userKey) => {
53
- await waitForSync(prefix(userKey));
54
- };
53
+ if (typeof key == "symbol") return undefined;
54
+ if (key == "sync") {
55
+ return async (userKey) => {
56
+ await waitForSync(prefix(userKey));
57
+ };
58
+ }
55
59
  key = prefix(key);
56
60
  storageCounters[key];
57
61
  const raw = localStorage[key];
@@ -63,16 +67,19 @@ const storageClient = (prefix, unprefix, serialize, deserialize, isSyncContext =
63
67
  if (localStorage[key] != value) {
64
68
  localStorage[key] = value;
65
69
  announce(key, value, isSyncContext);
66
- } else console.debug("[monoidentity storage] noop for", key);
70
+ } else {
71
+ console.debug("[monoidentity storage] noop for", key);
72
+ }
67
73
  return true;
68
74
  },
69
75
  deleteProperty(_, key) {
70
76
  key = prefix(key);
71
77
  delete localStorage[key];
72
- announce(key, void 0, isSyncContext);
78
+ announce(key, undefined, isSyncContext);
73
79
  return true;
74
80
  },
75
81
  ownKeys() {
82
+ allCounter;
76
83
  return getScopedKeys();
77
84
  },
78
85
  getOwnPropertyDescriptor(_, key) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "monoidentity",
3
- "version": "0.31.7",
3
+ "version": "0.31.8",
4
4
  "license": "ISC",
5
5
  "repository": "KTibow/monoidentity",
6
6
  "author": {