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