@jtfmumm/patchwork-standalone-frame 0.1.0 → 0.3.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/dist/frame.d.ts +3 -2
- package/dist/index.d.ts +40 -0
- package/dist/index.js +474 -418
- package/dist/mount.d.ts +2 -2
- package/dist/share-modal.d.ts +1 -1
- package/package.json +6 -1
- package/src/frame.tsx +125 -99
- package/src/index.ts +47 -0
- package/src/mount.tsx +43 -5
- package/src/share-modal.tsx +64 -37
package/dist/index.js
CHANGED
|
@@ -1,42 +1,38 @@
|
|
|
1
|
-
import { delegateEvents as
|
|
2
|
-
import { createSignal as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { BrowserWebSocketClientAdapter as Ke } from "@automerge/automerge-repo-network-websocket";
|
|
6
|
-
import { docIdFromAutomergeUrl as $e, uint8ArrayToHex as de, ContactCard as Le, Identifier as He, Access as De, initKeyhiveWasm as Be, initializeAutomergeRepoKeyhive as Ye } from "@automerge/automerge-repo-keyhive";
|
|
7
|
-
const Ve = 100;
|
|
8
|
-
function Pe(e, t) {
|
|
1
|
+
import { delegateEvents as xe, createComponent as m, insert as f, effect as D, style as E, memo as Z, setStyleProperty as X, template as w, use as Ee, setAttribute as He, render as Pe } from "solid-js/web";
|
|
2
|
+
import { createSignal as x, createEffect as ie, onCleanup as q, createMemo as we, Show as _, For as Me, onMount as $e } from "solid-js";
|
|
3
|
+
const Fe = 100;
|
|
4
|
+
function Oe(e, t) {
|
|
9
5
|
return `${e}-doc-history-${t}`;
|
|
10
6
|
}
|
|
11
7
|
function me(e, t) {
|
|
12
8
|
return `${e}-standalone-${t}`;
|
|
13
9
|
}
|
|
14
|
-
function
|
|
10
|
+
function ve(e, t) {
|
|
15
11
|
try {
|
|
16
|
-
const
|
|
17
|
-
return
|
|
12
|
+
const l = localStorage.getItem(Oe(e, t));
|
|
13
|
+
return l ? JSON.parse(l) : [];
|
|
18
14
|
} catch {
|
|
19
15
|
return [];
|
|
20
16
|
}
|
|
21
17
|
}
|
|
22
|
-
function
|
|
23
|
-
localStorage.setItem(
|
|
18
|
+
function Re(e, t, l) {
|
|
19
|
+
localStorage.setItem(Oe(e, t), JSON.stringify(l));
|
|
24
20
|
}
|
|
25
|
-
function Ie(e, t,
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
return
|
|
21
|
+
function Ie(e, t, l, g) {
|
|
22
|
+
const u = ve(e, t), p = u.findIndex(($) => $.url === l);
|
|
23
|
+
p !== -1 ? (u[p].title = g, u[p].lastOpened = Date.now()) : u.push({ url: l, title: g, lastOpened: Date.now() }), u.sort(($, v) => v.lastOpened - $.lastOpened);
|
|
24
|
+
const k = u.slice(0, Fe);
|
|
25
|
+
return Re(e, t, k), k;
|
|
30
26
|
}
|
|
31
|
-
function
|
|
32
|
-
const
|
|
33
|
-
return
|
|
27
|
+
function Ne(e, t, l) {
|
|
28
|
+
const g = ve(e, t).filter((u) => u.url !== l);
|
|
29
|
+
return Re(e, t, g), g;
|
|
34
30
|
}
|
|
35
|
-
function
|
|
31
|
+
function Ve(e) {
|
|
36
32
|
const t = "automerge:";
|
|
37
33
|
if (e.startsWith(t)) {
|
|
38
|
-
const
|
|
39
|
-
return t +
|
|
34
|
+
const l = e.slice(t.length);
|
|
35
|
+
return t + l.slice(0, 12) + "...";
|
|
40
36
|
}
|
|
41
37
|
return e;
|
|
42
38
|
}
|
|
@@ -44,10 +40,10 @@ function Te() {
|
|
|
44
40
|
const e = window.location.hash.slice(1);
|
|
45
41
|
return e && e.startsWith("automerge:") ? e : null;
|
|
46
42
|
}
|
|
47
|
-
function
|
|
43
|
+
function se(e) {
|
|
48
44
|
window.history.replaceState(null, "", `#${e}`);
|
|
49
45
|
}
|
|
50
|
-
const
|
|
46
|
+
const Ce = {
|
|
51
47
|
position: "fixed",
|
|
52
48
|
inset: "0",
|
|
53
49
|
background: "rgba(0,0,0,0.5)",
|
|
@@ -55,7 +51,7 @@ const ke = {
|
|
|
55
51
|
"align-items": "center",
|
|
56
52
|
"justify-content": "center",
|
|
57
53
|
"z-index": "2000"
|
|
58
|
-
},
|
|
54
|
+
}, Se = {
|
|
59
55
|
background: "#191e24",
|
|
60
56
|
color: "#edf2f7",
|
|
61
57
|
"border-radius": "8px",
|
|
@@ -63,21 +59,25 @@ const ke = {
|
|
|
63
59
|
"box-shadow": "0 8px 24px rgba(0,0,0,0.5)",
|
|
64
60
|
"font-family": "system-ui, sans-serif"
|
|
65
61
|
};
|
|
66
|
-
var
|
|
67
|
-
|
|
68
|
-
async function
|
|
69
|
-
|
|
70
|
-
return (await e.docMemberCapabilities(a)).forEach((f) => {
|
|
71
|
-
const C = de(f.who.id.toBytes());
|
|
72
|
-
y[C] = f.can.toString();
|
|
73
|
-
}), y;
|
|
62
|
+
var je = /* @__PURE__ */ w("<span style=font-size:13px>This document is <strong>public"), Ke = /* @__PURE__ */ w("<button>Revoke Public Access"), Je = /* @__PURE__ */ w("<button>Make Public"), Le = /* @__PURE__ */ w("<hr>"), We = /* @__PURE__ */ w('<form><textarea placeholder="Paste ContactCard JSON..."rows=3 style="width:100%;background:#15191e;border:1px solid #2a323c;color:#edf2f7;border-radius:4px;padding:6px 8px;font-size:12px;font-family:monospace;resize:vertical;box-sizing:border-box"></textarea><div style=display:flex;justify-content:flex-end;margin-top:6px><button type=submit>'), Be = /* @__PURE__ */ w("<p style=font-size:13px;color:#6b7280>Loading..."), Ye = /* @__PURE__ */ w("<p style=font-size:13px;color:#6b7280>No users have access yet"), qe = /* @__PURE__ */ w("<div>"), Ge = /* @__PURE__ */ w('<div><div><div style=display:flex;justify-content:space-between;align-items:center;margin-bottom:8px><h2 style=margin:0;font-size:16px>Share this document</h2><button aria-label="Close modal"style="border:none;font-size:18px;padding:0 4px">×</button></div><section><h3>Public Access</h3><div style=display:flex;align-items:center;gap:12px></div></section><section><h3>Current Access'), Qe = /* @__PURE__ */ w('<button aria-label="Remove member"style="color:#c66;border:1px solid #944;padding:2px 8px">Revoke'), Xe = /* @__PURE__ */ w('<div style="display:flex;justify-content:space-between;align-items:center;padding:4px 0;border-bottom:1px solid #15191e;font-size:13px"><div><span style=margin-right:8px></span><span style=color:#6b7280;font-size:11px>');
|
|
63
|
+
let ke = null;
|
|
64
|
+
async function ye() {
|
|
65
|
+
return ke || (ke = await import("@automerge/automerge-repo-keyhive")), ke;
|
|
74
66
|
}
|
|
75
|
-
const
|
|
76
|
-
|
|
67
|
+
const De = ["Pull", "Read", "Write", "Admin"];
|
|
68
|
+
async function de(e, t) {
|
|
69
|
+
const l = await ye(), g = l.docIdFromAutomergeUrl(t), u = {};
|
|
70
|
+
return (await e.docMemberCapabilities(g)).forEach((k) => {
|
|
71
|
+
const $ = l.uint8ArrayToHex(k.who.id.toBytes());
|
|
72
|
+
u[$] = k.can.toString();
|
|
73
|
+
}), u;
|
|
74
|
+
}
|
|
75
|
+
const Ze = {
|
|
76
|
+
...Se,
|
|
77
77
|
width: "420px",
|
|
78
78
|
"max-height": "80vh",
|
|
79
79
|
"overflow-y": "auto"
|
|
80
|
-
},
|
|
80
|
+
}, ue = {
|
|
81
81
|
background: "none",
|
|
82
82
|
border: "1px solid #2a323c",
|
|
83
83
|
color: "#edf2f7",
|
|
@@ -85,256 +85,271 @@ const at = {
|
|
|
85
85
|
"border-radius": "4px",
|
|
86
86
|
cursor: "pointer",
|
|
87
87
|
"font-size": "12px"
|
|
88
|
-
},
|
|
88
|
+
}, ze = {
|
|
89
89
|
"font-size": "13px",
|
|
90
90
|
color: "#6b7280",
|
|
91
91
|
margin: "16px 0 8px"
|
|
92
|
-
},
|
|
92
|
+
}, Ue = {
|
|
93
93
|
border: "none",
|
|
94
94
|
"border-top": "1px solid #2a323c",
|
|
95
95
|
margin: "12px 0"
|
|
96
96
|
};
|
|
97
|
-
function
|
|
98
|
-
const [t,
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
97
|
+
function et(e) {
|
|
98
|
+
const [t, l] = x(""), [g, u] = x({}), [p, k] = x(!0), [$, v] = x(void 0), [N, z] = x(!1), [oe, H] = x(null), [A, ae] = x(null), [ee, te] = x(null), [G, be] = x("");
|
|
99
|
+
ie(() => {
|
|
100
|
+
if (!e.isOpen) return;
|
|
101
|
+
let a = !1;
|
|
102
|
+
(async () => {
|
|
103
|
+
const s = await ye();
|
|
104
|
+
if (a) return;
|
|
105
|
+
H(s.docIdFromAutomergeUrl(e.docUrl));
|
|
106
|
+
const C = e.hive.active.individual.id;
|
|
107
|
+
ae(C ? s.uint8ArrayToHex(C.toBytes()) : null);
|
|
108
|
+
const U = e.hive.syncServer;
|
|
109
|
+
if (U) {
|
|
110
|
+
const T = s.ContactCard.fromJson(U.contactCard.toJson());
|
|
111
|
+
T && te(s.uint8ArrayToHex(T.individualId.bytes));
|
|
112
|
+
}
|
|
113
|
+
const P = s.Identifier.publicId();
|
|
114
|
+
be(s.uint8ArrayToHex(P.toBytes()));
|
|
115
|
+
})(), q(() => {
|
|
116
|
+
a = !0;
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
const Q = we(() => {
|
|
120
|
+
const a = g(), s = G();
|
|
121
|
+
return s && a[s] || null;
|
|
122
|
+
}), le = we(() => $() === "Admin");
|
|
123
|
+
ie(() => {
|
|
111
124
|
if (!e.isOpen) return;
|
|
112
|
-
|
|
125
|
+
const a = oe();
|
|
126
|
+
if (!a) return;
|
|
127
|
+
let s = !1;
|
|
113
128
|
(async () => {
|
|
114
|
-
const
|
|
115
|
-
if (!
|
|
116
|
-
|
|
129
|
+
const C = e.hive.active.individual.id;
|
|
130
|
+
if (!C) {
|
|
131
|
+
s || v(void 0);
|
|
117
132
|
return;
|
|
118
133
|
}
|
|
119
134
|
try {
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
} catch (
|
|
123
|
-
|
|
135
|
+
const U = await e.hive.accessForDoc(C, a);
|
|
136
|
+
s || v(U ? U.toString() : void 0);
|
|
137
|
+
} catch (U) {
|
|
138
|
+
s || (console.error("[ShareModal] Error checking access:", U), v(void 0));
|
|
124
139
|
}
|
|
125
|
-
})(),
|
|
126
|
-
|
|
140
|
+
})(), q(() => {
|
|
141
|
+
s = !0;
|
|
127
142
|
});
|
|
128
|
-
}),
|
|
143
|
+
}), ie(() => {
|
|
129
144
|
if (!e.isOpen) return;
|
|
130
|
-
let
|
|
145
|
+
let a = !1;
|
|
131
146
|
(async () => {
|
|
132
|
-
|
|
147
|
+
a || k(!0);
|
|
133
148
|
try {
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
} catch (
|
|
137
|
-
|
|
149
|
+
const s = await de(e.hive, e.docUrl);
|
|
150
|
+
a || (u(s), k(!1));
|
|
151
|
+
} catch (s) {
|
|
152
|
+
a || (console.error("[ShareModal] Error loading access list:", s), u({}), k(!1));
|
|
138
153
|
}
|
|
139
|
-
})(),
|
|
140
|
-
|
|
154
|
+
})(), q(() => {
|
|
155
|
+
a = !0;
|
|
141
156
|
});
|
|
142
|
-
}),
|
|
157
|
+
}), ie(() => {
|
|
143
158
|
if (!e.isOpen) return;
|
|
144
|
-
const
|
|
145
|
-
|
|
159
|
+
const a = (s) => {
|
|
160
|
+
s.key === "Escape" && e.onClose();
|
|
146
161
|
};
|
|
147
|
-
document.addEventListener("keydown",
|
|
162
|
+
document.addEventListener("keydown", a), q(() => document.removeEventListener("keydown", a));
|
|
148
163
|
});
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
const
|
|
152
|
-
if (
|
|
153
|
-
|
|
164
|
+
const fe = async (a) => {
|
|
165
|
+
a.preventDefault();
|
|
166
|
+
const s = t().trim();
|
|
167
|
+
if (s) {
|
|
168
|
+
z(!0);
|
|
154
169
|
try {
|
|
155
|
-
const
|
|
156
|
-
if (!
|
|
157
|
-
const
|
|
158
|
-
if (!
|
|
159
|
-
await e.hive.addMemberToDoc(e.docUrl,
|
|
160
|
-
} catch (
|
|
161
|
-
console.error("[ShareModal]",
|
|
170
|
+
const C = await ye(), U = C.ContactCard.fromJson(s);
|
|
171
|
+
if (!U) throw new Error("Invalid ContactCard JSON");
|
|
172
|
+
const P = C.Access.tryFromString("write");
|
|
173
|
+
if (!P) throw new Error("Invalid access level");
|
|
174
|
+
await e.hive.addMemberToDoc(e.docUrl, U, P), l("");
|
|
175
|
+
} catch (C) {
|
|
176
|
+
console.error("[ShareModal]", C);
|
|
162
177
|
} finally {
|
|
163
|
-
const
|
|
164
|
-
|
|
178
|
+
const C = await de(e.hive, e.docUrl);
|
|
179
|
+
u(C), z(!1);
|
|
165
180
|
}
|
|
166
181
|
}
|
|
167
|
-
},
|
|
182
|
+
}, he = async (a) => {
|
|
168
183
|
try {
|
|
169
|
-
await e.hive.revokeMemberFromDoc(e.docUrl,
|
|
170
|
-
} catch (
|
|
171
|
-
console.error("[ShareModal]",
|
|
184
|
+
await e.hive.revokeMemberFromDoc(e.docUrl, a);
|
|
185
|
+
} catch (s) {
|
|
186
|
+
console.error("[ShareModal]", s);
|
|
172
187
|
} finally {
|
|
173
|
-
const
|
|
174
|
-
|
|
188
|
+
const s = await de(e.hive, e.docUrl);
|
|
189
|
+
u(s);
|
|
175
190
|
}
|
|
176
|
-
},
|
|
191
|
+
}, ge = async () => {
|
|
177
192
|
try {
|
|
178
|
-
const
|
|
179
|
-
if (!
|
|
180
|
-
await e.hive.setPublicAccess(e.docUrl,
|
|
181
|
-
} catch (
|
|
182
|
-
console.error("[ShareModal]",
|
|
193
|
+
const s = (await ye()).Access.tryFromString("write");
|
|
194
|
+
if (!s) throw new Error("Invalid access level");
|
|
195
|
+
await e.hive.setPublicAccess(e.docUrl, s);
|
|
196
|
+
} catch (a) {
|
|
197
|
+
console.error("[ShareModal]", a);
|
|
183
198
|
} finally {
|
|
184
|
-
const
|
|
185
|
-
|
|
199
|
+
const a = await de(e.hive, e.docUrl);
|
|
200
|
+
u(a);
|
|
186
201
|
}
|
|
187
|
-
},
|
|
202
|
+
}, ne = async () => {
|
|
188
203
|
try {
|
|
189
|
-
await e.hive.revokeMemberFromDoc(e.docUrl,
|
|
190
|
-
} catch (
|
|
191
|
-
console.error("[ShareModal]",
|
|
204
|
+
await e.hive.revokeMemberFromDoc(e.docUrl, G());
|
|
205
|
+
} catch (a) {
|
|
206
|
+
console.error("[ShareModal]", a);
|
|
192
207
|
} finally {
|
|
193
|
-
const
|
|
194
|
-
|
|
208
|
+
const a = await de(e.hive, e.docUrl);
|
|
209
|
+
u(a);
|
|
195
210
|
}
|
|
196
|
-
},
|
|
197
|
-
return
|
|
211
|
+
}, pe = (a) => `0x${a.slice(0, 12)}...`, re = we(() => Object.entries(g()).sort(([a], [s]) => a.localeCompare(s)));
|
|
212
|
+
return m(_, {
|
|
198
213
|
get when() {
|
|
199
214
|
return e.isOpen;
|
|
200
215
|
},
|
|
201
216
|
get children() {
|
|
202
|
-
var
|
|
203
|
-
return
|
|
204
|
-
|
|
205
|
-
},
|
|
217
|
+
var a = Ge(), s = a.firstChild, C = s.firstChild, U = C.firstChild, P = U.nextSibling, T = C.nextSibling, L = T.firstChild, F = L.nextSibling, j = T.nextSibling, ce = j.firstChild;
|
|
218
|
+
return a.$$click = (i) => {
|
|
219
|
+
i.target === i.currentTarget && e.onClose();
|
|
220
|
+
}, s.$$click = (i) => i.stopPropagation(), P.$$click = () => e.onClose(), f(F, m(_, {
|
|
206
221
|
get when() {
|
|
207
|
-
return
|
|
222
|
+
return Q();
|
|
208
223
|
},
|
|
209
224
|
get children() {
|
|
210
|
-
return
|
|
225
|
+
return je();
|
|
211
226
|
}
|
|
212
|
-
}), null),
|
|
227
|
+
}), null), f(F, m(_, {
|
|
213
228
|
get when() {
|
|
214
|
-
return
|
|
229
|
+
return le();
|
|
215
230
|
},
|
|
216
231
|
get children() {
|
|
217
|
-
return [
|
|
232
|
+
return [m(_, {
|
|
218
233
|
get when() {
|
|
219
|
-
return
|
|
234
|
+
return Q();
|
|
220
235
|
},
|
|
221
236
|
get children() {
|
|
222
|
-
var
|
|
223
|
-
return
|
|
237
|
+
var i = Ke();
|
|
238
|
+
return i.$$click = ne, D((S) => E(i, ue, S)), i;
|
|
224
239
|
}
|
|
225
|
-
}),
|
|
240
|
+
}), m(_, {
|
|
226
241
|
get when() {
|
|
227
|
-
return !
|
|
242
|
+
return !Q();
|
|
228
243
|
},
|
|
229
244
|
get children() {
|
|
230
|
-
var
|
|
231
|
-
return
|
|
245
|
+
var i = Je();
|
|
246
|
+
return i.$$click = ge, D((S) => E(i, ue, S)), i;
|
|
232
247
|
}
|
|
233
248
|
})];
|
|
234
249
|
}
|
|
235
|
-
}), null), s
|
|
250
|
+
}), null), f(s, m(_, {
|
|
236
251
|
get when() {
|
|
237
|
-
return
|
|
252
|
+
return le();
|
|
238
253
|
},
|
|
239
254
|
get children() {
|
|
240
255
|
return [(() => {
|
|
241
|
-
var
|
|
242
|
-
return
|
|
256
|
+
var i = Le();
|
|
257
|
+
return D((S) => E(i, Ue, S)), i;
|
|
243
258
|
})(), (() => {
|
|
244
|
-
var
|
|
245
|
-
return
|
|
246
|
-
var
|
|
247
|
-
...
|
|
248
|
-
opacity:
|
|
249
|
-
},
|
|
250
|
-
return
|
|
259
|
+
var i = We(), S = i.firstChild, K = S.nextSibling, V = K.firstChild;
|
|
260
|
+
return i.addEventListener("submit", fe), S.$$input = (M) => l(M.currentTarget.value), f(V, () => N() ? "Adding..." : "Add Member"), D((M) => {
|
|
261
|
+
var n = {
|
|
262
|
+
...ue,
|
|
263
|
+
opacity: N() || !t().trim() ? "0.5" : "1"
|
|
264
|
+
}, r = N() || !t().trim();
|
|
265
|
+
return M.e = E(V, n, M.e), r !== M.t && (V.disabled = M.t = r), M;
|
|
251
266
|
}, {
|
|
252
267
|
e: void 0,
|
|
253
268
|
t: void 0
|
|
254
|
-
}),
|
|
269
|
+
}), D(() => S.value = t()), i;
|
|
255
270
|
})(), (() => {
|
|
256
|
-
var
|
|
257
|
-
return
|
|
271
|
+
var i = Le();
|
|
272
|
+
return D((S) => E(i, Ue, S)), i;
|
|
258
273
|
})()];
|
|
259
274
|
}
|
|
260
|
-
}),
|
|
275
|
+
}), j), f(j, m(_, {
|
|
261
276
|
get when() {
|
|
262
|
-
return
|
|
277
|
+
return p();
|
|
263
278
|
},
|
|
264
279
|
get children() {
|
|
265
|
-
return
|
|
280
|
+
return Be();
|
|
266
281
|
}
|
|
267
|
-
}), null),
|
|
282
|
+
}), null), f(j, m(_, {
|
|
268
283
|
get when() {
|
|
269
|
-
return
|
|
284
|
+
return Z(() => !p())() && re().length === 0;
|
|
270
285
|
},
|
|
271
286
|
get children() {
|
|
272
|
-
return
|
|
287
|
+
return Ye();
|
|
273
288
|
}
|
|
274
|
-
}), null),
|
|
289
|
+
}), null), f(j, m(_, {
|
|
275
290
|
get when() {
|
|
276
|
-
return
|
|
291
|
+
return Z(() => !p())() && re().length > 0;
|
|
277
292
|
},
|
|
278
293
|
get children() {
|
|
279
|
-
var
|
|
280
|
-
return
|
|
294
|
+
var i = qe();
|
|
295
|
+
return f(i, m(Me, {
|
|
281
296
|
get each() {
|
|
282
|
-
return
|
|
297
|
+
return re();
|
|
283
298
|
},
|
|
284
|
-
children: ([
|
|
285
|
-
const
|
|
299
|
+
children: ([S, K]) => {
|
|
300
|
+
const V = S === A(), M = S === ee(), n = S === G(), r = De.indexOf($()), h = De.indexOf(K), c = r >= 0 && h >= 0 && h <= r && !V && !M, b = () => V ? "You" : M ? "Sync Server" : n ? "Public" : pe(S);
|
|
286
301
|
return (() => {
|
|
287
|
-
var
|
|
288
|
-
return X(
|
|
289
|
-
when:
|
|
302
|
+
var y = Xe(), J = y.firstChild, R = J.firstChild, W = R.nextSibling;
|
|
303
|
+
return X(R, "color", V ? "#7ab4f5" : n ? "#b5bd68" : "#edf2f7"), f(R, b), f(W, K), f(y, m(_, {
|
|
304
|
+
when: c,
|
|
290
305
|
get children() {
|
|
291
|
-
var
|
|
292
|
-
return
|
|
293
|
-
...
|
|
294
|
-
},
|
|
306
|
+
var o = Qe();
|
|
307
|
+
return o.$$click = () => he(S), D((d) => E(o, {
|
|
308
|
+
...ue
|
|
309
|
+
}, d)), o;
|
|
295
310
|
}
|
|
296
|
-
}), null),
|
|
311
|
+
}), null), y;
|
|
297
312
|
})();
|
|
298
313
|
}
|
|
299
|
-
})),
|
|
314
|
+
})), i;
|
|
300
315
|
}
|
|
301
|
-
}), null),
|
|
302
|
-
var
|
|
303
|
-
...
|
|
304
|
-
},
|
|
305
|
-
return
|
|
316
|
+
}), null), D((i) => {
|
|
317
|
+
var S = Ce, K = Ze, V = {
|
|
318
|
+
...ue
|
|
319
|
+
}, M = ze, n = ze;
|
|
320
|
+
return i.e = E(a, S, i.e), i.t = E(s, K, i.t), i.a = E(P, V, i.a), i.o = E(L, M, i.o), i.i = E(ce, n, i.i), i;
|
|
306
321
|
}, {
|
|
307
322
|
e: void 0,
|
|
308
323
|
t: void 0,
|
|
309
324
|
a: void 0,
|
|
310
325
|
o: void 0,
|
|
311
326
|
i: void 0
|
|
312
|
-
}),
|
|
327
|
+
}), a;
|
|
313
328
|
}
|
|
314
329
|
});
|
|
315
330
|
}
|
|
316
|
-
|
|
317
|
-
var
|
|
318
|
-
function
|
|
319
|
-
return
|
|
331
|
+
xe(["click", "input"]);
|
|
332
|
+
var tt = /* @__PURE__ */ w('<div><div style=min-width:300px;max-width:400px><h3 style="margin:0 0 12px;font-size:15px"></h3><p style="margin:0 0 20px;font-size:13px;color:#6b7280"></p><div style=display:flex;justify-content:flex-end;gap:8px><button style="background:none;border:1px solid #2a323c;color:#edf2f7;padding:4px 14px;border-radius:4px;cursor:pointer;font-size:12px">Cancel</button><button style="background:#944;border:1px solid #a55;color:#fff;padding:4px 14px;border-radius:4px;cursor:pointer;font-size:12px">');
|
|
333
|
+
function nt(e) {
|
|
334
|
+
return ie(() => {
|
|
320
335
|
if (!e.isOpen) return;
|
|
321
|
-
const t = (
|
|
322
|
-
|
|
336
|
+
const t = (l) => {
|
|
337
|
+
l.key === "Escape" && e.onCancel();
|
|
323
338
|
};
|
|
324
|
-
document.addEventListener("keydown", t),
|
|
325
|
-
}),
|
|
339
|
+
document.addEventListener("keydown", t), q(() => document.removeEventListener("keydown", t));
|
|
340
|
+
}), m(_, {
|
|
326
341
|
get when() {
|
|
327
342
|
return e.isOpen;
|
|
328
343
|
},
|
|
329
344
|
get children() {
|
|
330
|
-
var t =
|
|
331
|
-
return t.$$click = (
|
|
332
|
-
|
|
333
|
-
},
|
|
334
|
-
var
|
|
335
|
-
...
|
|
345
|
+
var t = tt(), l = t.firstChild, g = l.firstChild, u = g.nextSibling, p = u.nextSibling, k = p.firstChild, $ = k.nextSibling;
|
|
346
|
+
return t.$$click = (v) => {
|
|
347
|
+
v.target === v.currentTarget && e.onCancel();
|
|
348
|
+
}, f(g, () => e.title), f(u, () => e.message), k.$$click = () => e.onCancel(), $.$$click = () => e.onConfirm(), f($, () => e.confirmLabel ?? "Confirm"), D((v) => {
|
|
349
|
+
var N = Ce, z = {
|
|
350
|
+
...Se
|
|
336
351
|
};
|
|
337
|
-
return
|
|
352
|
+
return v.e = E(t, N, v.e), v.t = E(l, z, v.t), v;
|
|
338
353
|
}, {
|
|
339
354
|
e: void 0,
|
|
340
355
|
t: void 0
|
|
@@ -342,370 +357,411 @@ function dt(e) {
|
|
|
342
357
|
}
|
|
343
358
|
});
|
|
344
359
|
}
|
|
345
|
-
|
|
346
|
-
var
|
|
347
|
-
function
|
|
348
|
-
const [t,
|
|
349
|
-
let
|
|
350
|
-
|
|
360
|
+
xe(["click"]);
|
|
361
|
+
var rt = /* @__PURE__ */ w('<div><div style=min-width:300px;max-width:400px><h3 style="margin:0 0 12px;font-size:15px">New Document</h3><input type=text style="width:100%;background:#15191e;border:1px solid #2a323c;color:#edf2f7;font-size:14px;padding:8px 10px;border-radius:4px;outline:none;box-sizing:border-box;margin-bottom:16px"><div style=display:flex;justify-content:flex-end;gap:8px><button style="background:none;border:1px solid #2a323c;color:#edf2f7;padding:4px 14px;border-radius:4px;cursor:pointer;font-size:12px">Cancel</button><button style="background:#2a5a8a;border:1px solid #3a6a9a;color:#fff;padding:4px 14px;border-radius:4px;cursor:pointer;font-size:12px">Create');
|
|
362
|
+
function it(e) {
|
|
363
|
+
const [t, l] = x("");
|
|
364
|
+
let g;
|
|
365
|
+
ie(() => {
|
|
351
366
|
if (!e.isOpen) return;
|
|
352
|
-
|
|
353
|
-
const
|
|
354
|
-
|
|
367
|
+
l(""), requestAnimationFrame(() => g?.focus());
|
|
368
|
+
const p = (k) => {
|
|
369
|
+
k.key === "Escape" && e.onCancel();
|
|
355
370
|
};
|
|
356
|
-
document.addEventListener("keydown",
|
|
371
|
+
document.addEventListener("keydown", p), q(() => document.removeEventListener("keydown", p));
|
|
357
372
|
});
|
|
358
|
-
function
|
|
359
|
-
const
|
|
360
|
-
e.onConfirm(
|
|
373
|
+
function u() {
|
|
374
|
+
const p = t().trim();
|
|
375
|
+
e.onConfirm(p || e.defaultTitle);
|
|
361
376
|
}
|
|
362
|
-
return
|
|
377
|
+
return m(_, {
|
|
363
378
|
get when() {
|
|
364
379
|
return e.isOpen;
|
|
365
380
|
},
|
|
366
381
|
get children() {
|
|
367
|
-
var
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
},
|
|
371
|
-
|
|
372
|
-
},
|
|
373
|
-
var
|
|
374
|
-
return typeof
|
|
375
|
-
var
|
|
376
|
-
...
|
|
377
|
-
},
|
|
378
|
-
return
|
|
382
|
+
var p = rt(), k = p.firstChild, $ = k.firstChild, v = $.nextSibling, N = v.nextSibling, z = N.firstChild, oe = z.nextSibling;
|
|
383
|
+
p.$$click = (A) => {
|
|
384
|
+
A.target === A.currentTarget && e.onCancel();
|
|
385
|
+
}, v.$$keydown = (A) => {
|
|
386
|
+
A.key === "Enter" && u();
|
|
387
|
+
}, v.$$input = (A) => l(A.currentTarget.value);
|
|
388
|
+
var H = g;
|
|
389
|
+
return typeof H == "function" ? Ee(H, v) : g = v, z.$$click = () => e.onCancel(), oe.$$click = () => u(), D((A) => {
|
|
390
|
+
var ae = Ce, ee = {
|
|
391
|
+
...Se
|
|
392
|
+
}, te = e.defaultTitle;
|
|
393
|
+
return A.e = E(p, ae, A.e), A.t = E(k, ee, A.t), te !== A.a && He(v, "placeholder", A.a = te), A;
|
|
379
394
|
}, {
|
|
380
395
|
e: void 0,
|
|
381
396
|
t: void 0,
|
|
382
397
|
a: void 0
|
|
383
|
-
}),
|
|
398
|
+
}), D(() => v.value = t()), p;
|
|
384
399
|
}
|
|
385
400
|
});
|
|
386
401
|
}
|
|
387
|
-
|
|
388
|
-
const
|
|
389
|
-
var
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
f(h), A(Ie(t.id, O(), r.url, h));
|
|
402
|
+
xe(["click", "input", "keydown"]);
|
|
403
|
+
const ot = {};
|
|
404
|
+
var at = /* @__PURE__ */ w('<div style="padding:8px 10px;color:#6b7280;font-style:italic">No documents yet'), lt = /* @__PURE__ */ w('<div style="position:absolute;top:34px;left:0;background:#191e24;border:1px solid #2a323c;border-radius:4px;max-height:400px;overflow-y:auto;min-width:280px;max-width:420px;z-index:1000;box-shadow:0 4px 12px rgba(0,0,0,0.4)">'), ct = /* @__PURE__ */ w('<button style="background:none;border:1px solid #2a323c;color:#edf2f7;font-size:13px;padding:4px 10px;border-radius:4px;cursor:pointer;white-space:nowrap">Share'), st = /* @__PURE__ */ w('<button title="Copy automerge URL"style="background:none;border:1px solid #2a323c;font-size:13px;padding:4px 10px;border-radius:4px;cursor:pointer;white-space:nowrap">'), dt = /* @__PURE__ */ w('<button style="background:none;border:1px solid #2a323c;font-size:13px;padding:4px 10px;border-radius:4px;cursor:pointer;white-space:nowrap">'), ut = /* @__PURE__ */ w('<button style="background:none;border:1px solid #944;color:#c66;font-size:13px;padding:4px 10px;border-radius:4px;cursor:pointer;white-space:nowrap">Remove Doc'), ft = /* @__PURE__ */ w('<div style=display:flex;flex-direction:column;height:100vh;background:#1d232a><div style="display:flex;align-items:center;height:52px;min-height:52px;background:#191e24;color:#edf2f7;font-size:14px;font-family:system-ui, sans-serif;padding:0 12px;border-bottom:1px solid #15191e;box-sizing:border-box"><button style="background:none;border:1px solid #2a323c;color:#edf2f7;font-size:13px;padding:4px 10px;border-radius:4px;cursor:pointer;flex-shrink:0;margin-right:12px;white-space:nowrap">+ New</button><input type=text placeholder="Paste automerge:… URL"style="background:#15191e;border:1px solid #2a323c;color:#edf2f7;font-size:13px;padding:4px 10px;border-radius:4px;width:200px;min-width:80px;flex-shrink:1;margin-right:12px;outline:none"><div data-doc-switcher style=position:relative;flex:1;min-width:120px><button style="background:none;border:none;color:#edf2f7;font-size:14px;cursor:pointer;padding:4px 8px;border-radius:4px;max-width:100%;display:flex;align-items:center;gap:4px"><span style=overflow:hidden;text-overflow:ellipsis;white-space:nowrap></span><span style=flex-shrink:0>▾</span></button></div><div style=display:flex;align-items:center;flex-shrink:0;gap:8px></div></div><div style=flex:1;min-height:0;overflow:hidden>'), ht = /* @__PURE__ */ w('<div style="padding:8px 12px;cursor:pointer;border-bottom:1px solid #15191e;overflow:hidden;text-overflow:ellipsis;white-space:nowrap"> <span style=color:#6b7280;font-size:12px>'), gt = /* @__PURE__ */ w('<div style="width:24px;height:24px;border:2px solid #2a323c;border-top-color:#6b7280;border-radius:50%;animation:spin 0.8s linear infinite">'), pt = /* @__PURE__ */ w('<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;height:100%;background:#1d232a;font-family:system-ui, sans-serif;font-size:14px">'), mt = /* @__PURE__ */ w("<div style=height:100%>");
|
|
405
|
+
function yt(e) {
|
|
406
|
+
const t = e.tool, [l, g] = x(null), [u, p] = x("..."), [k, $] = x([]), [v, N] = x(!1), [z, oe] = x(null), [H, A] = x(""), [ae, ee] = x(!1), [te, G] = x(!1), [be, Q] = x(!1), [le, fe] = x(!1), [he, ge] = x(!1), [ne, pe] = x(!1), [re, a] = x(!1), [s, C] = x(null), [U, P] = x(!1);
|
|
407
|
+
let T, L = null, F = 0;
|
|
408
|
+
function j(n) {
|
|
409
|
+
L && (L(), L = null);
|
|
410
|
+
const r = n.doc(), h = r ? t.getTitle(r) : t.defaultTitle;
|
|
411
|
+
p(h), $(Ie(t.id, H(), n.url, h));
|
|
398
412
|
const c = () => {
|
|
399
|
-
const
|
|
400
|
-
if (
|
|
401
|
-
const
|
|
402
|
-
|
|
413
|
+
const b = n.doc();
|
|
414
|
+
if (b) {
|
|
415
|
+
const y = t.getTitle(b);
|
|
416
|
+
p(y), $(Ie(t.id, H(), n.url, y));
|
|
403
417
|
}
|
|
404
418
|
};
|
|
405
|
-
|
|
419
|
+
n.on("change", c), L = () => n.off("change", c);
|
|
406
420
|
}
|
|
407
|
-
async function
|
|
408
|
-
const
|
|
409
|
-
if (!
|
|
421
|
+
async function ce(n) {
|
|
422
|
+
const r = z();
|
|
423
|
+
if (!r) return !0;
|
|
410
424
|
try {
|
|
411
|
-
const
|
|
412
|
-
|
|
425
|
+
const {
|
|
426
|
+
docIdFromAutomergeUrl: h,
|
|
427
|
+
Identifier: c
|
|
428
|
+
} = await import("@automerge/automerge-repo-keyhive"), b = h(n), y = r.active.individual.id, J = c.publicId(), [R, W] = await Promise.all([r.accessForDoc(y, b).catch(() => null), r.accessForDoc(J, b).catch(() => null)]);
|
|
429
|
+
return console.log(`[${t.name}] Access check for ${n.slice(0, 30)}...: my=${R}, public=${W}`), !!(R || W);
|
|
413
430
|
} catch (h) {
|
|
414
|
-
return console.error(`[${t.name}] Access check error for ${
|
|
431
|
+
return console.error(`[${t.name}] Access check error for ${n}:`, h), !0;
|
|
415
432
|
}
|
|
416
433
|
}
|
|
417
|
-
async function
|
|
418
|
-
const
|
|
419
|
-
|
|
434
|
+
async function i(n) {
|
|
435
|
+
const r = ++F;
|
|
436
|
+
L && (L(), L = null), g(null), a(!1), C(null), P(!0), p("Loading...");
|
|
420
437
|
try {
|
|
421
|
-
if (!await
|
|
422
|
-
if (
|
|
423
|
-
console.warn(`[${t.name}] No access to doc: ${
|
|
438
|
+
if (!await ce(n)) {
|
|
439
|
+
if (r !== F) return;
|
|
440
|
+
console.warn(`[${t.name}] No access to doc: ${n}`), P(!1), a(!0), C(n), se(n);
|
|
424
441
|
return;
|
|
425
442
|
}
|
|
426
|
-
if (
|
|
427
|
-
const h = (
|
|
428
|
-
const
|
|
429
|
-
return
|
|
443
|
+
if (r !== F) return;
|
|
444
|
+
const h = (b) => {
|
|
445
|
+
const y = b.doc();
|
|
446
|
+
return y ? t.isDocReady ? t.isDocReady(y) : !!y : !1;
|
|
430
447
|
};
|
|
431
|
-
let c =
|
|
432
|
-
if (await c.whenReady(),
|
|
448
|
+
let c = T.find(n);
|
|
449
|
+
if (await c.whenReady(), r !== F) return;
|
|
433
450
|
if (!h(c)) {
|
|
434
|
-
console.log(`[${t.name}] Doc incomplete, forcing re-sync for: ${
|
|
451
|
+
console.log(`[${t.name}] Doc incomplete, forcing re-sync for: ${n.slice(0, 30)}...`);
|
|
435
452
|
try {
|
|
436
|
-
|
|
453
|
+
T.delete(n);
|
|
437
454
|
} catch {
|
|
438
455
|
}
|
|
439
|
-
if (await new Promise((
|
|
456
|
+
if (await new Promise((b) => setTimeout(b, 100)), r !== F || (c = T.find(n), await c.whenReady(), r !== F)) return;
|
|
440
457
|
}
|
|
441
|
-
if (!h(c) && (
|
|
442
|
-
const
|
|
443
|
-
if (
|
|
444
|
-
c.off("change",
|
|
458
|
+
if (!h(c) && (se(n), await new Promise((b) => {
|
|
459
|
+
const y = () => {
|
|
460
|
+
if (r !== F) {
|
|
461
|
+
c.off("change", y), b();
|
|
445
462
|
return;
|
|
446
463
|
}
|
|
447
|
-
h(c) && (c.off("change",
|
|
464
|
+
h(c) && (c.off("change", y), b());
|
|
448
465
|
};
|
|
449
|
-
c.on("change",
|
|
450
|
-
c.off("change",
|
|
466
|
+
c.on("change", y), setTimeout(() => {
|
|
467
|
+
c.off("change", y), b();
|
|
451
468
|
}, 3e4);
|
|
452
|
-
}),
|
|
469
|
+
}), r !== F))
|
|
453
470
|
return;
|
|
454
|
-
|
|
471
|
+
P(!1), se(n), localStorage.setItem(me(t.id, H()), n), j(c), g(c);
|
|
455
472
|
} catch (h) {
|
|
456
|
-
if (
|
|
457
|
-
console.error(`[${t.name}] Failed to load doc: ${
|
|
473
|
+
if (r !== F) return;
|
|
474
|
+
console.error(`[${t.name}] Failed to load doc: ${n}`, h), P(!1), a(!0), C(n), se(n);
|
|
458
475
|
}
|
|
459
476
|
}
|
|
460
|
-
async function
|
|
461
|
-
const
|
|
462
|
-
|
|
463
|
-
const h = {};
|
|
464
|
-
t.init(h, M), t.setTitle && t.setTitle(h, r), h["@patchwork"] = {
|
|
477
|
+
async function S(n = t.defaultTitle) {
|
|
478
|
+
const r = {};
|
|
479
|
+
t.init(r, T), t.setTitle && t.setTitle(r, n), r["@patchwork"] = {
|
|
465
480
|
type: t.id
|
|
466
481
|
};
|
|
467
|
-
const
|
|
468
|
-
|
|
482
|
+
const h = z();
|
|
483
|
+
let c;
|
|
484
|
+
h ? (c = await T.create2(r), console.log(`[${t.name}] Created document (keyhive): ${c.url}`), await h.addSyncServerPullToDoc(c.url), await h.keyhiveStorage.saveKeyhiveWithHash(h.keyhive)) : (c = T.create(r), console.log(`[${t.name}] Created document (legacy): ${c.url}`)), g(c), se(c.url), localStorage.setItem(me(t.id, H()), c.url), j(c);
|
|
469
485
|
}
|
|
470
|
-
function
|
|
471
|
-
|
|
486
|
+
function K() {
|
|
487
|
+
L && (L(), L = null), g(null), p("..."), a(!1), C(null), localStorage.removeItem(me(t.id, H())), window.history.replaceState(null, "", window.location.pathname);
|
|
472
488
|
}
|
|
473
|
-
function
|
|
474
|
-
const
|
|
475
|
-
if (!
|
|
476
|
-
const
|
|
477
|
-
|
|
489
|
+
function V() {
|
|
490
|
+
const n = l();
|
|
491
|
+
if (!n) return;
|
|
492
|
+
const r = n.url;
|
|
493
|
+
K(), T.delete(r), $(Ne(t.id, H(), r));
|
|
478
494
|
}
|
|
479
|
-
async function
|
|
480
|
-
const
|
|
481
|
-
if (
|
|
495
|
+
async function M() {
|
|
496
|
+
const n = z();
|
|
497
|
+
if (n)
|
|
482
498
|
try {
|
|
483
|
-
const
|
|
484
|
-
await navigator.clipboard.writeText(
|
|
485
|
-
} catch (
|
|
486
|
-
console.error(`[${t.name}] Failed to copy contact card:`,
|
|
499
|
+
const r = n.active.contactCard.toJson();
|
|
500
|
+
await navigator.clipboard.writeText(r), fe(!0), setTimeout(() => fe(!1), 1500);
|
|
501
|
+
} catch (r) {
|
|
502
|
+
console.error(`[${t.name}] Failed to copy contact card:`, r);
|
|
487
503
|
}
|
|
488
504
|
}
|
|
489
|
-
return
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
});
|
|
498
|
-
window.hive = p, M = new We({
|
|
499
|
-
storage: new Ae(),
|
|
500
|
-
network: [p.networkAdapter],
|
|
501
|
-
peerId: p.peerId,
|
|
502
|
-
sharePolicy: async (B) => B === p.syncServer?.peerId,
|
|
503
|
-
idFactory: p.idFactory
|
|
504
|
-
}), p.linkRepo(M), ne(p);
|
|
505
|
-
const m = de(p.active.individual.id.toBytes());
|
|
506
|
-
_(m), A(we(t.id, m)), L(!0), console.log(`[${t.name}] Keyhive initialized, identity: 0x${m.slice(0, 12)}...`), p.networkAdapter.on("ingest-remote", async () => {
|
|
507
|
-
const B = he();
|
|
508
|
-
if (B) {
|
|
509
|
-
await E(B) && (console.log(`[${t.name}] Access granted, loading: ${B}`), await S(B));
|
|
510
|
-
return;
|
|
505
|
+
return $e(async () => {
|
|
506
|
+
if (e.config?.legacyMode) {
|
|
507
|
+
T = e.config.repo;
|
|
508
|
+
const h = `standalone-frame-identity-${t.id}`;
|
|
509
|
+
let c = localStorage.getItem(h);
|
|
510
|
+
if (!c) {
|
|
511
|
+
const b = new Uint8Array(16);
|
|
512
|
+
crypto.getRandomValues(b), c = Array.from(b).map((y) => y.toString(16).padStart(2, "0")).join(""), localStorage.setItem(h, c);
|
|
511
513
|
}
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
514
|
+
A(c), $(ve(t.id, c)), pe(!0), console.log(`[${t.name}] Legacy mode initialized, identity: 0x${c.slice(0, 12)}...`);
|
|
515
|
+
} else {
|
|
516
|
+
const [{
|
|
517
|
+
Repo: h
|
|
518
|
+
}, {
|
|
519
|
+
IndexedDBStorageAdapter: c
|
|
520
|
+
}, {
|
|
521
|
+
BrowserWebSocketClientAdapter: b
|
|
522
|
+
}, y] = await Promise.all([import("@automerge/automerge-repo"), import("@automerge/automerge-repo-storage-indexeddb"), import("@automerge/automerge-repo-network-websocket"), import("@automerge/automerge-repo-keyhive")]);
|
|
523
|
+
y.initKeyhiveWasm();
|
|
524
|
+
const J = new c(`${t.id}-keyhive`), R = ot?.VITE_SYNC_URL, W = new b(R || t.syncUrl || "ws://localhost:3030"), o = `${t.id}-${Math.random().toString(36).slice(2)}`, d = await y.initializeAutomergeRepoKeyhive({
|
|
525
|
+
storage: J,
|
|
526
|
+
peerIdSuffix: o,
|
|
527
|
+
networkAdapter: W,
|
|
528
|
+
automaticArchiveIngestion: !0,
|
|
529
|
+
onlyShareWithHardcodedServerPeerId: !0,
|
|
530
|
+
cacheHashes: !0
|
|
531
|
+
});
|
|
532
|
+
window.hive = d;
|
|
533
|
+
const I = new h({
|
|
534
|
+
storage: new c(),
|
|
535
|
+
network: [d.networkAdapter],
|
|
536
|
+
peerId: d.peerId,
|
|
537
|
+
sharePolicy: async (Y) => Y === d.syncServer?.peerId,
|
|
538
|
+
idFactory: d.idFactory
|
|
539
|
+
});
|
|
540
|
+
T = I, d.linkRepo(I), oe(d);
|
|
541
|
+
const B = y.uint8ArrayToHex(d.active.individual.id.toBytes());
|
|
542
|
+
A(B), $(ve(t.id, B)), pe(!0), console.log(`[${t.name}] Keyhive initialized, identity: 0x${B.slice(0, 12)}...`), d.networkAdapter.on("ingest-remote", async () => {
|
|
543
|
+
const Y = s();
|
|
544
|
+
if (Y) {
|
|
545
|
+
await ce(Y) && (console.log(`[${t.name}] Access granted, loading: ${Y}`), await i(Y));
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
548
|
+
const O = l();
|
|
549
|
+
O && (await ce(O.url) || (console.log(`[${t.name}] Access revoked for: ${O.url}`), L && (L(), L = null), g(null), p("..."), a(!0), C(O.url)));
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
const n = Te();
|
|
553
|
+
if (n) {
|
|
554
|
+
console.log(`[${t.name}] Loading doc from hash: ${n}`), await i(n);
|
|
518
555
|
return;
|
|
519
556
|
}
|
|
520
|
-
const
|
|
521
|
-
if (
|
|
522
|
-
console.log(`[${t.name}] Found existing doc: ${
|
|
557
|
+
const r = localStorage.getItem(me(t.id, H()));
|
|
558
|
+
if (r) {
|
|
559
|
+
console.log(`[${t.name}] Found existing doc: ${r}`), await i(r);
|
|
523
560
|
return;
|
|
524
561
|
}
|
|
525
562
|
console.log(`[${t.name}] No doc found, starting blank`);
|
|
526
|
-
}),
|
|
527
|
-
const
|
|
528
|
-
const
|
|
529
|
-
|
|
563
|
+
}), $e(() => {
|
|
564
|
+
const n = async () => {
|
|
565
|
+
const r = Te();
|
|
566
|
+
r && (console.log(`[${t.name}] Hash changed, loading: ${r}`), await i(r));
|
|
530
567
|
};
|
|
531
|
-
window.addEventListener("hashchange",
|
|
532
|
-
}),
|
|
533
|
-
const
|
|
534
|
-
|
|
568
|
+
window.addEventListener("hashchange", n), q(() => window.removeEventListener("hashchange", n));
|
|
569
|
+
}), $e(() => {
|
|
570
|
+
const n = (r) => {
|
|
571
|
+
r.target.closest("[data-doc-switcher]") || N(!1);
|
|
535
572
|
};
|
|
536
|
-
document.addEventListener("mousedown",
|
|
573
|
+
document.addEventListener("mousedown", n), q(() => document.removeEventListener("mousedown", n));
|
|
537
574
|
}), (() => {
|
|
538
|
-
var
|
|
539
|
-
|
|
540
|
-
var
|
|
541
|
-
return h.$$click = () =>
|
|
542
|
-
if (
|
|
543
|
-
const
|
|
544
|
-
if (
|
|
545
|
-
const
|
|
546
|
-
|
|
575
|
+
var n = ft(), r = n.firstChild, h = r.firstChild, c = h.nextSibling, b = c.nextSibling, y = b.firstChild, J = y.firstChild;
|
|
576
|
+
J.nextSibling;
|
|
577
|
+
var R = b.nextSibling, W = r.nextSibling;
|
|
578
|
+
return h.$$click = () => Q(!0), c.$$keydown = (o) => {
|
|
579
|
+
if (o.key === "Enter") {
|
|
580
|
+
const d = o.currentTarget.value.trim();
|
|
581
|
+
if (d) {
|
|
582
|
+
const I = d.startsWith("automerge:") ? d : `automerge:${d}`;
|
|
583
|
+
i(I), o.currentTarget.value = "";
|
|
547
584
|
}
|
|
548
585
|
}
|
|
549
|
-
},
|
|
586
|
+
}, y.$$click = () => N(!v()), f(J, u), f(b, m(_, {
|
|
550
587
|
get when() {
|
|
551
|
-
return
|
|
588
|
+
return v();
|
|
552
589
|
},
|
|
553
590
|
get children() {
|
|
554
|
-
var
|
|
555
|
-
return
|
|
591
|
+
var o = lt();
|
|
592
|
+
return f(o, m(Me, {
|
|
556
593
|
get each() {
|
|
557
|
-
return
|
|
594
|
+
return k();
|
|
558
595
|
},
|
|
559
|
-
children: (
|
|
560
|
-
var
|
|
561
|
-
return
|
|
562
|
-
|
|
563
|
-
}),
|
|
564
|
-
|
|
565
|
-
}),
|
|
566
|
-
|
|
567
|
-
},
|
|
568
|
-
var
|
|
569
|
-
return
|
|
596
|
+
children: (d) => (() => {
|
|
597
|
+
var I = ht(), B = I.firstChild, Y = B.nextSibling;
|
|
598
|
+
return I.addEventListener("mouseleave", (O) => {
|
|
599
|
+
O.currentTarget.style.background = "transparent";
|
|
600
|
+
}), I.addEventListener("mouseenter", (O) => {
|
|
601
|
+
O.currentTarget.style.background = "#1d232a";
|
|
602
|
+
}), I.$$click = () => {
|
|
603
|
+
i(d.url), N(!1);
|
|
604
|
+
}, f(I, () => d.title || "Untitled", B), f(Y, () => Ve(d.url)), D((O) => {
|
|
605
|
+
var _e = l()?.url === d.url ? "#7ab4f5" : "#edf2f7", Ae = l()?.url === d.url ? "bold" : "normal";
|
|
606
|
+
return _e !== O.e && X(I, "color", O.e = _e), Ae !== O.t && X(I, "font-weight", O.t = Ae), O;
|
|
570
607
|
}, {
|
|
571
608
|
e: void 0,
|
|
572
609
|
t: void 0
|
|
573
|
-
}),
|
|
610
|
+
}), I;
|
|
574
611
|
})()
|
|
575
|
-
}), null),
|
|
612
|
+
}), null), f(o, m(_, {
|
|
576
613
|
get when() {
|
|
577
|
-
return
|
|
614
|
+
return k().length === 0;
|
|
578
615
|
},
|
|
579
616
|
get children() {
|
|
580
|
-
return
|
|
617
|
+
return at();
|
|
581
618
|
}
|
|
582
|
-
}), null),
|
|
619
|
+
}), null), o;
|
|
583
620
|
}
|
|
584
|
-
}), null),
|
|
621
|
+
}), null), f(R, m(_, {
|
|
585
622
|
get when() {
|
|
586
|
-
return
|
|
623
|
+
return Z(() => !!l())() && z();
|
|
587
624
|
},
|
|
588
625
|
get children() {
|
|
589
|
-
var
|
|
590
|
-
return
|
|
626
|
+
var o = ct();
|
|
627
|
+
return o.$$click = () => ee(!0), o;
|
|
591
628
|
}
|
|
592
|
-
}), null),
|
|
629
|
+
}), null), f(R, m(_, {
|
|
593
630
|
get when() {
|
|
594
|
-
return
|
|
631
|
+
return l();
|
|
595
632
|
},
|
|
596
633
|
get children() {
|
|
597
|
-
var
|
|
598
|
-
return
|
|
599
|
-
const
|
|
600
|
-
|
|
601
|
-
},
|
|
634
|
+
var o = st();
|
|
635
|
+
return o.$$click = async () => {
|
|
636
|
+
const d = l();
|
|
637
|
+
d && (await navigator.clipboard.writeText(d.url), ge(!0), setTimeout(() => ge(!1), 1500));
|
|
638
|
+
}, f(o, () => he() ? "Copied!" : "Copy URL"), D((d) => X(o, "color", he() ? "#b5bd68" : "#edf2f7")), o;
|
|
602
639
|
}
|
|
603
|
-
}), null),
|
|
640
|
+
}), null), f(R, m(_, {
|
|
604
641
|
get when() {
|
|
605
|
-
return
|
|
642
|
+
return z();
|
|
606
643
|
},
|
|
607
644
|
get children() {
|
|
608
|
-
var
|
|
609
|
-
return
|
|
645
|
+
var o = dt();
|
|
646
|
+
return o.$$click = () => void M(), f(o, () => le() ? "Copied!" : "Contact Card"), D((d) => X(o, "color", le() ? "#b5bd68" : "#edf2f7")), o;
|
|
610
647
|
}
|
|
611
|
-
}), null),
|
|
648
|
+
}), null), f(R, m(_, {
|
|
612
649
|
get when() {
|
|
613
|
-
return
|
|
650
|
+
return l();
|
|
614
651
|
},
|
|
615
652
|
get children() {
|
|
616
|
-
var
|
|
617
|
-
return
|
|
653
|
+
var o = ut();
|
|
654
|
+
return o.$$click = () => G(!0), o;
|
|
618
655
|
}
|
|
619
|
-
}), null),
|
|
656
|
+
}), null), f(W, m(_, {
|
|
620
657
|
get when() {
|
|
621
|
-
return
|
|
658
|
+
return l();
|
|
622
659
|
},
|
|
623
660
|
keyed: !0,
|
|
624
661
|
get fallback() {
|
|
625
662
|
return (() => {
|
|
626
|
-
var
|
|
627
|
-
return
|
|
663
|
+
var o = pt();
|
|
664
|
+
return f(o, m(_, {
|
|
628
665
|
get when() {
|
|
629
|
-
return
|
|
666
|
+
return U() || !ne();
|
|
630
667
|
},
|
|
631
668
|
get children() {
|
|
632
|
-
return
|
|
669
|
+
return gt();
|
|
633
670
|
}
|
|
634
|
-
}), null),
|
|
635
|
-
var
|
|
636
|
-
return () =>
|
|
637
|
-
})(), null),
|
|
671
|
+
}), null), f(o, (() => {
|
|
672
|
+
var d = Z(() => !!re());
|
|
673
|
+
return () => d() ? "Document unavailable: you may not have access" : Z(() => !!U())() ? "Loading document..." : Z(() => !!ne())() ? "No document open" : e.config?.legacyMode ? "Initializing..." : "Initializing keyhive...";
|
|
674
|
+
})(), null), D((d) => X(o, "color", re() ? "#c66" : "#6b7280")), o;
|
|
638
675
|
})();
|
|
639
676
|
},
|
|
640
|
-
children: (
|
|
641
|
-
const
|
|
642
|
-
return
|
|
643
|
-
var
|
|
644
|
-
return
|
|
645
|
-
|
|
646
|
-
},
|
|
677
|
+
children: (o) => {
|
|
678
|
+
const d = document.createElement("div");
|
|
679
|
+
return d.repo = T, d.style.height = "100%", (() => {
|
|
680
|
+
var I = mt();
|
|
681
|
+
return Ee((B) => {
|
|
682
|
+
B.appendChild(d), t.render(o, d);
|
|
683
|
+
}, I), I;
|
|
647
684
|
})();
|
|
648
685
|
}
|
|
649
|
-
})),
|
|
686
|
+
})), f(n, m(_, {
|
|
650
687
|
get when() {
|
|
651
|
-
return
|
|
688
|
+
return Z(() => !!z())() && l();
|
|
652
689
|
},
|
|
653
690
|
get children() {
|
|
654
|
-
return
|
|
691
|
+
return m(et, {
|
|
655
692
|
get isOpen() {
|
|
656
|
-
return
|
|
693
|
+
return ae();
|
|
657
694
|
},
|
|
658
695
|
get docUrl() {
|
|
659
|
-
return
|
|
696
|
+
return l().url;
|
|
660
697
|
},
|
|
661
698
|
get hive() {
|
|
662
|
-
return
|
|
699
|
+
return z();
|
|
663
700
|
},
|
|
664
|
-
onClose: () =>
|
|
701
|
+
onClose: () => ee(!1)
|
|
665
702
|
});
|
|
666
703
|
}
|
|
667
|
-
}), null),
|
|
704
|
+
}), null), f(n, m(it, {
|
|
668
705
|
get isOpen() {
|
|
669
|
-
return
|
|
706
|
+
return be();
|
|
670
707
|
},
|
|
671
708
|
get defaultTitle() {
|
|
672
709
|
return t.defaultTitle;
|
|
673
710
|
},
|
|
674
|
-
onConfirm: (
|
|
675
|
-
|
|
711
|
+
onConfirm: (o) => {
|
|
712
|
+
Q(!1), S(o);
|
|
676
713
|
},
|
|
677
|
-
onCancel: () =>
|
|
678
|
-
}), null),
|
|
714
|
+
onCancel: () => Q(!1)
|
|
715
|
+
}), null), f(n, m(nt, {
|
|
679
716
|
get isOpen() {
|
|
680
|
-
return
|
|
717
|
+
return te();
|
|
681
718
|
},
|
|
682
719
|
title: "Remove Document",
|
|
683
720
|
message: "Remove this document from your history? The document data will be deleted locally.",
|
|
684
721
|
confirmLabel: "Remove",
|
|
685
722
|
onConfirm: () => {
|
|
686
|
-
|
|
723
|
+
G(!1), V();
|
|
687
724
|
},
|
|
688
|
-
onCancel: () =>
|
|
689
|
-
}), null),
|
|
690
|
-
var
|
|
691
|
-
return
|
|
725
|
+
onCancel: () => G(!1)
|
|
726
|
+
}), null), D((o) => {
|
|
727
|
+
var d = !ne(), I = ne() ? "1" : "0.4";
|
|
728
|
+
return d !== o.e && (h.disabled = o.e = d), I !== o.t && X(h, "opacity", o.t = I), o;
|
|
692
729
|
}, {
|
|
693
730
|
e: void 0,
|
|
694
731
|
t: void 0
|
|
695
|
-
}),
|
|
732
|
+
}), n;
|
|
696
733
|
})();
|
|
697
734
|
}
|
|
698
|
-
|
|
699
|
-
function
|
|
700
|
-
|
|
701
|
-
|
|
735
|
+
xe(["click", "keydown"]);
|
|
736
|
+
async function vt(e) {
|
|
737
|
+
const t = e.find(($) => $.type === "patchwork:tool"), l = e.find(($) => $.type === "patchwork:datatype");
|
|
738
|
+
if (!t) throw new Error("No patchwork:tool plugin found in plugins array");
|
|
739
|
+
if (!l) throw new Error("No patchwork:datatype plugin found in plugins array");
|
|
740
|
+
const [g, u] = await Promise.all([t.load(), l.load()]), p = {};
|
|
741
|
+
u.init(p, {});
|
|
742
|
+
const k = u.getTitle(p);
|
|
743
|
+
return {
|
|
744
|
+
id: t.id,
|
|
745
|
+
name: t.name,
|
|
746
|
+
defaultTitle: k,
|
|
747
|
+
init: u.init,
|
|
748
|
+
getTitle: u.getTitle,
|
|
749
|
+
setTitle: u.setTitle,
|
|
750
|
+
render: g
|
|
751
|
+
};
|
|
752
|
+
}
|
|
753
|
+
async function wt(e, t, l) {
|
|
754
|
+
let g;
|
|
755
|
+
Array.isArray(t) ? g = await vt(t) : g = t, Pe(() => m(yt, {
|
|
756
|
+
tool: g,
|
|
757
|
+
config: l
|
|
702
758
|
}), e);
|
|
703
759
|
}
|
|
704
760
|
export {
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
761
|
+
nt as ConfirmModal,
|
|
762
|
+
it as NewDocModal,
|
|
763
|
+
et as ShareModal,
|
|
764
|
+
Se as cardStyle,
|
|
765
|
+
wt as mountStandaloneApp,
|
|
766
|
+
Ce as overlayStyle
|
|
711
767
|
};
|