@inkandswitch/patchwork-pkg-base 0.0.109 → 0.0.110
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/module-settings-url +1 -1
- package/package.json +1 -1
- package/packages/add-doc-to-sidebar-button/button.js +141 -25
- package/packages/add-doc-to-sidebar-button/button.test.js +114 -0
- package/packages/threepane/dist/IsolatedDocumentArea-5WRK3TWL.js +2 -0
- package/packages/threepane/dist/PatchworkFrame-22UEOQ6E.js +2 -0
- package/packages/threepane/dist/PatchworkFrame-22UEOQ6E.js.map +7 -0
- package/packages/threepane/dist/{chunk-XOKWELWP.js → chunk-U4IJVHXK.js} +10 -5
- package/packages/threepane/dist/chunk-U4IJVHXK.js.map +7 -0
- package/packages/threepane/dist/index.js +1 -1
- package/plugin-registry-url +1 -1
- package/packages/threepane/dist/IsolatedDocumentArea-UTNJADQ7.js +0 -2
- package/packages/threepane/dist/PatchworkFrame-U2TVLGCZ.js +0 -2
- package/packages/threepane/dist/PatchworkFrame-U2TVLGCZ.js.map +0 -7
- package/packages/threepane/dist/chunk-XOKWELWP.js.map +0 -7
- /package/packages/threepane/dist/{IsolatedDocumentArea-UTNJADQ7.js.map → IsolatedDocumentArea-5WRK3TWL.js.map} +0 -0
package/module-settings-url
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
automerge:
|
|
1
|
+
automerge:25J8uXbNL9ojTwWnJpMJJzMahP28
|
package/package.json
CHANGED
|
@@ -7,19 +7,99 @@ link.rel = "stylesheet";
|
|
|
7
7
|
link.href = cssURL.href;
|
|
8
8
|
document.head.appendChild(link);
|
|
9
9
|
|
|
10
|
+
const LABEL = "Add to sidebar";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Fired (bubbling, composed, cancelable) at the button's own element. A frame
|
|
14
|
+
* that claims it calls preventDefault() and hands its work to
|
|
15
|
+
* `detail.respondWith`. threepane listens for this.
|
|
16
|
+
*/
|
|
17
|
+
export const ADD_TO_SIDEBAR_EVENT = "patchwork:add-to-sidebar";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Put `link` first in the folder. A doc that's already there is lifted to the
|
|
21
|
+
* top, keeping its own name, rather than added twice. (threepane has the same
|
|
22
|
+
* rule in src/account/addToSidebar.ts.)
|
|
23
|
+
*/
|
|
24
|
+
export function putAtTop(folder, link) {
|
|
25
|
+
if (!folder.docs) folder.docs = [];
|
|
26
|
+
const docs = folder.docs;
|
|
27
|
+
const at = docs.findIndex((existing) => existing.url === link.url);
|
|
28
|
+
if (at === 0) return;
|
|
29
|
+
if (at > 0) {
|
|
30
|
+
const { name, type } = docs[at];
|
|
31
|
+
docs.splice(at, 1);
|
|
32
|
+
docs.unshift({ url: link.url, name, type });
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
docs.unshift({ url: link.url, name: link.name, type: link.type });
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The account handle, wherever this host put it. Most hosts copy it onto
|
|
40
|
+
* `window.accountDocHandle`; some (gaios) only have it on `window.patchwork`.
|
|
41
|
+
*/
|
|
42
|
+
function accountHandle() {
|
|
43
|
+
return window.accountDocHandle ?? window.patchwork?.account;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The page's own repo, not the one on the element: titlebar tools can sit
|
|
48
|
+
* inside a draft overlay, whose repo would hand back a draft of the sidebar.
|
|
49
|
+
*/
|
|
50
|
+
function pageRepo(element) {
|
|
51
|
+
return window.repo ?? window.patchwork?.repo ?? element.repo;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Resolves with pick(doc) once it's something. */
|
|
55
|
+
function when(handle, pick) {
|
|
56
|
+
return new Promise((resolve) => {
|
|
57
|
+
const check = () => {
|
|
58
|
+
const doc = handle.doc();
|
|
59
|
+
const picked = doc && pick(doc);
|
|
60
|
+
if (!picked) return;
|
|
61
|
+
handle.off("change", check);
|
|
62
|
+
resolve(picked);
|
|
63
|
+
};
|
|
64
|
+
handle.on("change", check);
|
|
65
|
+
check();
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function withTimeout(promise, ms, message) {
|
|
70
|
+
let timer;
|
|
71
|
+
return Promise.race([
|
|
72
|
+
promise,
|
|
73
|
+
new Promise((_, reject) => {
|
|
74
|
+
timer = setTimeout(() => reject(new Error(message)), ms);
|
|
75
|
+
}),
|
|
76
|
+
]).finally(() => clearTimeout(timer));
|
|
77
|
+
}
|
|
78
|
+
|
|
10
79
|
export default function renderAddDocToSidebarButton(handle, element) {
|
|
11
80
|
const wrapper = document.createElement("div");
|
|
12
81
|
wrapper.className = "add-doc-to-sidebar";
|
|
13
82
|
|
|
14
83
|
const button = document.createElement("button");
|
|
15
|
-
button.
|
|
84
|
+
button.type = "button";
|
|
85
|
+
button.textContent = LABEL;
|
|
16
86
|
wrapper.appendChild(button);
|
|
17
87
|
|
|
18
|
-
// hidden
|
|
88
|
+
// hidden until we know the doc's datatype (a doc link needs one)
|
|
19
89
|
wrapper.style.display = "none";
|
|
20
90
|
|
|
21
91
|
let docDatatypeId;
|
|
22
92
|
let title;
|
|
93
|
+
let loadingDatatype;
|
|
94
|
+
let resetTimer;
|
|
95
|
+
let disposed = false;
|
|
96
|
+
|
|
97
|
+
// The doc the frame has open. The view's doc-url is the real one; the handle
|
|
98
|
+
// may be a draft overlay presenting it.
|
|
99
|
+
const docUrl = () =>
|
|
100
|
+
element.closest?.("patchwork-view")?.getAttribute("doc-url") ??
|
|
101
|
+
element.getAttribute?.("doc-url") ??
|
|
102
|
+
handle.url;
|
|
23
103
|
|
|
24
104
|
function update() {
|
|
25
105
|
const doc = handle.doc();
|
|
@@ -35,48 +115,84 @@ export default function renderAddDocToSidebarButton(handle, element) {
|
|
|
35
115
|
const loaded = registry.get(docDatatypeId);
|
|
36
116
|
if (loaded && "module" in loaded) {
|
|
37
117
|
title = loaded.module.getTitle(doc) || undefined;
|
|
118
|
+
} else if (loadingDatatype !== docDatatypeId) {
|
|
119
|
+
loadingDatatype = docDatatypeId;
|
|
120
|
+
registry.load(docDatatypeId).then(() => {
|
|
121
|
+
if (!disposed) update();
|
|
122
|
+
});
|
|
38
123
|
}
|
|
39
124
|
|
|
40
125
|
wrapper.style.display = "";
|
|
41
126
|
}
|
|
42
127
|
|
|
43
|
-
|
|
44
|
-
|
|
128
|
+
function flash(text) {
|
|
129
|
+
clearTimeout(resetTimer);
|
|
130
|
+
button.textContent = text;
|
|
131
|
+
resetTimer = setTimeout(() => {
|
|
132
|
+
button.textContent = LABEL;
|
|
133
|
+
button.disabled = false;
|
|
134
|
+
}, 1500);
|
|
135
|
+
}
|
|
45
136
|
|
|
46
|
-
|
|
47
|
-
|
|
137
|
+
// Ask whatever frame we're in to do it (threepane answers). If nobody
|
|
138
|
+
// claims the event, put it in the account's root folder ourselves.
|
|
139
|
+
function askFrame(link) {
|
|
140
|
+
let work;
|
|
141
|
+
const event = new CustomEvent(ADD_TO_SIDEBAR_EVENT, {
|
|
142
|
+
bubbles: true,
|
|
143
|
+
composed: true,
|
|
144
|
+
cancelable: true,
|
|
145
|
+
detail: {
|
|
146
|
+
...link,
|
|
147
|
+
respondWith(promise) {
|
|
148
|
+
work = promise;
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
wrapper.dispatchEvent(event);
|
|
153
|
+
if (!event.defaultPrevented) return undefined;
|
|
154
|
+
return work ?? Promise.resolve();
|
|
155
|
+
}
|
|
48
156
|
|
|
49
|
-
|
|
50
|
-
|
|
157
|
+
async function addItOurselves(link) {
|
|
158
|
+
const account = accountHandle();
|
|
159
|
+
if (!account) throw new Error("no account handle on this page");
|
|
160
|
+
const rootFolderUrl = await withTimeout(
|
|
161
|
+
when(account, (doc) => doc.rootFolderUrl),
|
|
162
|
+
5000,
|
|
163
|
+
"account has no rootFolderUrl"
|
|
51
164
|
);
|
|
165
|
+
const rootFolder = await pageRepo(element).find(rootFolderUrl);
|
|
166
|
+
rootFolder.change((folder) => putAtTop(folder, link));
|
|
167
|
+
}
|
|
52
168
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
169
|
+
async function onAddDocToSidebar() {
|
|
170
|
+
const link = {
|
|
171
|
+
url: docUrl(),
|
|
172
|
+
name: title ?? "Untitled",
|
|
173
|
+
type: docDatatypeId,
|
|
174
|
+
};
|
|
175
|
+
button.disabled = true;
|
|
176
|
+
try {
|
|
177
|
+
await (askFrame(link) ?? addItOurselves(link));
|
|
178
|
+
flash("Added ✓");
|
|
179
|
+
} catch (error) {
|
|
180
|
+
console.error("[add-doc-to-sidebar] couldn't add to sidebar", error);
|
|
181
|
+
flash("Couldn't add");
|
|
182
|
+
}
|
|
60
183
|
}
|
|
61
184
|
|
|
62
185
|
button.addEventListener("click", onAddDocToSidebar);
|
|
63
186
|
handle.on("change", update);
|
|
64
187
|
update();
|
|
65
188
|
|
|
66
|
-
// try to load the datatype async if it wasn't ready yet
|
|
67
|
-
const doc = handle.doc();
|
|
68
|
-
if (doc) {
|
|
69
|
-
const datatypeId = getType(doc);
|
|
70
|
-
if (datatypeId) {
|
|
71
|
-
const registry = getRegistry("patchwork:datatype");
|
|
72
|
-
registry.load(datatypeId).then(() => update());
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
189
|
element.appendChild(wrapper);
|
|
77
190
|
|
|
78
191
|
return () => {
|
|
192
|
+
disposed = true;
|
|
193
|
+
clearTimeout(resetTimer);
|
|
79
194
|
handle.off("change", update);
|
|
80
195
|
button.removeEventListener("click", onAddDocToSidebar);
|
|
196
|
+
wrapper.remove();
|
|
81
197
|
};
|
|
82
198
|
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { Repo, initSubduction } from "@automerge/automerge-repo";
|
|
3
|
+
|
|
4
|
+
beforeAll(() => initSubduction());
|
|
5
|
+
|
|
6
|
+
vi.mock("@inkandswitch/patchwork-plugins", () => ({
|
|
7
|
+
getRegistry: () => ({
|
|
8
|
+
get: () => ({ module: { getTitle: (doc) => doc.title } }),
|
|
9
|
+
load: () => Promise.resolve(),
|
|
10
|
+
}),
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
const { default: render, putAtTop, ADD_TO_SIDEBAR_EVENT } = await import(
|
|
14
|
+
"./button.js"
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
const flush = () => new Promise((resolve) => setTimeout(resolve, 0));
|
|
18
|
+
|
|
19
|
+
describe("putAtTop", () => {
|
|
20
|
+
const a = { url: "automerge:a", name: "A", type: "t" };
|
|
21
|
+
const b = { url: "automerge:b", name: "B", type: "t" };
|
|
22
|
+
|
|
23
|
+
it("adds a new doc first", () => {
|
|
24
|
+
const folder = { docs: [a] };
|
|
25
|
+
putAtTop(folder, b);
|
|
26
|
+
expect(folder.docs.map((d) => d.url)).toEqual([b.url, a.url]);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("lifts a doc that's already there instead of adding it twice", () => {
|
|
30
|
+
const folder = { docs: [a, { ...b, name: "kept" }] };
|
|
31
|
+
putAtTop(folder, b);
|
|
32
|
+
expect(folder.docs).toEqual([{ ...b, name: "kept" }, a]);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("makes the list if the folder has none", () => {
|
|
36
|
+
const folder = {};
|
|
37
|
+
putAtTop(folder, a);
|
|
38
|
+
expect(folder.docs).toEqual([a]);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
describe("the button", () => {
|
|
43
|
+
let repo, doc, root, account, host, cleanup;
|
|
44
|
+
|
|
45
|
+
beforeEach(() => {
|
|
46
|
+
repo = new Repo();
|
|
47
|
+
root = repo.create({ docs: [{ url: "automerge:x", name: "X", type: "t" }] });
|
|
48
|
+
account = repo.create({ rootFolderUrl: root.url });
|
|
49
|
+
doc = repo.create({ "@patchwork": { type: "essay" }, title: "My essay" });
|
|
50
|
+
host = document.createElement("patchwork-view");
|
|
51
|
+
host.setAttribute("doc-url", doc.url);
|
|
52
|
+
document.body.appendChild(host);
|
|
53
|
+
window.repo = repo;
|
|
54
|
+
window.accountDocHandle = account;
|
|
55
|
+
cleanup = render(doc, host);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
afterEach(() => {
|
|
59
|
+
cleanup();
|
|
60
|
+
host.remove();
|
|
61
|
+
delete window.repo;
|
|
62
|
+
delete window.accountDocHandle;
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const click = () => host.querySelector("button").click();
|
|
66
|
+
|
|
67
|
+
it("lets a frame that claims the event do the adding", async () => {
|
|
68
|
+
const seen = [];
|
|
69
|
+
let done;
|
|
70
|
+
const claim = (event) => {
|
|
71
|
+
event.preventDefault();
|
|
72
|
+
seen.push({ ...event.detail });
|
|
73
|
+
event.detail.respondWith(new Promise((resolve) => (done = resolve)));
|
|
74
|
+
};
|
|
75
|
+
document.body.addEventListener(ADD_TO_SIDEBAR_EVENT, claim);
|
|
76
|
+
click();
|
|
77
|
+
document.body.removeEventListener(ADD_TO_SIDEBAR_EVENT, claim);
|
|
78
|
+
|
|
79
|
+
expect(seen[0]).toMatchObject({
|
|
80
|
+
url: doc.url,
|
|
81
|
+
name: "My essay",
|
|
82
|
+
type: "essay",
|
|
83
|
+
});
|
|
84
|
+
done();
|
|
85
|
+
await flush();
|
|
86
|
+
expect(host.querySelector("button").textContent).toBe("Added ✓");
|
|
87
|
+
expect(root.doc().docs).toHaveLength(1);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it("adds to the top of the root folder itself when nobody claims it", async () => {
|
|
91
|
+
click();
|
|
92
|
+
await flush();
|
|
93
|
+
await flush();
|
|
94
|
+
expect(root.doc().docs.map((d) => d.url)).toEqual([doc.url, "automerge:x"]);
|
|
95
|
+
expect(root.doc().docs[0]).toEqual({
|
|
96
|
+
url: doc.url,
|
|
97
|
+
name: "My essay",
|
|
98
|
+
type: "essay",
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("finds the account on window.patchwork when that's all there is", async () => {
|
|
103
|
+
delete window.accountDocHandle;
|
|
104
|
+
window.patchwork = { account, repo };
|
|
105
|
+
try {
|
|
106
|
+
click();
|
|
107
|
+
await flush();
|
|
108
|
+
await flush();
|
|
109
|
+
expect(root.doc().docs[0].url).toBe(doc.url);
|
|
110
|
+
} finally {
|
|
111
|
+
delete window.patchwork;
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as H,b as de,c as M,d as R}from"./chunk-YERFWP5I.js";import{a as Ie,b as B,c as j,d as te,e as re,f as oe,g as ne,h as ie,i as ae,j as le,k as se,l as O,m as P,n as W,o as ce,p as ue,q as me,r as fe}from"./chunk-U4IJVHXK.js";import{b as Le}from"./chunk-FW4363Y4.js";import{template as _}from"solid-js/web";import{delegateEvents as nt}from"solid-js/web";import{memo as it}from"solid-js/web";import{setStyleProperty as at}from"solid-js/web";import{setAttribute as Y}from"solid-js/web";import{effect as I}from"solid-js/web";import{getOwner as k}from"solid-js/web";import{use as T}from"solid-js/web";import{insert as v}from"solid-js/web";import{createComponent as m}from"solid-js/web";import"@inkandswitch/patchwork-elements";import{subscribe as wt}from"@inkandswitch/patchwork-providers";import{template as q}from"solid-js/web";import{delegateEvents as Ae}from"solid-js/web";import{memo as xe}from"solid-js/web";import{insert as pe}from"solid-js/web";import{createComponent as L}from"solid-js/web";import{For as We,Show as z}from"solid-js";var Fe=q("<div class=threepane-widgets>"),Oe=q("<div class=threepane-widgets__empty><button type=button class=threepane-widgets__add>\uFF0B Add document list"),Pe=q("<div class=threepane-widget>");function he(e){let i=()=>{let o=e.rootFolderUrl(),n=e.configHandle();!o||!n||n.change(r=>{r.sidebar.widgets.push([M,o])})};return(()=>{var o=Fe();return pe(o,L(z,{get when(){return e.ready()},get children(){return L(z,{get when(){return e.widgets().length},get fallback(){return L(z,{get when(){return xe(()=>!!e.rootFolderUrl())()&&e.configHandle()},get children(){var n=Oe(),r=n.firstChild;return r.$$click=i,n}})},get children(){return L(We,{get each(){return e.widgets()},children:n=>(()=>{var r=Pe();return pe(r,L(W,{slot:n})),r})()})}})}})),o})()}Ae(["click"]);import{template as we}from"solid-js/web";import{setAttribute as He}from"solid-js/web";import{effect as Me}from"solid-js/web";import{insert as ge}from"solid-js/web";import{createComponent as K}from"solid-js/web";import{For as Be,Show as je}from"solid-js";var Ne=we("<div class=frame-tray>"),Ve=we("<div class=frame-tray__item>");function ve(e){return K(je,{get when(){return e.slots().length},get children(){var i=Ne();return ge(i,K(Be,{get each(){return P(e.slots())},children:o=>(()=>{var n=Ve();return ge(n,K(W,{slot:o})),Me(()=>He(n,"data-tray-id",O(o))),n})()})),i}})}import{createEffect as V,createMemo as vt,createSignal as b,onCleanup as C,onMount as Ce,Show as S}from"solid-js";import{render as _t}from"solid-js/web";import{createDocOfDatatype2 as qe}from"@inkandswitch/patchwork-plugins";import{getRegistry as ze}from"@inkandswitch/patchwork-plugins";function N(e){return ze("patchwork:datatype").loadWhenReady(e)}var Ke=new Set(["document-title","spacer"]);function _e(e){return e?[[M,e]]:[]}function Ge(e,i){if(!((e.version??0)>=1)){if(e.sidebar||(e.sidebar={widgets:[]}),i&&!e.sidebar.widgets?.length&&(e.sidebar.widgets=_e(i)),!e.tray)e.tray=H.slice();else{let o=P(e.tray);o.length!==e.tray.length&&(e.tray=o);let n=new Set(e.tray.map(r=>O(r)));for(let r of H)n.has(r)||(e.tray.push(r),n.add(r))}e.doctitle?.tools?.length||(e.doctitle={...e.doctitle,tools:de.slice()}),!(!e.sidebar.widgets?.length&&!i)&&(e.version=1)}}async function ye(e,i){let o=e.doc()?.rootFolderUrl,n=e.doc()?.tools?.threepane;if(n){let l=await i.find(n);if((l.doc()?.version??0)>=1)return;l.change(d=>Ge(d,o));return}let r=await N("threepane:config");if(!r){console.warn("frame: threepane:config datatype never registered");return}if(e.doc()?.tools?.threepane)return;let t=e.doc(),a=(t?.documentToolbarToolIds??[]).filter(l=>!Ke.has(l)),s=await qe(r,i);s.change(l=>{a.length&&(l.doctitle.tools=a),l.sidebar.widgets=_e(t?.rootFolderUrl),l.tray||(l.tray=H.slice()),t?.rootFolderUrl?l.version=1:delete l.version}),e.change(l=>{l.tools||(l.tools={}),l.tools.threepane||(l.tools.threepane=s.url)})}var Se=Le(Ie(),1);import{createDocOfDatatype2 as Ye}from"@inkandswitch/patchwork-plugins";var g=(0,Se.default)("patchwork:threepane:examples");async function $e(e,i){let o=e.doc();if(!o?.rootFolderUrl){g("skipped \u2014 account has no rootFolderUrl");return}if(o.exampleDocsSeededAt){g("skipped \u2014 already ran for this account at",new Date(o.exampleDocsSeededAt).toISOString());return}g("claiming marker on account",e.url),e.change(u=>{u.exampleDocsSeededAt||(u.exampleDocsSeededAt=Date.now())});let n=await i.find(o.rootFolderUrl),r=n.doc()?.docs?.length??0;if(r){g(`skipped \u2014 root folder already has ${r} doc(s); only fresh accounts are seeded`);return}let t=window.location.hostname.includes("gaios"),a=t?[]:await Je();if(g(t?"gaios examples":"bundle init scripts:",a),!t&&!a.length){g("skipped \u2014 no static module bundles to ask");return}let s=await N("folder");if(!s){g("folder datatype never registered; giving up");return}let l=await Ye(s,i,u=>{u.title="Examples"});if(t){let{seedGaiosExamples:u}=await import("./gaiosExamples-YDNQB35L.js");await u(i,l)}for(let u of a)try{await(await import(u)).default?.(i,l),g("ran init script",u)}catch(c){g("init script unavailable or failed",u,c)}let d=l.doc()?.docs?.length??0;if(!d){g("no bundle contributed any documents");return}n.change(u=>{u.docs.unshift({name:"Examples",type:"folder",url:l.url})}),g(`seeded ${d} document(s) into Examples folder`,l.url)}var be="https://patchwork-tools.netlify.app/init.js",De="https://patchwork-base.netlify.app/init.js";function Xe(){return document.documentElement.getAttribute("data-examples")==="site"}async function Je(){let e=Xe(),i=window.patchwork?.packages;if(!i?.urls)return e?[]:[De,be];await i.doneLoading;let o=Object.values(i.urls).filter(r=>typeof r=="string"&&!r.startsWith("automerge:")).map(r=>new URL("init.js",new URL(r,document.baseURI)).href);if(e)return[...new Set(o)];let n=o.length?[]:[De];return[...new Set([...o,...n,be])]}var ke="patchwork:add-to-sidebar";function Qe(e,i){e.docs||(e.docs=[]);let o=e.docs,n=o.findIndex(r=>r.url===i.url);if(n!==0){if(n>0){let{name:r,type:t}=o[n];o.splice(n,1),o.unshift({url:i.url,name:r,type:t});return}o.unshift({url:i.url,name:i.name,type:i.type})}}function Ze(e,i){return new Promise(o=>{let n=()=>{let r=e.doc(),t=r&&i(r);t&&(e.off("change",n),o(t))};e.on("change",n),n()})}function Te(e,i,o){let n=r=>{let t=r.detail;if(!t?.url)return;r.preventDefault(),r.stopPropagation();let a=(async()=>{let s=await Ze(o,d=>d.rootFolderUrl);(await i.find(s)).change(d=>Qe(d,{url:t.url,name:t.name||"Untitled",type:t.type||"unknown"}))})();a.catch(s=>console.error("threepane: couldn't add to sidebar",s)),t.respondWith?.(a)};return e.addEventListener(ke,n),()=>e.removeEventListener(ke,n)}import{createEffect as et,createMemo as tt,createSignal as rt,onCleanup as ot}from"solid-js";function G(e){let[i,o]=rt(0);return et(()=>{let n=e();if(!n)return;let r=()=>o(t=>t+1);n.on("change",r),ot(()=>n.off("change",r))}),tt(()=>(i(),e()?.doc()))}var lt=_("<div class=frame-shell><aside class=frame-warning-banner>research grade software. do not share links. sharing a doc is sharing your account.</aside><div class=frame><patchwork-view component=patchwork-selected-doc-provider><patchwork-view component=patchwork-account-provider><patchwork-view component=patchwork-tool-storage-provider><patchwork-view component=patchwork-worker-provider>",!0,!1,!1),st=_("<div style=display:contents>"),dt=_("<div class=main-area>"),ct=_("<div class=frame__popover-backdrop><div class=frame__popover role=dialog aria-modal=true><div class=frame__popover-toolbar><patchwork-view tool-id=doc-openwith></patchwork-view></div><div class=frame__popover-body><patchwork-view>",!0,!1,!1),ut=_('<button type=button class="frame__sidebar-toggle frame__left-toggle">'),mt=_("<div class=threepane-sidebar><div class=threepane-sidebar__footer><footer class=threepane-account-bar><button type=button class=threepane-account-bar__button>Settings"),ft=_("<div class=frame__tray-dock>"),pt=_('<button type=button class="threepane-account-bar__button threepane-account-bar__avatar"title=Account aria-label=Account><patchwork-view tool-id=contact-avatar>',!0,!1,!1),ht=_("<button type=button class=threepane-account-bar__button>Packages"),gt=_('<svg xmlns=http://www.w3.org/2000/svg width=18 height=18 viewBox="0 0 24 24"fill=none stroke=var(--studio-chrome-line) stroke-width=1.75 stroke-linecap=round stroke-linejoin=round><rect width=18 height=18 x=3 y=3 rx=2></rect><path d="M9 3v18">'),X=(e,i)=>{let[o,n]=b(!1);return V(()=>{let r=i();if(!r)return;n(!1);let t=a=>{a.detail?.componentId===e&&n(!0)};r.addEventListener("patchwork:mounted",t),C(()=>r.removeEventListener("patchwork:mounted",t))}),o};function J(e,i){e.dispatchEvent(new CustomEvent("patchwork:open-document",{detail:i,bubbles:!0,composed:!0}))}function yt({handle:e,repo:i,...o}){me();let n=e.url,[r,t]=b(),a=X("patchwork-account-provider",r),[s,l]=b(),d=X("patchwork-tool-storage-provider",s),[u,c]=b(),p=X("patchwork-selected-doc-provider",u),f=vt(()=>p()&&a()&&d());return(()=>{var w=lt(),E=w.firstChild,Q=E.firstChild,A=E.nextSibling,h=A.firstChild,D=h.firstChild,$=D.firstChild,U=$.firstChild;return v(E,m(S,{get when(){return o.isolation},get children(){return[" ","isolation is highly experimental. if things are broken, switch back to wild west."]}}),null),T(c,h),h._$owner=k(),T(t,D),D.docUrl=n,D._$owner=k(),T(l,$),$.docUrl=n,$._$owner=k(),U._$owner=k(),v(U,m(S,{get when(){return f()},get children(){return m(bt,{handle:e,repo:i,get isolation(){return o.isolation}})}})),w})()}function bt(e){let i=B(()=>e.handle.url,{repo:e.repo});(async()=>{await ye(e.handle,e.repo),await $e(e.handle,e.repo)})().catch(y=>{console.error("frame: account bootstrap failed",y)});let o=G(i),n=e.handle.url,r=()=>o()?.tools?.threepane,t=B(()=>r(),{repo:e.repo}),a=G(t),s=()=>a()?.doctitle?.tools,l=()=>a()?.sidebar?.widgets??[],d=()=>a()?.tray??[],u=()=>o()?.rootFolderUrl,c=ie(),p=ae("left",{isCollapsed:c.isSidebarCollapsed,setCollapsed:c.setIsSidebarCollapsed,setWidth:c.setLeftSidebarWidth}),f,[w,E]=b(null),[Q,A]=b(null);Ce(()=>{let y=wt(f,{type:"patchwork:selected-view"},x=>E(x));C(y),C(Te(f,e.repo,e.handle))});let h=()=>w()?.url,D=()=>w()?.toolId??void 0,$=()=>oe(j.rightWidth,re),U=()=>ne(j.rightCollapsed),[Ee,Z]=b(),Ue=le(Ee,h),[ee,Re]=b(!1);return V(()=>{ee()||(e.isolation||!h()||Ue())&&Re(!0)}),(()=>{var y=st(),x=f;return typeof x=="function"?T(x,y):f=y,v(y,m(St,{accountDocUrl:n,sidebarState:c,sidebarResize:p,sidebarWidgets:l,traySlots:d,configHandle:t,rootFolderUrl:u,widgetsReady:ee,contactUrl:()=>o()?.contactUrl,moduleSettingsUrl:()=>o()?.moduleSettingsUrl,get isolation(){return e.isolation},onInterceptOpen:A,get children(){return m(S,{get when(){return h()},get fallback(){return(()=>{var F=dt();return v(F,m(ce,{viewKey:h,selectedDocUrl:h,toolId:D,ref:Z})),F})()},get children(){return m(S,{get when(){return e.isolation},get fallback(){return m(ue,{setMainDocElement:Z,selectedDocUrl:h,selectedToolId:D,doctitleSlots:s,get isLeftCollapsed(){return c.isSidebarCollapsed},initialRightWidth:$,initialRightCollapsed:U})},get children(){return m(fe,{get contactUrl(){return o()?.contactUrl},selectedDocUrl:h,selectedToolId:D,doctitleSlots:s,get isLeftCollapsed(){return c.isSidebarCollapsed},initialRightWidth:$,initialRightCollapsed:U})}})}})}}),null),v(y,m(S,{get when(){return Q()},children:F=>m(Dt,{get view(){return F()},onClose:()=>A(null)})}),null),y})()}function Dt(e){let[i,o]=b(e.view.toolId??void 0);V(()=>o(e.view.toolId??void 0));let n;return Ce(()=>{let r=s=>{s.key==="Escape"&&e.onClose()};window.addEventListener("keydown",r),C(()=>window.removeEventListener("keydown",r));let t=n;if(!t)return;let a=s=>{let{url:l,toolId:d}=s.detail;l&&(s.stopPropagation(),o(d??void 0))};t.addEventListener("patchwork:open-document",a),C(()=>t.removeEventListener("patchwork:open-document",a))}),(()=>{var r=ct(),t=r.firstChild,a=t.firstChild,s=a.firstChild,l=a.nextSibling,d=l.firstChild;r.$$click=()=>e.onClose(),t.$$click=c=>c.stopPropagation();var u=n;return typeof u=="function"?T(u,t):n=t,s._$owner=k(),d._$owner=k(),I(c=>{var p=e.view.url,f=e.view.url,w=i();return p!==c.e&&(s.docUrl=c.e=p),f!==c.t&&(d.docUrl=c.t=f),w!==c.a&&(d.toolId=c.a=w),c},{e:void 0,t:void 0,a:void 0}),r})()}function St(e){let i=e.sidebarState.isSidebarCollapsed,o=()=>e.traySlots().length>0,n,r;return V(()=>{if(i())return;let t=n;if(!t)return;let a=r,s=l=>{let{url:d,toolId:u}=l.detail;if(e.isolation&&d&&a&&l.composedPath().includes(a)){l.stopPropagation(),e.onInterceptOpen?.({url:d,toolId:u??null});return}t.getBoundingClientRect().width<=window.innerWidth*.75||(e.sidebarState.setIsSidebarCollapsed(!0),window.dispatchEvent(new CustomEvent(te)))};t.addEventListener("patchwork:open-document",s),C(()=>t.removeEventListener("patchwork:open-document",s))}),[(()=>{var t=ut();return t.$$click=()=>e.sidebarState.setIsSidebarCollapsed(a=>!a),v(t,m($t,{})),I(a=>{var s=i()?"Show sidebar":"Hide sidebar",l=i()?"Show sidebar":"Hide sidebar",d=!i();return s!==a.e&&Y(t,"title",a.e=s),l!==a.t&&Y(t,"aria-label",a.t=l),d!==a.a&&Y(t,"aria-pressed",a.a=d),a},{e:void 0,t:void 0,a:void 0}),t})(),m(se,{side:"left",isCollapsed:i,get width(){return e.sidebarState.leftSidebarWidth},get onMouseDown(){return e.sidebarResize.handleMouseDown},get onToggleClick(){return e.sidebarResize.handleToggleClick},get children(){var t=mt(),a=t.firstChild,s=a.firstChild,l=s.firstChild,d=n;typeof d=="function"?T(d,t):n=t,v(t,m(he,{get widgets(){return e.sidebarWidgets},get configHandle(){return e.configHandle},get rootFolderUrl(){return e.rootFolderUrl},get ready(){return e.widgetsReady}}),a);var u=r;return typeof u=="function"?T(u,a):r=a,v(s,m(S,{get when(){return e.contactUrl()},children:c=>(()=>{var p=pt(),f=p.firstChild;return p.$$click=w=>J(w.currentTarget,{url:e.accountDocUrl,toolId:"account-picker"}),f._$owner=k(),I(()=>f.docUrl=c()),p})()}),l),v(s,m(S,{get when(){return e.moduleSettingsUrl()},children:c=>(()=>{var p=ht();return p.$$click=f=>J(f.currentTarget,{url:c(),toolId:"packages"}),p})()}),l),l.$$click=c=>J(c.currentTarget,{url:e.accountDocUrl,toolId:"frame-configurator"}),I(()=>t.classList.toggle("threepane-sidebar--has-tray",!!o())),t}}),m(S,{get when(){return o()},get children(){var t=ft();return v(t,m(ve,{get slots(){return e.traySlots}})),I(a=>{var s=!!i(),l=`${e.sidebarState.leftSidebarWidth()}px`;return s!==a.e&&t.classList.toggle("frame__tray-dock--collapsed",a.e=s),l!==a.t&&at(t,"width",a.t=l),a},{e:void 0,t:void 0}),t}}),it(()=>e.children)]}function $t(){return gt()}function Er(e){return(i,o)=>_t(()=>m(yt,{handle:i,get repo(){return o.repo},isolation:e}),o)}nt(["click"]);export{St as FrameLayout,yt as PatchworkFrame,Er as renderPatchworkFrame};
|
|
2
|
+
//# sourceMappingURL=PatchworkFrame-22UEOQ6E.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/PatchworkFrame.tsx", "../src/components/SidebarWidgets.tsx", "../src/components/Tray.tsx", "../src/account/ensureThreepaneConfig.ts", "../src/account/loadDatatypeWhenReady.ts", "../src/account/seedExampleDocuments.ts", "../src/account/addToSidebar.ts", "../src/hooks/useHandleDoc.ts"],
|
|
4
|
+
"sourcesContent": ["import { template as _$template } from \"solid-js/web\";\nimport { delegateEvents as _$delegateEvents } from \"solid-js/web\";\nimport { memo as _$memo } from \"solid-js/web\";\nimport { setStyleProperty as _$setStyleProperty } from \"solid-js/web\";\nimport { setAttribute as _$setAttribute } from \"solid-js/web\";\nimport { effect as _$effect } from \"solid-js/web\";\nimport { getOwner as _$getOwner } from \"solid-js/web\";\nimport { use as _$use } from \"solid-js/web\";\nimport { insert as _$insert } from \"solid-js/web\";\nimport { createComponent as _$createComponent } from \"solid-js/web\";\nvar _tmpl$ = /*#__PURE__*/_$template(`<div class=frame-shell><aside class=frame-warning-banner>research grade software. do not share links. sharing a doc is sharing your account.</aside><div class=frame><patchwork-view component=patchwork-selected-doc-provider><patchwork-view component=patchwork-account-provider><patchwork-view component=patchwork-tool-storage-provider><patchwork-view component=patchwork-worker-provider>`, true, false, false),\n _tmpl$2 = /*#__PURE__*/_$template(`<div style=display:contents>`),\n _tmpl$3 = /*#__PURE__*/_$template(`<div class=main-area>`),\n _tmpl$4 = /*#__PURE__*/_$template(`<div class=frame__popover-backdrop><div class=frame__popover role=dialog aria-modal=true><div class=frame__popover-toolbar><patchwork-view tool-id=doc-openwith></patchwork-view></div><div class=frame__popover-body><patchwork-view>`, true, false, false),\n _tmpl$5 = /*#__PURE__*/_$template(`<button type=button class=\"frame__sidebar-toggle frame__left-toggle\">`),\n _tmpl$6 = /*#__PURE__*/_$template(`<div class=threepane-sidebar><div class=threepane-sidebar__footer><footer class=threepane-account-bar><button type=button class=threepane-account-bar__button>Settings`),\n _tmpl$7 = /*#__PURE__*/_$template(`<div class=frame__tray-dock>`),\n _tmpl$8 = /*#__PURE__*/_$template(`<button type=button class=\"threepane-account-bar__button threepane-account-bar__avatar\"title=Account aria-label=Account><patchwork-view tool-id=contact-avatar>`, true, false, false),\n _tmpl$9 = /*#__PURE__*/_$template(`<button type=button class=threepane-account-bar__button>Packages`),\n _tmpl$0 = /*#__PURE__*/_$template(`<svg xmlns=http://www.w3.org/2000/svg width=18 height=18 viewBox=\"0 0 24 24\"fill=none stroke=var(--studio-chrome-line) stroke-width=1.75 stroke-linecap=round stroke-linejoin=round><rect width=18 height=18 x=3 y=3 rx=2></rect><path d=\"M9 3v18\">`);\nimport \"@inkandswitch/patchwork-elements\";\nimport { useDocHandle } from \"solid-automerge\";\nimport { subscribe } from \"@inkandswitch/patchwork-providers\";\nimport { useSidebarState, useSidebarResize, useMainDocMounted, SIDEBAR_KEYS, COLLAPSE_CONTEXT_SIDEBAR_EVENT, getStoredNumber, getStoredBoolean, DEFAULT_SIDEBAR_WIDTH } from \"./hooks\";\nimport { Sidebar } from \"./components/Sidebar\";\nimport { SidebarWidgets } from \"./components/SidebarWidgets\";\nimport { DocumentAreaRoot } from \"./components/DocumentAreaRoot\";\nimport { IsolatedDocumentArea } from \"./components/IsolatedDocumentArea\";\nimport { MainDocumentView } from \"./components/MainDocumentView\";\nimport { Tray } from \"./components/Tray\";\nimport { createEffect, createMemo, createSignal, onCleanup, onMount, Show } from \"solid-js\";\nimport { render } from \"solid-js/web\";\nimport { ensureThreepaneConfig } from \"./account/ensureThreepaneConfig\";\nimport { seedExampleDocuments } from \"./account/seedExampleDocuments\";\nimport { handleAddToSidebar } from \"./account/addToSidebar\";\nimport { ensureFrameStyles } from \"./ensureFrameStyles\";\nimport { useHandleDoc } from \"./hooks/useHandleDoc\";\nconst useFrameProviderReady = (componentId, element) => {\n const [isReady, setReady] = createSignal(false);\n createEffect(() => {\n const el = element();\n if (!el) return;\n setReady(false);\n const onMounted = event => {\n const detail = event.detail;\n if (detail?.componentId !== componentId) return;\n setReady(true);\n };\n el.addEventListener(\"patchwork:mounted\", onMounted);\n onCleanup(() => el.removeEventListener(\"patchwork:mounted\", onMounted));\n });\n return isReady;\n};\nfunction dispatchOpen(el, detail) {\n el.dispatchEvent(new CustomEvent(\"patchwork:open-document\", {\n detail,\n bubbles: true,\n composed: true\n }));\n}\nexport function PatchworkFrame({\n handle,\n repo,\n ...props\n}) {\n ensureFrameStyles();\n const accountDocUrl = handle.url;\n const [accountProviderElement, setAccountProviderElement] = createSignal();\n const isAccountProviderReady = useFrameProviderReady(\"patchwork-account-provider\", accountProviderElement);\n const [toolStorageProviderElement, setToolStorageProviderElement] = createSignal();\n const isToolStorageProviderReady = useFrameProviderReady(\"patchwork-tool-storage-provider\", toolStorageProviderElement);\n const [selectedDocProviderElement, setSelectedDocProviderElement] = createSignal();\n const isSelectedDocProviderReady = useFrameProviderReady(\"patchwork-selected-doc-provider\", selectedDocProviderElement);\n const areProvidersReady = createMemo(() => isSelectedDocProviderReady() && isAccountProviderReady() && isToolStorageProviderReady());\n return (() => {\n var _el$ = _tmpl$(),\n _el$2 = _el$.firstChild,\n _el$3 = _el$2.firstChild,\n _el$4 = _el$2.nextSibling,\n _el$5 = _el$4.firstChild,\n _el$6 = _el$5.firstChild,\n _el$7 = _el$6.firstChild,\n _el$8 = _el$7.firstChild;\n _$insert(_el$2, _$createComponent(Show, {\n get when() {\n return props.isolation;\n },\n get children() {\n return [\" \", \"isolation is highly experimental. if things are broken, switch back to wild west.\"];\n }\n }), null);\n _$use(setSelectedDocProviderElement, _el$5);\n _el$5._$owner = _$getOwner();\n _$use(setAccountProviderElement, _el$6);\n _el$6.docUrl = accountDocUrl;\n _el$6._$owner = _$getOwner();\n _$use(setToolStorageProviderElement, _el$7);\n _el$7.docUrl = accountDocUrl;\n _el$7._$owner = _$getOwner();\n _el$8._$owner = _$getOwner();\n _$insert(_el$8, _$createComponent(Show, {\n get when() {\n return areProvidersReady();\n },\n get children() {\n return _$createComponent(PatchworkFrameInner, {\n handle: handle,\n repo: repo,\n get isolation() {\n return props.isolation;\n }\n });\n }\n }));\n return _el$;\n })();\n}\nfunction PatchworkFrameInner(props) {\n const accountDocHandle = useDocHandle(() => props.handle.url, {\n repo: props.repo\n });\n void (async () => {\n await ensureThreepaneConfig(props.handle, props.repo);\n await seedExampleDocuments(props.handle, props.repo);\n })().catch(err => {\n console.error(\"frame: account bootstrap failed\", err);\n });\n const accountDoc = useHandleDoc(accountDocHandle);\n const accountDocUrl = props.handle.url;\n const threepaneUrl = () => accountDoc()?.tools?.[\"threepane\"];\n const threepaneConfigHandle = useDocHandle(() => threepaneUrl(), {\n repo: props.repo\n });\n const threepaneConfig = useHandleDoc(threepaneConfigHandle);\n const doctitleSlots = () => threepaneConfig()?.doctitle?.tools;\n const sidebarWidgets = () => threepaneConfig()?.sidebar?.widgets ?? [];\n const traySlots = () => threepaneConfig()?.tray ?? [];\n const rootFolderUrl = () => accountDoc()?.rootFolderUrl;\n const sidebarState = useSidebarState();\n const sidebarResize = useSidebarResize(\"left\", {\n isCollapsed: sidebarState.isSidebarCollapsed,\n setCollapsed: sidebarState.setIsSidebarCollapsed,\n setWidth: sidebarState.setLeftSidebarWidth\n });\n let element;\n const [selectedView, setSelectedView] = createSignal(null);\n const [popoverView, setPopoverView] = createSignal(null);\n onMount(() => {\n const unsubscribeSelectedView = subscribe(element, {\n type: \"patchwork:selected-view\"\n }, view => setSelectedView(view));\n onCleanup(unsubscribeSelectedView);\n onCleanup(handleAddToSidebar(element, props.repo, props.handle));\n });\n const selectedDocUrl = () => selectedView()?.url;\n const selectedToolId = () => selectedView()?.toolId ?? void 0;\n const initialRightWidth = () => getStoredNumber(SIDEBAR_KEYS.rightWidth, DEFAULT_SIDEBAR_WIDTH);\n const initialRightCollapsed = () => getStoredBoolean(SIDEBAR_KEYS.rightCollapsed);\n const [mainDocElement, setMainDocElement] = createSignal();\n const isMainDocMounted = useMainDocMounted(mainDocElement, selectedDocUrl);\n const [widgetsReady, setWidgetsReady] = createSignal(false);\n createEffect(() => {\n if (widgetsReady()) return;\n if (props.isolation || !selectedDocUrl() || isMainDocMounted()) setWidgetsReady(true);\n });\n return (() => {\n var _el$9 = _tmpl$2();\n var _ref$ = element;\n typeof _ref$ === \"function\" ? _$use(_ref$, _el$9) : element = _el$9;\n _$insert(_el$9, _$createComponent(FrameLayout, {\n accountDocUrl: accountDocUrl,\n sidebarState: sidebarState,\n sidebarResize: sidebarResize,\n sidebarWidgets: sidebarWidgets,\n traySlots: traySlots,\n configHandle: threepaneConfigHandle,\n rootFolderUrl: rootFolderUrl,\n widgetsReady: widgetsReady,\n contactUrl: () => accountDoc()?.contactUrl,\n moduleSettingsUrl: () => accountDoc()?.moduleSettingsUrl,\n get isolation() {\n return props.isolation;\n },\n onInterceptOpen: setPopoverView,\n get children() {\n return _$createComponent(Show, {\n get when() {\n return selectedDocUrl();\n },\n get fallback() {\n return (() => {\n var _el$0 = _tmpl$3();\n _$insert(_el$0, _$createComponent(MainDocumentView, {\n viewKey: selectedDocUrl,\n selectedDocUrl: selectedDocUrl,\n toolId: selectedToolId,\n ref: setMainDocElement\n }));\n return _el$0;\n })();\n },\n get children() {\n return _$createComponent(Show, {\n get when() {\n return props.isolation;\n },\n get fallback() {\n return _$createComponent(DocumentAreaRoot, {\n setMainDocElement: setMainDocElement,\n selectedDocUrl: selectedDocUrl,\n selectedToolId: selectedToolId,\n doctitleSlots: doctitleSlots,\n get isLeftCollapsed() {\n return sidebarState.isSidebarCollapsed;\n },\n initialRightWidth: initialRightWidth,\n initialRightCollapsed: initialRightCollapsed\n });\n },\n get children() {\n return _$createComponent(IsolatedDocumentArea, {\n get contactUrl() {\n return accountDoc()?.contactUrl;\n },\n selectedDocUrl: selectedDocUrl,\n selectedToolId: selectedToolId,\n doctitleSlots: doctitleSlots,\n get isLeftCollapsed() {\n return sidebarState.isSidebarCollapsed;\n },\n initialRightWidth: initialRightWidth,\n initialRightCollapsed: initialRightCollapsed\n });\n }\n });\n }\n });\n }\n }), null);\n _$insert(_el$9, _$createComponent(Show, {\n get when() {\n return popoverView();\n },\n children: view => _$createComponent(FramePopover, {\n get view() {\n return view();\n },\n onClose: () => setPopoverView(null)\n })\n }), null);\n return _el$9;\n })();\n}\nfunction FramePopover(props) {\n const [toolId, setToolId] = createSignal(props.view.toolId ?? void 0);\n createEffect(() => setToolId(props.view.toolId ?? void 0));\n let popoverEl;\n onMount(() => {\n const onKey = e => {\n if (e.key === \"Escape\") props.onClose();\n };\n window.addEventListener(\"keydown\", onKey);\n onCleanup(() => window.removeEventListener(\"keydown\", onKey));\n const el = popoverEl;\n if (!el) return;\n const onOpen = event => {\n const {\n url,\n toolId: nextToolId\n } = event.detail;\n if (!url) return;\n event.stopPropagation();\n setToolId(nextToolId ?? void 0);\n };\n el.addEventListener(\"patchwork:open-document\", onOpen);\n onCleanup(() => el.removeEventListener(\"patchwork:open-document\", onOpen));\n });\n return (() => {\n var _el$1 = _tmpl$4(),\n _el$10 = _el$1.firstChild,\n _el$11 = _el$10.firstChild,\n _el$12 = _el$11.firstChild,\n _el$13 = _el$11.nextSibling,\n _el$14 = _el$13.firstChild;\n _el$1.$$click = () => props.onClose();\n _el$10.$$click = e => e.stopPropagation();\n var _ref$2 = popoverEl;\n typeof _ref$2 === \"function\" ? _$use(_ref$2, _el$10) : popoverEl = _el$10;\n _el$12._$owner = _$getOwner();\n _el$14._$owner = _$getOwner();\n _$effect(_p$ => {\n var _v$ = props.view.url,\n _v$2 = props.view.url,\n _v$3 = toolId();\n _v$ !== _p$.e && (_el$12.docUrl = _p$.e = _v$);\n _v$2 !== _p$.t && (_el$14.docUrl = _p$.t = _v$2);\n _v$3 !== _p$.a && (_el$14.toolId = _p$.a = _v$3);\n return _p$;\n }, {\n e: undefined,\n t: undefined,\n a: undefined\n });\n return _el$1;\n })();\n}\nexport function FrameLayout(props) {\n const isCollapsed = props.sidebarState.isSidebarCollapsed;\n const hasTray = () => props.traySlots().length > 0;\n let sidebarContentEl;\n let footerEl;\n createEffect(() => {\n if (isCollapsed()) return;\n const el = sidebarContentEl;\n if (!el) return;\n const footer = footerEl;\n const onOpen = event => {\n const {\n url,\n toolId\n } = event.detail;\n if (props.isolation && url && footer && event.composedPath().includes(footer)) {\n event.stopPropagation();\n props.onInterceptOpen?.({\n url,\n toolId: toolId ?? null\n });\n return;\n }\n if (el.getBoundingClientRect().width <= window.innerWidth * 0.75) return;\n props.sidebarState.setIsSidebarCollapsed(true);\n window.dispatchEvent(new CustomEvent(COLLAPSE_CONTEXT_SIDEBAR_EVENT));\n };\n el.addEventListener(\"patchwork:open-document\", onOpen);\n onCleanup(() => el.removeEventListener(\"patchwork:open-document\", onOpen));\n });\n return [(() => {\n var _el$15 = _tmpl$5();\n _el$15.$$click = () => props.sidebarState.setIsSidebarCollapsed(v => !v);\n _$insert(_el$15, _$createComponent(PanelLeftIcon, {}));\n _$effect(_p$ => {\n var _v$4 = isCollapsed() ? \"Show sidebar\" : \"Hide sidebar\",\n _v$5 = isCollapsed() ? \"Show sidebar\" : \"Hide sidebar\",\n _v$6 = !isCollapsed();\n _v$4 !== _p$.e && _$setAttribute(_el$15, \"title\", _p$.e = _v$4);\n _v$5 !== _p$.t && _$setAttribute(_el$15, \"aria-label\", _p$.t = _v$5);\n _v$6 !== _p$.a && _$setAttribute(_el$15, \"aria-pressed\", _p$.a = _v$6);\n return _p$;\n }, {\n e: undefined,\n t: undefined,\n a: undefined\n });\n return _el$15;\n })(), _$createComponent(Sidebar, {\n side: \"left\",\n isCollapsed: isCollapsed,\n get width() {\n return props.sidebarState.leftSidebarWidth;\n },\n get onMouseDown() {\n return props.sidebarResize.handleMouseDown;\n },\n get onToggleClick() {\n return props.sidebarResize.handleToggleClick;\n },\n get children() {\n var _el$16 = _tmpl$6(),\n _el$17 = _el$16.firstChild,\n _el$18 = _el$17.firstChild,\n _el$19 = _el$18.firstChild;\n var _ref$3 = sidebarContentEl;\n typeof _ref$3 === \"function\" ? _$use(_ref$3, _el$16) : sidebarContentEl = _el$16;\n _$insert(_el$16, _$createComponent(SidebarWidgets, {\n get widgets() {\n return props.sidebarWidgets;\n },\n get configHandle() {\n return props.configHandle;\n },\n get rootFolderUrl() {\n return props.rootFolderUrl;\n },\n get ready() {\n return props.widgetsReady;\n }\n }), _el$17);\n var _ref$4 = footerEl;\n typeof _ref$4 === \"function\" ? _$use(_ref$4, _el$17) : footerEl = _el$17;\n _$insert(_el$18, _$createComponent(Show, {\n get when() {\n return props.contactUrl();\n },\n children: contactUrl => (() => {\n var _el$21 = _tmpl$8(),\n _el$22 = _el$21.firstChild;\n _el$21.$$click = e => dispatchOpen(e.currentTarget, {\n url: props.accountDocUrl,\n toolId: \"account-picker\"\n });\n _el$22._$owner = _$getOwner();\n _$effect(() => _el$22.docUrl = contactUrl());\n return _el$21;\n })()\n }), _el$19);\n _$insert(_el$18, _$createComponent(Show, {\n get when() {\n return props.moduleSettingsUrl();\n },\n children: moduleSettingsUrl => (() => {\n var _el$23 = _tmpl$9();\n _el$23.$$click = e => dispatchOpen(e.currentTarget, {\n url: moduleSettingsUrl(),\n toolId: \"packages\"\n });\n return _el$23;\n })()\n }), _el$19);\n _el$19.$$click = e => dispatchOpen(e.currentTarget, {\n url: props.accountDocUrl,\n toolId: \"frame-configurator\"\n });\n _$effect(() => _el$16.classList.toggle(\"threepane-sidebar--has-tray\", !!hasTray()));\n return _el$16;\n }\n }), _$createComponent(Show, {\n get when() {\n return hasTray();\n },\n get children() {\n var _el$20 = _tmpl$7();\n _$insert(_el$20, _$createComponent(Tray, {\n get slots() {\n return props.traySlots;\n }\n }));\n _$effect(_p$ => {\n var _v$7 = !!isCollapsed(),\n _v$8 = `${props.sidebarState.leftSidebarWidth()}px`;\n _v$7 !== _p$.e && _el$20.classList.toggle(\"frame__tray-dock--collapsed\", _p$.e = _v$7);\n _v$8 !== _p$.t && _$setStyleProperty(_el$20, \"width\", _p$.t = _v$8);\n return _p$;\n }, {\n e: undefined,\n t: undefined\n });\n return _el$20;\n }\n }), _$memo(() => props.children)];\n}\nfunction PanelLeftIcon() {\n return _tmpl$0();\n}\nexport function renderPatchworkFrame(isolation) {\n return (handle, element) => {\n return render(() => _$createComponent(PatchworkFrame, {\n handle: handle,\n get repo() {\n return element.repo;\n },\n isolation: isolation\n }), element);\n };\n}\n_$delegateEvents([\"click\"]);", "import { template as _$template } from \"solid-js/web\";\nimport { delegateEvents as _$delegateEvents } from \"solid-js/web\";\nimport { memo as _$memo } from \"solid-js/web\";\nimport { insert as _$insert } from \"solid-js/web\";\nimport { createComponent as _$createComponent } from \"solid-js/web\";\nvar _tmpl$ = /*#__PURE__*/_$template(`<div class=threepane-widgets>`),\n _tmpl$2 = /*#__PURE__*/_$template(`<div class=threepane-widgets__empty><button type=button class=threepane-widgets__add>\uFF0B Add document list`),\n _tmpl$3 = /*#__PURE__*/_$template(`<div class=threepane-widget>`);\nimport { For, Show } from \"solid-js\";\nimport { SlotView } from \"./SlotView\";\nimport { DOCUMENT_LIST_TOOL } from \"../datatypes\";\nexport function SidebarWidgets(props) {\n const addDocumentList = () => {\n const root = props.rootFolderUrl();\n const handle = props.configHandle();\n if (!root || !handle) return;\n handle.change(doc => {\n doc.sidebar.widgets.push([DOCUMENT_LIST_TOOL, root]);\n });\n };\n return (() => {\n var _el$ = _tmpl$();\n _$insert(_el$, _$createComponent(Show, {\n get when() {\n return props.ready();\n },\n get children() {\n return _$createComponent(Show, {\n get when() {\n return props.widgets().length;\n },\n get fallback() {\n return (// While the config/root folder are still loading we can't add a\n // widget yet \u2014 show nothing rather than a disabled button.\n _$createComponent(Show, {\n get when() {\n return _$memo(() => !!props.rootFolderUrl())() && props.configHandle();\n },\n get children() {\n var _el$2 = _tmpl$2(),\n _el$3 = _el$2.firstChild;\n _el$3.$$click = addDocumentList;\n return _el$2;\n }\n })\n );\n },\n get children() {\n return _$createComponent(For, {\n get each() {\n return props.widgets();\n },\n children: widget => (() => {\n var _el$4 = _tmpl$3();\n _$insert(_el$4, _$createComponent(SlotView, {\n slot: widget\n }));\n return _el$4;\n })()\n });\n }\n });\n }\n }));\n return _el$;\n })();\n}\n_$delegateEvents([\"click\"]);", "import { template as _$template } from \"solid-js/web\";\nimport { setAttribute as _$setAttribute } from \"solid-js/web\";\nimport { effect as _$effect } from \"solid-js/web\";\nimport { insert as _$insert } from \"solid-js/web\";\nimport { createComponent as _$createComponent } from \"solid-js/web\";\nvar _tmpl$ = /*#__PURE__*/_$template(`<div class=frame-tray>`),\n _tmpl$2 = /*#__PURE__*/_$template(`<div class=frame-tray__item>`);\nimport { For, Show } from \"solid-js\";\nimport { SlotView, slotId, uniqueSlots } from \"./SlotView\";\nexport function Tray(props) {\n return _$createComponent(Show, {\n get when() {\n return props.slots().length;\n },\n get children() {\n var _el$ = _tmpl$();\n _$insert(_el$, _$createComponent(For, {\n get each() {\n return uniqueSlots(props.slots());\n },\n children: slot => (() => {\n var _el$2 = _tmpl$2();\n _$insert(_el$2, _$createComponent(SlotView, {\n slot: slot\n }));\n _$effect(() => _$setAttribute(_el$2, \"data-tray-id\", slotId(slot)));\n return _el$2;\n })()\n }));\n return _el$;\n }\n });\n}", "import type { AutomergeUrl, DocHandle, Repo } from \"@automerge/automerge-repo/slim\";\nimport { createDocOfDatatype2 } from \"@inkandswitch/patchwork-plugins\";\nimport type { AccountDoc, ThreepaneConfigDoc, ToolRef, ToolSlot } from \"../types\";\nimport {\n DEFAULT_DOCTITLE_TOOLS,\n DEFAULT_TRAY_TOOLS,\n DOCUMENT_LIST_TOOL,\n THREEPANE_CONFIG_VERSION,\n} from \"../datatypes\";\nimport { loadDatatypeWhenReady } from \"./loadDatatypeWhenReady\";\nimport { slotId, uniqueSlots } from \"../components/SlotView\";\n\n// Title + spacer are intrinsic to the frame's top bar, never configured tools.\nconst INTRINSIC_DOCTITLE_TOOLS = new Set([\"document-title\", \"spacer\"]);\n\n/** The default sidebar widgets for a fresh (or empty) account. */\nfunction defaultSidebarWidgets(rootFolderUrl?: AutomergeUrl): ToolRef[] {\n return rootFolderUrl ? [[DOCUMENT_LIST_TOOL, rootFolderUrl]] : [];\n}\n\n/**\n * Bring a config doc made before versioning up to THREEPANE_CONFIG_VERSION:\n * fill in the default document list, tray and doctitle tools it's missing, and\n * drop duplicate tray slots. Runs once per doc. After that the doc is the\n * person's to edit, and anything they remove stays removed.\n */\nexport function migrateThreepaneConfig(\n doc: ThreepaneConfigDoc,\n rootFolderUrl?: AutomergeUrl\n) {\n if ((doc.version ?? 0) >= THREEPANE_CONFIG_VERSION) return;\n\n if (!doc.sidebar) doc.sidebar = { widgets: [] };\n if (rootFolderUrl && !doc.sidebar.widgets?.length) {\n doc.sidebar.widgets = defaultSidebarWidgets(rootFolderUrl);\n }\n\n if (!doc.tray) {\n doc.tray = DEFAULT_TRAY_TOOLS.slice();\n } else {\n // Append default tray tools the saved tray is missing, like\n // llm-config-tray. slotId compares across the string and tuple forms.\n const unique = uniqueSlots(doc.tray);\n if (unique.length !== doc.tray.length) doc.tray = unique;\n const present = new Set(doc.tray.map((s) => slotId(s)));\n for (const id of DEFAULT_TRAY_TOOLS) {\n if (!present.has(id)) {\n doc.tray.push(id);\n present.add(id);\n }\n }\n }\n\n // A doctitle lane that ended up empty (nothing to migrate from the legacy\n // field) gets the defaults rather than a bare top bar.\n if (!doc.doctitle?.tools?.length) {\n doc.doctitle = { ...doc.doctitle, tools: DEFAULT_DOCTITLE_TOOLS.slice() };\n }\n\n // Can't seed the document list until the account has a root folder, so leave\n // the migration pending and try again on the next mount.\n if (!doc.sidebar.widgets?.length && !rootFolderUrl) return;\n\n doc.version = THREEPANE_CONFIG_VERSION;\n}\n\n/**\n * Lazily create the threepane layout config doc and point `account.tools.threepane`\n * at it, migrating the legacy `account.documentToolbarToolIds` into its\n * `doctitle` lane and seeding the sidebar with a document list pinned to the\n * account's root folder.\n *\n * Defaults are written only when the config doc is created, or once when an\n * older doc is migrated (see `migrateThreepaneConfig`), never on every mount.\n *\n * Non-destructive: the old `documentToolbarToolIds` / `accountSidebarToolId`\n * fields are left untouched so older builds keep working. Run the (separate,\n * opt-in) cleanupLegacyAccountFields script to remove them later.\n */\nexport async function ensureThreepaneConfig(\n accountHandle: DocHandle<AccountDoc>,\n repo: Repo\n) {\n const rootFolderUrl = accountHandle.doc()?.rootFolderUrl;\n const existingConfigUrl = accountHandle.doc()?.tools?.[\"threepane\"];\n\n if (existingConfigUrl) {\n const configHandle = await repo.find<ThreepaneConfigDoc>(existingConfigUrl);\n if ((configHandle.doc()?.version ?? 0) >= THREEPANE_CONFIG_VERSION) return;\n configHandle.change((doc) => migrateThreepaneConfig(doc, rootFolderUrl));\n return;\n }\n\n const datatype = await loadDatatypeWhenReady<ThreepaneConfigDoc>(\n \"threepane:config\"\n );\n if (!datatype) {\n console.warn(\"frame: threepane:config datatype never registered\");\n return;\n }\n\n // Re-check after the await in case another tab migrated concurrently.\n if (accountHandle.doc()?.tools?.[\"threepane\"]) return;\n\n const account = accountHandle.doc();\n\n // doctitle tools migrate as bare ids: the frame always points them at the\n // selected main-view doc, so a slot tuple's docid would be ignored \u2014 keep\n // them as plain strings.\n const doctitleTools: ToolSlot[] = (account?.documentToolbarToolIds ?? [])\n .filter((id) => !INTRINSIC_DOCTITLE_TOOLS.has(id));\n\n const configHandle = await createDocOfDatatype2<ThreepaneConfigDoc>(\n datatype,\n repo\n );\n configHandle.change((doc) => {\n if (doctitleTools.length) doc.doctitle.tools = doctitleTools;\n doc.sidebar.widgets = defaultSidebarWidgets(account?.rootFolderUrl);\n if (!doc.tray) doc.tray = DEFAULT_TRAY_TOOLS.slice();\n // No root folder yet means no document list yet: leave the doc unversioned\n // so the next mount's migration seeds it.\n if (account?.rootFolderUrl) doc.version = THREEPANE_CONFIG_VERSION;\n else delete doc.version;\n });\n\n accountHandle.change((acc) => {\n if (!acc.tools) acc.tools = {};\n if (!acc.tools[\"threepane\"]) acc.tools[\"threepane\"] = configHandle.url;\n });\n}\n", "import {\n getRegistry,\n type DatatypeDescription,\n type LoadedDatatype,\n} from \"@inkandswitch/patchwork-plugins\";\n\nexport function loadDatatypeWhenReady<D>(\n id: string\n): Promise<LoadedDatatype<D>> {\n return getRegistry<DatatypeDescription>(\n \"patchwork:datatype\"\n ).loadWhenReady(id) as Promise<LoadedDatatype<D>>;\n}\n", "import debug from \"debug\";\nimport type { DocHandle, Repo } from \"@automerge/automerge-repo/slim\";\nimport { createDocOfDatatype2 } from \"@inkandswitch/patchwork-plugins\";\nimport type { FolderDoc } from \"@inkandswitch/patchwork-filesystem\";\nimport type { AccountDoc } from \"../types\";\nimport { loadDatatypeWhenReady } from \"./loadDatatypeWhenReady\";\n\nconst log = debug(\"patchwork:threepane:examples\");\n\n/**\n * Seed a fresh account with example documents by running each static module\n * bundle's generated `init.js` (emitted by that repo's scripts/bundle.mjs next\n * to its modules.json). Every init script receives the same Examples folder\n * handle, so multiple bundles merge their examples into one folder.\n *\n * Runs at most once per account: the account doc's `exampleDocsSeededAt`\n * marker is claimed *before* seeding (a race between two tabs can at worst\n * skip the examples, never duplicate them), and a deleted Examples folder is\n * never recreated. Accounts that already have documents get the marker but no\n * examples \u2014 only truly fresh accounts are seeded.\n */\nexport async function seedExampleDocuments(\n accountHandle: DocHandle<AccountDoc>,\n repo: Repo\n) {\n const account = accountHandle.doc();\n if (!account?.rootFolderUrl) {\n log(\"skipped \u2014 account has no rootFolderUrl\");\n return;\n }\n if (account.exampleDocsSeededAt) {\n log(\n \"skipped \u2014 already ran for this account at\",\n new Date(account.exampleDocsSeededAt).toISOString()\n );\n return;\n }\n\n log(\"claiming marker on account\", accountHandle.url);\n accountHandle.change((doc) => {\n if (!doc.exampleDocsSeededAt) doc.exampleDocsSeededAt = Date.now();\n });\n\n const rootFolder = await repo.find<FolderDoc>(account.rootFolderUrl);\n const existingDocs = rootFolder.doc()?.docs?.length ?? 0;\n if (existingDocs) {\n log(\n `skipped \u2014 root folder already has ${existingDocs} doc(s); only fresh accounts are seeded`\n );\n return;\n }\n\n const gaios = window.location.hostname.includes(\"gaios\");\n const initUrls = gaios ? [] : await bundleInitScriptUrls();\n log(gaios ? \"gaios examples\" : \"bundle init scripts:\", initUrls);\n if (!gaios && !initUrls.length) {\n log(\"skipped \u2014 no static module bundles to ask\");\n return;\n }\n\n const folderDatatype = await loadDatatypeWhenReady<FolderDoc>(\"folder\");\n if (!folderDatatype) {\n log(\"folder datatype never registered; giving up\");\n return;\n }\n const folder = await createDocOfDatatype2<FolderDoc>(\n folderDatatype,\n repo,\n (doc) => {\n doc.title = \"Examples\";\n }\n );\n\n if (gaios) {\n const { seedGaiosExamples } = await import(\"./gaiosExamples\");\n await seedGaiosExamples(repo, folder);\n }\n\n for (const url of initUrls) {\n try {\n const mod = await import(/* @vite-ignore */ url);\n await mod.default?.(repo, folder);\n log(\"ran init script\", url);\n } catch (err) {\n // A bundle that ships no init script 404s here \u2014 normal, not an error.\n log(\"init script unavailable or failed\", url, err);\n }\n }\n\n const seeded = folder.doc()?.docs?.length ?? 0;\n if (!seeded) {\n // Don't leave an empty Examples folder if no bundle contributed anything.\n log(\"no bundle contributed any documents\");\n return;\n }\n\n rootFolder.change((doc) => {\n doc.docs.unshift({ name: \"Examples\", type: \"folder\", url: folder.url });\n });\n log(`seeded ${seeded} document(s) into Examples folder`, folder.url);\n}\n\ntype ModuleWatcherLike = {\n urls?: Record<string, string>;\n doneLoading?: Promise<void>;\n};\n\n/**\n * The patchwork-tools bundle isn't in every site's default module sources\n * (some boot from an automerge module-settings doc, which has no init.js),\n * but its examples should seed everywhere \u2014 so it's always consulted, unless\n * the site asks for only its own examples (see siteExamplesOnly).\n */\nconst TOOLS_BUNDLE_INIT_URL = \"https://patchwork-tools.netlify.app/init.js\";\n\n/**\n * Fallback for shells with no static manifest at all (automerge-doc module\n * sources only): the deployed patchwork-base bundle. Not consulted when any\n * static manifest is configured, because that manifest is usually a copy of\n * this very bundle (e.g. a localhost dev serve) and URL-dedupe can't tell \u2014\n * always adding it would seed base's examples twice.\n */\nconst BASE_BUNDLE_INIT_URL = \"https://patchwork-base.netlify.app/init.js\";\n\n/**\n * A site that wants only its own examples says so on its root element \u2014\n * `<html data-examples=\"site\">` \u2014 and the hardcoded bundles above are left\n * out: just the init.js next to each of its own static manifests runs.\n */\nfunction siteExamplesOnly() {\n return document.documentElement.getAttribute(\"data-examples\") === \"site\";\n}\n\n/**\n * The `init.js` URL next to every static (http) module manifest the host is\n * watching, plus the hardcoded bundles above (unless the site opts out of\n * them). Automerge module-settings docs have no init script. Waits for the\n * watcher's initial load so the bundles' plugins are registered before any\n * example runs.\n */\nasync function bundleInitScriptUrls(): Promise<string[]> {\n const siteOnly = siteExamplesOnly();\n const watcher = (\n window as { patchwork?: { packages?: ModuleWatcherLike } }\n ).patchwork?.packages;\n if (!watcher?.urls) {\n return siteOnly ? [] : [BASE_BUNDLE_INIT_URL, TOOLS_BUNDLE_INIT_URL];\n }\n await watcher.doneLoading;\n const fromManifests = Object.values(watcher.urls)\n .filter((url) => typeof url === \"string\" && !url.startsWith(\"automerge:\"))\n .map((url) => new URL(\"init.js\", new URL(url, document.baseURI)).href);\n if (siteOnly) return [...new Set(fromManifests)];\n const base = fromManifests.length ? [] : [BASE_BUNDLE_INIT_URL];\n return [...new Set([...fromManifests, ...base, TOOLS_BUNDLE_INIT_URL])];\n}\n", "import type { AutomergeUrl, DocHandle, Repo } from \"@automerge/automerge-repo/slim\";\n\n/**\n * Asked for by anything that wants a doc in the sidebar (the \"Add to sidebar\"\n * titlebar button, say). It bubbles and is composed, so whatever frame is\n * around the asker can claim it: call `preventDefault()` and hand the work to\n * `detail.respondWith`. Unclaimed, the asker does it itself.\n */\nexport const ADD_TO_SIDEBAR_EVENT = \"patchwork:add-to-sidebar\";\n\nexport type DocLink = { url: AutomergeUrl; name: string; type: string };\n\nexport type AddToSidebarDetail = {\n url: AutomergeUrl;\n name?: string;\n type?: string;\n respondWith?(work: Promise<unknown>): void;\n};\n\ntype FolderLike = { docs?: DocLink[] };\n\n/**\n * Put `link` first in the folder. A doc that's already there is lifted to the\n * top, keeping its own name, rather than added twice.\n */\nexport function putAtTop(folder: FolderLike, link: DocLink) {\n if (!folder.docs) folder.docs = [];\n const docs = folder.docs;\n const at = docs.findIndex((existing) => existing.url === link.url);\n if (at === 0) return;\n if (at > 0) {\n const { name, type } = docs[at];\n docs.splice(at, 1);\n docs.unshift({ url: link.url, name, type });\n return;\n }\n docs.unshift({ url: link.url, name: link.name, type: link.type });\n}\n\n/** Resolves with pick(doc) once it's something. */\nfunction when<T, R>(\n handle: DocHandle<T>,\n pick: (doc: T) => R | undefined\n): Promise<R> {\n return new Promise((resolve) => {\n const check = () => {\n const doc = handle.doc();\n const picked = doc && pick(doc);\n if (!picked) return;\n handle.off(\"change\", check);\n resolve(picked);\n };\n handle.on(\"change\", check);\n check();\n });\n}\n\n/**\n * Answer `patchwork:add-to-sidebar` events from inside `element` by putting the\n * doc at the top of the account's root folder (what the sidebar's document list\n * shows). Uses the frame's own repo, so a request from inside a draft overlay\n * still lands in the real sidebar, not a draft of it.\n */\nexport function handleAddToSidebar<T extends { rootFolderUrl?: AutomergeUrl }>(\n element: HTMLElement,\n repo: Repo,\n accountHandle: DocHandle<T>\n) {\n const onAdd = (event: Event) => {\n const detail = (event as CustomEvent<AddToSidebarDetail>).detail;\n if (!detail?.url) return;\n event.preventDefault();\n event.stopPropagation();\n\n const work = (async () => {\n const rootFolderUrl = await when(accountHandle, (doc) => doc.rootFolderUrl);\n const rootFolder = await repo.find<FolderLike>(rootFolderUrl);\n rootFolder.change((folder) =>\n putAtTop(folder, {\n url: detail.url,\n name: detail.name || \"Untitled\",\n type: detail.type || \"unknown\",\n })\n );\n })();\n work.catch((error) =>\n console.error(\"threepane: couldn't add to sidebar\", error)\n );\n detail.respondWith?.(work);\n };\n\n element.addEventListener(ADD_TO_SIDEBAR_EVENT, onAdd);\n return () => element.removeEventListener(ADD_TO_SIDEBAR_EVENT, onAdd);\n}\n", "import type { DocHandle } from \"@automerge/automerge-repo/slim\";\nimport {\n createEffect,\n createMemo,\n createSignal,\n onCleanup,\n type Accessor,\n} from \"solid-js\";\n\n/**\n * The current doc of a handle, recomputed on every change. Reads through a\n * version counter instead of useDocument, because its store proxying conflicts\n * with Automerge array splices.\n */\nexport function useHandleDoc<T>(\n handle: Accessor<DocHandle<T> | undefined>\n): Accessor<T | undefined> {\n const [version, setVersion] = createSignal(0);\n createEffect(() => {\n const h = handle();\n if (!h) return;\n const onChange = () => setVersion((v) => v + 1);\n h.on(\"change\", onChange);\n onCleanup(() => h.off(\"change\", onChange));\n });\n return createMemo(() => {\n version();\n return handle()?.doc();\n });\n}\n"],
|
|
5
|
+
"mappings": "mRAAA,OAAS,YAAYA,MAAkB,eACvC,OAAS,kBAAkBC,OAAwB,eACnD,OAAS,QAAQC,OAAc,eAC/B,OAAS,oBAAoBC,OAA0B,eACvD,OAAS,gBAAgBC,MAAsB,eAC/C,OAAS,UAAUC,MAAgB,eACnC,OAAS,YAAYC,MAAkB,eACvC,OAAS,OAAOC,MAAa,eAC7B,OAAS,UAAUC,MAAgB,eACnC,OAAS,mBAAmBC,MAAyB,eAWrD,MAAO,mCAEP,OAAS,aAAAC,OAAiB,oCCtB1B,OAAS,YAAYC,MAAkB,eACvC,OAAS,kBAAkBC,OAAwB,eACnD,OAAS,QAAQC,OAAc,eAC/B,OAAS,UAAUC,OAAgB,eACnC,OAAS,mBAAmBC,MAAyB,eAIrD,OAAS,OAAAC,GAAK,QAAAC,MAAY,WAH1B,IAAIC,GAAsBC,EAAW,+BAA+B,EAClEC,GAAuBD,EAAW,+GAA0G,EAC5IE,GAAuBF,EAAW,8BAA8B,EAI3D,SAASG,GAAeC,EAAO,CACpC,IAAMC,EAAkB,IAAM,CAC5B,IAAMC,EAAOF,EAAM,cAAc,EAC3BG,EAASH,EAAM,aAAa,EAC9B,CAACE,GAAQ,CAACC,GACdA,EAAO,OAAOC,GAAO,CACnBA,EAAI,QAAQ,QAAQ,KAAK,CAACC,EAAoBH,CAAI,CAAC,CACrD,CAAC,CACH,EACA,OAAQ,IAAM,CACZ,IAAII,EAAOX,GAAO,EAClB,OAAAY,GAASD,EAAME,EAAkBC,EAAM,CACrC,IAAI,MAAO,CACT,OAAOT,EAAM,MAAM,CACrB,EACA,IAAI,UAAW,CACb,OAAOQ,EAAkBC,EAAM,CAC7B,IAAI,MAAO,CACT,OAAOT,EAAM,QAAQ,EAAE,MACzB,EACA,IAAI,UAAW,CACb,OAEEQ,EAAkBC,EAAM,CACtB,IAAI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ACvC,IAAI,OAAQ,CACV,OAAO5H,EAAM,SACf,CACF,CAAC,CAAC,EACF4F,EAASC,GAAO,CACd,IAAIgC,EAAO,CAAC,CAAC5B,EAAY,EACvB6B,EAAO,GAAG9H,EAAM,aAAa,iBAAiB,CAAC,KACjD,OAAA6H,IAAShC,EAAI,GAAK8B,EAAO,UAAU,OAAO,8BAA+B9B,EAAI,EAAIgC,CAAI,EACrFC,IAASjC,EAAI,GAAKkC,GAAmBJ,EAAQ,QAAS9B,EAAI,EAAIiC,CAAI,EAC3DjC,CACT,EAAG,CACD,EAAG,OACH,EAAG,MACL,CAAC,EACM8B,CACT,CACF,CAAC,EAAGK,GAAO,IAAMhI,EAAM,QAAQ,CAAC,CAClC,CACA,SAASyG,IAAgB,CACvB,OAAO1H,GAAQ,CACjB,CACO,SAASkJ,GAAqBC,EAAW,CAC9C,MAAO,CAACpI,EAAQZ,IACPiJ,GAAO,IAAM5G,EAAkB1B,GAAgB,CACpD,OAAQC,EACR,IAAI,MAAO,CACT,OAAOZ,EAAQ,IACjB,EACA,UAAWgJ,CACb,CAAC,EAAGhJ,CAAO,CAEf,CACAkJ,GAAiB,CAAC,OAAO,CAAC",
|
|
6
|
+
"names": ["_$template", "_$delegateEvents", "_$memo", "_$setStyleProperty", "_$setAttribute", "_$effect", "_$getOwner", "_$use", "_$insert", "_$createComponent", "subscribe", "_$template", "_$delegateEvents", "_$memo", "_$insert", "_$createComponent", "For", "Show", "_tmpl$", "_$template", "_tmpl$2", "_tmpl$3", "SidebarWidgets", "props", "addDocumentList", "root", "handle", "doc", "DOCUMENT_LIST_TOOL", "_el$", "_$insert", "_$createComponent", "Show", "_$memo", "_el$2", "_el$3", "For", "widget", "_el$4", "SlotView", "_$delegateEvents", "_$template", "_$setAttribute", "_$effect", "_$insert", "_$createComponent", "For", "Show", "_tmpl$", "_$template", "_tmpl$2", "Tray", "props", "_$createComponent", "Show", "_el$", "_$insert", "For", "uniqueSlots", "slot", "_el$2", "SlotView", "_$effect", "_$setAttribute", "slotId", "createEffect", "createMemo", "createSignal", "onCleanup", "onMount", "Show", "render", "createDocOfDatatype2", "getRegistry", "loadDatatypeWhenReady", "id", "INTRINSIC_DOCTITLE_TOOLS", "defaultSidebarWidgets", "rootFolderUrl", "DOCUMENT_LIST_TOOL", "migrateThreepaneConfig", "doc", "DEFAULT_TRAY_TOOLS", "unique", "uniqueSlots", "present", "s", "slotId", "id", "DEFAULT_DOCTITLE_TOOLS", "ensureThreepaneConfig", "accountHandle", "repo", "existingConfigUrl", "configHandle", "datatype", "loadDatatypeWhenReady", "account", "doctitleTools", "createDocOfDatatype2", "acc", "import_debug", "createDocOfDatatype2", "log", "debug", "seedExampleDocuments", "accountHandle", "repo", "account", "doc", "rootFolder", "existingDocs", "gaios", "initUrls", "bundleInitScriptUrls", "folderDatatype", "loadDatatypeWhenReady", "folder", "createDocOfDatatype2", "seedGaiosExamples", "url", "err", "seeded", "TOOLS_BUNDLE_INIT_URL", "BASE_BUNDLE_INIT_URL", "siteExamplesOnly", "siteOnly", "watcher", "fromManifests", "base", "ADD_TO_SIDEBAR_EVENT", "putAtTop", "folder", "link", "docs", "at", "existing", "name", "type", "when", "handle", "pick", "resolve", "check", "doc", "picked", "handleAddToSidebar", "element", "repo", "accountHandle", "onAdd", "event", "detail", "work", "rootFolderUrl", "error", "createEffect", "createMemo", "createSignal", "onCleanup", "useHandleDoc", "handle", "version", "setVersion", "h", "onChange", "v", "_tmpl$", "_$template", "_tmpl$2", "_tmpl$3", "_tmpl$4", "_tmpl$5", "_tmpl$6", "_tmpl$7", "_tmpl$8", "_tmpl$9", "_tmpl$0", "useFrameProviderReady", "componentId", "element", "isReady", "setReady", "createSignal", "createEffect", "el", "onMounted", "event", "onCleanup", "dispatchOpen", "detail", "PatchworkFrame", "handle", "repo", "props", "ensureFrameStyles", "accountDocUrl", "accountProviderElement", "setAccountProviderElement", "isAccountProviderReady", "toolStorageProviderElement", "setToolStorageProviderElement", "isToolStorageProviderReady", "selectedDocProviderElement", "setSelectedDocProviderElement", "isSelectedDocProviderReady", "areProvidersReady", "createMemo", "_el$", "_el$2", "_el$3", "_el$4", "_el$5", "_el$6", "_el$7", "_el$8", "_$insert", "_$createComponent", "Show", "_$use", "_$getOwner", "PatchworkFrameInner", "accountDocHandle", "useDocHandle", "ensureThreepaneConfig", "seedExampleDocuments", "err", "accountDoc", "useHandleDoc", "threepaneUrl", "threepaneConfigHandle", "threepaneConfig", "doctitleSlots", "sidebarWidgets", "traySlots", "rootFolderUrl", "sidebarState", "useSidebarState", "sidebarResize", "useSidebarResize", "selectedView", "setSelectedView", "popoverView", "setPopoverView", "onMount", "unsubscribeSelectedView", "subscribe", "view", "handleAddToSidebar", "selectedDocUrl", "selectedToolId", "initialRightWidth", "getStoredNumber", "SIDEBAR_KEYS", "DEFAULT_SIDEBAR_WIDTH", "initialRightCollapsed", "getStoredBoolean", "mainDocElement", "setMainDocElement", "isMainDocMounted", "useMainDocMounted", "widgetsReady", "setWidgetsReady", "_el$9", "_ref$", "FrameLayout", "_el$0", "MainDocumentView", "DocumentAreaRoot", "IsolatedDocumentArea", "FramePopover", "toolId", "setToolId", "popoverEl", "onKey", "e", "onOpen", "url", "nextToolId", "_el$1", "_el$10", "_el$11", "_el$12", "_el$13", "_el$14", "_ref$2", "_$effect", "_p$", "_v$", "_v$2", "_v$3", "isCollapsed", "hasTray", "sidebarContentEl", "footerEl", "footer", "COLLAPSE_CONTEXT_SIDEBAR_EVENT", "_el$15", "v", "PanelLeftIcon", "_v$4", "_v$5", "_v$6", "_$setAttribute", "Sidebar", "_el$16", "_el$17", "_el$18", "_el$19", "_ref$3", "SidebarWidgets", "_ref$4", "contactUrl", "_el$21", "_el$22", "moduleSettingsUrl", "_el$23", "_el$20", "Tray", "_v$7", "_v$8", "_$setStyleProperty", "_$memo", "renderPatchworkFrame", "isolation", "render", "_$delegateEvents"]
|
|
7
|
+
}
|