@acryldev/blends-frame 0.2.7 → 0.2.9
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/lib/client.js +155 -20
- package/lib/client.js.map +1 -1
- package/lib/contract.d.ts +9 -1
- package/lib/github-connect.d.ts +39 -22
- package/lib/index.d.ts +4 -2
- package/lib/index.js +150 -116
- package/lib/index.js.map +1 -1
- package/lib/types/client/frame-control.d.ts +39 -0
- package/lib/types/client/plugins-navigator.d.ts +5 -4
- package/lib/types/client/registry-api.d.ts +2 -0
- package/lib/types/contract.d.ts +9 -1
- package/package.json +3 -2
package/lib/client.js
CHANGED
|
@@ -475,7 +475,8 @@ window.__ModuleLoader__.load({
|
|
|
475
475
|
if (!isRecord$5(value)) throw new Error("github: not a readiness");
|
|
476
476
|
if (value.status === "ready" && typeof value.account === "string") return {
|
|
477
477
|
status: "ready",
|
|
478
|
-
account: value.account
|
|
478
|
+
account: value.account,
|
|
479
|
+
...value.via === "acryl" ? { via: "acryl" } : {}
|
|
479
480
|
};
|
|
480
481
|
if (value.status === "signed-out" && typeof value.say === "string" && typeof value.command === "string") return {
|
|
481
482
|
status: "signed-out",
|
|
@@ -17720,7 +17721,7 @@ window.__ModuleLoader__.load({
|
|
|
17720
17721
|
});
|
|
17721
17722
|
if (!response.ok) return errorOf$1(response);
|
|
17722
17723
|
},
|
|
17723
|
-
async planShare(name, target) {
|
|
17724
|
+
async planShare(name, target, owner) {
|
|
17724
17725
|
const response = await fetcher(FRAME_PLUGINS_SHARE_PLAN_PATH, {
|
|
17725
17726
|
method: "POST",
|
|
17726
17727
|
credentials: "same-origin",
|
|
@@ -17728,12 +17729,15 @@ window.__ModuleLoader__.load({
|
|
|
17728
17729
|
"Content-Type": "application/json",
|
|
17729
17730
|
Accept: "application/json"
|
|
17730
17731
|
},
|
|
17731
|
-
body: JSON.stringify(
|
|
17732
|
-
name
|
|
17733
|
-
|
|
17734
|
-
|
|
17735
|
-
|
|
17736
|
-
|
|
17732
|
+
body: JSON.stringify({
|
|
17733
|
+
...target === void 0 ? { name } : target === "registry" ? {
|
|
17734
|
+
name,
|
|
17735
|
+
registry: true
|
|
17736
|
+
} : {
|
|
17737
|
+
name,
|
|
17738
|
+
visibility: target
|
|
17739
|
+
},
|
|
17740
|
+
...owner === void 0 ? {} : { owner }
|
|
17737
17741
|
})
|
|
17738
17742
|
});
|
|
17739
17743
|
if (!response.ok) return errorOf$1(response);
|
|
@@ -17752,7 +17756,7 @@ window.__ModuleLoader__.load({
|
|
|
17752
17756
|
if (!response.ok) return errorOf$1(response);
|
|
17753
17757
|
return parseSavedPlugin(await response.json());
|
|
17754
17758
|
},
|
|
17755
|
-
async share(name, confirmed) {
|
|
17759
|
+
async share(name, confirmed, owner) {
|
|
17756
17760
|
const response = await fetcher(FRAME_PLUGINS_SHARE_PATH, {
|
|
17757
17761
|
method: "POST",
|
|
17758
17762
|
credentials: "same-origin",
|
|
@@ -17762,7 +17766,8 @@ window.__ModuleLoader__.load({
|
|
|
17762
17766
|
},
|
|
17763
17767
|
body: JSON.stringify({
|
|
17764
17768
|
name,
|
|
17765
|
-
confirm: confirmed
|
|
17769
|
+
confirm: confirmed,
|
|
17770
|
+
...owner === void 0 ? {} : { owner }
|
|
17766
17771
|
})
|
|
17767
17772
|
});
|
|
17768
17773
|
if (!response.ok) return errorOf$1(response);
|
|
@@ -47609,6 +47614,7 @@ body[data-bf-settings-full] { --bf-pane-h: calc(100vh - 24px); }
|
|
|
47609
47614
|
const [github, setGithub] = (0, react.useState)({ status: "checking" });
|
|
47610
47615
|
const [details, setDetails] = (0, react.useState)(false);
|
|
47611
47616
|
const [copied, setCopied] = (0, react.useState)(void 0);
|
|
47617
|
+
const [owner, setOwner] = (0, react.useState)("");
|
|
47612
47618
|
(0, react.useEffect)(() => {
|
|
47613
47619
|
let live = true;
|
|
47614
47620
|
readGithub().then((answer) => {
|
|
@@ -47624,6 +47630,7 @@ body[data-bf-settings-full] { --bf-pane-h: calc(100vh - 24px); }
|
|
|
47624
47630
|
};
|
|
47625
47631
|
}, [readGithub]);
|
|
47626
47632
|
const share = plugin.share;
|
|
47633
|
+
const ownerAsked = owner.trim() === "" ? void 0 : owner.trim();
|
|
47627
47634
|
const blocked = github.status === "missing" || github.status === "signed-out";
|
|
47628
47635
|
const idle = state.step === "choose" || state.step === "failed" || state.step === "done";
|
|
47629
47636
|
const save = async () => {
|
|
@@ -47653,7 +47660,7 @@ body[data-bf-settings-full] { --bf-pane-h: calc(100vh - 24px); }
|
|
|
47653
47660
|
try {
|
|
47654
47661
|
setState({
|
|
47655
47662
|
step: "confirm",
|
|
47656
|
-
plan: await share.plan(target)
|
|
47663
|
+
plan: await share.plan(target, ownerAsked)
|
|
47657
47664
|
});
|
|
47658
47665
|
} catch (cause) {
|
|
47659
47666
|
setState(failed(cause));
|
|
@@ -47666,7 +47673,7 @@ body[data-bf-settings-full] { --bf-pane-h: calc(100vh - 24px); }
|
|
|
47666
47673
|
what: "Sharing…"
|
|
47667
47674
|
});
|
|
47668
47675
|
try {
|
|
47669
|
-
const shared = await share.publish(plan);
|
|
47676
|
+
const shared = await share.publish(plan, ownerAsked);
|
|
47670
47677
|
onShared(shared);
|
|
47671
47678
|
const address = colleagueAddress(shared);
|
|
47672
47679
|
setState({
|
|
@@ -47765,14 +47772,22 @@ body[data-bf-settings-full] { --bf-pane-h: calc(100vh - 24px); }
|
|
|
47765
47772
|
children: shareDetails(state.plan).map((line) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: line }, line))
|
|
47766
47773
|
})
|
|
47767
47774
|
]
|
|
47768
|
-
}) : /* @__PURE__ */ (0, react_jsx_runtime.
|
|
47775
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [share !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
47776
|
+
className: "acrylBlendsSearch",
|
|
47777
|
+
"aria-label": "GitHub account or organization",
|
|
47778
|
+
placeholder: "GitHub account or organization (blank: yours)",
|
|
47779
|
+
value: owner,
|
|
47780
|
+
onChange: (event) => {
|
|
47781
|
+
setOwner(event.target.value);
|
|
47782
|
+
}
|
|
47783
|
+
}) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", { children: choices.map((choice) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: choice.title }), choice.say] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
47769
47784
|
type: "button",
|
|
47770
47785
|
disabled: choice.disabled || !idle,
|
|
47771
47786
|
onClick: () => {
|
|
47772
47787
|
choice.target === void 0 ? save() : ask(choice.target);
|
|
47773
47788
|
},
|
|
47774
47789
|
children: choice.button
|
|
47775
|
-
})] }, choice.title)) }),
|
|
47790
|
+
})] }, choice.title)) })] }),
|
|
47776
47791
|
state.step === "confirm" || state.step === "working" ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(GithubNote, {
|
|
47777
47792
|
github,
|
|
47778
47793
|
copy,
|
|
@@ -47856,7 +47871,23 @@ body[data-bf-settings-full] { --bf-pane-h: calc(100vh - 24px); }
|
|
|
47856
47871
|
waiting,
|
|
47857
47872
|
onConnected
|
|
47858
47873
|
]);
|
|
47859
|
-
if (github.status === "checking"
|
|
47874
|
+
if (github.status === "checking") return null;
|
|
47875
|
+
if (github.status === "ready") return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
|
47876
|
+
className: "acrylBlendsNote acrylBlendsConnected",
|
|
47877
|
+
role: "status",
|
|
47878
|
+
children: [
|
|
47879
|
+
"Connected as @",
|
|
47880
|
+
github.account,
|
|
47881
|
+
github.via === "acryl" && connect !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [" · ", /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
47882
|
+
type: "button",
|
|
47883
|
+
className: "acrylBlendsShareButton",
|
|
47884
|
+
onClick: () => {
|
|
47885
|
+
connect.disconnect().then(onConnected, () => {});
|
|
47886
|
+
},
|
|
47887
|
+
children: "Disconnect"
|
|
47888
|
+
})] })
|
|
47889
|
+
]
|
|
47890
|
+
});
|
|
47860
47891
|
const start = () => {
|
|
47861
47892
|
if (connect === void 0) return;
|
|
47862
47893
|
setConnecting({ status: "starting" });
|
|
@@ -47908,10 +47939,10 @@ body[data-bf-settings-full] { --bf-pane-h: calc(100vh - 24px); }
|
|
|
47908
47939
|
onClick: start,
|
|
47909
47940
|
children: connecting.status === "starting" ? "Connecting..." : "Connect GitHub"
|
|
47910
47941
|
}) }),
|
|
47911
|
-
github.status === "signed-out" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
|
47942
|
+
github.status === "signed-out" && connect === void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
|
47912
47943
|
className: "acrylBlendsConnectAlt",
|
|
47913
47944
|
children: [
|
|
47914
|
-
|
|
47945
|
+
"Open the Terminal and run:",
|
|
47915
47946
|
" ",
|
|
47916
47947
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: github.command }),
|
|
47917
47948
|
" ",
|
|
@@ -48298,7 +48329,16 @@ body[data-bf-settings-full] { --bf-pane-h: calc(100vh - 24px); }
|
|
|
48298
48329
|
if (!response.ok) throw await failureOf(response);
|
|
48299
48330
|
return parseGithubConnectState(await response.json());
|
|
48300
48331
|
},
|
|
48301
|
-
state: async () => parseGithubConnectState(await get(FRAME_PLUGINS_GITHUB_CONNECT_PATH))
|
|
48332
|
+
state: async () => parseGithubConnectState(await get(FRAME_PLUGINS_GITHUB_CONNECT_PATH)),
|
|
48333
|
+
async disconnect() {
|
|
48334
|
+
const response = await fetcher(FRAME_PLUGINS_GITHUB_PATH, {
|
|
48335
|
+
method: "DELETE",
|
|
48336
|
+
credentials: "same-origin",
|
|
48337
|
+
headers: { Accept: "application/json" }
|
|
48338
|
+
});
|
|
48339
|
+
if (!response.ok) throw await failureOf(response);
|
|
48340
|
+
return parseGithubReadiness(await response.json());
|
|
48341
|
+
}
|
|
48302
48342
|
},
|
|
48303
48343
|
async add(source) {
|
|
48304
48344
|
const response = await fetcher(FRAME_PLUGINS_PULL_PATH, {
|
|
@@ -50270,6 +50310,100 @@ body[data-bf-settings-full] [data-shortcut-modal="settings"] { width: calc(100vw
|
|
|
50270
50310
|
return parseSnapshotCapture(await response.json());
|
|
50271
50311
|
} };
|
|
50272
50312
|
}
|
|
50313
|
+
// src/client/frame-control.ts
|
|
50314
|
+
/**
|
|
50315
|
+
* The frame's own UI, operable by the agent (the door's `frame` verb): the left panel (branches and versions), the right panel (the agents), Build and
|
|
50316
|
+
* Preview, and Settings. These are not part of the app page, so the door's page script, which runs in the canvas page, cannot see or click them; the
|
|
50317
|
+
* frame publishes this control on its own window and the page reaches it through `window.parent`, the way {@link installFrameView} publishes the mode.
|
|
50318
|
+
* The shapes match the door's page protocol (plugins/door/src/page/protocol.ts: `FRAME_CONTROL_KEY`, `FrameControl`); keep them in step.
|
|
50319
|
+
*/
|
|
50320
|
+
const FRAME_CONTROL_KEY = Symbol.for("acryl.frame.control");
|
|
50321
|
+
const PANEL_NAME = {
|
|
50322
|
+
left: "left panel (branches and versions)",
|
|
50323
|
+
right: "right panel (the agents)"
|
|
50324
|
+
};
|
|
50325
|
+
/** What the person sees: Preview hides both panels whatever they were set to. */
|
|
50326
|
+
function stateOf(view, doc) {
|
|
50327
|
+
const { left, right, mode } = view.getSnapshot();
|
|
50328
|
+
const gear = doc.querySelector(".acrylBlendsSettings button[aria-label=\"Settings\"]");
|
|
50329
|
+
return {
|
|
50330
|
+
left: left && mode === "build",
|
|
50331
|
+
right: right && mode === "build",
|
|
50332
|
+
mode,
|
|
50333
|
+
settings: gear?.getAttribute("aria-expanded") === "true"
|
|
50334
|
+
};
|
|
50335
|
+
}
|
|
50336
|
+
const describe = (state) => `left panel ${state.left ? "open" : "closed"}, right panel ${state.right ? "open" : "closed"}, ${state.mode} mode${state.settings ? ", Settings open" : ""}`;
|
|
50337
|
+
const settle = (view) => new Promise((resolve) => {
|
|
50338
|
+
view.setTimeout(resolve, 50);
|
|
50339
|
+
});
|
|
50340
|
+
function frameControl(view, doc = document) {
|
|
50341
|
+
const setPanel = (panel, open) => {
|
|
50342
|
+
const shown = stateOf(view, doc)[panel];
|
|
50343
|
+
if (open && !shown) {
|
|
50344
|
+
if (panel === "left") view.showLeft();
|
|
50345
|
+
else view.showRight();
|
|
50346
|
+
}
|
|
50347
|
+
if (!open && shown) {
|
|
50348
|
+
if (panel === "left") view.toggleLeft();
|
|
50349
|
+
else view.toggleRight();
|
|
50350
|
+
}
|
|
50351
|
+
};
|
|
50352
|
+
return {
|
|
50353
|
+
state: () => stateOf(view, doc),
|
|
50354
|
+
async run(request) {
|
|
50355
|
+
const win = doc.defaultView ?? window;
|
|
50356
|
+
switch (request.action) {
|
|
50357
|
+
case "state": break;
|
|
50358
|
+
case "open":
|
|
50359
|
+
case "close":
|
|
50360
|
+
case "toggle": {
|
|
50361
|
+
const panel = request.panel;
|
|
50362
|
+
if (panel === void 0) throw new Error(`frame ${request.action} needs left or right`);
|
|
50363
|
+
setPanel(panel, request.action === "open" ? true : request.action === "close" ? false : !stateOf(view, doc)[panel]);
|
|
50364
|
+
await settle(win);
|
|
50365
|
+
return `${PANEL_NAME[panel]} ${stateOf(view, doc)[panel] ? "open" : "closed"}; frame: ${describe(stateOf(view, doc))}`;
|
|
50366
|
+
}
|
|
50367
|
+
case "build":
|
|
50368
|
+
case "preview":
|
|
50369
|
+
view.setMode(request.action);
|
|
50370
|
+
break;
|
|
50371
|
+
case "settings": {
|
|
50372
|
+
if (!stateOf(view, doc).settings) win.dispatchEvent(new Event(OPEN_SETTINGS_EVENT));
|
|
50373
|
+
if (request.section === void 0) {
|
|
50374
|
+
await settle(win);
|
|
50375
|
+
break;
|
|
50376
|
+
}
|
|
50377
|
+
const wanted = request.section.trim().toLowerCase();
|
|
50378
|
+
for (let tries = 0; tries < 20; tries += 1) {
|
|
50379
|
+
await settle(win);
|
|
50380
|
+
const button = [...doc.querySelectorAll("[role=\"dialog\"] button")].find((item) => item.textContent?.trim().toLowerCase() === wanted);
|
|
50381
|
+
if (button !== void 0) {
|
|
50382
|
+
button.click();
|
|
50383
|
+
await settle(win);
|
|
50384
|
+
return `Settings open at ${button.textContent?.trim() ?? request.section}; frame: ${describe(stateOf(view, doc))}`;
|
|
50385
|
+
}
|
|
50386
|
+
}
|
|
50387
|
+
throw new Error(`Settings has no section "${request.section}"`);
|
|
50388
|
+
}
|
|
50389
|
+
}
|
|
50390
|
+
await settle(win);
|
|
50391
|
+
return `frame: ${describe(stateOf(view, doc))}`;
|
|
50392
|
+
}
|
|
50393
|
+
};
|
|
50394
|
+
}
|
|
50395
|
+
/** Publish the control on the frame's window. @returns the disposer. */
|
|
50396
|
+
function installFrameControl(view) {
|
|
50397
|
+
const control = frameControl(view);
|
|
50398
|
+
Object.defineProperty(window, FRAME_CONTROL_KEY, {
|
|
50399
|
+
configurable: true,
|
|
50400
|
+
value: control
|
|
50401
|
+
});
|
|
50402
|
+
return () => {
|
|
50403
|
+
const own = window;
|
|
50404
|
+
if (own[FRAME_CONTROL_KEY] === control) delete own[FRAME_CONTROL_KEY];
|
|
50405
|
+
};
|
|
50406
|
+
}
|
|
50273
50407
|
// src/client/view-state.ts
|
|
50274
50408
|
/**
|
|
50275
50409
|
* The frame's own view: which panels are open, their widths and which mode it is in. Both panels open on the first run; after that the person's choice
|
|
@@ -50595,6 +50729,7 @@ body[data-bf-settings-full] [data-shortcut-modal="settings"] { width: calc(100vw
|
|
|
50595
50729
|
};
|
|
50596
50730
|
}, "@acryldev/blends-frame: the canvas service");
|
|
50597
50731
|
ctx.effect(() => installFrameView(canvas, view), "@acryldev/blends-frame: the app page view");
|
|
50732
|
+
ctx.effect(() => installFrameControl(view), "@acryldev/blends-frame: frame control");
|
|
50598
50733
|
let sidebarRight;
|
|
50599
50734
|
const sidebarOpens = /* @__PURE__ */ new Set();
|
|
50600
50735
|
ctx.inject(["sidebarRight"], (child) => {
|
|
@@ -50755,8 +50890,8 @@ body[data-bf-settings-full] [data-shortcut-modal="settings"] { width: calc(100vw
|
|
|
50755
50890
|
await appPlugins.switch(plugin.kind, plugin.name, on);
|
|
50756
50891
|
canvas.reload();
|
|
50757
50892
|
}, plugin.kind === "made" ? {
|
|
50758
|
-
plan: (target) => appPlugins.planShare(plugin.name, target),
|
|
50759
|
-
publish: (confirmed) => appPlugins.share(plugin.name, confirmed)
|
|
50893
|
+
plan: (target, owner) => appPlugins.planShare(plugin.name, target, owner),
|
|
50894
|
+
publish: (confirmed, owner) => appPlugins.share(plugin.name, confirmed, owner)
|
|
50760
50895
|
} : void 0, void 0, {
|
|
50761
50896
|
...plugin.kind === "made" ? { save: () => appPlugins.save(plugin.name) } : {},
|
|
50762
50897
|
...viewSource === void 0 ? {} : { viewSource }
|