@acryldev/blends-frame 0.2.11 → 0.2.13

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
@@ -140,7 +140,7 @@ window.__ModuleLoader__.load({
140
140
  /** @throws an Error naming the field when the answer is not a frame state. */
141
141
  function parseFrameState(value) {
142
142
  if (!isRecord$5(value)) throw new Error("frame state: not an object");
143
- const { appName, appRoot, appPage, branches, head, unsaved, upstreamHead } = value;
143
+ const { appName, appRoot, appPage, branches, head, unsaved, upstreamHead, appVersions } = value;
144
144
  if (typeof appName !== "string" || appName === "") throw new Error("frame state: appName");
145
145
  if (typeof appRoot !== "string" || appRoot === "") throw new Error("frame state: appRoot");
146
146
  if (appPage !== void 0 && (typeof appPage !== "string" || !appPage.startsWith("/"))) throw new Error("frame state: appPage");
@@ -148,6 +148,7 @@ window.__ModuleLoader__.load({
148
148
  if (head !== void 0 && (typeof head !== "string" || head === "")) throw new Error("frame state: head");
149
149
  if (unsaved !== void 0 && (typeof unsaved !== "number" || !Number.isInteger(unsaved) || unsaved < 0)) throw new Error("frame state: unsaved");
150
150
  if (upstreamHead !== void 0 && (typeof upstreamHead !== "string" || upstreamHead === "")) throw new Error("frame state: upstreamHead");
151
+ if (appVersions !== void 0 && (!isRecord$5(appVersions) || [appVersions.blend, appVersions.framework].some((v) => v !== void 0 && typeof v !== "string"))) throw new Error("frame state: appVersions");
151
152
  const parsed = branches.map((branch) => {
152
153
  if (!isRecord$5(branch) || typeof branch.name !== "string" || typeof branch.current !== "boolean") throw new Error("frame state: branch");
153
154
  return {
@@ -162,7 +163,8 @@ window.__ModuleLoader__.load({
162
163
  branches: parsed,
163
164
  ...head === void 0 ? {} : { head },
164
165
  ...unsaved === void 0 ? {} : { unsaved },
165
- ...upstreamHead === void 0 ? {} : { upstreamHead }
166
+ ...upstreamHead === void 0 ? {} : { upstreamHead },
167
+ ...appVersions === void 0 ? {} : { appVersions }
166
168
  };
167
169
  }
168
170
  const FRAME_PLUGINS_PATH = `${FRAME_API_PREFIX}/plugins`;
@@ -4280,6 +4282,8 @@ window.__ModuleLoader__.load({
4280
4282
  }, [switchRequest, view]);
4281
4283
  const appName = label ?? (state.status === "ready" ? state.state.appName : "");
4282
4284
  const barLabel = [versionLabel, state.status === "ready" ? savedLabel(state.state.unsaved) : void 0].filter((part) => part !== void 0).join(" · ");
4285
+ const appVersions = state.status === "ready" ? state.state.appVersions : void 0;
4286
+ const versionsLabel = [appVersions?.blend === void 0 ? void 0 : `Blend ${appVersions.blend}`, appVersions?.framework === void 0 ? void 0 : `ACRYL Blends ${appVersions.framework}`].filter((part) => part !== void 0).join(" · ");
4283
4287
  const preview = frameView.mode === "preview";
4284
4288
  const selected = useStore(selection).selection;
4285
4289
  (0, react.useEffect)(() => {
@@ -4367,6 +4371,11 @@ window.__ModuleLoader__.load({
4367
4371
  children: ["Not reloaded: ", appError]
4368
4372
  }),
4369
4373
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: "acrylBlendsGrow" }),
4374
+ versionsLabel !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("small", {
4375
+ className: "acrylBlendsVersions",
4376
+ title: "Your Blend's version (blend.yaml) and the ACRYL Blends framework it runs on",
4377
+ children: versionsLabel
4378
+ }),
4370
4379
  !preview && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
4371
4380
  type: "button",
4372
4381
  className: "acrylBlendsSelectButton",
@@ -17604,9 +17613,13 @@ window.__ModuleLoader__.load({
17604
17613
  */
17605
17614
  /** The command another app runs to take a shared plugin, from its repository address and version. */
17606
17615
  function pullCommand(shared) {
17616
+ const onNpm = /^https:\/\/www\.npmjs\.com\/package\/(.+)$/u.exec(shared.url);
17617
+ if (onNpm !== null) return `npm run acryl -- plugin pull npm:${onNpm[1] ?? ""}@${shared.version}`;
17607
17618
  const where = /^https:\/\/github\.com\/([^/]+)\/([^/#?]+)/u.exec(shared.url);
17608
17619
  return where === null ? void 0 : `npm run acryl -- plugin pull github:${where[1] ?? ""}/${where[2] ?? ""}@${shared.version}`;
17609
17620
  }
17621
+ /** Where a share went, in words: npm or GitHub. */
17622
+ const sharedOn = (shared) => /^https:\/\/www\.npmjs\.com\//u.test(shared.url) ? "npm" : "GitHub";
17610
17623
  /** What to send a colleague so they can add a shared plugin: the address the Registry tab's "Add by address" takes. */
17611
17624
  function colleagueAddress(shared) {
17612
17625
  const where = /^https:\/\/github\.com\/([^/]+)\/([^/#?]+)/u.exec(shared.url);
@@ -47634,6 +47647,7 @@ body[data-bf-settings-full] { --bf-pane-h: calc(100vh - 24px); }
47634
47647
  const [details, setDetails] = (0, react.useState)(false);
47635
47648
  const [copied, setCopied] = (0, react.useState)(void 0);
47636
47649
  const [owner, setOwner] = (0, react.useState)("");
47650
+ const [askedNpm, setAskedNpm] = (0, react.useState)(false);
47637
47651
  (0, react.useEffect)(() => {
47638
47652
  let live = true;
47639
47653
  readGithub().then((answer) => {
@@ -47672,6 +47686,7 @@ body[data-bf-settings-full] { --bf-pane-h: calc(100vh - 24px); }
47672
47686
  const ask = async (target) => {
47673
47687
  if (share === void 0) return;
47674
47688
  setDetails(false);
47689
+ setAskedNpm(target === "npm");
47675
47690
  setState({
47676
47691
  step: "working",
47677
47692
  what: "Checking…"
@@ -47814,7 +47829,7 @@ body[data-bf-settings-full] { --bf-pane-h: calc(100vh - 24px); }
47814
47829
  },
47815
47830
  children: choice.button
47816
47831
  })] }, choice.title)) })] }),
47817
- state.step === "confirm" || state.step === "working" ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(GithubNote, {
47832
+ state.step === "confirm" || state.step === "working" || state.step === "failed" && askedNpm ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(GithubNote, {
47818
47833
  github,
47819
47834
  copy,
47820
47835
  connect: connectGithub,
@@ -48275,7 +48290,9 @@ body[data-bf-settings-full] { --bf-pane-h: calc(100vh - 24px); }
48275
48290
  title: "GitHub says this repository no longer exists; Share publishes it again",
48276
48291
  children: [plugin.shared.url.replace(/^https:\/\//u, ""), " is gone"]
48277
48292
  }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
48278
- "Shared on GitHub:",
48293
+ "Shared on ",
48294
+ sharedOn(plugin.shared),
48295
+ ":",
48279
48296
  " ",
48280
48297
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("a", {
48281
48298
  className: "acrylBlendsShared",
@@ -49670,6 +49687,8 @@ body[data-dsh-desktop-platform="darwin"] .acrylBlendsBar { padding-left: 78px; }
49670
49687
  .acrylBlendsAppName small { color: var(--bf-dim); font-weight: 400; margin-left: 6px; font-size: 12px; }
49671
49688
  .acrylBlendsAppError { min-width: 0; max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--bf-error); }
49672
49689
  .acrylBlendsGrow { flex: 1; }
49690
+ .acrylBlendsVersions { color: var(--bf-dim); font-size: 11px; white-space: nowrap; margin-right: 8px; user-select: text; }
49691
+ @media (max-width: 640px) { .acrylBlendsVersions { display: none; } }
49673
49692
  .acrylBlendsIconButton { width: 28px; height: 26px; display: grid; place-items: center; border-radius: 6px; border: 0; background: transparent; color: var(--bf-text-2); cursor: pointer; }
49674
49693
  .acrylBlendsIconButton:hover:not(:disabled) { background: var(--bf-surface-2); }
49675
49694
  .acrylBlendsIconButton[aria-pressed="true"] { color: var(--bf-strong); background: var(--bf-surface-2); }