@acryldev/blends-frame 0.2.8 → 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 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",
@@ -47870,7 +47871,23 @@ body[data-bf-settings-full] { --bf-pane-h: calc(100vh - 24px); }
47870
47871
  waiting,
47871
47872
  onConnected
47872
47873
  ]);
47873
- if (github.status === "checking" || github.status === "ready") return null;
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
+ });
47874
47891
  const start = () => {
47875
47892
  if (connect === void 0) return;
47876
47893
  setConnecting({ status: "starting" });
@@ -47922,10 +47939,10 @@ body[data-bf-settings-full] { --bf-pane-h: calc(100vh - 24px); }
47922
47939
  onClick: start,
47923
47940
  children: connecting.status === "starting" ? "Connecting..." : "Connect GitHub"
47924
47941
  }) }),
47925
- 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", {
47926
47943
  className: "acrylBlendsConnectAlt",
47927
47944
  children: [
47928
- connect === void 0 ? "Open the Terminal and run:" : "Or in the Terminal:",
47945
+ "Open the Terminal and run:",
47929
47946
  " ",
47930
47947
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: github.command }),
47931
47948
  " ",
@@ -48312,7 +48329,16 @@ body[data-bf-settings-full] { --bf-pane-h: calc(100vh - 24px); }
48312
48329
  if (!response.ok) throw await failureOf(response);
48313
48330
  return parseGithubConnectState(await response.json());
48314
48331
  },
48315
- 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
+ }
48316
48342
  },
48317
48343
  async add(source) {
48318
48344
  const response = await fetcher(FRAME_PLUGINS_PULL_PATH, {
@@ -50284,6 +50310,100 @@ body[data-bf-settings-full] [data-shortcut-modal="settings"] { width: calc(100vw
50284
50310
  return parseSnapshotCapture(await response.json());
50285
50311
  } };
50286
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
+ }
50287
50407
  // src/client/view-state.ts
50288
50408
  /**
50289
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
@@ -50609,6 +50729,7 @@ body[data-bf-settings-full] [data-shortcut-modal="settings"] { width: calc(100vw
50609
50729
  };
50610
50730
  }, "@acryldev/blends-frame: the canvas service");
50611
50731
  ctx.effect(() => installFrameView(canvas, view), "@acryldev/blends-frame: the app page view");
50732
+ ctx.effect(() => installFrameControl(view), "@acryldev/blends-frame: frame control");
50612
50733
  let sidebarRight;
50613
50734
  const sidebarOpens = /* @__PURE__ */ new Set();
50614
50735
  ctx.inject(["sidebarRight"], (child) => {