monoidentity 0.31.2 → 0.31.4

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.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { SYNC_REQUEST_EVENT, STORAGE_EVENT } from './storageclient.svelte.js';
1
+ export { SYNC_REQUEST_EVENT, STORAGE_EVENT, storageClient as _storageClient, } from './storageclient.svelte.js';
2
2
  export declare const getLoginRecognized: () => {
3
3
  email: string;
4
4
  password: string;
package/dist/+index.js CHANGED
@@ -3,7 +3,7 @@ import { parse as useSchema } from 'valibot';
3
3
  import { decode } from 'base36-esm';
4
4
  import { storageClient } from './storageclient.svelte.js';
5
5
  import { object, pipe, email, string } from 'valibot';
6
- export { SYNC_REQUEST_EVENT, STORAGE_EVENT } from './storageclient.svelte.js';
6
+ export { SYNC_REQUEST_EVENT, STORAGE_EVENT, storageClient as _storageClient, } from './storageclient.svelte.js';
7
7
  const loginSchema = object({ email: pipe(string(), email()), password: string() });
8
8
  const LOGIN_RECOGNIZED_PATH = '.local/login.encjson';
9
9
  export const getLoginRecognized = () => {
@@ -1,11 +1,14 @@
1
1
  export declare const SYNC_REQUEST_EVENT = "monoidentity-sync-request";
2
2
  export declare const STORAGE_EVENT = "monoidentity-storage";
3
+ type StorageEventDetail = {
4
+ key: string;
5
+ value: string | undefined;
6
+ isSync: boolean;
7
+ };
3
8
  declare global {
4
9
  interface WindowEventMap {
5
- 'monoidentity-storage': CustomEvent<{
6
- key: string;
7
- value: string | undefined;
8
- }>;
10
+ 'monoidentity-storage': CustomEvent<StorageEventDetail>;
9
11
  }
10
12
  }
11
- export declare const storageClient: (prefix?: (key: string) => string, unprefix?: (key: string) => string | undefined, serialize?: (data: any) => string, deserialize?: (data: string) => any) => Record<string, any>;
13
+ export declare const storageClient: (prefix?: (key: string) => string, unprefix?: (key: string) => string | undefined, serialize?: (data: any) => string, deserialize?: (data: string) => any, isSyncContext?: boolean) => Record<string, any>;
14
+ export {};
@@ -3,9 +3,9 @@ export const STORAGE_EVENT = 'monoidentity-storage';
3
3
  const waitForSync = async (key) => {
4
4
  await new Promise((resolve, reject) => window.dispatchEvent(new CustomEvent(SYNC_REQUEST_EVENT, { detail: { key, resolve, reject } })));
5
5
  };
6
- const announce = (key, value) => {
6
+ const announce = (key, value, isSync = false) => {
7
7
  // Announce to all, even third parties
8
- window.dispatchEvent(new CustomEvent(STORAGE_EVENT, { detail: { key, value } }));
8
+ window.dispatchEvent(new CustomEvent(STORAGE_EVENT, { detail: { key, value, isSync } }));
9
9
  };
10
10
  const storageCounters = $state({});
11
11
  let allCounter = $state(0);
@@ -21,7 +21,7 @@ addEventListener('storage', (event) => {
21
21
  return;
22
22
  increment(event.key);
23
23
  });
24
- export const storageClient = (prefix, unprefix, serialize, deserialize) => {
24
+ export const storageClient = (prefix, unprefix, serialize, deserialize, isSyncContext = false) => {
25
25
  if (prefix) {
26
26
  const oldPrefix = prefix;
27
27
  prefix = (key) => `monoidentity/${oldPrefix(key)}`;
@@ -65,7 +65,7 @@ export const storageClient = (prefix, unprefix, serialize, deserialize) => {
65
65
  value = serialize(value);
66
66
  if (localStorage[key] != value) {
67
67
  localStorage[key] = value;
68
- announce(key, value);
68
+ announce(key, value, isSyncContext);
69
69
  }
70
70
  else {
71
71
  console.debug('[monoidentity storage] noop for', key);
@@ -75,7 +75,7 @@ export const storageClient = (prefix, unprefix, serialize, deserialize) => {
75
75
  deleteProperty(_, key) {
76
76
  key = prefix(key);
77
77
  delete localStorage[key];
78
- announce(key);
78
+ announce(key, undefined, isSyncContext);
79
79
  return true;
80
80
  },
81
81
  ownKeys() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "monoidentity",
3
- "version": "0.31.2",
3
+ "version": "0.31.4",
4
4
  "license": "ISC",
5
5
  "repository": "KTibow/monoidentity",
6
6
  "author": {
@@ -33,17 +33,17 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "base36-esm": "^0.1.0",
36
- "devalue": "^5.6.2",
36
+ "devalue": "^5.6.3",
37
37
  "valibot": "^1.2.0"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@sveltejs/adapter-static": "^3.0.10",
41
- "@sveltejs/kit": "^2.51.0",
41
+ "@sveltejs/kit": "^2.53.0",
42
42
  "@sveltejs/package": "^2.5.7",
43
43
  "@sveltejs/vite-plugin-svelte": "^6.2.4",
44
44
  "publint": "^0.3.17",
45
- "svelte": "^5.51.0",
46
- "svelte-check": "^4.4.0",
45
+ "svelte": "^5.53.2",
46
+ "svelte-check": "^4.4.3",
47
47
  "vite": "8.0.0-beta.15"
48
48
  },
49
49
  "keywords": [