monoidentity 0.22.0 → 0.23.0
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/LICENSE +13 -0
- package/dist/+client.d.ts +1 -1
- package/dist/Monoidentity.svelte +0 -4
- package/dist/Monoidentity.svelte.d.ts +0 -2
- package/dist/client.d.ts +8 -1
- package/dist/readyup.d.ts +1 -2
- package/dist/readyup.js +5 -5
- package/dist/storage/_backupcloud.d.ts +0 -1
- package/dist/storage/_backupcloud.js +1 -1
- package/dist/storage/backupcloud-pull.d.ts +2 -3
- package/dist/storage/backupcloud-pull.js +8 -8
- package/dist/storage/backupcloud-push.d.ts +1 -2
- package/dist/storage/backupcloud-push.js +2 -2
- package/dist/storage/backuplocally-push.d.ts +1 -2
- package/dist/storage/backuplocally-push.js +4 -4
- package/dist/storage/utils-storage.d.ts +0 -6
- package/dist/utils-localstorage.js +1 -1
- package/package.json +4 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
4
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
5
|
+
copyright notice and this permission notice appear in all copies.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
8
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
9
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
10
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
11
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
12
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
13
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/dist/+client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from "./_common.js";
|
|
2
2
|
export { getLoginRecognized, relog, getVerification, getStorage, getScopedFS } from "./storage.js";
|
|
3
|
-
export type { SyncStrategy } from "./
|
|
3
|
+
export type { SyncStrategy } from "./client.js";
|
|
4
4
|
export { waitForSync } from "./storage/utils-sync.js";
|
|
5
5
|
export { retrieveVerification } from "./verification-client.js";
|
|
6
6
|
export { attest as rawAttest } from "./verification/attest.js";
|
package/dist/Monoidentity.svelte
CHANGED
|
@@ -2,15 +2,12 @@
|
|
|
2
2
|
import { onDestroy, type Snippet } from "svelte";
|
|
3
3
|
import { readyUp } from "./readyup.js";
|
|
4
4
|
import type { Intent } from "./utils-transport.js";
|
|
5
|
-
import type { SyncStrategy } from "./storage/utils-storage.js";
|
|
6
5
|
|
|
7
6
|
let {
|
|
8
7
|
intents,
|
|
9
|
-
getSyncStrategy,
|
|
10
8
|
children,
|
|
11
9
|
}: {
|
|
12
10
|
intents?: Intent[];
|
|
13
|
-
getSyncStrategy: (path: string) => SyncStrategy;
|
|
14
11
|
children: Snippet;
|
|
15
12
|
} = $props();
|
|
16
13
|
|
|
@@ -22,7 +19,6 @@
|
|
|
22
19
|
let backup: (() => void) | undefined = $state();
|
|
23
20
|
readyUp(
|
|
24
21
|
intents || [],
|
|
25
|
-
getSyncStrategy,
|
|
26
22
|
aborter.signal,
|
|
27
23
|
(startBackup) =>
|
|
28
24
|
(backup = () => {
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { type Snippet } from "svelte";
|
|
2
2
|
import type { Intent } from "./utils-transport.js";
|
|
3
|
-
import type { SyncStrategy } from "./storage/utils-storage.js";
|
|
4
3
|
type $$ComponentProps = {
|
|
5
4
|
intents?: Intent[];
|
|
6
|
-
getSyncStrategy: (path: string) => SyncStrategy;
|
|
7
5
|
children: Snippet;
|
|
8
6
|
};
|
|
9
7
|
declare const Monoidentity: import("svelte").Component<$$ComponentProps, {}, "">;
|
package/dist/client.d.ts
CHANGED
|
@@ -1 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
export type SyncStrategy =
|
|
2
|
+
| undefined // do not upload or download; will be deleted on next sync unless shouldPersist(key)
|
|
3
|
+
| { mode: "immediate" } // instant sync (e.g., config)
|
|
4
|
+
| { mode: "debounced"; debounceMs: number }; // queued sync (e.g., notes, drawings, chats)
|
|
5
|
+
declare global {
|
|
6
|
+
declare const MONOIDENTITY_APP_ID: string;
|
|
7
|
+
declare const MONOIDENTITY_SYNC_FOR: (path: string) => SyncStrategy;
|
|
8
|
+
}
|
package/dist/readyup.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
import { type Intent } from "./utils-transport.js";
|
|
2
|
-
|
|
3
|
-
export declare const readyUp: (intents: Intent[], getSyncStrategy: (path: string) => SyncStrategy, signal: AbortSignal, requestBackup: (startBackup: () => void) => void) => void;
|
|
2
|
+
export declare const readyUp: (intents: Intent[], signal: AbortSignal, requestBackup: (startBackup: () => void) => void) => void;
|
package/dist/readyup.js
CHANGED
|
@@ -9,7 +9,7 @@ import { createCloudClient } from "./storage/backupcloud-connection.js";
|
|
|
9
9
|
import { mountCloudPull, pullFromCloud } from "./storage/backupcloud-pull.js";
|
|
10
10
|
import { mountCloudPush } from "./storage/backupcloud-push.js";
|
|
11
11
|
import { switchToHub } from "./utils-hub.js";
|
|
12
|
-
export const readyUp = (intents,
|
|
12
|
+
export const readyUp = (intents, signal, requestBackup) => {
|
|
13
13
|
let setup = localStorage["monoidentity-x/setup"]
|
|
14
14
|
? JSON.parse(localStorage["monoidentity-x/setup"])
|
|
15
15
|
: undefined;
|
|
@@ -41,7 +41,7 @@ export const readyUp = (intents, getSyncStrategy, signal, requestBackup) => {
|
|
|
41
41
|
signal.throwIfAborted();
|
|
42
42
|
if (!dir)
|
|
43
43
|
return;
|
|
44
|
-
mountLocalBackupPush(
|
|
44
|
+
mountLocalBackupPush(dir, signal);
|
|
45
45
|
})
|
|
46
46
|
.catch((err) => {
|
|
47
47
|
console.error("[monoidentity local] pull failed", err);
|
|
@@ -49,11 +49,11 @@ export const readyUp = (intents, getSyncStrategy, signal, requestBackup) => {
|
|
|
49
49
|
}
|
|
50
50
|
if (setup.method == "cloud") {
|
|
51
51
|
const client = createCloudClient(setup);
|
|
52
|
-
void pullFromCloud(
|
|
52
|
+
void pullFromCloud(client)
|
|
53
53
|
.then(() => {
|
|
54
54
|
signal.throwIfAborted();
|
|
55
|
-
mountCloudPull(
|
|
56
|
-
mountCloudPush(
|
|
55
|
+
mountCloudPull(client, signal);
|
|
56
|
+
mountCloudPush(client, signal);
|
|
57
57
|
})
|
|
58
58
|
.catch((err) => {
|
|
59
59
|
console.error("[monoidentity cloud] pull failed", err);
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export declare const isPlainTextCloudObject: (key: string) => boolean;
|
|
2
1
|
export declare const encodeCloudContent: (key: string, value: string) => string | Uint8Array<ArrayBuffer>;
|
|
3
2
|
export declare const decodeCloudContent: (key: string, response: Response) => Promise<string>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
const isPlainTextCloudObject = (key) => key.endsWith(".md") || key.endsWith(".devalue");
|
|
2
2
|
export const encodeCloudContent = (key, value) => {
|
|
3
3
|
if (isPlainTextCloudObject(key)) {
|
|
4
4
|
return value;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { type SyncStrategy } from "./utils-storage.js";
|
|
2
1
|
import type { AwsFetch } from "./backupcloud-connection.js";
|
|
3
2
|
export declare const setCloudCacheEntry: (key: string, etag: string, content: string) => Promise<void>;
|
|
4
|
-
export declare const pullFromCloud: (
|
|
5
|
-
export declare const mountCloudPull: (
|
|
3
|
+
export declare const pullFromCloud: (client: AwsFetch) => Promise<void>;
|
|
4
|
+
export declare const mountCloudPull: (client: AwsFetch, signal: AbortSignal) => () => void;
|
|
@@ -22,7 +22,7 @@ export const setCloudCacheEntry = async (key, etag, content) => {
|
|
|
22
22
|
getCache()[key] = { etag, content };
|
|
23
23
|
await saveCache();
|
|
24
24
|
};
|
|
25
|
-
const listCloud = async (
|
|
25
|
+
const listCloud = async (client) => {
|
|
26
26
|
const listResp = await client("");
|
|
27
27
|
if (!listResp.ok)
|
|
28
28
|
throw new Error(`List bucket failed: ${listResp.status}`);
|
|
@@ -30,7 +30,7 @@ const listCloud = async (getSyncStrategy, client) => {
|
|
|
30
30
|
return [...listXml.matchAll(/<Key>(.*?)<\/Key>.*?<ETag>(.*?)<\/ETag>/gs)]
|
|
31
31
|
.map((m) => m.slice(1).map((s) => s.replaceAll(""", `"`).replaceAll("'", `'`)))
|
|
32
32
|
.map(([key, etag]) => ({ key, etag: etag.replaceAll(`"`, "") }))
|
|
33
|
-
.filter(({ key }) =>
|
|
33
|
+
.filter(({ key }) => MONOIDENTITY_SYNC_FOR(key));
|
|
34
34
|
};
|
|
35
35
|
const loadFromCloud = async (objects, client) => {
|
|
36
36
|
const prevCache = getCache();
|
|
@@ -55,9 +55,9 @@ const loadFromCloud = async (objects, client) => {
|
|
|
55
55
|
await saveCache();
|
|
56
56
|
return model;
|
|
57
57
|
};
|
|
58
|
-
const _pullFromCloud = async (
|
|
58
|
+
const _pullFromCloud = async (client) => {
|
|
59
59
|
const cachePromise = initCache();
|
|
60
|
-
const objects = await listCloud(
|
|
60
|
+
const objects = await listCloud(client);
|
|
61
61
|
await cachePromise;
|
|
62
62
|
const remote = await loadFromCloud(objects, client);
|
|
63
63
|
const local = storageClient();
|
|
@@ -74,15 +74,15 @@ const _pullFromCloud = async (getSyncStrategy, client) => {
|
|
|
74
74
|
local[key] = value;
|
|
75
75
|
}
|
|
76
76
|
};
|
|
77
|
-
export const pullFromCloud = async (
|
|
78
|
-
const promise = _pullFromCloud(
|
|
77
|
+
export const pullFromCloud = async (client) => {
|
|
78
|
+
const promise = _pullFromCloud(client);
|
|
79
79
|
addSync("*", promise);
|
|
80
80
|
await promise;
|
|
81
81
|
};
|
|
82
|
-
export const mountCloudPull = (
|
|
82
|
+
export const mountCloudPull = (client, signal) => {
|
|
83
83
|
signal.throwIfAborted();
|
|
84
84
|
const syncIntervalId = setInterval(() => {
|
|
85
|
-
pullFromCloud(
|
|
85
|
+
pullFromCloud(client).catch((err) => {
|
|
86
86
|
console.error("[monoidentity cloud] pull failed", err);
|
|
87
87
|
});
|
|
88
88
|
}, 15 * 60 * 1000);
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { type SyncStrategy } from "./utils-storage.js";
|
|
2
1
|
import type { AwsFetch } from "./backupcloud-connection.js";
|
|
3
|
-
export declare const mountCloudPush: (
|
|
2
|
+
export declare const mountCloudPush: (client: AwsFetch, signal: AbortSignal) => () => void;
|
|
@@ -23,7 +23,7 @@ const write = async (key, value, client) => {
|
|
|
23
23
|
if (!r.ok && r.status != 404)
|
|
24
24
|
throw new Error(`DELETE ${key} failed: ${r.status}`);
|
|
25
25
|
};
|
|
26
|
-
export const mountCloudPush = (
|
|
26
|
+
export const mountCloudPush = (client, signal) => {
|
|
27
27
|
signal.throwIfAborted();
|
|
28
28
|
const writeWrapped = async (key, value) => write(key, value, client).catch((err) => {
|
|
29
29
|
console.error("[monoidentity cloud] save failed", key, err);
|
|
@@ -33,7 +33,7 @@ export const mountCloudPush = (getSyncStrategy, client, signal) => {
|
|
|
33
33
|
if (!fullKey.startsWith("monoidentity/"))
|
|
34
34
|
return;
|
|
35
35
|
const key = fullKey.slice("monoidentity/".length);
|
|
36
|
-
const strategy =
|
|
36
|
+
const strategy = MONOIDENTITY_SYNC_FOR(key);
|
|
37
37
|
if (!strategy) {
|
|
38
38
|
if (!shouldPersist(key))
|
|
39
39
|
console.warn("[monoidentity cloud]", key, "isn't marked to be synced");
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const mountLocalBackupPush: (getSyncStrategy: (path: string) => SyncStrategy, dir: FileSystemDirectoryHandle, signal: AbortSignal) => () => void;
|
|
1
|
+
export declare const mountLocalBackupPush: (dir: FileSystemDirectoryHandle, signal: AbortSignal) => () => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { STORAGE_EVENT } from "./storageclient.svelte.js";
|
|
2
2
|
import { shouldPersist } from "./utils-storage.js";
|
|
3
3
|
import { addSync } from "./utils-sync.js";
|
|
4
|
-
const saveToDir = (
|
|
4
|
+
const saveToDir = (dir) => {
|
|
5
5
|
let dirCache = {};
|
|
6
6
|
const getDirCached = async (route) => {
|
|
7
7
|
let key = "";
|
|
@@ -35,7 +35,7 @@ const saveToDir = (getSyncStrategy, dir) => {
|
|
|
35
35
|
if (!fullKey.startsWith("monoidentity/"))
|
|
36
36
|
return;
|
|
37
37
|
const key = fullKey.slice("monoidentity/".length);
|
|
38
|
-
const strategy =
|
|
38
|
+
const strategy = MONOIDENTITY_SYNC_FOR(key);
|
|
39
39
|
if (!strategy) {
|
|
40
40
|
if (!shouldPersist(key))
|
|
41
41
|
console.warn("[monoidentity local]", key, "isn't marked to be backed up or saved");
|
|
@@ -48,9 +48,9 @@ const saveToDir = (getSyncStrategy, dir) => {
|
|
|
48
48
|
removeEventListener(STORAGE_EVENT, listener);
|
|
49
49
|
};
|
|
50
50
|
};
|
|
51
|
-
export const mountLocalBackupPush = (
|
|
51
|
+
export const mountLocalBackupPush = (dir, signal) => {
|
|
52
52
|
signal.throwIfAborted();
|
|
53
|
-
const unmount = saveToDir(
|
|
53
|
+
const unmount = saveToDir(dir);
|
|
54
54
|
const cleanup = () => {
|
|
55
55
|
unmount();
|
|
56
56
|
signal.removeEventListener("abort", onAbort);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const canBackup = navigator.userAgent.includes("CrOS") &&
|
|
1
|
+
export const canBackup = navigator.userAgent.includes("CrOS") && "showDirectoryPicker" in window;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "monoidentity",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"repository": "KTibow/monoidentity",
|
|
6
6
|
"author": {
|
|
@@ -44,23 +44,21 @@
|
|
|
44
44
|
"@sveltejs/package": "^2.5.7",
|
|
45
45
|
"@sveltejs/vite-plugin-svelte": "^6.2.4",
|
|
46
46
|
"@types/wicg-file-system-access": "^2023.10.7",
|
|
47
|
-
"
|
|
48
|
-
"monoserve": "^3.2.3",
|
|
47
|
+
"monoserve": "^3.2.4",
|
|
49
48
|
"publint": "^0.3.17",
|
|
50
49
|
"rolldown": "1.0.0-rc.4",
|
|
51
50
|
"school-districts": "^5.0.1",
|
|
52
51
|
"svelte": "^5.51.0",
|
|
53
52
|
"svelte-check": "^4.4.0",
|
|
54
53
|
"tinyglobby": "^0.2.15",
|
|
55
|
-
"
|
|
56
|
-
"vite": "^7.3.1"
|
|
54
|
+
"vite": "8.0.0-beta.15"
|
|
57
55
|
},
|
|
58
56
|
"keywords": [
|
|
59
57
|
"svelte"
|
|
60
58
|
],
|
|
61
59
|
"scripts": {
|
|
62
60
|
"dev": "vite dev",
|
|
63
|
-
"build": "pnpm run prepack
|
|
61
|
+
"build": "pnpm run prepack",
|
|
64
62
|
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
|
65
63
|
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
|
66
64
|
"knip": "knip"
|